1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

link-config: default to "keep" policy if naming-scheme<=239 is used

This makes the new (>=240) behaviour conditional, restoring backwards compat, as least
as long as an old naming scheme is used.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-01-16 14:53:49 +01:00
parent 35b351900f
commit 73d2bb0881
2 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "link-config.h" #include "link-config.h"
#include "log.h" #include "log.h"
#include "missing_network.h" #include "missing_network.h"
#include "naming-scheme.h"
#include "netlink-util.h" #include "netlink-util.h"
#include "network-internal.h" #include "network-internal.h"
#include "parse-util.h" #include "parse-util.h"
@ -399,6 +400,12 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
(void) link_name_type(device, &name_type); (void) link_name_type(device, &name_type);
if (IN_SET(name_type, NET_NAME_USER, NET_NAME_RENAMED)
&& !naming_scheme_has(NAMING_ALLOW_RERENAMES)) {
log_device_debug(device, "Device already has a name given by userspace, not renaming.");
goto no_rename;
}
if (ctx->enable_name_policy && config->name_policy) if (ctx->enable_name_policy && config->name_policy)
for (NamePolicy *p = config->name_policy; !new_name && *p != _NAMEPOLICY_INVALID; p++) { for (NamePolicy *p = config->name_policy; !new_name && *p != _NAMEPOLICY_INVALID; p++) {
policy = *p; policy = *p;

View File

@ -26,11 +26,12 @@ typedef enum NamingSchemeFlags {
NAMING_NPAR_ARI = 1 << 1, /* Use NPAR "ARI", see 6bc04997b6eab35d1cb9fa73889892702c27be09 */ NAMING_NPAR_ARI = 1 << 1, /* Use NPAR "ARI", see 6bc04997b6eab35d1cb9fa73889892702c27be09 */
NAMING_INFINIBAND = 1 << 2, /* Use "ib" prefix for infiniband, see 938d30aa98df887797c9e05074a562ddacdcdf5e */ NAMING_INFINIBAND = 1 << 2, /* Use "ib" prefix for infiniband, see 938d30aa98df887797c9e05074a562ddacdcdf5e */
NAMING_ZERO_ACPI_INDEX = 1 << 3, /* Allow zero acpi_index field, see d81186ef4f6a888a70f20a1e73a812d6acb9e22f */ NAMING_ZERO_ACPI_INDEX = 1 << 3, /* Allow zero acpi_index field, see d81186ef4f6a888a70f20a1e73a812d6acb9e22f */
NAMING_ALLOW_RERENAMES = 1 << 4, /* Allow re-renaming of devices, see #9006 */
/* And now the masks that combine the features above */ /* And now the masks that combine the features above */
NAMING_V238 = 0, NAMING_V238 = 0,
NAMING_V239 = NAMING_V238 | NAMING_SR_IOV_V | NAMING_NPAR_ARI, NAMING_V239 = NAMING_V238 | NAMING_SR_IOV_V | NAMING_NPAR_ARI,
NAMING_V240 = NAMING_V239 | NAMING_INFINIBAND | NAMING_ZERO_ACPI_INDEX, NAMING_V240 = NAMING_V239 | NAMING_INFINIBAND | NAMING_ZERO_ACPI_INDEX | NAMING_ALLOW_RERENAMES,
_NAMING_SCHEME_FLAGS_INVALID = -1, _NAMING_SCHEME_FLAGS_INVALID = -1,
} NamingSchemeFlags; } NamingSchemeFlags;