52be021e72ec58ee0c0a3f2b62e9cb6121cec675
[openwrt/staging/xback.git] /
1 From c44003f7e7254ac972eaa1b22a686471ea4ce2d7 Mon Sep 17 00:00:00 2001
2 From: Liping Zhang <liping.zhang@spreadtrum.com>
3 Date: Tue, 20 Sep 2016 02:09:02 -0700
4 Subject: [PATCH] ipmonitor: fix ip monitor can't work when NET_NS is not
5 enabled
6
7 In ip monitor, netns_map_init will check getnsid is supported or not.
8 But when /proc/self/ns/net does not exist, we just print out error
9 messages and exit. So user cannot use ip monitor anymore when
10 CONFIG_NET_NS is disabled:
11 # ip monitor
12 open("/proc/self/ns/net"): No such file or directory
13
14 If open "/proc/self/ns/net" failed, set have_rtnl_getnsid to false.
15
16 Fixes: d652ccbf8195 ("netns: allow to dump and monitor nsid")
17 Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
18 Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
19 ---
20 ip/ipnetns.c | 4 ++--
21 1 file changed, 2 insertions(+), 2 deletions(-)
22
23 diff --git a/ip/ipnetns.c b/ip/ipnetns.c
24 index af87065..ccc652c 100644
25 --- a/ip/ipnetns.c
26 +++ b/ip/ipnetns.c
27 @@ -72,8 +72,8 @@ static int ipnetns_have_nsid(void)
28 if (have_rtnl_getnsid < 0) {
29 fd = open("/proc/self/ns/net", O_RDONLY);
30 if (fd < 0) {
31 - perror("open(\"/proc/self/ns/net\")");
32 - exit(1);
33 + have_rtnl_getnsid = 0;
34 + return 0;
35 }
36
37 addattr32(&req.n, 1024, NETNSA_FD, fd);
38 --
39 2.6.4
40