From 1b3758c36e88fd261377726f9ab958a0be53f2ca Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 13 Jun 2017 17:09:05 -0700 Subject: 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 Acked-by: Aaron Conole --- utilities/ovs-ofctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'utilities/ovs-ofctl.c') 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); -- cgit v1.2.1