lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6f0cb09c-3a3b-4307-8b7e-6a7c6e45b97e@linux.dev>
Date: Mon, 30 Sep 2024 19:33:43 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Feng zhou <zhoufeng.zf@...edance.com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
 eddyz87@...il.com, song@...nel.org, yonghong.song@...ux.dev,
 john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me,
 haoluo@...gle.com, jolsa@...nel.org, davem@...emloft.net,
 edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, mykolal@...com,
 shuah@...nel.org, alan.maguire@...cle.com, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
 linux-kselftest@...r.kernel.org, yangzhenze@...edance.com,
 wangdongdong.6@...edance.com
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: Setget_sockopt add a test
 for tcp over ipv4 via ipv6

On 9/14/24 3:32 AM, Feng zhou wrote:
> From: Feng Zhou <zhoufeng.zf@...edance.com>
> 
> This patch adds a test for TCP over IPv4 via INET6 API.
> 
> Signed-off-by: Feng Zhou <zhoufeng.zf@...edance.com>
> ---
>   .../selftests/bpf/prog_tests/setget_sockopt.c | 33 +++++++++++++++++++
>   .../selftests/bpf/progs/setget_sockopt.c      | 13 ++++++--
>   2 files changed, 43 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/setget_sockopt.c b/tools/testing/selftests/bpf/prog_tests/setget_sockopt.c
> index 7d4a9b3d3722..3cad92128e60 100644
> --- a/tools/testing/selftests/bpf/prog_tests/setget_sockopt.c
> +++ b/tools/testing/selftests/bpf/prog_tests/setget_sockopt.c
> @@ -15,8 +15,11 @@
>   
>   #define CG_NAME "/setget-sockopt-test"
>   
> +#define INT_PORT	8008
> +
>   static const char addr4_str[] = "127.0.0.1";
>   static const char addr6_str[] = "::1";
> +static const char addr6_any_str[] = "::";
>   static struct setget_sockopt *skel;
>   static int cg_fd;
>   
> @@ -67,6 +70,35 @@ static void test_tcp(int family)
>   	ASSERT_EQ(bss->nr_binddev, 2, "nr_bind");
>   }
>   
> +static void test_tcp_over_ipv4_via_ipv6(void)
> +{
> +	struct setget_sockopt__bss *bss = skel->bss;
> +	int sfd, cfd;
> +
> +	memset(bss, 0, sizeof(*bss));
> +	skel->bss->test_tcp_over_ipv4_via_ipv6 = 1;
> +
> +	sfd = start_server(AF_INET6, SOCK_STREAM,
> +			   addr6_any_str, INT_PORT, 0);
> +	if (!ASSERT_GE(sfd, 0, "start_server"))
> +		return;
> +
> +	cfd = connect_to_addr_str(AF_INET, SOCK_STREAM, addr4_str, INT_PORT, NULL);
> +	if (!ASSERT_GE(cfd, 0, "connect_to_addr_str")) {
> +		close(sfd);
> +		return;
> +	}
> +	close(sfd);
> +	close(cfd);
> +
> +	ASSERT_EQ(bss->nr_listen, 1, "nr_listen");
> +	ASSERT_EQ(bss->nr_connect, 1, "nr_connect");
> +	ASSERT_EQ(bss->nr_active, 1, "nr_active");
> +	ASSERT_EQ(bss->nr_passive, 1, "nr_passive");
> +	ASSERT_EQ(bss->nr_socket_post_create, 2, "nr_socket_post_create");
> +	ASSERT_EQ(bss->nr_binddev, 2, "nr_bind");
> +}
> +
>   static void test_udp(int family)
>   {
>   	struct setget_sockopt__bss *bss = skel->bss;
> @@ -191,6 +223,7 @@ void test_setget_sockopt(void)
>   	test_udp(AF_INET);
>   	test_ktls(AF_INET6);
>   	test_ktls(AF_INET);
> +	test_tcp_over_ipv4_via_ipv6();

This has a conflict with commit d53050934e66.

pw-bot: cr

>   
>   done:
>   	setget_sockopt__destroy(skel);
> diff --git a/tools/testing/selftests/bpf/progs/setget_sockopt.c b/tools/testing/selftests/bpf/progs/setget_sockopt.c
> index 60518aed1ffc..ff834d94dd23 100644
> --- a/tools/testing/selftests/bpf/progs/setget_sockopt.c
> +++ b/tools/testing/selftests/bpf/progs/setget_sockopt.c
> @@ -20,6 +20,7 @@ int nr_connect;
>   int nr_binddev;
>   int nr_socket_post_create;
>   int nr_fin_wait1;
> +int test_tcp_over_ipv4_via_ipv6;
>   
>   struct sockopt_test {
>   	int opt;
> @@ -262,9 +263,15 @@ static int bpf_test_sockopt(void *ctx, struct sock *sk)
>   		if (n != ARRAY_SIZE(sol_ip_tests))
>   			return -1;
>   	} else {
> -		n = bpf_loop(ARRAY_SIZE(sol_ipv6_tests), bpf_test_ipv6_sockopt, &lc, 0);
> -		if (n != ARRAY_SIZE(sol_ipv6_tests))
> -			return -1;
> +		if (test_tcp_over_ipv4_via_ipv6) {
> +			n = bpf_loop(ARRAY_SIZE(sol_ip_tests), bpf_test_ip_sockopt, &lc, 0);

Can this bpf_loop(..., bpf_test_ip_sockopt, ...) be always run? Then the above 
test_tcp_over_ipv4_via_ipv6() addition will not be needed.


> +			if (n != ARRAY_SIZE(sol_ip_tests))
> +				return -1;
> +		} else {
> +			n = bpf_loop(ARRAY_SIZE(sol_ipv6_tests), bpf_test_ipv6_sockopt, &lc, 0);
> +			if (n != ARRAY_SIZE(sol_ipv6_tests))
> +				return -1;
> +		}
>   	}
>   
>   	return 0;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