diff --git a/src/conf_mode/interfaces_wireless.py b/src/conf_mode/interfaces_wireless.py index 02b4a2500b7..a931872b5d2 100755 --- a/src/conf_mode/interfaces_wireless.py +++ b/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 @@ -48,9 +48,17 @@ def find_other_stations(conf, base, ifname): Only one wireless interface per phy can be in station mode - find all interfaces attached to a phy which run in station mode """ + dict = {} + # Is class ieee80211 exists + if ( + not os.path.isdir('/sys/class/ieee80211') + or len(os.listdir('/sys/class/ieee80211')) == 0 + ): + return dict + old_level = conf.get_level() conf.set_level(base) - dict = {} + for phy in os.listdir('/sys/class/ieee80211'): list = [] for interface in conf.list_nodes([]): @@ -173,6 +181,13 @@ def verify(wifi): if len(wifi['station_interfaces'][phy]) > 0: raise ConfigError('Only one station per wireless physical interface possible!') + # Wireless interface does not exist or module not loaded + if ( + not os.path.isdir('/sys/class/ieee80211') + or len(os.listdir('/sys/class/ieee80211')) == 0 + ): + raise ConfigError('Wireless module is not found!') + verify_address(wifi) verify_vrf(wifi) verify_bond_bridge_member(wifi)