* [PATCH bpf v2] selftests: bpf: Fix bind on used port
@ 2022-01-18 15:11 Felix Maurer
2022-01-20 18:52 ` Jakub Sitnicki
2022-01-20 22:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Felix Maurer @ 2022-01-18 15:11 UTC (permalink / raw)
To: bpf; +Cc: sdf, kafai, ast, jakub
The bind_perm BPF selftest failed when port 111/tcp was already in use
during the test. To fix this, the test now runs in its own network name
space.
To use unshare, it is necessary to reorder the includes. The style of
the includes is adapted to be consistent with the other prog_tests.
v2: Replace deprecated CHECK macro with ASSERT_OK
Fixes: 8259fdeb30326 ("selftests/bpf: Verify that rebinding to port < 1024 from BPF works")
Signed-off-by: Felix Maurer <fmaurer@redhat.com>
---
.../selftests/bpf/prog_tests/bind_perm.c | 20 ++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bind_perm.c b/tools/testing/selftests/bpf/prog_tests/bind_perm.c
index d0f06e40c16d..eac71fbb24ce 100644
--- a/tools/testing/selftests/bpf/prog_tests/bind_perm.c
+++ b/tools/testing/selftests/bpf/prog_tests/bind_perm.c
@@ -1,13 +1,24 @@
// SPDX-License-Identifier: GPL-2.0
-#include <test_progs.h>
-#include "bind_perm.skel.h"
-
+#define _GNU_SOURCE
+#include <sched.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/capability.h>
+#include "test_progs.h"
+#include "bind_perm.skel.h"
+
static int duration;
+static int create_netns(void)
+{
+ if (!ASSERT_OK(unshare(CLONE_NEWNET), "create netns"))
+ return -1;
+
+ return 0;
+}
+
void try_bind(int family, int port, int expected_errno)
{
struct sockaddr_storage addr = {};
@@ -75,6 +86,9 @@ void test_bind_perm(void)
struct bind_perm *skel;
int cgroup_fd;
+ if (create_netns())
+ return;
+
cgroup_fd = test__join_cgroup("/bind_perm");
if (CHECK(cgroup_fd < 0, "cg-join", "errno %d", errno))
return;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf v2] selftests: bpf: Fix bind on used port
2022-01-18 15:11 [PATCH bpf v2] selftests: bpf: Fix bind on used port Felix Maurer
@ 2022-01-20 18:52 ` Jakub Sitnicki
2022-01-21 23:12 ` Andrii Nakryiko
2022-01-20 22:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Sitnicki @ 2022-01-20 18:52 UTC (permalink / raw)
To: Felix Maurer; +Cc: bpf, sdf, kafai, ast
On Tue, Jan 18, 2022 at 04:11 PM CET, Felix Maurer wrote:
> The bind_perm BPF selftest failed when port 111/tcp was already in use
> during the test. To fix this, the test now runs in its own network name
> space.
>
> To use unshare, it is necessary to reorder the includes. The style of
> the includes is adapted to be consistent with the other prog_tests.
>
> v2: Replace deprecated CHECK macro with ASSERT_OK
>
> Fixes: 8259fdeb30326 ("selftests/bpf: Verify that rebinding to port < 1024 from BPF works")
> Signed-off-by: Felix Maurer <fmaurer@redhat.com>
> ---
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf v2] selftests: bpf: Fix bind on used port
2022-01-18 15:11 [PATCH bpf v2] selftests: bpf: Fix bind on used port Felix Maurer
2022-01-20 18:52 ` Jakub Sitnicki
@ 2022-01-20 22:40 ` patchwork-bot+netdevbpf
2022-01-22 0:20 ` Andrii Nakryiko
1 sibling, 1 reply; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-20 22:40 UTC (permalink / raw)
To: Felix Maurer; +Cc: bpf, sdf, kafai, ast, jakub
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 18 Jan 2022 16:11:56 +0100 you wrote:
> The bind_perm BPF selftest failed when port 111/tcp was already in use
> during the test. To fix this, the test now runs in its own network name
> space.
>
> To use unshare, it is necessary to reorder the includes. The style of
> the includes is adapted to be consistent with the other prog_tests.
>
> [...]
Here is the summary with links:
- [bpf,v2] selftests: bpf: Fix bind on used port
https://git.kernel.org/bpf/bpf-next/c/8c0be0631d81
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf v2] selftests: bpf: Fix bind on used port
2022-01-20 18:52 ` Jakub Sitnicki
@ 2022-01-21 23:12 ` Andrii Nakryiko
0 siblings, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2022-01-21 23:12 UTC (permalink / raw)
To: Jakub Sitnicki
Cc: Felix Maurer, bpf, Stanislav Fomichev, Martin Lau, Alexei Starovoitov
On Fri, Jan 21, 2022 at 2:32 PM Jakub Sitnicki <jakub@cloudflare.com> wrote:
>
> On Tue, Jan 18, 2022 at 04:11 PM CET, Felix Maurer wrote:
> > The bind_perm BPF selftest failed when port 111/tcp was already in use
> > during the test. To fix this, the test now runs in its own network name
> > space.
> >
> > To use unshare, it is necessary to reorder the includes. The style of
> > the includes is adapted to be consistent with the other prog_tests.
> >
> > v2: Replace deprecated CHECK macro with ASSERT_OK
> >
> > Fixes: 8259fdeb30326 ("selftests/bpf: Verify that rebinding to port < 1024 from BPF works")
> > Signed-off-by: Felix Maurer <fmaurer@redhat.com>
> > ---
>
> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
I've applied it to bpf-next yesterday, patchbot missed it and I forgot
to follow up to notify, sorry.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf v2] selftests: bpf: Fix bind on used port
2022-01-20 22:40 ` patchwork-bot+netdevbpf
@ 2022-01-22 0:20 ` Andrii Nakryiko
0 siblings, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2022-01-22 0:20 UTC (permalink / raw)
To: patchwork-bot+netdevbpf
Cc: Felix Maurer, bpf, Stanislav Fomichev, Martin Lau,
Alexei Starovoitov, Jakub Sitnicki
On Fri, Jan 21, 2022 at 4:18 PM <patchwork-bot+netdevbpf@kernel.org> wrote:
>
> Hello:
>
> This patch was applied to bpf/bpf-next.git (master)
> by Andrii Nakryiko <andrii@kernel.org>:
Better late than never :)
>
> On Tue, 18 Jan 2022 16:11:56 +0100 you wrote:
> > The bind_perm BPF selftest failed when port 111/tcp was already in use
> > during the test. To fix this, the test now runs in its own network name
> > space.
> >
> > To use unshare, it is necessary to reorder the includes. The style of
> > the includes is adapted to be consistent with the other prog_tests.
> >
> > [...]
>
> Here is the summary with links:
> - [bpf,v2] selftests: bpf: Fix bind on used port
> https://git.kernel.org/bpf/bpf-next/c/8c0be0631d81
>
> You are awesome, thank you!
> --
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-22 0:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 15:11 [PATCH bpf v2] selftests: bpf: Fix bind on used port Felix Maurer
2022-01-20 18:52 ` Jakub Sitnicki
2022-01-21 23:12 ` Andrii Nakryiko
2022-01-20 22:40 ` patchwork-bot+netdevbpf
2022-01-22 0:20 ` Andrii Nakryiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).