From: Larysa Zaremba <larysa.zaremba@intel.com>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: <netdev@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, <bpf@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
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>, Mykola Lysenko <mykolal@fb.com>,
Felix Maurer <fmaurer@redhat.com>,
"Matthieu Baerts" <matthieu.baerts@tessares.net>
Subject: Re: [PATCH bpf-next] selftests/bpf: run mptcp in a dedicated netns
Date: Fri, 17 Feb 2023 12:19:16 +0100 [thread overview]
Message-ID: <Y+9itBDl8itgA0e3@lincoln> (raw)
In-Reply-To: <20230217082607.3309391-1-liuhangbin@gmail.com>
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@linux.dev>
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.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
>
next prev parent reply other threads:[~2023-02-17 11:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 8:26 [PATCH bpf-next] selftests/bpf: run mptcp in a dedicated netns Hangbin Liu
2023-02-17 11:19 ` Larysa Zaremba [this message]
2023-02-17 13:53 ` Matthieu Baerts
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=Y+9itBDl8itgA0e3@lincoln \
--to=larysa.zaremba@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=fmaurer@redhat.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=liuhangbin@gmail.com \
--cc=martin.lau@linux.dev \
--cc=matthieu.baerts@tessares.net \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.