]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: bridge: disabling ipv6 on bridge if any VXLAN port
authorJulien Fortin <julien@cumulusnetworks.com>
Sun, 24 Apr 2016 22:32:59 +0000 (00:32 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Sun, 24 Apr 2016 22:32:59 +0000 (00:32 +0200)
Ticket: CM-7594
Reviewed By: Roopa
Testing Done: Creating a bridge with and without vxlan

addons/bridge.py
ifupdown/iface.py
ifupdown/ifupdownmain.py

index e1cbf709ef0909ebef7df89892c9506ba35c928a..98c5a00d8f66e786e3c374971450e0d001ab1bca 100644 (file)
@@ -306,14 +306,17 @@ class bridge(moduleBase):
             self.log_warn('%s: unable to process waitport: %s'
                     %(ifaceobj.name, str(e)))
 
-    def _ports_enable_disable_ipv6(self, ports, enable='1'):
+    def _enable_disable_ipv6(self, port, enable='1'):
+        try:
+            self.write_file('/proc/sys/net/ipv6/conf/%s/disable_ipv6' % port, enable)
+        except Exception, e:
+            self.logger.info(str(e))
+
+    def handle_ipv6(self, ports, state, ifaceobj=None):
+        if ifaceobj and (ifaceobj.link_privflags & ifaceLinkPrivFlags.BRIDGE_VXLAN):
+            self._enable_disable_ipv6(ifaceobj.name, state)
         for p in ports:
-            try:
-                self.write_file('/proc/sys/net/ipv6/conf/%s' %p +
-                                '/disable_ipv6', enable)
-            except Exception, e:
-                self.logger.info(str(e))
-                pass
+            self._enable_disable_ipv6(p, state)
 
     def _pretty_print_add_ports_error(self, errstr, bridgename, bridgeports):
         """ pretty print bridge port add errors.
@@ -395,7 +398,7 @@ class bridge(moduleBase):
             pass
 
         # enable ipv6 for ports that were removed
-        self._ports_enable_disable_ipv6(removedbridgeports, '0')
+        self.handle_ipv6(removedbridgeports, '0')
         if err:
             self.log_error('bridge configuration failed (missing ports)')
 
@@ -1061,7 +1064,7 @@ class bridge(moduleBase):
             if not running_ports:
                return
             # disable ipv6 for ports that were added to bridge
-            self._ports_enable_disable_ipv6(running_ports, '1')
+            self.handle_ipv6(running_ports, '1', ifaceobj=ifaceobj)
             self._apply_bridge_port_settings_all(ifaceobj,
                             ifaceobj_getfunc=ifaceobj_getfunc)
         except Exception, e:
@@ -1090,7 +1093,7 @@ class bridge(moduleBase):
                 ports = self.brctlcmd.get_bridge_ports(ifaceobj.name)
                 self.brctlcmd.delete_bridge(ifaceobj.name)
                 if ports:
-                    self._ports_enable_disable_ipv6(ports, '0')
+                    self.handle_ipv6(ports, '0', ifaceobj=ifaceobj)
                     if ifaceobj.link_type != ifaceLinkType.LINK_NA:
                         map(lambda p: rtnetlink_api.rtnl_api.link_set(p,
                                     "down"), ports)
index cccd39fb2f09113348ef2d7d370641f054fb4adb..69c3ef5453118a74828159bcb56e438fd661e6f7 100644 (file)
@@ -56,11 +56,12 @@ class ifaceLinkKind():
 class ifaceLinkPrivFlags():
     """ This corresponds to kernel netdev->priv_flags
         and can be BRIDGE_PORT, BOND_SLAVE etc """
-    UNKNOWN =           0x0000
-    BRIDGE_PORT =       0x0001
-    BOND_SLAVE =        0x0010
-    VRF_SLAVE =         0x0100
-    BRIDGE_VLAN_AWARE = 0x1000
+    UNKNOWN =           0x00000
+    BRIDGE_PORT =       0x00001
+    BOND_SLAVE =        0x00010
+    VRF_SLAVE =         0x00100
+    BRIDGE_VLAN_AWARE = 0x01000
+    BRIDGE_VXLAN =      0x10000
 
     @classmethod
     def get_str(cls, flag):
@@ -74,18 +75,22 @@ class ifaceLinkPrivFlags():
             return 'vrf slave'
         elif flag == cls.BRIDGE_VLAN_AWARE:
             return 'vlan aware bridge'
+        elif flag == cls.BRIDGE_VXLAN:
+            return 'vxlan bridge'
 
     @classmethod
     def get_all_str(cls, flags):
         str = ''
-        if (flags & cls.BRIDGE_PORT):
+        if flags & cls.BRIDGE_PORT:
             str += 'bridgeport '
-        if (flags == cls.BOND_SLAVE):
+        if flags & cls.BOND_SLAVE:
             str += 'bondslave '
-        elif flags == cls.VRF_SLAVE:
+        if flags & cls.VRF_SLAVE:
             str += 'vrfslave '
-        elif flags == cls.BRIDGE_VLAN_AWARE:
+        if flags & cls.BRIDGE_VLAN_AWARE:
             str += 'vlanawarebridge '
+        if flags & cls.BRIDGE_VXLAN:
+            str += 'vxlanbridge '
         return str
 
 class ifaceLinkType():
index 555549fe2a5052ba5a817b473fbf4e128520bef4..16b25bb6b7654414f6a544f32a53d3249e99df1b 100644 (file)
@@ -448,6 +448,10 @@ class ifupdownMain(ifupdownBase):
             self._set_iface_role(ifaceobj, ifaceRole.SLAVE, upperifaceobj)
             ifaceobj.link_privflags |= ifaceLinkPrivFlags.BRIDGE_PORT
 
+        if (ifaceobj.link_kind & ifaceLinkKind.VXLAN) \
+                and (upperifaceobj.link_kind & ifaceLinkKind.BRIDGE):
+            upperifaceobj.link_privflags |= ifaceLinkPrivFlags.BRIDGE_VXLAN
+
         # vrf masters get processed after slaves, which means
         # check both link_kind vrf and vrf slave
         if ((upperifaceobj.link_kind & ifaceLinkKind.VRF) or