netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH iproute2] configure: add missing INCLUDE to netnsid detection
  2015-04-08 19:42 [PATCH iproute2] configure: add missing INCLUDE to netnsid detection Jiri Benc
@ 2015-04-08 19:40 ` Vadim Kochan
  2015-04-10 16:17   ` Nicolas Dichtel
  2015-04-10 20:25 ` [PATCH iproute2] configure: add missing INCLUDE to netnsid detection Stephen Hemminger
  1 sibling, 1 reply; 11+ messages in thread
From: Vadim Kochan @ 2015-04-08 19:40 UTC (permalink / raw)
  To: Jiri Benc; +Cc: netdev, Vadim Kochan, Stephen Hemminger

On Wed, Apr 08, 2015 at 09:42:00PM +0200, Jiri Benc wrote:
> Fixes: d116ff34145b0 ("ip netns: Fix rtnl error while print netns list")
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
> ---
> The whole check added by d116ff34145b0 is dubious, though. This should be
> a run time check, not a compile time one.
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 631938e97206..e54f4b6db5e8 100755
> --- a/configure
> +++ b/configure
> @@ -224,7 +224,7 @@ check_netnsid()
>  #include <linux/rtnetlink.h>
>  int test_def = RTM_GETNSID;
>  EOF
> -    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
> +    $CC -I$INCLUDE -c $TMPDIR/netnsid.c >/dev/null 2>&1
>      if [ $? -eq 0 ]
>      then
>  	echo "IP_CONFIG_NETNSID:=y" >> Config
> -- 
> 1.8.3.1
> 

Hi,

On 3.18 I get same RTNL error with this fix, I agree that runtime checking
would be better than compile time checking, but how to do it, suppress
RTNL errors ?

Regards,

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

* [PATCH iproute2] configure: add missing INCLUDE to netnsid detection
@ 2015-04-08 19:42 Jiri Benc
  2015-04-08 19:40 ` Vadim Kochan
  2015-04-10 20:25 ` [PATCH iproute2] configure: add missing INCLUDE to netnsid detection Stephen Hemminger
  0 siblings, 2 replies; 11+ messages in thread
From: Jiri Benc @ 2015-04-08 19:42 UTC (permalink / raw)
  To: netdev; +Cc: Vadim Kochan, Stephen Hemminger

Fixes: d116ff34145b0 ("ip netns: Fix rtnl error while print netns list")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
The whole check added by d116ff34145b0 is dubious, though. This should be
a run time check, not a compile time one.
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 631938e97206..e54f4b6db5e8 100755
--- a/configure
+++ b/configure
@@ -224,7 +224,7 @@ check_netnsid()
 #include <linux/rtnetlink.h>
 int test_def = RTM_GETNSID;
 EOF
-    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
+    $CC -I$INCLUDE -c $TMPDIR/netnsid.c >/dev/null 2>&1
     if [ $? -eq 0 ]
     then
 	echo "IP_CONFIG_NETNSID:=y" >> Config
-- 
1.8.3.1

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

* Re: [PATCH iproute2] configure: add missing INCLUDE to netnsid detection
  2015-04-08 19:40 ` Vadim Kochan
