Page MenuHomeVyOS Platform

wireless: fix race on interface removal
Closed, ResolvedPublicBUG

Description

A classical race condition detected depending on host system CPU load while executing smoketests.

Removal of the Wireless/Wifi interfaces can cause a KeyError.

DEBUG -
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/conf_mode/interfaces_wireless.py", line 414, in <module>
DEBUG -     apply(c)
DEBUG -   File "/usr/libexec/vyos/conf_mode/interfaces_wireless.py", line 325, in apply
DEBUG -     WiFiIf(**wifi).remove()
DEBUG -     ^^^^^^^^^^^^^^
DEBUG -   File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 358, in __init__
DEBUG -     self._create()
DEBUG -   File "/usr/lib/python3/dist-packages/vyos/ifconfig/wireless.py", line 33, in _create
DEBUG -     cmd = ['iw', 'phy', self.config['physical_device'], 'interface', 'add',
DEBUG -                         ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
DEBUG - KeyError: 'physical_device'
DEBUG -
DEBUG - noteworthy:
DEBUG - cmd 'ip link show dev wlan1'
DEBUG - returned (out):
DEBUG -
DEBUG - returned (err):
DEBUG - Device "wlan1" does not exist.
DEBUG -
DEBUG - delete [ interfaces wireless wlan1 ] failed
DEBUG - Commit failed

In src/conf_mode/interfaces_wireless.py:apply(), the delete path unconditionally does WiFiIf(**wifi).remove().
Since the wifi dict for a deleted node never contains physical_device, and Interface.__init__ calls self._create() whenever the kernel interface doesn't already exist, WiFiIf._create() crashes with KeyError: 'physical_device' when the interface never actually got created (or already vanished) before deletion.

Details

Version
2026.07.18-rolling
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)