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

From: Andrei Gherzan

Date: Wed Sep 09 2026 - 10:12:18 EST


On 26/09/08 03:03PM, Andrei Gherzan wrote:
> 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/20220308135106.890270-1-kleber.souza@xxxxxxxxxxxxx/
>
> 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).
>

I forgot to add Cc: stable@xxxxxxxxxxxxxxx to these patches. Should I
send a v2 for that, given patch 2/2 only makes sense together with
patch 1/2 (applying just one regresses the test on one endianness or
the other)?

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

--
Andrei Gherzan
gpg: rsa4096/D4D94F67AD0E9640

Attachment: signature.asc
Description: PGP signature