I am trying to setup the ethernet interface of an embedded device to run with e.g. 10 MBit/s / half-duplex.
Since the system uses systemd (systemd-networkd) for configuring network devices, the usual way might be to define a proper .link file, which I tried:
/lib/systemd/network/20-eth0.link:
[Match]
Name=eth0
[Link]
MTUBytes=1450
BitsPerSecond=10M
Duplex=half
Calling udevadm info /sys/class/net/eth0
tells me that the link file was loaded and even the MTU value was properly adopted.
But neither speed nor duplex mode was changed - ethtool eth0
outputs:
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: Symmetric
Link partner advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Link detected: yes
I also tried so set the values within an udev rule right away:
/lib/udev/rules.d/10-persistent-network.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", ATTR{speed}="10", ATTR{duplex}="half", ATTR{mtu}="1400"
which brings me to the same result: MTU value is adopted but neither speed nor duplex mode
On the other hand it is no problem to manually set these attributes using ethtool -s eth0 speed 10 duplex half
My suggestion is that somehow the driver loads the default values afterwards since one of the last messages of dmesg
after startup says:
xilinx_axienet xilinx_axienet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
But I am not sure if this really overwrites my settings or that the settings were not taken at all (because they are set somewhere else with higher precedence e.g.)
Thanks for any advice
I finally figured it out - systemctl status systemd-udevd
gave me the first needed hint.
First, Name
is no valid Match
option value for .link but it is for .network - it was still loaded for the ethernet device though.
The more interesting information was that udevd
complained about invalid arguments for setting speed/duplex which guided me to this related question where a bug in systemd
prevents the configuration of speed/duplex mode via .link file.This bug was fixed with version v237
The funny thing now is that it even did not work when running v237
because v237
has another bug preventing this approach. So I recommend to update to at least v239
to have both bugs fixed.
And if someone else also needs to patch an older version of systemd
here are the 2 related bugs: