From: Nick Rosbrook Date: Fri, 2 Dec 2022 20:26:18 +0000 (-0500) Subject: sd-netlink: do not swap old name and alternative name X-Git-Tag: v253-rc1~251^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=080afbb57c4b2d592c5cf77ab10c6e0be74f0732;p=thirdparty%2Fsystemd.git sd-netlink: do not swap old name and alternative name Commit 434a348380 ("netlink: do not fail when new interface name is already used as an alternative name") added logic to set the old interface name as an alternative name, but only when the new name is currently an alternative name. This is not the desired outcome in most cases, and the important part of this commit was to delete the new name from the list of alternative names if necessary. --- diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c index c6091542d28..a53ffb26163 100644 --- a/src/libsystemd/sd-netlink/netlink-util.c +++ b/src/libsystemd/sd-netlink/netlink-util.c @@ -3,7 +3,6 @@ #include "sd-netlink.h" #include "fd-util.h" -#include "format-util.h" #include "io-util.h" #include "memory-util.h" #include "netlink-internal.h" @@ -15,7 +14,6 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; _cleanup_strv_free_ char **alternative_names = NULL; - char old_name[IF_NAMESIZE] = {}; int r; assert(rtnl); @@ -35,10 +33,6 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) { if (r < 0) return log_debug_errno(r, "Failed to remove '%s' from alternative names on network interface %i: %m", name, ifindex); - - r = format_ifname(ifindex, old_name); - if (r < 0) - return log_debug_errno(r, "Failed to get current name of network interface %i: %m", ifindex); } r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex); @@ -53,13 +47,6 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) { if (r < 0) return r; - if (!isempty(old_name)) { - r = rtnl_set_link_alternative_names(rtnl, ifindex, STRV_MAKE(old_name)); - if (r < 0) - log_debug_errno(r, "Failed to set '%s' as an alternative name on network interface %i, ignoring: %m", - old_name, ifindex); - } - return 0; }