netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liping Zhang <zlpnobody@gmail.com>
To: stephen@networkplumber.org
Cc: netdev@vger.kernel.org, nicolas.dichtel@6wind.com,
	Liping Zhang <liping.zhang@spreadtrum.com>
Subject: [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled
Date: Tue, 20 Sep 2016 02:09:02 -0700	[thread overview]
Message-ID: <1474362542-5506-1-git-send-email-zlpnobody@gmail.com> (raw)

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

             reply	other threads:[~2016-09-20  9:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20  9:09 Liping Zhang [this message]
2016-09-20 11:53 ` [PATCH iproute2] ipmonitor: fix ip monitor can't work when NET_NS is not enabled Nicolas Dichtel
2016-09-21 23:33 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474362542-5506-1-git-send-email-zlpnobody@gmail.com \
    --to=zlpnobody@gmail.com \
    --cc=liping.zhang@spreadtrum.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).