Developing lightweight computation at the DSG edge

Commit 8d26005d authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] 802.1ad VLANs for the routing protocol are created on top of the physical interface

Previously, when an interface (i.e. eth0) was configured as "lan" and "mesh",
it was added to the LAN bridge and, on top of the virtual "br-lan" interface,
the VLAN for the routing protocol was created (i.e. lan_12). This was wrong in
some cases, for example, when another interface was in the bridge but not meant
to be meshing. Now the VLANs are created on the interfaces actually configured
as "mesh".
parent 4fdd709d
......@@ -43,12 +43,24 @@ qmp_check_device() {
ip link show $1 1> /dev/null 2>/dev/null
return $?
}
# Function qmp_set_vlan()
#
# This function creates a VLAN interface on top of an interface in order to
# isolate the routing protocol traffic there:
#
# - 802.1 VLANs are used for wireless interfaces.
# - 802.1ad (QinQ) VLANs are used for wired devices since qMp > 3.2.1
qmp_set_vlan() {
local viface="$1" # lan/wan/meshX
local vid=$2
echo "Setting VLAN $vid for interface $viface"
[ -z "$viface" ] || [ -z "$vid" ] && return
or_viface="$viface"
viface="$(echo $viface | sed -r 's/\./_/g')"
uci set network.${viface}_${vid}=device
if [ -e "/sys/class/net/$dev/phy80211" ]; then
# 802.1q VLANs for wireless interfaces
......@@ -61,10 +73,10 @@ qmp_set_vlan() {
uci set network.${viface}_${vid}.name=${viface}_${vid}
if [ -e "/sys/class/net/$dev/phy80211" ]; then
# 802.1q VLANs for wireless interfaces
uci set network.${viface}_${vid}.ifname='@'${viface}
uci set network.${viface}_${vid}.ifname='@'${or_viface}
else
# 802.1ad VLANs for wired interfaces
uci set network.${viface}_${vid}.ifname=$3
uci set network.${viface}_${vid}.ifname=$or_viface
fi
uci set network.${viface}_${vid}.vid=${vid}
......@@ -144,28 +156,30 @@ qmp_get_devices() {
local devices=""
if [ "$1" == "mesh" ]; then
local brlan_enabled=0
for dev in $(uci get qmp.interfaces.mesh_devices 2>/dev/null); do
# Looking if device is defined as LAN, in such case dev=br-lan, but only once
# except eth1 for RouterStation Pro
if ! ( [[ "$dev" == "eth1" ]] && qmp_is_routerstationpro ) ; then
for landev in $(uci get qmp.interfaces.lan_devices 2>/dev/null); do
if [ "$landev" == "$dev" ] && [ ! -e "/sys/class/net/$dev/phy80211" ] ; then
if [ $brlan_enabled -eq 0 ]; then
dev="br-lan"
brlan_enabled=1
else
dev=""
fi
break
fi
done
fi
[ -n "$dev" ] && devices="$devices $dev"
done
fi
devices="$(uci get qmp.interfaces.mesh_devices 2>/dev/null)"
fi
# local brlan_enabled=0
# for dev in $(uci get qmp.interfaces.mesh_devices 2>/dev/null); do
#
# # Looking if device is defined as LAN, in such case dev=br-lan, but only once
# # except eth1 for RouterStation Pro
# if ! ( [[ "$dev" == "eth1" ]] && qmp_is_routerstationpro ) ; then
# for landev in $(uci get qmp.interfaces.lan_devices 2>/dev/null); do
# if [ "$landev" == "$dev" ] && [ ! -e "/sys/class/net/$dev/phy80211" ] ; then
# if [ $brlan_enabled -eq 0 ]; then
# dev="br-lan"
# brlan_enabled=1
# else
# dev=""
# fi
# break
# fi
# done
# fi
#
# [ -n "$dev" ] && devices="$devices $dev"
# done
# fi
if [ "$1" == "lan" ]; then
devices="$(uci get qmp.interfaces.lan_devices 2>/dev/null)"
......@@ -798,12 +812,12 @@ fi
local counter=1
for dev in $(qmp_get_devices mesh); do
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
echo "Configuring interface $dev in BMX6"
for protocol_vid in $(uci get qmp.networks.mesh_protocol_vids); do
local protocol_name="$(echo $protocol_vid | awk -F':' '{print $1}')"
if [ "$protocol_name" = "bmx6" ] ; then
# Check if the current device is configured as no-vlan
local use_vlan=1
for no_vlan_int in $(qmp_uci_get interfaces.no_vlan_devices); do
......@@ -820,7 +834,8 @@ fi
# If vlan tagging
if [ $use_vlan -eq 1 ]; then
local viface="$(qmp_get_virtual_iface $dev)"
# For interfaces like eth0.1, replace the dot with an underscore
local viface="$(echo $dev | sed -r 's/\./_/g')"
local ifname="${viface}_${vid}"
# If not vlan tagging
......
......@@ -357,10 +357,9 @@ qmp_configure_mesh() {
# if no vlan is specified do not use vlan
[ -z "$vid" ] && vid=1 && use_vlan=0
# virtual interface
local viface=$(qmp_get_virtual_iface $dev)
echo "device $dev is in viface $viface"
# put typical IPv6 prefix (2002::), otherwise ipv6 calc assumes mapped or embedded ipv4 address
local ip6_suffix="2002::${counter}${vid}"
......@@ -368,33 +367,23 @@ qmp_configure_mesh() {
# in case of not use vlan tag, device definition is not needed.
[ $use_vlan -eq 1 ] && {
#### [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 $dev $vid
}
dev="$(echo $dev | sed -r 's/\./_/g')"
# Configure IPv6 address only if mesh_prefix48 is defined (bmx6 does not need it)
if qmp_uci_test qmp.networks.${protocol_name}_mesh_prefix48; then
local ip6="$(qmp_get_ula96 $(uci get qmp.networks.${protocol_name}_mesh_prefix48):: $primary_mesh_device $ip6_suffix 128)"
echo "Configuring $ip6 for $protocol_name"
qmp_uci_set_raw network.${viface}_$vid.proto=static
qmp_uci_set_raw network.${viface}_$vid.ip6addr="$ip6"
qmp_uci_set_raw network.${dev}_$vid.proto=static
qmp_uci_set_raw network.${dev}_$vid.ip6addr="$ip6"
else
qmp_uci_set_raw network.${viface}_$vid.proto=none
qmp_uci_set_raw network.${viface}_$vid.auto=1
qmp_uci_set_raw network.${dev}_$vid.proto=none
qmp_uci_set_raw network.${dev}_$vid.auto=1
fi
done
qmp_configure_rescue_ip_device "$dev" "$viface"
echo qmp_configure_rescue_ip_device "$dev" "$viface"
counter=$(( $counter + 1 ))
done
fi
......@@ -407,10 +396,15 @@ qmp_configure_rescue_ip_device() {
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
qmp_attach_device_to_interface $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
elif qmp_is_in "$dev" $(qmp_get_devices mesh) && [ "$dev" != "br-lan" ]; then
echo "MESH_NOT_LAN"
# If it is only mesh device
qmp_configure_rescue_ip $dev
qmp_attach_device_to_interface $dev $viface
......
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