Skip to content

Commit 9db6a9c

Browse files
liuhangbinvijay-suman
authored andcommitted
netdevsim: print human readable IP address
Currently, IPSec addresses are printed in hexadecimal format, which is not user-friendly. e.g. # cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20 sa[0] rx ipaddr=0x00000000 00000000 00000000 0100a8c0 sa[0] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] tx ipaddr=0x00000000 00000000 00000000 00000000 sa[1] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 This patch updates the code to print the IPSec address in a human-readable format for easier debug. e.g. # cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=4 tx=40 sa[0] tx ipaddr=0.0.0.0 sa[0] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] rx ipaddr=192.168.0.1 sa[1] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 sa[2] tx ipaddr=:: sa[2] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[2] key=0x3167608a ca4f1397 43565909 941fa627 sa[3] rx ipaddr=2000::1 sa[3] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[3] key=0x3167608a ca4f1397 43565909 941fa627 Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit c71bc6d) Orabug: 37547931 Signed-off-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Liam Merwick <[email protected]> Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 18d445d commit 9db6a9c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/net/netdevsim/ipsec.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
3939
if (!sap->used)
4040
continue;
4141

42-
p += scnprintf(p, bufsize - (p - buf),
43-
"sa[%i] %cx ipaddr=0x%08x %08x %08x %08x\n",
44-
i, (sap->rx ? 'r' : 't'), sap->ipaddr[0],
45-
sap->ipaddr[1], sap->ipaddr[2], sap->ipaddr[3]);
42+
if (sap->xs->props.family == AF_INET6)
43+
p += scnprintf(p, bufsize - (p - buf),
44+
"sa[%i] %cx ipaddr=%pI6c\n",
45+
i, (sap->rx ? 'r' : 't'), &sap->ipaddr);
46+
else
47+
p += scnprintf(p, bufsize - (p - buf),
48+
"sa[%i] %cx ipaddr=%pI4\n",
49+
i, (sap->rx ? 'r' : 't'), &sap->ipaddr[3]);
4650
p += scnprintf(p, bufsize - (p - buf),
4751
"sa[%i] spi=0x%08x proto=0x%x salt=0x%08x crypt=%d\n",
4852
i, be32_to_cpu(sap->xs->id.spi),

0 commit comments

Comments
 (0)