Message ID | 20200909232443.3099637-2-iii@linux.ibm.com |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | Fix three endianness issues in test_progs | expand |
On Wed, Sep 9, 2020 at 7:52 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote: > > 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: 8a027dc0 ("selftests/bpf: add sockopt test that exercises sk helpers") > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> > --- > tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c > index 5f54c6aec7f0..ba4da50987d6 100644 > --- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c > +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c > @@ -45,7 +45,7 @@ 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 here? > goto err; > -- > 2.25.4 >
diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c index 5f54c6aec7f0..ba4da50987d6 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c @@ -45,7 +45,7 @@ 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); goto err;
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: 8a027dc0 ("selftests/bpf: add sockopt test that exercises sk helpers") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)