mvebu: use device-tree board detection
[openwrt/staging/dedeckeh.git] / target / linux / mvebu / base-files / lib / preinit / 06_set_iface_mac
1 #
2 # Copyright (C) 2014-2015 OpenWrt.org
3 # Copyright (C) 2016 LEDE-Project.org
4 #
5
6 preinit_set_mac_address() {
7 local mac
8
9 . /lib/functions.sh
10
11 case $(board_name) in
12 linksys,caiman|linksys,cobra|linksys,rango|linksys,shelby|linksys,venom)
13 # rename interfaces back to the way they were with 4.4
14 case "$(readlink /sys/class/net/eth0)" in
15 *f1070000*)
16 ip link set eth0 name tmp0
17 ip link set eth1 name eth0
18 ip link set tmp0 name eth1
19 ;;
20 esac
21
22 mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
23 mac_wan=$(macaddr_setbit_la "$mac")
24 ip link set dev eth1 address $mac 2>/dev/null
25 ip link set dev eth0 address $mac_wan 2>/dev/null
26 ;;
27 linksys,mamba)
28 mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
29 ip link set dev eth0 address $mac 2>/dev/null
30 ip link set dev eth1 address $mac 2>/dev/null
31 ;;
32 marvell,a385-db-ap|solidrun,clearfog*a1)
33 # rename interfaces back to the way they were with 4.4
34 case "$(readlink /sys/class/net/eth0)" in
35 *f1070000*)
36 ip link set eth0 name tmp0
37 ip link set eth1 name eth0
38 ip link set eth2 name eth1
39 ip link set tmp0 name eth2
40 ;;
41 esac
42 ;;
43 esac
44 }
45
46 boot_hook_add preinit_main preinit_set_mac_address