xenserver: Kill bond master's dhclient when bringing up bond slave.
authorBen Pfaff <blp@nicira.com>
Mon, 28 Jun 2010 17:34:10 +0000 (10:34 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 28 Jun 2010 17:39:03 +0000 (10:39 -0700)
interface-reconfigure is never explicitly called to down a bond master.
However, when it is called to up a slave it is implicit that we are
destroying the master.  The "bridge" version of interface-reconfigure
always "ifdown"s the bond master in such a case, but until now the
"vswitch" version has not done so.  Usually, it doesn't matter, because
the bond master network device disappears when the slave is brought up,
but one case was missed: for a bond master with an IP address obtained
via DHCP, the dhclient process needs to be killed, and we were not doing
it.  This commit starts doing it (by invoking ifdown on the bond master).

The dhclient process that hangs around doesn't cause problems until the
bond master is brought back up, at which point "ifup" fails because it
refuses to start another dhclient for the same interface.

The converse behavior is also important; that is, when a bond PIF is
brought up, interface-reconfigure is expected to implicitly take down its
slave PIFs.  My testing (on 5.5.0) shows that this behavior is already
correct.  At any rate, this commit does not change that behavior.

Bug #2668.
Bug #2734.

Signed-off-by: Ben Pfaff <blp@nicira.com>
xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py

index c31fa2d..b737555 100644 (file)
@@ -421,7 +421,18 @@ class DatapathVswitch(Datapath):
         self._extra_ports = extra_ports
 
     def bring_down_existing(self):
-        pass
+        # interface-reconfigure is never explicitly called to down a
+        # bond master.  However, when we are called to up a slave it
+        # is implicit that we are destroying the master.
+        #
+        # This is (only) important in the case where the bond master
+        # uses DHCP.  We need to kill the dhclient process, otherwise
+        # bringing the bond master back up later will fail because
+        # ifup will refuse to start a duplicate dhclient.
+        bond_masters = pif_get_bond_masters(self._pif)
+        for master in bond_masters:
+            log("action_up: bring down bond master %s" % (pif_netdev_name(master)))
+            run_command(["/sbin/ifdown", pif_bridge_name(master)])
 
     def configure(self):
         # Bring up physical devices. ovs-vswitchd initially enables or