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 @@ ...@@ -9,7 +9,7 @@
[ $(bmx6 -c show=interfaces| grep -c UP) -le 0 ] && { [ $(bmx6 -c show=interfaces| grep -c UP) -le 0 ] && {
echo "[$(date)] There is no interface working, restarting network and bmx6." echo "[$(date)] There is no interface working, restarting network and bmx6."
logread > /tmp/bmx6_crash_$(date +%Y%m%d_%H%M).log 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 if /etc/init.d/gwck enabled
then then
/etc/init.d/gwck restart /etc/init.d/gwck restart
......
...@@ -33,7 +33,7 @@ configure_wifi() { ...@@ -33,7 +33,7 @@ configure_wifi() {
qmp_configure_wifi_initial qmp_configure_wifi_initial
qmp_configure_wifi qmp_configure_wifi
configure_network configure_network
/etc/init.d/network restart /etc/init.d/network reload
if /etc/init.d/gwck enabled if /etc/init.d/gwck enabled
then then
/etc/init.d/gwck restart /etc/init.d/gwck restart
...@@ -51,7 +51,7 @@ apply_services() { ...@@ -51,7 +51,7 @@ apply_services() {
configure_network() { configure_network() {
qmp_configure qmp_configure
qmp_bmx6_reload qmp_bmx6_reload
/etc/init.d/network restart /etc/init.d/network reload
if /etc/init.d/gwck enabled if /etc/init.d/gwck enabled
then then
/etc/init.d/gwck restart /etc/init.d/gwck restart
......
...@@ -49,10 +49,24 @@ qmp_set_vlan() { ...@@ -49,10 +49,24 @@ qmp_set_vlan() {
local vid=$2 local vid=$2
[ -z "$viface" ] || [ -z "$vid" ] && return [ -z "$viface" ] || [ -z "$vid" ] && return
uci set network.${viface}_$vid=interface uci set network.${viface}_${vid}=device
uci set network.${viface}_$vid.proto=none if [ -e "/sys/class/net/$dev/phy80211" ]; then
uci set network.${viface}_$vid.ifname=@$viface.$vid # 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 uci commit network
} }
qmp_get_virtual_iface() { qmp_get_virtual_iface() {
...@@ -190,11 +204,19 @@ qmp_configure_smart_network() { ...@@ -190,11 +204,19 @@ qmp_configure_smart_network() {
[ "$id" == "$dev" ] && ignore=1 [ "$id" == "$dev" ] && ignore=1
done 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
if [ $ignore -eq 0 ]; then
phydevs="$phydevs $dev\n"
fi
} }
done done
phydevs="$(echo -e "$phydevs" | grep -v -e ".*ap$" | sort -u | tr -d ' ' \t)"
phydevs="$(echo -e "$phydevs" | grep -v -e ".*ap$" | grep -v "\\." | sort -u | tr -d ' ' \t)"
# if force is not enabled, we are not changing the existing lan/wan/mesh (only adding new ones) # if force is not enabled, we are not changing the existing lan/wan/mesh (only adding new ones)
[ "$force" != "force" ] && { [ "$force" != "force" ] && {
...@@ -211,6 +233,7 @@ qmp_configure_smart_network() { ...@@ -211,6 +233,7 @@ qmp_configure_smart_network() {
for dev in $phydevs; do for dev in $phydevs; do
# If force is enabled, do not check if the device is already configured # If force is enabled, do not check if the device is already configured
[ "$force" != "force" ] && { [ "$force" != "force" ] && {
cnt=0 cnt=0
# If it is already configured, doing nothing # If it is already configured, doing nothing
for cdev in $lan; do for cdev in $lan; do
...@@ -226,9 +249,9 @@ qmp_configure_smart_network() { ...@@ -226,9 +249,9 @@ qmp_configure_smart_network() {
} }
# If not found before... # If not found before...
[ "$dev" == "eth0" ] && { [ "$dev" == "eth0" ] || [ "$dev" == "eth0.1" ] && {
lan="$lan eth0" lan="$lan $dev"
mesh="$mesh eth0" mesh="$mesh $dev"
continue continue
} }
...@@ -248,12 +271,13 @@ qmp_configure_smart_network() { ...@@ -248,12 +271,13 @@ qmp_configure_smart_network() {
done done
} && continue } && continue
# if there is already LAN device and it is not wifi, use as WAN # if there is already LAN device and it is not wifi, use as WAN+MESH
[ -z "$wan" ] && wan="$dev" || { [ -z "$wan" ] && wan="$dev" && mesh="$mesh $dev" || {
# else use as LAN and MESH # else use as LAN and MESH
lan="$dev $lan" lan="$dev $lan"
mesh="$dev $mesh" mesh="$dev $mesh"
} }
done done
echo "Network devices found:" echo "Network devices found:"
...@@ -773,7 +797,7 @@ qmp_configure_bmx6() { ...@@ -773,7 +797,7 @@ qmp_configure_bmx6() {
for no_vlan_int in $(qmp_uci_get interfaces.no_vlan_devices); do for no_vlan_int in $(qmp_uci_get interfaces.no_vlan_devices); do
[ "$no_vlan_int" == "$dev" ] && use_vlan=0 [ "$no_vlan_int" == "$dev" ] && use_vlan=0
done done
# Check if the protocol has VLAN tag configured # Check if the protocol has VLAN tag configured
local vid="$(echo $protocol_vid | awk -F':' '{print $2}')" local vid="$(echo $protocol_vid | awk -F':' '{print $2}')"
[ -z "$vid" -o $vid -lt 1 ] && use_vlan=0 [ -z "$vid" -o $vid -lt 1 ] && use_vlan=0
...@@ -783,16 +807,22 @@ qmp_configure_bmx6() { ...@@ -783,16 +807,22 @@ qmp_configure_bmx6() {
[ -z "$vid" -o $vid -lt 1 ] && use_vlan=0 [ -z "$vid" -o $vid -lt 1 ] && use_vlan=0
# If vlan tagging # If vlan tagging
if [ $use_vlan -eq 1 ]; then 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 # If not vlan tagging
else else
local ifname="$dev" local ifname="$dev"
fi fi
uci set $conf.mesh_$counter="dev" uci set $conf.mesh_$counter="dev"
uci set $conf.mesh_$counter.dev="$ifname" 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 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)" local bmx6_ipv4_netmask="$(echo $(uci get qmp.networks.bmx6_ipv4_address) | cut -s -d / -f2)"
...@@ -851,7 +881,7 @@ qmp_configure_initial() { ...@@ -851,7 +881,7 @@ qmp_configure_initial() {
qmp_hooks_exec firstboot qmp_hooks_exec firstboot
qmp_configure_wifi_initial qmp_configure_wifi_initial
qmp_configure_wifi qmp_configure_wifi
/etc/init.d/network restart /etc/init.d/network reload
sleep 1 sleep 1
qmp_configure_smart_network qmp_configure_smart_network
} }
......
...@@ -34,7 +34,7 @@ qmp_set_mss_clamping_and_masq() { ...@@ -34,7 +34,7 @@ qmp_set_mss_clamping_and_masq() {
# Prepare config files # Prepare config files
qmp_configure_prepare_network() { 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" qmp_log "Removing current network configuration"
for i in $toRemove; do for i in $toRemove; do
uci del network.$i uci del network.$i
...@@ -346,7 +346,7 @@ qmp_configure_mesh() { ...@@ -346,7 +346,7 @@ qmp_configure_mesh() {
for protocol_vid in $protocol_vids; do for protocol_vid in $protocol_vids; do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')" local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
local vid="$(echo $protocol_vid | awk -F':' '{print $2}')" local vid="$(echo $protocol_vid | awk -F':' '{print $2}')"
# if no vlan is specified do not use vlan # if no vlan is specified do not use vlan
[ -z "$vid" ] && vid=1 && use_vlan=0 [ -z "$vid" ] && vid=1 && use_vlan=0
...@@ -362,12 +362,21 @@ qmp_configure_mesh() { ...@@ -362,12 +362,21 @@ qmp_configure_mesh() {
# Since all interfaces are defined somewhere (LAN, WAN or with Rescue IP), # Since all interfaces are defined somewhere (LAN, WAN or with Rescue IP),
# in case of not use vlan tag, device definition is not needed. # in case of not use vlan tag, device definition is not needed.
[ $use_vlan -eq 1 ] && { [ $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 #### [QinQ]
qmp_set_vlan ${viface}_rescue $vid ####
else #### Using the rescue interface here does not make much sense as of
qmp_set_vlan $viface $vid #### current qMp status and does not work for 802.1-ad
fi ####
#### # 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) # 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