From: Ben Pfaff Date: Wed, 31 Dec 2008 17:56:20 +0000 (-0800) Subject: vswitchd: Be careful to sort all the svecs that are passed to svec_contains(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b45d3b12f1aee6c3d48ac7fa47e6c157fe0d4c56;p=openvswitch vswitchd: Be careful to sort all the svecs that are passed to svec_contains(). --- diff --git a/lib/svec.c b/lib/svec.c index 3a6f53de..054e5ffe 100644 --- a/lib/svec.c +++ b/lib/svec.c @@ -195,6 +195,7 @@ svec_diff(const struct svec *a, const struct svec *b, bool svec_contains(const struct svec *svec, const char *name) { + assert(svec_is_sorted(svec)); return bsearch(&name, svec->names, svec->n, sizeof *svec->names, compare_strings) != NULL; } diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index fa76d3e0..1b9af42d 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -231,10 +231,11 @@ bridge_reconfigure(void) LIST_FOR_EACH (br, struct bridge, node, &all_bridges) { svec_add(&old_br, br->name); } - svec_sort(&old_br); cfg_get_subsections(&new_br, "bridge"); /* Get rid of deleted bridges and add new bridges. */ + svec_sort(&old_br); + svec_sort(&new_br); LIST_FOR_EACH_SAFE (br, next, struct bridge, node, &all_bridges) { if (!svec_contains(&new_br, br->name)) { bridge_destroy(br); @@ -751,6 +752,8 @@ bridge_reconfigure_one(struct bridge *br) cfg_get_all_keys(&new_ports, "bridge.%s.port", br->name); /* Get rid of deleted ports and add new ports. */ + svec_sort(&old_ports); + svec_sort(&new_ports); for (i = 0; i < br->n_ports; ) { struct port *port = br->ports[i]; if (!svec_contains(&new_ports, port->name)) {