Skip to content

Commit

Permalink
dpctl: Add new 'flush-conntrack' command.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Joe Stringer <[email protected]>
  • Loading branch information
ddiproietto committed Dec 22, 2015
1 parent 15eabc9 commit 7f278d1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/dpctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down Expand Up @@ -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 },

Expand Down
6 changes: 6 additions & 0 deletions lib/dpctl.man
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions utilities/ovs-dpctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7f278d1

Please sign in to comment.