git: 11bd6ade5dfd - main - linux: switch off interface name translation and schedule its removal

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 07 Jul 2026 21:19:52 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=11bd6ade5dfdfb5160dd001542c4cfd44aed98bc

commit 11bd6ade5dfdfb5160dd001542c4cfd44aed98bc
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-07-07 21:19:17 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-07-07 21:19:17 +0000

    linux: switch off interface name translation and schedule its removal
    
    Modern Linuxes don't use ethX for almost 15 years already, see [1] and
    [2].  The translation logic has always been a source of bugs and PITA.
    Switch default to not translate (long due!) and schedule removal of the
    code for FreeBSD 17.
    
    [1] https://systemd.io/PREDICTABLE_INTERFACE_NAMES/
    [2] https://www.freedesktop.org/software/systemd/man/latest/systemd.net-naming-scheme.html
    
    Reviewed by:            iwtcex_gmail.com, vvd, melifaro, dchagin
    Differential Revision:  https://reviews.freebsd.org/D57852
---
 sys/compat/linux/linux_if.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linux/linux_if.c b/sys/compat/linux/linux_if.c
index ca4e3a4079ed..51a76aa13be3 100644
--- a/sys/compat/linux/linux_if.c
+++ b/sys/compat/linux/linux_if.c
@@ -44,9 +44,24 @@
 
 _Static_assert(LINUX_IFNAMSIZ == IFNAMSIZ, "Linux IFNAMSIZ");
 
-static bool use_real_ifnames = false;
-SYSCTL_BOOL(_compat_linux, OID_AUTO, use_real_ifnames, CTLFLAG_RWTUN,
-    &use_real_ifnames, 0,
+static bool use_real_ifnames = true;
+static int
+sysctl_linux_use_real_ifnames(SYSCTL_HANDLER_ARGS)
+{
+	int error;
+
+	error = sysctl_handle_bool(oidp, &use_real_ifnames, arg2, req);
+	if (error != 0 || req->newptr == NULL)
+		return (error);
+	if (!use_real_ifnames)
+		gone_in(17, "linux(4): %s: conversion of native interface "
+		    "names to ethN is not needed to emulate modern Linux. "
+		    "See https://systemd.io/PREDICTABLE_INTERFACE_NAMES. ",
+		    oidp->oid_name);
+	return (0);
+}
+SYSCTL_PROC(_compat_linux, OID_AUTO, use_real_ifnames,
+    CTLTYPE_U8 | CTLFLAG_RWTUN, 0, 0, sysctl_linux_use_real_ifnames, "CU",
     "Use FreeBSD interface names instead of generating ethN aliases");
 
 VNET_DEFINE_STATIC(struct unrhdr *, linux_eth_unr);