netns
netns copied to clipboard
Is there a way to get notified when new netns is created
my application when it starts it detect all available netns by looking at /var/run/netns
but while its running if new netns is created my application won't know anything about it and as a result it won't know about links and their attributes
what is the best way to know runtime when netns is created so we can use LinkSubscribeAt()
for it ?
I believe we can use inotify to watch for creation/deletion events in /var/run/netns
Yeah I added inotify and when netns is created I subscribe for notificatoin using netlink.LinkSubscribeAt
but it failed here
cc'd @vishvananda I have an easy reproducer w/o using k8s or docker
- clone https://github.com/netobserv/netobserv-ebpf-agent
-
make build
-
sudo FLOWS_TARGET_HOST=127.0.0.1 FLOWS_TARGET_PORT=9999 ./bin/netobserv-ebpf-agent
-
sudo ip netns add n1
that will result into
ERRO[0009] can't subscribe to links netns NS(16: 25, 58164) component=ifaces.Watcher error="failed to set into network namespace 16 while creating netlink socket: invalid argument"