From 04b541dfe5c2b9027f365204b727133c9c574989 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Mon, 23 Dec 2013 17:43:48 -0800 Subject: [PATCH] ofproto-dpif: Verbosity option for dpif/dump-flows command. 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 Acked-by: Ben Pfaff --- 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 0512b2166..14e9ff2f1 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 befa9f710..52759b563 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 72308547e..3e74f8028 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 -- 2.43.0