[LEDE-DEV] [PATCH v2 2/3] ipq806x: Add support for new device: tew827dru

Mathias Kresin dev at kresin.me
Sun Sep 11 01:52:43 PDT 2016


11.09.2016 06:07, J Mo:
>
>
> On 09/10/2016 06:36 PM, J Mo wrote:
>>>> diff --git
>>>> a/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
>>>> b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
>>>> new file mode 100644
>>>> index 0000000..b4ed225
>>>> --- /dev/null
>>>> +++ b/target/linux/ipq806x/base-files/lib/preinit/06_set_iface_mac
>>>> @@ -0,0 +1,23 @@
>>>> +#!/bin/sh
>>>> +#
>>>> +# Copyright (c) 2014 The Linux Foundation. All rights reserved.
>>>> +#
>>>> +
>>>> +set_ether_mac() {
>>>> +    . /lib/functions/uci-defaults.sh
>>>> +    . /lib/ipq806x.sh
>>>> +    . /lib/functions/system.sh
>>>> +
>>>> +    board=$(ipq806x_board_name)
>>>> +
>>>> +    case "$board" in
>>>> +    tew827dru)
>>>> +        # Set the correct ethernet MAC addresses per OEM intent.
>>>> +        ifconfig eth0 hw ether $(mtd_get_mac_ascii APPSBLENV
>>>> wan_mac) 2>/dev/null
>>>> +        ifconfig eth1 hw ether $(mtd_get_mac_ascii APPSBLENV
>>>> lan_mac) 2>/dev/null
>>>> +        ;;
>>>> +    esac
>>>> +
>>>> +}
>>>> +
>>>> +boot_hook_add preinit_main set_ether_mac
>>>
>>> Okay I guess I see what you are trying to do. But you doing it at the
>>> wrong place using the wrong functions. Please have a look at
>>> https://git.lede-project.org/?p=source.git;a=blob;f=target/linux/lantiq/base-files/etc/board.d/02_network
>>> to see how to set the mac addresses properly.
>>>
>>
>> Oh yea, that's much better.
>
> Nevermind, your method does not address the problem. This probably has
> to be done in preinit or at least before any subinterfaces are created.
>
> Other devices are already doing this, probably for the same reasons.

Which doesn't mean that it's correct what is done with other boards. 
It's the job of netifd to set mac addresses. Bypassing netifd for the 
network configuration is a no go for me.

>
> Right:
>
> root at lede:/# ifconfig -a | egrep -i hwadd
> br-lan    Link encap:Ethernet  HWaddr D8:EB:97:30:30:03
> eth0      Link encap:Ethernet  HWaddr D8:EB:97:30:30:03
> eth0.1    Link encap:Ethernet  HWaddr D8:EB:97:30:30:03
> eth1      Link encap:Ethernet  HWaddr D8:EB:97:30:30:04
> eth1.2    Link encap:Ethernet  HWaddr D8:EB:97:30:30:04
>
> Wrong:
>
> root at lede:/# ifconfig -a | egrep -i hwadd
> br-lan    Link encap:Ethernet  HWaddr D8:EB:97:30:30:03
> eth0      Link encap:Ethernet  HWaddr 00:03:7F:BA:DB:01
> eth0.1    Link encap:Ethernet  HWaddr D8:EB:97:30:30:03
> eth1      Link encap:Ethernet  HWaddr 00:03:7F:BA:DB:02
> eth1.2    Link encap:Ethernet  HWaddr D8:EB:97:30:30:04

Well, it is perfect fine. Your configured lan (br-lan) and wan (eth1.2) 
are using the configured mac addresses. The physical interfaces are 
having a random macs, which is fine since no package is send over these 
interface.

I mean having the correct mac address for the physical interfaces looks 
nice but isn't really required. Feel free to use tcpdump/wireshark to 
confirm that outgoing packages have the correct mac address.



More information about the Lede-dev mailing list