Developing lightweight computation at the DSG edge

Commit 1863f86f authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Use OpenWrt's default interface roles on autoconfig



Previously, eth0/eth0.1 was used as LAN by default, then any other
interface as WAN. For those devices not matching this a specific hook
was needed.

By using /etc/board.json information, now the LAN/WAN roles are
assigned the same way as OpenWrt does it, so no hooks are needed to
avoid roles swap.

Fixes #214.
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 3020d557
......@@ -182,6 +182,8 @@ qmp_configure_smart_network() {
local dev=""
local phydevs=""
local ignore_devs=""
local default_lan=$(qmp_get_openwrt_default_network "lan")
local default_wan=$(qmp_get_openwrt_default_network "wan")
[ "$force" != "force" ] && {
ignore_devs="$(qmp_uci_get interfaces.ignore_devices)"
......@@ -241,33 +243,35 @@ qmp_configure_smart_network() {
[ $cnt -eq 1 ] && continue
}
# If not found before...
[ "$dev" == "eth0" ] || [ "$dev" == "eth0.1" ] && {
# If the device is not configured already, assign its role acording to
# OpenWrt's defaults. This avoids the per-device hooks that swapped roles
[ "$dev" == "$default_lan" ] && {
lan="$lan $dev"
mesh="$mesh $dev"
continue
}
[ "$dev" == "$default_wan" ] && {
wan="$wan $dev"
mesh="$mesh $dev"
continue
}
## if there is not yet a LAN device, configuring as lan and mesh
##[ -z "$lan" ] && { lan="$dev"; mesh="$dev" && continue
# if it is a wifi device
# If it is a wifi device
[ -e "/sys/class/net/$dev/phy80211" ] && {
j=0
while qmp_uci_test qmp.@wireless[$j]; do
[ "$(qmp_uci_get @wireless[$j].device)" == "$dev" ] && {
mode="$(qmp_uci_get @wireless[$j].mode)"
[ "$mode" == "ap" ] && lan="$dev $lan" || mesh="$dev $mesh"
( [ "$mode" == "aplan" ] || [ "$mode" == "80211s_aplan" ] || [ "$mode" == "adhoc_ap" ] ) && lan="$dev $lan"
( [ "$mode" == "80211s" ] || [ "$mode" == "80211s_aplan" ] || [ "$mode" == "80211s_adhoc" ] || [ "$mode" == "adhoc" ] || [ "$mode" == "adhoc_ap" ] ) && mesh="$dev $mesh"
break
}
j=$(($j+1))
done
} && continue
# if there is already LAN device and it is not wifi, use as WAN+MESH
[ -z "$wan" ] && wan="$dev" && mesh="$mesh $dev" || {
# else use as LAN and MESH
lan="$dev $lan"
# If its not wireless nor a default wan/lan, set it to mesh
[ "$dev" != "$default_lan" ] && [ "$dev" != "$default_wan" ] && {
mesh="$dev $mesh"
}
......
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