]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: bridge: if device exists - check if device is really a bridge master-next
authorJulien Fortin <julien@cumulusnetworks.com>
Tue, 3 Jul 2018 08:06:40 +0000 (10:06 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Tue, 3 Jul 2018 08:13:09 +0000 (10:13 +0200)
[18:43:47] root:~ # ip link show swp3
5: swp3: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:27:bc:04:3c brd ff:ff:ff:ff:ff:ff
[18:43:48] root:~ #
[18:43:49] root:~ #
[18:43:50] root:~ # cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto swp3
iface swp3
bridge-vlan-aware yes
[18:43:50] root:~ #
[18:43:51] root:~ #
[18:43:51] root:~ # ifup -a
warning: swp3: error getting dependent interfaces (misconfiguration of bridge attribute(s) on existing non-bridge interface (swp3))
[18:43:56] root:~ # echo $?
1
[18:43:58] root:~ #

Reviewed-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ifupdown2/addons/bridge.py

index 259986af36f635f9d7c288448e5192a0f180fbe6..1b4dcddd0652d46f1679a162aae46bdda8e9536b 100644 (file)
@@ -826,8 +826,14 @@ class bridge(moduleBase):
             return True
         return False
 
+    def check_valid_bridge(self, ifaceobj, ifname):
+        if LinkUtils.link_exists(ifname) and not LinkUtils.is_bridge(ifname):
+            self.log_error('misconfiguration of bridge attribute(s) on existing non-bridge interface (%s)' % ifname, ifaceobj=ifaceobj)
+            return False
+        return True
+
     def get_dependent_ifacenames(self, ifaceobj, ifacenames_all=None):
-        if not self._is_bridge(ifaceobj):
+        if not self._is_bridge(ifaceobj) or not self.check_valid_bridge(ifaceobj, ifaceobj.name):
             return None
         if ifaceobj.link_type != ifaceLinkType.LINK_NA:
            ifaceobj.link_type = ifaceLinkType.LINK_MASTER