From: Martin KaFai Lau <martin.lau@linux.dev>
To: Geliang Tang <geliang@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
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>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 02/14] selftests/bpf: Add start_server_addr* helpers
Date: Wed, 17 Apr 2024 17:08:06 -0700 [thread overview]
Message-ID: <6c64339b-70c0-40d4-94a5-75c8bdfb08ea@linux.dev> (raw)
In-Reply-To: <48186b788bc029cbd3a47007175c83357fa28668.1713262052.git.tanggeliang@kylinos.cn>
On 4/16/24 3:13 AM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> In order to pair up with connect_to_addr(), this patch adds a new helper
> start_server_addr(), and another one start_server_addr_opts(), which is
> a wrapper of __start_server(), only added a network_helper_opts arg at
> the end.
>
> They all accept an argument 'addr' of 'struct sockaddr_storage' type
> instead of a string type argument like start_server().
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/bpf/network_helpers.c | 16 ++++++++++++++++
> tools/testing/selftests/bpf/network_helpers.h | 3 +++
> 2 files changed, 19 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 563dde8617dd..836436688ca6 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c
> @@ -185,6 +185,22 @@ int *start_reuseport_server(int family, int type, const char *addr_str,
> return NULL;
> }
>
> +int start_server_addr_opts(int type, const struct sockaddr_storage *addr, socklen_t len,
> + const struct network_helper_opts *opts)
I meant to only add one helper with the "opts" arg in v2 instead of adding two
helpers. I want to minimize the number of new helpers and each just has
different variants of args. timeout_ms usually makes sense, so opts is usually
required.
Thinking a bit more. A small nit from my v2 comment. Name this as
start_server_addr() without the "_opts" part. Keep it short. I want the default
helper has the opts arg from now other than a few exceptions like close_netns(),
get_socket_local_port()...etc. No need to change other existing helpers. Stay
with start_server_addr() and connect_to_addr() in this set.
so,
int start_server_addr(int type, const struct sockaddr_storage *addr,
socklen_t len, const struct network_helper_opts *opts);
opts could be NULL.
pw-bot: cr
> +{
> + return __start_server(type, 0, (struct sockaddr *)addr, len,
> + opts->timeout_ms, 0);
> +}
> +
> +int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t len)
> +{
> + struct network_helper_opts opts = {
> + .timeout_ms = 0,
> + };
> +
> + return start_server_addr_opts(type, addr, len, &opts);
> +}
> +
> void free_fds(int *fds, unsigned int nr_close_fds)
> {
> if (fds) {
> diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h
> index ac4da5fdcc95..9e6fcc89a8d0 100644
> --- a/tools/testing/selftests/bpf/network_helpers.h
> +++ b/tools/testing/selftests/bpf/network_helpers.h
> @@ -53,6 +53,9 @@ int start_mptcp_server(int family, const char *addr, __u16 port,
> int *start_reuseport_server(int family, int type, const char *addr_str,
> __u16 port, int timeout_ms,
> unsigned int nr_listens);
> +int start_server_addr_opts(int type, const struct sockaddr_storage *addr, socklen_t len,
> + const struct network_helper_opts *opts);
> +int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t len);
> void free_fds(int *fds, unsigned int nr_close_fds);
> int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t len);
> int connect_to_fd(int server_fd, int timeout_ms);
next prev parent reply other threads:[~2024-04-18 0:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 10:13 [PATCH bpf-next v4 00/14] use network helpers, part 1 Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 01/14] selftests/bpf: Update arguments of connect_to_addr Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 02/14] selftests/bpf: Add start_server_addr* helpers Geliang Tang
2024-04-18 0:08 ` Martin KaFai Lau [this message]
2024-04-16 10:13 ` [PATCH bpf-next v4 03/14] selftests/bpf: Use start_server_addr in cls_redirect Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 04/14] selftests/bpf: Use connect_to_addr " Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 05/14] selftests/bpf: Use start_server_addr in sk_assign Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 06/14] selftests/bpf: Use connect_to_addr " Geliang Tang
2024-04-18 0:15 ` Martin KaFai Lau
2024-04-16 10:13 ` [PATCH bpf-next v4 07/14] selftests/bpf: Use get_socket_local_port " Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 08/14] selftests/bpf: Use make_sockaddr " Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 09/14] selftests/bpf: Use log_err in network_helpers Geliang Tang
2024-04-18 0:19 ` Martin KaFai Lau
2024-04-16 10:13 ` [PATCH bpf-next v4 10/14] selftests/bpf: Use start_server_addr in test_sock_addr Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 11/14] selftests/bpf: Use connect_to_addr " Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 12/14] selftests/bpf: Use make_sockaddr " Geliang Tang
2024-04-16 10:13 ` [PATCH bpf-next v4 13/14] selftests/bpf: Use make_sockaddr in test_sock Geliang Tang
2024-04-16 10:14 ` [PATCH bpf-next v4 14/14] selftests/bpf: Use make_sockaddr in ip_check_defrag 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=6c64339b-70c0-40d4-94a5-75c8bdfb08ea@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