Skip to content

netdevsim: fix IPsec debugfs byte order

Andrei Gherzan linux-kselftest lkml netdev 1 version Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2netdevsim: print IPsec salt/key in network byte orderdrivers/net/netdevsim/ipsec.c drivers/net/netdevsim/netdevsim.h+7 -70 repliesApplied
2/2selftests: rtnetlink: update ipsec_offload expected outputtools/testing/selftests/net/rtnetlink.sh+4 -40 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/2] netdevsim: fix IPsec debugfs byte order

The netdevsim IPsec debugfs file (used by selftests/net/rtnetlink.sh's ipsec_offload subtest) prints the SA salt and key in host CPU byte order instead of network byte order, because nsim_sa.key[]/salt are typed as plain u32 and printed directly with "%08x". This makes the reported values differ between little-endian and big-endian hosts for the same underlying key material, and breaks the selftest on big-endian (e.g. s390x), which hardcodes the little-endian output.

A driver-side fix was proposed in 2022 but stalled in review: keeping the fields as plain u32 meant sparse could not validate the added ntohl()/be32_to_cpu() conversions.

https://lore.kernel.org/netdev/[email protected]/

This series:

1/2 retypes nsim_sa.key[]/salt to __be32 (matching the existing
__be32 ipaddr[] field) and converts with be32_to_cpu() before printing, so the debugfs output is now network-order on every host, independent of endianness.

2/2 updates the selftest's expected output to match the new,
endianness-independent values. It depends on 1/2: applied on its own it would regress little-endian hosts (though it happens to have no effect on big-endian hosts, whose old host-order output already matched the new expected values).

Tested on real booted kernels, both patches applied:
- x86_64 (little-endian): PASS: ipsec_offload
- s390x (big-endian): PASS: ipsec_offload

checkpatch.pl --strict and sparse (make C=2) are clean on both patches.

Andrei Gherzan (2):
netdevsim: print IPsec salt/key in network byte order
selftests: rtnetlink: update ipsec_offload expected output

 drivers/net/netdevsim/ipsec.c            | 10 +++++-----
 drivers/net/netdevsim/netdevsim.h        |  4 ++--
 tools/testing/selftests/net/rtnetlink.sh |  8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0