!767 wait-online: fix handling of unmanaged state

From: @zhang-yao-2022 
Reviewed-by: @xujing99 
Signed-off-by: @xujing99
This commit is contained in:
openeuler-ci-bot 2024-12-04 07:29:43 +00:00 committed by Gitee
commit 3fcb7f815b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 81 additions and 1 deletions

View File

@ -0,0 +1,75 @@
From cd7fcda54333dc95116a434cffc591f21edddbb2 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Wed, 26 Jan 2022 16:48:08 +0900
Subject: [PATCH] wait-online: make manager_link_is_online() return 0 when in
unmanaged state
Previously, even if a link is in unmanaged state, the function may
returns positive value. So, even if all managed links are in the configured
sate but do not satisfy the online criteria, e.g., IPv4 address state,
then wait-online finishes with positive value.
This makes the function always return 0 for unmanaged state. So, at
least one managed link must satisfies the online criteria.
This also adds more comments and debugging logs.
Fixes #22246.
Reference: https://github.com/systemd/systemd/pull/22249/commits/cd7fcda54333dc95116a434cffc591f21edddbb2
Signed-off-by: zhaoxiaohu <zhaoxiaohu@kuaishou.com>
Signed-off-by: yuwang <yuwang@kuaishou.com>
---
src/network/wait-online/manager.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c
index d8cf233..17b7475 100644
--- a/src/network/wait-online/manager.c
+++ b/src/network/wait-online/manager.c
@@ -45,13 +45,29 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
* 0: operstate is not enough
* 1: online */
- if (!l->state)
+ if (!l->state || streq(l->state, "pending"))
+ /* If no state string exists, networkd (and possibly also udevd) has not detected the
+ * interface yet, that mean we cannot determine whether the interface is managed or
+ * not. Hence, return negative value.
+ * If the link is in pending state, then udevd has not processed the link, and networkd
+ * has not tried to find .network file for the link. Hence, return negative value. */
return log_link_debug_errno(l, SYNTHETIC_ERRNO(EAGAIN),
- "link has not yet been processed by udev");
+ "link has not yet been processed by udev: setup state is %s.",
+ strna(l->state));
+
+ if (streq(l->state, "unmanaged")) {
+ /* If the link is in unmanaged state, then ignore the interface unless the interface is
+ * specified in '--interface/-i' option. */
+ if (!hashmap_contains(m->command_line_interfaces_by_name, l->ifname)) {
+ log_link_debug(l, "link is not managed by networkd (yet?).");
+ return 0;
+ }
- if (STR_IN_SET(l->state, "configuring", "pending"))
+ } else if (!streq(l->state, "configured"))
+ /* If the link is in non-configured state, return negative value here. */
return log_link_debug_errno(l, SYNTHETIC_ERRNO(EAGAIN),
- "link is being processed by networkd");
+ "link is being processed by networkd: setup state is %s.",
+ l->state);
if (s.min < 0)
s.min = m->required_operstate.min >= 0 ? m->required_operstate.min
@@ -96,6 +112,7 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
}
}
+ log_link_debug(l, "link is configured by networkd and online.");
return 1;
}
--
2.33.0

View File

@ -25,7 +25,7 @@
Name: systemd
Url: https://systemd.io/
Version: 249
Release: 91
Release: 92
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -694,6 +694,7 @@ Patch6641: backport-repart-fix-invalid-errno-in-log.patch
Patch6642: backport-sysusers-insist-that-root-group-is-0.patch
Patch6643: backport-importd-Always-specify-file-unpacked-by-tar.patch
Patch6644: backport-docs-remove-dev-tty-confusion.patch
Patch6645: backport-wait-online-make-manager_link_is_online-return-0-whe.patch
Patch9001: update-rtc-with-system-clock-when-shutdown.patch
Patch9002: udev-add-actions-while-rename-netif-failed.patch
@ -2208,6 +2209,10 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null &&
/usr/bin/systemd-cryptenroll
%changelog
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-92
- wait-online: fix handling of unmanaged state
- add backport-wait-online-make-manager_link_is_online-return-0-whe.patch
* Wed Dec 04 2024 zhangyao <zhangyao108@huawei.com> - 249-91
- add backport-userdb-Use-json_dispatch_user_group_name-to-parse-Ge.patch
backport-README-explicitly-note-that-util-linux-s-mount-swap-.patch