Developing lightweight computation at the DSG edge

Commit 2df4490f authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Fix #377 (1): backport QinQ branch into testing

This commit fixes issue #377, regarding the ways VLANs are specified in
/etc/config/network. The previous method (with @wlan0-like stuff) was never
meant to work, although it just happened to work. Recent OpenWrt changes
have deprecated that *unsupported* way to declare VLANs. Backporting the
work in branch QinQ and adding a couple of changes (e.g. linklayer details
for BMX6) fixes the problem.
parent 820accb4
......@@ -9,7 +9,7 @@
[ $(bmx6 -c show=interfaces| grep -c UP) -le 0 ] && {
echo "[$(date)] There is no interface working, restarting network and bmx6."
logread > /tmp/bmx6_crash_$(date +%Y%m%d_%H%M).log
/etc/init.d/network restart
/etc/init.d/network reload
if /etc/init.d/gwck enabled
then
/etc/init.d/gwck restart
......
......@@ -33,7 +33,7 @@ configure_wifi() {
qmp_configure_wifi_initial
qmp_configure_wifi
configure_network
/etc/init.d/network restart
/etc/init.d/network reload
if /etc/init.d/gwck enabled
then
/etc/init.d/gwck restart
......@@ -51,7 +51,7 @@ apply_services() {
configure_network() {
qmp_configure
qmp_bmx6_reload
/etc/init.d/network restart
/etc/init.d/network reload
if /etc/init.d/gwck enabled
then
/etc/init.d/gwck restart
......
......@@ -49,10 +49,24 @@ qmp_set_vlan() {
local vid=$2
[ -z "$viface" ] || [ -z "$vid" ] && return
uci set network.${viface}_$vid=interface
uci set network.${viface}_$vid.proto=none
uci set network.${viface}_$vid.ifname=@$viface.$vid
uci set network.${viface}_${vid}=device
if [ -e "/sys/class/net/$dev/phy80211" ]; then
# 802.1Q VLANs for wireless interfaces
uci set network.${viface}_${vid}.type=8021q
else
# [QinQ backport] 802.1q VLANs for wired interfaces
uci set network.${viface}_${vid}.type=8021q
fi
uci set network.${viface}_${vid}.name=${viface}_${vid}
uci set network.${viface}_${vid}.ifname=$3
uci set network.${viface}_${vid}.vid=${vid}
uci set network.${viface}_${vid}_ad=interface
uci set network.${viface}_${vid}_ad.ifname=${viface}_${vid}
uci set network.${viface}_${vid}_ad.proto=${none}
uci set network.${viface}_${vid}_ad.auto=1
uci commit network
}
qmp_get_virtual_iface() {
......@@ -190,11 +204,19 @@ qmp_configure_smart_network() {
[ "$id" == "$dev" ] && ignore=1
done
[ $ignore -eq 0 ] && phydevs="$phydevs $dev\n"
}
# [Qin] The device might be a wired device (e.g. eth0) with a switch
# and two or more virtual switched devices (e.g. eth0.1, eth0.2)
for sdev in $(ls /sys/class/net/$dev/ | grep upper_$dev. | cut -d "_" -f2); do
phydevs="$phydevs $sdev\n"
ignore=1
done
phydevs="$(echo -e "$phydevs" | grep -v -e ".*ap$" | grep -v "\\." | sort -u | tr -d ' ' \t)"
if [ $ignore -eq 0 ]; then
phydevs="$phydevs $dev\n"
fi
}
done
phydevs="$(echo -e "$phydevs" | grep -v -e ".*ap$" | sort -u | tr -d ' ' \t)"
# if force is not enabled, we are not changing the existing lan/wan/mesh (only adding new ones)
[ "$force" != "force" ] && {
......@@ -211,6 +233,7 @@ qmp_configure_smart_network() {
for dev in $phydevs; do
# If force is enabled, do not check if the device is already configured
[ "$force" != "force" ] && {
cnt=0
# If it is already configured, doing nothing
for cdev in $lan; do
......@@ -226,9 +249,9 @@ qmp_configure_smart_network() {
}
# If not found before...
[ "$dev" == "eth0" ] && {
lan="$lan eth0"
mesh="$mesh eth0"
[ "$dev" == "eth0" ] || [ "$dev" == "eth0.1" ] && {
lan="$lan $dev"
mesh="$mesh $dev"
continue
}
......@@ -248,12 +271,13 @@ qmp_configure_smart_network() {
done
} && continue
# if there is already LAN device and it is not wifi, use as WAN
[ -z "$wan" ] && wan="$dev" || {
# 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"
mesh="$dev $mesh"
}
done
echo "Network devices found:"
......@@ -784,7 +808,8 @@ qmp_configure_bmx6() {
# If vlan tagging
if [ $use_vlan -eq 1 ]; then
local ifname="$dev.$vid"
local viface="$(qmp_get_virtual_iface $dev)"
local ifname="${viface}_${vid}"
# If not vlan tagging
else
......@@ -793,6 +818,11 @@ qmp_configure_bmx6() {
uci set $conf.mesh_$counter="dev"
uci set $conf.mesh_$counter.dev="$ifname"
if [ -e "/sys/class/net/$dev/phy80211" ]; then
uci set $conf.mesh_$counter.linklayer=2
else
uci set $conf.mesh_$counter.linklayer=1
fi
if qmp_uci_test qmp.networks.bmx6_ipv4_address ; then
local bmx6_ipv4_netmask="$(echo $(uci get qmp.networks.bmx6_ipv4_address) | cut -s -d / -f2)"
......@@ -851,7 +881,7 @@ qmp_configure_initial() {
qmp_hooks_exec firstboot
qmp_configure_wifi_initial
qmp_configure_wifi
/etc/init.d/network restart
/etc/init.d/network reload
sleep 1
qmp_configure_smart_network
}
......
......@@ -34,7 +34,7 @@ qmp_set_mss_clamping_and_masq() {
# Prepare config files
qmp_configure_prepare_network() {
local toRemove="$(uci show network | egrep "network.(lan|wan|mesh_).*=interface" | cut -d. -f2 | cut -d= -f1)"
local toRemove="$(uci show network | egrep "network.(lan|wan|mesh_).*=(interface|device)" | cut -d. -f2 | cut -d= -f1)"
qmp_log "Removing current network configuration"
for i in $toRemove; do
uci del network.$i
......@@ -362,12 +362,21 @@ 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 ] && {
# If device is WAN use rescue for the VLAN tag
if [ $(qmp_get_devices wan | grep -c $dev) -gt 0 ]; then
qmp_set_vlan ${viface}_rescue $vid
else
qmp_set_vlan $viface $vid
fi
#### [QinQ]
####
#### Using the rescue interface here does not make much sense as of
#### current qMp status and does not work for 802.1-ad
####
#### # If device is WAN use rescue for the VLAN tag
####
#### if [ $(qmp_get_devices wan | grep -c $dev) -gt 0 ]; then
#### qmp_set_vlan ${viface}_rescue $vid $dev
#### else
#### qmp_set_vlan $viface $vid $dev
#### fi
qmp_set_vlan $viface $vid $dev
}
# Configure IPv6 address only if mesh_prefix48 is defined (bmx6 does not need it)
......
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