[ovs-dev] [PATCH 3/3] ofp-parse: Ignore extra fields produced by dump-flows.

Ben Pfaff blp at nicira.com
Wed Jun 8 20:41:19 UTC 2011


It's reasonable to want to dump a flow table with "dump-flows" and then
later use that output as input to other commands that read flows, but until
now that hasn't been directly possible because "dump-flows" adds extra
fields that other commands reject on input.  This changes the flow parser
to just ignore those extra fields.
---
 lib/ofp-parse.c          |    6 ++++++
 utilities/ovs-ofctl.8.in |    5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 956f1c2..5b5bd59 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -883,6 +883,12 @@ parse_ofp_str(struct flow_mod *fm, struct ofpbuf *actions, char *string)
                     ovs_fatal(0, "only %d registers supported", FLOW_N_REGS);
                 }
                 parse_reg_value(&fm->cr, reg_idx, value);
+            } else if (!strcmp(name, "duration")
+                       || !strcmp(name, "n_packets")
+                       || !strcmp(name, "n_bytes")) {
+                /* Ignore these, so that users can feed the output of
+                 * "ovs-ofctl dump-flows" back into commands that parse
+                 * flows. */
             } else {
                 ovs_fatal(0, "unknown keyword %s", name);
             }
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 2d17d20..48a44e1 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -548,6 +548,11 @@ Same as \fBdl_type=0x86dd,nw_proto=17\fR.
 Same as \fBdl_type=0x86dd,nw_proto=58\fR.
 .
 .PP
+Finally, field assignments to \fBduration\fR, \fBn_packets\fR, or
+\fBn_bytes\fR are ignored to allow output from the \fBdump\-flows\fR
+command to be used as input for other commands that parse flows.
+.
+.PP
 The \fBadd\-flow\fR and \fBadd\-flows\fR commands require an additional
 field, which must be the final field specified:
 .
-- 
1.7.4.4




More information about the dev mailing list