diff mbox series

[bpf-next,v6,08/14] selftests/bpf: adding a namespace reset for tc_redirect

Message ID 20211006185619.364369-9-fallentree@fb.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series selftests/bpf: Add parallelism to test_progs | expand

Checks

Context Check Description
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 12 maintainers not CCed: joamaki@gmail.com linux-kselftest@vger.kernel.org netdev@vger.kernel.org shuah@kernel.org kafai@fb.com daniel@iogearbox.net yhs@fb.com john.fastabend@gmail.com songliubraving@fb.com kpsingh@kernel.org sdf@google.com ast@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files
bpf/vmtest-bpf-next success VM_Test
bpf/vmtest-bpf-next-PR success PR summary

Commit Message

Yucong Sun Oct. 6, 2021, 6:56 p.m. UTC
From: Yucong Sun <sunyucong@gmail.com>

This patch delete ns_src/ns_dst/ns_redir namespaces before recreating
them, making the test more robust.

Signed-off-by: Yucong Sun <sunyucong@gmail.com>
---
 .../testing/selftests/bpf/prog_tests/tc_redirect.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Andrii Nakryiko Oct. 8, 2021, 10:27 p.m. UTC | #1
On Wed, Oct 6, 2021 at 11:56 AM Yucong Sun <fallentree@fb.com> wrote:
>
> From: Yucong Sun <sunyucong@gmail.com>
>
> This patch delete ns_src/ns_dst/ns_redir namespaces before recreating
> them, making the test more robust.
>
> Signed-off-by: Yucong Sun <sunyucong@gmail.com>
> ---
>  .../testing/selftests/bpf/prog_tests/tc_redirect.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> index e87bc4466d9a..25744136e131 100644
> --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> @@ -176,6 +176,18 @@ static int netns_setup_namespaces(const char *verb)
>         return 0;
>  }
>
> +static void netns_setup_namespaces_nofail(const char *verb)
> +{
> +       const char * const *ns = namespaces;
> +       char cmd[128];
> +
> +       while (*ns) {
> +               snprintf(cmd, sizeof(cmd), "ip netns %s %s", verb, *ns);
> +               system(cmd);

is this what's causing

Cannot remove namespace file "/var/run/netns/ns_src": No such file or directory
Cannot remove namespace file "/var/run/netns/ns_fwd": No such file or directory
Cannot remove namespace file "/var/run/netns/ns_dst": No such file or directory

?

I haven't applied it yet, let's see if there is a way to avoid
unnecessary "warnings".



> +               ns++;
> +       }
> +}
> +
>  struct netns_setup_result {
>         int ifindex_veth_src_fwd;
>         int ifindex_veth_dst_fwd;
> @@ -762,6 +774,8 @@ static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result)
>
>  static void *test_tc_redirect_run_tests(void *arg)
>  {
> +       netns_setup_namespaces_nofail("delete");
> +
>         RUN_TEST(tc_redirect_peer);
>         RUN_TEST(tc_redirect_peer_l3);
>         RUN_TEST(tc_redirect_neigh);
> --
> 2.30.2
>
sunyucong@gmail.com Oct. 8, 2021, 11:07 p.m. UTC | #2
On Fri, Oct 8, 2021 at 3:27 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Wed, Oct 6, 2021 at 11:56 AM Yucong Sun <fallentree@fb.com> wrote:
> >
> > From: Yucong Sun <sunyucong@gmail.com>
> >
> > This patch delete ns_src/ns_dst/ns_redir namespaces before recreating
> > them, making the test more robust.
> >
> > Signed-off-by: Yucong Sun <sunyucong@gmail.com>
> > ---
> >  .../testing/selftests/bpf/prog_tests/tc_redirect.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> > index e87bc4466d9a..25744136e131 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> > @@ -176,6 +176,18 @@ static int netns_setup_namespaces(const char *verb)
> >         return 0;
> >  }
> >
> > +static void netns_setup_namespaces_nofail(const char *verb)
> > +{
> > +       const char * const *ns = namespaces;
> > +       char cmd[128];
> > +
> > +       while (*ns) {
> > +               snprintf(cmd, sizeof(cmd), "ip netns %s %s", verb, *ns);
> > +               system(cmd);
>
> is this what's causing
>
> Cannot remove namespace file "/var/run/netns/ns_src": No such file or directory
> Cannot remove namespace file "/var/run/netns/ns_fwd": No such file or directory
> Cannot remove namespace file "/var/run/netns/ns_dst": No such file or directory
>
> ?
>
> I haven't applied it yet, let's see if there is a way to avoid
> unnecessary "warnings".

we could just change this line

+               snprintf(cmd, sizeof(cmd), "ip netns %s %s > /dev/null
2>&1", verb, *ns);

to get rid of the warning

>
>
>
> > +               ns++;
> > +       }
> > +}
> > +
> >  struct netns_setup_result {
> >         int ifindex_veth_src_fwd;
> >         int ifindex_veth_dst_fwd;
> > @@ -762,6 +774,8 @@ static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result)
> >
> >  static void *test_tc_redirect_run_tests(void *arg)
> >  {
> > +       netns_setup_namespaces_nofail("delete");
> > +
> >         RUN_TEST(tc_redirect_peer);
> >         RUN_TEST(tc_redirect_peer_l3);
> >         RUN_TEST(tc_redirect_neigh);
> > --
> > 2.30.2
> >
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
index e87bc4466d9a..25744136e131 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
@@ -176,6 +176,18 @@  static int netns_setup_namespaces(const char *verb)
 	return 0;
 }
 
+static void netns_setup_namespaces_nofail(const char *verb)
+{
+	const char * const *ns = namespaces;
+	char cmd[128];
+
+	while (*ns) {
+		snprintf(cmd, sizeof(cmd), "ip netns %s %s", verb, *ns);
+		system(cmd);
+		ns++;
+	}
+}
+
 struct netns_setup_result {
 	int ifindex_veth_src_fwd;
 	int ifindex_veth_dst_fwd;
@@ -762,6 +774,8 @@  static void test_tc_redirect_peer_l3(struct netns_setup_result *setup_result)
 
 static void *test_tc_redirect_run_tests(void *arg)
 {
+	netns_setup_namespaces_nofail("delete");
+
 	RUN_TEST(tc_redirect_peer);
 	RUN_TEST(tc_redirect_peer_l3);
 	RUN_TEST(tc_redirect_neigh);