From: Lorenz Bauer <lmb@cloudflare.com>
To: Shuah Khan <shuah@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>
Cc: Lorenz Bauer <lmb@cloudflare.com>,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH bpf 2/4] selftests: bpf: ignore RST packets for reuseport tests
Date: Thu, 23 Jan 2020 16:59:31 +0000 [thread overview]
Message-ID: <20200123165934.9584-3-lmb@cloudflare.com> (raw)
In-Reply-To: <20200123165934.9584-1-lmb@cloudflare.com>
The reuseport tests currently suffer from a race condition: RST
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 RST is processed.
Exit the BPF program early if FIN is set.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
.../selftests/bpf/progs/test_select_reuseport_kern.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c
index d69a1f2bbbfd..26e77dcc7e91 100644
--- a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c
@@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reuseport_md *reuse_md)
data_check.skb_ports[0] = th->source;
data_check.skb_ports[1] = th->dest;
+ if (th->fin)
+ /* The connection is being torn down at the end of a
+ * test. It can't contain a cmd, so return early.
+ */
+ return SK_PASS;
+
if ((th->doff << 2) + sizeof(*cmd) > data_check.len)
GOTO_DONE(DROP_ERR_SKB_DATA);
if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy,
--
2.20.1
next prev parent reply other threads:[~2020-01-23 17:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200123165934.9584-1-lmb@cloudflare.com>
2020-01-23 16:59 ` [PATCH bpf 1/4] selftests: bpf: use a temporary file in test_sockmap Lorenz Bauer
2020-01-23 18:34 ` Martin Lau
2020-01-24 19:50 ` John Fastabend
2020-01-24 9:20 ` Jakub Sitnicki
2020-01-24 19:43 ` John Fastabend
2020-01-23 16:59 ` Lorenz Bauer [this message]
2020-01-23 17:16 ` [PATCH bpf 2/4] selftests: bpf: ignore RST packets for reuseport tests Martin Lau
2020-01-23 17:18 ` Lorenz Bauer
2020-01-23 21:53 ` Martin Lau
2020-01-24 9:00 ` Lorenz Bauer
2020-01-24 9:32 ` Daniel Borkmann
2020-01-24 19:45 ` John Fastabend
2020-01-23 16:59 ` [PATCH bpf 3/4] selftests: bpf: make reuseport test output more legible Lorenz Bauer
2020-01-23 17:26 ` Martin Lau
2020-01-24 19:46 ` John Fastabend
2020-01-23 16:59 ` [PATCH bpf 4/4] selftests: bpf: reset global state between reuseport test runs Lorenz Bauer
2020-01-23 17:56 ` Martin Lau
[not found] ` <20200124112754.19664-1-lmb@cloudflare.com>
2020-01-24 11:27 ` [PATCH bpf-next v2 1/4] selftests: bpf: use a temporary file in test_sockmap Lorenz Bauer
2020-01-24 11:27 ` [PATCH bpf-next v2 2/4] selftests: bpf: ignore FIN packets for reuseport tests Lorenz Bauer
2020-01-24 11:27 ` [PATCH bpf-next v2 3/4] selftests: bpf: make reuseport test output more legible Lorenz Bauer
2020-01-24 11:27 ` [PATCH bpf-next v2 4/4] selftests: bpf: reset global state between reuseport test runs Lorenz Bauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200123165934.9584-3-lmb@cloudflare.com \
--to=lmb@cloudflare.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).