]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix tc_redirect_dtime
authorMartin KaFai Lau <kafai@fb.com>
Wed, 1 Jun 2022 23:40:50 +0000 (16:40 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 3 Jun 2022 21:53:33 +0000 (14:53 -0700)
commitd5efd0db6e9d8236e0d6f2ac1dc2d725e95e0c5f
treef13341d365d697ced4cbcffb3e189505c331317e
parent6fb833213ba9e0afeed603d7857e4d5f310f009b
selftests/bpf: Fix tc_redirect_dtime

tc_redirect_dtime was reported flaky from time to time.  It
always fails at the udp test and complains about the bpf@tc-ingress
got a skb->tstamp when handling udp packet.  It is unexpected
because the skb->tstamp should have been cleared when crossing
different netns.

The most likely cause is that the skb is actually a tcp packet
from the earlier tcp test.  It could be the final TCP_FIN handling.

This patch tightens the skb->tstamp check in the bpf prog.  It ensures
the skb is the current testing traffic.  First, it checks that skb
matches the IPPROTO of the running test (i.e. tcp vs udp).
Second, it checks the server port (dst_ns_port).  The server
port is unique for each test (50000 + test_enum).

Also fixed a typo in test_udp_dtime(): s/P100/P101/

Fixes: 0157dc4293bc ("bpf: selftests: test skb->tstamp in redirect_neigh")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20220601234050.2572671-1-kafai@fb.com
tools/testing/selftests/bpf/prog_tests/tc_redirect.c
tools/testing/selftests/bpf/progs/test_tc_dtime.c