summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-08-23 20:14:37 +0200
committerChristian Breunig <christian@breunig.cc>2023-09-01 08:29:12 +0200
commit396329cc9a2419c5be8ddd0bc8fbde67fdcb03fa (patch)
tree3104f70666b7ff8b731690b4ddf50cda4ef9caba /python/vyos
parent0ba723bcdbf608ba73bedbba74a8aa9be1d7df7b (diff)
downloadvyos-1x-396329cc9a2419c5be8ddd0bc8fbde67fdcb03fa.tar.gz
vyos-1x-396329cc9a2419c5be8ddd0bc8fbde67fdcb03fa.zip
vrf: T5428: stop DHCP processes on VRF removal
This is a workaround for the priority inversion from T5492 ("CLI node priority is not inversed on node deletion"). As this is a corner case bug that's only triggered if an interface is removed from a VRF and also the VRF is removed in one commit, priorities are not honored. Thus we implement this workaround which stop the DHCP(v6) client processes on the VRF associated interfaces to get out the DHCP RELEASE message before interfaces are shut down. (cherry picked from commit 005151f77be5cf999689cfd03620bbc39df59018)
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/util.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 03809fc83..ede22006c 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -912,3 +912,24 @@ def sysctl_write(name, value):
def is_ipv6_enabled() -> bool:
""" Check if IPv6 support on the system is enabled or not """
return (sysctl_read('net.ipv6.conf.all.disable_ipv6') == '0')
+
+def interface_exists(interface) -> bool:
+ import os
+ return os.path.exists(f'/sys/class/net/{interface}')
+
+def get_vrf_members(vrf: str) -> list:
+ """
+ Get list of interface VRF members
+ :param vrf: str
+ :return: list
+ """
+ import json
+ if not interface_exists(vrf):
+ raise ValueError(f'VRF "{vrf}" does not exist!')
+ output = cmd(f'ip --json --brief link show master {vrf}')
+ answer = json.loads(output)
+ interfaces = []
+ for data in answer:
+ if 'ifname' in data:
+ interfaces.append(data.get('ifname'))
+ return interfaces