From: Daniele Di Proietto Date: Wed, 28 Oct 2015 17:34:52 +0000 (-0700) Subject: dpctl: Add new 'flush-conntrack' command. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=7f278d1fbc88c35377145949827b2e30a41f8341 dpctl: Add new 'flush-conntrack' command. Signed-off-by: Daniele Di Proietto Acked-by: Joe Stringer --- diff --git a/lib/dpctl.c b/lib/dpctl.c index 7d3a95871..d58df0da9 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -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; +} /* 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 }, diff --git a/lib/dpctl.man b/lib/dpctl.man index 54c3e8efe..70df690b9 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. diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index a0e4aea4d..89a5a60a9 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -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"