summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-11-20 14:05:39 +0100
committerChristian Poessinger <christian@poessinger.com>2020-11-20 14:05:39 +0100
commitfe8d884b564e1758216b6a2db025bf1b22e56fa7 (patch)
treeeb95406b9edcd44cf4ff5ff6240bd75fd4bf49e0 /src
parent7ad026794beee0bc4310a96bac286823283b7fd8 (diff)
downloadvyos-1x-fe8d884b564e1758216b6a2db025bf1b22e56fa7.tar.gz
vyos-1x-fe8d884b564e1758216b6a2db025bf1b22e56fa7.zip
tunnel: T3072: support changing tunnel encapsulation on-the-fly
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-tunnel.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py
index 78fc9667c..bf643f3d1 100755
--- a/src/conf_mode/interfaces-tunnel.py
+++ b/src/conf_mode/interfaces-tunnel.py
@@ -17,7 +17,7 @@
import os
from sys import exit
-from copy import deepcopy
+from netifaces import interfaces
from vyos.config import Config
from vyos.configdict import dict_merge
@@ -46,8 +46,8 @@ 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
+ 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
@@ -62,6 +62,9 @@ def get_config(config=None):
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)
@@ -123,10 +126,12 @@ def generate(tunnel):
return None
def apply(tunnel):
- if 'deleted' in tunnel:
- tmp = Interface(tunnel['ifname'])
- tmp.remove()
- return None
+ 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,
@@ -173,10 +178,10 @@ def apply(tunnel):
if dict_search(our_key, tunnel) and their_key in conf:
conf[their_key] = dict_search(our_key, tunnel)
- # TODO: support encapsulation change per tunnel
-
tun = klass(tunnel['ifname'], **conf)
+ tun.change_options()
tun.update(tunnel)
+
return None
if __name__ == '__main__':