vswitchd: Be careful to sort all the svecs that are passed to svec_contains().
authorBen Pfaff <blp@nicira.com>
Wed, 31 Dec 2008 17:56:20 +0000 (09:56 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 31 Dec 2008 18:36:32 +0000 (10:36 -0800)
lib/svec.c
vswitchd/bridge.c

index 3a6f53deb6c68b3e21194394a7dc7edac2d23e39..054e5ffe77d3ce0e5f24a42592829f67fcb78b9b 100644 (file)
@@ -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;
 }
index fa76d3e0e58ae9e726c1a454d6b56c728caac5f2..1b9af42d959b7d248ee881702b0d1ad12222eb92 100644 (file)
@@ -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)) {