mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Don't allow IP addresses on ports enslaved in bonds or bridges
Ticket: CM-5146 Reviewed By: roopa,jtoppins Testing Done: built new ifupdown package and ran testifupdown2 suite of tests This patch prevents enslaved interfaces from having IP addresses. (cherry picked from commit 0c00606fbc76db11557a8e946310e93a2b376aa7) (cherry picked from commit dc30987acfc6af356b9e055db95d94ae45f0de9f)
This commit is contained in:
@@ -104,6 +104,11 @@ class address(moduleBase):
|
||||
newaddrs = []
|
||||
addrs = ifaceobj.get_attr_value('address')
|
||||
if addrs:
|
||||
if ifaceobj.role & ifaceRole.SLAVE:
|
||||
# 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' % \
|
||||
(ifaceobj.name))
|
||||
return
|
||||
# If user address is not in CIDR notation, convert them to CIDR
|
||||
for addr_index in range(0, len(addrs)):
|
||||
addr = addrs[addr_index]
|
||||
|
@@ -219,7 +219,8 @@ class bridge(moduleBase):
|
||||
return None
|
||||
if ifaceobj.link_type != ifaceLinkType.LINK_NA:
|
||||
ifaceobj.link_type = ifaceLinkType.LINK_MASTER
|
||||
ifaceobj.link_kind = ifaceLinkKind.BRIDGE
|
||||
ifaceobj.link_kind |= ifaceLinkKind.BRIDGE
|
||||
ifaceobj.role |= ifaceRole.MASTER
|
||||
ifaceobj.dependency_type = ifaceDependencyType.MASTER_SLAVE
|
||||
return self.parse_port_list(ifaceobj.get_attr_value_first(
|
||||
'bridge-ports'), ifacenames_all)
|
||||
|
@@ -128,6 +128,9 @@ class ifenslave(moduleBase):
|
||||
ifaceobj.priv_data = list(slave_list)
|
||||
if ifaceobj.link_type != ifaceLinkType.LINK_NA:
|
||||
ifaceobj.link_type = ifaceLinkType.LINK_MASTER
|
||||
ifaceobj.link_kind |= ifaceLinkKind.BOND
|
||||
ifaceobj.role |= ifaceRole.MASTER
|
||||
|
||||
return slave_list
|
||||
|
||||
def get_dependent_ifacenames_running(self, ifaceobj):
|
||||
|
@@ -95,6 +95,7 @@ class vlan(moduleBase):
|
||||
def get_dependent_ifacenames(self, ifaceobj, ifaceobjs_all=None):
|
||||
if not self._is_vlan_device(ifaceobj):
|
||||
return None
|
||||
ifaceobj.link_kind |= ifaceLinkKind.VLAN
|
||||
return [self._get_vlan_raw_device(ifaceobj)]
|
||||
|
||||
def _bridge_vid_add_del(self, ifaceobj, bridgename, vlanid,
|
||||
|
@@ -36,6 +36,12 @@ class vxlan(moduleBase):
|
||||
moduleBase.__init__(self, *args, **kargs)
|
||||
self.ipcmd = None
|
||||
|
||||
def get_dependent_ifacenames(self, ifaceobj, ifaceobjs_all=None):
|
||||
if not self._is_vxlan_device(ifaceobj):
|
||||
return None
|
||||
ifaceobj.link_kind |= ifaceLinkKind.VXLAN
|
||||
return None
|
||||
|
||||
def _is_vxlan_device(self, ifaceobj):
|
||||
if ifaceobj.get_attr_value_first('vxlan-id'):
|
||||
return True
|
||||
|
Reference in New Issue
Block a user