summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2018-03-15 10:42:38 -0700
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-03-16 02:42:38 +0900
commit8eebb6a9e5e74ec0ef40902e2da53d24559b94a4 (patch)
treeb59184f318f375f73189d48da26fd2d703bafa71 /src/udev
parent848e863acc51ecfb0f3955c498874588201d9130 (diff)
downloadsystemd-8eebb6a9e5e74ec0ef40902e2da53d24559b94a4.tar.gz
udev/net-id: Fix check for address to keep interface names stable (#8458)
This was a bug inadvertently added by commit 73fc96c8ac0aa9. The intent of the check is to "match slot address with device by stripping the function" (as the comment above states it), for example match network device PCI address 0000:05:00.0 (including a .0 for function) to PCI slot address 0000:05:00, but changing that to a streq() call prevented the match. Change that to startswith(), which should both fix the bug and make the intent of the check more clear and prevent unintentional bugs from being introduced by future refactorings.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-builtin-net_id.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index 36994360c7..6efa712930 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -297,7 +297,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
if (snprintf_ok(str, sizeof str, "%s/%s/address", slots, dent->d_name) &&
read_one_line_file(str, &address) >= 0)
/* match slot address with device by stripping the function */
- if (streq(address, udev_device_get_sysname(names->pcidev)))
+ if (startswith(udev_device_get_sysname(names->pcidev), address))
hotplug_slot = i;
if (hotplug_slot > 0)