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(-)
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@canonical.com/
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(-)
--
2.43.0
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@canonical.com/ > > 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@vger.kernel.org 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
On Wed, 9 Sep 2026 14:37:41 +0100 Andrei Gherzan wrote: > I forgot to add Cc: stable@vger.kernel.org to these patches. We don't generally send documentation and test fixes to stable in netdev Especially now that stable is busy enough with all the AI-found bugs In fact I'm stripping the Fixes tags, too. > 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)? No need. Thanks for the changes!
© 2016 - 2026 Red Hat, Inc.