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] [day] [month] [year] [list]
Message-ID: <1d6b9d1d-6ce4-488b-9884-3025f06c5e3f@linux.dev>
Date: Tue, 29 Oct 2024 12:36:07 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Geliang Tang <geliang@...nel.org>
Cc: Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman
 <eddyz87@...il.com>, Mykola Lysenko <mykolal@...com>,
 Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
 Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>,
 Geliang Tang <tanggeliang@...inos.cn>, netdev@...r.kernel.org,
 mptcp@...ts.linux.dev, bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
 Matthieu Baerts <matttbe@...nel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Use make/remove netns helpers in
 mptcp

On 10/24/24 1:11 AM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@...inos.cn>
> 
> New netns selftest helpers make_netns() and remove_netns() has been added
> in network_helpers.c, let's use them in mptcp selftests too.
> 
> Signed-off-by: Geliang Tang <tanggeliang@...inos.cn>
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@...nel.org>
> ---
>   tools/testing/selftests/bpf/prog_tests/mptcp.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> index d2ca32fa3b21..8276398f7d6a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> @@ -66,12 +66,18 @@ struct mptcp_storage {
>   
>   static struct nstoken *create_netns(void)
>   {
> -	SYS(fail, "ip netns add %s", NS_TEST);
> -	SYS(fail, "ip -net %s link set dev lo up", NS_TEST);
> +	struct nstoken *nstoken;
>   
> -	return open_netns(NS_TEST);
> -fail:
> -	return NULL;
> +	if (make_netns(NS_TEST) < 0)
> +		return NULL;
> +
> +	nstoken = open_netns(NS_TEST);
> +	if (!nstoken) {
> +		log_err("open netns %s failed", NS_TEST);
> +		remove_netns(NS_TEST);
> +	}
> +
> +	return nstoken;
>   }

This can be further simplified by using the netns_new() and netns_free(). Then 
create_netns() and remove_netns() can be removed from mptcp.c. Take a look at a 
recent usage in prog_tests/btf_skc_cls_ingress.c.

pw-bot: cr

>   
>   static void cleanup_netns(struct nstoken *nstoken)
> @@ -79,7 +85,7 @@ static void cleanup_netns(struct nstoken *nstoken)
>   	if (nstoken)
>   		close_netns(nstoken);
>   
> -	SYS_NOFAIL("ip netns del %s", NS_TEST);
> +	remove_netns(NS_TEST);
>   }
>   
>   static int start_mptcp_server(int family, const char *addr_str, __u16 port,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