selftests/bpf: Fix tc_redirect_dtime
Subsystems (3)
PATCH 1/1 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/
--- .../selftests/bpf/prog_tests/tc_redirect.c | 8 +-- .../selftests/bpf/progs/test_tc_dtime.c | 53 ++++++++++++++++++- 2 files changed, 55 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/tc_redirect.c +4 -4
@@ -646,7 +646,7 @@ static void test_tcp_clear_dtime(struct test_tc_dtime *skel)__u32 *errs = skel->bss->errs[t]; skel->bss->test = t; -test_inet_dtime (AF_INET6 ,SOCK_STREAM ,IP6_DST ,0 ); +test_inet_dtime (AF_INET6 ,SOCK_STREAM ,IP6_DST ,50000 + t);ASSERT_EQ (dtimes[INGRESS_FWDNS_P100 ],0 ,dtime_cnt_str (t,INGRESS_FWDNS_P100 ));
@@ -683,7 +683,7 @@ static void test_tcp_dtime(struct test_tc_dtime *skel, int family, bool bpf_fwd) errs = skel->bss->errs[t]; skel->bss->test = t; -test_inet_dtime (family,SOCK_STREAM , addr,0 ); +test_inet_dtime (family,SOCK_STREAM , addr,50000 + t);/* fwdns_prio100 prog does not read delivery_time_type, so * kernel puts the (rcv) timetamp in __sk_buff->tstamp
@@ -715,13 +715,13 @@ static void test_udp_dtime(struct test_tc_dtime *skel, int family, bool bpf_fwd) errs = skel->bss->errs[t]; skel->bss->test = t; -test_inet_dtime (family,SOCK_DGRAM , addr,0 ); +test_inet_dtime (family,SOCK_DGRAM , addr,50000 + t);ASSERT_EQ (dtimes[INGRESS_FWDNS_P100 ],0 ,dtime_cnt_str (t,INGRESS_FWDNS_P100 ));/* non mono delivery time is not forwarded */ ASSERT_EQ (dtimes[INGRESS_FWDNS_P101 ],0 , -dtime_cnt_str (t,INGRESS_FWDNS_P100 )); +dtime_cnt_str (t,INGRESS_FWDNS_P101 ));for (i =EGRESS_FWDNS_P100 ; i <SET_DTIME ; i++)ASSERT_GT (dtimes[i],0 ,dtime_cnt_str (t, i));
tools/testing/selftests/bpf/progs/test_tc_dtime.c +51 -2
95 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 16 lines · Martin KaFai Lau
tc_redirect_dtimewas reported flaky from time to time. It always fails at the udp test and complains about the bpf@tc-ingress got askb->tstampwhen handling udp packet. It is unexpected because theskb->tstampshould 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_FINhandling.This patch tightens the
skb->tstampcheck 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).
Quoted 5 lines
Also fixed a typo in
test_udp_dtime(): s/P100/P101/Fixes c803475fd8dd ("bpf: selftests: test skb->tstamp in redirect_neigh")Reported-by Andrii Nakryiko <[email protected]>Signed-off-by Martin KaFai Lau <[email protected]>
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 10 lines · On Wed, 1 Jun 2022 16:40:50 -0700 you wrote:
tc_redirect_dtimewas reported flaky from time to time. It always fails at the udp test and complains about the bpf@tc-ingress got askb->tstampwhen handling udp packet. It is unexpected because theskb->tstampshould 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_FINhandling.[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Fix tc_redirect_dtime
https://git.kernel.org/bpf/bpf-next/c/f7dd4cfb82db
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html