Skip to content

ramips: Further improvements and fixes of MAC address setup#2319

Closed
adschm wants to merge 1 commit intoopenwrt:masterfrom
adschm:nodefaultcase
Closed

ramips: Further improvements and fixes of MAC address setup#2319
adschm wants to merge 1 commit intoopenwrt:masterfrom
adschm:nodefaultcase

Conversation

@adschm
Copy link
Copy Markdown
Member

@adschm adschm commented Aug 12, 2019

Based on recent device support discussion and fixes on ramips MAC address assignment, this patchset removes the misleading wan_mac default cases and fixes/tidies up several things after that.

Please refer to the individual commit description for further details.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 12, 2019

Despite what's addressed in the patches, I left some devices untouched which show strange setup:
onion,omega2 / onion,omega2p :
mtd-mac-address = <&factory 0x28>;
wan_mac=$(mtd_get_mac_binary factory 4)
lan_mac=$(mtd_get_mac_binary factory 46)

Three addresses are used (strange thing no. 1: why are lan AND wan different from &ethernet).
But the device is set up as one-port (strange thing no. 2):

		ucidef_add_switch "switch0"
		ucidef_add_switch_attr "switch0" "enable" "false"
		ucidef_set_interface_lan "eth0"

Multiple examples can be found for both cases.

@adschm adschm force-pushed the nodefaultcase branch 4 times, most recently from fd80236 to b20acb3 Compare August 14, 2019 21:57
@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 14, 2019

Rebased.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 16, 2019

@dangowrt
Hi, I'm currently reviewing the MAC address assignment on ramips target.
You added support for zbt-we1226 some while ago, and set &ethernet to <&factory 0x2e>, with WAN address just calculated by adding +1 to that.
However, there might be another MAC address stored on flash for the device in <&factory 0x28>.

Can you check that? If yes, I would also be interested in which of the two addresses should be "lan" and which "wan" then ...

@dangowrt
Copy link
Copy Markdown
Member

dangowrt commented Aug 16, 2019 via email

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 16, 2019

@pepe2k
Hi, I'm currently reviewing the MAC address assignment on ramips target.
You added support for ALFA Network AC1200RM some while ago, and set &ethernet to <&factory 0x28>, with WAN address just calculated by adding +1 to that.
However, there might be another MAC address stored on flash for the device in <&factory 0x2e>.

Can you check that? If yes, I would also be interested in which of the two addresses should be "lan" and which "wan" then ...

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 16, 2019

@pepe2k Same question for u7628-01-xxx devices.

@pepe2k pepe2k added the target/ramips pull request/issue for ramips target label Aug 16, 2019
@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 16, 2019

For later reference: Discussion about newifi devices can be found here: #2075 (comment)

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 17, 2019

Rebased.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Aug 31, 2019

@981213 @blocktrron
I do not think there will be a lot of additional feedback here, so have a look at this if you like.
It contains several fixes/improvements besides changing the default-case logic.

(Latest Update: Rebase and account for recently added devices)

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 1, 2019

@zorun
I'm currently looking into the MAC address assignment of several ramips devices (#2319).
Many of them just have the wan MAC address calculated although it is stored on flash.

As you happen to own a ZBT WE3526, can you check whether you have a MAC address in <&factory 0xe006> and whether it matches your wan (eth0.2) MAC address? If you could provide a hexdump of your factory partition, this would be even better ...

Copy link
Copy Markdown

@zorun zorun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when a device does not match any case? I.e. wan_mac / lan_mac is not defined?

Copy link
Copy Markdown

@zorun zorun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is really hard to review because you bundle several changes together... It's hard to check what is an actual change and what is just cosmetic or reordering, and whether any device was forgotten/lost in the change.

@zorun
Copy link
Copy Markdown

zorun commented Sep 1, 2019

@zorun
I'm currently looking into the MAC address assignment of several ramips devices (#2319).
Many of them just have the wan MAC address calculated although it is stored on flash.

As you happen to own a ZBT WE3526, can you check whether you have a MAC address in <&factory 0xe006> and whether it matches your wan (eth0.2) MAC address? If you could provide a hexdump of your factory partition, this would be even better ...

So, here it is:

  • MAC address on the label: 78:A3:51:30:18:F8
  • MAC address on eth0.1 (LAN): 78:A3:51:30:18:FA (with OpenWrt r10865-c3a78955f3)
  • MAC address on eth0.2 (WAN): 78:A3:51:30:18:FB (with OpenWrt r10865-c3a78955f3)

The data at 0xe000 is 78 a3 51 30 18 fa, and data at 0xe006 is 78 a3 51 30 18 fb.

Here are the MAC addresses I spotted in the factory partition:

  • 0x0004: 78 a3 51 30 18 f8 (the one from the label)
  • 0x8004: 78 a3 51 30 18 f9
  • 0xe000: 78 a3 51 30 18 fa
  • 0xe006: 78 a3 51 30 18 fb

