2019-05-13 23:30:48 +02:00
|
|
|
# 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"
|
2020-04-17 15:51:48 +02:00
|
|
|
local ports="$(uci -q get gateway.$vlan.ports)"
|
2019-05-13 23:30:48 +02:00
|
|
|
local name="$SWITCHDEV"_$vlan
|
|
|
|
|
|
|
|
uci set network.$name='switch_vlan'
|
|
|
|
uci set network.$name.device="$(uci get network.$SWITCHDEV.name)"
|
|
|
|
uci set network.$name.vlan="$vlan"
|
2020-09-19 02:00:02 +02:00
|
|
|
uci set network.$name.ports="$(get_cpu_port) $ports"
|
2019-05-13 23:30:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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_load gateway
|
|
|
|
config_foreach add_vlan vlan
|
|
|
|
}
|
|
|
|
|
|
|
|
apply() {
|
|
|
|
uci commit network
|
|
|
|
}
|
|
|
|
|
|
|
|
revert() {
|
|
|
|
uci revert network
|
|
|
|
}
|