ipmonitor: fix ip monitor can't work when NET_NS is not enabled
In ip monitor, netns_map_init will check getnsid is supported or not.
But when /proc/self/ns/net does not exist, we just print out error
messages and exit. So user cannot use ip monitor anymore when
CONFIG_NET_NS is disabled:
# ip monitor
open("/proc/self/ns/net"): No such file or directory
If open "/proc/self/ns/net" failed, set have_rtnl_getnsid to false.
Fixes: d652ccbf81 ("netns: allow to dump and monitor nsid")
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
This commit is contained in:
parent
bffb68b6c2
commit
c44003f7e7
|
|
@ -72,8 +72,8 @@ static int ipnetns_have_nsid(void)
|
||||||
if (have_rtnl_getnsid < 0) {
|
if (have_rtnl_getnsid < 0) {
|
||||||
fd = open("/proc/self/ns/net", O_RDONLY);
|
fd = open("/proc/self/ns/net", O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror("open(\"/proc/self/ns/net\")");
|
have_rtnl_getnsid = 0;
|
||||||
exit(1);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addattr32(&req.n, 1024, NETNSA_FD, fd);
|
addattr32(&req.n, 1024, NETNSA_FD, fd);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue