all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Felix Lechner via Guix-patches via <guix-patches@gnu.org>
To: 63508@debbugs.gnu.org
Cc: Felix Lechner <felix.lechner@lease-up.com>
Subject: [bug#63508] [PATCH 3/3] gnu: eudev: Always use MAC-based names for network interfaces.
Date: Sun, 14 May 2023 14:42:31 -0700	[thread overview]
Message-ID: <89b635e974a7d570cbd19b847fc3eb8ac903103b.1684100044.git.felix.lechner@lease-up.com> (raw)
In-Reply-To: <cover.1684100044.git.felix.lechner@lease-up.com>

Upon personal reflection, a declarative operating system like Guix probably
ought to use only predictable interface names.

While shorter names like 'eno1' offer an indisputable convenience and beauty
when typing on the command line, administrators in Guix are unlikely to do so
due to the declarative configuration system.

Some system services may explicitly refer to interface names in their
configuration. They would also benefit from the predictable and constant
nature of MAC-based names.

The latter is particularly relevant on multi-homed machines, i.e. those with
more than one network connection.

A MAC-based interface name as issued by 'eudev' looks like this:

  enx0123456789af   (fictitious)

This commit was deployed on two production machines. The migration to
MAC-based interface names took place without issues. A second reconfiguration
was the used to add the new interface name in services tha needed it. The
second step can be skipped, since the name is known with certainty in advance.

The current naming scheme is less desirable because some services may silently
refuse to start after equipment was added or removed. A removal may take
place, for example, when something broke or when equipment was sold.

The device enumeration may also change when a CMOS battery fails and system
options are lost. In the author's option, Guix should not depend on BIOS
enumeration for device names.

In the author's case, the name of the sole network interface changed from
enp3s0 to enp4s0 when a PCIe disk controller (a SAS host-based adapter) was
installed. As a result, OpenSMTPd silently failed to start.

This commit switches 'eudev' from the standard naming order

  ID_NET_NAME_ONBOARD
  ID_NET_NAME_SLOT
  ID_NET_NAME_PATH

to ID_NET_NAME_MAC, which is always available. [1]

The author initially attempted to achieve the same result via

(udev-rules-service 'net-name-mac
  (udev-rule
    "01-net-name-mac.rules"
    "SUBSYSTEM==\"net\", ACTION==\"add\", NAME=\"$env{ID_NET_NAME_MAC}\"
")))

but that did not work. While the situation was not examined exhaustively, it
was not clear that udevadm can currently work because the standard command to
test udev setups: [2]

  $ udevadm --debug test /sys/class/net/*

did not find the script installed via the 'udev-service-type'.

A review of the 'eudev' sources indicated that the path to find rules [3] is
hard-coded to the store location during installation. An attempt to set the
path to /etc/udev/rules.d yielded a build error because that target folder
outside the store was understandably not writable.

The manual page for udevadm did not offer a way to select the runtime location
of the udev/rules.d folder via environment variables or a command-line option.

Anyone for whom such a setup is working properly should please contact the
author. Thank you!

This commit may result in some loss of privacy, although it is presently not
clear how meaningful that is. With this commit, anyone using privacy-enhanced
IPv6 addresses risks having their MAC exposed when they publish their
configuration files in Git or post a well-meant sample in a chat rooms,
because that configuration may mention the MAC address.

Moreover, the compatibilty with schemes to generate fake one-time MAC
addresses upon boot should be evaluated. One concern is that the explicit
reference to a network interface in a configuration file would likely force
the use of a single and constant MAC address for that interface.

This commit was tested in production and is currently being used.

The change here resulted in the recompilation of several seemingly unrelated
packages such as Emacs and GTK. Perhaps those dependency relationships should
be examined.

[1] https://wiki.debian.org/NetworkInterfaceNames#How_to_migrate_to_this_scheme_on_upgraded_systems
[2] https://wiki.archlinux.org/title/Udev#Testing_rules_before_loading
[3] https://github.com/eudev-project/eudev/blob/39979ddf46e75d1b75bf381e1c73914c226c4302/configure.ac#L180
[4] https://en.wikipedia.org/wiki/IPv6_address#Temporary_addresses

* gnu/packages/linux.scm (eudev): Always use MAC-based names for network
interfaces.
---
 gnu/packages/linux.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 98e683bdb0..724c621fed 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -4173,6 +4173,12 @@ (define-public eudev
                 (substitute* (string-append #$output "/lib/libudev.la")
                   (("old_library=.*")
                    "old_library=''\n")))))
+          (add-before 'install 'net-name-mac
+            (lambda _
+              (use-modules (ice-9 regex))
+              (substitute* "rules/80-net-name-slot.rules"
+                (((regexp-quote "ID_NET_NAME_ONBOARD"))
+                 "ID_NET_NAME_MAC"))))
           (add-after 'install 'build-hwdb
             (lambda _
               ;; Build OUT/etc/udev/hwdb.bin.  This allows 'lsusb' and
-- 
2.40.1





  parent reply	other threads:[~2023-05-14 21:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-14 21:41 [bug#63508] [PATCH 0/3] Use MAC-based names for network interfaces Felix Lechner via Guix-patches via
2023-05-14 21:42 ` [bug#63508] [PATCH 1/3] gnu: eudev: Convert native-inputs to new style Felix Lechner via Guix-patches via
2023-05-14 21:42 ` [bug#63508] [PATCH 2/3] gnu: eudev: Convert build arguments to gexps Felix Lechner via Guix-patches via
2023-05-14 21:42 ` Felix Lechner via Guix-patches via [this message]
2023-05-15  4:31   ` [bug#63508] [PATCH 3/3] gnu: eudev: Always use MAC-based names for network interfaces Liliana Marie Prikler
2023-05-15  4:56     ` Felix Lechner via Guix-patches via
2023-05-15 19:11 ` [bug#63508] [PATCH] gnu: udev: Allow EUDEV_RULES_DIRECTORY to shadow built-in rules Liliana Marie Prikler
2023-05-18  0:52 ` [bug#63508] [PATCH v2 1/4] gnu: eudev: Convert native-inputs to new style Felix Lechner via Guix-patches via
2023-05-18  0:52   ` [bug#63508] [PATCH v2 2/4] gnu: eudev: Convert build arguments to gexps Felix Lechner via Guix-patches via
2023-05-18  4:12     ` Liliana Marie Prikler
2023-05-18  0:52   ` [bug#63508] [PATCH v2 3/4] gnu: eudev: Use new project URL Felix Lechner via Guix-patches via
2023-05-18  0:52   ` [bug#63508] [PATCH v2 4/4] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-18  4:19     ` Liliana Marie Prikler
2023-05-28 23:23       ` Felix Lechner via Guix-patches via
2023-05-29  8:29         ` Liliana Marie Prikler
2023-05-28 23:28 ` [bug#63508] [PATCH v3 1/3] gnu: eudev: Convert native-inputs to new style, and build arguments to Gexps Felix Lechner via Guix-patches via
2023-05-28 23:28   ` [bug#63508] [PATCH v3 2/3] gnu: eudev: Use new project URL Felix Lechner via Guix-patches via
2023-05-29  7:49     ` Liliana Marie Prikler
2023-05-28 23:28   ` [bug#63508] [PATCH v3 3/3] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-29  7:38     ` Liliana Marie Prikler
2023-05-29  7:40   ` [bug#63508] [PATCH v3 1/3] gnu: eudev: Convert native-inputs to new style, and build arguments to Gexps Liliana Marie Prikler
2023-05-29 16:57 ` [bug#63508] [PATCH v4 1/2] gnu: eudev: Use new project URL for Git repo and home page Felix Lechner via Guix-patches via
2023-05-29 16:57   ` [bug#63508] [PATCH v4 2/2] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-29 20:28     ` Bruno Victal
2023-05-29 21:06       ` Felix Lechner via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89b635e974a7d570cbd19b847fc3eb8ac903103b.1684100044.git.felix.lechner@lease-up.com \
    --to=guix-patches@gnu.org \
    --cc=63508@debbugs.gnu.org \
    --cc=felix.lechner@lease-up.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.