Skip to contentSkip to conversation

selftests/bpf: Fix endianness issue in sk_assign

PATCH Applied Ilya Leoshkevich 4 participants 4 messages Sep 16, 2020 – Sep 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/bpf: Fix endianness issue in sk_assign

server_map's value size is 8, but the test tries to put an int there. This sort of works on x86 (unless followed by non-0), but hard fails on s390.

Fix by using __s64 instead of int.

Fixes 2d7824ffd25c ("selftests: bpf: Add test for sk_assign")

---

v1->v2: Use __s64.

tools/testing/selftests/bpf/prog_tests/sk_assign.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sk_assign.c +1 -1
index a49a26f95a8b..3a469099f30d 100644
@@ -265,7 +265,7 @@ void test_sk_assign(void)
 		TEST("ipv6 udp port redir", AF_INET6, SOCK_DGRAM, false),
 		TEST("ipv6 udp addr redir", AF_INET6, SOCK_DGRAM, true),
 	};
-	int server = -1;
+	__s64 server = -1;
 	int server_map;
 	int self_net;
 	int i;
Signature · 1 line
2.25.4
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Ilya Leoshkevich

server_map's value size is 8, but the test tries to put an int there. This sort of works on x86 (unless followed by non-0), but hard fails on s390.

Quoted 7 lines

Fix by using __s64 instead of int.

Fixes 2d7824ffd25c ("selftests: bpf: Add test for sk_assign")

---

v1->v2: Use __s64.

Quoted 20 lines

tools/testing/selftests/bpf/prog_tests/sk_assign.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sk_assign.c +1 -2
index a49a26f95a8b..3a469099f30d 100644
@@ -265,7 +265,7 @@ void test_sk_assign(void)
                TEST("ipv6 udp port redir", AF_INET6, SOCK_DGRAM, false),
                TEST("ipv6 udp addr redir", AF_INET6, SOCK_DGRAM, true),
        };
-       int server = -1;
+       __s64 server = -1;
        int server_map;
        int self_net;
        int i;
--

2.25.4

reviewer Acked-by
#2 lore raw
Quoted 9 lines · Andrii Nakryiko
Quoted 7 lines · Ilya Leoshkevich

server_map's value size is 8, but the test tries to put an int there. This sort of works on x86 (unless followed by non-0), but hard fails on s390.

Fix by using __s64 instead of int.

Quoted 7 lines
Quoted 5 lines
Fixes 2d7824ffd25c ("selftests: bpf: Add test for sk_assign")

---

v1->v2: Use __s64.

[...]