summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-10-31 10:25:50 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-11-01 22:37:08 +0900
commit0d7e58038e3eaaeb28ff82b8b504d8780c736fe7 (patch)
tree28f4ec564df8b40faed60960951e5042bcb89b19 /src/network
parent2401f920f351a4b15560f61b3008328d2f9b87fa (diff)
downloadsystemd-0d7e58038e3eaaeb28ff82b8b504d8780c736fe7.tar.gz
wait-online: check received interface name
Diffstat (limited to 'src/network')
-rw-r--r--src/network/wait-online/link.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/network/wait-online/link.c b/src/network/wait-online/link.c
index f379578355..287a91648d 100644
--- a/src/network/wait-online/link.c
+++ b/src/network/wait-online/link.c
@@ -64,6 +64,7 @@ Link *link_free(Link *l) {
}
static int link_update_name(Link *l, sd_netlink_message *m) {
+ char ifname_from_index[IF_NAMESIZE];
const char *ifname;
int r;
@@ -81,6 +82,18 @@ static int link_update_name(Link *l, sd_netlink_message *m) {
if (streq(ifname, l->ifname))
return 0;
+ /* The kernel sometimes sends wrong ifname change. Let's confirm the received name. */
+ r = format_ifname(l->ifindex, ifname_from_index);
+ if (r < 0)
+ return r;
+
+ if (!streq(ifname, ifname_from_index)) {
+ log_link_debug(l, "New interface name '%s' received from the kernel does not correspond "
+ "with the name currently configured on the actual interface '%s'. Ignoring.",
+ ifname, ifname_from_index);
+ return 0;
+ }
+
hashmap_remove(l->manager->links_by_name, l->ifname);
r = free_and_strdup(&l->ifname, ifname);