From 7f67f3e59f5571cf2df81accd8548cb6f3d60afc Mon Sep 17 00:00:00 2001 From: Sam Tannous Date: Wed, 24 Jun 2015 11:39:56 -0400 Subject: [PATCH] ifupdown2 should not allow IP address command under vlan aware bridge stanza Ticket: CM-6106 Reviewed By: roopa,scotte Testing Done: ran ifupdown2 regression suite and hand tested This patch prevents IP address assignment under vlan aware bridges. This prevents some confusion because a bridge subinterface is required for layer 3 termination. --- addons/address.py | 7 +++++-- addons/bridge.py | 3 +++ ifupdown/iface.py | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/address.py b/addons/address.py index 8d9bb75..029c391 100644 --- a/addons/address.py +++ b/addons/address.py @@ -104,9 +104,12 @@ class address(moduleBase): newaddrs = [] addrs = ifaceobj.get_attr_value('address') if addrs: - if ifaceobj.role & ifaceRole.SLAVE: + if (ifaceobj.role & ifaceRole.SLAVE) or \ + (ifaceobj.link_kind & ifaceLinkKind.BRIDGE_VLAN_AWARE): # we must not configure an IP address if the interface is enslaved - self.log_warn('interface %s is enslaved and cannot have an IP Address' % \ + # or is a VLAN AWARE BRIDGE + self.log_warn('interface %s is enslaved or a vlan aware bridge ' + 'and cannot have an IP Address' % \ (ifaceobj.name)) return # If user address is not in CIDR notation, convert them to CIDR diff --git a/addons/bridge.py b/addons/bridge.py index 012465a..390262d 100644 --- a/addons/bridge.py +++ b/addons/bridge.py @@ -220,6 +220,9 @@ class bridge(moduleBase): if ifaceobj.link_type != ifaceLinkType.LINK_NA: ifaceobj.link_type = ifaceLinkType.LINK_MASTER ifaceobj.link_kind |= ifaceLinkKind.BRIDGE + # for special vlan aware bridges, we need to add another bit + if ifaceobj.get_attr_value_first('bridge-vlan-aware') == 'yes': + ifaceobj.link_kind |= ifaceLinkKind.BRIDGE_VLAN_AWARE ifaceobj.role |= ifaceRole.MASTER ifaceobj.dependency_type = ifaceDependencyType.MASTER_SLAVE return self.parse_port_list(ifaceobj.get_attr_value_first( diff --git a/ifupdown/iface.py b/ifupdown/iface.py index 81ded1a..e38715d 100644 --- a/ifupdown/iface.py +++ b/ifupdown/iface.py @@ -44,6 +44,7 @@ class ifaceLinkKind(): BOND = 0x2 VLAN = 0x4 VXLAN = 0x8 + BRIDGE_VLAN_AWARE = 0x10 class ifaceLinkType(): LINK_UNKNOWN = 0x0