From 6c28c31f47436a5c9c0dd4a6d06b630afc5bccff Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Mon, 13 Apr 2009 23:52:57 -0700 Subject: [PATCH] Add "dp-del-flows" command to dpctl. Add ability to delete flows from the datapath. Currently, there is no way to delete specific flows--it's all or nothing. By deleting flows from underneath the process that set them up, some confusion may arise. For vswitchd, this only amounts to a few warning messages, though. --- lib/dpif.c | 38 ++++++++++++++++++++++++++++++++++++++ utilities/dpctl.8.in | 8 ++++++++ utilities/dpctl.c | 13 +++++++++++++ 3 files changed, 59 insertions(+) diff --git a/lib/dpif.c b/lib/dpif.c index 119b40c3..d52c52ea 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -553,6 +553,44 @@ dpif_flow_list_all(const struct dpif *dpif, return 0; } +int +dpif_flow_del_all(struct dpif *dpif) +{ + struct odp_stats stats; + struct odp_flow *flows; + size_t n_flows; + size_t i; + int error; + + error = dpif_get_dp_stats(dpif, &stats); + if (error) { + return error; + } + + flows = xmalloc(sizeof *flows * stats.n_flows); + error = dpif_flow_list(dpif, flows, stats.n_flows, &n_flows); + if (error) { + free(flows); + return error; + } + + if (stats.n_flows != n_flows) { + VLOG_WARN_RL(&error_rl, "dp%u: datapath stats reported %"PRIu32" " + "flows but flow listing reported %zu", + dpif->minor, stats.n_flows, n_flows); + } + + for (i=0; iminor); + return error; + } + } + return 0; +} + int dpif_execute(struct dpif *dpif, uint16_t in_port, const union odp_action actions[], size_t n_actions, diff --git a/utilities/dpctl.8.in b/utilities/dpctl.8.in index f3b33403..9397ee60 100644 --- a/utilities/dpctl.8.in +++ b/utilities/dpctl.8.in @@ -110,6 +110,14 @@ OpenFlow flow entries. Instead, they are different and considerably simpler flows maintained by the datapaths used by the OpenFlow reference implementation. +.IP "\fBdp-del-flows \fIdp\fR" +Deletes all flow entries from datapath \fIdp\fR's flow table. + +This command is primarily useful for debugging the OpenFlow reference +implementation. As discussed in \fBdp-dump-flows\fR, these entries are +not OpenFlow flow entries. By deleting them, the process that set them +up may be confused about their disappearance. + .IP "\fBdp-dump-groups \fIdp\fR" Prints to the console the sets of port groups maintained by datapath \fIdp\fR. Ordinarily there are at least 2 port groups in a datapath diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 26e5160d..93651f5a 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -217,6 +217,7 @@ usage(void) " dp-show show basic info on all datapaths\n" " dp-show DP... show basic info on each DP\n" " dp-dump-flows DP display flows in DP\n" + " dp-del-flows DP delete all flows from DP\n" " dp-dump-groups DP display port groups in DP\n" "\nFor OpenFlow switches:\n" " show SWITCH show OpenFlow information\n" @@ -566,6 +567,17 @@ do_dp_dump_flows(const struct settings *s UNUSED, dpif_close(&dpif); } +static void +do_dp_del_flows(const struct settings *s UNUSED, + int argc UNUSED, char *argv[]) +{ + struct dpif dpif; + + run(dpif_open(argv[1], &dpif), "opening datapath"); + run(dpif_flow_del_all(&dpif), "deleting all flows"); + dpif_close(&dpif); +} + static void do_dp_dump_groups(const struct settings *s UNUSED, int argc UNUSED, char *argv[]) @@ -1675,6 +1687,7 @@ static struct command all_commands[] = { { "get-name", 1, 1, do_get_name }, { "dp-show", 0, INT_MAX, do_dp_show }, { "dp-dump-flows", 1, 1, do_dp_dump_flows }, + { "dp-del-flows", 1, 1, do_dp_del_flows }, { "dp-dump-groups", 1, 1, do_dp_dump_groups }, #endif -- 2.30.2