Message ID | 20231009182753.851551-6-toke@redhat.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | David Ahern |
Headers | show |
Series | Persisting of mount namespaces along with network namespaces | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
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;
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@redhat.com> --- lib/namespace.c | 3 +++ 1 file changed, 3 insertions(+)