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: <Y+9itBDl8itgA0e3@lincoln>
Date:   Fri, 17 Feb 2023 12:19:16 +0100
From:   Larysa Zaremba <larysa.zaremba@...el.com>
To:     Hangbin Liu <liuhangbin@...il.com>
CC:     <netdev@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        "Daniel Borkmann" <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>, <bpf@...r.kernel.org>,
        Jakub Kicinski <kuba@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Martin KaFai Lau <martin.lau@...ux.dev>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
        Mykola Lysenko <mykolal@...com>,
        Felix Maurer <fmaurer@...hat.com>,
        "Matthieu Baerts" <matthieu.baerts@...sares.net>
Subject: Re: [PATCH bpf-next] selftests/bpf: run mptcp in a dedicated netns

On Fri, Feb 17, 2023 at 04:26:07PM +0800, Hangbin Liu wrote:
> The current mptcp test is run in init netns. If the user or default
> system config disabled mptcp, the test will fail. Let's run the mptcp
> test in a dedicated netns to avoid none kernel default mptcp setting.
> 
> Suggested-by: Martin KaFai Lau <martin.lau@...ux.dev>

Reviewed-by: Larysa Zaremba <larysa.zaremba@...el.com>

> Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
> ---
>  .../testing/selftests/bpf/prog_tests/mptcp.c  | 24 +++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> index 59f08d6d1d53..8a4ed9510ec7 100644
> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> @@ -7,6 +7,16 @@
>  #include "network_helpers.h"
>  #include "mptcp_sock.skel.h"
>  
> +#define SYS(fmt, ...)						\
> +	({							\
> +		char cmd[1024];					\
> +		snprintf(cmd, sizeof(cmd), fmt, ##__VA_ARGS__);	\
> +		if (!ASSERT_OK(system(cmd), cmd))		\
> +			goto cmd_fail;				\
> +	})
> +
> +#define NS_TEST "mptcp_ns"
> +
>  #ifndef TCP_CA_NAME_MAX
>  #define TCP_CA_NAME_MAX	16
>  #endif
> @@ -138,12 +148,20 @@ static int run_test(int cgroup_fd, int server_fd, bool is_mptcp)
>  
>  static void test_base(void)
>  {
> +	struct nstoken *nstoken = NULL;
>  	int server_fd, cgroup_fd;
>  
>  	cgroup_fd = test__join_cgroup("/mptcp");
>  	if (!ASSERT_GE(cgroup_fd, 0, "test__join_cgroup"))
>  		return;
>  
> +	SYS("ip netns add %s", NS_TEST);
> +	SYS("ip -net %s link set dev lo up", NS_TEST);
> +
> +	nstoken = open_netns(NS_TEST);
> +	if (!ASSERT_OK_PTR(nstoken, "open_netns"))
> +		goto cmd_fail;
> +
>  	/* without MPTCP */
>  	server_fd = start_server(AF_INET, SOCK_STREAM, NULL, 0, 0);
>  	if (!ASSERT_GE(server_fd, 0, "start_server"))
> @@ -163,6 +181,12 @@ static void test_base(void)
>  
>  	close(server_fd);
>  
> +cmd_fail:
> +	if (nstoken)
> +		close_netns(nstoken);
> +
> +	system("ip netns del " NS_TEST " >& /dev/null");
> +
>  close_cgroup_fd:
>  	close(cgroup_fd);
>  }
> -- 
> 2.38.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