[ovs-dev] [PATCH] ofproto-dpif: Verbosity option for dpif/dump-flows command.

Gurucharan Shetty shettyg at nicira.com
Tue Dec 24 01:47:40 UTC 2013


The display of port names instead of port number for in_port
is considered useful. Enabling the verbosity option also lets
you see all the wildcarded fields and can be helpful.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 ofproto/ofproto-dpif-unixctl.man |    5 +++--
 ofproto/ofproto-dpif.c           |   22 +++++++++++++++++++---
 tests/ofproto-dpif.at            |    9 +++++++++
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/ofproto/ofproto-dpif-unixctl.man b/ofproto/ofproto-dpif-unixctl.man
index 0512b21..14e9ff2 100644
--- a/ofproto/ofproto-dpif-unixctl.man
+++ b/ofproto/ofproto-dpif-unixctl.man
@@ -11,9 +11,10 @@ list of connected ports.  The port information includes the OpenFlow
 port number, datapath port number, and the type.  (The local port is
 identified as OpenFlow port 65534.)
 .
-.IP "\fBdpif/dump\-flows \fIdp\fR"
+.IP "\fBdpif/dump\-flows\fR [\fB\-m\fR] \fIdp\fR"
 Prints to the console all flow entries in datapath \fIdp\fR's
-flow table.
+flow table. Without \fB\-m\fR, output omits match fields that a flow
+wildcards entirely; with \fB\-m\fR output includes all wildcarded fields.
 .IP
 This command is primarily useful for debugging Open vSwitch.  The flow
 table entries that it displays are not OpenFlow flow entries.  Instead,
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index befa9f7..52759b5 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3968,13 +3968,26 @@ ofproto_unixctl_dpif_dump_flows(struct unixctl_conn *conn,
     size_t actions_len;
     size_t mask_len;
     size_t key_len;
+    bool verbosity = false;
+    struct dpif_port dpif_port;
+    struct dpif_port_dump port_dump;
+    struct hmap portno_names;
 
-    ofproto = ofproto_dpif_lookup(argv[1]);
+    ofproto = ofproto_dpif_lookup(argv[argc - 1]);
     if (!ofproto) {
         unixctl_command_reply_error(conn, "no such bridge");
         return;
     }
 
+    if (argc > 2 && !strcmp(argv[1], "-m")) {
+        verbosity = true;
+    }
+
+    hmap_init(&portno_names);
+    DPIF_PORT_FOR_EACH (&dpif_port, &port_dump, ofproto->backer->dpif) {
+        odp_portno_names_set(&portno_names, dpif_port.port_no, dpif_port.name);
+    }
+
     ds_init(&ds);
     dpif_flow_dump_start(&flow_dump, ofproto->backer->dpif);
     while (dpif_flow_dump_next(&flow_dump, &key, &key_len, &mask, &mask_len,
@@ -3983,7 +3996,8 @@ ofproto_unixctl_dpif_dump_flows(struct unixctl_conn *conn,
             continue;
         }
 
-        odp_flow_format(key, key_len, mask, mask_len, NULL, &ds, false);
+        odp_flow_format(key, key_len, mask, mask_len, &portno_names, &ds,
+                        verbosity);
         ds_put_cstr(&ds, ", ");
         dpif_flow_stats_format(stats, &ds);
         ds_put_cstr(&ds, ", actions:");
@@ -3998,6 +4012,8 @@ ofproto_unixctl_dpif_dump_flows(struct unixctl_conn *conn,
     } else {
         unixctl_command_reply(conn, ds_cstr(&ds));
     }
+    odp_portno_names_destroy(&portno_names);
+    hmap_destroy(&portno_names);
     ds_destroy(&ds);
 }
 
@@ -4026,7 +4042,7 @@ ofproto_dpif_unixctl_init(void)
                              ofproto_unixctl_dpif_dump_dps, NULL);
     unixctl_command_register("dpif/show", "", 0, 0, ofproto_unixctl_dpif_show,
                              NULL);
-    unixctl_command_register("dpif/dump-flows", "bridge", 1, 1,
+    unixctl_command_register("dpif/dump-flows", "[-m] bridge", 1, 2,
                              ofproto_unixctl_dpif_dump_flows, NULL);
 }
 
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 7230854..3e74f80 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -2368,6 +2368,15 @@ AT_CHECK([ovs-appctl dpif/dump-flows br1 | sort | STRIP_USED], [0], [dnl
 skb_priority(0),in_port(3),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no/0xff), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
 ])
 
+AT_CHECK([ovs-appctl dpif/dump-flows -m br0 | sort | STRIP_USED], [0], [dnl
+skb_priority(0),skb_mark(0/0),in_port(p1),eth(src=50:54:00:00:00:05/00:00:00:00:00:00,dst=50:54:00:00:00:07/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.1/0.0.0.0,dst=192.168.0.2/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
+skb_priority(0),skb_mark(0/0),in_port(p2),eth(src=50:54:00:00:00:07/00:00:00:00:00:00,dst=50:54:00:00:00:05/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=192.168.0.2/0.0.0.0,dst=192.168.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=0/0,code=0/0), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
+])
+
+AT_CHECK([ovs-appctl dpif/dump-flows -m br1 | sort | STRIP_USED], [0], [dnl
+skb_priority(0),skb_mark(0/0),in_port(p3),eth(src=50:54:00:00:00:09/00:00:00:00:00:00,dst=50:54:00:00:00:0a/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller))
+])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
-- 
1.7.9.5




More information about the dev mailing list