From 308998759f26032ed055cd8c2eabd5d3693bd594 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 9 Oct 2025 16:49:23 +0200 Subject: 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. --- python/vyos/ifconfig/interface.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'python') 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}' -- cgit v1.2.3