mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: bridge: add multi bridge support when bridge_set_static_mac_from_port=yes
The policy bridge_set_static_mac_from_port was added to ifupdown2 back when we didn't support a mix of traditional and vlan-aware bridges. The code wasn't revisited after such config was allowed on the system. how to repro: - set bridge_set_static_mac_from_port=yes in module_globals of: /var/lib/ifupdown2/policy.d/bridge.json auto br1 iface br1 bridge-vlan-aware no bridge-stp off bridge-ports swp1 auto bridge iface bridge bridge-ports swp7 bridge-vids 10 bridge-vlan-aware yes auto vlan10 iface vlan10 address 192.168.0.20/32 vlan-id 10 vlan-raw-device bridge br1 and bridge will share the same mac address (swp1's mac). Signed-off-by: Julien Fortin <julien@cumulusnetworks.com> Signed-off-by: Julien Fortin <jfortin@nvidia.com>
This commit is contained in:
committed by
Julien Fortin
parent
31bddf7647
commit
8b99615b83
@ -689,7 +689,8 @@ class bridge(Bridge, moduleBase):
|
||||
self.logger.debug('bridge: init: multiple vlans allowed %s' % self.bridge_allow_multiple_vlans)
|
||||
|
||||
self.bridge_mac_iface_list = policymanager.policymanager_api.get_module_globals(self.__class__.__name__, 'bridge_mac_iface') or []
|
||||
self.bridge_mac_iface = None, None # ifname, mac
|
||||
# each bridge should have it's own tuple (ifname, mac)
|
||||
self.bridge_mac_iface = {}
|
||||
|
||||
self.bridge_set_static_mac_from_port = utils.get_boolean_from_string(
|
||||
policymanager.policymanager_api.get_module_globals(
|
||||
@ -2601,8 +2602,10 @@ class bridge(Bridge, moduleBase):
|
||||
self.logger.warning('%s: setting bridge mac address: %s' % (ifaceobj.name, str(e)))
|
||||
|
||||
def _get_bridge_mac(self, ifaceobj, ifname, ifaceobj_getfunc):
|
||||
if self.bridge_mac_iface and self.bridge_mac_iface[0] and self.bridge_mac_iface[1]:
|
||||
return self.bridge_mac_iface
|
||||
bridge_mac_iface = self.bridge_mac_iface.get(ifname)
|
||||
|
||||
if bridge_mac_iface and bridge_mac_iface[0] and bridge_mac_iface[1]:
|
||||
return bridge_mac_iface
|
||||
|
||||
if self.bridge_mac_iface_list:
|
||||
self.logger.debug('bridge mac iface list: %s' % self.bridge_mac_iface_list)
|
||||
@ -2625,8 +2628,8 @@ class bridge(Bridge, moduleBase):
|
||||
iface_mac = self.cache.get_link_address(bridge_mac_intf)
|
||||
# if hwaddress attribute is not configured we use the running mac addr
|
||||
|
||||
self.bridge_mac_iface = (bridge_mac_intf, iface_mac)
|
||||
return self.bridge_mac_iface
|
||||
self.bridge_mac_iface[ifname] = (bridge_mac_intf, iface_mac)
|
||||
return self.bridge_mac_iface[ifname]
|
||||
elif self.bridge_set_static_mac_from_port:
|
||||
# no policy was provided, we need to get the first physdev or bond ports
|
||||
# and use its hwaddress to set the bridge mac
|
||||
@ -2641,8 +2644,8 @@ class bridge(Bridge, moduleBase):
|
||||
|
||||
if current_mac == port_mac:
|
||||
self.logger.info("bridge mac is already inherited from %s" % port)
|
||||
self.bridge_mac_iface = (port, port_mac)
|
||||
return self.bridge_mac_iface
|
||||
self.bridge_mac_iface[ifname] = (port, port_mac)
|
||||
return self.bridge_mac_iface[ifname]
|
||||
|
||||
for port in bridge_ports or []:
|
||||
# iterate through the bridge-port list
|
||||
@ -2660,8 +2663,8 @@ class bridge(Bridge, moduleBase):
|
||||
iface_mac = self.cache.get_link_address(port)
|
||||
|
||||
if iface_mac:
|
||||
self.bridge_mac_iface = (port, iface_mac)
|
||||
return self.bridge_mac_iface
|
||||
self.bridge_mac_iface[ifname] = (port, iface_mac)
|
||||
return self.bridge_mac_iface[ifname]
|
||||
|
||||
return None, None
|
||||
|
||||
|
Reference in New Issue
Block a user