Skip to content

Commit 2cf567f

Browse files
liuhangbinkuba-moo
authored andcommitted
netdevsim: copy addresses for both in and out paths
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: 7699353 ("netdevsim: add ipsec offload testing") 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]>
1 parent c71bc6d commit 2cf567f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/net/netdevsim/ipsec.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,13 @@ static int nsim_ipsec_add_sa(struct xfrm_state *xs,
180180
return ret;
181181
}
182182

183-
if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) {
183+
if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN)
184184
sa.rx = true;
185185

186-
if (xs->props.family == AF_INET6)
187-
memcpy(sa.ipaddr, &xs->id.daddr.a6, 16);
188-
else
189-
memcpy(&sa.ipaddr[3], &xs->id.daddr.a4, 4);
190-
}
186+
if (xs->props.family == AF_INET6)
187+
memcpy(sa.ipaddr, &xs->id.daddr.a6, 16);
188+
else
189+
memcpy(&sa.ipaddr[3], &xs->id.daddr.a4, 4);
191190

192191
/* the preparations worked, so save the info */
193192
memcpy(&ipsec->sa[sa_idx], &sa, sizeof(sa));

0 commit comments

Comments
 (0)