From: Martin KaFai Lau <martin.lau@linux.dev>
To: Geliang Tang <geliang@kernel.org>
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>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Geliang Tang <tanggeliang@kylinos.cn>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v6 1/9] selftests/bpf: Add backlog for network_helper_opts
Date: Wed, 3 Jul 2024 14:34:38 -0700 [thread overview]
Message-ID: <5b9f6be0-96f3-4471-9852-cf87c4845f7a@linux.dev> (raw)
In-Reply-To: <7ee521c76e45a536da7940c19a4d8de235e63e78.1719623708.git.tanggeliang@kylinos.cn>
On 6/28/24 6:20 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Some callers expect __start_server() helper to pass their own "backlog"
> value to listen() instead of the default of 1. So this patch adds struct
> member "backlog" for network_helper_opts to allow callers to set "backlog"
> value via start_server_str() helper.
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/bpf/network_helpers.c | 2 +-
> tools/testing/selftests/bpf/network_helpers.h | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 44c2c8fa542a..16cbb3fdcabf 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c
> @@ -106,7 +106,7 @@ static int __start_server(int type, const struct sockaddr *addr, socklen_t addrl
> }
>
> if (type == SOCK_STREAM) {
> - if (listen(fd, 1) < 0) {
> + if (listen(fd, opts->backlog ? : 1) < 0) {
iirc, listen(fd, 0 /* backlog */) can be used to enforce syncookie. Meaning
backlog 0 is a legit value.
Using 0 as a default and changing it to 1 here is fine. It makes the test
program easier to write for the common case. Enforcing syncookie mode by using
backlog 0 is a niche use case but it should at least have a way for the caller
to do that.
May be using -ve backlog to do that, like
if (listen(fd, opts->backlog ? max(opts->backlog, 0): 1) < 0)
> log_err("Failed to listed on socket");
> goto error_close;
> }
> diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h
> index 9ea36524b9db..8339c4e4b075 100644
> --- a/tools/testing/selftests/bpf/network_helpers.h
> +++ b/tools/testing/selftests/bpf/network_helpers.h
> @@ -25,6 +25,7 @@ struct network_helper_opts {
> int timeout_ms;
> bool must_fail;
> int proto;
> + int backlog;
and add a comment here to explain the meaning of the -ve backlog.
> int (*post_socket_cb)(int fd, void *opts);
> void *cb_opts;
> };
next prev parent reply other threads:[~2024-07-03 21:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-29 1:20 [PATCH bpf-next v6 0/9] use network helpers, part 8 Geliang Tang
2024-06-29 1:20 ` [PATCH bpf-next v6 1/9] selftests/bpf: Add backlog for network_helper_opts Geliang Tang
2024-07-03 21:34 ` Martin KaFai Lau [this message]
2024-06-29 1:20 ` [PATCH bpf-next v6 2/9] selftests/bpf: Use start_server_str in sockmap_ktls Geliang Tang
2024-07-03 21:39 ` Martin KaFai Lau
2024-06-29 1:20 ` [PATCH bpf-next v6 3/9] selftests/bpf: Use connect_to_fd " Geliang Tang
2024-07-03 21:47 ` Martin KaFai Lau
2024-06-29 1:20 ` [PATCH bpf-next v6 4/9] selftests/bpf: Use make_sockaddr " Geliang Tang
2024-06-29 1:20 ` [PATCH bpf-next v6 5/9] selftests/bpf: Close fd in error path in drop_on_reuseport Geliang Tang
2024-06-29 1:20 ` [PATCH bpf-next v6 6/9] selftests/bpf: Use start_server_str in sk_lookup Geliang Tang
2024-07-03 21:53 ` Martin KaFai Lau
2024-06-29 1:20 ` [PATCH bpf-next v6 7/9] selftests/bpf: Use connect_to_fd " Geliang Tang
2024-06-29 1:20 ` [PATCH bpf-next v6 8/9] selftests/bpf: Use connect_to_addr " Geliang Tang
2024-07-03 21:58 ` Martin KaFai Lau
2024-06-29 1:20 ` [PATCH bpf-next v6 9/9] selftests/bpf: Drop make_socket " Geliang Tang
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=5b9f6be0-96f3-4471-9852-cf87c4845f7a@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=eddyz87@gmail.com \
--cc=geliang@kernel.org \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tanggeliang@kylinos.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox