firmware/src/packages/fff/fff-layer3-config/files/etc/layer3.d/30-network-client
Fabian Bläse 15d259b98a 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>
2021-08-05 17:49:39 +02:00

72 lines
1.8 KiB
Plaintext

# load board specific properties
BOARD="$(uci get board.model.name)"
. /etc/network.$BOARD
configure() {
# ipaddr
#remove old ipaddr
uci -q del network.client.ipaddr
#set new ipaddr
if ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
for ip in $ipaddr; do
uci add_list network.client.ipaddr=$ip
done
else
echo "WARNING: No client ipaddr set!"
fi
#put interface routes from set addresses into fff table
uci set network.client.ip4table='fff'
# ip6addr
#remove old ip6addr
for ip in $(uci get network.client.ip6addr); do
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
uci del_list network.client.ip6addr="$ip"
fi
done
#set new ip6addr
if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
for ip in $ip6addr; do
uci add_list network.client.ip6addr=$ip
done
else
echo "WARNING: No client ip6addr set!"
fi
#put interface routes from set addresses into fff table
uci set network.client.ip6table='fff'
# dhcp
uci -q del dhcp.client.start
uci -q del dhcp.client.limit
if dhcp_start=$(uci -q get gateway.@client[0].dhcp_start); then
uci set dhcp.client=dhcp
uci set dhcp.client.interface=client
uci set dhcp.client.start=$dhcp_start
uci set dhcp.client.limit=$(uci -q get gateway.@client[0].dhcp_limit)
else
echo "WARNING: No DHCP range start and/or limit set!"
fi
# set interface
#remove all eth interfaces
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
uci set network.client.ifname="$iface $ifaces"
else
echo "WARNING: No Interface for client specified"
fi
}
apply() {
uci commit network
uci commit dhcp
}
revert() {
uci revert network
uci revert dhcp
}