summaryrefslogtreecommitdiff
path: root/utilities/ovs-ofctl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-06-13 17:09:05 -0700
committerBen Pfaff <blp@ovn.org>2017-06-14 12:50:23 -0700
commit1b3758c36e88fd261377726f9ab958a0be53f2ca (patch)
tree12b68e5006754b9a43edc337e537cf25b6181377 /utilities/ovs-ofctl.c
parent89cf41eca75e28b85423c04f0ed7665a0f160a26 (diff)
downloadopenvswitch-1b3758c36e88fd261377726f9ab958a0be53f2ca.tar.gz
ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".
It's pretty common to want to omit statistics from output, to make it easier to read. This commit adds an ovs-ofctl option to make that easy. A lot of the OVS internal tests could use this, too, in place of ofctl_strip. This commit adopts it for a subset. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
Diffstat (limited to 'utilities/ovs-ofctl.c')
-rw-r--r--utilities/ovs-ofctl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 95989eb11..d7e37e85f 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -135,6 +135,9 @@ static const struct ofputil_port_map *ports_to_show(const char *vconn_name);
static bool should_accept_ports(void);
static bool should_show_ports(void);
+/* --stats, --no-stats: Show statistics in flow dumps? */
+static int show_stats = 1;
+
static const struct ovs_cmdl_command *get_all_commands(void);
OVS_NO_RETURN static void usage(void);
@@ -212,6 +215,8 @@ parse_options(int argc, char *argv[])
{"rsort", optional_argument, NULL, OPT_RSORT},
{"names", no_argument, &use_port_names, 1},
{"no-names", no_argument, &use_port_names, 0},
+ {"stats", no_argument, &show_stats, 1},
+ {"no-stats", no_argument, &show_stats, 0},
{"unixctl", required_argument, NULL, OPT_UNIXCTL},
{"help", no_argument, NULL, 'h'},
{"option", no_argument, NULL, 'o'},
@@ -1357,7 +1362,7 @@ compare_flows(const void *afs_, const void *bfs_)
static void
ofctl_dump_flows(struct ovs_cmdl_context *ctx)
{
- if (!n_criteria && !should_show_ports()) {
+ if (!n_criteria && !should_show_ports() && show_stats) {
ofctl_dump_flows__(ctx->argc, ctx->argv, false);
return;
} else {
@@ -1378,8 +1383,9 @@ ofctl_dump_flows(struct ovs_cmdl_context *ctx)
struct ds s = DS_EMPTY_INITIALIZER;
for (size_t i = 0; i < n_fses; i++) {
ds_clear(&s);
- ofp_print_flow_stats(&s, &fses[i], ports_to_show(ctx->argv[1]));
- puts(ds_cstr(&s));
+ ofp_print_flow_stats(&s, &fses[i], ports_to_show(ctx->argv[1]),
+ show_stats);
+ printf(" %s\n", ds_cstr(&s));
}
ds_destroy(&s);