f770414
From 8eebb6a9e5e74ec0ef40902e2da53d24559b94a4 Mon Sep 17 00:00:00 2001
f770414
From: Filipe Brandenburger <filbranden@google.com>
f770414
Date: Thu, 15 Mar 2018 10:42:38 -0700
f770414
Subject: [PATCH] udev/net-id: Fix check for address to keep interface names
f770414
 stable (#8458)
f770414
f770414
This was a bug inadvertently added by commit 73fc96c8ac0aa9.
f770414
f770414
The intent of the check is to "match slot address with device by
f770414
stripping the function" (as the comment above states it), for example
f770414
match network device PCI address 0000:05:00.0 (including a .0 for
f770414
function) to PCI slot address 0000:05:00, but changing that to a streq()
f770414
call prevented the match.
f770414
f770414
Change that to startswith(), which should both fix the bug and make the
f770414
intent of the check more clear and prevent unintentional bugs from being
f770414
introduced by future refactorings.
f770414
---
f770414
 src/udev/udev-builtin-net_id.c | 2 +-
f770414
 1 file changed, 1 insertion(+), 1 deletion(-)
f770414
f770414
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
f770414
index 36994360c7..6efa712930 100644
f770414
--- a/src/udev/udev-builtin-net_id.c
f770414
+++ b/src/udev/udev-builtin-net_id.c
f770414
@@ -297,7 +297,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
f770414
                 if (snprintf_ok(str, sizeof str, "%s/%s/address", slots, dent->d_name) &&
f770414
                     read_one_line_file(str, &address) >= 0)
f770414
                         /* match slot address with device by stripping the function */
f770414
-                        if (streq(address, udev_device_get_sysname(names->pcidev)))
f770414
+                        if (startswith(udev_device_get_sysname(names->pcidev), address))
f770414
                                 hotplug_slot = i;
f770414
 
f770414
                 if (hotplug_slot > 0)
f770414
-- 
f770414
2.16.2
f770414