From 1a9181807c3e0517a7ef618f01079d752cdf56c1 Mon Sep 17 00:00:00 2001 From: Lee Clements Date: Fri, 6 Nov 2026 17:14:05 +0100 Subject: tunnel: T9193: match GRE tunnel uniqueness check to the Kernel The pairwise GRE collision check did not follow the Kernel's notion of a duplicate tunnel. With a key set it ignored remote and source-interface, rejecting tunnels the Kernel keeps apart. Without one it refused keyless tunnels on different source-interfaces, and collided a keyless tunnel with a keyed one, which also left the keyless tunnel failing every later commit. A zero key was judged differently depending on which side was verified. Two tunnels now collide only when local address, remote, source-interface and key all match, as ip_tunnel_find() decides. An any address counts as unset, and a zero key is treated as no key only where neither endpoint is set. Keys are compared as the value the Kernel stores, so octal spellings such as "010" are caught and invalid ones such as "08" are refused on commit. Error messages name the configured source and the shared node. Smoketests cover the new cases. --- smoketest/scripts/cli/test_interfaces_tunnel.py | 291 ++++++++++++++++++++++++ 1 file changed, 291 insertions(+) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py index 8eb32b7ca..e8f992793 100755 --- a/smoketest/scripts/cli/test_interfaces_tunnel.py +++ b/smoketest/scripts/cli/test_interfaces_tunnel.py @@ -26,6 +26,7 @@ from vyos.template import inc_ip remote_ip4 = '192.0.2.100' remote_ip6 = '2001:db8::ffff' source_if = 'dum2222' +source_if2 = 'dum2223' mtu = 1476 class TunnelInterfaceTest(BasicInterfaceTest.TestCase): @@ -45,10 +46,12 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): # create some test interfaces cls.cli_set(cls, ['interfaces', 'dummy', source_if, 'address', cls.local_v4 + '/32']) cls.cli_set(cls, ['interfaces', 'dummy', source_if, 'address', cls.local_v6 + '/128']) + cls.cli_set(cls, ['interfaces', 'dummy', source_if2]) @classmethod def tearDownClass(cls): cls.cli_delete(cls, ['interfaces', 'dummy', source_if]) + cls.cli_delete(cls, ['interfaces', 'dummy', source_if2]) super().tearDownClass() def test_ipv4_encapsulations(self): @@ -321,10 +324,25 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): # GRE key must be supplied with a 0.0.0.0 source address with self.assertRaises(ConfigSessionError): self.cli_commit() + + # A zero key is no key at all for such a tunnel - with an any + # source-address and no remote it catches every packet, exactly as a + # keyless tunnel would + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '0']) + with self.assertRaises(ConfigSessionError): + self.cli_commit() + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', key]) self.cli_commit() + # A remote address identifies the tunnel on its own, so a zero key is + # no longer a problem + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '0']) + self.cli_set(self._base_path + [interface, 'remote', remote_ip4]) + + self.cli_commit() + def test_multiple_gre_tunnel_same_remote(self): tunnels = { 'tun10' : { @@ -394,6 +412,279 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): self.assertEqual(tunnel_config['encapsulation'], conf['linkinfo']['info_kind']) self.assertEqual(tunnel_config['remote'], conf['linkinfo']['info_data']['remote']) + def test_multiple_gre_tunnel_same_key_different_remote(self): + # The Kernel identifies a tunnel by local address, remote address, + # source-interface and key - a differing remote address is enough to + # make both tunnels unique, even if they share one GRE key + ip_key = '10' + tunnels = { + 'tun10': '1.2.3.4', + 'tun20': '1.2.3.5', + } + + for tunnel, remote in tunnels.items(): + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + [tunnel, 'remote', remote]) + self.cli_set(self._base_path + [tunnel, 'parameters', 'ip', 'key', ip_key]) + + self.cli_commit() + + for tunnel, remote in tunnels.items(): + conf = get_interface_config(tunnel) + + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + self.assertEqual(remote, conf['linkinfo']['info_data']['remote']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['ikey']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['okey']) + + def test_multiple_gre_tunnel_same_key_different_source_interface(self): + # Tunnels bound to different source-interfaces are distinct for the + # Kernel, thus they are free to share one GRE key + ip_key = '20' + tunnels = { + 'tun10': source_if, + 'tun20': source_if2, + } + + for tunnel, interface in tunnels.items(): + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-interface', interface]) + self.cli_set(self._base_path + [tunnel, 'parameters', 'ip', 'key', ip_key]) + + self.cli_commit() + + for tunnel, interface in tunnels.items(): + conf = get_interface_config(tunnel) + + self.assertEqual(interface, conf['link']) + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['ikey']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['okey']) + + def test_multiple_gre_tunnel_any_remote(self): + # The Kernel stores an unset remote address as the any address, thus + # "remote 0.0.0.0" and an unset remote must be treated alike - creating + # both would fail with "add tunnel "gre0" failed: File exists" + ip_key = '30' + + for tunnel in ['tun10', 'tun20']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + [tunnel, 'parameters', 'ip', 'key', ip_key]) + self.cli_set(self._base_path + ['tun10', 'remote', '0.0.0.0']) + + # Both tunnels resolve to the same Kernel tunnel - this must be rejected + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + # A differing key makes them unique again + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '31']) + self.cli_commit() + + def test_multiple_gre_tunnel_keyless_and_keyed(self): + # A keyless tunnel is distinct from a keyed one even when both share + # the same local and remote address - the Kernel only matches a tunnel + # carrying no key against another tunnel carrying no key + ip_key = '40' + + for tunnel in ['tun10', 'tun20']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + ['tun20', 'remote', '0.0.0.0']) + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', ip_key]) + + self.cli_commit() + + # Re-verifying the keyless tunnel must keep succeeding - if it does not, + # the next commit touching it fails and it is lost on the next boot + self.cli_set(self._base_path + ['tun10', 'description', 'foo']) + self.cli_commit() + + conf = get_interface_config('tun10') + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + self.assertNotIn('ikey', conf['linkinfo']['info_data']) + + conf = get_interface_config('tun20') + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['ikey']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['okey']) + + def test_multiple_gre_tunnel_keyless_different_source_interface(self): + # Tunnels bound to different source-interfaces stay distinct for the + # Kernel even when they share one local and remote address - "dev" is + # compared as the tunnel link index - so no GRE key is needed to tell + # them apart + remote = '1.2.3.4' + tunnels = { + 'tun10': source_if, + 'tun20': source_if2, + } + + for tunnel, interface in tunnels.items(): + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + [tunnel, 'source-interface', interface]) + self.cli_set(self._base_path + [tunnel, 'remote', remote]) + + self.cli_commit() + + for tunnel, interface in tunnels.items(): + conf = get_interface_config(tunnel) + + self.assertEqual(interface, conf['link']) + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + self.assertEqual(remote, conf['linkinfo']['info_data']['remote']) + self.assertNotIn('ikey', conf['linkinfo']['info_data']) + + def test_multiple_gre_tunnel_zero_key(self): + # Carrying neither a source-address nor a remote, these tunnels are only + # told apart by their key - and a zero key does not do that, it cannot be + # told from an unset one on receive. A non-zero key can + for tunnel in ['tun10', 'tun20']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-interface', source_if]) + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '0']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '50']) + self.cli_commit() + + conf = get_interface_config('tun20') + self.assertEqual('0.0.0.50', conf['linkinfo']['info_data']['ikey']) + self.assertEqual('0.0.0.50', conf['linkinfo']['info_data']['okey']) + + # Dropping back to a zero key must be rejected just the same. Only the + # tunnel which changed is verified again here, so this is the case a + # check trusting its own zero key - but not the neighbours - lets + # through: both tunnels commit, and every later commit touching the + # keyless one is refused from then on + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '0']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + def test_multiple_gre_tunnel_zero_key_with_endpoints(self): + # A zero key does tell a tunnel apart from a keyless one as soon as a + # local or a remote address is set - the Kernel then matches through + # ip_tunnel_key_match(), which tests the flag saying that a key is set + # before it compares the value + for tunnel in ['tun10', 'tun20']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '0']) + + # The same holds when it is the remote address which identifies them + for tunnel in ['tun30', 'tun40']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-interface', source_if]) + self.cli_set(self._base_path + [tunnel, 'remote', remote_ip4]) + self.cli_set(self._base_path + ['tun40', 'parameters', 'ip', 'key', '0']) + + self.cli_commit() + + # Re-verifying the keyless tunnels must keep succeeding - if it does + # not, the next commit touching them fails and they are lost on the + # next boot + for tunnel in ['tun10', 'tun30']: + self.cli_set(self._base_path + [tunnel, 'description', 'foo']) + + self.cli_commit() + + for tunnel in ['tun10', 'tun20']: + conf = get_interface_config(tunnel) + + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + + for tunnel in ['tun30', 'tun40']: + conf = get_interface_config(tunnel) + + self.assertEqual(source_if, conf['link']) + self.assertEqual('gre', conf['linkinfo']['info_kind']) + self.assertEqual(remote_ip4, conf['linkinfo']['info_data']['remote']) + + # The keyless tunnels must have stayed keyless. That the commit went + # through at all is what proves the zero key reached the Kernel with its + # flag set - dropped, it would have left two keyless tunnels sharing one + # endpoint and the second of them could not have been created + for tunnel in ['tun10', 'tun30']: + conf = get_interface_config(tunnel) + + self.assertNotIn('ikey', conf['linkinfo']['info_data']) + + def test_tunnel_gre_key_leading_zero(self): + # iproute2 parses the key with strtoul(3) and base 0, so a leading zero + # makes it octal - "00" is the very same zero key as "0" and must be + # refused for a tunnel which carries no endpoint at all + interface = 'tun1281' + + self.cli_set(self._base_path + [interface, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [interface, 'source-address', '0.0.0.0']) + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '00']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + # "010" is octal 8 and does identify the tunnel + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '010']) + + self.cli_commit() + + conf = get_interface_config(interface) + self.assertEqual('0.0.0.8', conf['linkinfo']['info_data']['ikey']) + + def test_tunnel_gre_key_octal_collision(self): + # "010" reaches the Kernel as 8, thus it collides with a plain "8" on an + # otherwise identical tunnel although the two strings differ + for tunnel in ['tun10', 'tun20']: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + ['tun10', 'parameters', 'ip', 'key', '010']) + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '8']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + # "010" and "10" are 8 and 10 - different keys, so both tunnels fit + self.cli_set(self._base_path + ['tun20', 'parameters', 'ip', 'key', '10']) + + self.cli_commit() + + self.assertEqual( + '0.0.0.8', get_interface_config('tun10')['linkinfo']['info_data']['ikey'] + ) + self.assertEqual( + '0.0.0.10', get_interface_config('tun20')['linkinfo']['info_data']['ikey'] + ) + + def test_tunnel_gre_key_invalid_octal(self): + # The numeric validator takes "08", but a leading zero makes the key + # octal where "8" is no digit - iproute2 refuses the value outright, so + # the tunnel could never be created and this must fail on commit + interface = 'tun1282' + + self.cli_set(self._base_path + [interface, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [interface, 'source-address', self.local_v4]) + self.cli_set(self._base_path + [interface, 'remote', remote_ip4]) + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '08']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '8']) + + self.cli_commit() + + conf = get_interface_config(interface) + self.assertEqual('0.0.0.8', conf['linkinfo']['info_data']['ikey']) + def test_tunnel_invalid_source_interface(self): encapsulation = 'gre' remote = '192.0.2.1' -- cgit v1.2.3 From b3c4828f5386d3c3ee53501e7711178a1fcf8e78 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 5 Nov 2026 23:17:40 +0100 Subject: tunnel: T9193: do not collide GRE tunnels of different encapsulation The Kernel keeps gre and gretap tunnels in tables of their own, so a gre and a gretap tunnel may share local address, remote address and GRE key. Only compare tunnels of the same encapsulation. --- smoketest/scripts/cli/test_interfaces_tunnel.py | 25 +++++++++++++++++++++++++ src/conf_mode/interfaces_tunnel.py | 11 +++++------ 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py index e8f992793..ba30a0e73 100755 --- a/smoketest/scripts/cli/test_interfaces_tunnel.py +++ b/smoketest/scripts/cli/test_interfaces_tunnel.py @@ -619,6 +619,31 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): self.assertNotIn('ikey', conf['linkinfo']['info_data']) + def test_gre_and_gretap_tunnel_same_key(self): + # The Kernel keeps gre and gretap tunnels in tables of their own, so + # both may share local address, remote address and GRE key + ip_key = '60' + tunnels = { + 'tun10': 'gre', + 'tun20': 'gretap', + } + + for tunnel, encapsulation in tunnels.items(): + self.cli_set(self._base_path + [tunnel, 'encapsulation', encapsulation]) + self.cli_set(self._base_path + [tunnel, 'source-address', self.local_v4]) + self.cli_set(self._base_path + [tunnel, 'remote', remote_ip4]) + self.cli_set(self._base_path + [tunnel, 'parameters', 'ip', 'key', ip_key]) + + self.cli_commit() + + for tunnel, encapsulation in tunnels.items(): + conf = get_interface_config(tunnel) + + self.assertEqual(encapsulation, conf['linkinfo']['info_kind']) + self.assertEqual(self.local_v4, conf['linkinfo']['info_data']['local']) + self.assertEqual(remote_ip4, conf['linkinfo']['info_data']['remote']) + self.assertEqual(f'0.0.0.{ip_key}', conf['linkinfo']['info_data']['ikey']) + def test_tunnel_gre_key_leading_zero(self): # iproute2 parses the key with strtoul(3) and base 0, so a leading zero # makes it octal - "00" is the very same zero key as "0" and must be diff --git a/src/conf_mode/interfaces_tunnel.py b/src/conf_mode/interfaces_tunnel.py index 8476aa7f6..f525e9e27 100644 --- a/src/conf_mode/interfaces_tunnel.py +++ b/src/conf_mode/interfaces_tunnel.py @@ -66,7 +66,8 @@ def tunnel_identity(conf): """ The Kernel identifies a GRE tunnel by the tuple of local address, remote address, source-interface and key, see ip_tunnel_find() in - net/ipv4/ip_tunnel.c. Two tunnels collide iff these tuples match. + net/ipv4/ip_tunnel.c. Two tunnels of the same encapsulation collide if + these tuples match. An unconfigured endpoint is stored as the any address, so "0.0.0.0" and "::" compare equal to an endpoint which is not set at all. A zero GRE key @@ -211,11 +212,9 @@ def verify(tunnel): # Prevent the same key for 2 tunnels with same source-address/encap. T2920 ours = tunnel_identity(tunnel) for o_tunnel, o_tunnel_conf in tunnel['other_tunnels'].items(): - # no match on encapsulation - bail out - our_encapsulation = tunnel['encapsulation'] - their_encapsulation = o_tunnel_conf['encapsulation'] - if our_encapsulation in gre_encapsulations and their_encapsulation \ - not in gre_encapsulations: + # no match on encapsulation - bail out. The Kernel keeps gre and + # gretap tunnels in tables of their own, so they never collide + if o_tunnel_conf['encapsulation'] != tunnel['encapsulation']: continue try: -- cgit v1.2.3 From 4bdf9c3a6741f56a572a149dacc94204a513c6f2 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Fri, 6 Nov 2026 17:21:25 +0100 Subject: tunnel: T9193: keep accepting a lone zero-keyed GRE tunnel on an any source A GRE tunnel with source-address 0.0.0.0, no remote and "parameters ip key 0" used to commit, but was refused once a zero key stopped counting as a key for such a tunnel. That breaks existing configurations on upgrade. Accept it again whenever a key is configured at all. A zero key still cannot tell two such tunnels apart, and the collision check keeps refusing the second one, so only the single-tunnel case changes back. --- smoketest/scripts/cli/test_interfaces_tunnel.py | 24 +++++++++++++++++------- src/conf_mode/interfaces_tunnel.py | 22 +++++++++------------- 2 files changed, 26 insertions(+), 20 deletions(-) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py index ba30a0e73..70097786b 100755 --- a/smoketest/scripts/cli/test_interfaces_tunnel.py +++ b/smoketest/scripts/cli/test_interfaces_tunnel.py @@ -325,13 +325,19 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): with self.assertRaises(ConfigSessionError): self.cli_commit() - # A zero key is no key at all for such a tunnel - with an any - # source-address and no remote it catches every packet, exactly as a - # keyless tunnel would + # A zero key on a single tunnel stays accepted for backwards + # compatibility self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '0']) + self.cli_commit() + + # It does not tell a second such tunnel apart, though + self.cli_set(self._base_path + ['tun1281', 'encapsulation', encapsulation]) + self.cli_set(self._base_path + ['tun1281', 'source-address', src_addr]) + self.cli_set(self._base_path + ['tun1281', 'parameters', 'ip', 'key', '0']) with self.assertRaises(ConfigSessionError): self.cli_commit() + self.cli_delete(self._base_path + ['tun1281']) self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', key]) self.cli_commit() @@ -646,17 +652,21 @@ class TunnelInterfaceTest(BasicInterfaceTest.TestCase): def test_tunnel_gre_key_leading_zero(self): # iproute2 parses the key with strtoul(3) and base 0, so a leading zero - # makes it octal - "00" is the very same zero key as "0" and must be - # refused for a tunnel which carries no endpoint at all + # makes it octal - "00" is the very same zero key as "0" and must + # collide with it on a tunnel which carries no endpoint at all interface = 'tun1281' - self.cli_set(self._base_path + [interface, 'encapsulation', 'gre']) - self.cli_set(self._base_path + [interface, 'source-address', '0.0.0.0']) + for tunnel in ['tun1280', interface]: + self.cli_set(self._base_path + [tunnel, 'encapsulation', 'gre']) + self.cli_set(self._base_path + [tunnel, 'source-address', '0.0.0.0']) + self.cli_set(self._base_path + ['tun1280', 'parameters', 'ip', 'key', '0']) self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '00']) with self.assertRaises(ConfigSessionError): self.cli_commit() + self.cli_delete(self._base_path + ['tun1280']) + # "010" is octal 8 and does identify the tunnel self.cli_set(self._base_path + [interface, 'parameters', 'ip', 'key', '010']) diff --git a/src/conf_mode/interfaces_tunnel.py b/src/conf_mode/interfaces_tunnel.py index f525e9e27..9d4665a8b 100644 --- a/src/conf_mode/interfaces_tunnel.py +++ b/src/conf_mode/interfaces_tunnel.py @@ -187,24 +187,20 @@ def verify(tunnel): if 'direction' not in tunnel['parameters']['erspan']: raise ConfigError('ERSPAN version 2 requires direction to be set!') - # If tunnel source is any and the gre key does not identify the tunnel + # If tunnel source is any and gre key is not set. A zero key is accepted + # for backwards compatibility - it only fails to identify a tunnel which + # carries no remote either, and the collision check below refuses that + # as soon as a second such tunnel exists interface = tunnel['ifname'] if ( tunnel['encapsulation'] in ['gre'] and dict_search('source_address', tunnel) == '0.0.0.0' + and dict_search('parameters.ip.key', tunnel) == None ): - # The source-address being the any address, a tunnel without a remote - # carries no endpoint at all - a zero key does not tell such a tunnel - # apart from a keyless one either - identity = tunnel_identity(tunnel) - if identity.key is None: - # Only a tunnel which has no remote either is asked for a - # non-zero key, a zero one does identify the rest - tmp = 'set to a non-zero value' if identity.remote is None else 'set' - raise ConfigError( - f'"parameters ip key" must be {tmp} for {interface} when ' - 'encapsulation is GRE!' - ) + raise ConfigError( + f'"parameters ip key" must be set for {interface} when ' + 'encapsulation is GRE!' + ) gre_encapsulations = ['gre', 'gretap'] if tunnel['encapsulation'] in gre_encapsulations and 'other_tunnels' in tunnel: -- cgit v1.2.3