From: Liping Zhang Date: Tue, 20 Sep 2016 09:09:02 +0000 (-0700) Subject: ipmonitor: fix ip monitor can't work when NET_NS is not enabled X-Git-Tag: v4.8.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c44003f7e7254ac972eaa1b22a686471ea4ce2d7;p=thirdparty%2Fiproute2.git 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: d652ccbf8195 ("netns: allow to dump and monitor nsid") Signed-off-by: Liping Zhang Acked-by: Nicolas Dichtel --- diff --git a/ip/ipnetns.c b/ip/ipnetns.c index af8706530..ccc652c13 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -72,8 +72,8 @@ static int ipnetns_have_nsid(void) if (have_rtnl_getnsid < 0) { fd = open("/proc/self/ns/net", O_RDONLY); if (fd < 0) { - perror("open(\"/proc/self/ns/net\")"); - exit(1); + have_rtnl_getnsid = 0; + return 0; } addattr32(&req.n, 1024, NETNSA_FD, fd);