summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-02-28 10:14:20 +0100
committerChristian Poessinger <christian@poessinger.com>2021-02-28 18:10:08 +0100
commit5574bd672825a87b1983cc135ae2e0bdabbe751b (patch)
tree51172c12b38525028db29a4321b759cb9c6c8773
parentf585fd497ad0daa4cbecd777bb5e8fa6d18f879f (diff)
downloadvyos-1x-5574bd672825a87b1983cc135ae2e0bdabbe751b.tar.gz
vyos-1x-5574bd672825a87b1983cc135ae2e0bdabbe751b.zip
l2tpv3: T3366: migrate local-ip and remote-ip CLI options
Rename CLI options local-ip to source-address and remote-ip to remote to get a consistent CLI experience for the user.
-rw-r--r--interface-definitions/interfaces-l2tpv3.xml.in35
-rw-r--r--python/vyos/ifconfig/l2tpv3.py4
-rw-r--r--smoketest/configs/tunnel-broker39
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_l2tpv3.py6
-rwxr-xr-xsrc/conf_mode/interfaces-l2tpv3.py11
-rwxr-xr-xsrc/migration-scripts/interfaces/19-to-2048
6 files changed, 76 insertions, 67 deletions
diff --git a/interface-definitions/interfaces-l2tpv3.xml.in b/interface-definitions/interfaces-l2tpv3.xml.in
index 3853cd339..68ac15861 100644
--- a/interface-definitions/interfaces-l2tpv3.xml.in
+++ b/interface-definitions/interfaces-l2tpv3.xml.in
@@ -55,22 +55,7 @@
</leafNode>
#include <include/interface-ipv4-options.xml.i>
#include <include/interface-ipv6-options.xml.i>
- <leafNode name="local-ip">
- <properties>
- <help>Local IP address for L2TPv3 tunnel</help>
- <valueHelp>
- <format>ipv4</format>
- <description>Local IPv4 address of tunnel</description>
- </valueHelp>
- <valueHelp>
- <format>ipv6</format>
- <description>Local IPv6 address of tunnel</description>
- </valueHelp>
- <constraint>
- <validator name="ip-address"/>
- </constraint>
- </properties>
- </leafNode>
+ #include <include/source-address-ipv4-ipv6.xml.i>
#include <include/interface-mtu-68-16000.xml.i>
<leafNode name="mtu">
<defaultValue>1488</defaultValue>
@@ -99,22 +84,8 @@
</constraint>
</properties>
</leafNode>
- <leafNode name="remote-ip">
- <properties>
- <help>Remote IP address for L2TPv3 tunnel</help>
- <valueHelp>
- <format>ipv4</format>
- <description>Remote IPv4 address of tunnel</description>
- </valueHelp>
- <valueHelp>
- <format>ipv6</format>
- <description>Remote IPv6 address of tunnel</description>
- </valueHelp>
- <constraint>
- <validator name="ip-address"/>
- </constraint>
- </properties>
- </leafNode>
+ #include <include/interface-mtu-68-16000.xml.i>
+ #include <include/tunnel-remote.xml.i>
<leafNode name="session-id">
<properties>
<help>Session identifier</help>
diff --git a/python/vyos/ifconfig/l2tpv3.py b/python/vyos/ifconfig/l2tpv3.py
index 34f8cd4d3..b717394a6 100644
--- a/python/vyos/ifconfig/l2tpv3.py
+++ b/python/vyos/ifconfig/l2tpv3.py
@@ -41,8 +41,8 @@ class L2TPv3If(Interface):
cmd += ' udp_sport {source_port}'
cmd += ' udp_dport {destination_port}'
cmd += ' encap {encapsulation}'
- cmd += ' local {local_ip}'
- cmd += ' remote {remote_ip}'
+ cmd += ' local {source_address}'
+ cmd += ' remote {remote}'
self._cmd(cmd.format(**self.config))
# setup session
diff --git a/smoketest/configs/tunnel-broker b/smoketest/configs/tunnel-broker
index 54e63abda..b52ba2541 100644
--- a/smoketest/configs/tunnel-broker
+++ b/smoketest/configs/tunnel-broker
@@ -20,6 +20,45 @@ interfaces {
speed auto
address 172.18.202.10/24
}
+ l2tpv3 l2tpeth10 {
+ description "L2 VPN Tunnel"
+ destination-port 5010
+ encapsulation ip
+ local-ip 172.18.202.10
+ mtu 1500
+ peer-session-id 110
+ peer-tunnel-id 10
+ remote-ip 172.18.254.201
+ session-id 110
+ source-port 5010
+ tunnel-id 10
+ }
+ l2tpv3 l2tpeth20 {
+ description "L2 VPN Tunnel"
+ destination-port 5020
+ encapsulation ip
+ local-ip 172.18.202.10
+ mtu 1500
+ peer-session-id 120
+ peer-tunnel-id 20
+ remote-ip 172.18.254.202
+ session-id 120
+ source-port 5020
+ tunnel-id 20
+ }
+ l2tpv3 l2tpeth30 {
+ description "L2 VPN Tunnel"
+ destination-port 5030
+ encapsulation ip
+ local-ip 172.18.202.10
+ mtu 1500
+ peer-session-id 130
+ peer-tunnel-id 30
+ remote-ip 172.18.254.203
+ session-id 130
+ source-port 5030
+ tunnel-id 30
+ }
tunnel tun100 {
address 172.16.0.1/30
encapsulation gre-bridge
diff --git a/smoketest/scripts/cli/test_interfaces_l2tpv3.py b/smoketest/scripts/cli/test_interfaces_l2tpv3.py
index a89895b92..74fd4f6c6 100755
--- a/smoketest/scripts/cli/test_interfaces_l2tpv3.py
+++ b/smoketest/scripts/cli/test_interfaces_l2tpv3.py
@@ -27,12 +27,12 @@ class GeneveInterfaceTest(BasicInterfaceTest.BaseTest):
cls._test_ipv6 = True
cls._base_path = ['interfaces', 'l2tpv3']
cls._options = {
- 'l2tpeth10': ['local-ip 127.0.0.1', 'remote-ip 127.10.10.10',
+ 'l2tpeth10': ['source-address 127.0.0.1', 'remote 127.10.10.10',
'tunnel-id 100', 'peer-tunnel-id 10',
'session-id 100', 'peer-session-id 10',
'source-port 1010', 'destination-port 10101'],
- 'l2tpeth20': ['local-ip 127.0.0.1', 'peer-session-id 20',
- 'peer-tunnel-id 200', 'remote-ip 127.20.20.20',
+ 'l2tpeth20': ['source-address 127.0.0.1', 'peer-session-id 20',
+ 'peer-tunnel-id 200', 'remote 127.20.20.20',
'session-id 20', 'tunnel-id 200',
'source-port 2020', 'destination-port 20202'],
}
diff --git a/src/conf_mode/interfaces-l2tpv3.py b/src/conf_mode/interfaces-l2tpv3.py
index 5bae66074..9b6ddd5aa 100755
--- a/src/conf_mode/interfaces-l2tpv3.py
+++ b/src/conf_mode/interfaces-l2tpv3.py
@@ -34,7 +34,6 @@ airbag.enable()
k_mod = ['l2tp_eth', 'l2tp_netlink', 'l2tp_ip', 'l2tp_ip6']
-
def get_config(config=None):
"""
Retrive CLI config as dictionary. Dictionary can never be empty, as at least the
@@ -65,15 +64,15 @@ def verify(l2tpv3):
interface = l2tpv3['ifname']
- for key in ['local_ip', 'remote_ip', 'tunnel_id', 'peer_tunnel_id',
+ for key in ['source_address', 'remote', 'tunnel_id', 'peer_tunnel_id',
'session_id', 'peer_session_id']:
if key not in l2tpv3:
tmp = key.replace('_', '-')
- raise ConfigError(f'L2TPv3 {tmp} must be configured!')
+ raise ConfigError(f'Missing mandatory L2TPv3 option: "{tmp}"!')
- if not is_addr_assigned(l2tpv3['local_ip']):
- raise ConfigError('L2TPv3 local-ip address '
- '"{local_ip}" is not configured!'.format(**l2tpv3))
+ if not is_addr_assigned(l2tpv3['source_address']):
+ raise ConfigError('L2TPv3 source-address address "{source_address}" '
+ 'not configured on any interface!'.format(**l2tpv3))
verify_mtu_ipv6(l2tpv3)
verify_address(l2tpv3)
diff --git a/src/migration-scripts/interfaces/19-to-20 b/src/migration-scripts/interfaces/19-to-20
index ed2780b92..e96663e54 100755
--- a/src/migration-scripts/interfaces/19-to-20
+++ b/src/migration-scripts/interfaces/19-to-20
@@ -28,30 +28,30 @@ if __name__ == '__main__':
config_file = f.read()
config = ConfigTree(config_file)
- base = ['interfaces', 'tunnel']
-
- if not config.exists(base):
- # Nothing to do
- exit(0)
-
- #
- # Migrate "interface tunnel <tunX> encapsulation gre-bridge" to gretap
- # Migrate "interface tunnel <tunX> local-ip" to source-address
- # Migrate "interface tunnel <tunX> remote-ip" to remote
- for interface in config.list_nodes(base):
- encap_path = base + [interface, 'encapsulation']
- if config.exists(encap_path):
- tmp = config.return_value(encap_path)
- if tmp == 'gre-bridge':
- config.set(encap_path, value='gretap')
-
- local_ip_path = base + [interface, 'local-ip']
- if config.exists(local_ip_path):
- config.rename(local_ip_path, 'source-address')
-
- remote_ip_path = base + [interface, 'remote-ip']
- if config.exists(remote_ip_path):
- config.rename(remote_ip_path, 'remote')
+
+ for type in ['tunnel', 'l2tpv3']:
+ base = ['interfaces', type]
+ if not config.exists(base):
+ # Nothing to do
+ continue
+
+ for interface in config.list_nodes(base):
+ # Migrate "interface tunnel <tunX> encapsulation gre-bridge" to gretap
+ encap_path = base + [interface, 'encapsulation']
+ if type == 'tunnel' and config.exists(encap_path):
+ tmp = config.return_value(encap_path)
+ if tmp == 'gre-bridge':
+ config.set(encap_path, value='gretap')
+
+ # Migrate "interface tunnel|l2tpv3 <interface> local-ip" to source-address
+ # Migrate "interface tunnel|l2tpv3 <interface> remote-ip" to remote
+ local_ip_path = base + [interface, 'local-ip']
+ if config.exists(local_ip_path):
+ config.rename(local_ip_path, 'source-address')
+
+ remote_ip_path = base + [interface, 'remote-ip']
+ if config.exists(remote_ip_path):
+ config.rename(remote_ip_path, 'remote')
try:
with open(file_name, 'w') as f: