From nobody Tue Dec 05 16:18:01 2023 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 4Sl5L14jJJz539Zl; Tue, 5 Dec 2023 16:18:01 +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 4Sl5L14CjQz3L7p; Tue, 5 Dec 2023 16:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701793081; 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=J+nAJOaviU8TTRXoiFPhNtEiU8aWdAIJFoohyjVw5Hc=; b=aiZxcecuGKY927byC+2CBu/vtyRzCImtX6Mz46iQy50kvtIvzQm3SLf1hBQsXaOgiaor1/ LmxPUmlsgROlo1qxkcj576mvdfOX8Mzr8aCLwlkDfISxYJ0f/ZxoI/MdYuC4oXwmiyI8Fa jsT52dvtrKeCprGmlBFVUPQtaHHrl95W5BXwpRc8t1IoJQKh9SGPopPnVvqWbCX9h0zQxd 9IMR8atMokeNKGKH0Ddyso/x0Nxd+206yySbgB80iXbYbKffUUQh9YkXNIXhA7s4YdkOpb Ch2V0FaVSon4z9mFdcI1XtxbZVDb40E25OqYWoq3Z1uR+HWOMiI/7Wew7P51iQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701793081; a=rsa-sha256; cv=none; b=PTXZYsUVksSJ3ZPcwbRWcVuiMcmpKERX6U/fJ0pWr5uhixjv3eNxKEvJPxC4iGRKxXT/pq h+I+EEpG1AZcL7Fhl/wIKen0P4hYvq8+haT/CmjJSeS5IjJE7OfoppNONbv/PY8GE5zWLr icLNbRbvN444Hc8qnKscwDhsx3N8bx6ct+lYAHnFaHe161JVaWirhiHRcftkwo81eM+iV4 N+Gf8S44AM6C7pwt93mdeZHQyU7LlywIX8chJd9f9TPH/fQcLhHxfrRrfDGdiZFcI/+6Vz OLD6/jnFCZrDSUOXWMkPA4i4cmivBDHuNAckYfwXG1NlQKvyTyi85K09EWxdcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701793081; 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=J+nAJOaviU8TTRXoiFPhNtEiU8aWdAIJFoohyjVw5Hc=; b=KPsVaDHIQGO5P3eTT39dXUD2V8ogQx0kVp4exWJlyjqgajOm24arMSstZCOZ3MGvlYMNHr wATVmJzdOzSIQgU0LkuBiHCeAW9mDrIdKpksvmjHPox47dOhAGFcahe+83wyjwj9Sowwsh ettnHwn2kXCwwLGS/g4yzK09YsccG1C+CZISQTu0nYuP8gDJ2o2SxkDavmq0Z2ZILq9bLi om+4R1PQVuP0hec8baFXgUq6qycirv8/jLaN+uGHJ+pOxlfwrMuNskXmCyD/aMkgtOT65A pdDeVzKKUpo1Th0Jjb7QR3PIxx7zKy9qAB6F+VCbRakp8bYvmGgDeKHuwPU4Ag== 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 4Sl5L13Gzvz1Xv; Tue, 5 Dec 2023 16:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B5GI1sT089587; Tue, 5 Dec 2023 16:18:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B5GI1aR089584; Tue, 5 Dec 2023 16:18:01 GMT (envelope-from git) Date: Tue, 5 Dec 2023 16:18:01 GMT Message-Id: <202312051618.3B5GI1aR089584@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mike Karels Subject: git: 9b8515f71bd4 - stable/14 - ifconfig: add -D option to print driver name for interface 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: karels X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9b8515f71bd413520ba7d8e2b92a60deb2c7a528 Auto-Submitted: auto-generated The branch stable/14 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=9b8515f71bd413520ba7d8e2b92a60deb2c7a528 commit 9b8515f71bd413520ba7d8e2b92a60deb2c7a528 Author: Mike Karels AuthorDate: 2023-11-28 19:47:37 +0000 Commit: Mike Karels CommitDate: 2023-12-05 16:17:47 +0000 ifconfig: add -D option to print driver name for interface Add -D option to add the drivername and unit number to ifconfig output for normal display, including -a. Use ifconfig_get_orig_name() from libifconfig to fetch the name. Note that this is the original name for many drivers, but not for some exceptions like epair (which appends 'a' or 'b' to the unit number). epair interface pairs both display as "epair0", etc. Make -v imply -D; might as well be fully verbose. Reviewed by: zlei, kp Differential Revision: https://reviews.freebsd.org/D42721 (cherry picked from commit cd201c090858e5cfae3be005453ec634c1fca36a) --- sbin/ifconfig/ifconfig.8 | 10 ++++++++-- sbin/ifconfig/ifconfig.c | 5 ++++- sbin/ifconfig/ifconfig.h | 1 + sbin/ifconfig/ifconfig_netlink.c | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 3b1774606b21..a538981608cd 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -36,7 +36,7 @@ .Sh SYNOPSIS .Nm .Op Fl j Ar jail -.Op Fl kLmn +.Op Fl DkLmn .Op Fl f Ar type Ns Cm \&: Ns Ar format .Ar interface .Op Cm create @@ -55,7 +55,7 @@ .Nm .Op Fl j Ar jail .Fl a -.Op Fl dkLmuv +.Op Fl dDkLmuv .Op Fl f Ar type Ns Cm \&: Ns Ar format .Op Fl G Ar groupname .Op Fl g Ar groupname @@ -104,6 +104,12 @@ with no additional information. Use of this flag is mutually exclusive with all other flags and commands. .It Fl d Display only the interfaces that are down. +.It Fl D +Include the driver name and unit number of the interface in the output. +This is normally the original name of the interface, +even if it has been renamed; it may differ from the original name +in some cases, such as +.Xr epair 4 . .It Fl f Xo .Ar type Ns Cm \&: Ns Ar format Ns .Op Cm \&, Ns Ar type Ns Cm \&: Ns Ar format Ar ... diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 1a7823fedd67..7a78e9a934f7 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -465,7 +465,7 @@ args_parse(struct ifconfig_args *args, int argc, char *argv[]) int c; /* Parse leading line options */ - strlcpy(options, "G:adf:j:klmnuv", sizeof(options)); + strlcpy(options, "G:adDf:j:klmnuv", sizeof(options)); for (p = opts; p != NULL; p = p->next) strlcat(options, p->opt, sizeof(options)); while ((c = getopt(argc, argv, options)) != -1) { @@ -476,6 +476,9 @@ args_parse(struct ifconfig_args *args, int argc, char *argv[]) case 'd': /* restrict scan to "down" interfaces */ args->downonly = true; break; + case 'D': /* Print driver name */ + args->drivername = true; + break; case 'f': if (optarg == NULL) usage(); diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 80e6b9bc2289..0ae317aca409 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -230,6 +230,7 @@ struct ifconfig_args { bool supmedia; /* Supported media */ bool printkeys; /* Print security keys */ bool allfamilies; /* Print all families */ + bool drivername; /* Print driver name */ int verbose; /* verbosity level */ int argc; char **argv; diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c index 7be340e18ab5..bb0d242f21f6 100644 --- a/sbin/ifconfig/ifconfig_netlink.c +++ b/sbin/ifconfig/ifconfig_netlink.c @@ -369,6 +369,7 @@ status_nl(if_ctx *ctx, struct iface *iface) { if_link_t *link = &iface->link; struct ifconfig_args *args = ctx->args; + char *drivername = NULL; printf("%s: ", link->ifla_ifname); @@ -413,6 +414,22 @@ status_nl(if_ctx *ctx, struct iface *iface) args->afp->af_other_status(ctx); print_ifstatus(ctx); + if (args->drivername || args->verbose) { + if (ifconfig_get_orig_name(lifh, link->ifla_ifname, + &drivername) != 0) { + if (ifconfig_err_errtype(lifh) == OTHER) + fprintf(stderr, "get original name: %s\n", + strerror(ifconfig_err_errno(lifh))); + else + fprintf(stderr, + "get original name: error type %d\n", + ifconfig_err_errtype(lifh)); + exit_code = 1; + } + if (drivername != NULL) + printf("\tdrivername: %s\n", drivername); + free(drivername); + } if (args->verbose > 0) sfp_status(ctx); }