@ 2015-04-10 16:17   ` Nicolas Dichtel
  2015-04-13  8:23     ` [PATCH iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-10 16:17 UTC (permalink / raw)
  To: Vadim Kochan, Jiri Benc; +Cc: netdev, Stephen Hemminger

Le 08/04/2015 21:40, Vadim Kochan a écrit :
> On Wed, Apr 08, 2015 at 09:42:00PM +0200, Jiri Benc wrote:
>> Fixes: d116ff34145b0 ("ip netns: Fix rtnl error while print netns list")
>> Signed-off-by: Jiri Benc <jbenc@redhat.com>
>> ---
>> The whole check added by d116ff34145b0 is dubious, though. This should be
>> a run time check, not a compile time one.
[snip]
>
> On 3.18 I get same RTNL error with this fix, I agree that runtime checking
> would be better than compile time checking, but how to do it, suppress
> RTNL errors ?
I also hit this issue.
This whole check is done only to bypass some fprintf(stderr) messages from
rtnl_talk().
I think adding a mechanism like iplink_have_newlink() should be enough.

If nobody wants to do it, I will look at this on Monday.

Regards,
Nicolas

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

* Re: [PATCH iproute2] configure: add missing INCLUDE to netnsid detection
  2015-04-08 19:42 [PATCH iproute2] configure: add missing INCLUDE to netnsid detection Jiri Benc
  2015-04-08 19:40 ` Vadim Kochan
@ 2015-04-10 20:25 ` Stephen Hemminger
  1 sibling, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2015-04-10 20:25 UTC (permalink / raw)
  To: Jiri Benc; +Cc: netdev, Vadim Kochan

On Wed,  8 Apr 2015 21:42:00 +0200
Jiri Benc <jbenc@redhat.com> wrote:

> Fixes: d116ff34145b0 ("ip netns: Fix rtnl error while print netns list")
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
> ---
> The whole check added by d116ff34145b0 is dubious, though. This should be
> a run time check, not a compile time one.
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 631938e97206..e54f4b6db5e8 100755
> --- a/configure
> +++ b/configure
> @@ -224,7 +224,7 @@ check_netnsid()
>  #include <linux/rtnetlink.h>
>  int test_def = RTM_GETNSID;
>  EOF
> -    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
> +    $CC -I$INCLUDE -c $TMPDIR/netnsid.c >/dev/null 2>&1
>      if [ $? -eq 0 ]
>      then
>  	echo "IP_CONFIG_NETNSID:=y" >> Config


Merged, but always up for a better solution in future.

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

* [PATCH iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection"
  2015-04-10 16:17   ` Nicolas Dichtel
@ 2015-04-13  8:23     ` Nicolas Dichtel
  2015-04-13  8:23       ` [PATCH iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:23 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

This reverts commit d059de70cafb470f77fc19a42d95f6dc442cf6a3.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index e54f4b6db5e8..631938e97206 100755
--- a/configure
+++ b/configure
@@ -224,7 +224,7 @@ check_netnsid()
 #include <linux/rtnetlink.h>
 int test_def = RTM_GETNSID;
 EOF
-    $CC -I$INCLUDE -c $TMPDIR/netnsid.c >/dev/null 2>&1
+    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
     if [ $? -eq 0 ]
     then
 	echo "IP_CONFIG_NETNSID:=y" >> Config
-- 
2.2.2

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

* [PATCH iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list"
  2015-04-13  8:23     ` [PATCH iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
@ 2015-04-13  8:23       ` Nicolas Dichtel
  2015-04-13  8:23       ` [PATCH iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
       [not found]       ` <f5aa0068662f470e988a01e3b92450f1@HQ1WP-EXMB12.corp.brocade.com>
  2 siblings, 0 replies; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:23 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

This reverts commit d116ff34145b00db54a37e2a6282dccd8bc08225.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 configure    | 21 +--------------------
 ip/Makefile  |  4 ----
 ip/ipnetns.c |  7 -------
 3 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/configure b/configure
index 631938e97206..c3dacdba14ff 100755
--- a/configure
+++ b/configure
@@ -201,7 +201,7 @@ check_setns()
 {
     cat >$TMPDIR/setnstest.c <<EOF
 #include <sched.h>
-int main(int argc, char **argv)
+int main(int argc, char **argv) 
 {
 	(void)setns(0,0);
 	return 0;
@@ -218,23 +218,6 @@ EOF
     rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
 }
 
-check_netnsid()
-{
-    cat >$TMPDIR/netnsid.c <<EOF
-#include <linux/rtnetlink.h>
-int test_def = RTM_GETNSID;
-EOF
-    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
-	echo "IP_CONFIG_NETNSID:=y" >> Config
-	echo "yes"
-    else
-	echo "no"
-    fi
-    rm -f $TMPDIR/netnsid.c $TMPDIR/netnsid.o
-}
-
 check_ipset()
 {
     cat >$TMPDIR/ipsettest.c <<EOF
@@ -300,8 +283,6 @@ check_ipt_lib_dir
 
 echo -n "libc has setns: "
 check_setns
-echo -n "netns has peer id suport: "
-check_netnsid
 
 echo -n "SELinux support: "
 check_selinux
diff --git a/ip/Makefile b/ip/Makefile
index 5637bcfebde0..2c742f305fef 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -16,10 +16,6 @@ ifeq ($(IP_CONFIG_SETNS),y)
 	CFLAGS += -DHAVE_SETNS
 endif
 
-ifeq ($(IP_CONFIG_NETNSID),y)
-	CFLAGS += -DHAVE_NETNSID
-endif
-
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
 TARGETS=ip rtmon
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 45e234a4d98c..5a213dcf46cd 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -34,7 +34,6 @@ static int usage(void)
 	exit(-1);
 }
 
-#ifdef HAVE_NETNSID
 static int get_netnsid_from_name(const char *name)
 {
 	struct {
@@ -79,12 +78,6 @@ static int get_netnsid_from_name(const char *name)
 
 	return -1;
 }
-#else
-static int get_netnsid_from_name(const char *name)
-{
-	return -1;
-}
-#endif /* HAVE_NETNSID */
 
 static int netns_list(int argc, char **argv)
 {
-- 
2.2.2

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

* [PATCH iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support
  2015-04-13  8:23     ` [PATCH iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
  2015-04-13  8:23       ` [PATCH iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
@ 2015-04-13  8:23       ` Nicolas Dichtel
  2015-04-13  8:34         ` [PATCH v2 iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
       [not found]       ` <f5aa0068662f470e988a01e3b92450f1@HQ1WP-EXMB12.corp.brocade.com>
  2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:23 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

The goal of this patch is to test during the runtime if the command RTM_GETNSID
is supported by the kernel.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 ip/ipnetns.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 5a213dcf46cd..12f6b90de89a 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -34,6 +34,54 @@ static int usage(void)
 	exit(-1);
 }
 
+static int have_rtnl_getnsid = -1;
+
+static int ipnetns_accept_msg(const struct sockaddr_nl *who,
+			      struct nlmsghdr *n, void *arg)
+{
+	struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(n);
+
+	if (n->nlmsg_type == NLMSG_ERROR &&
+	    (err->error == -EOPNOTSUPP || err->error == -EINVAL))
+		have_rtnl_getnsid = 0;
+	else
+		have_rtnl_getnsid = 1;
+	return -1;
+}
+
+static int ipnetns_have_nsid(void)
+{
+	struct {
+		struct nlmsghdr n;
+		struct rtgenmsg g;
+		char            buf[1024];
+	} req;
+	int fd;
+
+	if (have_rtnl_getnsid < 0) {
+		memset(&req, 0, sizeof(req));
+		req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg));
+		req.n.nlmsg_flags = NLM_F_REQUEST;
+		req.n.nlmsg_type = RTM_GETNSID;
+		req.g.rtgen_family = AF_UNSPEC;
+
+		fd = open("/proc/self/ns/net", O_RDONLY);
+		if (fd < 0)
+			return fd;
+
+		addattr32(&req.n, 1024, NETNSA_FD, fd);
+
+		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) < 0) {
+			perror("request send failed");
+			exit(1);
+		}
+		rtnl_listen(&rth, ipnetns_accept_msg, NULL);
+		close(fd);
+	}
+
+	return have_rtnl_getnsid;
+}
+
 static int get_netnsid_from_name(const char *name)
 {
 	struct {
@@ -95,9 +143,11 @@ static int netns_list(int argc, char **argv)
 		if (strcmp(entry->d_name, "..") == 0)
 			continue;
 		printf("%s", entry->d_name);
-		id = get_netnsid_from_name(entry->d_name);
-		if (id >= 0)
-			printf(" (id: %d)", id);
+		if (ipnetns_have_nsid()) {
+			id = get_netnsid_from_name(entry->d_name);
+			if (id >= 0)
+				printf(" (id: %d)", id);
+		}
 		printf("\n");
 	}
 	closedir(dir);
-- 
2.2.2

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

* [PATCH v2 iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection"
  2015-04-13  8:23       ` [PATCH iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
@ 2015-04-13  8:34         ` Nicolas Dichtel
  2015-04-13  8:34           ` [PATCH v2 iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
  2015-04-13  8:34           ` [PATCH v2 iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
  0 siblings, 2 replies; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:34 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

This reverts commit d059de70cafb470f77fc19a42d95f6dc442cf6a3.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index e54f4b6db5e8..631938e97206 100755
--- a/configure
+++ b/configure
@@ -224,7 +224,7 @@ check_netnsid()
 #include <linux/rtnetlink.h>
 int test_def = RTM_GETNSID;
 EOF
-    $CC -I$INCLUDE -c $TMPDIR/netnsid.c >/dev/null 2>&1
+    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
     if [ $? -eq 0 ]
     then
 	echo "IP_CONFIG_NETNSID:=y" >> Config
-- 
2.2.2

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

* [PATCH v2 iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list"
  2015-04-13  8:34         ` [PATCH v2 iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
@ 2015-04-13  8:34           ` Nicolas Dichtel
  2015-04-13  8:34           ` [PATCH v2 iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
  1 sibling, 0 replies; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:34 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

This reverts commit d116ff34145b00db54a37e2a6282dccd8bc08225.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 configure    | 21 +--------------------
 ip/Makefile  |  4 ----
 ip/ipnetns.c |  7 -------
 3 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/configure b/configure
index 631938e97206..c3dacdba14ff 100755
--- a/configure
+++ b/configure
@@ -201,7 +201,7 @@ check_setns()
 {
     cat >$TMPDIR/setnstest.c <<EOF
 #include <sched.h>
-int main(int argc, char **argv)
+int main(int argc, char **argv) 
 {
 	(void)setns(0,0);
 	return 0;
@@ -218,23 +218,6 @@ EOF
     rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
 }
 
-check_netnsid()
-{
-    cat >$TMPDIR/netnsid.c <<EOF
-#include <linux/rtnetlink.h>
-int test_def = RTM_GETNSID;
-EOF
-    $CC -c $TMPDIR/netnsid.c >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
-	echo "IP_CONFIG_NETNSID:=y" >> Config
-	echo "yes"
-    else
-	echo "no"
-    fi
-    rm -f $TMPDIR/netnsid.c $TMPDIR/netnsid.o
-}
-
 check_ipset()
 {
     cat >$TMPDIR/ipsettest.c <<EOF
@@ -300,8 +283,6 @@ check_ipt_lib_dir
 
 echo -n "libc has setns: "
 check_setns
-echo -n "netns has peer id suport: "
-check_netnsid
 
 echo -n "SELinux support: "
 check_selinux
diff --git a/ip/Makefile b/ip/Makefile
index 5637bcfebde0..2c742f305fef 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -16,10 +16,6 @@ ifeq ($(IP_CONFIG_SETNS),y)
 	CFLAGS += -DHAVE_SETNS
 endif
 
-ifeq ($(IP_CONFIG_NETNSID),y)
-	CFLAGS += -DHAVE_NETNSID
-endif
-
 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
 SCRIPTS=ifcfg rtpr routel routef
 TARGETS=ip rtmon
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 45e234a4d98c..5a213dcf46cd 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -34,7 +34,6 @@ static int usage(void)
 	exit(-1);
 }
 
-#ifdef HAVE_NETNSID
 static int get_netnsid_from_name(const char *name)
 {
 	struct {
@@ -79,12 +78,6 @@ static int get_netnsid_from_name(const char *name)
 
 	return -1;
 }
-#else
-static int get_netnsid_from_name(const char *name)
-{
-	return -1;
-}
-#endif /* HAVE_NETNSID */
 
 static int netns_list(int argc, char **argv)
 {
-- 
2.2.2

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

* [PATCH v2 iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support
  2015-04-13  8:34         ` [PATCH v2 iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
  2015-04-13  8:34           ` [PATCH v2 iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
@ 2015-04-13  8:34           ` Nicolas Dichtel
  1 sibling, 0 replies; 11+ messages in thread
From: Nicolas Dichtel @ 2015-04-13  8:34 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, vadim4j, jbenc, Nicolas Dichtel

The goal of this patch is to test during the runtime if the command RTM_GETNSID
is supported by the kernel.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---

v2: fix error handling in ipnetns_have_nsid() when open() fails

 ip/ipnetns.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 55 insertions(+), 3 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 5a213dcf46cd..24df167e9262 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -34,6 +34,56 @@ static int usage(void)
 	exit(-1);
 }
 
+static int have_rtnl_getnsid = -1;
+
+static int ipnetns_accept_msg(const struct sockaddr_nl *who,
+			      struct nlmsghdr *n, void *arg)
+{
+	struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(n);
+
+	if (n->nlmsg_type == NLMSG_ERROR &&
+	    (err->error == -EOPNOTSUPP || err->error == -EINVAL))
+		have_rtnl_getnsid = 0;
+	else
+		have_rtnl_getnsid = 1;
+	return -1;
+}
+
+static int ipnetns_have_nsid(void)
+{
+	struct {
+		struct nlmsghdr n;
+		struct rtgenmsg g;
+		char            buf[1024];
+	} req;
+	int fd;
+
+	if (have_rtnl_getnsid < 0) {
+		memset(&req, 0, sizeof(req));
+		req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg));
+		req.n.nlmsg_flags = NLM_F_REQUEST;
+		req.n.nlmsg_type = RTM_GETNSID;
+		req.g.rtgen_family = AF_UNSPEC;
+
+		fd = open("/proc/self/ns/net", O_RDONLY);
+		if (fd < 0) {
+			perror("open(\"/proc/self/ns/net\")");
+			exit(1);
+		}
+
+		addattr32(&req.n, 1024, NETNSA_FD, fd);
+
+		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) < 0) {
+			perror("request send failed");
+			exit(1);
+		}
+		rtnl_listen(&rth, ipnetns_accept_msg, NULL);
+		close(fd);
+	}
+
+	return have_rtnl_getnsid;
+}
+
 static int get_netnsid_from_name(const char *name)
 {
 	struct {
@@ -95,9 +145,11 @@ static int netns_list(int argc, char **argv)
 		if (strcmp(entry->d_name, "..") == 0)
 			continue;
 		printf("%s", entry->d_name);
-		id = get_netnsid_from_name(entry->d_name);
-		if (id >= 0)
-			printf(" (id: %d)", id);
+		if (ipnetns_have_nsid()) {
+			id = get_netnsid_from_name(entry->d_name);
+			if (id >= 0)
+				printf(" (id: %d)", id);
+		}
 		printf("\n");
 	}
 	closedir(dir);
-- 
2.2.2

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

* Re: [PATCH iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support
       [not found]       ` <f5aa0068662f470e988a01e3b92450f1@HQ1WP-EXMB12.corp.brocade.com>
@ 2015-04-13 15:53         ` Stephen Hemminger
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2015-04-13 15:53 UTC (permalink / raw)
  To: Nicolas Dichtel
  Cc: netdev@vger.kernel.org, vadim4j@gmail.com, jbenc@redhat.com

On Mon, 13 Apr 2015 08:23:05 +0000
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:

> The goal of this patch is to test during the runtime if the command RTM_GETNSID
> is supported by the kernel.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied for 4.0

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

end of thread, other threads:[~2015-04-13 15:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-08 19:42 [PATCH iproute2] configure: add missing INCLUDE to netnsid detection Jiri Benc
2015-04-08 19:40 ` Vadim Kochan
2015-04-10 16:17   ` Nicolas Dichtel
2015-04-13  8:23     ` [PATCH iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
2015-04-13  8:23       ` [PATCH iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
2015-04-13  8:23       ` [PATCH iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
2015-04-13  8:34         ` [PATCH v2 iproute2 1/3] Revert "configure: add missing INCLUDE to netnsid detection" Nicolas Dichtel
2015-04-13  8:34           ` [PATCH v2 iproute2 2/3] Revert "ip netns: Fix rtnl error while print netns list" Nicolas Dichtel
2015-04-13  8:34           ` [PATCH v2 iproute2 3/3] ipnetns: add a runtime check for RTM_GETNSID support Nicolas Dichtel
     [not found]       ` <f5aa0068662f470e988a01e3b92450f1@HQ1WP-EXMB12.corp.brocade.com>
2015-04-13 15:53         ` [PATCH " Stephen Hemminger
2015-04-10 20:25 ` [PATCH iproute2] configure: add missing INCLUDE to netnsid detection 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).