aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2017-02-01 16:45:19 +0100
committerRafał Miłecki <rafal@milecki.pl>2017-02-03 07:50:59 +0100
commit50efd403e67c6195a057417f8a2436d189c8dc81 (patch)
treef41ea4e880635291b528e549ebd9c2f54c9c57e3 /target/linux/bcm53xx
parenta4d12aed304937560c6ef8def9e478e4ee102a4f (diff)
downloadupstream-50efd403e67c6195a057417f8a2436d189c8dc81.tar.gz
upstream-50efd403e67c6195a057417f8a2436d189c8dc81.tar.bz2
upstream-50efd403e67c6195a057417f8a2436d189c8dc81.zip
bcm53xx: set WAN MAC address to don't share one with LAN interface
After analyzing numerous NVRAMs and vendor firmwares it seems the base MAC address is used for LAN interface. WAN interface has different one which sometimes is set directly in NVRAM and sometines needs to be calculated. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'target/linux/bcm53xx')
-rwxr-xr-xtarget/linux/bcm53xx/base-files/etc/board.d/02_network11
1 files changed, 10 insertions, 1 deletions
diff --git a/target/linux/bcm53xx/base-files/etc/board.d/02_network b/target/linux/bcm53xx/base-files/etc/board.d/02_network
index 0a055f4d1f..fa2837cba2 100755
--- a/target/linux/bcm53xx/base-files/etc/board.d/02_network
+++ b/target/linux/bcm53xx/base-files/etc/board.d/02_network
@@ -25,22 +25,28 @@ buffalo,wzr-1750dhp)
;;
esac
+wan_macaddr="$(nvram get wan_hwaddr)"
case "$board" in
asus,rt-ac87u)
ifname=eth1
+ etXmacaddr=$(nvram get et1macaddr)
;;
dlink,dir-885l | \
netgear,r7900 | \
netgear,r8000 | \
netgear,r8500)
-
ifname=eth2
+ etXmacaddr=$(nvram get et2macaddr)
;;
*)
ifname=eth0
+ etXmacaddr=$(nvram get et0macaddr)
;;
esac
+# If WAN MAC isn't explicitly set, calculate it using base MAC as reference.
+[ -z "$wan_macaddr" -a -n "$etXmacaddr" ] && wan_macaddr=$(macaddr_add "$etXmacaddr" 1)
+
# Workaround for devices using eth2 connected to (CPU) switch port 8
case "$board" in
dlink,dir-885l | \
@@ -55,6 +61,7 @@ netgear,r8500)
# assigned. Manually assign eth2's MAC to the LAN.
et2macaddr="$(nvram get et2macaddr)"
[ -n "$et2macaddr" ] && ucidef_set_interface_macaddr "lan" "$et2macaddr"
+ [ -n "$wan_macaddr" ] && ucidef_set_interface_macaddr "wan" "$wan_macaddr"
board_config_flush
exit 0
@@ -85,6 +92,8 @@ else
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@$ifname"
fi
+[ -n "$wan_macaddr" ] && ucidef_set_interface_macaddr "wan" "$wan_macaddr"
+
board_config_flush
exit 0