[SRU][Q][PATCH 1/1] UBUNTU: [SAUCE] Fix selftest/net/rtnetlink.sh for Big Endian

Alessio Faina alessio.faina at canonical.com
Fri Dec 12 11:14:59 UTC 2025


When running on a Big endian machine, the rtnetlink.sh script,
part of the net/selftest kernel suite, will fail as one of its
tests (kci_test_ipsec_offload) is expecting to read some keys
from memory and getting them returned with a predefined order.

```
sa[0]    spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
sa[0]    key=0x34333231 38373635 32313039 36353433
```

The problem arises from the driver that writes into the
/sys/kernel/debug/netdevsim/netdevsim0/ports/0//ipsec interface
using the internal CPU byte ordering sequence, generating a different
result and a failure.

--------------------------------------------------------------------
$ sudo ./rtnetlink.sh -t kci_test_ipsec_offload -v
.....
COMMAND: diff /sys/kernel/debug/netdevsim/netdevsim0/ports/0//ipsec -
    3,4c3,4
< sa[0]    spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
< sa[0]    key=0x31323334 35363738 39303132 33343536
---
> sa[0]    spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
> sa[0]    key=0x34333231 38373635 32313039 36353433
6,7c6,7
< sa[1]    spi=0x00000009 proto=0x32 salt=0x64636261 crypt=1
< sa[1]    key=0x31323334 35363738 39303132 33343536
---
> sa[1]    spi=0x00000009 proto=0x32 salt=0x61626364 crypt=1
> sa[1]    key=0x34333231 38373635 32313039 36353433
FAIL: ipsec_offload incorrect driver data

FAIL: ipsec_offload
--------------------------------------------------------------------

This patch tries to fix the behaviour by detecting the CPU byte order
and switch the order of the keys, so the final comparison block will
be the same for both architectures.

After this patch is applied, the result is the following:

--------------------------------------------------------------------
$ sudo ./rtnetlink.sh -t kci_test_ipsec_offload
PASS: ipsec_offload
--------------------------------------------------------------------

No regression is expected from this patch as it's targeting only
a selftest patch.

Signed-off-by: Alessio Faina <alessio.faina at canonical.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index d6c00efeb664..ed547eb1ac15 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -713,7 +713,14 @@ kci_test_ipsec()
 kci_test_ipsec_offload()
 {
 	local ret=0
-	algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
+	lscpu | grep "Byte Order" | grep "Big" > /dev/null
+	isLittleEndian=$?
+	# If Big Endian invert key elements to use the same parsing for both endiannesses
+	if [ "$isLittleEndian" == "1" ]; then
+		algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"
+	else
+		algo="aead rfc4106(gcm(aes)) 0x3433323138373635323130393635343361626364 128"
+	fi
 	srcip=192.168.123.3
 	dstip=192.168.123.4
 	sysfsd=/sys/kernel/debug/netdevsim/netdevsim0/ports/0/
-- 
2.43.0




More information about the kernel-team mailing list