meson: make net.naming-scheme= default configurable
This is useful for distributions, where the stability of interface names should be preseved after an upgrade of systemd. So when some specific release of the distro is made available, systemd defaults to the latest & greatest naming scheme, and subsequent updates set the same default. This default may still be overriden through the kernel and env var options. A special value "latest" is also allowed. Without a specific name, it is harder to verride from meson. In case of 'combo' options, meson reads the default during the initial configuration, and "remembers" this choice. When systemd is updated, old build/ directories could keep the old default, which would be annoying. Hence, "latest" is introduced to make it explicit, yet follow the upstream. This is actually useful for the user too, because it may be used as an override, without having to actually specify a version.
This commit is contained in:
committed by
Lennart Poettering
parent
f7e81fd96f
commit
06da5c63dd
@@ -193,6 +193,19 @@ struct virtfn_info {
|
||||
char suffix[IFNAMSIZ];
|
||||
};
|
||||
|
||||
static const NamingScheme* naming_scheme_from_name(const char *name) {
|
||||
size_t i;
|
||||
|
||||
if (streq(name, "latest"))
|
||||
return naming_schemes + ELEMENTSOF(naming_schemes) - 1;
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(naming_schemes); i++)
|
||||
if (streq(naming_schemes[i].name, name))
|
||||
return naming_schemes + i;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const NamingScheme* naming_scheme(void) {
|
||||
static const NamingScheme *cache = NULL;
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
@@ -216,24 +229,18 @@ static const NamingScheme* naming_scheme(void) {
|
||||
k = buffer;
|
||||
|
||||
if (k) {
|
||||
size_t i;
|
||||
cache = naming_scheme_from_name(k);
|
||||
if (cache) {
|
||||
log_info("Using interface naming scheme '%s'.", cache->name);
|
||||
return cache;
|
||||
}
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(naming_schemes); i++)
|
||||
if (streq(naming_schemes[i].name, k)) {
|
||||
cache = naming_schemes + i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!cache)
|
||||
log_warning("Unknown interface naming scheme '%s' requested, ignoring.", k);
|
||||
log_warning("Unknown interface naming scheme '%s' requested, ignoring.", k);
|
||||
}
|
||||
|
||||
if (cache)
|
||||
log_info("Using interface naming scheme '%s'.", cache->name);
|
||||
else {
|
||||
cache = naming_schemes + ELEMENTSOF(naming_schemes) - 1;
|
||||
log_info("Using default interface naming scheme '%s'.", cache->name);
|
||||
}
|
||||
cache = naming_scheme_from_name(DEFAULT_NET_NAMING_SCHEME);
|
||||
assert(cache);
|
||||
log_info("Using default interface naming scheme '%s'.", cache->name);
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user