xenserver: Ensure that Bridge.other-config:hwaddr and Interface.MAC are set as approp...
authorIan Campbell <ian.campbell@citrix.com>
Fri, 26 Mar 2010 16:35:32 +0000 (09:35 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 26 Mar 2010 16:35:46 +0000 (09:35 -0700)
Otherwise bridges can end up with a generated MAC address using Nicira OID
which has an impact when using DHCP on that devices.

tests/interface-reconfigure.at updated by Ben Pfaff.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
tests/interface-reconfigure.at
xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py

index feed2804e0cfcf0aabce7b5ab5d210c4a6088a45..69f9830a00d4715440fbb6e65fb4ba0a2ea05d64 100644 (file)
@@ -653,8 +653,8 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration
     --with-iface --if-exists del-port eth2
     --may-exist add-br xenbr2
     --may-exist add-port xenbr2 eth2
+    set Bridge xenbr2 other-config:hwaddr="00:15:17:a0:29:80"
     br-set-external-id xenbr2 network-uuids d08c8749-0c8f-9e8d-ce25-fd364661ee99
-    set Interface xenbr2 MAC="00:15:17:a0:29:80"
 /sbin/ifup xenbr2
 /sbin/update-issue
 Committing changes to /etc/sysconfig/network-scripts/route-xenbr2 configuration
@@ -716,8 +716,8 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi3 configuration
     --with-iface --if-exists del-port eth3
     --may-exist add-br xenbr3
     --may-exist add-port xenbr3 eth3
+    set Bridge xenbr3 other-config:hwaddr="00:15:17:a0:29:81"
     br-set-external-id xenbr3 network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
-    set Interface xenbr3 MAC="00:15:17:a0:29:81"
     --if-exists del-br xapi3
     --may-exist add-br xapi3 xenbr3 123
     br-set-external-id xapi3 network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
@@ -801,8 +801,8 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi1 configuration
     --with-iface --if-exists del-port bond0
     --fake-iface add-bond xapi1 bond0 eth0 eth1
     set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:"bond-miimon"=100 other-config:"bond-use_carrier"=1 other-config:"bond-mode"="balance-slb" bond_updelay=31000
+    set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af"
     br-set-external-id xapi1 network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
-    set Interface xapi1 MAC="00:22:19:22:4b:af"
 /sbin/ifup xapi1
 action_up: bring up bond0
 /sbin/ifconfig bond0 up
@@ -882,8 +882,8 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi2 configuration
     --with-iface --if-exists del-port bond0
     --fake-iface add-bond xapi1 bond0 eth0 eth1
     set Port bond0 MAC="00:22:19:22:4b:af" bond_downdelay=200 other-config:"bond-miimon"=100 other-config:"bond-use_carrier"=1 other-config:"bond-mode"="balance-slb" bond_updelay=31000
+    set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af"
     br-set-external-id xapi1 network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
-    set Interface xapi1 MAC="00:22:19:22:4b:af"
     --if-exists del-br xapi2
     --may-exist add-br xapi2 xapi1 4
     br-set-external-id xapi2 network-uuids 99be2da4-6c33-6f8e-49ea-3bc592fe3c85;45cbbb43-113d-a712-3231-c6463f253cef
index 6b60cb073e81b8608cb9252fe1b17a5c55af495e..b102886e0cabb89850dcabd18e1a7ee9881d6ceb 100644 (file)
@@ -297,6 +297,10 @@ def configure_datapath(pif):
         vsctl_argv += ['# add physical device %s' % iface]
         vsctl_argv += ['--', '--may-exist', 'add-port', bridge, iface]
 
+    vsctl_argv += ['# configure Bridge MAC']
+    vsctl_argv += ['--', 'set', 'Bridge', bridge,
+                   'other-config:hwaddr=%s' % vsctl_escape(db().get_pif_record(pif)['MAC'])]
+
     vsctl_argv += set_br_external_ids(pif)
     vsctl_argv += ['## done configuring datapath %s' % bridge]
 
@@ -337,10 +341,6 @@ def set_br_external_ids(pif):
     vsctl_argv += ['--', 'br-set-external-id', pif_bridge_name(pif),
             'network-uuids', ';'.join(xs_network_uuids)]
 
-    vsctl_argv += ['# configure MAC']
-    vsctl_argv += ['--', 'set', 'Interface', pif_ipdev_name(pif),
-                   'MAC=%s' % vsctl_escape(dprec['MAC'])]
-
     return vsctl_argv
 
 #
@@ -374,6 +374,8 @@ class DatapathVswitch(Datapath):
         vsctl_argv += c
         extra_ports += e
 
+        dpname = pif_bridge_name(self._dp)
+        
         if pif_is_vlan(self._pif):
             # XXX this is only needed on XS5.5, because XAPI misguidedly
             # creates the fake bridge (via bridge ioctl) before it calls us.
@@ -382,7 +384,7 @@ class DatapathVswitch(Datapath):
             # configure_datapath() set up the underlying datapath bridge.
             # Stack a VLAN bridge on top of it.
             vsctl_argv += ['--', '--may-exist', 'add-br',
-                           bridge, pif_bridge_name(self._dp), pifrec['VLAN']]
+                           bridge, dpname, pifrec['VLAN']]
 
             vsctl_argv += set_br_external_ids(self._pif)
 
@@ -392,6 +394,11 @@ class DatapathVswitch(Datapath):
             vsctl_argv += ["# reconfigure ipdev %s" % ipdev]
             vsctl_argv += ['--', 'add-port', bridge, ipdev]
 
+        if ipdev != dpname:
+            vsctl_argv += ['# configure Interface MAC']
+            vsctl_argv += ['--', 'set', 'Interface', pif_ipdev_name(self._pif),
+                           'MAC=%s' % vsctl_escape(dprec['MAC'])]
+
         self._vsctl_argv = vsctl_argv
         self._extra_ports = extra_ports