Message ID | 20200802175502.451663-4-fabian@blaese.de |
---|---|
State | Superseded |
Headers | show |
diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan new file mode 100644 index 0000000..aea0055 --- /dev/null +++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan @@ -0,0 +1,35 @@ +# load board specific properties +BOARD="$(uci get board.model.name)" +. /etc/network.$BOARD + + +configure() { + # set wan interface + if vlan=$(uci -q get gateway.@wan[0].vlan); then + uci set network.wan.ifname="${SWITCHDEV}.$vlan" + elif iface=$(uci -q get gateway.@wan[0].iface); then + uci set network.wan.ifname="$iface" + else + # transitional behaviour to migrate configurations without + # explicit WAN vlan/interface specification + + echo "WARNING: No interface for WAN specified. Setting WAN to vlan 2." + + if ! uci -q get gateway.@wan[0]; then + uci add gateway wan >/dev/null + fi + uci set gateway.@wan[0].vlan='2' + + uci set network.wan.ifname="${SWITCHDEV}.2" + fi +} + +apply() { + uci commit network + uci commit gateway +} + +revert() { + uci revert network + uci revert gateway +}
Reviewed-by: Christian Dresel <fff@chrisi01.de> On 02.08.20 19:55, Fabian Bläse wrote: > Allow setting WAN vlan/interface from gateway config. > A configuration without explicit definition of a WAN interface is > valid at the moment and results in the default vlan (2) being used. > > To maintain this behaviour this script sets the gateway config to vlan > 2 if no vlan/interface is for WAN specified. This behaviour is transitional and > will be removed in the future. > > Fixes: #143 > Signed-off-by: Fabian Bläse <fabian@blaese.de> > --- > .../files/etc/gateway.d/30-network-wan | 35 +++++++++++++++++++ > 1 file changed, 35 insertions(+) > create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan > > diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan > new file mode 100644 > index 0000000..aea0055 > --- /dev/null > +++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan > @@ -0,0 +1,35 @@ > +# load board specific properties > +BOARD="$(uci get board.model.name)" > +. /etc/network.$BOARD > + > + > +configure() { > + # set wan interface > + if vlan=$(uci -q get gateway.@wan[0].vlan); then > + uci set network.wan.ifname="${SWITCHDEV}.$vlan" > + elif iface=$(uci -q get gateway.@wan[0].iface); then > + uci set network.wan.ifname="$iface" > + else > + # transitional behaviour to migrate configurations without > + # explicit WAN vlan/interface specification > + > + echo "WARNING: No interface for WAN specified. Setting WAN to vlan 2." > + > + if ! uci -q get gateway.@wan[0]; then > + uci add gateway wan >/dev/null > + fi > + uci set gateway.@wan[0].vlan='2' > + > + uci set network.wan.ifname="${SWITCHDEV}.2" > + fi > +} > + > +apply() { > + uci commit network > + uci commit gateway > +} > + > +revert() { > + uci revert network > + uci revert gateway > +} >
Allow setting WAN vlan/interface from gateway config. A configuration without explicit definition of a WAN interface is valid at the moment and results in the default vlan (2) being used. To maintain this behaviour this script sets the gateway config to vlan 2 if no vlan/interface is for WAN specified. This behaviour is transitional and will be removed in the future. Fixes: #143 Signed-off-by: Fabian Bläse <fabian@blaese.de> --- .../files/etc/gateway.d/30-network-wan | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/30-network-wan