Page MenuHomeVyOS Platform

No OneTemporary

Size
30 KB
Referenced Files
None
Subscribers
None
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
@@ -1,292 +1,311 @@
<?xml version="1.0"?>
<interfaceDefinition>
<node name="interfaces">
<children>
<tagNode name="tunnel" owner="${vyos_conf_scripts_dir}/interfaces-tunnel.py">
<properties>
<help>Tunnel interface</help>
<priority>380</priority>
<constraint>
<regex>^tun[0-9]+$</regex>
</constraint>
<constraintErrorMessage>tunnel interface must be named tunN</constraintErrorMessage>
<valueHelp>
<format>tunN</format>
<description>Tunnel interface name</description>
</valueHelp>
</properties>
<children>
#include <include/interface-description.xml.i>
#include <include/address-ipv4-ipv6.xml.i>
#include <include/interface-disable.xml.i>
#include <include/interface-disable-link-detect.xml.i>
#include <include/interface-vrf.xml.i>
#include <include/interface-mtu-64-8024.xml.i>
#include <include/interface-ipv4-options.xml.i>
#include <include/interface-ipv6-options.xml.i>
<leafNode name="local-ip">
<properties>
<help>Local IP address for this tunnel</help>
<valueHelp>
<format>ipv4</format>
<description>Local IPv4 address for this tunnel</description>
</valueHelp>
<valueHelp>
<format>ipv6</format>
<description>Local IPv6 address for this tunnel [NOTICE: unavailable for mGRE tunnels]</description>
</valueHelp>
<completionHelp>
<script>${vyos_completion_dir}/list_local_ips.sh --both</script>
</completionHelp>
<constraint>
<validator name="ip-address"/>
</constraint>
</properties>
</leafNode>
<leafNode name="remote-ip">
<properties>
<help>Remote IP address for this tunnel</help>
<valueHelp>
<format>ipv4</format>
<description>Remote IPv4 address for this tunnel</description>
</valueHelp>
<valueHelp>
<format>ipv6</format>
<description>Remote IPv6 address for this tunnel</description>
</valueHelp>
<constraint>
<!-- does it need fixing/changing to be more restrictive ? -->
<validator name="ip-address"/>
</constraint>
</properties>
</leafNode>
<leafNode name="source-interface">
<properties>
<help>Physical Interface used for underlaying traffic</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces.py</script>
</completionHelp>
</properties>
</leafNode>
<leafNode name="6rd-prefix">
<properties>
<help>6rd network prefix</help>
<valueHelp>
<format>ipv6</format>
<description>IPv6 address and prefix length</description>
</valueHelp>
<constraint>
<validator name="ipv6-prefix"/>
</constraint>
</properties>
</leafNode>
<leafNode name="6rd-relay-prefix">
<properties>
<help>6rd relay prefix</help>
<valueHelp>
<format>ipv4net</format>
<description>IPv4 prefix of interface for 6rd</description>
</valueHelp>
<constraint>
<validator name="ipv4-prefix"/>
</constraint>
</properties>
</leafNode>
<leafNode name="dhcp-interface">
<properties>
<help>dhcp interface</help>
<valueHelp>
<format>interface</format>
<description>DHCP interface that supplies the local IP address for this tunnel</description>
</valueHelp>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces.py</script>
</completionHelp>
<constraint>
<regex>^(en|eth|br|bond|gnv|vxlan|wg|tun)[0-9]+$</regex>
</constraint>
</properties>
</leafNode>
<leafNode name="encapsulation">
<properties>
<help>Encapsulation of this tunnel interface</help>
<completionHelp>
<list>gre gre-bridge ip6gre ip6ip6 ipip ipip6 sit</list>
</completionHelp>
<valueHelp>
<format>gre</format>
<description>Generic Routing Encapsulation</description>
</valueHelp>
<valueHelp>
<format>gre-bridge</format>
<description>Generic Routing Encapsulation bridge interface</description>
</valueHelp>
<valueHelp>
<format>ip6gre</format>
<description>GRE over IPv6 network</description>
</valueHelp>
<valueHelp>
<format>ip6ip6</format>
<description>IP6 in IP6 encapsulation</description>
</valueHelp>
<valueHelp>
<format>ipip</format>
<description>IP in IP encapsulation</description>
</valueHelp>
<valueHelp>
<format>ipip6</format>
<description>IP in IP6 encapsulation</description>
</valueHelp>
<valueHelp>
<format>sit</format>
<description>Simple Internet Transition encapsulation</description>
</valueHelp>
<constraint>
<regex>^(gre|gre-bridge|ip6gre|ip6ip6|ipip|ipip6|sit)$</regex>
</constraint>
<constraintErrorMessage>Invalid encapsulation, must be one of: gre, gre-bridge, ipip, sit, ipip6, ip6ip6, ip6gre</constraintErrorMessage>
</properties>
</leafNode>
<leafNode name="multicast">
<properties>
<help>Multicast operation over tunnel</help>
<completionHelp>
<list>enable disable</list>
</completionHelp>
<valueHelp>
<format>enable</format>
<description>Enable Multicast</description>
</valueHelp>
<valueHelp>
<format>disable</format>
<description>Disable Multicast (default)</description>
</valueHelp>
<constraint>
<regex>^(enable|disable)$</regex>
</constraint>
<constraintErrorMessage>Must be 'disable' or 'enable'</constraintErrorMessage>
</properties>
</leafNode>
<node name="parameters">
<properties>
<help>Tunnel parameters</help>
</properties>
<children>
<node name="ip">
<properties>
<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>
<valueHelp>
<format>0-255</format>
<description>Time to live (default 255)</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-255"/>
</constraint>
<constraintErrorMessage>TTL must be between 0 and 255</constraintErrorMessage>
</properties>
<defaultValue>255</defaultValue>
</leafNode>
<leafNode name="tos">
<properties>
<help>Type of Service (TOS)</help>
<valueHelp>
<format>0-99</format>
<description>Type of Service (TOS)</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-99"/>
</constraint>
<constraintErrorMessage>TOS must be between 0 and 99</constraintErrorMessage>
</properties>
<defaultValue>inherit</defaultValue>
</leafNode>
<leafNode name="key">
<properties>
<help>Tunnel key</help>
<valueHelp>
<format>u32</format>
<description>Tunnel key</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-4294967295"/>
</constraint>
<constraintErrorMessage>key must be between 0-4294967295</constraintErrorMessage>
</properties>
</leafNode>
</children>
</node>
<node name="ipv6">
<properties>
<help>IPv6 specific tunnel parameters</help>
</properties>
<children>
<leafNode name="encaplimit">
<properties>
<help>Encaplimit field</help>
<valueHelp>
<format>0-255</format>
<description>Encaplimit (default 4)</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-255"/>
</constraint>
<constraintErrorMessage>key must be between 0-255</constraintErrorMessage>
</properties>
<defaultValue>4</defaultValue>
</leafNode>
<leafNode name="flowlabel">
<properties>
<help>Flowlabel</help>
<valueHelp>
<format>0x0-0x0FFFFF</format>
<description>Tunnel key, 'inherit' or hex value</description>
</valueHelp>
<constraint>
<regex>(0x){0,1}(0?[0-9A-Fa-f]{1,5})</regex>
</constraint>
<constraintErrorMessage>Must be 'inherit' or a number</constraintErrorMessage>
</properties>
<defaultValue>inherit</defaultValue>
</leafNode>
<leafNode name="hoplimit">
<properties>
<help>Hoplimit</help>
<valueHelp>
<format>0-255</format>
<description>Hoplimit (default 64)</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-255"/>
</constraint>
<constraintErrorMessage>hoplimit must be between 0-255</constraintErrorMessage>
</properties>
<defaultValue>64</defaultValue>
</leafNode>
<leafNode name="tclass">
<properties>
<help>Traffic class (Tclass)</help>
<valueHelp>
<format>0x0-0x0FFFFF</format>
<description>Traffic class, 'inherit' or hex value</description>
</valueHelp>
<constraint>
<regex>(0x){0,1}(0?[0-9A-Fa-f]{1,2})</regex>
</constraint>
<constraintErrorMessage>Must be 'inherit' or a number</constraintErrorMessage>
</properties>
<defaultValue>inherit</defaultValue>
</leafNode>
</children>
</node>
</children>
</node>
</children>
</tagNode>
</children>
</node>
</interfaceDefinition>
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
@@ -1,246 +1,252 @@
# Copyright 2019-2020 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
# https://developers.redhat.com/blog/2019/05/17/an-introduction-to-linux-virtual-interfaces-tunnels/
# https://community.hetzner.com/tutorials/linux-setup-gre-tunnel
from copy import deepcopy
from netaddr import EUI
from netaddr import mac_unix_expanded
from random import getrandbits
from vyos.ifconfig.interface import Interface
from vyos.validate import assert_list
def enable_to_on(value):
if value == 'enable':
return 'on'
if value == 'disable':
return 'off'
raise ValueError(f'expect enable or disable but got "{value}"')
@Interface.register
class _Tunnel(Interface):
"""
_Tunnel: private base class for tunnels
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/tunnel.c
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/ip6tunnel.c
"""
definition = {
**Interface.definition,
**{
'section': 'tunnel',
'prefixes': ['tun',],
},
}
# TODO: This is surely used for more than tunnels
# TODO: could be refactored elsewhere
_command_set = {**Interface._command_set, **{
'multicast': {
'validate': lambda v: assert_list(v, ['enable', 'disable']),
'convert': enable_to_on,
'shellcmd': 'ip link set dev {ifname} multicast {value}',
},
'allmulticast': {
'validate': lambda v: assert_list(v, ['enable', 'disable']),
'convert': enable_to_on,
'shellcmd': 'ip link set dev {ifname} allmulticast {value}',
},
}}
def __init__(self, ifname, **config):
self.config = deepcopy(config) if config else {}
super().__init__(ifname, **config)
def _create(self):
create = 'ip tunnel add {ifname} mode {type}'
# 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
def get_config(cls):
return dict(zip(cls.options, ['']*len(cls.options)))
def get_mac(self):
"""
Get current interface MAC (Media Access Contrl) address used.
NOTE: Tunnel interfaces have no "MAC" address by default. The content
of the 'address' file in /sys/class/net/device contains the
local-ip thus we generate a random MAC address instead
Example:
>>> from vyos.ifconfig import Interface
>>> Interface('eth0').get_mac()
'00:50:ab:cd:ef:00'
"""
# we choose 40 random bytes for the MAC address, this gives
# us e.g. EUI('00-EA-EE-D6-A3-C8') or EUI('00-41-B9-0D-F2-2A')
tmp = EUI(getrandbits(48)).value
# set locally administered bit in MAC address
tmp |= 0xf20000000000
# convert integer to "real" MAC address representation
mac = EUI(hex(tmp).split('x')[-1])
# change dialect to use : as delimiter instead of -
mac.dialect = mac_unix_expanded
return str(mac)
def update(self, config):
""" General helper function which works on a dictionary retrived by
get_config_dict(). It's main intention is to consolidate the scattered
interface setup code and provide a single point of entry when workin
on any interface. """
# call base class first
super().update(config)
# Enable/Disable of an interface must always be done at the end of the
# derived class to make use of the ref-counting set_admin_state()
# function. We will only enable the interface if 'up' was called as
# often as 'down'. This is required by some interface implementations
# as certain parameters can only be changed when the interface is
# in admin-down state. This ensures the link does not flap during
# reconfiguration.
state = 'down' if 'disable' in config else 'up'
self.set_admin_state(state)
class GREIf(_Tunnel):
"""
GRE: Generic Routing Encapsulation
For more information please refer to:
RFC1701, RFC1702, RFC2784
https://tools.ietf.org/html/rfc2784
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/link_gre.c
"""
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):
"""
GRETapIF: GreIF using TAP instead of TUN
https://en.wikipedia.org/wiki/TUN/TAP
"""
# no multicast, ttl or tos for gretap
definition = {
**_Tunnel.definition,
**{
'bridgeable': True,
},
}
default = {'type': 'gretap'}
options = ['local', 'remote', 'ttl',]
class IP6GREIf(_Tunnel):
"""
IP6Gre: IPv6 Support for Generic Routing Encapsulation (GRE)
For more information please refer to:
https://tools.ietf.org/html/rfc7676
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/link_gre6.c
"""
default = {'type': 'ip6gre'}
options = ['local', 'remote', 'dev', 'encaplimit',
'hoplimit', 'tclass', 'flowlabel']
class IPIPIf(_Tunnel):
"""
IPIP: IP Encapsulation within IP
For more information please refer to:
https://tools.ietf.org/html/rfc2003
"""
# IPIP does not allow to pass multicast, unlike GRE
# but the interface itself can be set with multicast
default = {'type': 'ipip'}
options = ['local', 'remote', 'dev', 'ttl', 'tos', 'key']
class IPIP6If(_Tunnel):
"""
IPIP6: IPv4 over IPv6 tunnel
For more information please refer to:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/link_ip6tnl.c
"""
default = {'type': 'ipip6'}
options = ['local', 'remote', 'dev', 'encaplimit',
'hoplimit', 'tclass', 'flowlabel']
class IP6IP6If(IPIP6If):
"""
IP6IP6: IPv6 over IPv6 tunnel
For more information please refer to:
https://tools.ietf.org/html/rfc2473
"""
default = {'type': 'ip6ip6'}
class SitIf(_Tunnel):
"""
Sit: Simple Internet Transition
For more information please refer to:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/link_iptnl.c
"""
default = {'type': 'sit'}
options = ['local', 'remote', 'dev', 'ttl', 'tos', 'key']
class Sit6RDIf(SitIf):
"""
Sit6RDIf: Simple Internet Transition with 6RD
https://en.wikipedia.org/wiki/IPv6_rapid_deployment
"""
# TODO: check if key can really be used with 6RD
options = ['remote', 'ttl', 'tos', 'key', '6rd-prefix', '6rd-relay-prefix']
def _create(self):
# do not call _Tunnel.create, building fully here
create = 'ip tunnel add {ifname} mode {type} remote {remote}'
self._cmd(create.format(**self.config))
self.set_interface('state','down')
set6rd = 'ip tunnel 6rd dev {ifname} 6rd-prefix {6rd-prefix}'
if '6rd-relay-prefix' in self.config:
set6rd += ' 6rd-relay-prefix {6rd-relay-prefix}'
self._cmd(set6rd.format(**self.config))
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
@@ -1,199 +1,205 @@
#!/usr/bin/env python3
#
# Copyright (C) 2018-2021 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from sys import exit
from netifaces import interfaces
from vyos.config import Config
from vyos.configdict import dict_merge
from vyos.configdict import get_interface_dict
from vyos.configdict import node_changed
from vyos.configdict import leaf_node_changed
from vyos.configverify import verify_address
from vyos.configverify import verify_bridge_delete
from vyos.configverify import verify_interface_exists
from vyos.configverify import verify_mtu_ipv6
from vyos.configverify import verify_vrf
from vyos.ifconfig import Interface
from vyos.ifconfig import GREIf
from vyos.ifconfig import GRETapIf
from vyos.ifconfig import IPIPIf
from vyos.ifconfig import IP6GREIf
from vyos.ifconfig import IPIP6If
from vyos.ifconfig import IP6IP6If
from vyos.ifconfig import SitIf
from vyos.ifconfig import Sit6RDIf
from vyos.template import is_ipv4
from vyos.template import is_ipv6
from vyos.util import dict_search
from vyos import ConfigError
from vyos import airbag
airbag.enable()
def get_config(config=None):
"""
Retrive CLI config as dictionary. Dictionary can never be empty, as at least
the interface name will be added or a deleted flag
"""
if config:
conf = config
else:
conf = Config()
base = ['interfaces', 'tunnel']
tunnel = get_interface_dict(conf, base)
# Wireguard is "special" the default MTU is 1420 - update accordingly
# as the config_level is already st in get_interface_dict() - we can use []
tmp = conf.get_config_dict([], key_mangling=('-', '_'), get_first_key=True)
if 'mtu' not in tmp:
tunnel['mtu'] = '1476'
tmp = leaf_node_changed(conf, ['encapsulation'])
if tmp: tunnel.update({'encapsulation_changed': {}})
# We must check if our interface is configured to be a DMVPN member
nhrp_base = ['protocols', 'nhrp', 'tunnel']
conf.set_level(nhrp_base)
nhrp = conf.get_config_dict([], key_mangling=('-', '_'), get_first_key=True)
if nhrp: tunnel.update({'nhrp' : list(nhrp.keys())})
return tunnel
def verify(tunnel):
if 'deleted' in tunnel:
verify_bridge_delete(tunnel)
if 'nhrp' in tunnel and tunnel['ifname'] in tunnel['nhrp']:
raise ConfigError('Tunnel used for NHRP, it can not be deleted!')
return None
if 'encapsulation' not in tunnel:
raise ConfigError('Must configure the tunnel encapsulation for '\
'{ifname}!'.format(**tunnel))
verify_mtu_ipv6(tunnel)
verify_address(tunnel)
verify_vrf(tunnel)
if 'local_ip' not in tunnel and 'dhcp_interface' not in tunnel:
raise ConfigError('local-ip is mandatory for tunnel')
if 'remote_ip' not in tunnel and tunnel['encapsulation'] != 'gre':
raise ConfigError('remote-ip is mandatory for tunnel')
if {'local_ip', 'dhcp_interface'} <= set(tunnel):
raise ConfigError('Can not use both local-ip and dhcp-interface')
if tunnel['encapsulation'] in ['ipip6', 'ip6ip6', 'ip6gre']:
error_ipv6 = 'Encapsulation mode requires IPv6'
if 'local_ip' in tunnel and not is_ipv6(tunnel['local_ip']):
raise ConfigError(f'{error_ipv6} local-ip')
if 'remote_ip' in tunnel and not is_ipv6(tunnel['remote_ip']):
raise ConfigError(f'{error_ipv6} remote-ip')
else:
error_ipv4 = 'Encapsulation mode requires IPv4'
if 'local_ip' in tunnel and not is_ipv4(tunnel['local_ip']):
raise ConfigError(f'{error_ipv4} local-ip')
if 'remote_ip' in tunnel and not is_ipv4(tunnel['remote_ip']):
raise ConfigError(f'{error_ipv4} remote-ip')
if tunnel['encapsulation'] in ['sit', 'gre-bridge']:
if 'source_interface' in tunnel:
raise ConfigError('Option source-interface can not be used with ' \
'encapsulation "sit" or "gre-bridge"')
elif tunnel['encapsulation'] == 'gre':
if 'local_ip' in tunnel and is_ipv6(tunnel['local_ip']):
raise ConfigError('Can not use local IPv6 address is for mGRE tunnels')
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
def apply(tunnel):
if 'deleted' in tunnel or 'encapsulation_changed' in tunnel:
if tunnel['ifname'] in interfaces():
tmp = Interface(tunnel['ifname'])
tmp.remove()
if 'deleted' in tunnel:
return None
dispatch = {
'gre': GREIf,
'gre-bridge': GRETapIf,
'ipip': IPIPIf,
'ipip6': IPIP6If,
'ip6ip6': IP6IP6If,
'ip6gre': IP6GREIf,
'sit': SitIf,
}
# We need to re-map the tunnel encapsulation proto to a valid interface class
encap = tunnel['encapsulation']
klass = dispatch[encap]
# This is a special type of interface which needs additional parameters
# when created using iproute2. Instead of passing a ton of arguments,
# use a dictionary provided by the interface class which holds all the
# options necessary.
conf = klass.get_config()
# Copy/re-assign our dictionary values to values understood by the
# derived _Tunnel classes
mapping = {
# this : get_config()
'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',
'parameters.ipv6.encaplimit' : 'encaplimit'
}
# Add additional IPv6 options if tunnel is IPv6 aware
if tunnel['encapsulation'] in ['ipip6', 'ip6ip6', 'ip6gre']:
mappingv6 = {
# this : get_config()
'parameters.ipv6.encaplimit' : 'encaplimit'
}
mapping.update(mappingv6)
for our_key, their_key in mapping.items():
if dict_search(our_key, tunnel) and their_key in conf:
conf[their_key] = dict_search(our_key, tunnel)
tun = klass(tunnel['ifname'], **conf)
tun.change_options()
tun.update(tunnel)
return None
if __name__ == '__main__':
try:
c = get_config()
generate(c)
verify(c)
apply(c)
except ConfigError as e:
print(e)
exit(1)

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 6, 7:41 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4642086
Default Alt Text
(30 KB)

Event Timeline