diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index dfb00485d1..eb2477cea4 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -14,6 +14,7 @@ #include "link-config.h" #include "log.h" #include "missing_network.h" +#include "naming-scheme.h" #include "netlink-util.h" #include "network-internal.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); + 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) for (NamePolicy *p = config->name_policy; !new_name && *p != _NAMEPOLICY_INVALID; p++) { policy = *p; diff --git a/src/udev/net/naming-scheme.h b/src/udev/net/naming-scheme.h index c7f9505ab7..0b3d9bff1d 100644 --- a/src/udev/net/naming-scheme.h +++ b/src/udev/net/naming-scheme.h @@ -26,11 +26,12 @@ typedef enum NamingSchemeFlags { NAMING_NPAR_ARI = 1 << 1, /* Use NPAR "ARI", see 6bc04997b6eab35d1cb9fa73889892702c27be09 */ 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_ALLOW_RERENAMES = 1 << 4, /* Allow re-renaming of devices, see #9006 */ /* And now the masks that combine the features above */ NAMING_V238 = 0, 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, } NamingSchemeFlags;