diff mbox series

[ovs-dev,7/8] nlmon: added netns support.

Message ID 20171102190509.2688-8-fbl@redhat.com
State Superseded
Headers show
Series Add minimum network namespace support. | expand

Commit Message

Flavio Leitner Nov. 2, 2017, 7:05 p.m. UTC
Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 utilities/nlmon.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utilities/nlmon.c b/utilities/nlmon.c
index 08a117b58..609b152f9 100644
--- a/utilities/nlmon.c
+++ b/utilities/nlmon.c
@@ -41,6 +41,7 @@  main(int argc OVS_UNUSED, char *argv[])
 {
     uint64_t buf_stub[4096 / 64];
     struct nl_sock *sock;
+    struct netns ns;
     struct ofpbuf buf;
     int error;
 
@@ -57,9 +58,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, &ns, false);
         if (error == EAGAIN) {
             /* Nothing to do. */
         } else if (error == ENOBUFS) {
@@ -123,6 +125,11 @@  main(int argc OVS_UNUSED, char *argv[])
                 }
             }
             printf("\n");
+            if (netns_is_remote(&ns)) {
+                printf("\tnetns id: %d\n", ns.id);
+            } else {
+                printf("\tnetns id: local\n");
+            }
             if (attrs[IFLA_MASTER]) {
                 uint32_t idx = nl_attr_get_u32(attrs[IFLA_MASTER]);
                 char ifname[IFNAMSIZ];