[systemd-devel] Updating network file during boot

Henti Smith henti at gaydonsmith.co.uk
Thu Aug 22 08:45:12 UTC 2024


On Wed, 21 Aug 2024 at 17:12, Lennart Poettering <lennart at poettering.net>
wrote:

> On Mi, 21.08.24 16:57, Henti Smith (henti at gaydonsmith.co.uk) wrote:
>
> > After adding some more network devices to udev this way I now have the
> same
> > udev configuration working intermittently and I'm not sure why.
>
> You are probably racing against the usual rename logic via .link
> devices if you rename via udev rules. You need to disable the policy
> via a .link file.
>
> Honestly, I'd really avoid mixing rename via udev rules and rename via
> .link files. I'd stick to .link files for this, really.
>

Good morning Lennart,

This is what I suspected as well. I started this thread to try to resolve
the network device naming issue using only .link files, but this did not
seem possible, and the udev solution worked, at least for some of the
network cards.

The core problem is that the PCIe path changes when the Debug Board is
plugged into the hotplug PCIe port.

For example, here is the device PCI addressing without the board plugged in
(using hard coded link files):

    E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/0000:01:00.0/net/eno1
    E: DEVPATH=/devices/pci0000:00/0000:00:10.0/0000:04:00.0/net/mvc-sw1
    E: DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:05:00.0/net/mvc-sw2

And with the Debug Board plugged in (using hard coded link files):

    E: DEVPATH=/devices/pci0000:00/0000:00:0c.0/0000:01:00.0/net/debug1
    E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/0000:02:00.0/net/eno1
    E: DEVPATH=/devices/pci0000:00/0000:00:10.0/0000:05:00.0/net/mvc-sw1
    E: DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:06:00.0/net/mvc-sw2

As you can see, the PCI device address changes, but the PCI bus number does
not. When using the "Path" property, which utilizes ID_PATH, I cannot match
the PCI bus number.

Silvio suggested that I could match on any output from udevadm info, and
after reading the systemd.link man page, I found the Property= directive,
which states:

    "A whitespace-separated list of udev property names with their values
after the equals sign ("="). If multiple properties are specified, the test
results are ANDed. If the list is prefixed with a "!", the test is
inverted."

I attempted to match the network devices using Property= as follows (using
debug1 as an example):

# Fixed name for debug1 (Debug Board)
[Match]
Property=Path=pci-0000:01:00.0 ID_NET_DRIVER=igb

[Link]
Name=debug1

However, this did not work as expected, and the device was configured with
/usr/lib/systemd/network/99-default.link instead:

udevadm info /sys/class/net/enp1s0
P: /devices/pci0000:00/0000:00:0c.0/0000:01:00.0/net/enp1s0
L: 0
E: DEVPATH=/devices/pci0000:00/0000:00:0c.0/0000:01:00.0/net/enp1s0
E: INTERFACE=enp1s0
E: IFINDEX=2
E: SUBSYSTEM=net
E: USEC_INITIALIZED=4788144
E: ID_NET_NAMING_SCHEME=v245
E: ID_NET_NAME_MAC=enx00a0c9000000
E: ID_OUI_FROM_DATABASE=Intel Corporation
E: ID_NET_NAME_PATH=enp1s0
E: ID_BUS=pci
E: ID_VENDOR_ID=0x8086
E: ID_MODEL_ID=0x1533
E: ID_PCI_CLASS_FROM_DATABASE=Network controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: ID_MODEL_FROM_DATABASE=I210 Gigabit Network Connection
E: ID_PATH=pci-0000:01:00.0
E: ID_PATH_TAG=pci-0000_01_00_0
E: ID_NET_DRIVER=igb
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/enp1s0
E: TAGS=:systemd:

Andrei asked if the PCI bus addresses change, which I confirmed do not. He
then suggested I use udev.

I would prefer to use .link files to manage the interfaces; however, I
cannot seem to find the correct configuration to do this with changing PCI
addresses, but constant PCI bus addresses.

Using Property= seemed the most likely solution, as I could create a
configuration for all devices in both states, and only the current hardware
state would then be applied correctly, resulting in the correct
configuration for that hardware state. But as I indicated above, using
Property= to match the Path and ID_NET_DRIVER did not appear to work.

Could you, or anybody else, please look over the thread and the information
I have provided and provide guidance on how to proceed to be able to
configure the network devices in both hardware states with only .link files.

Kind regards
Henti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20240822/cb50ecf7/attachment.htm>


More information about the systemd-devel mailing list