From 240a506ee77c6f22a9d99545e617523e4b128d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= Date: Tue, 22 Mar 2022 22:25:51 +0100 Subject: [PATCH] fff-network: convert GL-AR150 to TWOPORT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GL-AR150 has two ethernet ports. One of them is connected directly to the CPU (labeled "WAN"), while the other one (labeled "LAN") is connected to the internal switch of the AR9330 platform. Previously, this device had its own codepath in configurenetwork, utilizing the ETHPORT variable, so the single physical port of the switch could be connected to either the CLIENT or BATMAN vlan of the SWITCHPORT. When adding support for TWO_PORT devices, this codepath was accidentally removed, so the LAN-Port was not configured anymore. Configuring the internal switch is not necessary when only a single physical port ist connected to it. Instead, leave the switch unconfigured, so it behaves like an unmanaged vlan-transparent switch. As we support TWO_PORT devices now, utilize the TWO_PORT codepath (instead of the ONE_PORT codepath, which would be equivalent to the old behaviour) to make both ports configureable. To retain the previously configured mode of the LAN-Port, migrate ETHPORT to LAN1MODE before executing configurenetwork. Fixes: #222 Fixes: c22032e25430 ("fff-network: support native two-port devices") Signed-off-by: Fabian Bläse Tested-by: Sebastian Beck --- .../files/etc/uci-defaults/20-migrate-gl-ar150 | 12 ++++++++++++ .../fff/fff-network/mips/network.glinet,gl-ar150 | 6 +----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 src/packages/fff/fff-network/files/etc/uci-defaults/20-migrate-gl-ar150 diff --git a/src/packages/fff/fff-network/files/etc/uci-defaults/20-migrate-gl-ar150 b/src/packages/fff/fff-network/files/etc/uci-defaults/20-migrate-gl-ar150 new file mode 100644 index 00000000..fd7e731d --- /dev/null +++ b/src/packages/fff/fff-network/files/etc/uci-defaults/20-migrate-gl-ar150 @@ -0,0 +1,12 @@ +# The GL-AR150 was converted from ONEPORT to TWOPORT. +# Copy ETHMODE to LAN1MODE ("LAN"-Port) and set LAN0MODE ("WAN"-Port) to WAN to retain the configured behaviour for upgraded devices. +if [ -s /etc/network.config ] ; then + . /etc/network.config + + # Ensure ETHMODE contains a sensible value. Use default behaviour (CLIENT) otherwise. + [ "$ETHMODE" != "BATMAN" ] && [ "$ETHMODE" != "CLIENT" ] && [ "$ETHMODE" != "WAN" ] && ETHMODE="CLIENT" + + echo "LAN0MODE='WAN' # use BATMAN, CLIENT or WAN" > /etc/network.config + echo "LAN1MODE='$ETHMODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config + echo "FORCEPARSE='2' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config +fi diff --git a/src/packages/fff/fff-network/mips/network.glinet,gl-ar150 b/src/packages/fff/fff-network/mips/network.glinet,gl-ar150 index 1782d4ea..d88673c1 100644 --- a/src/packages/fff/fff-network/mips/network.glinet,gl-ar150 +++ b/src/packages/fff/fff-network/mips/network.glinet,gl-ar150 @@ -2,12 +2,8 @@ WANDEV=eth1 SWITCHDEV=eth0 -WAN_PORTS= -BATMAN_PORTS="0t" -CLIENT_PORTS="0t" +TWO_PORT=YES ETHMESHMAC="$(macFlipLocalBit $(cat /sys/class/net/eth0/address))" . /etc/network.mode - -ETHPORT=1