diff mbox series

[net-next,2/2] netdevsim: copy addresses for both in and out paths

Message ID 20241008122134.4343-3-liuhangbin@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series netdevsim: better ipsec output format. | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 6 this patch: 6
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-10-09--06-00 (tests: 775)

Commit Message

Hangbin Liu Oct. 8, 2024, 12:21 p.m. UTC
The 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

Fixes: 7699353da875 ("netdevsim: add ipsec offload testing")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 drivers/net/netdevsim/ipsec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Simon Horman Oct. 9, 2024, 12:21 p.m. UTC | #1
On Tue, Oct 08, 2024 at 12:21:34PM +0000, Hangbin Liu wrote:
> The 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
> 
> Fixes: 7699353da875 ("netdevsim: add ipsec offload testing")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c
index 102b0955eb04..88187dd4eb2d 100644
--- a/drivers/net/netdevsim/ipsec.c
+++ b/drivers/net/netdevsim/ipsec.c
@@ -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));