diff --git a/addons/tunnel.py b/addons/tunnel.py index caf11c1..8277caf 100644 --- a/addons/tunnel.py +++ b/addons/tunnel.py @@ -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): diff --git a/ifupdownaddons/iproute2.py b/ifupdownaddons/iproute2.py index 21e6410..9e5a72a 100644 --- a/ifupdownaddons/iproute2.py +++ b/ifupdownaddons/iproute2.py @@ -761,7 +761,12 @@ class iproute2(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():