summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-04-03 22:39:25 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-04-04 18:48:59 +0200
commit3df2b4557a6951a7b381ae04f17655917d0ec8a1 (patch)
tree669a70599551bf45a78cac59e204c4bcaa0768cb
parentMerge pull request #32097 from keszybz/sd-notify-cleanups (diff)
downloadsystemd-3df2b4557a6951a7b381ae04f17655917d0ec8a1.tar.xz
systemd-3df2b4557a6951a7b381ae04f17655917d0ec8a1.zip
udev-util: rename device_is_processing() -> device_is_processed()
And make it also check the existence of the udev database.
-rw-r--r--src/network/networkd-link.c12
-rw-r--r--src/shared/udev-util.c17
-rw-r--r--src/shared/udev-util.h2
3 files changed, 17 insertions, 14 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 3e8aa9e37a..192e9df979 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1630,9 +1630,9 @@ static int link_check_initialized(Link *link) {
return 0;
}
- r = sd_device_get_is_initialized(device);
+ r = device_is_processed(device);
if (r < 0)
- return log_link_warning_errno(link, r, "Could not determine whether the device is initialized: %m");
+ return log_link_warning_errno(link, r, "Could not determine whether the device is processed by udevd: %m");
if (r == 0) {
/* not yet ready */
log_link_debug(link, "link pending udev initialization...");
@@ -1647,14 +1647,6 @@ static int link_check_initialized(Link *link) {
return 0;
}
- r = device_is_processing(device);
- if (r < 0)
- return log_link_warning_errno(link, r, "Failed to determine whether the device is being processed: %m");
- if (r > 0) {
- log_link_debug(link, "Interface is being processed by udevd, pending initialization.");
- return 0;
- }
-
return link_initialized(link, device);
}
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c
index 0014b7236f..1934694035 100644
--- a/src/shared/udev-util.c
+++ b/src/shared/udev-util.c
@@ -237,16 +237,27 @@ int device_is_renaming(sd_device *dev) {
return r;
}
-int device_is_processing(sd_device *dev) {
+int device_is_processed(sd_device *dev) {
int r;
assert(dev);
+ /* sd_device_get_is_initialized() only checks if the udev database file exists. However, even if the
+ * database file exist, systemd-udevd may be still processing the device, e.g. when the udev rules
+ * for the device have RUN tokens. See issue #30056. Hence, to check if the device is really
+ * processed by systemd-udevd, we also need to read ID_PROCESSING property. */
+
+ r = sd_device_get_is_initialized(dev);
+ if (r <= 0)
+ return r;
+
r = device_get_property_bool(dev, "ID_PROCESSING");
if (r == -ENOENT)
- return false; /* defaults to false */
+ return true; /* If the property does not exist, then it means that the device is processed. */
+ if (r < 0)
+ return r;
- return r;
+ return !r;
}
bool device_for_action(sd_device *dev, sd_device_action_t a) {
diff --git a/src/shared/udev-util.h b/src/shared/udev-util.h
index 13710a3ec1..c21c4c158c 100644
--- a/src/shared/udev-util.h
+++ b/src/shared/udev-util.h
@@ -13,7 +13,7 @@ int udev_parse_config(void);
int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret);
int device_wait_for_devlink(const char *path, const char *subsystem, usec_t timeout_usec, sd_device **ret);
int device_is_renaming(sd_device *dev);
-int device_is_processing(sd_device *dev);
+int device_is_processed(sd_device *dev);
bool device_for_action(sd_device *dev, sd_device_action_t action);