summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-09-13 11:01:39 +0200
committerChristian Breunig <christian@breunig.cc>2025-09-13 11:01:39 +0200
commit5d94687c84d1fc655916bb8f9b924820479f30cb (patch)
treeff265933623a499cc159e2c87a2f9833176db6b4 /python
parent6a47b699577904eb3e5866c27ab2813058cc9ed9 (diff)
downloadvyos-1x-5d94687c84d1fc655916bb8f9b924820479f30cb.tar.gz
vyos-1x-5d94687c84d1fc655916bb8f9b924820479f30cb.zip
ethernet: T7813: remove VLAN interfaces first on deletion
When an Ethernet interface is deleted from the configuration, its associated VLAN subinterfaces must be removed first. This ordering allows VLAN interfaces to gracefully release any active DHCP or DHCPv6 leases before the parent interface disappears, ensuring proper cleanup and avoiding potential lease retention issues.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/ethernet.py14
-rw-r--r--python/vyos/ifconfig/section.py10
2 files changed, 15 insertions, 9 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 864a9d0bc..6c7b230ca 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -131,19 +131,17 @@ class EthernetIf(Interface):
>>> i.remove()
"""
+ # T7813: we do need to remove the VLAN subinterfaces first so we can
+ # properly stop the DHCP client and inform the DHCP server that we are
+ # returning the lease.
+ for vlan in Section.sub_interfaces(self.ifname):
+ Interface(vlan).remove()
+
if self.exists(self.ifname):
# interface is placed in A/D state when removed from config! It
# will remain visible for the operating system.
self.set_admin_state('down')
- # Remove all VLAN subinterfaces - filter with the VLAN dot
- for vlan in [
- x
- for x in Section.interfaces('ethernet')
- if x.startswith(f'{self.ifname}.')
- ]:
- Interface(vlan).remove()
-
super().remove()
def set_flow_control(self, enable):
diff --git a/python/vyos/ifconfig/section.py b/python/vyos/ifconfig/section.py
index 4ea606495..201494736 100644
--- a/python/vyos/ifconfig/section.py
+++ b/python/vyos/ifconfig/section.py
@@ -144,10 +144,18 @@ class Section:
if no section is provided, then it returns all configured interfaces.
If vlan is True, also Vlan subinterfaces will be returned
"""
-
return cls._sort_interfaces(cls._intf_under_section(section, vlan))
@classmethod
+ def sub_interfaces(cls, interface : str) -> list:
+ """
+ return a list of subinterfaces (e.g. VLAN) derived from a given interface
+ """
+ if_type = cls.section(interface)
+ res = [x for x in cls.interfaces(if_type) if x.startswith(f'{interface}.')]
+ return res
+
+ @classmethod
def _intf_with_feature(cls, feature=''):
"""
return a generator with the name of the configured interface which have