[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231009182753.851551-6-toke@redhat.com>
Date: Mon, 9 Oct 2023 20:27:53 +0200
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: David Ahern <dsahern@...il.com>,
Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org,
Toke Høiland-Jørgensen <toke@...hat.com>,
Nicolas Dichtel <nicolas.dichtel@...nd.com>,
Christian Brauner <brauner@...nel.org>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
David Laight <David.Laight@...LAB.COM>
Subject: [RFC PATCH iproute2-next 5/5] lib/namespace: Also mount a bpffs instance inside new mount namespaces
When creating a new mount namespace, we remount /sys inside that namespace,
which means there is no bpffs available unless it is manually remounted later.
To make it easier to work with BPF in combination with 'ip netns', make sure we
always mount a bpffs instance to /sys/fs/bpf after creating a new namespace.
Since bpffs may not always be available, we only warn if the mounting fails, but
carry on regardless.
Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
---
lib/namespace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/namespace.c b/lib/namespace.c
index 5f2449fb0003..62456ab24e4f 100644
--- a/lib/namespace.c
+++ b/lib/namespace.c
@@ -93,6 +93,9 @@ int prepare_mountns(const char *name, bool do_unshare)
return -1;
}
+ if (mount("bpf", "/sys/fs/bpf", "bpf", mountflags, NULL) < 0)
+ fprintf(stderr, "could not mount /sys/fs/bpf inside namespace: %s. continuing anyway\n",strerror(errno));
+
/* Setup bind mounts for config files in /etc */
bind_etc(name);
return 0;
--
2.42.0
Powered by blists - more mailing lists