From 16f2ae571fc7d21f13c9ddbe4e948d8f35552ae5 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 26 Mar 2010 09:35:32 -0700 Subject: [PATCH] xenserver: Ensure that Bridge.other-config:hwaddr and Interface.MAC are set as appropriate. 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 Signed-off-by: Ben Pfaff --- tests/interface-reconfigure.at | 8 ++++---- ...ource_libexec_InterfaceReconfigureVswitch.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at index feed2804..69f9830a 100644 --- a/tests/interface-reconfigure.at +++ b/tests/interface-reconfigure.at @@ -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 diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py index 6b60cb07..b102886e 100644 --- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py +++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py @@ -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 -- 2.30.2