Re: [ovs-dev] [PATCH] ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".

2017-06-14 Thread Ben Pfaff
On Wed, Jun 14, 2017 at 02:26:04PM -0400, Aaron Conole wrote:
> Ben Pfaff  writes:
> 
> > 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.
> >
> > CC: Aaron Conole 
> > Signed-off-by: Ben Pfaff 
> > ---
> 
> LGTM.  Thanks for doing this, Ben!
> 
> Acked-by: Aaron Conole 

Thanks for the review.  I applied this to master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".

2017-06-14 Thread Aaron Conole
Ben Pfaff  writes:

> 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.
>
> CC: Aaron Conole 
> Signed-off-by: Ben Pfaff 
> ---

LGTM.  Thanks for doing this, Ben!

Acked-by: Aaron Conole 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ovs-ofctl: New option "--no-stats" for "ovs-ofctl dump-flows".

2017-06-13 Thread Ben Pfaff
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.

CC: Aaron Conole 
Signed-off-by: Ben Pfaff 
---
 NEWS|  8 +++---
 include/openvswitch/ofp-print.h |  2 +-
 lib/ofp-print.c | 50 ++
 ovn/utilities/ovn-sbctl.c   |  6 ++---
 ovn/utilities/ovn-trace.c   | 10 +++
 tests/bundle.at |  3 +--
 tests/learn.at  | 59 ++---
 utilities/ovs-ofctl.8.in| 14 --
 utilities/ovs-ofctl.c   | 12 ++---
 9 files changed, 87 insertions(+), 77 deletions(-)

diff --git a/NEWS b/NEWS
index b526646810f8..bc39aab5c4d7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,10 @@
 Post-v2.7.0
 -
-   - ovs-ofctl can now accept and display port names in place of numbers.  By
- default it always accepts names and in interactive use it displays them;
- use --names or --no-names to override.  See ovs-ofctl(8) for details.
+   - ovs-ofctl:
+ * ovs-ofctl can now accept and display port names in place of numbers.  By
+   default it always accepts names and in interactive use it displays them;
+   use --names or --no-names to override.  See ovs-ofctl(8) for details.
+ * "ovs-ofctl dump-flows" now accepts --no-stats to omit flow statistics.
- Tunnels:
  * Added support to set packet mark for tunnel endpoint using
`egress_pkt_mark` OVSDB option.
diff --git a/include/openvswitch/ofp-print.h b/include/openvswitch/ofp-print.h
index 4893d44b4b48..20f049a37f65 100644
--- a/include/openvswitch/ofp-print.h
+++ b/include/openvswitch/ofp-print.h
@@ -61,7 +61,7 @@ void ofp_print_table_features(
 const struct ofputil_table_stats *prev_stats);
 
 void ofp_print_flow_stats(struct ds *, const struct ofputil_flow_stats *,
-  const struct ofputil_port_map *);
+  const struct ofputil_port_map *, bool show_stats);
 
 #ifdef  __cplusplus
 }
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 423df31027d9..b1c412ea4c21 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1682,21 +1682,34 @@ ofp_print_flow_stats_request(struct ds *string, const 
struct ofp_header *oh,
 match_format(, port_map, string, OFP_DEFAULT_PRIORITY);
 }
 
+/* Appends a textual form of 'fs' to 'string', translating port numbers to
+ * names using 'port_map' (if provided).  If 'show_stats' is true, the output
+ * includes the flow duration, packet and byte counts, and its idle and hard
+ * ages, otherwise they are omitted. */
 void
 ofp_print_flow_stats(struct ds *string, const struct ofputil_flow_stats *fs,
- const struct ofputil_port_map *port_map)
+ const struct ofputil_port_map *port_map, bool show_stats)
 {
-ds_put_format(string, " %scookie=%s0x%"PRIx64", %sduration=%s",
-  colors.param, colors.end, ntohll(fs->cookie),
-  colors.param, colors.end);
-
-ofp_print_duration(string, fs->duration_sec, fs->duration_nsec);
-ds_put_format(string, ", %stable=%s%"PRIu8", ",
-  colors.special, colors.end, fs->table_id);
-ds_put_format(string, "%sn_packets=%s%"PRIu64", ",
-  colors.param, colors.end, fs->packet_count);
-ds_put_format(string, "%sn_bytes=%s%"PRIu64", ",
-  colors.param, colors.end, fs->byte_count);
+if (show_stats || fs->cookie) {
+ds_put_format(string, "%scookie=%s0x%"PRIx64", ",
+  colors.param, colors.end, ntohll(fs->cookie));
+}
+if (show_stats) {
+ds_put_format(string, "%sduration=%s", colors.param, colors.end);
+ofp_print_duration(string, fs->duration_sec, fs->duration_nsec);
+ds_put_cstr(string, ", ");
+}
+
+if (show_stats || fs->table_id) {
+ds_put_format(string, "%stable=%s%"PRIu8", ",
+  colors.special, colors.end, fs->table_id);
+}
+if (show_stats) {
+ds_put_format(string, "%sn_packets=%s%"PRIu64", ",
+  colors.param, colors.end, fs->packet_count);
+ds_put_format(string, "%sn_bytes=%s%"PRIu64", ",
+  colors.param, colors.end, fs->byte_count);
+}
 if (fs->idle_timeout != OFP_FLOW_PERMANENT) {
 ds_put_format(string, "%sidle_timeout=%s%"PRIu16", ",
   colors.param, colors.end, fs->idle_timeout);
@@ -1712,17 +1725,20 @@ ofp_print_flow_stats(struct ds *string, const struct 
ofputil_flow_stats *fs,
 ds_put_format(string, "%simportance=%s%"PRIu16", ",
   colors.param, colors.end, fs->importance);
 }
-if (fs->idle_age >= 0) {
+if (show_stats && fs->idle_age >= 0) {