From 0bbcc75b1ef44b16e4ba2dcaba6a079161808698 Mon Sep 17 00:00:00 2001 From: Sukru Senli Date: Sat, 10 Feb 2018 12:15:31 +0100 Subject: [PATCH] layer2interface: populate wan ifname with various norhbound interfaces --- .../uci-defaults/20-layer2-config-generate | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/layer2interface/broadcom/etc/uci-defaults/20-layer2-config-generate b/layer2interface/broadcom/etc/uci-defaults/20-layer2-config-generate index adcd48f97..feee48505 100644 --- a/layer2interface/broadcom/etc/uci-defaults/20-layer2-config-generate +++ b/layer2interface/broadcom/etc/uci-defaults/20-layer2-config-generate @@ -10,14 +10,14 @@ LANPORTS="$(db -q get hw.board.ethernetLanPorts)" ETHDEV="" PTMDEV="" ATMDEV="" -WANIFACE="" +WANDEV="" +WANIFNAME="" device_config_exists() { ubus call uci get '{"config":"network","type":"device"}' | grep -w name | grep -qw "$1" && return 0 return 1 } - populate_dsl_settings() { if [ "$hasAdsl" == "0" -a "$hasVdsl" == "0" ]; then rm -f /etc/config/dsl @@ -88,14 +88,16 @@ populate_atm_device() { ATMDEV="${ATMDEV:-atm0}" - WANIFACE="$ATMDEV.1" + WANDEV="$ATMDEV.1" - device_config_exists "$WANIFACE" && return + WANIFNAME="$WANIFNAME $WANDEV" + + device_config_exists "$WANDEV" && return uci -q set network.atmwan=device uci -q set network.atmwan.type=untagged uci -q set network.atmwan.ifname="$ATMDEV" - uci -q set network.atmwan.name="$WANIFACE" + uci -q set network.atmwan.name="$WANDEV" } populate_ptm_device() { @@ -115,14 +117,16 @@ populate_ptm_device() { PTMDEV="${PTMDEV:-ptm0}" - WANIFACE="$PTMDEV.1" + WANDEV="$PTMDEV.1" + + WANIFNAME="$WANIFNAME $WANDEV" device_config_exists "$PTMDEV" && return uci -q set network.ptmwan=device uci -q set network.ptmwan.type=untagged uci -q set network.ptmwan.ifname="$PTMDEV" - uci -q set network.ptmwan.name="$WANIFACE" + uci -q set network.ptmwan.name="$WANDEV" } populate_eth_device() { @@ -130,14 +134,16 @@ populate_eth_device() { ETHDEV="$(db -q get hw.board.ethernetWanPort)" - WANIFACE="$ETHDEV.1" + WANDEV="$ETHDEV.1" - device_config_exists "$WANIFACE" && return + WANIFNAME="$WANIFNAME $WANDEV" + + device_config_exists "$WANDEV" && return uci -q set network.ethwan=device uci -q set network.ethwan.type=untagged uci -q set network.ethwan.ifname="$ETHDEV" - uci -q set network.ethwan.name="$WANIFACE" + uci -q set network.ethwan.name="$WANDEV" } populate_network_config_ifnames() { @@ -149,14 +155,12 @@ populate_network_config_ifnames() { return } - WANTYPE="$(uci -q get network.wan.type)" - [ "$WANTYPE" == "anywan" ] && { - uci -q delete network.wan.type - uci -q set network.wan.ifname="$WANIFACE" + uci -q get network.wan.ifname >/dev/null || { + uci -q set network.wan.type="anywan" + WANIFNAME="$(echo $WANIFNAME | sed -e 's/^ *//')" + uci -q set network.wan.ifname="$WANIFNAME" } - uci -q get network.wan.ifname >/dev/null || uci -q set network.wan.ifname="$WANIFACE" - uci -q commit network }