[OpenWrt-Devel] [PATCH] ipq40xx: add label MAC address for FritzBox 4040

mail at adrianschmutzler.de mail at adrianschmutzler.de
Sun Sep 29 18:15:18 EDT 2019


Hello Christian,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Christian Lamparter
> Sent: Samstag, 28. September 2019 18:37
> To: openwrt-devel at lists.openwrt.org
> Cc: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> Subject: Re: [OpenWrt-Devel] [PATCH] ipq40xx: add label MAC address for
> FritzBox 4040
> 
> On Monday, September 23, 2019 4:31:38 PM CEST Adrian Schmutzler wrote:
> > This adds label MAC address for the AVM FritzBox 4040, the first
> > device in ipq40xx target.
> 
> I had to look this up a bit more, since my (broken) retail-unit Fritz!Box 4040
> does not have the MAC-Address on the sticker labeled as "MAC Address" (or
> something like that).
> Instead there is a "CWMP-Account" String/Number which displays the
> Address as a "part" of it.

I thought the MAC address was on the box, but I'm not really sure and don't have the box anymore.

> 
> Wouldn't it be better to just go with the "serial number" of the device in this
> case then?

I need a MAC address for certain use cases, like calculating local/ULA IPv6 addresses based on MAC address or EUI that will allow identifying the device in a network (Freifunk...). For that, it's convenient to exploit the fact the most vendors print a MAC address on the device. A serial number won't help me there. So, CWMP-Account will be the best I can get ATM.
Or are you pointing at something I don't see?

> 
> Going deeper: The patch that introduced ucidef_set_label_macaddr
> describes it as
> 
> |commit 469e347f19ce9eefdc16f421b8e1f18ed60c310c
> |Author: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> |Date:   Thu Aug 15 15:13:27 2019 +0200
> |
> |    base-files: provide option to specify label MAC address in board.d
> |
> |    For many devices, MAC addresses cannot be retrieved via the
> |    device tree alias.
> | [...]
> 
> ... This is somewhat strange in the context of the Fritz!Box 4040.
> This is because the extra u-boot we use for the Fritz!Box 4040 makes a real
> effort to patch the real mac-address into the device tree before handing it
> off to the kernel.
> 
> https://github.com/chunkeey/FritzBox-4040-
> UBOOT/blob/master/board/qcom/ipq40xx_cdp/ipq40xx_cdp.c#L455
> 
> So, everything should just "click" with this alias added.
> 
> 	label-mac-device = &gmac0;
> 
> Or does it not?

I tested this when I started the effort to add label-mac-address to OpenWrt several months ago.
Back then there was no MAC address in /proc/device-tree (using find /proc/device-tree -name "*mac-address")

I re-checked today and now there are local-mac-address entries for gmac0 and gmac1. So this must have been added recently?

Anyway, I will send a new patch adding label-mac-device as you suggested.

Best

Adrian

> 
> Cheers,
> Christian
> 
> > Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> > ---
> >  target/linux/ipq40xx/base-files/etc/board.d/02_network | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network
> > b/target/linux/ipq40xx/base-files/etc/board.d/02_network
> > index e5ba7260f3..082724ebfc 100755
> > --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network
> > +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network
> > @@ -77,6 +77,9 @@ ipq40xx_setup_macs()
> >  		wan_mac=$(mtd_get_mac_binary_ubi Factory 0x5006)
> >  		lan_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
> >  		;;
> > +	avm,fritzbox-4040)
> > +		label_mac=$(cat /sys/class/net/eth0/address)
> > +		;;
> >  	engenius,ens620ext)
> >  		wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
> >  		lan_mac=$(macaddr_add "$wan_mac" 1) @@ -89,6 +92,7
> @@
> > ipq40xx_setup_macs()
> >
> >  	[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
> >  	[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan"
> $wan_mac
> > +	[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
> >  }
> >
> >  board_config_update
> >
> 
> 
> 
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20190930/a6fe0121/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list