systemd/5cdb3f70ebe035323f4f079028a262669a2bbbf6.patch
Zbigniew Jędrzejewski-Szmek 6384abb1d1 A few more patches
2021-03-23 01:08:51 +01:00

56 lines
2.4 KiB
Diff

From 5cdb3f70ebe035323f4f079028a262669a2bbbf6 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Fri, 19 Mar 2021 06:26:53 +0900
Subject: [PATCH] udev: do not try to assign invalid ifname
Fixes #19038.
---
src/udev/net/link-config.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index f06ecd455df..31e5d0cd673 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -441,8 +441,6 @@ static int link_config_apply_rtnl_settings(sd_netlink **rtnl, const link_config
static int link_config_generate_new_name(const link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
unsigned name_type = NET_NAME_UNKNOWN;
- const char *new_name = NULL;
- NamePolicy policy;
int r;
assert(ctx);
@@ -460,7 +458,8 @@ static int link_config_generate_new_name(const link_config_ctx *ctx, const link_
if (ctx->enable_name_policy && config->name_policy)
for (NamePolicy *p = config->name_policy; *p != _NAMEPOLICY_INVALID; p++) {
- policy = *p;
+ const char *new_name = NULL;
+ NamePolicy policy = *p;
switch (policy) {
case NAMEPOLICY_KERNEL:
@@ -496,16 +495,13 @@ static int link_config_generate_new_name(const link_config_ctx *ctx, const link_
default:
assert_not_reached("invalid policy");
}
- if (ifname_valid(new_name))
- break;
+ if (ifname_valid(new_name)) {
+ log_device_debug(device, "Policy *%s* yields \"%s\".", name_policy_to_string(policy), new_name);
+ *ret_name = new_name;
+ return 0;
+ }
}
- if (new_name) {
- log_device_debug(device, "Policy *%s* yields \"%s\".", name_policy_to_string(policy), new_name);
- *ret_name = new_name;
- return 0;
- }
-
if (config->name) {
log_device_debug(device, "Policies didn't yield a name, using specified Name=%s.", config->name);
*ret_name = config->name;