summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-04 21:31:25 +0100
committerChristian Poessinger <christian@poessinger.com>2021-03-06 10:07:05 +0100
commita7301da66ab4b52c2a1c1a562d75b0def63ff93a (patch)
tree778f3ea86052399cb7f4a2a3bf54fc56b7f7a0fa
parentbab4537ae4c64dd622e69b43c97b79e8e6e63863 (diff)
downloadvyos-1x-a7301da66ab4b52c2a1c1a562d75b0def63ff93a.tar.gz
vyos-1x-a7301da66ab4b52c2a1c1a562d75b0def63ff93a.zip
tunnel: T3381: fix error when switching from mGRE to GRE mode
Linux does not support changing the remote address from any (multipoint GRE as used by DMVPN) to a discrete remote address. THis will return an error: add tunnel "tun1" failed: Invalid argument This can be handled by detecting the mGRE -> GRE change and re-create the tunnel silently. (cherry picked from commit ea2a22f7844735021fb638c911527e612abfbc69)
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_tunnel.py32
-rwxr-xr-xsrc/conf_mode/interfaces-tunnel.py8
2 files changed, 18 insertions, 22 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py
index 41300cf62..5ed2c924d 100755
--- a/smoketest/scripts/cli/test_interfaces_tunnel.py
+++ b/smoketest/scripts/cli/test_interfaces_tunnel.py
@@ -88,20 +88,13 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.commit()
conf = get_json_iface_options(interface)
- if encapsulation not in ['sit', 'gretap']:
+ if encapsulation not in ['sit', 'gre-bridge']:
self.assertEqual(source_if, conf['link'])
self.assertEqual(interface, conf['ifname'])
self.assertEqual(mtu, conf['mtu'])
-
- if encapsulation not in ['sit', 'gre-bridge']:
- self.assertEqual(source_if, conf['link'])
- self.assertEqual(encapsulation, conf['link_type'])
- elif encapsulation in ['gre-bridge']:
- self.assertEqual('ether', conf['link_type'])
-
self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local'])
- self.assertEqual(remote_ip4, conf['linkinfo']['info_data']['remote'])
+ self.assertEqual(remote_ip4, conf['linkinfo']['info_data']['remote'])
# cleanup this instance
self.session.delete(self._base_path + [interface])
@@ -140,16 +133,17 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.assertEqual(mtu, conf['mtu'])
self.assertEqual(source_if, conf['link'])
- # remap encapsulation protocol(s)
- if encapsulation in ['ipip6', 'ip6ip6']:
- encapsulation = 'tunnel6'
- elif encapsulation in ['ip6gre']:
- encapsulation = 'gre6'
+ # Not applicable for ip6gre
+ if 'proto' in conf['linkinfo']['info_data']:
+ self.assertEqual(encapsulation, conf['linkinfo']['info_data']['proto'])
- self.assertEqual(encapsulation, conf['link_type'])
+ # remap encapsulation protocol(s) only for ipip6, ip6ip6
+ if encapsulation in ['ipip6', 'ip6ip6']:
+ encapsulation = 'ip6tnl'
+ self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
self.assertEqual(self.local_v6, conf['linkinfo']['info_data']['local'])
- self.assertEqual(remote_ip6, conf['linkinfo']['info_data']['remote'])
+ self.assertEqual(remote_ip6, conf['linkinfo']['info_data']['remote'])
# cleanup this instance
self.session.delete(self._base_path + [interface])
@@ -182,10 +176,9 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
tos = '20'
self.session.set(self._base_path + [interface, 'encapsulation', encapsulation])
- self.session.set(self._base_path + [interface, 'source-address', self.local_v4])
- self.session.set(self._base_path + [interface, 'remote', remote_ip4])
+ self.session.set(self._base_path + [interface, 'local-ip', self.local_v4])
+ self.session.set(self._base_path + [interface, 'remote-ip', remote_ip4])
- self.session.set(self._base_path + [interface, 'parameters', 'ip', 'no-pmtu-discovery'])
self.session.set(self._base_path + [interface, 'parameters', 'ip', 'key', gre_key])
self.session.set(self._base_path + [interface, 'parameters', 'ip', 'tos', tos])
@@ -199,7 +192,6 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local'])
self.assertEqual(remote_ip4, conf['linkinfo']['info_data']['remote'])
self.assertEqual(0, conf['linkinfo']['info_data']['ttl'])
- self.assertFalse( conf['linkinfo']['info_data']['pmtudisc'])
def test_gretap_parameters_change(self):
interface = f'tun1040'
diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py
index d1d3616f6..e73c2b811 100755
--- a/src/conf_mode/interfaces-tunnel.py
+++ b/src/conf_mode/interfaces-tunnel.py
@@ -130,10 +130,14 @@ def apply(tunnel):
# remote addresses. This returns "Operation not supported" by the Kernel.
# There is no other solution to destroy and recreate the tunnel.
encap = ''
+ remote = ''
tmp = get_json_iface_options(interface)
- if tmp: encap = dict_search('linkinfo.info_kind', tmp)
+ if tmp:
+ encap = dict_search('linkinfo.info_kind', tmp)
+ remote = dict_search('linkinfo.info_data.remote', tmp)
- if 'deleted' in tunnel or 'encapsulation_changed' in tunnel or encap == 'gretap':
+ if ('deleted' in tunnel or 'encapsulation_changed' in tunnel or
+ encap in ['gretap', 'ip6gretap'] or remote in ['any']):
if interface in interfaces():
tmp = Interface(interface)
tmp.remove()