[ovs-dev] [PATCH v3 08/12] dpctl: Add new 'flush-conntrack' command.

Daniele Di Proietto diproiettod at vmware.com
Wed Dec 2 19:46:22 UTC 2015


Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
 lib/dpctl.c   | 30 ++++++++++++++++++++++++++++++
 lib/dpctl.man |  6 ++++++
 2 files changed, 36 insertions(+)

diff --git a/lib/dpctl.c b/lib/dpctl.c
index 2990026..73204e2 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -1285,6 +1285,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;
+}
 
 /* Undocumented commands for unit testing. */
 
@@ -1564,6 +1593,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]", 0, 2, dpctl_dump_conntrack },
+    { "flush-conntrack", "[dp]", 0, 2, dpctl_flush_conntrack },
     { "help", "", 0, INT_MAX, dpctl_help },
     { "list-commands", "", 0, INT_MAX, dpctl_list_commands },
 
diff --git a/lib/dpctl.man b/lib/dpctl.man
index 54c3e8e..70df690 100644
--- a/lib/dpctl.man
+++ b/lib/dpctl.man
@@ -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.
-- 
2.1.4




More information about the dev mailing list