So, either the label is wrong, or the current OpenWrt location is wrong.

Here is the full hexdump if you find it useful: https://paste.swordarmor.fr/Z3Xg

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 1, 2019

What happens when a device does not match any case? I.e. wan_mac / lan_mac is not defined?

@zorun

If set up at all, wan will be some ethY.2 and lan will be some ethX.1, where in most cases ethX and ethY will be eth0. So, ethX.1 will inherit the MAC address from ethX and ethY.2 will inherit the MAC address from ethY. If you set lan_mac or wan_mac, you overwrite this inherent MAC address.
That's why it makes no sense to set BOTH lan_mac and wan_mac, as then the address from eth0 will be completely unused. Also setting eth0.2 to eth0 address makes no sense here.
Note that you do only set the ethX.Z, not the lan/wan bridge/device directly ...

At the moment (without the patchset), if there is no specific definition for a device in 02_network, the default case will just set eth0 + 1 for it. This might be based on a frequent case, but I think it has several drawbacks, so my first patch here changes the default case to be what one would expect: no change to the MAC addresses if you do not set one.

The other patches then fix and enhance stuff. Note that some of those changes are only possible after the default case has been removed.

This patch is really hard to review because you bundle several changes together...

I have thought about that, but I doubt it will be easier with more patches after all. However, I think about giving more details in the commit message for the big patches ...

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 1, 2019

MAC address on eth0.2 (WAN): 78:A3:51:30:18:FB (with OpenWrt r10865-c3a78955f3)

0xe006: 78 a3 51 30 18 fb

Well, that's what I wanted to know. So, the wan address can actually be read from 0xe006 instead of calculating it.

So, either the label is wrong, or the current OpenWrt location is wrong.

0x0004 and 0x8004 are used for Wifi when reading caldata from 0x0000 and 0x8000, so everything looks correct there to me. Or are you referring to something else?

Thank you very much for the detailed information.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 2, 2019

Added we1326.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 5, 2019

Sent the following two patches to the list, as they are simple fixes and independent of the other changes here:

  • ramips: remove duplicate case for MAC setup of freestation5
  • ramips: fix duplicate network setup for dlink,dir-615-h1

@981213
Copy link
Copy Markdown
Member

981213 commented Sep 6, 2019

Hi! I'm a bit skeptical about this: ramips: remove default case for MAC address assignment

This is not desirable, as many device supporters will just not
care or know about this definition, so another MAC address will be
introduced by accident. In some cases the wan_mac is assigned
although it is not needed, in other cases even addresses not
dedicated to the device will be used

Those developers who are aware of this problem will add correct definition, and those who don't care will just add their device into the largest case anyway. In the end we just bloat 02_network a bit and still have to explicitly ask PR/patch authors to check mac address assignments when they use wan_mac = lan_mac + 1

BTW I'd be happy to merge the rest of this PR if you could move this commit down to the last one :)

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 6, 2019

@981213 Thanks for the response.

In the end we just bloat 02_network a bit and still have to explicitly ask PR/patch authors to check mac address assignments when they use wan_mac = lan_mac + 1

Well, that's part of what I want to achieve, since I have the feeling that almost nobody really cares about the MAC assignment. In this situation, I prefer that the event leading to another MAC address occupied requires more work than the event where nothing is changed.

But despite that, note that especially patch 2 here is based on having the default case removed:
With the default changed, I can remove entire blocks that do not set anything in patch 2. If the "old" default case remained, I would have to introduce a "do nothing" case into 02_network, just to prevent devices falling into the default and having wan set to lan+1 although that's not correct.
While this "do nothing" case might be considerably smaller that the lan+1 case, it still feels wrong to me to have an "empty" case where the default case does something different.
As already mentioned, this will have the counter-intuitive effect that removing a case will not result in having no MAC address changes, but in having just different address changes (lan+1).

So I'm still deeply convinced that having the default case swapped is the proper solution here.

BTW I'd be happy to merge the rest of this PR if you could move this commit down to the last one :)

Since this won't hurt too much, I will try to do that during the day. This will then introduce the "do nothing" case which will be removed again in the final patch. Maybe by that it will also become a little more obvious what my desire is in this context.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 6, 2019

@981213 I have changed patch order as requested (including the necessary adjustments).

Copy link
Copy Markdown
Member

@981213 981213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially merged into my staging tree at: https://git.openwrt.org/?p=openwrt/staging/981213.git
Just one more question before pushing:

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 7, 2019

Thanks for merge.
Rebased and updated the rest.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 7, 2019

@981213 I've backported the most important fixes and sent them to the list...

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 20, 2019

Rebased.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Sep 22, 2019

Change for youhua,wr1200js has been sent to list as separate patch.

