<varlistentry>
<term><varname>NamePolicy=</varname></term>
<listitem>
- <para>An ordered, space-separated list of policies by which
- the interface name should be set.
- <literal>NamePolicy</literal> may be disabled by specifying
- <literal>net.ifnames=0</literal> on the kernel command line.
- Each of the policies may fail, and the first successful one
- is used. The name is not set directly, but is exported to
- udev as the property <literal>ID_NET_NAME</literal>, which
- is, by default, used by a udev rule to set
- <literal>NAME</literal>. If the name has already been set by
- userspace, no renaming is performed. The available policies
- are:</para>
+ <para>An ordered, space-separated list of policies by which the interface name should be set.
+ <literal>NamePolicy</literal> may be disabled by specifying <literal>net.ifnames=0</literal> on the
+ kernel command line. Each of the policies may fail, and the first successful one is used. The name
+ is not set directly, but is exported to udev as the property <literal>ID_NET_NAME</literal>, which
+ is, by default, used by a udev rule to set <literal>NAME</literal>. The available policies are:
+ </para>
<variablelist>
<varlistentry>
<literal>ID_NET_NAME_MAC</literal>.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>keep</literal></term>
+ <listitem>
+ <para>If the device already had a name given by userspace (as part of creation of the device
+ or a rename), keep it.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</listitem>
</varlistentry>
(void) link_name_type(device, &name_type);
- if (IN_SET(name_type, NET_NAME_USER, NET_NAME_RENAMED)) {
- log_device_info(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;
log_device_debug(device, "Policy *%s*: keeping predictable kernel name",
name_policy_to_string(policy));
goto no_rename;
+ case NAMEPOLICY_KEEP:
+ if (!IN_SET(name_type, NET_NAME_USER, NET_NAME_RENAMED))
+ continue;
+
+ log_device_debug(device, "Policy *%s*: keeping existing userspace name",
+ name_policy_to_string(policy));
+ goto no_rename;
case NAMEPOLICY_DATABASE:
(void) sd_device_get_property_value(device, "ID_NET_NAME_FROM_DATABASE", &new_name);
break;
static const char* const mac_policy_table[_MACPOLICY_MAX] = {
[MACPOLICY_PERSISTENT] = "persistent",
[MACPOLICY_RANDOM] = "random",
- [MACPOLICY_NONE] = "none"
+ [MACPOLICY_NONE] = "none",
};
DEFINE_STRING_TABLE_LOOKUP(mac_policy, MACPolicy);
static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
[NAMEPOLICY_KERNEL] = "kernel",
+ [NAMEPOLICY_KEEP] = "keep",
[NAMEPOLICY_DATABASE] = "database",
[NAMEPOLICY_ONBOARD] = "onboard",
[NAMEPOLICY_SLOT] = "slot",
[NAMEPOLICY_PATH] = "path",
- [NAMEPOLICY_MAC] = "mac"
+ [NAMEPOLICY_MAC] = "mac",
};
DEFINE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);