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

The bridge does not inherit the MAC address of the NIC. #25555

Closed
daiaji opened this issue Nov 29, 2022 · 11 comments
Closed

The bridge does not inherit the MAC address of the NIC. #25555

daiaji opened this issue Nov 29, 2022 · 11 comments

Comments

@daiaji
Copy link

daiaji commented Nov 29, 2022

systemd version the issue has been seen with

systemd 252 (252.2-1-manjaro)

Used distribution

manjaro 22.0.0

Linux kernel version used

6.0.10-1-MANJARO

CPU architectures issue was seen on

x86_64

Component

systemd-networkd

Expected behaviour you didn't see

The bridge inherits the MAC address of the NIC.

Unexpected behaviour you saw

The bridge does not inherit the MAC address of the NIC.

Steps to reproduce the problem

cat /etc/systemd/network/98-bridge-inherit-mac.link
[Match]
Type=bridge

[Link]
MACAddressPolicy=none

cat /etc/systemd/network/99-default.link 
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
AlternativeNamesPolicy=database onboard slot path
MACAddressPolicy=persistent
WakeOnLan=magic

cat /etc/systemd/network/br0_bind.network 
[Match]
Name=enp39s0

[Network]
Bridge=br0

cat /etc/systemd/network/br0.netdev 
[NetDev]
Name=br0
Kind=bridge

cat /etc/systemd/network/br0.network 
[Match]
Name=br0

[Network]
DHCP=yes
MulticastDNS=true
IPv6Token=prefixstable
IPv6PrivacyExtensions=prefer-public
ip a
2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 66:df:dc:xx:xx:xx brd ff:ff:ff:ff:ff:ff
4: enp39s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether 00:d8:61:xx:xx:xx brd ff:ff:ff:ff:ff:ff

sudo SYSTEMD_LOG_LEVEL=debug udevadm test-builtin net_setup_link /sys/class/net/br0
Trying to open "/etc/systemd/hwdb/hwdb.bin"...
Trying to open "/etc/udev/hwdb.bin"...
Trying to open "/usr/lib/systemd/hwdb/hwdb.bin"...
Trying to open "/usr/lib/udev/hwdb.bin"...
=== trie on-disk ===
tool version:          252
file size:        12223125 bytes
header size             80 bytes
strings            2479237 bytes
nodes              9743808 bytes
Loading kernel module index.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Using default interface naming scheme 'v252'.
Skipping overridden file '/usr/lib/systemd/network/99-default.link'.
Parsed configuration file "/etc/systemd/network/99-default.link"
Parsed configuration file "/etc/systemd/network/98-bridge-inherit-mac.link"
Created link configuration context.
br0: Device has name_assign_type=3
br0: Device has addr_assign_type=3
ID_NET_DRIVER=bridge
br0: Config file /etc/systemd/network/98-bridge-inherit-mac.link is applied
br0: Using static MAC address.
br0: Policies didn't yield a name and Name= is not given, not renaming.
ID_NET_LINK_FILE=/etc/systemd/network/98-bridge-inherit-mac.link
ID_NET_NAME=br0
Unload kernel module index.
Unloaded link configuration context.

Additional program output to the terminal or log subsystem illustrating the issue

systemd-networkd:

https://gist.github.com/daiaji/8a250930632ce9a8a184e2617451dd40

I checked some configuration instructions. It seems that there should be no problem with the configuration, and I tried to change the kernel version, which seems to be useless.

@daiaji daiaji added the bug 🐛 Programming errors, that need preferential fixing label Nov 29, 2022
@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

Ah, please try to set MACAddress=none in the .netdev file.

It is introduced by aaa5ca5 (v250).

@yuwata yuwata added the needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer label Nov 29, 2022
@daiaji
Copy link
Author

daiaji commented Nov 29, 2022

cat /etc/systemd/network/br0.netdev
[NetDev]
Name=br0
Kind=bridge

[Link]
MACAddress=none

It doesn't seem to be of much use.
The IP address has not changed.

@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

It must be in [NetDev] section.

@daiaji
Copy link
Author

daiaji commented Nov 29, 2022

OK,After this configuration, the bridge inherits the mac address of the NIC.

Also, I have two NICs, and sometimes I need to use wildcards to create bridges for these two NICs, so how do I decide which NIC's MAC address the bridge inherits?

@arvidjaar
Copy link
Contributor

how do I decide which NIC's MAC address the bridge inherits?

If it is left to the kernel, kernel selects the lowest MAC address among slave interfaces. I do not think you can change it.

@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

OK,After this configuration, the bridge inherits the mac address of the NIC.

Nice.

Also, I have two NICs, and sometimes I need to use wildcards to create bridges for these two NICs, so how do I decide which NIC's MAC address the bridge inherits?

If networkd and udevd do not set MAC address for the interface, then the kernel controls it. There is no way we can do in that case, at least now.If you have any suggestions, then please open a new RFE, or submit as a PR.

Anyway, the original issue(?) is resolved. Closing.

@yuwata yuwata closed this as completed Nov 29, 2022
@yuwata yuwata added already-implemented and removed bug 🐛 Programming errors, that need preferential fixing needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Nov 29, 2022
@daiaji
Copy link
Author

daiaji commented Nov 29, 2022

Well, then an RFE should indeed be initiated.

@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

Though, I have no idea about how to implement. Do you?

@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

Note, there is already a similar RFE #21577.

@daiaji
Copy link
Author

daiaji commented Nov 29, 2022

Although it may seem inelegant to hardcode NIC names into configuration files, an option should be provided that specifies that the bridge inherits the MAC address of a particular NIC name.

@yuwata
Copy link
Member

yuwata commented Nov 29, 2022

Sorry, I cannot follow. Could you elaborate more?
BTW, I think it is better to discuss at the RFE page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants