Developing lightweight computation at the DSG edge

Commit b45499e1 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Fix viface for 2.4 GHz 80211s_aplan radios



On first boot, routers with a single 2.4 GHz radio had it auto-
configured as 80211s_aplan, with interface wlan0 as 80211s and
wlan0ap as AP. However, the wlan0 interface was wrongly considered
as being inside the virtual interface (viface) "lan" instead of
"mesh_w0". This was a corner case in the qmp_get_virtual_iface()
function, which ultimately made rescue_ip 169.254.x.y to be
incorrectly assigned to "br-lan" instead of "mesh_w0".

Fixes #481.
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 9348e637
......@@ -98,22 +98,26 @@ qmp_set_vlan() {
}
qmp_get_virtual_iface() {
local device="$1"
local viface=""
local device="$1"
local viface=""
# is lan?
# Is it the br-lan interface?
if [ "$device" == "br-lan" ]; then
viface="lan"
if [ ! -e "/sys/class/net/$device/phy80211" ]; then
echo $viface
return
fi
fi
fi
# Is it in the LAN bridge, and not wireless?
for l in $(qmp_get_devices lan); do
if [ "$l" == "$device" ]; then
viface="lan"
if [ ! -e "/sys/class/net/$device/phy80211" ]; then
qmp_log "LOG: 5"
qmp_log "Viface: $viface"
qmp_log $device $viface
echo $viface
return
fi
......@@ -129,28 +133,29 @@ qmp_get_virtual_iface() {
# id_extra are the extra characters after the number: eth0[], wlan1[a]
local id_extra=$(echo $device | sed -e 's/^[a-z]*[0-9]*//g')
# is wan?
# It it a WAN device?
for w in $(qmp_get_devices wan); do
if [ "$w" == "$device" ]; then
viface="wan_${id_char}${id_num}"
qmp_log "LOG: 6"
qmp_log "Viface: $viface"
qmp_log $device $viface
echo $viface
return
fi
done
qmp_log "LOG: 5"
qmp_log "Viface: $viface"
qmp_log $device $viface
# is mesh?
# Is it mesh?
for w in $(qmp_get_devices mesh); do
if [ "$w" == "$device" ]; then
viface="mesh_${id_char}${id_num}${id_extra}"
break
qmp_log "LOG: 7"
qmp_log "Viface: $viface"
qmp_log $device $viface
echo "$viface"
return
fi
done
echo "$viface"
}
# arg1=<mesh|lan|wan>, returns the devices which have to be configured in such mode
......
......@@ -306,9 +306,13 @@ qmp_configure_lan() {
# Attaching LAN devices to br-lan
local device
for device in $(qmp_get_devices lan) ; do
echo " -> LAN device $device"
# Do not attach to br-lan wireless devices, they do it themselves
# somewhere else via /etc/config/wireless
if ! qmp_is_in "$device" $(qmp_get_wifi_devices); then
if qmp_is_in "$device" $(qmp_get_wifi_devices); then
echo " -> Wireless device $device is attached automatically"
else
echo " -> Attaching device $device to br-lan"
qmp_attach_device_to_interface $device lan
qmp_set_mss_clamping_and_masq $device remove
fi
......@@ -339,7 +343,7 @@ qmp_configure_mesh() {
qmp_uci_test qmp.networks.mesh_protocol_vids; then
for dev in $(qmp_get_devices mesh); do
echo "Configuring "$dev" for Meshing"
echo "Configuring "$dev" for meshing"
# Check if the current device is configured as no-vlan
local use_vlan=1
......@@ -407,17 +411,18 @@ qmp_configure_rescue_ip_device() {
local dev="$1"
local viface="$2"
if qmp_is_in "$dev" $(qmp_get_devices wan) || [ "$dev" == "br-lan" ]; then
echo "WAN_OR_LAN"
# If it is WAN or LAN
qmp_configure_rescue_ip $dev ${viface}_rescue
if qmp_is_in "$dev" $(qmp_get_devices wan) ; then
#qmp_attach_device_to_interface $dev ${viface}_rescue
qmp_attach_device_to_interface $dev $viface
fi
echo "Configuring rescue IP for device $dev, with viface $viface."
if qmp_is_in "$dev" $(qmp_get_devices wan); then
echo " -> Device has WAN role"
qmp_configure_rescue_ip $dev ${viface}_rescue
#qmp_attach_device_to_interface $dev ${viface}_rescue
qmp_attach_device_to_interface $dev $viface
elif [ "$dev" == "br-lan" ]; then
echo " -> Device is br-lan"
qmp_configure_rescue_ip $dev ${viface}_rescue
elif qmp_is_in "$dev" $(qmp_get_devices mesh) && [ "$dev" != "br-lan" ]; then
echo "MESH_NOT_LAN"
# If it is only mesh device
echo " -> Device has mesh role and is not br-lan"
qmp_configure_rescue_ip $dev
qmp_attach_device_to_interface $dev $viface
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment