summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-09-14 22:28:20 +0200
committerGitHub <noreply@github.com>2026-09-14 22:28:20 +0200
commit4e1793c69cb077dbfde2fe2c012b664b4bf1cba2 (patch)
treebd8bf1f296a1ab868e7fb36ba83a843b50ae06b5
parentd185906f383eac7aad51840cd9150842c4709c83 (diff)
parent41fac0cfbf1a1558c7c6b9cbde9f7a9786e80162 (diff)
downloadvyos-1x-4e1793c69cb077dbfde2fe2c012b664b4bf1cba2.tar.gz
vyos-1x-4e1793c69cb077dbfde2fe2c012b664b4bf1cba2.zip
Merge pull request #5469 from c-po/q-in-q-removal
ifconfig: T9313: fix removal of QinQ sub-interfaces
-rw-r--r--python/vyos/ifconfig/ethernet.py13
-rw-r--r--python/vyos/ifconfig/interface.py14
2 files changed, 19 insertions, 8 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 1b10d075e..ab5c8a0b8 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -19,7 +19,6 @@ from glob import glob
from vyos.base import Warning
from vyos.ethtool import Ethtool
-from vyos.ifconfig import Section
from vyos.ifconfig.interface import Interface
from vyos.utils.dict import dict_search
from vyos.utils.file import read_file
@@ -136,19 +135,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()
+ # T7813: the base class removes all VLAN sub-interfaces and flushes the
+ # addresses of this interface - both require a link which is still up so
+ # a DHCP client can return its lease. A physical interface is "eternal"
+ # and thus survives this call.
+ super().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')
- super().remove()
-
def set_flow_control(self, enable, warn=True):
"""
Changes the pause parameters of the specified Ethernet device.
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 3a5efec8c..73f7544dd 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -393,6 +393,20 @@ class Interface(Control):
>>> i = Interface('eth0')
>>> i.remove()
"""
+ # T7813: VLAN sub-interfaces must be de-configured before this interface
+ # is torn down, otherwise a running DHCP client can neither talk to the
+ # server nor return its lease. Deleting an interface implicitly deletes
+ # all its VLAN children in the Kernel, thus start with the deepest
+ # interface (vif-c) and work the way up to the vif interfaces.
+ for vlan in sorted(
+ Section.sub_interfaces(self.ifname), key=lambda x: x.count('.'), reverse=True
+ ):
+ # A previous iteration may have already removed this interface as a
+ # side effect - do not re-create it when instantiating Interface()
+ if not Interface.exists(vlan):
+ continue
+ Interface(vlan).remove()
+
# Stop WPA supplicant if EAPoL was in use
netns = self.config['netns'] if 'netns' in self.config else None
stop_systemd_unit(f'wpa_supplicant-wired@{self.ifname}', netns=netns)