Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look up primary MAC address through board.json for LAN/WAN #2011

Merged
merged 4 commits into from
May 28, 2020

Conversation

neocturne
Copy link
Member

In #2008, some confusion was caused by the fact that eth0/eth1 MAC addresses can be overridden by board.json after Gluon's upgrade scripts run, making eth() return the wrong address.

Clean this up by always looking up logical interface names through board.json, thus avoiding future confusion.

@neocturne neocturne added 0. type: enhancement The changeset is an enhancement 5. needs: testing Testing of the changes is necessary 2. status: waiting-on-review Awaiting review from the assignee but also interested parties. labels May 6, 2020
neocturne added 4 commits May 8, 2020 19:55
- Replace misnamed, closure-returning sysfs() to a reusable read() function
- Rename eth() to netdev(), pass full interface name
- Rename board() to interface()
- Split reuable get_netdev_addr() out of netdev()
In most cases, board.json does not contain any MAC addresses; in this
case, the default MAC address of the underlying interface is to be used.
The netdev() lookup is confusing to use: whenever a interface does not
exist during boot (for example VLAN) or when the address is overridden
from board.json (which is not obvious at all), it will yield either no
address, or a different address than expected.

To avoid this confusion, using board.json-based interface() is
preferable. This converts all uses of netdev() to the corresponding
lan/wan lookups, except for the final fallback for eth0.
@neocturne neocturne force-pushed the board-json-addresses branch from e073b61 to e93dca7 Compare May 8, 2020 17:57
Copy link
Contributor

@mweinelt mweinelt left a comment

Choose a reason for hiding this comment

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

This looks very neat.

FWIW: I did not check whether the WAN/LAN mappings make sense.

@rotanid rotanid mentioned this pull request May 25, 2020
2 tasks
@mweinelt mweinelt added this to the 2020.2 milestone May 28, 2020
Copy link
Contributor

@mweinelt mweinelt left a comment

Choose a reason for hiding this comment

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

lgtm

@neocturne neocturne merged commit 20c7fd9 into master May 28, 2020
@neocturne neocturne deleted the board-json-addresses branch May 28, 2020 20:30
@rotanid rotanid removed the 2. status: waiting-on-review Awaiting review from the assignee but also interested parties. label May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. type: enhancement The changeset is an enhancement 5. needs: testing Testing of the changes is necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants