forked from freifunk-franken/firmware
Fabian Bläse
15d259b98a
Starting with OpenWrt 21.02 some devices now use upstream kernel drivers for the built-in switch instead of relying on OpenWrt's swconfig driver. The upstream kernel drivers use the Distributed Switch Architecture (DSA) for configuration of the switch. Instead of explicitly configuring the hardware switch, all ports appear as distinct interfaces and linux bridges are offloaded to the hardware switch if possible. To keep changes small, this patch adds support for DSA devices by setting up a linux bridge, which is then treated just like the cpuport-interface of the swconfig driver. Signed-off-by: Fabian Bläse <fabian@blaese.de> Tested-by: Fabian Bläse <fabian@blaese.de>
55 lines
1.1 KiB
Plaintext
55 lines
1.1 KiB
Plaintext
# load uci functions
|
|
. /lib/functions.sh
|
|
|
|
# load board specific properties
|
|
BOARD="$(uci get board.model.name)"
|
|
. /etc/network.$BOARD
|
|
. /lib/functions/fff/cpuport
|
|
|
|
|
|
configure() {
|
|
add_vlan() {
|
|
local vlan="$1"
|
|
local ports="$(uci -q get gateway.$vlan.ports)"
|
|
local name="$SWITCHDEV"_$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"
|
|
}
|
|
|
|
remove_vlan() {
|
|
local name="$1"
|
|
|
|
local switchdev=$(echo $name | cut -d_ -f1)
|
|
local vlan=$(echo $name | cut -d_ -f2)
|
|
|
|
# only remove vlans not present in gateway config
|
|
if ! uci -q get gateway.$vlan > /dev/null; then
|
|
# remove switch_vlan
|
|
uci del network.$name
|
|
fi
|
|
}
|
|
|
|
config_load network
|
|
config_foreach remove_vlan switch_vlan
|
|
config_foreach remove_vlan bridge-vlan
|
|
|
|
config_load gateway
|
|
config_foreach add_vlan vlan
|
|
}
|
|
|
|
apply() {
|
|
uci commit network
|
|
}
|
|
|
|
revert() {
|
|
uci revert network
|
|
}
|