teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0004-udev-net-id-Fix-check-for-address-to-keep-interface-.patch

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