Developing lightweight computation at the DSG edge

Commit 1525fd49 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Put wired interfaces with MESH role in a virtual interface



Interfaces (e.g., eth2) with only MESH role, now without rescue addres
nor VLANs on top, need to be put inside a virtual interface (e.g.,
mesh_e2) for them to be activated by OpenWrt's network daemon, so that
they can be used by BMX6.

Fixes #493
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent ba712452
......@@ -94,7 +94,29 @@ qmp_set_vlan() {
uci set network.${uiface}_${vid}_${vtype}.proto=${none}
uci set network.${uiface}_${vid}_${vtype}.auto=1
uci commit network
}
# Function qmp_set_viface()
#
# This function creates a virtual dummy interface (e.g., mesh_e2) on top of a
# network device (e.g., eth2). This is needed for wired devices working only as
# MESH, which otherwise are not brought up even if they have link. Fixes #493.
qmp_set_viface() {
local dev="${1}" # The physical interface
local viface="${2}" # The virtual device
echo "Setting virtual interface ${viface} for device ${dev}"
[ -z "${dev}" ] || [ -z "${viface}" ] && return
# Replace dots by underscores, in case there is any
local viface="$(echo $viface | sed -r 's/\./_/g')"
uci set network.${viface}="interface"
uci set network.${viface}.device=${dev}
uci set network.${viface}.auto=1
uci set network.${viface}.proto="none"
uci commit network
}
qmp_get_virtual_iface() {
......@@ -138,12 +160,12 @@ qmp_get_virtual_iface() {
return;
}
# id_char is the first char of the device: [e]th0 [w]lan1a
# id_char is the first char of the device: [e]th0, [e]th0.2, [w]lan1a
local id_char=$(echo $device | cut -c 1)
# id_num is the number of the device: eth[0], wlan[1]a
# id_num is the number of the device: eth[0], eth[0,2] wlan[1]a
local id_num=$(echo $device | tr -d "[A-z]" | tr - _ | tr . _)
# 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')
# id_extra are the extra characters after the number: eth0[], eth0.2[], wlan1[a]
local id_extra=$(echo $device | sed -e 's/\.//g' | sed -e 's/^[a-z]*[0-9]*//g')
# It it a WAN device?
for w in $(qmp_get_devices wan); do
......@@ -160,8 +182,8 @@ qmp_get_virtual_iface() {
# Is it mesh?
for w in $(qmp_get_devices mesh); do
if [ "$w" == "$device" ]; then
qmp_log "LOG: 9"
viface="mesh_${id_char}${id_num}${id_extra}"
qmp_log "LOG: 8"
qmp_log "Viface: $viface"
qmp_log "$device $viface"
echo "$viface"
......
......@@ -395,7 +395,6 @@ qmp_configure_mesh() {
# Since all interfaces are defined somewhere (LAN, WAN or with Rescue IP),
# in case of not use vlan tag, device definition is not needed.
[ $use_vlan -eq 1 ] && {
qmp_set_vlan $dev $vid $viface
}
......@@ -416,13 +415,16 @@ qmp_configure_mesh() {
# IPv6 address. However, the radios must be "assigned" to some interface to
# bring them up; otherwise the VLAN interface on top of the radio interface
# can't be brought up
if ! ( [ -e "/sys/class/net/$dev" ] && [ ! -e "/sys/class/net/$dev/phy80211" ] ); then
if ( [ -e "/sys/class/net/$dev" ] && [ -e "/sys/class/net/$dev/phy80211" ] ); then
local wireless_network="$(uci get wireless.${dev}.network)"
if [ -z "$wireless_network" ]; then
qmp_configure_rescue_ip_device "$dev" "$viface"
else
qmp_configure_rescue_ip_device "$dev" "$wireless_network"
fi
# Add to the virtual interface those wired interfaces that wouldn't be brought up (Fixes #493)
elif ( ! ( qmp_is_in "$dev" $(qmp_get_devices wan) || qmp_is_in "$dev" $(qmp_get_devices lan) ) ); then
qmp_set_viface $dev $viface
fi
counter=$(( $counter + 1 ))
done
......
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