]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: tunnel: fix tunnel v4 to v6 change
authorSven Auhagen <Sven.Auhagen@voleatech.de>
Wed, 4 Apr 2018 18:53:32 +0000 (20:53 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Thu, 13 Dec 2018 22:42:35 +0000 (14:42 -0800)
ifupdown2/addons/tunnel.py
ifupdown2/ifupdownaddons/LinkUtils.py

index caf11c1d3f546931a450bdc2dd52bc79458f8804..8277caf59603b0c51e08afb5cd750d0c6155212d 100644 (file)
@@ -87,12 +87,20 @@ class tunnel (moduleBase):
             if attr_val != None:
                 attrs[iproute_attr] = attr_val
 
-        if not self.ipcmd.link_exists(ifaceobj.name):
-            self.ipcmd.tunnel_create (ifaceobj.name, mode, attrs)
-        else:
-            attrs['mode'] = mode
-            self._check_settings(ifaceobj, attrs)
+        current_attrs = self.ipcmd.link_get_linkinfo_attrs(ifaceobj.name)
 
+        try:
+            if not self.ipcmd.link_exists(ifaceobj.name):
+                self.ipcmd.tunnel_create (ifaceobj.name, mode, attrs)
+            elif current_attrs and current_attrs['mode'] != mode and ( ('6' in mode and '6' not in current_attrs['mode']) or ('6' not in mode and '6' in current_attrs['mode']) ):
+                # Mode changes between ipv4 and ipv6 are not possible without recreating the interface
+                self.ipcmd.link_delete (ifaceobj.name)
+                self.ipcmd.tunnel_create (ifaceobj.name, mode, attrs)
+            else:
+                attrs['mode'] = mode
+                self._check_settings(ifaceobj, attrs)
+        except Exception, e:
+            self.log_warn (str (e))
 
     def _down (self, ifaceobj):
         if not ifupdownflags.flags.PERFMODE and not self.ipcmd.link_exists (ifaceobj.name):
index 58bba508c53108b34aa5f9775366a4184998e9b1..e4d06be6a88271aa68915670af3039872e2348a5 100644 (file)
@@ -1258,7 +1258,12 @@ class LinkUtils(utilsBase):
         """ generic link_create function """
         if self.link_exists(tunnelname):
             return
-        cmd = 'tunnel add'
+
+        cmd = ''
+        if '6' in mode:
+            cmd = ' -6 '
+
+        cmd += 'tunnel add'
         cmd += ' %s mode %s' %(tunnelname, mode)
         if attrs:
             for k, v in attrs.iteritems():