netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled
@ 2016-09-20  9:09 Liping Zhang
  2016-09-20 11:53 ` Nicolas Dichtel
  2016-09-21 23:33 ` Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Liping Zhang @ 2016-09-20  9:09 UTC (permalink / raw)
  To: stephen; +Cc: netdev, nicolas.dichtel, Liping Zhang

From: Liping Zhang <liping.zhang@spreadtrum.com>

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 <liping.zhang@spreadtrum.com>
---
 ip/ipnetns.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index af87065..ccc652c 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);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled
  2016-09-20  9:09 [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled Liping Zhang
@ 2016-09-20 11:53 ` Nicolas Dichtel
  2016-09-21 23:33 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Dichtel @ 2016-09-20 11:53 UTC (permalink / raw)
  To: Liping Zhang, stephen; +Cc: netdev, Liping Zhang

Le 20/09/2016 à 11:09, Liping Zhang a écrit :
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> 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 <liping.zhang@spreadtrum.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled
  2016-09-20  9:09 [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled Liping Zhang
  2016-09-20 11:53 ` Nicolas Dichtel
@ 2016-09-21 23:33 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2016-09-21 23:33 UTC (permalink / raw)
  To: Liping Zhang; +Cc: netdev, nicolas.dichtel, Liping Zhang

On Tue, 20 Sep 2016 02:09:02 -0700
Liping Zhang <zlpnobody@gmail.com> wrote:

> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> 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 <liping.zhang@spreadtrum.com>

Makes sense. Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-21 23:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20  9:09 [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled Liping Zhang
2016-09-20 11:53 ` Nicolas Dichtel
2016-09-21 23:33 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).