From nobody Mon Jan 17 09:35:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 81D0B195C569; Mon, 17 Jan 2022 09:35:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JcmwV173Nz3Kfg; Mon, 17 Jan 2022 09:35:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642412122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SLQ4xvX5gBpgVIiuBBLJvyul5GKcGJn5QoAUurV5LDE=; b=VRMLEDyT9A4Hsym7KsvvHZCkBE1WWBsNkVQJWV0O8dNowaXqy/Zrb+vhFPJSzx3EG4KchX 7LYv4z6ap62ONF4avMCK6XqHsYMZWajH2koWUl1sFMbCSWcUm0y825q4CWVGI9FDpHbQL9 +q7fwJftrFfjC7G5vb+hqL7CgmoKzsmC6rK2c2OXkfO54udWk1ZXr67cvt0JgTPoaJEgV0 w++0cdRzM3cQ9bXYWGAy8S6EVS/Hi+OA5GQQFcaFnQJyuFBBV1CV4BIs8KcydG8vV7lbtc At6PF0jsQDiIMYS9j4RT1nd0gZu++t+CfxuoRYYWz7CksotC6hUgcbV0S6xhrA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF372379F; Mon, 17 Jan 2022 09:35:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20H9ZLoI069524; Mon, 17 Jan 2022 09:35:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20H9ZLd4069523; Mon, 17 Jan 2022 09:35:21 GMT (envelope-from git) Date: Mon, 17 Jan 2022 09:35:21 GMT Message-Id: <202201170935.20H9ZLd4069523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 1f70a85b4cbc - main - linux: add sysctl to pass untranslated interface names List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1f70a85b4cbc3ad19cec4a390e8754e54815be85 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642412122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SLQ4xvX5gBpgVIiuBBLJvyul5GKcGJn5QoAUurV5LDE=; b=PzkAu0tk/Kkm58KV7VnrVuWQcVJqb58+lRiUodBEnRNyuwvgwWxlNr1ZwDbyzDZ7jZas8J JvjJh877xQnRJE7ZP2V0QkNRxsZ7ZfbvQXWGTItsargiCvkzRN5H5j+SLOjU/BPpvLjg4H vAMRLTXI2EVFKQVgBkR+dYLK3NgvuP0CHvQi6irasSp8C7F66S1BVOiJEktu3x3sDz0V67 SIsgQVmNavF2/tDcTEtdf7Q+U1PVDjyTHy/zDe4lqUgC04oyAblhzv2NjHrpX9tJRaUbDp oxcmDbPfEZJJTf85jJ+teUgiwn+vk1AhQH0dngHWDILAsQ4yHHbrSMGCEVfBzA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642412122; a=rsa-sha256; cv=none; b=a2qB2kwuVveEmUnfgaeBa7vZgh7AihQM9qzHqdCsyJrVc3EbHy+nXSZfSTXdgPNbH/Gli+ gIunL47bGB8fhFBzf+XW1vwC3VfbaVZuoihpON67CWI8G+xanypF8R3FtDf7QDtC60691l mxiJebirOZx7mzXk3mSm7JTcVWCe8aX6fODoD2N+jN6bRjTkNlyl1ozx6fgKTPUhRpQqeR eOulZTtX2kst+cO9PUZIug5il/pW9NUXuK7ribBS9AGgJAHhp6EbvErdZ0xoWMYkUaLGIy mHMgdJtB6DQnaydSGxud6qM8ehSFOntRTilX4wpaKz2yIcuoFfqcVy6fCJtvgg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=1f70a85b4cbc3ad19cec4a390e8754e54815be85 commit 1f70a85b4cbc3ad19cec4a390e8754e54815be85 Author: Alexander V. Chernikov AuthorDate: 2022-01-08 15:41:53 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-01-17 09:35:15 +0000 linux: add sysctl to pass untranslated interface names Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33792 --- sys/compat/linprocfs/linprocfs.c | 9 ++------- sys/compat/linux/linux.h | 6 ------ sys/compat/linux/linux_ioctl.c | 4 ++-- sys/compat/linux/linux_util.c | 15 +++++++++++++++ sys/compat/linux/linux_util.h | 9 +++++++++ sys/modules/linux_common/Makefile | 1 + 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 09144350a8ee..69da8f33a8f3 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1412,11 +1412,6 @@ linprocfs_doprocmem(PFS_FILL_ARGS) return (error); } -/* - * Criteria for interface name translation - */ -#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) - static int linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) { @@ -1426,7 +1421,7 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) IFNET_RLOCK_ASSERT(); /* Short-circuit non ethernet interfaces */ - if (!IFP_IS_ETH(ifp)) + if (linux_use_real_ifname(ifp)) return (strlcpy(buffer, ifp->if_xname, buflen)); /* Determine the (relative) unit number for ethernet interfaces */ @@ -1434,7 +1429,7 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) CK_STAILQ_FOREACH(ifscan, &V_ifnet, if_link) { if (ifscan == ifp) return (snprintf(buffer, buflen, "eth%d", ethno)); - if (IFP_IS_ETH(ifscan)) + if (!linux_use_real_ifname(ifscan)) ethno++; } diff --git a/sys/compat/linux/linux.h b/sys/compat/linux/linux.h index e75fbe773e61..f73a0484cf55 100644 --- a/sys/compat/linux/linux.h +++ b/sys/compat/linux/linux.h @@ -55,12 +55,6 @@ #define LINUX_IFHWADDRLEN 6 #define LINUX_IFNAMSIZ 16 -/* - * Criteria for interface name translation - */ -#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) -#define IFP_IS_LOOP(ifp) (ifp->if_type == IFT_LOOP) - struct l_sockaddr { unsigned short sa_family; char sa_data[14]; diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 12568b1666a3..ea391e56cd9a 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -2121,7 +2121,7 @@ linux_ioctl_ifname(struct thread *td, struct l_ifreq *uifr) error = ENODEV; CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifr.ifr_ifindex == index) { - if (IFP_IS_ETH(ifp)) + if (!linux_use_real_ifname(ifp)) snprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d", ethno); else @@ -2130,7 +2130,7 @@ linux_ioctl_ifname(struct thread *td, struct l_ifreq *uifr) error = 0; break; } - if (IFP_IS_ETH(ifp)) + if (!linux_use_real_ifname(ifp)) ethno++; index++; } diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index 35376db6063d..3fd88f291e11 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -50,6 +50,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include @@ -82,6 +86,11 @@ SYSCTL_STRING(_compat_linux, OID_AUTO, emul_path, CTLFLAG_RWTUN, linux_emul_path, sizeof(linux_emul_path), "Linux runtime environment path"); +static bool use_real_ifnames = false; +SYSCTL_BOOL(_compat_linux, OID_AUTO, use_real_ifnames, CTLFLAG_RWTUN, + &use_real_ifnames, 0, + "Use FreeBSD interface names instead of generating ethN aliases"); + /* * Search an alternate path before passing pathname arguments on to * system calls. Useful for keeping a separate 'emulation tree'. @@ -315,3 +324,9 @@ linux_device_unregister_handler(struct linux_device_handler *d) return (EINVAL); } + +bool +linux_use_real_ifname(const struct ifnet *ifp) +{ + return (use_real_ifnames || !IFP_IS_ETH(ifp)); +} diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h index 621b99afbff3..a29ba0bc4af1 100644 --- a/sys/compat/linux/linux_util.h +++ b/sys/compat/linux/linux_util.h @@ -120,6 +120,15 @@ int linux_vn_get_major_minor(const struct vnode *vn, int *major, int *minor); char *linux_get_char_devices(void); void linux_free_get_char_devices(char *string); +/* + * Criteria for interface name translation + */ +#define IFP_IS_ETH(ifp) ((ifp)->if_type == IFT_ETHER) +#define IFP_IS_LOOP(ifp) ((ifp)->if_type == IFT_LOOP) + +struct ifnet; +bool linux_use_real_ifname(const struct ifnet *ifp); + #if defined(KTR) #define KTR_LINUX KTR_SUBSYS diff --git a/sys/modules/linux_common/Makefile b/sys/modules/linux_common/Makefile index 9197ba9454bc..1815714e9202 100644 --- a/sys/modules/linux_common/Makefile +++ b/sys/modules/linux_common/Makefile @@ -11,6 +11,7 @@ EXPORT_SYMS= EXPORT_SYMS+= linux_emul_path EXPORT_SYMS+= linux_get_osname EXPORT_SYMS+= linux_get_osrelease +EXPORT_SYMS+= linux_use_real_ifname .if !defined(KERNBUILDDIR) .warning Building Linuxulator outside of a kernel does not make sense