Skip to content

Commit 8bec4f6

Browse files
lmbborkmann
authored andcommitted
selftests: bpf: Ignore FIN packets for reuseport tests
The reuseport tests currently suffer from a race condition: FIN packets count towards DROP_ERR_SKB_DATA, since they don't contain a valid struct cmd. Tests will spuriously fail depending on whether check_results is called before or after the FIN is processed. Exit the BPF program early if FIN is set. Fixes: 91134d8 ("bpf: Test BPF_PROG_TYPE_SK_REUSEPORT") Signed-off-by: Lorenz Bauer <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Jakub Sitnicki <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c31dbb1 commit 8bec4f6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reuseport_md *reuse_md)
113113
data_check.skb_ports[0] = th->source;
114114
data_check.skb_ports[1] = th->dest;
115115

116+
if (th->fin)
117+
/* The connection is being torn down at the end of a
118+
* test. It can't contain a cmd, so return early.
119+
*/
120+
return SK_PASS;
121+
116122
if ((th->doff << 2) + sizeof(*cmd) > data_check.len)
117123
GOTO_DONE(DROP_ERR_SKB_DATA);
118124
if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy,

0 commit comments

Comments
 (0)