diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2020-09-15 13:39:28 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-09-19 01:01:18 +0200 |
commit | fec47bbc10b243690f5d0ee484a0bbdee273e71b (patch) | |
tree | db40259d9394e53727ab2328412577b4badbf1da /tools | |
parent | selftests/bpf: Fix endianness issue in sk_assign (diff) | |
download | linux-fec47bbc10b243690f5d0ee484a0bbdee273e71b.tar.xz linux-fec47bbc10b243690f5d0ee484a0bbdee273e71b.zip |
selftests/bpf: Fix endianness issue in test_sockopt_sk
getsetsockopt() calls getsockopt() with optlen == 1, but then checks
the resulting int. It is ok on little endian, but not on big endian.
Fix by checking char instead.
Fixes: 8a027dc0d8f5 ("selftests/bpf: add sockopt test that exercises sk helpers")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200915113928.3768496-1-iii@linux.ibm.com
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c index 5f54c6aec7f0..b25c9c45c148 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c @@ -45,9 +45,9 @@ static int getsetsockopt(void) goto err; } - if (*(int *)big_buf != 0x08) { + if (*big_buf != 0x08) { log_err("Unexpected getsockopt(IP_TOS) optval 0x%x != 0x08", - *(int *)big_buf); + (int)*big_buf); goto err; } |