Commit c4708bf3 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'netdevsim-better-ipsec-output-format'

Hangbin Liu says:

====================
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)
====================

Link: https://patch.msgid.link/20241010040027.21440-1-liuhangbin@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 5e7e69ba 3ec920bb
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -39,10 +39,14 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
		if (!sap->used)
			continue;

		if (sap->xs->props.family == AF_INET6)
			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]);
				       "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),
@@ -176,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);
	}

	/* the preparations worked, so save the info */
	memcpy(&ipsec->sa[sa_idx], &sa, sizeof(sa));
+2 −2
Original line number Diff line number Diff line
@@ -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