]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: make net.naming-scheme= default configurable
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Dec 2018 22:28:29 +0000 (23:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 12 Dec 2018 09:09:36 +0000 (10:09 +0100)
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.

docs/ENVIRONMENT.md
man/systemd-udevd.service.xml
meson.build
meson_options.txt
src/udev/udev-builtin-net_id.c

index e9e82cfca448186f26cd30c894413450b423a216..eaac288ec585d5881d37142713a83c652b2c77b4 100644 (file)
@@ -92,13 +92,14 @@ systemd-logind:
   for it.
 
 * `$NET_NAMING_SCHEME=` – if set, takes a network naming scheme (i.e. one of
-  v238, v239, v240 …) as parameter. If specified udev's net_id builtin will
-  follow the specified naming scheme when determining stable network interface
-  names. This may be used to revert to naming schemes of older udev versions,
-  in order to provide more stable naming across updates. This environment
-  variable takes precedence over the kernel command line option
-  `net.naming-scheme=`, except if the value is prefixed with `:` in which case
-  the kernel command line option takes precedence, if it is specified as well.
+  "v238", "v239", "v240"…, or the special value "latest") as parameter. If
+  specified udev's net_id builtin will follow the specified naming scheme when
+  determining stable network interface names. This may be used to revert to
+  naming schemes of older udev versions, in order to provide more stable naming
+  across updates. This environment variable takes precedence over the kernel
+  command line option `net.naming-scheme=`, except if the value is prefixed
+  with `:` in which case the kernel command line option takes precedence, if it
+  is specified as well.
 
 installed systemd tests:
 
index b1409698ab500e054467dbf80fa1b472cbd7c482..330700d7dd1972db8e53cb7291dbec900896d837 100644 (file)
         <term><varname>net.naming-scheme=</varname></term>
         <listitem>
           <para>Network interfaces are renamed to give them predictable names when possible (unless
-          <varname>net.ifnames=0</varname> is specified, see above). The names are derived from various device metadata
-          fields. Newer versions of <filename>systemd-udevd.service</filename> take more of these fields into account,
-          improving (and thus possibly changing) the names used for the same devices. With this kernel command line
-          option it is possible to pick a specific version of this algorithm. It expects a naming scheme identifier as
-          argument. Currently the following identifiers are known: <literal>v238</literal>, <literal>v239</literal>,
-          <literal>v240</literal> which each implement the naming scheme that was the default in the indicated systemd
-          version. Note that selecting a specific scheme is not sufficient to fully stabilize interface naming: the
-          naming is generally derived from driver attributes exposed by the kernel. As the kernel is updated,
-          previously missing attributes <filename>systemd-udevd.service</filename> is checking might appear, which
-          affects older name derivation algorithms, too.</para>
+          <varname>net.ifnames=0</varname> is specified, see above). The names are derived from various
+          device metadata fields. Newer versions of <filename>systemd-udevd.service</filename> take more of
+          these fields into account, improving (and thus possibly changing) the names used for the same
+          devices. With this kernel command line option it is possible to pick a specific version of this
+          algorithm. It expects a naming scheme identifier as argument. Currently the following identifiers
+          are known: <literal>v238</literal>, <literal>v239</literal>, <literal>v240</literal> which each
+          implement the naming scheme that was the default in the indicated systemd version. In addition,
+          <literal>latest</literal> may be used to designate the latest scheme known (to this particular
+          version of <filename>systemd-udevd.service</filename>).</para>
+
+          <para>Note that selecting a specific scheme is not sufficient to fully stabilize interface naming:
+          the naming is generally derived from driver attributes exposed by the kernel. As the kernel is
+          updated, previously missing attributes <filename>systemd-udevd.service</filename> is checking might
+          appear, which affects older name derivation algorithms, too.</para>
         </listitem>
       </varlistentry>
     </variablelist>
index 1f44c0fe70d327f4e84d902cff359e815a203eef..d8e35e618d2507dc7ad4bff5b979314c450d4324 100644 (file)
@@ -694,6 +694,9 @@ else
         conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
 endif
 
+default_net_naming_scheme = get_option('default-net-naming-scheme')
+conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
+
 time_epoch = get_option('time-epoch')
 if time_epoch == -1
         NEWS = files('NEWS')
@@ -3093,6 +3096,7 @@ status = [
         'default DNSSEC mode:               @0@'.format(default_dnssec),
         'default DNS-over-TLS mode:         @0@'.format(default_dns_over_tls),
         'default cgroup hierarchy:          @0@'.format(default_hierarchy),
+        'default net.naming-scheme setting: @0@'.format(default_net_naming_scheme),
         'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
 
 alt_dns_servers = '\n                                            '.join(dns_servers.split(' '))
index 62167ae92d6b9f58895ac8919ce54746df3bc1ac..1423b8998e5d3860fa245559ee0b8184764d57e4 100644 (file)
@@ -156,6 +156,9 @@ option('compat-gateway-hostname', type : 'boolean', value : 'false',
 option('default-hierarchy', type : 'combo',
        choices : ['legacy', 'hybrid', 'unified'], value : 'hybrid',
        description : 'default cgroup hierarchy')
+option('default-net-naming-scheme', type : 'combo',
+       choices : ['latest', 'v238', 'v239', 'v240'],
+       description : 'default net.naming-scheme= value')
 option('time-epoch', type : 'integer', value : '-1',
        description : 'time epoch for time clients')
 option('system-uid-max', type : 'integer', value : '-1',
index 18d8d3b8e8e6f4303adff7586ef9a545170d3309..0292c4973c8b4c7f05e09f1a67aa0a2f69c13178 100644 (file)
@@ -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;
-
-                for (i = 0; i < ELEMENTSOF(naming_schemes); i++)
-                        if (streq(naming_schemes[i].name, k)) {
-                                cache = naming_schemes + i;
-                                break;
-                        }
+                cache = naming_scheme_from_name(k);
+                if (cache) {
+                        log_info("Using interface naming scheme '%s'.", cache->name);
+                        return cache;
+                }
 
-                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;
 }