selftests/bpf: fix sendmsg6_prog on s390
Subsystems (5)
PATCH 1/1 selftests/bpf: fix sendmsg6_prog on s390
"sendmsg6: rewrite IP & port (C)" fails on s390, because the code in sendmsg_v6_prog() assumes that (ctx->user_ip6[0] & 0xFFFF) refers to leading IPv6 address digits, which is not the case on big-endian machines.
Since checking bitwise operations doesn't seem to be the point of the test, replace two short comparisons with a single int comparison.
--- tools/testing/selftests/bpf/progs/sendmsg6_prog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/sendmsg6_prog.c +1 -2
@@ -41,8 +41,7 @@ int sendmsg_v6_prog(struct bpf_sock_addr *ctx) }/* Rewrite destination. */ -if ((ctx->user_ip6[0 ] &0xFFFF ) ==bpf_htons (0xFACE ) && - ctx->user_ip6[0 ] >>16 ==bpf_htons (0xB00C )) { +if (ctx->user_ip6[0 ] ==bpf_htonl (0xFACEB00C )) { ctx->user_ip6[0 ] =bpf_htonl (DST_REWRITE_IP6_0 ); ctx->user_ip6[1 ] =bpf_htonl (DST_REWRITE_IP6_1 ); ctx->user_ip6[2 ] =bpf_htonl (DST_REWRITE_IP6_2 );
Signature · 1 line
2.21.0
Ilya Leoshkevich <[email protected]> [Fri, 2019-07-19 02:07 -0700]:
Quoted 9 lines
"sendmsg6: rewrite IP & port (C)" fails on s390, because the code in
sendmsg_v6_prog()assumes that (ctx->user_ip6[0] &0xFFFF) refers to leading IPv6 address digits, which is not the case on big-endian machines.Since checking bitwise operations doesn't seem to be the point of the test, replace two short comparisons with a single int comparison.
Signed-off-by Ilya Leoshkevich <[email protected]>
IIRC I did it this way to test 16bit loads from C program, but such loads are already tested by asm prog in test_sock_addr.c.
Thanks for the fix!
Quoted 21 lines
--- tools/testing/selftests/bpf/progs/sendmsg6_prog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/testing/selftests/bpf/progs/sendmsg6_prog.c +1
-2@@ -41,8 +41,7 @@ int sendmsg_v6_prog(struct bpf_sock_addr *ctx) }/* Rewrite destination. */ -if ((ctx->user_ip6[0 ] &0xFFFF ) ==bpf_htons (0xFACE ) && - ctx->user_ip6[0 ] >>16 ==bpf_htons (0xB00C )) { +if (ctx->user_ip6[0 ] ==bpf_htonl (0xFACEB00C )) { ctx->user_ip6[0 ] =bpf_htonl (DST_REWRITE_IP6_0 ); ctx->user_ip6[1 ] =bpf_htonl (DST_REWRITE_IP6_1 ); ctx->user_ip6[2 ] =bpf_htonl (DST_REWRITE_IP6_2 );Signature · 1 line
2.21.0
Signature · 1 line
Andrey Ignatov
Quoted 9 lines · Ilya Leoshkevich
"sendmsg6: rewrite IP & port (C)" fails on s390, because the code in
sendmsg_v6_prog()assumes that (ctx->user_ip6[0] &0xFFFF) refers to leading IPv6 address digits, which is not the case on big-endian machines.Since checking bitwise operations doesn't seem to be the point of the test, replace two short comparisons with a single int comparison.
Signed-off-by Ilya Leoshkevich <[email protected]>
Applied, thanks!