summaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2019-07-19 11:06:11 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-29 08:28:28 +0200
commitb7038c195fd172b322ed1bf71d62ca3674407077 (patch)
tree460dddc3cbb4c7cf4ccb76b0626376ed8a68e65f /tools/testing
parente6dc6409f47446ba632b8bd7415529e5986d99a2 (diff)
downloadlinux-stable-b7038c195fd172b322ed1bf71d62ca3674407077.tar.gz
linux-stable-b7038c195fd172b322ed1bf71d62ca3674407077.tar.bz2
linux-stable-b7038c195fd172b322ed1bf71d62ca3674407077.zip
selftests/bpf: fix sendmsg6_prog on s390
[ Upstream commit c8eee4135a456bc031d67cadc454e76880d1afd8 ] "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 <iii@linux.ibm.com> Acked-by: Andrey Ignatov <rdna@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/bpf/sendmsg6_prog.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/sendmsg6_prog.c b/tools/testing/selftests/bpf/sendmsg6_prog.c
index 5aeaa284fc47..a68062820410 100644
--- a/tools/testing/selftests/bpf/sendmsg6_prog.c
+++ b/tools/testing/selftests/bpf/sendmsg6_prog.c
@@ -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);