udev-builtin-net_id: ignore firmware_node/sun == 0

Since ID_NET_NAME_SLOT was introduced we ignore slot == 0
https://github.com/systemd/systemd/blob/0035597a30d120f70df2dd7da3d6128fb8ba6051/src/udev/udev-builtin-net_id.c#L139

Qemu sets _SUN to PCI_SLOT() for all NICs, so _SUN is not unique.
https://gitlab.com/qemu-project/qemu/-/issues/2530

In my tests with libvirt I can only set 'slot="0x00"' in interface definition,
so all NICs end up with _SUN == 0, and this commit is enough to avoid the issue.

Fixes 0a4ecc54cb
This commit is contained in:
Etienne Champetier
2024-08-23 09:30:49 +09:00
committed by Yu Watanabe
parent b6b9ddb2b5
commit 448f9f81fd
+5 -1
View File
@@ -577,10 +577,14 @@ static int get_device_firmware_node_sun(sd_device *dev, uint32_t *ret) {
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to read firmware_node/sun, ignoring: %m");
r = safe_atou32(attr, ret);
uint32_t sun;
r = safe_atou32(attr, &sun);
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to parse firmware_node/sun '%s', ignoring: %m", attr);
if (sun == 0)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL), "firmware_node/sun == 0, ignoring: %m");
*ret = sun;
return 0;
}