bond: Use bond_enable_slave at slave registration.
authorEthan Jackson <ethan@nicira.com>
Tue, 12 Apr 2011 22:15:32 +0000 (15:15 -0700)
committerEthan Jackson <ethan@nicira.com>
Wed, 13 Apr 2011 21:15:22 +0000 (14:15 -0700)
Slave registration should go through the normal slave enabling
facilities instead of doing it by hand.  Before this patch, newly
created slaves would have no tag associated with them.
Furthermore, any further changes to how slaves are enabled would
not be picked up by the registration code.

lib/bond.c

index ee0e68c..de71b9f 100644 (file)
@@ -357,7 +357,8 @@ bond_slave_register(struct bond *bond, void *slave_, struct netdev *netdev,
         slave->aux = slave_;
         slave->delay_expires = LLONG_MAX;
         slave->up = bond_is_link_up(bond, netdev);
-        slave->enabled = slave->up;
+        slave->enabled = false;
+        bond_enable_slave(slave, slave->up, NULL);
     }
 
     slave->netdev = netdev;
@@ -384,6 +385,8 @@ bond_slave_unregister(struct bond *bond, const void *slave_)
         return;
     }
 
+    bond_enable_slave(slave, false, NULL);
+
     del_active = bond->active_slave == slave;
     if (bond->hash) {
         struct bond_entry *e;
@@ -1321,7 +1324,9 @@ bond_enable_slave(struct bond_slave *slave, bool enable, struct tag_set *tags)
         slave->enabled = enable;
         if (!slave->enabled) {
             VLOG_WARN("interface %s: disabled", slave->name);
-            tag_set_add(tags, slave->tag);
+            if (tags) {
+                tag_set_add(tags, slave->tag);
+            }
         } else {
             VLOG_WARN("interface %s: enabled", slave->name);
             slave->tag = tag_create_random();