-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T6267: Check interface wireless module before apply config #3368
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A proper fix should be:
from vyos.utils.kernel import check_kmod
...
if __name__ == '__main__':
try:
check_kmod('mac80211')
c = get_config()
verify(c)
Which will create /sys/class/ieee80211
. Calling the module loader is what we already do for other drivers like l2tpv3
@c-po, it doesn't work
The modules are loaded, but I don't have any real wireless device:
|
cpo@vyos# commit
[ interfaces wireless wlan0 ]
Wirelss interface PHY "phy0" does not exist!
[[interfaces wireless wlan0]] failed
Commit failed diff --git i/src/conf_mode/interfaces_wireless.py w/src/conf_mode/interfaces_wireless.py
index 02b4a2500..c0a17c0bc 100755
--- i/src/conf_mode/interfaces_wireless.py
+++ w/src/conf_mode/interfaces_wireless.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2019-2020 VyOS maintainers and contributors
+# Copyright (C) 2019-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -31,8 +31,9 @@
from vyos.configverify import verify_bond_bridge_member
from vyos.ifconfig import WiFiIf
from vyos.template import render
-from vyos.utils.process import call
from vyos.utils.dict import dict_search
+from vyos.utils.kernel import check_kmod
+from vyos.utils.process import call
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -118,6 +119,10 @@ def verify(wifi):
if 'physical_device' not in wifi:
raise ConfigError('You must specify a physical-device "phy"')
+ physical_device = wifi['physical_device']
+ if not os.path.exists(f'/sys/class/ieee80211/{physical_device}'):
+ raise ConfigError(f'Wirelss interface PHY "{physical_device}" does not exist!')
+
if 'type' not in wifi:
raise ConfigError('You must specify a WiFi mode')
@@ -266,6 +271,7 @@ def apply(wifi):
if __name__ == '__main__':
try:
+ check_kmod('mac80211')
c = get_config()
verify(c)
generate(c) |
Check if the wireless device/modem exists in the system and the module `ieee802111` was loaded In cases where we do not have wireless devices, it prevents the unexpected traceback ``` set interfaces wireless wlan0 address 192.0.2.5/32 commit Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/interfaces_wireless.py", line 269, in <modu> c = get_config() ^^^^^^^^^^^^ File "/usr/libexec/vyos/conf_mode/interfaces_wireless.py", line 104, in get_cg tmp = find_other_stations(conf, base, wifi['ifname']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/libexec/vyos/conf_mode/interfaces_wireless.py", line 54, in find_os for phy in os.listdir('/sys/class/ieee80211'): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/ieee80211' ```
@Mergifyio backport sagitta |
✅ Backports have been created
|
Change Summary
Check if the wireless device/modem exists in the system and the module
ieee802111
was loadedIn cases where we do not have wireless devices, it prevents the unexpected traceback
(I do not have an actual wireless device to check if it will work when the device really exists, will be perfect to re-check it)
Types of changes
Related Task(s)
Related PR(s)
Component(s) name
wireless
Proposed changes
How to test
In the instance without a wireless device try to configure a wireless interface:
Before the fix:
After the fix:
Smoketest result
Checklist: