Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: 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>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	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>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
	bpf@vger.kernel.org,  linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v7 8/9] selftests/bpf: Use connect_to_addr in sk_lookup
Date: Fri, 05 Jul 2024 10:12:18 +0800	[thread overview]
Message-ID: <a2ff6d1bcbab6da1ce25965e6fb522e39cd65a0b.camel@kernel.org> (raw)
In-Reply-To: <04e41d6e3158b294a30ae6bf93a856b63832d65a.1720083019.git.tanggeliang@kylinos.cn>

On Thu, 2024-07-04 at 16:59 +0800, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> Use public network helpers make_sockaddr() and connect_to_addr()
> instead
> of using the local defined function make_socket() and connect().
> 
> This make_socket() can be dropped latter.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  .../selftests/bpf/prog_tests/sk_lookup.c      | 20 +++++++++--------
> --
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
> b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
> index ef4a3db34c5f..7c42ebff80a4 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
> @@ -231,23 +231,23 @@ static int make_server(int sotype, const char
> *ip, int port,
>  
>  static int make_client(int sotype, const char *ip, int port)
>  {
> +	int family = is_ipv6(ip) ? AF_INET6 : AF_INET;
> +	struct network_helper_opts opts = {
> +		.timeout_ms = IO_TIMEOUT_SEC,
> +	};
>  	struct sockaddr_storage addr = {0};
> +	socklen_t len;
>  	int err, fd;
>  
> -	fd = make_socket(sotype, ip, port, &addr);
> -	if (fd < 0)
> +	err = make_sockaddr(family, ip, port, &addr, &len);
> +	if (!ASSERT_OK(err, "make_sockaddr"))
>  		return -1;
>  
> -	err = connect(fd, (void *)&addr, inetaddr_len(&addr));
> -	if (CHECK(err, "make_client", "connect")) {
> -		log_err("failed to connect client socket");
> -		goto fail;
> -	}
> +	fd = connect_to_addr(sotype, &addr, len, &opts);
> +	if (!ASSERT_GE(fd, 0, "connect_to_addr"))
Sorry, this line breaks CI.

Changes Requested.

-Geliang

> +		return -1;
>  
>  	return fd;
> -fail:
> -	close(fd);
> -	return -1;
>  }
>  
>  static __u64 socket_cookie(int fd)


  reply	other threads:[~2024-07-05  2:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04  8:59 [PATCH bpf-next v7 0/9] use network helpers, part 8 Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 1/9] selftests/bpf: Add backlog for network_helper_opts Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 2/9] selftests/bpf: Use start_server_str in sockmap_ktls Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 3/9] selftests/bpf: Use connect_to_fd_opts " Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 4/9] selftests/bpf: Use make_sockaddr " Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 5/9] selftests/bpf: Close fd in error path in drop_on_reuseport Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 6/9] selftests/bpf: Use start_server_str in sk_lookup Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 7/9] selftests/bpf: Use connect_to_fd_opts " Geliang Tang
2024-07-04  8:59 ` [PATCH bpf-next v7 8/9] selftests/bpf: Use connect_to_addr " Geliang Tang
2024-07-05  2:12   ` Geliang Tang [this message]
2024-07-04  8:59 ` [PATCH bpf-next v7 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=a2ff6d1bcbab6da1ce25965e6fb522e39cd65a0b.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --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