From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jordan Rife <jrife@google.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
"Daniel T. Lee" <danieltimlee@gmail.com>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 1/4] selftests/bpf: Migrate *_POST_BIND test cases to prog_tests
Date: Mon, 21 Oct 2024 14:27:48 -0700 [thread overview]
Message-ID: <fb910573-41d8-47b5-8ab9-ecbc8df7a56b@linux.dev> (raw)
In-Reply-To: <20241017225031.2448426-2-jrife@google.com>
On 10/17/24 3:49 PM, Jordan Rife wrote:
> Move all BPF_CGROUP_INET6_POST_BIND and BPF_CGROUP_INET4_POST_BIND test
> cases to a new prog_test, prog_tests/sock_post_bind.c, except for
> LOAD_REJECT test cases.
>
> Signed-off-by: Jordan Rife <jrife@google.com>
> ---
> .../selftests/bpf/prog_tests/sock_post_bind.c | 417 ++++++++++++++++++
> tools/testing/selftests/bpf/test_sock.c | 245 ----------
> 2 files changed, 417 insertions(+), 245 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_post_bind.c
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/sock_post_bind.c b/tools/testing/selftests/bpf/prog_tests/sock_post_bind.c
> new file mode 100644
> index 000000000000..c46537e3b9d4
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/sock_post_bind.c
> @@ -0,0 +1,417 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/bpf.h>
> +#include <test_progs.h>
> +#include "cgroup_helpers.h"
> +
> +static char bpf_log_buf[4096];
> +static bool verbose;
How is verbose used and is it still needed?
[ ... ]
> + if (bind(sockfd, (const struct sockaddr *)&addr, len) == -1) {
> + /* sys_bind() may fail for different reasons, errno has to be
> + * checked to confirm that BPF program rejected it.
> + */
> + if (errno != EPERM)
> + goto err;
> + if (port_retry)
> + goto retry;
> + res = BIND_REJECT;
> + goto out;
> + }
[ ... ]
> +void test_sock_post_bind(void)
> +{
> + int cgroup_fd, i;
> +
> + cgroup_fd = test__join_cgroup("/post_bind");
> + if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup"))
nit. ASSERT_OK_FD().
Since the test binds to a specific ip/port, please run it in its own netns. It
is easy to do with netns_new and netns_free, a recent example:
https://lore.kernel.org/bpf/20241020-syncookie-v2-1-2db240225fed@bootlin.com/
The same netns can be reused for different subtests of this "sock_post_bind" test.
Others look good. Thanks for moving the test to test_progs.
pw-bot: cr
next prev parent reply other threads:[~2024-10-21 21:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 22:49 [PATCH bpf-next v1 0/4] Retire test_sock.c Jordan Rife
2024-10-17 22:49 ` [PATCH bpf-next v1 1/4] selftests/bpf: Migrate *_POST_BIND test cases to prog_tests Jordan Rife
2024-10-21 21:27 ` Martin KaFai Lau [this message]
2024-10-21 22:54 ` Jordan Rife
2024-10-17 22:49 ` [PATCH bpf-next v1 2/4] selftests/bpf: Migrate LOAD_REJECT " Jordan Rife
2024-10-17 22:49 ` [PATCH bpf-next v1 3/4] selftests/bpf: Migrate BPF_CGROUP_INET_SOCK_CREATE " Jordan Rife
2024-10-17 22:49 ` [PATCH bpf-next v1 4/4] selftests/bpf: Retire test_sock.c Jordan Rife
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=fb910573-41d8-47b5-8ab9-ecbc8df7a56b@linux.dev \
--to=martin.lau@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=danieltimlee@gmail.com \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jrife@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.