|
|
698723 |
From 817a707daf1e9fa4f20eba04ce1c52af7518e355 Mon Sep 17 00:00:00 2001
|
|
|
698723 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
698723 |
Date: Fri, 17 Jul 2020 21:36:05 +0900
|
|
|
698723 |
Subject: [PATCH] udev: do not try to reassign alternative names
|
|
|
698723 |
|
|
|
698723 |
Setting alternative names may fail if some of them are already assigned.
|
|
|
698723 |
|
|
|
698723 |
(cherry picked from commit 97fdae33dfe8e7e0a4e5230564f6cdebc4450eec)
|
|
|
698723 |
|
|
|
698723 |
Related: #1850986
|
|
|
698723 |
---
|
|
|
698723 |
src/udev/net/link-config.c | 12 ++++++++++--
|
|
|
698723 |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
698723 |
|
|
|
698723 |
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
|
|
698723 |
index 8bd374d352..5220f247f0 100644
|
|
|
698723 |
--- a/src/udev/net/link-config.c
|
|
|
698723 |
+++ b/src/udev/net/link-config.c
|
|
|
698723 |
@@ -350,7 +350,7 @@ static int get_mac(struct udev_device *device, bool want_random,
|
|
|
698723 |
|
|
|
698723 |
int link_config_apply(link_config_ctx *ctx, link_config *config,
|
|
|
698723 |
struct udev_device *device, const char **name) {
|
|
|
698723 |
- _cleanup_strv_free_ char **altnames = NULL;
|
|
|
698723 |
+ _cleanup_strv_free_ char **altnames = NULL, **current_altnames = NULL;
|
|
|
698723 |
bool respect_predictable = false;
|
|
|
698723 |
struct ether_addr generated_mac;
|
|
|
698723 |
struct ether_addr *mac = NULL;
|
|
|
698723 |
@@ -514,9 +514,17 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
|
|
698723 |
if (new_name)
|
|
|
698723 |
strv_remove(altnames, new_name);
|
|
|
698723 |
strv_remove(altnames, old_name);
|
|
|
698723 |
+
|
|
|
698723 |
+ r = rtnl_get_link_alternative_names(&ctx->rtnl, ifindex, ¤t_altnames);
|
|
|
698723 |
+ if (r < 0)
|
|
|
698723 |
+ log_debug_errno(r, "Failed to get alternative names on %s, ignoring: %m", old_name);
|
|
|
698723 |
+
|
|
|
698723 |
+ char **p;
|
|
|
698723 |
+ STRV_FOREACH(p, current_altnames)
|
|
|
698723 |
+ strv_remove(altnames, *p);
|
|
|
698723 |
+
|
|
|
698723 |
strv_uniq(altnames);
|
|
|
698723 |
strv_sort(altnames);
|
|
|
698723 |
-
|
|
|
698723 |
r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames);
|
|
|
698723 |
if (r == -EOPNOTSUPP)
|
|
|
698723 |
log_debug_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s, ignoring: %m", old_name);
|