[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzYUV4ay6STtaGWQWcR1PQsD3w6HYpQjdXpSxdCOU56Gog@mail.gmail.com>
Date: Wed, 1 Jul 2020 12:55:36 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Martin KaFai Lau <kafai@...com>
Cc: bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next 2/2] bpf: selftests: Restore netns after each test
On Wed, Jul 1, 2020 at 12:48 PM Martin KaFai Lau <kafai@...com> wrote:
>
> It is common for networking tests creating its netns and making its own
> setting under this new netns (e.g. changing tcp sysctl). If the test
> forgot to restore to the original netns, it would affect the
> result of other tests.
>
> This patch saves the original netns at the beginning and then restores it
> after every test. Since the restore "setns()" is not expensive, it does it
> on all tests without tracking if a test has created a new netns or not.
>
> The new restore_netns() could also be done in test__end_subtest() such
> that each subtest will get an automatic netns reset. However,
> the individual test would lose flexibility to have total control
> on netns for its own subtests. In some cases, forcing a test to do
> unnecessary netns re-configure for each subtest is time consuming.
> e.g. In my vm, forcing netns re-configure on each subtest in sk_assign.c
> increased the runtime from 1s to 8s. On top of that, test_progs.c
> is also doing per-test (instead of per-subtest) cleanup for cgroup.
> Thus, this patch also does per-test restore_netns(). The only existing
> per-subtest cleanup is reset_affinity() and no test is depending on this.
> Thus, it is removed from test__end_subtest() to give a consistent
> expectation to the individual tests. test_progs.c only ensures
> any affinity/netns/cgroup change made by an earlier test does not
> affect the following tests.
>
> Signed-off-by: Martin KaFai Lau <kafai@...com>
> ---
LGTM, thanks.
Acked-by: Andrii Nakryiko <andriin@...com>
> tools/testing/selftests/bpf/test_progs.c | 23 +++++++++++++++++++++--
> tools/testing/selftests/bpf/test_progs.h | 2 ++
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
[...]
Powered by blists - more mailing lists