netdevsim: better ipsec output format
Subsystems (4)
v2 cover netdevsim: better ipsec output format
The first 2 patches improve the netdevsim ipsec debug output with better format. The 3rd patch update the selftests.
v2: update rtnetlink selftest with new output format (Stanislav Fomichev, Jakub Kicinski)
Hangbin Liu (3):
netdevsim: print human readable IP address
netdevsim: copy addresses for both in and out paths
selftests: rtnetlink: update netdevsim ipsec output format
drivers/net/netdevsim/ipsec.c | 23 +++++++++++++---------- tools/testing/selftests/net/rtnetlink.sh | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v2 1/3 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
--- drivers/net/netdevsim/ipsec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/netdevsim/ipsec.c +8 -4
@@ -39,10 +39,14 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,if (!sap->used)continue ; - p +=scnprintf (p, bufsize - (p - buf), -"sa[%i] %cx ipaddr=0x%08x %08x %08x %08x\n" , - i, (sap->rx ?'r' :'t' ), sap->ipaddr[0 ], - sap->ipaddr[1 ], sap->ipaddr[2 ], sap->ipaddr[3 ]); +if (sap->xs->props.family ==AF_INET6 ) + p +=scnprintf (p, bufsize - (p - buf), +"sa[%i] %cx ipaddr=%pI6c\n" , + i, (sap->rx ?'r' :'t' ), &sap->ipaddr); +else + p +=scnprintf (p, bufsize - (p - buf), +"sa[%i] %cx ipaddr=%pI4\n" , + i, (sap->rx ?'r' :'t' ), &sap->ipaddr[3 ]); p += scnprintf(p, bufsize - (p - buf), "sa[%i] spi=0x%08x proto=0x%x salt=0x%08x crypt=%d\n", i, be32_to_cpu(sap->xs->id.spi),
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v2 2/3 netdevsim: copy addresses for both in and out paths
In reply to Hangbin LiuThe current code only copies the address for the in path, leaving the out path address set to 0. This patch corrects the issue by copying the addresses for both the in and out paths. Before this patch:
# cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20 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
After this patch:
= cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20
sa[0] tx ipaddr=192.168.0.2
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
--- drivers/net/netdevsim/ipsec.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/netdevsim/ipsec.c +5 -6
@@ -180,14 +180,13 @@ static int nsim_ipsec_add_sa(struct xfrm_state *xs,return ret; } -if (xs->xso.dir ==XFRM_DEV_OFFLOAD_IN ) { +if (xs->xso.dir ==XFRM_DEV_OFFLOAD_IN ) sa.rx = true; -if (xs->props.family ==AF_INET6 ) -memcpy (sa.ipaddr, &xs->id.daddr.a6,16 ); -else -memcpy (&sa.ipaddr[3 ], &xs->id.daddr.a4,4 ); - } +if (xs->props.family ==AF_INET6 ) +memcpy (sa.ipaddr, &xs->id.daddr.a6,16 ); +else +memcpy (&sa.ipaddr[3 ], &xs->id.daddr.a4,4 );/* the preparations worked, so save the info */ memcpy (&ipsec->sa[sa_idx], &sa,sizeof (sa));
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v2 3/3 selftests: rtnetlink: update netdevsim ipsec output format
In reply to Hangbin LiuAfter the netdevsim update to use human-readable IP address formats for IPsec, we can now use the source and destination IPs directly in testing. Here is the result:
# ./rtnetlink.sh -t kci_test_ipsec_offload PASS: ipsec_offload
--- tools/testing/selftests/net/rtnetlink.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/rtnetlink.sh +2 -2
@@ -809,10 +809,10 @@ kci_test_ipsec_offload() # does driver have correct offload info run_cmd diff $sysfsf - << EOF SA count=2 tx=3 -sa[0] tx ipaddr=0x00000000 00000000 00000000 00000000 +sa[0] tx ipaddr=$dstip sa[0] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1 sa[0] key=0x34333231 38373635 32313039 36353433 -sa[1] rx ipaddr=0x00000000 00000000 00000000 037ba8c0 +sa[1] rx ipaddr=$srcip sa[1] spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1 sa[1] key=0x34333231 38373635 32313039 36353433 EOF
Signature · 1 line
2.39.5 (Apple Git-154)
Re: [PATCHv2 net-next 3/3] selftests: rtnetlink: update netdevsim ipsec output format
Quoted 7 lines · Hangbin Liu
After the netdevsim update to use human-readable IP address formats for IPsec, we can now use the source and destination IPs directly in testing. Here is the result:
# ./rtnetlink.sh -t kci_test_ipsec_offload PASS: ipsec_offloadSigned-off-by Hangbin Liu <[email protected]>
Thank you!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Thu, 10 Oct 2024 04:00:24 +0000 you wrote:
The first 2 patches improve the netdevsim ipsec debug output with better format. The 3rd patch update the selftests.
v2: update rtnetlink selftest with new output format (Stanislav Fomichev, Jakub Kicinski)
Hangbin Liu (3):
netdevsim: print human readable IP address
netdevsim: copy addresses for both in and out paths
selftests: rtnetlink: update netdevsim ipsec output format[...]
Here is the summary with links:
- [PATCHv2,net-next,1/3] netdevsim: print human readable IP address
https://git.kernel.org/netdev/net-next/c/c71bc6da6198 - [PATCHv2,net-next,2/3] netdevsim: copy addresses for both in and out paths https://git.kernel.org/netdev/net-next/c/2cf567f421db - [PATCHv2,net-next,3/3] selftests: rtnetlink: update netdevsim ipsec output format https://git.kernel.org/netdev/net-next/c/3ec920bb978c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html