Files
systemd/src/udev/net/naming-scheme.h
T
Zbigniew Jędrzejewski-Szmek 96848152fa udev: introduce NAMING_STABLE_VIRTUAL_MACS (retroactively)
This is for 6d36464065. It turns out that this is causing more problems than
expected. Let's retroactively introduce naming scheme v241 to conditionalize
this change.

Follow-up for #12792 and 6d36464065. See also
https://bugzilla.suse.com/show_bug.cgi?id=1136600.

$ SYSTEMD_LOG_LEVEL=debug NET_NAMING_SCHEME=v240 build/udevadm test-builtin net_setup_link /sys/class/net/br11
$ SYSTEMD_LOG_LEVEL=debug NET_NAMING_SCHEME=v241 build/udevadm test-builtin net_setup_link /sys/class/net/br11
...
@@ -20,11 +20,13 @@
 link_config: could not set ethtool features for br11
 Could not set offload features of br11: Operation not permitted
 br11: Device has name_assign_type=3
-Using interface naming scheme 'v240'.
+Using interface naming scheme 'v241'.
 br11: Policy *keep*: keeping existing userspace name
 br11: Device has addr_assign_type=1
-br11: No stable identifying information found
-br11: Could not generate persistent MAC: No data available
+br11: Using "br11" as stable identifying information
+br11: Using generated persistent MAC address
+Could not set Alias=, MACAddress= or MTU= on br11: Operation not permitted
+br11: Could not apply link config, ignoring: Operation not permitted
 Unload module index
 Unloaded link configuration context.
 ID_NET_DRIVER=bridge
2019-06-17 13:43:18 +02:00

54 lines
3.0 KiB
C

/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <stdbool.h>
#include "macro.h"
/* So here's the deal: net_id is supposed to be an exercise in providing stable names for network devices. However, we
* also want to keep updating the naming scheme used in future versions of net_id. These two goals of course are
* contradictory: on one hand we want things to not change and on the other hand we want them to improve. Our way out
* of this dilemma is to introduce the "naming scheme" concept: each time we improve the naming logic we define a new
* flag for it. Then, we keep a list of schemes, each identified by a name associated with the flags it implements. Via
* a kernel command line and environment variable we then allow the user to pick the scheme they want us to follow:
* installers could "freeze" the used scheme at the moment of installation this way.
*
* Developers: each time you tweak the naming logic here, define a new flag below, and condition the tweak with
* it. Each time we do a release we'll then add a new scheme entry and include all newly defined flags.
*
* Note that this is only half a solution to the problem though: not only udev/net_id gets updated all the time, the
* kernel gets too. And thus a kernel that previously didn't expose some sysfs attribute we look for might eventually
* do, and thus affect our naming scheme too. Thus, enforcing a naming scheme will make interfacing more stable across
* OS versions, but not fully stabilize them. */
typedef enum NamingSchemeFlags {
/* First, the individual features */
NAMING_SR_IOV_V = 1 << 0, /* Use "v" suffix for SR-IOV, see 609948c7043a */
NAMING_NPAR_ARI = 1 << 1, /* Use NPAR "ARI", see 6bc04997b6ea */
NAMING_INFINIBAND = 1 << 2, /* Use "ib" prefix for infiniband, see 938d30aa98df */
NAMING_ZERO_ACPI_INDEX = 1 << 3, /* Use zero acpi_index field, see d81186ef4f6a */
NAMING_ALLOW_RERENAMES = 1 << 4, /* Allow re-renaming of devices, see #9006 */
NAMING_STABLE_VIRTUAL_MACS = 1 << 5, /* Use device name to generate MAC, see 6d3646406560 */
NAMING_NETDEVSIM = 1 << 6, /* Generate names for netdevsim devices, see eaa9d507d855 */
NAMING_LABEL_NOPREFIX = 1 << 7, /* Don't prepend ID_NET_LABEL_ONBOARD with interface type prefix */
/* 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_ALLOW_RERENAMES,
NAMING_V241 = NAMING_V240 | NAMING_STABLE_VIRTUAL_MACS,
NAMING_V243 = NAMING_V241 | NAMING_NETDEVSIM | NAMING_LABEL_NOPREFIX,
_NAMING_SCHEME_FLAGS_INVALID = -1,
} NamingSchemeFlags;
typedef struct NamingScheme {
const char *name;
NamingSchemeFlags flags;
} NamingScheme;
const NamingScheme* naming_scheme(void);
static inline bool naming_scheme_has(NamingSchemeFlags flags) {
return FLAGS_SET(naming_scheme()->flags, flags);
}