2013.09.13. 12:57 keltezéssel, Sebastian Kemper írta:
> Hello list,
> 
> The current behavior is that all interfaces (LAN, WAN and Wifi0) get the
> first MAC address in the mac mtd assigned (Wifi1 gets the MAC address of
> the second MAC address plus 1).
> 
> Unfortunately the MAC address printed on the sticker on the bottom of
> the router (the second MAC address in the mac mtd) is not used at all.
> But for some use cases it appears to be vital that the printed MAC gets
> assigned.
> 
> For testing I installed D-Link's firmware 304b01 (latest). It handles
> MAC assignments the same way as OpenWrt does, except it assigns the
> printed MAC to the WAN interface.
> 
> So I tried to come up with a way to do the same in OpenWrt. As the WAN
> interface is a virtual interface there's no way to do this while loading
> the driver. For the same reason I couldn't use the existing code in
> lib/preinit, i.e. 05_set_iface_mac_ar71xx.
> 
> So I ended up with the following patch. Please consider it/tell me what
> you think. Thanks!
> 
> Signed-off-by: Sebastian Kemper <[email protected]>
> 
> diff -Nur 
> openwrt.orig/target/linux/ar71xx/base-files/etc/uci-defaults/02_network 
> openwrt.new/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
> --- openwrt.orig/target/linux/ar71xx/base-files/etc/uci-defaults/02_network   
> 2013-09-12 23:54:58.491543186 +0200
> +++ openwrt.new/target/linux/ar71xx/base-files/etc/uci-defaults/02_network    
> 2013-09-13 00:04:46.284856230 +0200
> @@ -5,6 +5,18 @@
>  
>  [ -e /etc/config/network ] && exit 0
>  
> +fetch_wan_mac_from_mtd() {
> +     local mtd_part=$1
> +     local wan_env=$2
> +     local mtd mac
> +
> +     mtd=$(grep $mtd_part /proc/mtd | cut -d: -f1)
> +     [ -z $mtd ] && return
> +
> +     mac=$(grep -m 1 $wan_env /dev/$mtd | cut -d= -f2)
> +     [ ! -z $mac ] && ucidef_set_interface_macaddr "wan" "$mac"
> +}
> +

We have a generic 'mtd_get_mac_ascii' function defined in 'lib/functions.sh'. It
should work on the DIR-825-C1 as well, please use that instead of a similar
local function.

-Gabor
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to