mvebu: add linux 4.9 support
[openwrt/openwrt.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 . /lib/mvebu.sh
11
12 case $(mvebu_board_name) in
13 armada-xp-linksys-mamba)
14 mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
15 ifconfig eth0 hw ether $mac 2>/dev/null
16 ifconfig eth1 hw ether $mac 2>/dev/null
17 ;;
18 armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-rango|armada-385-linksys-shelby)
19 # rename interfaces back to the way they were with 4.4
20 case "$(readlink /sys/class/net/eth0)" in
21 *f1070000*)
22 ip link set eth0 name tmp0
23 ip link set eth1 name eth0
24 ip link set tmp0 name eth1
25 ;;
26 esac
27
28 mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
29 mac_wan=$(macaddr_setbit_la "$mac")
30 ifconfig eth1 hw ether $mac 2>/dev/null
31 ifconfig eth0 hw ether $mac_wan 2>/dev/null
32 ;;
33 armada-385-db-ap|armada-388-clearfog)
34 # rename interfaces back to the way they were with 4.4
35 case "$(readlink /sys/class/net/eth0)" in
36 *f1070000*)
37 ip link set eth0 name tmp0
38 ip link set eth1 name eth0
39 ip link set eth2 name eth1
40 ip link set tmp0 name eth2
41 ;;
42 esac
43 ;;
44 esac
45 }
46
47 boot_hook_add preinit_main preinit_set_mac_address