forked from freifunk-franken/firmware
fff-network: add support for DSA switch configuration
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>
This commit is contained in:
parent
c569a9a4b5
commit
15d259b98a
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-layer3-config
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=7
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-network
|
||||
PKG_RELEASE:=45
|
||||
PKG_RELEASE:=46
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -113,31 +113,54 @@ elif [ "$TWO_PORT" = "YES" ]; then
|
|||
else
|
||||
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" ] || [ -n "$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
|
||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||
|
||||
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" ] || [ -n "$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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user