[ovs-discuss] [PATCH 1/6] ovs-dpctl: Add dump-dps command

Justin Pettit jpettit at nicira.com
Wed Aug 5 23:48:54 UTC 2009


The "dump-dps" command prints the name of each datapath on a separate
line.
---
 utilities/ovs-dpctl.8.in |    6 +++++-
 utilities/ovs-dpctl.c    |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/utilities/ovs-dpctl.8.in b/utilities/ovs-dpctl.8.in
index 652ebb1..8cb7098 100644
--- a/utilities/ovs-dpctl.8.in
+++ b/utilities/ovs-dpctl.8.in
@@ -1,4 +1,4 @@
-.TH ovs\-dpctl 8 "March 2009" "Open vSwitch" "Open vSwitch Manual"
+.TH ovs\-dpctl 8 "August 2009" "Open vSwitch" "Open vSwitch Manual"
 .ds PN ovs\-dpctl
 
 .SH NAME
@@ -87,6 +87,10 @@ Removes each \fInetdev\fR from the list of network devices datapath
 \fIdp\fR monitors.
 
 .TP
+\fBdump-dps
+Prints the name of each configured datapath on a separate line.
+
+.TP
 \fBshow \fR[\fIdp\fR...]
 Prints a summary of configured datapaths, including their datapath
 numbers and a list of ports connected to each datapath.  (The local
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index c44291b..c3c4122 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -157,6 +157,7 @@ usage(void)
            "  del-dp DP                delete local datapath DP\n"
            "  add-if DP IFACE...       add each IFACE as a port on DP\n"
            "  del-if DP IFACE...       delete each IFACE from DP\n"
+           "  dump-dps                 display names of all datapaths\n"
            "  show                     show basic info on all datapaths\n"
            "  show DP...               show basic info on each DP\n"
            "  dump-flows DP            display flows in DP\n"
@@ -466,6 +467,38 @@ do_show(int argc UNUSED, char *argv[])
 }
 
 static void
+do_dump_dps(int argc UNUSED, char *argv[] UNUSED)
+{
+    bool failure = false;
+    unsigned int i;
+
+    for (i = 0; i < ODP_MAX; i++) {
+        char name[128];
+        struct dpif dpif;
+        int error;
+
+        sprintf(name, "dp%u", i);
+        error = dpif_open(name, &dpif);
+        if (!error) {
+            struct odp_port *ports;
+            size_t n_ports;
+
+            query_ports(&dpif, &ports, &n_ports);
+            printf("%s\n", ports[0].devname);
+
+            free(ports);
+            dpif_close(&dpif);
+        } else if (error != ENODEV) {
+            ovs_error(error, "opening datapath %s failed", name);
+            failure = true;
+        }
+    }
+    if (failure) {
+        exit(EXIT_FAILURE);
+    }
+}
+
+static void
 do_dump_flows(int argc UNUSED, char *argv[])
 {
     struct odp_flow *flows;
@@ -543,6 +576,7 @@ static struct command all_commands[] = {
     { "del-dp", 1, 1, do_del_dp },
     { "add-if", 2, INT_MAX, do_add_if },
     { "del-if", 2, INT_MAX, do_del_if },
+    { "dump-dps", 0, 0, do_dump_dps },
     { "show", 0, INT_MAX, do_show },
     { "dump-flows", 1, 1, do_dump_flows },
     { "del-flows", 1, 1, do_del_flows },
-- 
1.5.5





More information about the discuss mailing list