@adschm adschm force-pushed the nodefaultcase branch 2 times, most recently from 5aa96a2 to 8e94499 Compare September 29, 2019 17:47
@adschm
Copy link
Copy Markdown
Member Author

adschm commented Oct 21, 2019

Rebased and adjusted due to unielec rename.

@adschm adschm added the work in progress pull request the author is still working on label Oct 31, 2019
So far, MAC address assignment in ramips has contained a default
case, which defined wan_mac = eth0 + 1 for _every_ device not
having an explicit case there.

This is not desirable, as many device supporters will just not
care or know about this definition, so another MAC address will be
introduced by accident. In some cases the wan_mac is assigned
although it is not needed, in other cases even addresses not
dedicated to the device will be used (e.g. wan_mac actually is
eth0 - 1, but during support nobody cared, so eth0 + 1 is used now,
which might actually belong to another device ...).

Thus, in this PR the former default case is converted to an
explicit case. This one comprises all devices not being accounted
for by other cases, reduced by those not having wan at all.
The big number of entries for this node might be another indication
that many of them wouldn't actually be there if there hadn't been
default wan_mac setup.

In exchange, the current "do nothing" case can be removed, as it
will be the new default case.

The devices being put in the newly created explicit case were
determined as follows:

1. Create a list of all devices based on the DTS files.

2. Remove all devices already having an explicit entry setting
   their address.

3. Remove all devices that only have lan set up in the first part
   of 02_network:

mt7620:
   - alfa-network,tube-e4g
   - asus,rp-n53
   - buffalo,wmr-300
   - comfast,cf-wr800n
   - edimax,ew-7476rpc
   - edimax,ew-7478ac
   - elecom,wrh-300cr
   - hnet,c108
   - kimax,u25awf-h1
   - kimax,u35wf
   - kingston,mlw221
   - kingston,mlwg2
   - microduino,microwrt
   - netgear,ex2700
   - netgear,ex3700
   - netgear,wn3000rp-v3
   - planex,cs-qr10
   - planex,mzk-ex300np
   - planex,mzk-ex750np
   - ravpower,wd03
   - sercomm,na930
   - yukai,bocco
   - zbtlink,zbt-cpe102
   - zbtlink,zbt-we1026-5g-16m
   - zte,q7

mt7621:
   - gnubee,gb-pc1
   - gnubee,gb-pc2
   - linksys,re6500
   - mikrotik,rbm11g
   - netgear,ex6150
   - thunder,timecloud
   - tplink,re350-v1
   - tplink,re650-v1

mt76x8:
   - alfa-network,awusfree1
   - d-team,pbr-d1
   - glinet,vixmini
   - vocore,vocore2-lite
   - tama,w06
   - tplink,tl-mr3020-v3
   - tplink,tl-wa801nd-v5
   - tplink,tl-wr802n-v4
   - tplink,tl-wr902ac-v3
   - vocore,vocore2
   - widora,neo-16m
   - widora,neo-32m

rt288x:
   - buffalo,wli-tx4-ag300n
   - dlink,dap-1522-a1

rt305x:
   - allnet,all0256n-4m
   - allnet,all0256n-8m
   - allnet,all5002
   - allnet,all5003
   - alphanetworks,asl26555-16m
   - alphanetworks,asl26555-8m
   - asus,wl-330n
   - aximcom,mr-102n
   - dlink,dcs-930
   - easyacc,wizard-8800
   - hame,mpr-a2
   - hootoo,ht-tm02
   - huawei,d105
   - intenso,memory2move
   - planex,mzk-dp150n
   - rt305x dlink,dcs-930l-b1
   - sparklan,wcr-150gn
   - tenda,3g150b
   - tenda,3g300m
   - tenda,w150m
   - trendnet,tew-638apb-v2
   - unbranded,a5-v11
   - vocore,vocore-16m
   - vocore,vocore-8m
   - wansview,ncs601w
   - zorlik,zl5900v2

rt3883:
   - loewe,wmdr-143n
   - omnima,hpm

4. Put the remaining devices in the new case.

Signed-off-by: Adrian Schmutzler <[email protected]>
@adschm
Copy link
Copy Markdown
Member Author

adschm commented Nov 3, 2019

@981213 I personally still think that the wan MAC assignment patch here would be an improvement.
I've rebased the patch onto the base-files split, so it is now distributed on the 6 new 02_network files.

Since you have been skeptical about it and justified your view, I want to give you the chance to veto on merging this patch before I push it.

@adschm
Copy link
Copy Markdown
Member Author

adschm commented Nov 6, 2019

I will merge this today.

@adschm adschm closed this Nov 6, 2019
@adschm adschm deleted the nodefaultcase branch November 6, 2019 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/ramips pull request/issue for ramips target work in progress pull request the author is still working on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants