]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix test for 4-byte load from remote_port on big-endian
authorJakub Sitnicki <jakub@cloudflare.com>
Sat, 19 Mar 2022 18:33:56 +0000 (19:33 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Mar 2022 01:59:00 +0000 (18:59 -0700)
commit00a24ad91841b57d64f860b454f78b2d80a07258
treea68caed04866465d23d56a0ce32220741231745a
parent4bd8cd39227b12977fd6178ee771169a46a1a66a
selftests/bpf: Fix test for 4-byte load from remote_port on big-endian

The context access converter rewrites the 4-byte load from
bpf_sk_lookup->remote_port to a 2-byte load from bpf_sk_lookup_kern
structure.

It means that we cannot treat the destination register contents as a 32-bit
value, or the code will not be portable across big- and little-endian
architectures.

This is exactly the same case as with 4-byte loads from bpf_sock->dst_port
so follow the approach outlined in [1] and treat the register contents as a
16-bit value in the test.

[1]: https://lore.kernel.org/bpf/20220317113920.1068535-5-jakub@cloudflare.com/

Fixes: 306ecb352f97 ("selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup")
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220319183356.233666-4-jakub@cloudflare.com
tools/testing/selftests/bpf/progs/test_sk_lookup.c