mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 03:09:08 +08:00
mac80211: track unmanaged interfaces
In addition to wpa_supplicant and hostapd managed interfaces, also track unmanaged interfaces. This is used to make sure that running 'wifi' always returns into a clean state regardless of what the user did before. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
c888e17e06
commit
2568db3fff
@ -19,6 +19,8 @@ NEWAPLIST=
|
|||||||
OLDAPLIST=
|
OLDAPLIST=
|
||||||
NEWSPLIST=
|
NEWSPLIST=
|
||||||
OLDSPLIST=
|
OLDSPLIST=
|
||||||
|
NEWUMLIST=
|
||||||
|
OLDUMLIST=
|
||||||
|
|
||||||
drv_mac80211_init_device_config() {
|
drv_mac80211_init_device_config() {
|
||||||
hostapd_common_add_device_config
|
hostapd_common_add_device_config
|
||||||
@ -666,6 +668,8 @@ mac80211_setup_adhoc() {
|
|||||||
local enable=$1
|
local enable=$1
|
||||||
json_get_vars bssid ssid key mcast_rate
|
json_get_vars bssid ssid key mcast_rate
|
||||||
|
|
||||||
|
NEWUMLIST="${NEWUMLIST}$ifname "
|
||||||
|
|
||||||
[ "$enable" = 0 ] && {
|
[ "$enable" = 0 ] && {
|
||||||
ip link set dev "$ifname" down
|
ip link set dev "$ifname" down
|
||||||
return 0
|
return 0
|
||||||
@ -712,6 +716,8 @@ mac80211_setup_mesh() {
|
|||||||
local enable=$1
|
local enable=$1
|
||||||
json_get_vars ssid mesh_id mcast_rate
|
json_get_vars ssid mesh_id mcast_rate
|
||||||
|
|
||||||
|
NEWUMLIST="${NEWUMLIST}$ifname "
|
||||||
|
|
||||||
[ "$enable" = 0 ] && {
|
[ "$enable" = 0 ] && {
|
||||||
ip link set dev "$ifname" down
|
ip link set dev "$ifname" down
|
||||||
return 0
|
return 0
|
||||||
@ -800,7 +806,7 @@ mac80211_vap_cleanup() {
|
|||||||
local vaps="$2"
|
local vaps="$2"
|
||||||
|
|
||||||
for wdev in $vaps; do
|
for wdev in $vaps; do
|
||||||
ubus call ${service}.${phy} config_remove "{\"iface\":\"$wdev\"}"
|
[ "$service" != "none" ] && ubus call ${service}.${phy} config_remove "{\"iface\":\"$wdev\"}"
|
||||||
ip link set dev "$wdev" down 2>/dev/null
|
ip link set dev "$wdev" down 2>/dev/null
|
||||||
iw dev "$wdev" del
|
iw dev "$wdev" del
|
||||||
done
|
done
|
||||||
@ -813,6 +819,7 @@ mac80211_interface_cleanup() {
|
|||||||
|
|
||||||
mac80211_vap_cleanup hostapd "${primary_ap}"
|
mac80211_vap_cleanup hostapd "${primary_ap}"
|
||||||
mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
mac80211_vap_cleanup wpa_supplicant "$(uci -q -P /var/state get wireless._${phy}.splist)"
|
||||||
|
mac80211_vap_cleanup none "$(uci -q -P /var/state get wireless._${phy}.umlist)"
|
||||||
}
|
}
|
||||||
|
|
||||||
mac80211_set_noscan() {
|
mac80211_set_noscan() {
|
||||||
@ -845,6 +852,28 @@ drv_mac80211_setup() {
|
|||||||
wireless_set_data phy="$phy"
|
wireless_set_data phy="$phy"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OLDAPLIST=$(uci -q -P /var/state get wireless._${phy}.aplist)
|
||||||
|
OLDSPLIST=$(uci -q -P /var/state get wireless._${phy}.splist)
|
||||||
|
OLDUMLIST=$(uci -q -P /var/state get wireless._${phy}.umlist)
|
||||||
|
|
||||||
|
local wdev
|
||||||
|
local cwdev
|
||||||
|
local found
|
||||||
|
|
||||||
|
for wdev in $(list_phy_interfaces "$phy"); do
|
||||||
|
found=0
|
||||||
|
for cwdev in $OLDAPLIST $OLDSPLIST $OLDUMLIST; do
|
||||||
|
if [ "$wdev" = "$cwdev" ]; then
|
||||||
|
found=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$found" = "0" ]; then
|
||||||
|
ip link set dev "$wdev" down
|
||||||
|
iw dev "$wdev" del
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# convert channel to frequency
|
# convert channel to frequency
|
||||||
[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")"
|
[ "$auto_channel" -gt 0 ] || freq="$(get_freq "$phy" "$channel")"
|
||||||
|
|
||||||
@ -896,7 +925,6 @@ drv_mac80211_setup() {
|
|||||||
for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
|
||||||
NEWAPLIST=
|
NEWAPLIST=
|
||||||
for_each_interface "ap" mac80211_prepare_vif
|
for_each_interface "ap" mac80211_prepare_vif
|
||||||
OLDAPLIST=$(uci -q -P /var/state get wireless._${phy}.aplist)
|
|
||||||
NEW_MD5=$(md5sum ${hostapd_conf_file})
|
NEW_MD5=$(md5sum ${hostapd_conf_file})
|
||||||
OLD_MD5=$(uci -q -P /var/state get wireless._${phy}.md5)
|
OLD_MD5=$(uci -q -P /var/state get wireless._${phy}.md5)
|
||||||
if [ "${NEWAPLIST}" != "${OLDAPLIST}" ]; then
|
if [ "${NEWAPLIST}" != "${OLDAPLIST}" ]; then
|
||||||
@ -927,10 +955,12 @@ drv_mac80211_setup() {
|
|||||||
for_each_interface "ap" mac80211_setup_vif
|
for_each_interface "ap" mac80211_setup_vif
|
||||||
|
|
||||||
NEWSPLIST=
|
NEWSPLIST=
|
||||||
OLDSPLIST=$(uci -q -P /var/state get wireless._${phy}.splist)
|
NEWUMLIST=
|
||||||
|
|
||||||
for_each_interface "sta adhoc mesh monitor" mac80211_setup_vif
|
for_each_interface "sta adhoc mesh monitor" mac80211_setup_vif
|
||||||
|
|
||||||
uci -q -P /var/state set wireless._${phy}.splist="${NEWSPLIST}"
|
uci -q -P /var/state set wireless._${phy}.splist="${NEWSPLIST}"
|
||||||
|
uci -q -P /var/state set wireless._${phy}.umlist="${NEWUMLIST}"
|
||||||
|
|
||||||
local foundvap
|
local foundvap
|
||||||
local dropvap=""
|
local dropvap=""
|
||||||
@ -945,6 +975,15 @@ drv_mac80211_setup() {
|
|||||||
wireless_set_up
|
wireless_set_up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_phy_interfaces() {
|
||||||
|
local phy="$1"
|
||||||
|
if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then
|
||||||
|
ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null;
|
||||||
|
else
|
||||||
|
ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
drv_mac80211_teardown() {
|
drv_mac80211_teardown() {
|
||||||
wireless_process_kill_all
|
wireless_process_kill_all
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user