dpctl: Add new 'flush-conntrack' command.
authorDaniele Di Proietto <diproiettod@vmware.com>
Wed, 28 Oct 2015 17:34:52 +0000 (10:34 -0700)
committerDaniele Di Proietto <diproiettod@vmware.com>
Tue, 22 Dec 2015 01:23:59 +0000 (17:23 -0800)
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joe@ovn.org>
lib/dpctl.c
lib/dpctl.man
utilities/ovs-dpctl.c

index 7d3a958..d58df0d 100644 (file)
@@ -1291,6 +1291,35 @@ dpctl_dump_conntrack(int argc, const char *argv[],
     return error;
 }
 
+static int
+dpctl_flush_conntrack(int argc, const char *argv[],
+                      struct dpctl_params *dpctl_p)
+{
+    struct dpif *dpif;
+    uint16_t zone, *pzone = NULL;
+    char *name;
+    int error;
+
+    if (argc > 1 && ovs_scan(argv[argc - 1], "zone=%"SCNu16, &zone)) {
+        pzone = &zone;
+        argc--;
+    }
+    name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p);
+    if (!name) {
+        return EINVAL;
+    }
+    error = parsed_dpif_open(name, false, &dpif);
+    free(name);
+    if (error) {
+        dpctl_error(dpctl_p, error, "opening datapath");
+        return error;
+    }
+
+    error = ct_dpif_flush(dpif, pzone);
+
+    dpif_close(dpif);
+    return error;
+}
 \f
 /* Undocumented commands for unit testing. */
 
@@ -1570,6 +1599,7 @@ static const struct dpctl_command all_commands[] = {
     { "del-flow", "del-flow [dp] flow", 1, 2, dpctl_del_flow },
     { "del-flows", "[dp]", 0, 1, dpctl_del_flows },
     { "dump-conntrack", "[dp] [zone=N]", 0, 2, dpctl_dump_conntrack },
+    { "flush-conntrack", "[dp] [zone=N]", 0, 2, dpctl_flush_conntrack },
     { "help", "", 0, INT_MAX, dpctl_help },
     { "list-commands", "", 0, INT_MAX, dpctl_list_commands },
 
index 54c3e8e..70df690 100644 (file)
@@ -173,3 +173,9 @@ Prints to the console all the connection entries in the tracker used by
 in \fBzone\fR.  With \fB\-\-more\fR, some implementation specific details
 are included. With \fB\-\-statistics\fR timeouts and timestamps are
 added to the output.
+.
+.TP
+\*(DX\fBflush\-conntrack [\fIdp\fR] [\fBzone=\fIzone\fR]
+Flushes all the connection entries in the tracker used by \fIdp\fR.
+If \fBzone=\fIzone\fR is specified, only flushes the connections in
+\fBzone\fR.
index a0e4aea..89a5a60 100644 (file)
@@ -172,6 +172,7 @@ usage(void *userdata OVS_UNUSED)
            "  del-flow [DP] FLOW         delete FLOW from DP\n"
            "  del-flows [DP]             delete all flows from DP\n"
            "  dump-conntrack [DP]        display conntrack entries\n"
+           "  flush-conntrack [DP]       delete all conntrack entries\n"
            "Each IFACE on add-dp, add-if, and set-if may be followed by\n"
            "comma-separated options.  See ovs-dpctl(8) for syntax, or the\n"
            "Interface table in ovs-vswitchd.conf.db(5) for an options list.\n"