be0c12
From f0b11f5042489c85d5016eceff06647bb49d486a Mon Sep 17 00:00:00 2001
be0c12
From: Yu Watanabe <watanabe.yu+github@gmail.com>
be0c12
Date: Tue, 17 Dec 2019 15:32:22 +0900
be0c12
Subject: [PATCH] udev: do not fail if kernel does not support alternative
be0c12
 names
be0c12
be0c12
(cherry picked from commit bb181dd4a664ca8e82a8f7194261fd6531e861d8)
be0c12
be0c12
Related: #2005008
be0c12
---
be0c12
 man/systemd.link.xml       | 3 ++-
be0c12
 src/udev/net/link-config.c | 4 +++-
be0c12
 2 files changed, 5 insertions(+), 2 deletions(-)
be0c12
be0c12
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
be0c12
index 0b0d83349d..c8ebb751ee 100644
be0c12
--- a/man/systemd.link.xml
be0c12
+++ b/man/systemd.link.xml
be0c12
@@ -348,7 +348,8 @@
be0c12
         <listitem>
be0c12
           <para>The alternative interface name to use. This option can be specified multiple times.
be0c12
           If the empty string is assigned to this option, the list is reset, and all prior assignments
be0c12
-          have no effect.</para>
be0c12
+          have no effect. If the kernel does not support the alternative names, then this setting will
be0c12
+          be ignored.</para>
be0c12
         </listitem>
be0c12
       </varlistentry>
be0c12
       <varlistentry>
be0c12
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
be0c12
index 4de8ee7d7e..8e88c8e5c4 100644
be0c12
--- a/src/udev/net/link-config.c
be0c12
+++ b/src/udev/net/link-config.c
be0c12
@@ -474,7 +474,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
be0c12
                 return log_warning_errno(r, "Could not set Alias=, MACAddress= or MTU= on %s: %m", old_name);
be0c12
 
be0c12
         r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, config->alternative_names);
be0c12
-        if (r < 0)
be0c12
+        if (r == -EOPNOTSUPP)
be0c12
+                log_debug_errno(r, "Could not set AlternativeName= on %s, ignoring: %m", old_name);
be0c12
+        else if (r < 0)
be0c12
                 return log_warning_errno(r, "Could not set AlternativeName= on %s: %m", old_name);
be0c12
 
be0c12
         *name = new_name;