X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=001f9f68dcd3c71321d46a138119802fabac7f06;hb=9aa952b2dd7c091c63dbfc7becb3b3dcc9f7bfce;hp=951ce74e1739af18604392151b8d68099fd5260a;hpb=b3c01ed3308e7899e98e981bf465f74be86f5f12;p=openvswitch diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 951ce74e..001f9f68 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -374,8 +374,9 @@ static void bridge_configure_once(const struct ovsrec_open_vswitch *cfg) { static bool already_configured_once; - struct svec bridge_names; - struct svec dpif_names, dpif_types; + struct sset bridge_names; + struct sset dpif_names, dpif_types; + const char *type; size_t i; /* Only do this once per ovs-vswitchd run. */ @@ -387,30 +388,28 @@ bridge_configure_once(const struct ovsrec_open_vswitch *cfg) stats_timer = time_msec() + STATS_INTERVAL; /* Get all the configured bridges' names from 'cfg' into 'bridge_names'. */ - svec_init(&bridge_names); + sset_init(&bridge_names); for (i = 0; i < cfg->n_bridges; i++) { - svec_add(&bridge_names, cfg->bridges[i]->name); + sset_add(&bridge_names, cfg->bridges[i]->name); } - svec_sort(&bridge_names); /* Iterate over all system dpifs and delete any of them that do not appear * in 'cfg'. */ - svec_init(&dpif_names); - svec_init(&dpif_types); + sset_init(&dpif_names); + sset_init(&dpif_types); dp_enumerate_types(&dpif_types); - for (i = 0; i < dpif_types.n; i++) { - size_t j; + SSET_FOR_EACH (type, &dpif_types) { + const char *name; - dp_enumerate_names(dpif_types.names[i], &dpif_names); + dp_enumerate_names(type, &dpif_names); /* Delete each dpif whose name is not in 'bridge_names'. */ - for (j = 0; j < dpif_names.n; j++) { - if (!svec_contains(&bridge_names, dpif_names.names[j])) { + SSET_FOR_EACH (name, &dpif_names) { + if (!sset_contains(&bridge_names, name)) { struct dpif *dpif; int retval; - retval = dpif_open(dpif_names.names[j], dpif_types.names[i], - &dpif); + retval = dpif_open(name, type, &dpif); if (!retval) { dpif_delete(dpif); dpif_close(dpif); @@ -418,9 +417,9 @@ bridge_configure_once(const struct ovsrec_open_vswitch *cfg) } } } - svec_destroy(&bridge_names); - svec_destroy(&dpif_names); - svec_destroy(&dpif_types); + sset_destroy(&bridge_names); + sset_destroy(&dpif_names); + sset_destroy(&dpif_types); } /* Callback for iterate_and_prune_ifaces(). */ @@ -820,12 +819,14 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) } } - opts.collectors.n = nf_cfg->n_targets; - opts.collectors.names = nf_cfg->targets; + sset_init(&opts.collectors); + sset_add_array(&opts.collectors, + nf_cfg->targets, nf_cfg->n_targets); if (ofproto_set_netflow(br->ofproto, &opts)) { VLOG_ERR("bridge %s: problem setting netflow collectors", br->name); } + sset_destroy(&opts.collectors); } else { ofproto_set_netflow(br->ofproto, NULL); } @@ -839,8 +840,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) memset(&oso, 0, sizeof oso); - oso.targets.n = sflow_cfg->n_targets; - oso.targets.names = sflow_cfg->targets; + sset_init(&oso.targets); + sset_add_array(&oso.targets, + sflow_cfg->targets, sflow_cfg->n_targets); oso.sampling_rate = SFL_DEFAULT_SAMPLING_RATE; if (sflow_cfg->sampling) { @@ -870,7 +872,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) } ofproto_set_sflow(br->ofproto, &oso); - /* Do not destroy oso.targets because it is owned by sflow_cfg. */ + sset_destroy(&oso.targets); } else { ofproto_set_sflow(br->ofproto, NULL); } @@ -1812,7 +1814,6 @@ static void bridge_reconfigure_one(struct bridge *br) { enum ofproto_fail_mode fail_mode; - struct svec snoops, old_snoops; struct port *port, *next; struct shash_node *node; struct shash new_ports; @@ -1892,16 +1893,15 @@ bridge_reconfigure_one(struct bridge *br) * controller to another?) */ /* Configure OpenFlow controller connection snooping. */ - svec_init(&snoops); - svec_add_nocopy(&snoops, xasprintf("punix:%s/%s.snoop", - ovs_rundir(), br->name)); - svec_init(&old_snoops); - ofproto_get_snoops(br->ofproto, &old_snoops); - if (!svec_equal(&snoops, &old_snoops)) { + if (!ofproto_has_snoops(br->ofproto)) { + struct sset snoops; + + sset_init(&snoops); + sset_add_and_free(&snoops, xasprintf("punix:%s/%s.snoop", + ovs_rundir(), br->name)); ofproto_set_snoops(br->ofproto, &snoops); + sset_destroy(&snoops); } - svec_destroy(&snoops); - svec_destroy(&old_snoops); mirror_reconfigure(br); }