Skip to content

Commit

Permalink
selftests/bpf: Fix endianness issue in test_sockopt_sk
Browse files Browse the repository at this point in the history
[ Upstream commit fec47bb ]

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: 8a027dc ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
iii-i authored and gregkh committed Oct 29, 2020
1 parent f130c8a commit 98d66a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/sockopt_sk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 98d66a3

Please sign in to comment.