[ovs-dev] [PATCH v3 5/6] nlmon: added netns support.

Flavio Leitner fbl at redhat.com
Thu Dec 7 02:22:23 UTC 2017


Signed-off-by: Flavio Leitner <fbl at redhat.com>
---
 utilities/nlmon.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/utilities/nlmon.c b/utilities/nlmon.c
index d38a70b6f..448b5eb5d 100644
--- a/utilities/nlmon.c
+++ b/utilities/nlmon.c
@@ -25,6 +25,7 @@
 #include <linux/rtnetlink.h>
 #include "netlink.h"
 #include "netlink-socket.h"
+#include "netnsid.h"
 #include "openvswitch/ofpbuf.h"
 #include "openvswitch/poll-loop.h"
 #include "timeval.h"
@@ -41,6 +42,7 @@ main(int argc OVS_UNUSED, char *argv[])
 {
     uint64_t buf_stub[4096 / 64];
     struct nl_sock *sock;
+    int nsid;
     struct ofpbuf buf;
     int error;
 
@@ -57,9 +59,10 @@ main(int argc OVS_UNUSED, char *argv[])
         ovs_fatal(error, "could not join RTNLGRP_LINK multicast group");
     }
 
+    nl_sock_listen_all_nsid(sock, true);
     ofpbuf_use_stub(&buf, buf_stub, sizeof buf_stub);
     for (;;) {
-        error = nl_sock_recv(sock, &buf, NULL, false);
+        error = nl_sock_recv(sock, &buf, &nsid, false);
         if (error == EAGAIN) {
             /* Nothing to do. */
         } else if (error == ENOBUFS) {
@@ -123,6 +126,11 @@ main(int argc OVS_UNUSED, char *argv[])
                 }
             }
             printf("\n");
+            if (netnsid_is_remote(nsid)) {
+                printf("\tnetns id: %d\n", nsid);
+            } else {
+                printf("\tnetns id: local\n");
+            }
             if (attrs[IFLA_MASTER]) {
                 uint32_t idx = nl_attr_get_u32(attrs[IFLA_MASTER]);
                 char ifname[IFNAMSIZ];
-- 
2.14.3



More information about the dev mailing list