]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net: do not set unapplied .link file name to ID_NET_LINK_FILE
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 5 Jan 2024 11:36:33 +0000 (20:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Jan 2024 19:27:41 +0000 (04:27 +0900)
Instead, import already assigned value from the udev database.
Then, return the builtin earlier.

src/udev/net/link-config.c
src/udev/udev-builtin-net_setup_link.c

index 910ec2709e5827da0e7f128f6730c12dd1f447a8..8689630f4b5392c85e4aad4adec81a05e84f35fa 100644 (file)
@@ -928,14 +928,6 @@ int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link) {
         assert(rtnl);
         assert(link);
 
-        if (!IN_SET(link->action, SD_DEVICE_ADD, SD_DEVICE_BIND, SD_DEVICE_MOVE)) {
-                log_link_debug(link, "Skipping to apply .link settings on '%s' uevent.",
-                               device_action_to_string(link->action));
-
-                link->new_name = link->ifname;
-                return 0;
-        }
-
         r = link_apply_ethtool_settings(link, &ctx->ethtool_fd);
         if (r < 0)
                 return r;
index a308a211fb0d99298ac9bc077536574633812497..ad73b8e1c440f3a02c2441d0c7c0f09b6baa3578 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "alloc-util.h"
+#include "device-private.h"
 #include "device-util.h"
 #include "escape.h"
 #include "errno-util.h"
@@ -21,6 +22,27 @@ static int builtin_net_setup_link(UdevEvent *event, int argc, char **argv, bool
         if (argc > 1)
                 return log_device_error_errno(dev, SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
 
+        sd_device_action_t action;
+        r = sd_device_get_action(dev, &action);
+        if (r < 0)
+                return log_device_error_errno(dev, r, "Failed to get action: %m");
+
+        if (!IN_SET(action, SD_DEVICE_ADD, SD_DEVICE_BIND, SD_DEVICE_MOVE)) {
+                log_device_debug(dev, "Skipping to apply .link settings on '%s' uevent.",
+                                 device_action_to_string(action));
+
+                /* Import previously assigned .link file name. */
+                (void) udev_builtin_import_property(dev, event->dev_db_clone, test, "ID_NET_LINK_FILE");
+                (void) udev_builtin_import_property(dev, event->dev_db_clone, test, "ID_NET_LINK_FILE_DROPINS");
+
+                /* Set ID_NET_NAME= with the current interface name. */
+                const char *value;
+                if (sd_device_get_sysname(dev, &value) >= 0)
+                        (void) udev_builtin_add_property(dev, test, "ID_NET_NAME", value);
+
+                return 0;
+        }
+
         r = link_new(ctx, &event->rtnl, dev, &link);
         if (r == -ENODEV) {
                 log_device_debug_errno(dev, r, "Link vanished while getting information, ignoring.");