summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-03 00:11:28 +0100
committerChristian Poessinger <christian@poessinger.com>2021-03-03 00:16:49 +0100
commitaf609001364404e0b53ac3ee31ac75de54325ecb (patch)
treeb326f3d72f2b1eabfa4b5fec6b15089fde52d9a2 /python/vyos
parent93ce06e24a5d527bcae5315aefbc25533d2a7f07 (diff)
downloadvyos-1x-af609001364404e0b53ac3ee31ac75de54325ecb.tar.gz
vyos-1x-af609001364404e0b53ac3ee31ac75de54325ecb.zip
geneve: T1799: add additional per tunnel options
Support setting additional options to the GENEVE tunnel like: - ttl - tos - do not fragment bit - ipv6 flowlabel
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/geneve.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/python/vyos/ifconfig/geneve.py b/python/vyos/ifconfig/geneve.py
index 6747d2bd6..7cb3968df 100644
--- a/python/vyos/ifconfig/geneve.py
+++ b/python/vyos/ifconfig/geneve.py
@@ -13,7 +13,8 @@
# 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/>.
-from vyos.ifconfig.interface import Interface
+from vyos.ifconfig import Interface
+from vyos.util import dict_search
@Interface.register
class GeneveIf(Interface):
@@ -37,8 +38,27 @@ class GeneveIf(Interface):
}
def _create(self):
- cmd = 'ip link add name {ifname} type geneve id {vni} remote {remote}'.format(**self.config)
- self._cmd(cmd)
+ # This table represents a mapping from VyOS internal config dict to
+ # arguments used by iproute2. For more information please refer to:
+ # - https://man7.org/linux/man-pages/man8/ip-link.8.html
+ mapping = {
+ 'parameters.ip.dont_fragment': 'df set',
+ 'parameters.ip.tos' : 'tos',
+ 'parameters.ip.ttl' : 'ttl',
+ 'parameters.ipv6.flowlabel' : 'flowlabel',
+ }
+
+ cmd = 'ip link add name {ifname} type {type} id {vni} remote {remote}'
+ for vyos_key, iproute2_key in mapping.items():
+ # dict_search will return an empty dict "{}" for valueless nodes like
+ # "parameters.nolearning" - thus we need to test the nodes existence
+ # by using isinstance()
+ tmp = dict_search(vyos_key, self.config)
+ if isinstance(tmp, dict):
+ cmd += f' {iproute2_key}'
+ elif tmp != None:
+ cmd += f' {iproute2_key} {tmp}'
+ self._cmd(cmd.format(**self.config))
# interface is always A/D down. It needs to be enabled explicitly
self.set_admin_state('down')