diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2025-09-15 15:51:53 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-15 15:51:53 +0300 |
| commit | d72d15c28f2e890ded3e5d24fceac00dac1238ed (patch) | |
| tree | ff36c472df3c58c1ca0fb4001890c89dbe788daf /python | |
| parent | 98dfa08687bc7db3bc27df11910cea778f991fa2 (diff) | |
| parent | 5d94687c84d1fc655916bb8f9b924820479f30cb (diff) | |
| download | vyos-1x-d72d15c28f2e890ded3e5d24fceac00dac1238ed.tar.gz vyos-1x-d72d15c28f2e890ded3e5d24fceac00dac1238ed.zip | |
Merge pull request #4715 from c-po/ethernet-if-removal
ethernet: T7813: remove VLAN interfaces first on deletion
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/ifconfig/ethernet.py | 14 | ||||
| -rw-r--r-- | python/vyos/ifconfig/section.py | 10 |
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 |
