X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=b7f068bf0cd181407bc7cf74b8cca5b52c774bab;hb=efdd908807544de7bee8644fafc1400e6a32d936;hp=3768eb9c625657d858f1c2bad83c502f5fb67483;hpb=018f1525ed26ad4872350105e066b6b1eac5e867;p=sliver-openvswitch.git diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 3768eb9c6..b7f068bf0 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -195,6 +195,7 @@ static struct bridge *bridge_create(const struct ovsrec_bridge *br_cfg); static void bridge_destroy(struct bridge *); static struct bridge *bridge_lookup(const char *name); static unixctl_cb_func bridge_unixctl_dump_flows; +static unixctl_cb_func bridge_unixctl_reconnect; static int bridge_run_one(struct bridge *); static size_t bridge_get_controllers(const struct ovsrec_open_vswitch *ovs_cfg, const struct bridge *br, @@ -272,6 +273,8 @@ bridge_init(const char *remote) unixctl_command_register("fdb/show", bridge_unixctl_fdb_show, NULL); unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows, NULL); + unixctl_command_register("bridge/reconnect", bridge_unixctl_reconnect, + NULL); bond_init(); } @@ -642,9 +645,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) shash_init(&cur_ifaces); for (i = 0; i < n_dpif_ports; i++) { const char *name = dpif_ports[i].devname; - if (!shash_find(&cur_ifaces, name)) { - shash_add(&cur_ifaces, name, NULL); - } + shash_add_once(&cur_ifaces, name, NULL); } free(dpif_ports); @@ -1353,6 +1354,29 @@ bridge_unixctl_dump_flows(struct unixctl_conn *conn, ds_destroy(&results); } +/* "bridge/reconnect [BRIDGE]": makes BRIDGE drop all of its controller + * connections and reconnect. If BRIDGE is not specified, then all bridges + * drop their controller connections and reconnect. */ +static void +bridge_unixctl_reconnect(struct unixctl_conn *conn, + const char *args, void *aux OVS_UNUSED) +{ + struct bridge *br; + if (args[0] != '\0') { + br = bridge_lookup(args); + if (!br) { + unixctl_command_reply(conn, 501, "Unknown bridge"); + return; + } + ofproto_reconnect_controllers(br->ofproto); + } else { + LIST_FOR_EACH (br, struct bridge, node, &all_bridges) { + ofproto_reconnect_controllers(br->ofproto); + } + } + unixctl_command_reply(conn, 200, NULL); +} + static int bridge_run_one(struct bridge *br) {