initial dsa switch changes

This commit is contained in:
Fabian Bläse 2021-02-12 03:39:47 +01:00
parent 97161949aa
commit 45b47b052a
6 changed files with 76 additions and 36 deletions

View File

@ -13,7 +13,12 @@ configure() {
local ports="$(uci -q get gateway.$vlan.ports)"
local name="$SWITCHDEV"_$vlan
uci set network.$name='switch_vlan'
if [ "$DSA" = "1" ]; then
uci set network.$name='bridge-vlan'
else
uci set network.$name='switch_vlan'
fi
uci set network.$name.device="$(uci get network.$SWITCHDEV.name)"
uci set network.$name.vlan="$vlan"
uci set network.$name.ports="$(get_cpu_port) $ports"
@ -34,6 +39,7 @@ configure() {
config_load network
config_foreach remove_vlan switch_vlan
config_foreach remove_vlan bridge-vlan
config_load gateway
config_foreach add_vlan vlan
@ -46,3 +52,14 @@ apply() {
revert() {
uci revert network
}
reload() {
# This is a dirty workaround because
# DSA refuses to correctly apply new
# vlan filtering on reload_config.
#
# This probably has to be fixed upstream.
# Until then, explicity restart the network
# service, which completely recreates the bridge.
/etc/init.d/network restart
}

View File

@ -50,7 +50,7 @@ configure() {
# set interface
#remove all eth interfaces
ifaces=$(uci get network.client.ifname | sed 's/\beth[^ ]* *//g')
ifaces=$(uci get network.client.ifname | sed 's/\beth[^ ]* *//g' | sed 's/\bswitch[^ ]* *//g')
if vlan=$(uci -q get gateway.@client[0].vlan); then
uci set network.client.ifname="${SWITCHDEV}.$vlan $ifaces"
elif iface=$(uci -q get gateway.@client[0].iface); then

View File

@ -10,12 +10,10 @@ get_cpu_port() {
tplink,c50-v4|\
tplink,tl-wr1043nd-v2|\
tplink,tl-wr1043nd-v3|\
tl-wr841n-v13|\
netgear,r6220|\
ubnt,edgerouter-x|\
ubnt,edgerouter-x-sfp)
tl-wr841n-v13)
CPUPORT="6t"
;;
netgear,r6220|\
tplink,cpe210-v2|\
tplink,cpe210-v3|\
tplink,tl-mr3020-v1|\
@ -23,6 +21,8 @@ get_cpu_port() {
tplink,tl-wa860re-v1|\
tplink,tl-wa901nd-v2|\
ubnt,bullet-m|\
ubnt,edgerouter-x|\
ubnt,edgerouter-x-sfp|\
ubnt,nanostation-loco-m|\
ubnt,nanostation-loco-m-xw|\
ubnt,nanostation-m|\

View File

@ -73,31 +73,52 @@ fi
if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
SWITCHHW=$(swconfig list | awk '{ print $4 }')
if [ "$DSA" = "1" ]; then
uci set network.$SWITCHDEV=device
uci set network.$SWITCHDEV.name=$SWITCHDEV
uci set network.$SWITCHDEV.type=bridge
uci set network.$SWITCHDEV=switch
uci set network.$SWITCHDEV.name=$SWITCHHW
uci set network.$SWITCHDEV.enable=1
uci set network.$SWITCHDEV.reset=1
uci set network.$SWITCHDEV.enable_vlan=1
uci set network.${SWITCHDEV}_1=bridge-vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHDEV
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
uci set network.${SWITCHDEV}_1=switch_vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=bridge-vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHDEV
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=switch_vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
uci set network.${SWITCHDEV}_3=bridge-vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHDEV
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
else
uci set network.$SWITCHDEV=switch
uci set network.$SWITCHDEV.name=$SWITCHHW
uci set network.$SWITCHDEV.enable=1
uci set network.$SWITCHDEV.reset=1
uci set network.$SWITCHDEV.enable_vlan=1
uci set network.${SWITCHDEV}_1=switch_vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=switch_vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
uci set network.${SWITCHDEV}_3=switch_vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
fi
uci set network.${SWITCHDEV}_3=switch_vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
uci set network.client.ifname="$SWITCHDEV.1 bat0"
uci set network.ethmesh.ifname="$SWITCHDEV.3"

View File

@ -1,9 +1,10 @@
. /lib/functions/fff/network
WANDEV=eth0
SWITCHDEV=eth0
CLIENT_PORTS="6t 3 4"
WAN_PORTS="6t 0"
BATMAN_PORTS="6t 1 2"
WANDEV=switch0
SWITCHDEV=switch0
CLIENT_PORTS="eth3 eth4"
WAN_PORTS="eth0"
BATMAN_PORTS="eth1 eth2"
DSA=1
ROUTERMAC=$(cat /sys/class/net/eth0/address)

View File

@ -1,9 +1,10 @@
. /lib/functions/fff/network
WANDEV=eth0
SWITCHDEV=eth0
CLIENT_PORTS="6t 3 4"
WAN_PORTS="6t 0"
BATMAN_PORTS="6t 1 2"
WANDEV=switch0
SWITCHDEV=switch0
CLIENT_PORTS="eth3 eth4 eth5"
WAN_PORTS="eth0"
BATMAN_PORTS="eth1 eth2"
DSA=1
ROUTERMAC=$(cat /sys/class/net/eth0/address)