ovs-ofctl: New --readd option for "replace-flows".
authorBen Pfaff <blp@nicira.com>
Wed, 27 Jul 2011 21:58:10 +0000 (14:58 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 27 Jul 2011 21:58:10 +0000 (14:58 -0700)
This is useful for resetting flows' byte and packet counters to 0.

Suggested-by: Jed Daniels <openvswitch@jeddaniels.com>
AUTHORS
ChangeLog
utilities/ovs-ofctl.8.in
utilities/ovs-ofctl.c

diff --git a/AUTHORS b/AUTHORS
index 2f720fc85ba9cd6ccaec8a1f934d73d0b22e4b71..62c19d5eaee2c2633a2cb661d404f5ff1467caf1 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -65,6 +65,7 @@ Hector Oron             hector.oron@gmail.com
 Henrik Amren            henrik@nicira.com
 Jad Naous               jnaous@gmail.com
 Jan Medved              jmedved@juniper.net
 Henrik Amren            henrik@nicira.com
 Jad Naous               jnaous@gmail.com
 Jan Medved              jmedved@juniper.net
+Jed Daniels             openvswitch@jeddaniels.com
 Jeongkeun Lee           jklee@hp.com
 Joan Cirer              joan@ev0.net
 John Galgay             john@galgay.net
 Jeongkeun Lee           jklee@hp.com
 Joan Cirer              joan@ev0.net
 John Galgay             john@galgay.net
index eaf4d85f30bf2700c9c2c909fb9ab6133eccd654..c38a50d4b8851748725276e406b68ae8f0a22ab2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ post v1.1.0
 ------------------------
     - The new "-s" option for "ovs-dpctl show" prints packet and byte
       counters for each port.
 ------------------------
     - The new "-s" option for "ovs-dpctl show" prints packet and byte
       counters for each port.
+    - ovs-ofctl:
+      - New "--readd" option for "replace-flows".
     - ovs-vsctl:
       - New "show" command to print an overview of configuration.
     - ovs-brcompatd has been rewritten to fix long-standing bugs.
     - ovs-vsctl:
       - New "show" command to print an overview of configuration.
     - ovs-brcompatd has been rewritten to fix long-standing bugs.
index bb52be22e1e680374aadc61881a3f0ae38872e95..c59bca9316896d2d712d5d4900478839ad6634cd 100644 (file)
@@ -143,7 +143,7 @@ Deletes entries from \fIswitch\fR's flow table.  With only a
 entries that match the specified flows.  With \fB\-\-strict\fR,
 wildcards are not treated as active for matching purposes.
 .
 entries that match the specified flows.  With \fB\-\-strict\fR,
 wildcards are not treated as active for matching purposes.
 .
-.IP "\fBreplace\-flows \fIswitch file\fR"
+.IP "[\fB\-\-readd\fR] \fBreplace\-flows \fIswitch file\fR"
 Reads flow entries from \fIfile\fR (or \fBstdin\fR if \fIfile\fR is
 \fB\-\fR) and queries the flow table from \fIswitch\fR.  Then it fixes
 up any differences, adding flows from \fIflow\fR that are missing on
 Reads flow entries from \fIfile\fR (or \fBstdin\fR if \fIfile\fR is
 \fB\-\fR) and queries the flow table from \fIswitch\fR.  Then it fixes
 up any differences, adding flows from \fIflow\fR that are missing on
@@ -151,6 +151,12 @@ up any differences, adding flows from \fIflow\fR that are missing on
 \fIfile\fR, and updating flows in \fIswitch\fR whose actions, cookie,
 or timeouts differ in \fIfile\fR.
 .
 \fIfile\fR, and updating flows in \fIswitch\fR whose actions, cookie,
 or timeouts differ in \fIfile\fR.
 .
+.IP
+With \fB\-\-readd\fR, \fBovs\-ofctl\fR adds all the flows from
+\fIfile\fR, even those that exist with the same actions, cookie, and
+timeout in \fIswitch\fR.  This resets all the flow packet and byte
+counters to 0, which can be useful for debugging.
+.
 .IP "\fBdiff\-flows \fIsource1 source2\fR"
 Reads flow entries from \fIsource1\fR and \fIsource2\fR and prints the
 differences.  A flow that is in \fIsource1\fR but not in \fIsource2\fR
 .IP "\fBdiff\-flows \fIsource1 source2\fR"
 Reads flow entries from \fIsource1\fR and \fIsource2\fR and prints the
 differences.  A flow that is in \fIsource1\fR but not in \fIsource2\fR
index 7cdf42db6e66382e1bf54f32907a54ba0c4546dc..e948c662b06d2fdb704ad43a8c2a401749215f55 100644 (file)
@@ -55,6 +55,10 @@ VLOG_DEFINE_THIS_MODULE(ofctl);
 /* --strict: Use strict matching for flow mod commands? */
 static bool strict;
 
 /* --strict: Use strict matching for flow mod commands? */
 static bool strict;
 
+/* --readd: If ture, on replace-flows, re-add even flows that have not changed
+ * (to reset flow counters). */
+static bool readd;
+
 /* -F, --flow-format: Flow format to use.  Either one of NXFF_* to force a
  * particular flow format or -1 to let ovs-ofctl choose intelligently. */
 static int preferred_flow_format = -1;
 /* -F, --flow-format: Flow format to use.  Either one of NXFF_* to force a
  * particular flow format or -1 to let ovs-ofctl choose intelligently. */
 static int preferred_flow_format = -1;
@@ -82,11 +86,13 @@ parse_options(int argc, char *argv[])
 {
     enum {
         OPT_STRICT = UCHAR_MAX + 1,
 {
     enum {
         OPT_STRICT = UCHAR_MAX + 1,
+        OPT_READD,
         VLOG_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"timeout", required_argument, NULL, 't'},
         {"strict", no_argument, NULL, OPT_STRICT},
         VLOG_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"timeout", required_argument, NULL, 't'},
         {"strict", no_argument, NULL, OPT_STRICT},
+        {"readd", no_argument, NULL, OPT_READD},
         {"flow-format", required_argument, NULL, 'F'},
         {"more", no_argument, NULL, 'm'},
         {"help", no_argument, NULL, 'h'},
         {"flow-format", required_argument, NULL, 'F'},
         {"more", no_argument, NULL, 'm'},
         {"help", no_argument, NULL, 'h'},
@@ -139,6 +145,10 @@ parse_options(int argc, char *argv[])
             strict = true;
             break;
 
             strict = true;
             break;
 
+        case OPT_READD:
+            readd = true;
+            break;
+
         VLOG_OPTION_HANDLERS
         STREAM_SSL_OPTION_HANDLERS
 
         VLOG_OPTION_HANDLERS
         STREAM_SSL_OPTION_HANDLERS
 
@@ -184,6 +194,7 @@ usage(void)
     vlog_usage();
     printf("\nOther options:\n"
            "  --strict                    use strict match for flow commands\n"
     vlog_usage();
     printf("\nOther options:\n"
            "  --strict                    use strict match for flow commands\n"
+           "  --readd                     replace flows that haven't changed\n"
            "  -F, --flow-format=FORMAT    force particular flow format\n"
            "  -m, --more                  be more verbose printing OpenFlow\n"
            "  -t, --timeout=SECS          give up after SECS seconds\n"
            "  -F, --flow-format=FORMAT    force particular flow format\n"
            "  -m, --more                  be more verbose printing OpenFlow\n"
            "  -t, --timeout=SECS          give up after SECS seconds\n"
@@ -1206,7 +1217,8 @@ do_replace_flows(int argc OVS_UNUSED, char *argv[])
         struct fte_version *file_ver = fte->versions[FILE_IDX];
         struct fte_version *sw_ver = fte->versions[SWITCH_IDX];
 
         struct fte_version *file_ver = fte->versions[FILE_IDX];
         struct fte_version *sw_ver = fte->versions[SWITCH_IDX];
 
-        if (file_ver && (!sw_ver || !fte_version_equals(sw_ver, file_ver))) {
+        if (file_ver
+            && (readd || !sw_ver || !fte_version_equals(sw_ver, file_ver))) {
             fte_make_flow_mod(fte, FILE_IDX, OFPFC_ADD, flow_format,
                               &requests);
         }
             fte_make_flow_mod(fte, FILE_IDX, OFPFC_ADD, flow_format,
                               &requests);
         }