diff options
author | sever-sever <v.gletenko@vyos.io> | 2021-01-10 16:35:09 +0000 |
---|---|---|
committer | sever-sever <v.gletenko@vyos.io> | 2021-01-10 16:35:09 +0000 |
commit | 0a7fc50a5aa686552ceb787349f953ea1e0ebd1a (patch) | |
tree | 3ca74f8fc67a7ecd649b7c4bb5e95bbc3c1e6119 | |
parent | ef6d9333c9b985bef6ca662bcae56044cded76a1 (diff) | |
download | vyos-1x-0a7fc50a5aa686552ceb787349f953ea1e0ebd1a.tar.gz vyos-1x-0a7fc50a5aa686552ceb787349f953ea1e0ebd1a.zip |
tunnel: T3173: Add nopmtudisc parameter for tunnels conf-mode
-rw-r--r-- | interface-definitions/interfaces-tunnel.xml.in | 19 | ||||
-rw-r--r-- | python/vyos/ifconfig/tunnel.py | 14 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-tunnel.py | 6 |
3 files changed, 35 insertions, 4 deletions
diff --git a/interface-definitions/interfaces-tunnel.xml.in b/interface-definitions/interfaces-tunnel.xml.in index 3a4db6f09..273aa648e 100644 --- a/interface-definitions/interfaces-tunnel.xml.in +++ b/interface-definitions/interfaces-tunnel.xml.in @@ -177,6 +177,25 @@ <help>IPv4 specific tunnel parameters</help> </properties> <children> + <leafNode name="pmtu-discovery"> + <properties> + <help>Path MTU Discovery parameters</help> + <completionHelp> + <list>disable enable</list> + </completionHelp> + <valueHelp> + <format>disable</format> + <description>Disable Path MTU Discovery for tunnel</description> + </valueHelp> + <valueHelp> + <format>enable</format> + <description>Enable Path MTU Discovery for tunnel (by default)</description> + </valueHelp> + <constraint> + <regex>^(disable|enable)$</regex> + </constraint> + </properties> + </leafNode> <leafNode name="ttl"> <properties> <help>Time to live field</help> diff --git a/python/vyos/ifconfig/tunnel.py b/python/vyos/ifconfig/tunnel.py index 00dc36420..8ecb59755 100644 --- a/python/vyos/ifconfig/tunnel.py +++ b/python/vyos/ifconfig/tunnel.py @@ -72,16 +72,22 @@ class _Tunnel(Interface): # add " option-name option-name-value ..." for all options set options = " ".join(["{} {}".format(k, self.config[k]) - for k in self.options if k in self.config and self.config[k]]) + for k in self.options if k in self.config and self.config[k] and k is not 'pmtud']) self._cmd('{} {}'.format(create.format(**self.config), options)) self.set_admin_state('down') def change_options(self): - change = 'ip tunnel cha {ifname} mode {type}' + change = 'ip tunnel cha {ifname} mode {type} pmtudisc' # add " option-name option-name-value ..." for all options set + # option 'pmtud' doesn't has any value like 'ttl' or 'key' (ip tunnel cha tunX [no]pmtudisc) options = " ".join(["{} {}".format(k, self.config[k]) - for k in self.options if k in self.config and self.config[k]]) + for k in self.options if k in self.config and self.config[k] and k is not 'pmtud']) + + # set interfaces tunnel tunX parameters ip pmtu-discovery disable + if 'disable' in self.config['pmtud']: + change = 'ip tunnel cha {ifname} mode {type} nopmtudisc' + self._cmd('{} {}'.format(change.format(**self.config), options)) @classmethod @@ -142,7 +148,7 @@ class GREIf(_Tunnel): """ default = {'type': 'gre'} - options = ['local', 'remote', 'dev', 'ttl', 'tos', 'key'] + options = ['local', 'remote', 'dev', 'ttl', 'tos', 'key', 'pmtud'] # GreTap also called GRE Bridge class GRETapIf(_Tunnel): diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py index ffeb57784..f79405388 100755 --- a/src/conf_mode/interfaces-tunnel.py +++ b/src/conf_mode/interfaces-tunnel.py @@ -126,6 +126,11 @@ def verify(tunnel): if 'source_interface' in tunnel: verify_interface_exists(tunnel['source_interface']) + # ttl != 0 and nopmtudisc are incompatible + if 'pmtu_discovery' in tunnel['parameters']['ip']: + if 'disable' in tunnel['parameters']['ip']['pmtu_discovery'] and "0" not in tunnel['parameters']['ip']['ttl']: + raise ConfigError('ip ttl should be set to "0" with option "pmtu-discovery disable"') + def generate(tunnel): return None @@ -164,6 +169,7 @@ def apply(tunnel): 'local_ip' : 'local', 'remote_ip' : 'remote', 'source_interface' : 'dev', + 'parameters.ip.pmtu_discovery' : 'pmtud', 'parameters.ip.ttl' : 'ttl', 'parameters.ip.tos' : 'tos', 'parameters.ip.key' : 'key', |