From 13937a16d40693df67d3d39faa3a80644bdb7abf Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Fri, 30 Aug 2019 22:41:18 +0200
Subject: [PATCH] ramips: fix network setup for various NETGEAR boards

There are currently the following issues present for the Netgear R6220,
R6350 and WNDR3700 v5:

 - LAN and WAN MAC-addresses are inverted
 - WAN MAC-address is off. It are +2 compared to the LAN MAC-address
   (R6350 only)
 - Switchport order is inverted in LuCi

This commit fixes both these issues by assigning correct MAC-addresses
to LAN and WAN interfaces and defining the switchports with the correct
labels.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 .../ramips/base-files/etc/board.d/02_network    | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index 27f85d7458..2fd7b07bd7 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -66,9 +66,6 @@ ramips_setup_interfaces()
 	mercury,mac1200r-v2|\
 	mqmaker,witi|\
 	mtc,wr1201|\
-	netgear,r6220|\
-	netgear,r6350|\
-	netgear,wndr3700-v5|\
 	netis,wf-2881|\
 	nixcore,x1-16m|\
 	nixcore,x1-8m|\
@@ -396,7 +393,10 @@ ramips_setup_interfaces()
 		ucidef_add_switch "switch0" \
 			"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
 		;;
-	netgear,r6120)
+	netgear,r6120|\
+	netgear,r6220|\
+	netgear,r6350|\
+	netgear,wndr3700-v5)
 		ucidef_add_switch "switch0" \
 			"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
 		;;
@@ -592,7 +592,8 @@ ramips_setup_macs()
 	edimax,br-6475nd)
 		wan_mac=$(mtd_get_mac_binary devdata 0x7)
 		;;
-	edimax,br-6478ac-v2)
+	edimax,br-6478ac-v2|\
+	netgear,r6350)
 		wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
 		;;
 	elecom,wrc-1167ghbk2-s|\
@@ -640,12 +641,6 @@ ramips_setup_macs()
 		lan_mac=$(mtd_get_mac_binary factory_info 0xd)
 		wan_mac=$(macaddr_add "$lan_mac" 1)
 		;;
-	netgear,r6220|\
-	netgear,r6350|\
-	netgear,wndr3700-v5)
-		wan_mac=$(mtd_get_mac_binary factory 0x4)
-		lan_mac=$(macaddr_add "$wan_mac" 1)
-		;;
 	ohyeah,oy-0001|\
 	phicomm,k2g|\
 	skylab,skw92a)
-- 
2.30.2