From 96e466a3c6aebd4ac21ddad971f6a7886a948f91 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Tue, 24 Jan 2012 14:33:23 -0800 Subject: [PATCH] ofproto: Optionally flush all learning tables with appctl. Signed-off-by: Ethan Jackson --- ofproto/ofproto-dpif.c | 23 +++++++++++++++-------- vswitchd/ovs-vswitchd.8.in | 5 +++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 471ba643d..ea5ed1ea4 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5812,18 +5812,25 @@ ofproto_dpif_lookup(const char *name) } static void -ofproto_unixctl_fdb_flush(struct unixctl_conn *conn, int argc OVS_UNUSED, +ofproto_unixctl_fdb_flush(struct unixctl_conn *conn, int argc, const char *argv[], void *aux OVS_UNUSED) { struct ofproto_dpif *ofproto; - ofproto = ofproto_dpif_lookup(argv[1]); - if (!ofproto) { - unixctl_command_reply(conn, 501, "no such bridge"); - return; + if (argc > 1) { + ofproto = ofproto_dpif_lookup(argv[1]); + if (!ofproto) { + unixctl_command_reply(conn, 501, "no such bridge"); + return; + } + mac_learning_flush(ofproto->ml); + ofproto->need_revalidate = true; + } else { + HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) { + mac_learning_flush(ofproto->ml); + ofproto->need_revalidate = true; + } } - mac_learning_flush(ofproto->ml); - ofproto->need_revalidate = true; unixctl_command_reply(conn, 200, "table successfully flushed"); } @@ -6124,7 +6131,7 @@ ofproto_dpif_unixctl_init(void) "ofproto/trace", "bridge {tun_id in_port packet | odp_flow [-generate]}", 2, 5, ofproto_unixctl_trace, NULL); - unixctl_command_register("fdb/flush", "bridge", 1, 1, + unixctl_command_register("fdb/flush", "[bridge]", 0, 1, ofproto_unixctl_fdb_flush, NULL); unixctl_command_register("fdb/show", "bridge", 1, 1, ofproto_unixctl_fdb_show, NULL); diff --git a/vswitchd/ovs-vswitchd.8.in b/vswitchd/ovs-vswitchd.8.in index b5f9f3e47..4fa707b1c 100644 --- a/vswitchd/ovs-vswitchd.8.in +++ b/vswitchd/ovs-vswitchd.8.in @@ -120,8 +120,9 @@ then displays detailed information about all interfaces with CFM enabled. .SS "BRIDGE COMMANDS" These commands manage bridges. -.IP "\fBfdb/flush\fR \fIbridge\fR" -Flushes \fIbridge\fR MAC address learning table. +.IP "\fBfdb/flush\fR [\fIbridge\fR]" +Flushes \fIbridge\fR MAC address learning table, or all learning tables +if no \fIbridge\fR is given. .IP "\fBfdb/show\fR \fIbridge\fR" Lists each MAC address/VLAN pair learned by the specified \fIbridge\fR, along with the port on which it was learned and the age of the entry, -- 2.43.0