summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-10-09 16:49:23 +0200
committerChristian Breunig <christian@breunig.cc>2025-10-09 16:50:02 +0200
commit308998759f26032ed055cd8c2eabd5d3693bd594 (patch)
tree7a9bd9f6567e702cdf9963344f367de1b3d36b4a /python
parentfc178aaf00f7a9dc4589567ae3e17cb9718d9ad3 (diff)
downloadvyos-1x-308998759f26032ed055cd8c2eabd5d3693bd594.tar.gz
vyos-1x-308998759f26032ed055cd8c2eabd5d3693bd594.zip
vyos.ifconfig: T7919: call "ip addr flush" only if interface exists
Flushing all interface addresses on an interface that does not exists will throw a Python PermissionError. Add safe-guard to only flush interfaces still available.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/interface.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 8101fdcc3..761ba1799 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -1354,6 +1354,9 @@ class Interface(Control):
self.set_dhcp(False)
self.set_dhcpv6(False)
+ if not self.exists(self.ifname):
+ return
+
netns = get_interface_namespace(self.ifname)
netns_cmd = f'ip netns exec {netns}' if netns else ''
cmd = f'{netns_cmd} ip addr flush dev {self.ifname}'