From nobody Tue Feb 21 23:16:51 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 4PLwCm1PqTz3tcsh; Tue, 21 Feb 2023 23:16:52 +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 4PLwCm0wBrz4Sf3; Tue, 21 Feb 2023 23:16:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677021412; 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=BUGQABh+FXF/ROWiFMtfjZPaqG/xfpTHuUSUF8g6DQw=; b=NxHkO5/qhsoV7+o0YstPlNY8ZFyFBqQHVCrsCwYWJ+G3zmYFRwGAXvYc7FY4x0WSP4nkj1 jQyROgXHcqRB80uFAJ9LsfChWSetzmYpEjpWxYSPVWUNNWsKTcfxkGOA+YQ/+V3AFjjDE0 X+l/PNXQv2KEAYk5XrA/iIjh9BW36allko/++/ExNk5C1AhSYMszLyw4l+CcRebFpVAXKe unCQw8Ltp0bw542+QROpdSdLjXGjJOxixYdutOLgbyZft7XIjPTGop3jr7so/fJTQHm0Y2 c2qTaCSKBwVWlbKaJN3n/DLqMdpYYkEj9dqEwAeEyG36WChZ0T6l3YSjduFMpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677021412; 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=BUGQABh+FXF/ROWiFMtfjZPaqG/xfpTHuUSUF8g6DQw=; b=GoD30Q61YhgkEKBARLxP6s04CAQrclj4vA5AjkhPPaoFM+wY6Hb31lL4Zm8muJLdILoTtE TBwYOr4/M2b5xcmCC3BR7up+WYdInRLy0IABi0MqJRcNqK6nUbh7xGmbYDSpiNYASh6XU8 NFUb+B0i/fATn5yAD7jza8keCR+S08AGDZ7LCV13t4oqcBbzFAT18f5EBZvOuRauiF9FHZ 7eYsi0IkUmkhwDKUY+u/VWwOyr2FSmZOfYMWwsW1zijlF0F0CRIGkfYE5fqfqVEifXvB9I 7Jdzc2pb7uQ4Z2MSk7su+UwuRyk4ostPff88w6m5hSARoCZvCjSZ1JiOiV7Lcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677021412; a=rsa-sha256; cv=none; b=ru2MaQ7EldafJaPZotzc0fQLCIM2De95ZfSViQtCPlJoZrHERj2E+dDm8a8Or4wgoItvOi q1BrErLRKM/m1l9fyoKYTMXg1QHojq1SxL3Rbh5rrQU9NNGg2/jQNLVNJm8dZkPwBeg0V0 HHOQDRxqYB9HNyLwjY2joli+/E9rbOzFrxBIv/1MWkmp0gVPh9z8qJqgKs8GV8dhKJJ17A VxnKG0BiQwUTT6nwCDxPFwIDg9Q4ChQjkXbcBFhSSPyPCexkGcZOwjeo0sUgyumVOsHULT EHGVCLX9eUf6uqbr5p9P6/UKxu9pVVEerKCrxmwWLINU7JL9ISmO34ktpa8DRA== 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 4PLwCl74PRzfDY; Tue, 21 Feb 2023 23:16:51 +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 31LNGp9k011788; Tue, 21 Feb 2023 23:16:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31LNGpsp011787; Tue, 21 Feb 2023 23:16:51 GMT (envelope-from git) Date: Tue, 21 Feb 2023 23:16:51 GMT Message-Id: <202302212316.31LNGpsp011787@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 19850ee07363 - main - Revert "linprocfs: Migrate to IfAPI" 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: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 19850ee07363ffd97b4ba3c06361392ce9834440 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=19850ee07363ffd97b4ba3c06361392ce9834440 commit 19850ee07363ffd97b4ba3c06361392ce9834440 Author: Justin Hibbits AuthorDate: 2023-02-21 23:13:00 +0000 Commit: Justin Hibbits CommitDate: 2023-02-21 23:17:26 +0000 Revert "linprocfs: Migrate to IfAPI" This reverts commit 5243598927a95e77b3bb9804b049539b87353a5b. Requested by: dchagin --- sys/compat/linprocfs/linprocfs.c | 107 ++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 64 deletions(-) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index f2a8c5833c82..15c4d3c41749 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1474,79 +1474,26 @@ linprocfs_doprocmem(PFS_FILL_ARGS) return (error); } -struct linux_ifname_cb_s { - struct ifnet *ifp; - int ethno; - char *buffer; - size_t buflen; -}; - -static int -linux_ifname_cb(if_t ifp, void *arg) -{ - struct linux_ifname_cb_s *cbs = arg; - - if (ifp == cbs->ifp) - return (snprintf(cbs->buffer, cbs->buflen, "eth%d", cbs->ethno)); - if (!linux_use_real_ifname(ifp)) - cbs->ethno++; - return (0); -} - static int linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) { - struct linux_ifname_cb_s arg; + struct ifnet *ifscan; + int ethno; IFNET_RLOCK_ASSERT(); - arg.ifp = ifp; - arg.buffer = buffer; - arg.buflen = buflen; - arg.ethno = 0; - /* Short-circuit non ethernet interfaces */ if (linux_use_real_ifname(ifp)) - return (strlcpy(buffer, if_name(ifp), buflen)); + return (strlcpy(buffer, ifp->if_xname, buflen)); /* Determine the (relative) unit number for ethernet interfaces */ - return (if_foreach(linux_ifname_cb, &arg)); -} - -static int -linprocfs_donetdev_cb(if_t ifp, void *arg) -{ - char ifname[16]; /* XXX LINUX_IFNAMSIZ */ - struct sbuf *sb = arg; - - linux_ifname(ifp, ifname, sizeof ifname); - sbuf_printf(sb, "%6.6s: ", ifname); - sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ", - (uintmax_t )if_getcounter(ifp, IFCOUNTER_IBYTES), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_IPACKETS), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_IERRORS), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_IQDROPS), - /* rx_missed_errors */ - 0UL, /* rx_fifo_errors */ - 0UL, /* rx_length_errors + - * rx_over_errors + - * rx_crc_errors + - * rx_frame_errors */ - 0UL, /* rx_compressed */ - (uintmax_t )if_getcounter(ifp, IFCOUNTER_IMCASTS)); - /* XXX-BZ rx only? */ - sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n", - (uintmax_t )if_getcounter(ifp, IFCOUNTER_OBYTES), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_OPACKETS), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_OERRORS), - (uintmax_t )if_getcounter(ifp, IFCOUNTER_OQDROPS), - 0UL, /* tx_fifo_errors */ - (uintmax_t )if_getcounter(ifp, IFCOUNTER_COLLISIONS), - 0UL, /* tx_carrier_errors + - * tx_aborted_errors + - * tx_window_errors + - * tx_heartbeat_errors*/ - 0UL); /* tx_compressed */ + ethno = 0; + CK_STAILQ_FOREACH(ifscan, &V_ifnet, if_link) { + if (ifscan == ifp) + return (snprintf(buffer, buflen, "eth%d", ethno)); + if (!linux_use_real_ifname(ifscan)) + ethno++; + } return (0); } @@ -1557,6 +1504,9 @@ linprocfs_donetdev_cb(if_t ifp, void *arg) static int linprocfs_donetdev(PFS_FILL_ARGS) { + char ifname[16]; /* XXX LINUX_IFNAMSIZ */ + struct ifnet *ifp; + sbuf_printf(sb, "%6s|%58s|%s\n" "%6s|%58s|%58s\n", "Inter-", " Receive", " Transmit", @@ -1566,7 +1516,36 @@ linprocfs_donetdev(PFS_FILL_ARGS) CURVNET_SET(TD_TO_VNET(curthread)); IFNET_RLOCK(); - if_foreach(linprocfs_donetdev_cb, sb); + CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { + linux_ifname(ifp, ifname, sizeof ifname); + sbuf_printf(sb, "%6.6s: ", ifname); + sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ", + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IBYTES), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IERRORS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IQDROPS), + /* rx_missed_errors */ + 0UL, /* rx_fifo_errors */ + 0UL, /* rx_length_errors + + * rx_over_errors + + * rx_crc_errors + + * rx_frame_errors */ + 0UL, /* rx_compressed */ + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IMCASTS)); + /* XXX-BZ rx only? */ + sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n", + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OBYTES), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OERRORS), + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS), + 0UL, /* tx_fifo_errors */ + (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_COLLISIONS), + 0UL, /* tx_carrier_errors + + * tx_aborted_errors + + * tx_window_errors + + * tx_heartbeat_errors*/ + 0UL); /* tx_compressed */ + } IFNET_RUNLOCK(); CURVNET_RESTORE();