summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/ethernet.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-01-07 13:17:13 +0100
committerGitHub <noreply@github.com>2025-01-07 14:17:13 +0200
commit08c00548ec11329774d315f745dbbd007c986bfe (patch)
tree0f64fd098603f90a5b2a9071eaaa3574da3a4d0c /python/vyos/ifconfig/ethernet.py
parentfb651c09f07b8aba45f2d31cfb3851e9e9c82ef0 (diff)
downloadveeos-1x-08c00548ec11329774d315f745dbbd007c986bfe.tar.gz
veeos-1x-08c00548ec11329774d315f745dbbd007c986bfe.zip
vyos.ifconfig: T7018: drop 'iftype' class attribute (#4280)
Under very rare cases we can run into a race condition where interfaces are still in creation phase but are already referenced.. This can trigger: File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 270, in <module> apply(c) File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 249, in apply call_dependents() File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 147, in call_dependents f() File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 118, in func_impl run_config_mode_script(script, config) File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 106, in run_config_mode_script mod.verify(c) File "/usr/libexec/vyos//conf_mode/service_conntrack-sync.py", line 72, in verify if len(get_ipv4(interface)) < 1: ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/vyos/template.py", line 458, in get_ipv4 return Interface(interface).get_addr_v4() ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 334, in __init__ if not self.iftype: ^^^^^^^^^^^ AttributeError: 'Interface' object has no attribute 'iftype' This commit removes the code path in question and the class attribute check. The reason for the iftype attribute in the past was a common _create() method serving for all interface types. As we already have a lot of derived implementations and not all honor the classes iftype/type member - or even worse honor it only in 50% of the occurrences it's time to drop it.
Diffstat (limited to 'python/vyos/ifconfig/ethernet.py')
-rw-r--r--python/vyos/ifconfig/ethernet.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index d0c03dbe0..93727bdf6 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -33,7 +33,6 @@ class EthernetIf(Interface):
Abstraction of a Linux Ethernet Interface
"""
- iftype = 'ethernet'
definition = {
**Interface.definition,
**{
@@ -119,6 +118,9 @@ class EthernetIf(Interface):
super().__init__(ifname, **kargs)
self.ethtool = Ethtool(ifname)
+ def _create(self):
+ pass
+
def remove(self):
"""
Remove interface from config. Removing the interface deconfigures all
@@ -137,7 +139,7 @@ class EthernetIf(Interface):
# Remove all VLAN subinterfaces - filter with the VLAN dot
for vlan in [
x
- for x in Section.interfaces(self.iftype)
+ for x in Section.interfaces('ethernet')
if x.startswith(f'{self.ifname}.')
]:
Interface(vlan).remove()