diff options
author | Christian Breunig <christian@breunig.cc> | 2024-08-01 13:08:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 13:08:36 +0200 |
commit | 962ead698e191ff413aaa1585270dfed48100547 (patch) | |
tree | d0aefbaeaf2b5d1716dd578060a93eb07618972a /python/vyos/ifconfig | |
parent | b12cd41000bf64950582dc62538be609741aac54 (diff) | |
parent | 50cf1746d3ab5e3666a3e502c67d7d853ae7f932 (diff) | |
download | vyos-1x-962ead698e191ff413aaa1585270dfed48100547.tar.gz vyos-1x-962ead698e191ff413aaa1585270dfed48100547.zip |
Merge pull request #3221 from lucasec/t5873
T5873: ipsec remote access VPN: support VTI interfaces.
Diffstat (limited to 'python/vyos/ifconfig')
-rw-r--r-- | python/vyos/ifconfig/vti.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/vti.py b/python/vyos/ifconfig/vti.py index 9511386f4..251cbeb36 100644 --- a/python/vyos/ifconfig/vti.py +++ b/python/vyos/ifconfig/vti.py @@ -15,6 +15,7 @@ from vyos.ifconfig.interface import Interface from vyos.utils.dict import dict_search +from vyos.utils.vti_updown_db import vti_updown_db_exists, open_vti_updown_db_readonly @Interface.register class VTIIf(Interface): @@ -27,6 +28,10 @@ class VTIIf(Interface): }, } + def __init__(self, ifname, **kwargs): + self.bypass_vti_updown_db = kwargs.pop("bypass_vti_updown_db", False) + super().__init__(ifname, **kwargs) + def _create(self): # This table represents a mapping from VyOS internal config dict to # arguments used by iproute2. For more information please refer to: @@ -57,8 +62,18 @@ class VTIIf(Interface): self.set_interface('admin_state', 'down') def set_admin_state(self, state): - """ Handled outside by /etc/ipsec.d/vti-up-down """ - pass + """ + Set interface administrative state to be 'up' or 'down'. + + The interface will only be brought 'up' if ith is attached to an + active ipsec site-to-site connection or remote access connection. + """ + if state == 'down' or self.bypass_vti_updown_db: + super().set_admin_state(state) + elif vti_updown_db_exists(): + with open_vti_updown_db_readonly() as db: + if db.wantsInterfaceUp(self.ifname): + super().set_admin_state(state) def get_mac(self): """ Get a synthetic MAC address. """ |