summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-31 13:04:59 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-31 13:04:59 +0100
commit4ebe0e002208b67dd4720a3fa8569557232df7e5 (patch)
treede56f2b01410f39948f1edccbab1cdfac51adcd7 /python/vyos/ifconfig.py
parentdb658825c7bb17e3221474e22b78306dc3edd2df (diff)
downloadvyos-1x-4ebe0e002208b67dd4720a3fa8569557232df7e5.tar.gz
vyos-1x-4ebe0e002208b67dd4720a3fa8569557232df7e5.zip
l2tpv3: T1923: support interface deletion
Diffstat (limited to 'python/vyos/ifconfig.py')
-rw-r--r--python/vyos/ifconfig.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 1c5a7cd14..36bd8c57c 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1714,8 +1714,10 @@ class L2TPv3If(Interface):
monitoring may be performed.
"""
def __init__(self, ifname, config=''):
+ self._config = {}
if config:
self._ifname = ifname
+ self._config = config
if not os.path.exists('/sys/class/net/{}'.format(self._ifname)):
# create tunnel interface
cmd = 'ip l2tp add tunnel tunnel_id {} '.format(config['tunnel_id'])
@@ -1729,7 +1731,7 @@ class L2TPv3If(Interface):
# setup session
cmd = 'ip l2tp add session name {} '.format(self._ifname)
- cmd += 'tunnel_id {} '.format(config['tunnel_id'])
+ cmd += 'tunnel_id {} '.format(config['tunnel_id'])
cmd += 'session_id {} '.format(config['session_id'])
cmd += 'peer_session_id {} '.format(config['peer_session_id'])
self._cmd(cmd)
@@ -1753,10 +1755,14 @@ class L2TPv3If(Interface):
# interface is always A/D down. It needs to be enabled explicitly
self.set_state('down')
- #cmd = 'ip l2tp add tunnel tunnel_id {} '.format(config['tunnel_id'])
+ if self._config['tunnel_id'] and self._config['session_id']:
+ cmd = 'ip l2tp del session tunnel_id {} '.format(self._config['tunnel_id'])
+ cmd += 'session_id {} '.format(self._config['session_id'])
+ self._cmd(cmd)
- # call remove of parent class
- super().remove()
+ if self._config['tunnel_id']:
+ cmd = 'ip l2tp del tunnel tunnel_id {} '.format(self._config['tunnel_id'])
+ self._cmd(cmd)
@staticmethod
def get_config():