From owner-dev-commits-src-all@freebsd.org Mon May 10 00:58:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C7CC647484; Mon, 10 May 2021 00:58:48 +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 4FdjNm1jg1z4YPP; Mon, 10 May 2021 00:58:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 294111B44F; Mon, 10 May 2021 00:58:48 +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 14A0wmQC001692; Mon, 10 May 2021 00:58:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0wm0e001691; Mon, 10 May 2021 00:58:48 GMT (envelope-from git) Date: Mon, 10 May 2021 00:58:48 GMT Message-Id: <202105100058.14A0wm0e001691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c2bea64e7c06 - stable/12 - ifconfig: Minor documentation fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c2bea64e7c06afd951d77f8c723b7a11db31b0cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:58:48 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c2bea64e7c06afd951d77f8c723b7a11db31b0cc commit c2bea64e7c06afd951d77f8c723b7a11db31b0cc Author: Jose Luis Duran AuthorDate: 2021-04-29 11:03:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:58:25 +0000 ifconfig: Minor documentation fix PR: 255557 (cherry picked from commit 0ea8a7f36db31bfc550bbe5e39703fdedd12fa8c) --- sbin/ifconfig/ifconfig.8 | 6 +++--- sys/net/ethernet.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 9c1a672c70e2..00ec525490aa 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd December 1, 2020 +.Dd April 29, 2021 .Dt IFCONFIG 8 .Os .Sh NAME @@ -2658,9 +2658,9 @@ Values in order of priority are: .Cm 3 .Pq Dv Critical applications , .Cm 4 -.Pq Dv Video, < 100ms latency , +.Pq Dv Video, < 100ms latency and jitter , .Cm 5 -.Pq Dv Video, < 10ms latency , +.Pq Dv Voice, < 10ms latency and jitter , .Cm 6 .Pq Dv Internetwork control , .Cm 7 diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 1f718e6e69d2..68ead710e595 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -411,8 +411,8 @@ struct ether_vlan_header { #define IEEE8021Q_PCP_BE 0 /* Best effort (default) */ #define IEEE8021Q_PCP_EE 2 /* Excellent effort */ #define IEEE8021Q_PCP_CA 3 /* Critical applications */ -#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency */ -#define IEEE8021Q_PCP_VO 5 /* Video, < 10ms latency */ +#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency and jitter */ +#define IEEE8021Q_PCP_VO 5 /* Voice, < 10ms latency and jitter */ #define IEEE8021Q_PCP_IC 6 /* Internetwork control */ #define IEEE8021Q_PCP_NC 7 /* Network control (highest) */ From owner-dev-commits-src-all@freebsd.org Mon May 10 00:58:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A50EB64722A; Mon, 10 May 2021 00:58:49 +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 4FdjNn2Zfbz4Y2t; Mon, 10 May 2021 00:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4B0ED1B917; Mon, 10 May 2021 00:58:49 +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 14A0wnhl001714; Mon, 10 May 2021 00:58:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0wnsm001713; Mon, 10 May 2021 00:58:49 GMT (envelope-from git) Date: Mon, 10 May 2021 00:58:49 GMT Message-Id: <202105100058.14A0wnsm001713@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 87781d3962a8 - stable/12 - uart_bus_pci.c: Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 87781d3962a8f22a8fef5e1c13dd4a8c36bed220 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:58:49 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=87781d3962a8f22a8fef5e1c13dd4a8c36bed220 commit 87781d3962a8f22a8fef5e1c13dd4a8c36bed220 Author: Jose Luis Duran AuthorDate: 2021-05-02 21:20:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:58:25 +0000 uart_bus_pci.c: Style PR: 255556 (cherry picked from commit 5b8b6b26e40a81320f02a46df98b96bd8e93295a) --- sys/dev/uart/uart_bus_pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index ddf5561b0410..a00b884046c7 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -135,12 +135,13 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x108f, 0xffff, 0, "Intel AMT - SOL", 0x10 }, { 0x8086, 0x19d8, 0xffff, 0, "Intel Denverton UART", 0x10 }, { 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 }, -{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", 0x10 }, +{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", + 0x10 }, { 0x8086, 0x1e3d, 0xffff, 0, "Intel Panther Point KT Controller", 0x10 }, { 0x8086, 0x228a, 0xffff, 0, "Intel Cherryview SIO HSUART#1", 0x10, - 24 * DEFAULT_RCLK, 2 }, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x228c, 0xffff, 0, "Intel Cherryview SIO HSUART#2", 0x10, - 24 * DEFAULT_RCLK, 2 }, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x2a07, 0xffff, 0, "Intel AMT - PM965/GM965 KT Controller", 0x10 }, { 0x8086, 0x2a47, 0xffff, 0, "Mobile 4 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, From owner-dev-commits-src-all@freebsd.org Mon May 10 00:58:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 91778647504; Mon, 10 May 2021 00:58:50 +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 4FdjNp3V6pz4Y7x; Mon, 10 May 2021 00:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 68B781B661; Mon, 10 May 2021 00:58:50 +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 14A0worA001735; Mon, 10 May 2021 00:58:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0woQb001734; Mon, 10 May 2021 00:58:50 GMT (envelope-from git) Date: Mon, 10 May 2021 00:58:50 GMT Message-Id: <202105100058.14A0woQb001734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 765f31a86876 - stable/12 - Add Apollo Lake SIO/LPSS UARTs PCI IDs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 765f31a86876aae85e3ba1da95ea6053720e9b31 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:58:50 -0000 The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=765f31a86876aae85e3ba1da95ea6053720e9b31 commit 765f31a86876aae85e3ba1da95ea6053720e9b31 Author: Jose Luis Duran AuthorDate: 2021-05-02 21:20:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:58:25 +0000 Add Apollo Lake SIO/LPSS UARTs PCI IDs PR: 255556 (cherry picked from commit 8f1562430fbb83f6cedff6450e1aa1b593e3d7e7) --- sys/dev/uart/uart_bus_pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index a00b884046c7..4de2299488cf 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -147,6 +147,14 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, { 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller", 0x10 }, +{ 0x8086, 0x5abc, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 0", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5abe, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 1", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5ac0, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 2", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5aee, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 3", 0x10, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x8811, 0xffff, 0, "Intel EG20T Serial Port 0", 0x10 }, { 0x8086, 0x8812, 0xffff, 0, "Intel EG20T Serial Port 1", 0x10 }, { 0x8086, 0x8813, 0xffff, 0, "Intel EG20T Serial Port 2", 0x10 }, From owner-dev-commits-src-all@freebsd.org Mon May 10 00:59:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 116E964706B; Mon, 10 May 2021 00:59:13 +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 4FdjPD6l7Xz4Y3H; Mon, 10 May 2021 00:59:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DA4D91B3DC; Mon, 10 May 2021 00:59:12 +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 14A0xCwc001916; Mon, 10 May 2021 00:59:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0xCf4001915; Mon, 10 May 2021 00:59:12 GMT (envelope-from git) Date: Mon, 10 May 2021 00:59:12 GMT Message-Id: <202105100059.14A0xCf4001915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: fbf613c93fd2 - stable/13 - filt_timerexpire: do not iterate over the interval MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fbf613c93fd2db057b7f80917556228998ba720b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:59:13 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fbf613c93fd2db057b7f80917556228998ba720b commit fbf613c93fd2db057b7f80917556228998ba720b Author: Konstantin Belousov AuthorDate: 2021-04-28 16:28:49 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:47:35 +0000 filt_timerexpire: do not iterate over the interval (cherry picked from commit 7cb40543e96451092d5bc6bb3d96ebee364327e0) --- sys/kern/kern_event.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 45d505fca757..03f4b3afbc28 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -718,6 +718,7 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) { struct kq_timer_cb_data *kc; struct proc *p; + uint64_t delta; sbintime_t now; kc = kn->kn_ptr.p_v; @@ -728,9 +729,17 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) return; } - for (now = sbinuptime(); kc->next <= now; kc->next += kc->to) - kn->kn_data++; - KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */ + now = sbinuptime(); + if (now >= kc->next) { + delta = (now - kc->next) / kc->to; + if (delta == 0) + delta = 1; + kn->kn_data += delta; + kc->next += (delta + 1) * kc->to; + if (now >= kc->next) /* overflow */ + kc->next = now + kc->to; + KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */ + } /* * Initial check for stopped kc->p is racy. It is fine to From owner-dev-commits-src-all@freebsd.org Mon May 10 00:59:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4BA7664723E; Mon, 10 May 2021 00:59:14 +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 4FdjPG1bpsz4YXx; Mon, 10 May 2021 00:59:14 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1ED311B8F8; Mon, 10 May 2021 00:59:14 +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 14A0xDdX001937; Mon, 10 May 2021 00:59:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0xDde001936; Mon, 10 May 2021 00:59:13 GMT (envelope-from git) Date: Mon, 10 May 2021 00:59:13 GMT Message-Id: <202105100059.14A0xDde001936@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e0c2f8156cc6 - stable/13 - ifconfig: Minor documentation fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e0c2f8156cc6868f83ab2e4c44f92393b5fb0c0a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:59:14 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e0c2f8156cc6868f83ab2e4c44f92393b5fb0c0a commit e0c2f8156cc6868f83ab2e4c44f92393b5fb0c0a Author: Jose Luis Duran AuthorDate: 2021-04-29 11:03:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:48:05 +0000 ifconfig: Minor documentation fix PR: 255557 (cherry picked from commit 0ea8a7f36db31bfc550bbe5e39703fdedd12fa8c) --- sbin/ifconfig/ifconfig.8 | 6 +++--- sys/net/ethernet.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index b8adad3c75b0..f183bc3dd66f 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd January 28, 2021 +.Dd April 29, 2021 .Dt IFCONFIG 8 .Os .Sh NAME @@ -2729,9 +2729,9 @@ Values in order of priority are: .Cm 3 .Pq Dv Critical applications , .Cm 4 -.Pq Dv Video, < 100ms latency , +.Pq Dv Video, < 100ms latency and jitter , .Cm 5 -.Pq Dv Video, < 10ms latency , +.Pq Dv Voice, < 10ms latency and jitter , .Cm 6 .Pq Dv Internetwork control , .Cm 7 diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index f174ca9eb143..9a80a6db794f 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -416,8 +416,8 @@ struct ether_vlan_header { #define IEEE8021Q_PCP_BE 0 /* Best effort (default) */ #define IEEE8021Q_PCP_EE 2 /* Excellent effort */ #define IEEE8021Q_PCP_CA 3 /* Critical applications */ -#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency */ -#define IEEE8021Q_PCP_VO 5 /* Video, < 10ms latency */ +#define IEEE8021Q_PCP_VI 4 /* Video, < 100ms latency and jitter */ +#define IEEE8021Q_PCP_VO 5 /* Voice, < 10ms latency and jitter */ #define IEEE8021Q_PCP_IC 6 /* Internetwork control */ #define IEEE8021Q_PCP_NC 7 /* Network control (highest) */ From owner-dev-commits-src-all@freebsd.org Mon May 10 00:59:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5997647442; Mon, 10 May 2021 00:59:15 +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 4FdjPH2Y0mz4Y3J; Mon, 10 May 2021 00:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3F97E1B662; Mon, 10 May 2021 00:59:15 +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 14A0xFqF001966; Mon, 10 May 2021 00:59:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0xFj3001963; Mon, 10 May 2021 00:59:15 GMT (envelope-from git) Date: Mon, 10 May 2021 00:59:15 GMT Message-Id: <202105100059.14A0xFj3001963@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2fb889b52071 - stable/13 - uart_bus_pci.c: Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2fb889b52071868e1da08251cce93a9d42edbb7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:59:15 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2fb889b52071868e1da08251cce93a9d42edbb7e commit 2fb889b52071868e1da08251cce93a9d42edbb7e Author: Jose Luis Duran AuthorDate: 2021-05-02 21:20:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:50:02 +0000 uart_bus_pci.c: Style PR: 255556 (cherry picked from commit 5b8b6b26e40a81320f02a46df98b96bd8e93295a) --- sys/dev/uart/uart_bus_pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index fbd1d68b88ca..123ee3e26829 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -135,12 +135,13 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x108f, 0xffff, 0, "Intel AMT - SOL", 0x10 }, { 0x8086, 0x19d8, 0xffff, 0, "Intel Denverton UART", 0x10 }, { 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 }, -{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", 0x10 }, +{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", + 0x10 }, { 0x8086, 0x1e3d, 0xffff, 0, "Intel Panther Point KT Controller", 0x10 }, { 0x8086, 0x228a, 0xffff, 0, "Intel Cherryview SIO HSUART#1", 0x10, - 24 * DEFAULT_RCLK, 2 }, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x228c, 0xffff, 0, "Intel Cherryview SIO HSUART#2", 0x10, - 24 * DEFAULT_RCLK, 2 }, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x2a07, 0xffff, 0, "Intel AMT - PM965/GM965 KT Controller", 0x10 }, { 0x8086, 0x2a47, 0xffff, 0, "Mobile 4 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, From owner-dev-commits-src-all@freebsd.org Mon May 10 00:59:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 744E9647444; Mon, 10 May 2021 00:59:16 +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 4FdjPJ2kzQz4Yb5; Mon, 10 May 2021 00:59:16 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4E12B1B919; Mon, 10 May 2021 00:59:16 +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 14A0xGOx001990; Mon, 10 May 2021 00:59:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A0xGcY001989; Mon, 10 May 2021 00:59:16 GMT (envelope-from git) Date: Mon, 10 May 2021 00:59:16 GMT Message-Id: <202105100059.14A0xGcY001989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b316c016e195 - stable/13 - Add Apollo Lake SIO/LPSS UARTs PCI IDs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b316c016e1958a8274133fdefc1251329beb8b42 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 00:59:16 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b316c016e1958a8274133fdefc1251329beb8b42 commit b316c016e1958a8274133fdefc1251329beb8b42 Author: Jose Luis Duran AuthorDate: 2021-05-02 21:20:25 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 00:50:08 +0000 Add Apollo Lake SIO/LPSS UARTs PCI IDs PR: 255556 (cherry picked from commit 8f1562430fbb83f6cedff6450e1aa1b593e3d7e7) --- sys/dev/uart/uart_bus_pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index 123ee3e26829..707b82dc078b 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -147,6 +147,14 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, { 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller", 0x10 }, +{ 0x8086, 0x5abc, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 0", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5abe, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 1", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5ac0, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 2", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x5aee, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 3", 0x10, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x8811, 0xffff, 0, "Intel EG20T Serial Port 0", 0x10 }, { 0x8086, 0x8812, 0xffff, 0, "Intel EG20T Serial Port 1", 0x10 }, { 0x8086, 0x8813, 0xffff, 0, "Intel EG20T Serial Port 2", 0x10 }, From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D7C4762809F; Mon, 10 May 2021 01:14:46 +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 4FdjlB5fvpz4ZDH; Mon, 10 May 2021 01:14:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B53261B97A; Mon, 10 May 2021 01:14:46 +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 14A1EkN3028581; Mon, 10 May 2021 01:14:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1EkUb028580; Mon, 10 May 2021 01:14:46 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:46 GMT Message-Id: <202105100114.14A1EkUb028580@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 69130fd57abb - stable/13 - imgact_elf: consistently pass flags from coredump down to helper functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 69130fd57abb744154bfac64dcb8a7986b016f10 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:46 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=69130fd57abb744154bfac64dcb8a7986b016f10 commit 69130fd57abb744154bfac64dcb8a7986b016f10 Author: Konstantin Belousov AuthorDate: 2021-04-24 11:42:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:10 +0000 imgact_elf: consistently pass flags from coredump down to helper functions (cherry picked from commit 5bc3c61780d775810eea852936671ca4a232b2a8) --- sys/kern/imgact_elf.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index c4aedbe6bbfa..77045842a13c 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1471,12 +1471,13 @@ static void cb_put_phdr(vm_map_entry_t, void *); static void cb_size_segment(vm_map_entry_t, void *); static int core_write(struct coredump_params *, const void *, size_t, off_t, enum uio_seg, size_t *); -static void each_dumpable_segment(struct thread *, segment_callback, void *); +static void each_dumpable_segment(struct thread *, segment_callback, void *, + int); static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t, - struct note_info_list *, size_t); + struct note_info_list *, size_t, int); static void __elfN(prepare_notes)(struct thread *, struct note_info_list *, size_t *); -static void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t); +static void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int); static void __elfN(putnote)(struct note_info *, struct sbuf *); static size_t register_note(struct note_info_list *, int, outfunc_t, void *); static int sbuf_drain_core_output(void *, const char *, int); @@ -1669,7 +1670,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) /* Size the program segments. */ seginfo.count = 0; seginfo.size = 0; - each_dumpable_segment(td, cb_size_segment, &seginfo); + each_dumpable_segment(td, cb_size_segment, &seginfo, flags); /* * Collect info about the core file header area. @@ -1722,7 +1723,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) */ hdr = malloc(hdrsize, M_TEMP, M_WAITOK); error = __elfN(corehdr)(¶ms, seginfo.count, hdr, hdrsize, ¬elst, - notesz); + notesz, flags); /* Write the contents of all of the writable segments. */ if (error == 0) { @@ -1806,7 +1807,8 @@ cb_size_segment(vm_map_entry_t entry, void *closure) * caller-supplied data. */ static void -each_dumpable_segment(struct thread *td, segment_callback func, void *closure) +each_dumpable_segment(struct thread *td, segment_callback func, void *closure, + int flags) { struct proc *p = td->td_proc; vm_map_t map = &p->p_vmspace->vm_map; @@ -1867,7 +1869,8 @@ each_dumpable_segment(struct thread *td, segment_callback func, void *closure) */ static int __elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr, - size_t hdrsize, struct note_info_list *notelst, size_t notesz) + size_t hdrsize, struct note_info_list *notelst, size_t notesz, + int flags) { struct note_info *ninfo; struct sbuf *sb; @@ -1875,7 +1878,7 @@ __elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr, /* Fill in the header. */ bzero(hdr, hdrsize); - __elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz); + __elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz, flags); sb = sbuf_new(NULL, NULL, CORE_BUF_SIZE, SBUF_FIXEDLEN); sbuf_set_drain(sb, sbuf_drain_core_output, p); @@ -1953,7 +1956,7 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list, static void __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs, - size_t notesz) + size_t notesz, int flags) { Elf_Ehdr *ehdr; Elf_Phdr *phdr; @@ -2032,7 +2035,7 @@ __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs, /* All the writable segments from the program. */ phc.phdr = phdr; phc.offset = round_page(hdrsize + notesz); - each_dumpable_segment(td, cb_put_phdr, &phc); + each_dumpable_segment(td, cb_put_phdr, &phc, flags); } static size_t From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 171D2647EE6; Mon, 10 May 2021 01:14:48 +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 4FdjlD01rNz4ZDL; Mon, 10 May 2021 01:14:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E1CC51BC90; Mon, 10 May 2021 01:14:47 +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 14A1ElbL028603; Mon, 10 May 2021 01:14:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1ElWl028602; Mon, 10 May 2021 01:14:47 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:47 GMT Message-Id: <202105100114.14A1ElWl028602@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 969dcc5f49af - stable/13 - ELF coredump: define several useful flags for the coredump operations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 969dcc5f49af783a91a1e1744b06518c0dd49670 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:48 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=969dcc5f49af783a91a1e1744b06518c0dd49670 commit 969dcc5f49af783a91a1e1744b06518c0dd49670 Author: Konstantin Belousov AuthorDate: 2021-04-24 11:45:01 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:16 +0000 ELF coredump: define several useful flags for the coredump operations (cherry picked from commit 86ffb3d1a0cbb09ba0123ff8d34149e691b461c4) --- sys/kern/imgact_elf.c | 31 ++++++++++++++++++++----------- sys/sys/sysent.h | 5 +++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 77045842a13c..563629b747b5 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1655,7 +1655,7 @@ int __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) { struct ucred *cred = td->td_ucred; - int error = 0; + int compm, error = 0; struct sseg_closure seginfo; struct note_info_list notelst; struct coredump_params params; @@ -1706,9 +1706,13 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) } /* Create a compression stream if necessary. */ - if (compress_user_cores != 0) { + compm = compress_user_cores; + if ((flags & (SVC_PT_COREDUMP | SVC_NOCOMPRESS)) == SVC_PT_COREDUMP && + compm == 0) + compm = COMPRESS_GZIP; + if (compm != 0) { params.comp = compressor_init(core_compressed_write, - compress_user_cores, CORE_BUF_SIZE, + compm, CORE_BUF_SIZE, compress_user_cores_level, ¶ms); if (params.comp == NULL) { error = EFAULT; @@ -1826,12 +1830,15 @@ each_dumpable_segment(struct thread *td, segment_callback func, void *closure, * are marked MAP_ENTRY_NOCOREDUMP now so we no longer * need to arbitrarily ignore such segments. */ - if (elf_legacy_coredump) { - if ((entry->protection & VM_PROT_RW) != VM_PROT_RW) - continue; - } else { - if ((entry->protection & VM_PROT_ALL) == 0) - continue; + if ((flags & SVC_ALL) == 0) { + if (elf_legacy_coredump) { + if ((entry->protection & VM_PROT_RW) != + VM_PROT_RW) + continue; + } else { + if ((entry->protection & VM_PROT_ALL) == 0) + continue; + } } /* @@ -1840,9 +1847,11 @@ each_dumpable_segment(struct thread *td, segment_callback func, void *closure, * madvise(2). Do not dump submaps (i.e. parts of the * kernel map). */ - if (entry->eflags & (MAP_ENTRY_NOCOREDUMP|MAP_ENTRY_IS_SUB_MAP)) + if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) + continue; + if ((entry->eflags & MAP_ENTRY_NOCOREDUMP) != 0 && + (flags & SVC_ALL) == 0) continue; - if ((object = entry->object.vm_object) == NULL) continue; diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index db729239243f..e6db2ec3dfb1 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -171,6 +171,11 @@ struct sysentvec { #define SV_ABI_CLOUDABI 17 #define SV_ABI_UNDEF 255 +/* sv_coredump flags */ +#define SVC_PT_COREDUMP 0x00000001 /* dump requested by ptrace(2) */ +#define SVC_NOCOMPRESS 0x00000002 /* disable compression. */ +#define SVC_ALL 0x00000004 /* dump everything */ + #ifdef _KERNEL extern struct sysentvec aout_sysvec; extern struct sysent sysent[]; From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7248C647EE8; Mon, 10 May 2021 01:14:49 +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 4FdjlF2CWCz4ZK0; Mon, 10 May 2021 01:14:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0C5841BC91; Mon, 10 May 2021 01:14:49 +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 14A1Emlo028624; Mon, 10 May 2021 01:14:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1EmJa028623; Mon, 10 May 2021 01:14:48 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:48 GMT Message-Id: <202105100114.14A1EmJa028623@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5771601bf45a - stable/13 - Add sleepq_remove_nested() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5771601bf45a29b5330faa22dfcd15c91360fb07 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:49 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5771601bf45a29b5330faa22dfcd15c91360fb07 commit 5771601bf45a29b5330faa22dfcd15c91360fb07 Author: Konstantin Belousov AuthorDate: 2021-04-25 00:01:32 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:23 +0000 Add sleepq_remove_nested() (cherry picked from commit 15465a2c25cc2915e8c7c65178805b10e339dde3) --- sys/kern/subr_sleepqueue.c | 20 ++++++++++++++++++++ sys/sys/sleepqueue.h | 1 + 2 files changed, 21 insertions(+) diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index 20ca455480b5..0718f01fa48a 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -854,6 +854,26 @@ sleepq_remove_thread(struct sleepqueue *sq, struct thread *td) (void *)td, (long)td->td_proc->p_pid, td->td_name); } +void +sleepq_remove_nested(struct thread *td) +{ + struct sleepqueue_chain *sc; + struct sleepqueue *sq; + const void *wchan; + + MPASS(TD_ON_SLEEPQ(td)); + + wchan = td->td_wchan; + sc = SC_LOOKUP(wchan); + mtx_lock_spin(&sc->sc_lock); + sq = sleepq_lookup(wchan); + MPASS(sq != NULL); + thread_lock(td); + sleepq_remove_thread(sq, td); + mtx_unlock_spin(&sc->sc_lock); + /* Returns with the thread lock owned. */ +} + #ifdef INVARIANTS /* * UMA zone item deallocator. diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h index ba2f85f2c8a1..18c7568777b6 100644 --- a/sys/sys/sleepqueue.h +++ b/sys/sys/sleepqueue.h @@ -100,6 +100,7 @@ void sleepq_release(const void *wchan); void sleepq_remove(struct thread *td, const void *wchan); int sleepq_remove_matching(struct sleepqueue *sq, int queue, bool (*matches)(struct thread *), int pri); +void sleepq_remove_nested(struct thread *td); int sleepq_signal(const void *wchan, int flags, int pri, int queue); void sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt, sbintime_t pr, int flags); From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6730E62803A; Mon, 10 May 2021 01:14:50 +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 4FdjlG28y7z4ZK3; Mon, 10 May 2021 01:14:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 362C41B7E3; Mon, 10 May 2021 01:14:50 +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 14A1Eo7B028645; Mon, 10 May 2021 01:14:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1Eoic028644; Mon, 10 May 2021 01:14:50 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:50 GMT Message-Id: <202105100114.14A1Eoic028644@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8e1c74210cec - stable/13 - Add thread_run_flash() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8e1c74210cec0b81318b6f90648cb0e9387244ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:50 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8e1c74210cec0b81318b6f90648cb0e9387244ad commit 8e1c74210cec0b81318b6f90648cb0e9387244ad Author: Konstantin Belousov AuthorDate: 2021-04-24 11:47:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:28 +0000 Add thread_run_flash() helper (cherry picked from commit af928fded0705100e4f3926c99ed488f7ab6dcf1) --- sys/kern/kern_thread.c | 25 +++++++++++++++++++++++++ sys/sys/proc.h | 1 + 2 files changed, 26 insertions(+) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 3561895d9fff..c16b6dd3c791 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1514,6 +1514,31 @@ thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary) return (setrunnable(td, 0)); } +void +thread_run_flash(struct thread *td) +{ + struct proc *p; + + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (TD_ON_SLEEPQ(td)) + sleepq_remove_nested(td); + else + thread_lock(td); + + THREAD_LOCK_ASSERT(td, MA_OWNED); + KASSERT(TD_IS_SUSPENDED(td), ("Thread not suspended")); + + TD_CLR_SUSPENDED(td); + PROC_SLOCK(p); + MPASS(p->p_suspcount > 0); + p->p_suspcount--; + PROC_SUNLOCK(p); + if (setrunnable(td, 0)) + kick_proc0(); +} + /* * Allow all threads blocked by single threading to continue running. */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 3e5a96185e0c..9de7be4628dd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1179,6 +1179,7 @@ void thread_stopped(struct proc *p); void childproc_stopped(struct proc *child, int reason); void childproc_continued(struct proc *child); void childproc_exited(struct proc *child); +void thread_run_flash(struct thread *td); int thread_suspend_check(int how); bool thread_suspend_check_needed(void); void thread_suspend_switch(struct thread *, struct proc *p); From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE3DA62828B; Mon, 10 May 2021 01:14:51 +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 4FdjlH4Jhnz4ZVf; Mon, 10 May 2021 01:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 597341BDB0; Mon, 10 May 2021 01:14: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 14A1EpkN028666; Mon, 10 May 2021 01:14:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1Ep3F028665; Mon, 10 May 2021 01:14:51 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:51 GMT Message-Id: <202105100114.14A1Ep3F028665@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b35e4edc97d8 - stable/13 - kern_ptrace: change type of proctree_locked to bool MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b35e4edc97d82e7897abc0e15eb6839b65e3441d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:51 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b35e4edc97d82e7897abc0e15eb6839b65e3441d commit b35e4edc97d82e7897abc0e15eb6839b65e3441d Author: Konstantin Belousov AuthorDate: 2021-04-30 21:14:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:36 +0000 kern_ptrace: change type of proctree_locked to bool (cherry picked from commit 2bd0506c8d94a2c581dd16407f3a1c159a38769b) --- sys/kern/sys_process.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index c4dfc2def72a..cc440d932eb5 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -612,13 +612,14 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) struct ptrace_lwpinfo *pl; struct ptrace_sc_ret *psr; int error, num, tmp; - int proctree_locked = 0; lwpid_t tid = 0, *buf; #ifdef COMPAT_FREEBSD32 int wrap32 = 0, safe = 0; #endif + bool proctree_locked; curp = td->td_proc; + proctree_locked = false; /* Lock proctree before locking the process. */ switch (req) { @@ -636,7 +637,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) case PT_DETACH: case PT_GET_SC_ARGS: sx_xlock(&proctree_lock); - proctree_locked = 1; + proctree_locked = true; break; default: break; @@ -816,7 +817,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) p->p_oppid); sx_xunlock(&proctree_lock); - proctree_locked = 0; + proctree_locked = false; MPASS(p->p_xthread == NULL); MPASS((p->p_flag & P_STOPPED_TRACE) == 0); @@ -1053,10 +1054,10 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) } sx_xunlock(&proctree_lock); - proctree_locked = 0; + proctree_locked = false; sendsig: - MPASS(proctree_locked == 0); + MPASS(!proctree_locked); /* * Clear the pending event for the thread that just From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67A00647F7A; Mon, 10 May 2021 01:14:54 +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 4FdjlK6rpSz4ZZw; Mon, 10 May 2021 01:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9BC3C1BE04; Mon, 10 May 2021 01:14:53 +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 14A1Er67028714; Mon, 10 May 2021 01:14:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1ErdR028713; Mon, 10 May 2021 01:14:53 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:53 GMT Message-Id: <202105100114.14A1ErdR028713@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4495cd6e7e50 - stable/13 - ptrace: do not allow for parallel ptrace requests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4495cd6e7e50e54515cc3d9b9faba7c6fb21042b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:54 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4495cd6e7e50e54515cc3d9b9faba7c6fb21042b commit 4495cd6e7e50e54515cc3d9b9faba7c6fb21042b Author: Konstantin Belousov AuthorDate: 2021-04-24 11:57:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:47 +0000 ptrace: do not allow for parallel ptrace requests (cherry picked from commit 9ebf9100bad129a92961572ac862781d6c5681c7) --- sys/kern/sys_process.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- sys/sys/proc.h | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index c93bfe15324c..e89fc6dff7e0 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -604,11 +604,18 @@ proc_set_traced(struct proc *p, bool stop) static int proc_can_ptrace(struct thread *td, struct proc *p) { + int error; + PROC_LOCK_ASSERT(p, MA_OWNED); if ((p->p_flag & P_WEXIT) != 0) return (ESRCH); + if ((error = p_cansee(td, p)) != 0) + return (error); + if ((error = p_candebug(td, p)) != 0) + return (error); + /* not being traced... */ if ((p->p_flag & P_TRACED) == 0) return (EPERM); @@ -640,10 +647,11 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) #ifdef COMPAT_FREEBSD32 int wrap32 = 0, safe = 0; #endif - bool proctree_locked; + bool proctree_locked, p2_req_set; curp = td->td_proc; proctree_locked = false; + p2_req_set = false; /* Lock proctree before locking the process. */ switch (req) { @@ -782,15 +790,47 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) /* FALLTHROUGH */ default: + /* + * Check for ptrace eligibility before waiting for + * holds to drain. + */ error = proc_can_ptrace(td, p); if (error != 0) goto fail; + /* + * Block parallel ptrace requests. Most important, do + * not allow other thread in debugger to continue the + * debuggee until coredump finished. + */ + while ((p->p_flag2 & P2_PTRACEREQ) != 0) { + if (proctree_locked) + sx_xunlock(&proctree_lock); + error = msleep(&p->p_flag2, &p->p_mtx, PPAUSE | PCATCH | + (proctree_locked ? PDROP : 0), "pptrace", 0); + if (proctree_locked) { + sx_xlock(&proctree_lock); + PROC_LOCK(p); + } + if (error == 0 && td2->td_proc != p) + error = ESRCH; + if (error == 0) + error = proc_can_ptrace(td, p); + if (error != 0) + goto fail; + } + /* Ok */ break; } - /* Keep this process around until we finish this request. */ + /* + * Keep this process around and request parallel ptrace() + * request to wait until we finish this request. + */ + MPASS((p->p_flag2 & P2_PTRACEREQ) == 0); + p->p_flag2 |= P2_PTRACEREQ; + p2_req_set = true; _PHOLD(p); /* @@ -1325,6 +1365,11 @@ out: /* Drop our hold on this process now that the request has completed. */ _PRELE(p); fail: + if (p2_req_set) { + if ((p->p_flag2 & P2_PTRACEREQ) != 0) + wakeup(&p->p_flag2); + p->p_flag2 &= ~P2_PTRACEREQ; + } PROC_UNLOCK(p); if (proctree_locked) sx_xunlock(&proctree_lock); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 9de7be4628dd..0a779820fddc 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -817,6 +817,7 @@ struct proc { #define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled after exec */ #define P2_ITSTOPPED 0x00002000 +#define P2_PTRACEREQ 0x00004000 /* Active ptrace req */ /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE7496280AF; Mon, 10 May 2021 01:14: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 4FdjlJ40qnz4ZgH; Mon, 10 May 2021 01:14:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 78D021BC92; Mon, 10 May 2021 01:14:52 +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 14A1EqMV028691; Mon, 10 May 2021 01:14:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1Eqit028690; Mon, 10 May 2021 01:14:52 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:52 GMT Message-Id: <202105100114.14A1Eqit028690@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 57d7b30ea855 - stable/13 - kern_ptrace(): extract code to determine ptrace eligibility into helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 57d7b30ea855ee506b86ccba9b753bcdecda14a2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:52 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=57d7b30ea855ee506b86ccba9b753bcdecda14a2 commit 57d7b30ea855ee506b86ccba9b753bcdecda14a2 Author: Konstantin Belousov AuthorDate: 2021-04-24 11:52:11 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:02:40 +0000 kern_ptrace(): extract code to determine ptrace eligibility into helper (cherry picked from commit 54c8baa021957bc026406b3a424296e84b28baa5) --- sys/kern/sys_process.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index cc440d932eb5..c93bfe15324c 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -601,6 +601,30 @@ proc_set_traced(struct proc *p, bool stop) p->p_ptevents = PTRACE_DEFAULT; } +static int +proc_can_ptrace(struct thread *td, struct proc *p) +{ + PROC_LOCK_ASSERT(p, MA_OWNED); + + if ((p->p_flag & P_WEXIT) != 0) + return (ESRCH); + + /* not being traced... */ + if ((p->p_flag & P_TRACED) == 0) + return (EPERM); + + /* not being traced by YOU */ + if (p->p_pptr != td->td_proc) + return (EBUSY); + + /* not currently stopped */ + if ((p->p_flag & P_STOPPED_TRACE) == 0 || + p->p_suspcount != p->p_numthreads || + (p->p_flag & P_WAITED) == 0) + return (EBUSY); + + return (0); +} int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) { @@ -758,27 +782,11 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) /* FALLTHROUGH */ default: - /* not being traced... */ - if ((p->p_flag & P_TRACED) == 0) { - error = EPERM; + error = proc_can_ptrace(td, p); + if (error != 0) goto fail; - } - - /* not being traced by YOU */ - if (p->p_pptr != td->td_proc) { - error = EBUSY; - goto fail; - } - /* not currently stopped */ - if ((p->p_flag & P_STOPPED_TRACE) == 0 || - p->p_suspcount != p->p_numthreads || - (p->p_flag & P_WAITED) == 0) { - error = EBUSY; - goto fail; - } - - /* OK */ + /* Ok */ break; } From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A523362831C; Mon, 10 May 2021 01:14:55 +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 4FdjlM0THgz4Zk7; Mon, 10 May 2021 01:14:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CC6EA1BDB1; Mon, 10 May 2021 01:14:54 +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 14A1Ess5028736; Mon, 10 May 2021 01:14:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1EsRY028734; Mon, 10 May 2021 01:14:54 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:54 GMT Message-Id: <202105100114.14A1EsRY028734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2b348ecde121 - stable/13 - ptracestop: mark threads suspended there with the new TDB_SSWITCH flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b348ecde121f57020addd77d59a1b79b8046c79 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:55 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2b348ecde121f57020addd77d59a1b79b8046c79 commit 2b348ecde121f57020addd77d59a1b79b8046c79 Author: Konstantin Belousov AuthorDate: 2021-04-24 12:02:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:03:00 +0000 ptracestop: mark threads suspended there with the new TDB_SSWITCH flag (cherry picked from commit 68d311b66678d9daffc5cf1c78f3101f2eeec3ea) --- sys/kern/kern_sig.c | 2 ++ sys/sys/proc.h | 1 + 2 files changed, 3 insertions(+) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 46b520030dcd..445582a176c8 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2648,7 +2648,9 @@ ptracestop(struct thread *td, int sig, ksiginfo_t *si) td->td_dbgflags &= ~TDB_STOPATFORK; } stopme: + td->td_dbgflags |= TDB_SSWITCH; thread_suspend_switch(td, p); + td->td_dbgflags &= ~TDB_SSWITCH; if (p->p_xthread == td) p->p_xthread = NULL; if (!(p->p_flag & P_TRACED)) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0a779820fddc..e4e01f9bec16 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -484,6 +484,7 @@ do { \ #define TDB_VFORK 0x00000800 /* vfork indicator for ptrace() */ #define TDB_FSTP 0x00001000 /* The thread is PT_ATTACH leader */ #define TDB_STEP 0x00002000 /* (x86) PSL_T set for PT_STEP */ +#define TDB_SSWITCH 0x00004000 /* Suspended in ptracestop */ /* * "Private" flags kept in td_pflags: From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85F536280BE; Mon, 10 May 2021 01:14:56 +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 4FdjlN0Sdqz4ZVq; Mon, 10 May 2021 01:14:56 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E7F761B97B; Mon, 10 May 2021 01:14:55 +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 14A1EtBD028758; Mon, 10 May 2021 01:14:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1Et6r028757; Mon, 10 May 2021 01:14:55 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:55 GMT Message-Id: <202105100114.14A1Et6r028757@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 51af25060861 - stable/13 - Add ptrace(PT_COREDUMP) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 51af25060861869b9ba59601eb67eae2445e61e0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:56 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=51af25060861869b9ba59601eb67eae2445e61e0 commit 51af25060861869b9ba59601eb67eae2445e61e0 Author: Konstantin Belousov AuthorDate: 2021-04-23 13:26:01 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:03:06 +0000 Add ptrace(PT_COREDUMP) (cherry picked from commit 87a64872cd3166a09b58aac28cdb95380d6a38eb) --- lib/libc/sys/ptrace.2 | 66 ++++++++++++++++++++++++++- sys/compat/freebsd32/freebsd32.h | 7 +++ sys/compat/freebsd32/freebsd32_misc.c | 12 +++++ sys/kern/kern_sig.c | 42 +++++++++++++++++ sys/kern/sys_process.c | 85 ++++++++++++++++++++++++++++++++++- sys/sys/proc.h | 2 + sys/sys/ptrace.h | 21 +++++++++ 7 files changed, 233 insertions(+), 2 deletions(-) diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 8e9c5d8ab87a..6148e6d333d5 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd July 15, 2019 +.Dd April 10, 2021 .Dt PTRACE 2 .Os .Sh NAME @@ -807,6 +807,70 @@ and extends up to The .Fa data argument is ignored. +.It Dv PT_COREDUMP +This request creates a coredump for the stopped program. +The +.Fa addr +argument specifies a pointer to a +.Vt "struct ptrace_coredump" , +which is defined as follows: +.Bd -literal +struct ptrace_coredump { + int pc_fd; + uint32_t pc_flags; + off_t pc_limit; +}; +.Ed +The fields of the structure are: +.Bl -tag -width pc_flags +.It Dv pc_fd +File descriptor to write the dump to. +It must refer to a regular file, opened for writing. +.It Dv pc_flags +Flags. +The following flags are defined: +.Bl -tag -width PC_COMPRESS +.It Dv PC_COMPRESS +Request compression of the dump. +.It Dv PC_ALL +Include non-dumpable entries into the dump. +The dumper ignores +.Dv MAP_NOCORE +flag of the process map entry, but device mappings are not dumped even with +.Dv PC_ALL +set. +.El +.It Dv pc_limit +Maximum size of the coredump. +Specify zero for no limit. +.El +.Pp +The size of +.Vt "struct ptrace_coredump" +must be passed in +.Fa data . +.Pp +The process must be stopped before dumping core. +A single thread in the target process is temporarily unsuspended +in kernel to write the dump. +If the +.Nm +call fails before a thread is unsuspended, there is no event to +.Xr waitpid 2 +for. +If a thread was unsuspended, it will stop again before the +.Nm +call returns, and the process must be waited upon using +.Xr waitpid 2 +to consume the new stop event. +Since it is hard to deduce whether a thread was unsuspended before +an error occurred, it is recommended to unconditionally perform +.Xr waitpid 2 +with +.Dv WNOHANG +flag after +.Dv PT_COREDUMP , +and silently accept zero result from it. .El .Sh ARM MACHINE-SPECIFIC REQUESTS .Bl -tag -width "Dv PT_SETVFPREGS" diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index 4227d9037afb..2e4f5155cbf4 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -429,4 +429,11 @@ struct timex32 { int32_t stbcnt; }; +struct ptrace_coredump32 { + int pc_fd; + uint32_t pc_flags; + uint32_t pc_limit1, pc_limit2; +}; + + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index b7db1c4468d7..d258afa2352d 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -920,6 +920,7 @@ freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) struct ptrace_io_desc piod; struct ptrace_lwpinfo pl; struct ptrace_vm_entry pve; + struct ptrace_coredump pc; struct dbreg32 dbreg; struct fpreg32 fpreg; struct reg32 reg; @@ -931,6 +932,7 @@ freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) struct ptrace_io_desc32 piod; struct ptrace_lwpinfo32 pl; struct ptrace_vm_entry32 pve; + struct ptrace_coredump32 pc; uint32_t args[nitems(td->td_sa.args)]; struct ptrace_sc_ret32 psr; } r32; @@ -1009,6 +1011,16 @@ freebsd32_ptrace(struct thread *td, struct freebsd32_ptrace_args *uap) CP(r32.pve, r.pve, pve_fsid); PTRIN_CP(r32.pve, r.pve, pve_path); break; + case PT_COREDUMP: + if (uap->data != sizeof(r32.pc)) + error = EINVAL; + else + error = copyin(uap->addr, &r32.pc, uap->data); + CP(r32.pc, r.pc, pc_fd); + CP(r32.pc, r.pc, pc_flags); + r.pc.pc_limit = PAIR32TO64(off_t, r32.pc.pc_limit); + data = sizeof(r.pc); + break; default: addr = uap->addr; break; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 445582a176c8..0453d3b2702c 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2521,6 +2521,42 @@ out: thread_unlock(td); } +static void +ptrace_coredump(struct thread *td) +{ + struct proc *p; + struct thr_coredump_req *tcq; + void *rl_cookie; + + MPASS(td == curthread); + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + if ((td->td_dbgflags & TDB_COREDUMPRQ) == 0) + return; + KASSERT((p->p_flag & P_STOPPED_TRACE) != 0, ("not stopped")); + + tcq = td->td_coredump; + KASSERT(tcq != NULL, ("td_coredump is NULL")); + + if (p->p_sysent->sv_coredump == NULL) { + tcq->tc_error = ENOSYS; + goto wake; + } + + PROC_UNLOCK(p); + rl_cookie = vn_rangelock_wlock(tcq->tc_vp, 0, OFF_MAX); + + tcq->tc_error = p->p_sysent->sv_coredump(td, tcq->tc_vp, + tcq->tc_limit, tcq->tc_flags); + + vn_rangelock_unlock(tcq->tc_vp, rl_cookie); + PROC_LOCK(p); +wake: + td->td_dbgflags &= ~TDB_COREDUMPRQ; + td->td_coredump = NULL; + wakeup(p); +} + static int sig_suspend_threads(struct thread *td, struct proc *p, int sending) { @@ -2651,6 +2687,12 @@ stopme: td->td_dbgflags |= TDB_SSWITCH; thread_suspend_switch(td, p); td->td_dbgflags &= ~TDB_SSWITCH; + if ((td->td_dbgflags & TDB_COREDUMPRQ) != 0) { + PROC_SUNLOCK(p); + ptrace_coredump(td); + PROC_SLOCK(p); + goto stopme; + } if (p->p_xthread == td) p->p_xthread = NULL; if (!(p->p_flag & P_TRACED)) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index e89fc6dff7e0..bc38a8ee585d 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include @@ -469,6 +471,7 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap) struct ptrace_io_desc piod; struct ptrace_lwpinfo pl; struct ptrace_vm_entry pve; + struct ptrace_coredump pc; struct dbreg dbreg; struct fpreg fpreg; struct reg reg; @@ -519,6 +522,12 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap) case PT_VM_ENTRY: error = copyin(uap->addr, &r.pve, sizeof(r.pve)); break; + case PT_COREDUMP: + if (uap->data != sizeof(r.pc)) + error = EINVAL; + else + error = copyin(uap->addr, &r.pc, uap->data); + break; default: addr = uap->addr; break; @@ -632,6 +641,22 @@ proc_can_ptrace(struct thread *td, struct proc *p) return (0); } + +static struct thread * +ptrace_sel_coredump_thread(struct proc *p) +{ + struct thread *td2; + + PROC_LOCK_ASSERT(p, MA_OWNED); + MPASS((p->p_flag & P_STOPPED_TRACE) != 0); + + FOREACH_THREAD_IN_PROC(p, td2) { + if ((td2->td_dbgflags & TDB_SSWITCH) != 0) + return (td2); + } + return (NULL); +} + int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) { @@ -642,6 +667,9 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) struct ptrace_io_desc *piod = NULL; struct ptrace_lwpinfo *pl; struct ptrace_sc_ret *psr; + struct file *fp; + struct ptrace_coredump *pc; + struct thr_coredump_req *tcq; int error, num, tmp; lwpid_t tid = 0, *buf; #ifdef COMPAT_FREEBSD32 @@ -1348,6 +1376,62 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) PROC_LOCK(p); break; + case PT_COREDUMP: + pc = addr; + CTR2(KTR_PTRACE, "PT_COREDUMP: pid %d, fd %d", + p->p_pid, pc->pc_fd); + + if ((pc->pc_flags & ~(PC_COMPRESS | PC_ALL)) != 0) { + error = EINVAL; + break; + } + PROC_UNLOCK(p); + + tcq = malloc(sizeof(*tcq), M_TEMP, M_WAITOK | M_ZERO); + fp = NULL; + error = fget_write(td, pc->pc_fd, &cap_write_rights, &fp); + if (error != 0) + goto coredump_cleanup_nofp; + if (fp->f_type != DTYPE_VNODE || fp->f_vnode->v_type != VREG) { + error = EPIPE; + goto coredump_cleanup; + } + + PROC_LOCK(p); + error = proc_can_ptrace(td, p); + if (error != 0) + goto coredump_cleanup_locked; + + td2 = ptrace_sel_coredump_thread(p); + if (td2 == NULL) { + error = EBUSY; + goto coredump_cleanup_locked; + } + KASSERT((td2->td_dbgflags & TDB_COREDUMPRQ) == 0, + ("proc %d tid %d req coredump", p->p_pid, td2->td_tid)); + + tcq->tc_vp = fp->f_vnode; + tcq->tc_limit = pc->pc_limit == 0 ? OFF_MAX : pc->pc_limit; + tcq->tc_flags = SVC_PT_COREDUMP; + if ((pc->pc_flags & PC_COMPRESS) == 0) + tcq->tc_flags |= SVC_NOCOMPRESS; + if ((pc->pc_flags & PC_ALL) != 0) + tcq->tc_flags |= SVC_ALL; + td2->td_coredump = tcq; + td2->td_dbgflags |= TDB_COREDUMPRQ; + thread_run_flash(td2); + while ((td2->td_dbgflags & TDB_COREDUMPRQ) != 0) + msleep(p, &p->p_mtx, PPAUSE, "crdmp", 0); + error = tcq->tc_error; +coredump_cleanup_locked: + PROC_UNLOCK(p); +coredump_cleanup: + fdrop(fp, td); +coredump_cleanup_nofp: + free(tcq, M_TEMP); + PROC_LOCK(p); + break; + default: #ifdef __HAVE_PTRACE_MACHDEP if (req >= PT_FIRSTMACH) { @@ -1360,7 +1444,6 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) error = EINVAL; break; } - out: /* Drop our hold on this process now that the request has completed. */ _PRELE(p); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index e4e01f9bec16..8e2a081eb027 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -376,6 +376,7 @@ struct thread { int td_oncpu; /* (t) Which cpu we are on. */ void *td_lkpi_task; /* LinuxKPI task struct pointer */ int td_pmcpend; + void *td_coredump; /* (c) coredump request. */ #ifdef EPOCH_TRACE SLIST_HEAD(, epoch_tracker) td_epochs; #endif @@ -485,6 +486,7 @@ do { \ #define TDB_FSTP 0x00001000 /* The thread is PT_ATTACH leader */ #define TDB_STEP 0x00002000 /* (x86) PSL_T set for PT_STEP */ #define TDB_SSWITCH 0x00004000 /* Suspended in ptracestop */ +#define TDB_COREDUMPRQ 0x00008000 /* Coredump request */ /* * "Private" flags kept in td_pflags: diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 1ee42318e57e..06f01a04fd9d 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -74,6 +74,8 @@ #define PT_GET_SC_ARGS 27 /* fetch syscall args */ #define PT_GET_SC_RET 28 /* fetch syscall results */ +#define PT_COREDUMP 29 /* create a coredump */ + #define PT_GETREGS 33 /* get general-purpose registers */ #define PT_SETREGS 34 /* set general-purpose registers */ #define PT_GETFPREGS 35 /* get floating-point registers */ @@ -176,8 +178,27 @@ struct ptrace_vm_entry { char *pve_path; /* Path name of object. */ }; +/* Argument structure for PT_COREDUMP */ +struct ptrace_coredump { + int pc_fd; /* File descriptor to write dump to. */ + uint32_t pc_flags; /* Flags PC_* */ + off_t pc_limit; /* Maximum size of the coredump, + 0 for no limit. */ +}; + +/* Flags for PT_COREDUMP pc_flags */ +#define PC_COMPRESS 0x00000001 /* Allow compression */ +#define PC_ALL 0x00000002 /* Include non-dumpable entries */ + #ifdef _KERNEL +struct thr_coredump_req { + struct vnode *tc_vp; /* vnode to write coredump to. */ + off_t tc_limit; /* max coredump file size. */ + int tc_flags; /* user flags */ + int tc_error; /* request result */ +}; + int ptrace_set_pc(struct thread *_td, unsigned long _addr); int ptrace_single_step(struct thread *_td); int ptrace_clear_single_step(struct thread *_td); From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6BCB6282A5; Mon, 10 May 2021 01:14:57 +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 4FdjlP1bHdz4Zgf; Mon, 10 May 2021 01:14:57 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 04D2B1B9DE; Mon, 10 May 2021 01:14:57 +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 14A1EuKC028779; Mon, 10 May 2021 01:14:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1EuDI028778; Mon, 10 May 2021 01:14:56 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:56 GMT Message-Id: <202105100114.14A1EuDI028778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 7a94e71e0586 - stable/13 - gcore: split code to open core file into helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7a94e71e058684f9d8812d1180540c84cbf720c2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:58 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7a94e71e058684f9d8812d1180540c84cbf720c2 commit 7a94e71e058684f9d8812d1180540c84cbf720c2 Author: Konstantin Belousov AuthorDate: 2021-04-24 10:31:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:03:14 +0000 gcore: split code to open core file into helper (cherry picked from commit c192228b7398df72e472128605338555e5aa2db9) --- usr.bin/gcore/gcore.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/usr.bin/gcore/gcore.c b/usr.bin/gcore/gcore.c index 8681b8484d81..cbbfea82085b 100644 --- a/usr.bin/gcore/gcore.c +++ b/usr.bin/gcore/gcore.c @@ -78,12 +78,27 @@ static pid_t pid; SET_DECLARE(dumpset, struct dumpers); +static int +open_corefile(char *corefile) +{ + char fname[MAXPATHLEN]; + + if (corefile == NULL) { + (void)snprintf(fname, sizeof(fname), "core.%d", pid); + corefile = fname; + } + fd = open(corefile, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE); + if (fd < 0) + err(1, "%s", corefile); + return (fd); +} + int main(int argc, char *argv[]) { int ch, efd, fd, name[4]; char *binfile, *corefile; - char passpath[MAXPATHLEN], fname[MAXPATHLEN]; + char passpath[MAXPATHLEN]; struct dumpers **d, *dumper; size_t len; @@ -138,13 +153,7 @@ main(int argc, char *argv[]) } if (dumper == NULL) errx(1, "Invalid executable file"); - if (corefile == NULL) { - (void)snprintf(fname, sizeof(fname), "core.%d", pid); - corefile = fname; - } - fd = open(corefile, O_RDWR|O_CREAT|O_TRUNC, DEFFILEMODE); - if (fd < 0) - err(1, "%s", corefile); + fd = open_corefile(corefile); dumper->dump(efd, fd, pid); (void)close(fd); From owner-dev-commits-src-all@freebsd.org Mon May 10 01:14:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1A6FF628329; Mon, 10 May 2021 01:14:59 +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 4FdjlQ5B4Tz4Zd7; Mon, 10 May 2021 01:14:58 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 347A81B97C; Mon, 10 May 2021 01:14:58 +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 14A1Ewat028802; Mon, 10 May 2021 01:14:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14A1EwEm028801; Mon, 10 May 2021 01:14:58 GMT (envelope-from git) Date: Mon, 10 May 2021 01:14:58 GMT Message-Id: <202105100114.14A1EwEm028801@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 32bfffcb9adf - stable/13 - gcore: add option to dump core using kernel facility MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32bfffcb9adfe146f0e852d997717fd3982eda36 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 01:14:59 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=32bfffcb9adfe146f0e852d997717fd3982eda36 commit 32bfffcb9adfe146f0e852d997717fd3982eda36 Author: Konstantin Belousov AuthorDate: 2021-04-24 11:20:24 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 01:03:19 +0000 gcore: add option to dump core using kernel facility (cherry picked from commit 73e8f06ac523ee4b530e17d50cc580dc366f7ad8) --- usr.bin/gcore/gcore.1 | 16 +++++++++-- usr.bin/gcore/gcore.c | 75 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 80 insertions(+), 11 deletions(-) diff --git a/usr.bin/gcore/gcore.1 b/usr.bin/gcore/gcore.1 index 55db2aed3e3a..aa93a5ef1fe0 100644 --- a/usr.bin/gcore/gcore.1 +++ b/usr.bin/gcore/gcore.1 @@ -28,7 +28,7 @@ .\" @(#)gcore.1 8.2 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 13, 2016 +.Dd April 24, 2021 .Dt GCORE 1 .Os .Sh NAME @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl f +.Op Fl k .Op Fl c Ar core .Op Ar executable .Ar pid @@ -58,13 +59,24 @@ The following options are available: Write the core file to the specified file instead of .Dq Pa core. . .It Fl f -Dumps all available segments, excluding only malformed and undumpable segments. +Dumps all available segments, excluding only malformed and undumpable +segments. Unlike the default invocation, this flag dumps mappings of devices which may invalidate the state of device transactions or trigger other unexpected behavior. As a result, this flag should only be used when the behavior of the application and any devices it has mapped is fully understood and any side effects can be controlled or tolerated. +.It Fl k +Use the +.Xr ptrace 2 +.Dv PT_COREDUMP +kernel facility to write the core dump, instead of reading the process' +memory and constructing the dump file in +.Nm +itself. +This is faster, and the dump is written by the +same kernel code that writes core dumps upon fatal signals. .El .Sh FILES .Bl -tag -width /var/log/messages -compact diff --git a/usr.bin/gcore/gcore.c b/usr.bin/gcore/gcore.c index cbbfea82085b..8055193625f9 100644 --- a/usr.bin/gcore/gcore.c +++ b/usr.bin/gcore/gcore.c @@ -56,13 +56,16 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include #include +#include #include #include +#include #include #include #include @@ -75,6 +78,7 @@ static void killed(int); static void usage(void) __dead2; static pid_t pid; +static bool kflag = false; SET_DECLARE(dumpset, struct dumpers); @@ -82,6 +86,7 @@ static int open_corefile(char *corefile) { char fname[MAXPATHLEN]; + int fd; if (corefile == NULL) { (void)snprintf(fname, sizeof(fname), "core.%d", pid); @@ -93,6 +98,45 @@ open_corefile(char *corefile) return (fd); } +static void +kcoredump(int fd, pid_t pid) +{ + struct ptrace_coredump pc; + int error, res, ret, waited; + + error = ptrace(PT_ATTACH, pid, NULL, 0); + if (error != 0) + err(1, "attach"); + + waited = waitpid(pid, &res, 0); + if (waited == -1) + err(1, "wait for STOP"); + + ret = 0; + memset(&pc, 0, sizeof(pc)); + pc.pc_fd = fd; + pc.pc_flags = (pflags & PFLAGS_FULL) != 0 ? PC_ALL : 0; + error = ptrace(PT_COREDUMP, pid, (void *)&pc, sizeof(pc)); + if (error == -1) { + warn("coredump"); + ret = 1; + } + + waited = waitpid(pid, &res, WNOHANG); + if (waited == -1) { + warn("wait after coredump"); + ret = 1; + } + + error = ptrace(PT_DETACH, pid, NULL, 0); + if (error == -1) { + warn("detach failed, check process status"); + ret = 1; + } + + exit(ret); +} + int main(int argc, char *argv[]) { @@ -104,7 +148,7 @@ main(int argc, char *argv[]) pflags = 0; corefile = NULL; - while ((ch = getopt(argc, argv, "c:f")) != -1) { + while ((ch = getopt(argc, argv, "c:fk")) != -1) { switch (ch) { case 'c': corefile = optarg; @@ -112,6 +156,9 @@ main(int argc, char *argv[]) case 'f': pflags |= PFLAGS_FULL; break; + case 'k': + kflag = true; + break; default: usage(); break; @@ -119,10 +166,26 @@ main(int argc, char *argv[]) } argv += optind; argc -= optind; + /* XXX we should check that the pid argument is really a number */ switch (argc) { case 1: pid = atoi(argv[0]); + break; + case 2: + binfile = argv[0]; + pid = atoi(argv[1]); + break; + default: + usage(); + } + + if (kflag) { + fd = open_corefile(corefile); + kcoredump(fd, pid); + } + + if (argc == 1) { name[0] = CTL_KERN; name[1] = KERN_PROC; name[2] = KERN_PROC_PATHNAME; @@ -131,13 +194,6 @@ main(int argc, char *argv[]) if (sysctl(name, 4, passpath, &len, NULL, 0) == -1) errx(1, "kern.proc.pathname failure"); binfile = passpath; - break; - case 2: - pid = atoi(argv[1]); - binfile = argv[0]; - break; - default: - usage(); } efd = open(binfile, O_RDONLY, 0); if (efd < 0) @@ -165,6 +221,7 @@ void usage(void) { - (void)fprintf(stderr, "usage: gcore [-c core] [executable] pid\n"); + (void)fprintf(stderr, + "usage: gcore [-kf] [-c core] [executable] pid\n"); exit(1); } From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3BD78637DF3; Mon, 10 May 2021 13:49:28 +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 4Ff2V01D9Sz3PJl; Mon, 10 May 2021 13:49:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1C78B255DA; Mon, 10 May 2021 13:49:28 +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 14ADnSEe026383; Mon, 10 May 2021 13:49:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnSlG026382; Mon, 10 May 2021 13:49:28 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:28 GMT Message-Id: <202105101349.14ADnSlG026382@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 990d0523c9c1 - stable/13 - devd.conf: Typo MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 990d0523c9c11ff04d48db859e1622cbaa5a0a1a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:28 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=990d0523c9c11ff04d48db859e1622cbaa5a0a1a commit 990d0523c9c11ff04d48db859e1622cbaa5a0a1a Author: Ceri Davies AuthorDate: 2021-05-07 18:31:02 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:34:46 +0000 devd.conf: Typo PR: 255051 (cherry picked from commit 6a8ed85f487c6fd109897235c60f710948bd5150) --- sbin/devd/devd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/devd/devd.conf b/sbin/devd/devd.conf index dba7d41402d7..db459a7b6e50 100644 --- a/sbin/devd/devd.conf +++ b/sbin/devd/devd.conf @@ -33,7 +33,7 @@ options { # # Configure the interface on attach. Due to a historical accident, this # script is called pccard_ether. We omit the usbus devices because those -# devices are assocaited with the USB Bus and provide an ifnet device to +# devices are associated with the USB Bus and provide an ifnet device to # allow usb traffic to be captured with usbdump(8). # # NB: DETACH events are ignored; the kernel should handle all cleanup From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 650F8637E35; Mon, 10 May 2021 13:49:29 +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 4Ff2V12H9jz3Nwq; Mon, 10 May 2021 13:49:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 40DF125917; Mon, 10 May 2021 13:49:29 +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 14ADnT46026404; Mon, 10 May 2021 13:49:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnT1M026403; Mon, 10 May 2021 13:49:29 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:29 GMT Message-Id: <202105101349.14ADnT1M026403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0f19be5f97b8 - stable/13 - devd.conf: Remove support for coldsync MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0f19be5f97b830247df33793da0ef368f0e94573 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:29 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0f19be5f97b830247df33793da0ef368f0e94573 commit 0f19be5f97b830247df33793da0ef368f0e94573 Author: Ceri Davies AuthorDate: 2021-05-07 18:19:34 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:34:49 +0000 devd.conf: Remove support for coldsync The coldsync port was removed in 2012. The last stable release of coldsync was issued in 2002. Let's get rid of it. PR: 255051 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D30100 (cherry picked from commit 1a212abd54c0e4323f11e3bc2fd94ca26f7e5329) --- sbin/devd/devd.conf | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sbin/devd/devd.conf b/sbin/devd/devd.conf index db459a7b6e50..9d23b77fe96a 100644 --- a/sbin/devd/devd.conf +++ b/sbin/devd/devd.conf @@ -155,19 +155,6 @@ notify 100 { action "service moused stop $cdev"; }; -# This entry starts the ColdSync tool in daemon mode. Make sure you have an up -# to date /usr/local/etc/palms. We override the 'listen' settings for port and -# type in /usr/local/etc/coldsync.conf. -notify 100 { - match "system" "USB"; - match "subsystem" "DEVICE"; - match "type" "ATTACH"; - match "vendor" "0x082d"; - match "product" "0x0100"; - match "release" "0x0100"; - action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb"; -}; - # # Rescan SCSI device-names on attach, but not detach. However, it is # disabled by default due to reports of problems. From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BAB60638082; Mon, 10 May 2021 13:49:30 +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 4Ff2V241crz3PJn; Mon, 10 May 2021 13:49:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 696EF25728; Mon, 10 May 2021 13:49:30 +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 14ADnUZl026425; Mon, 10 May 2021 13:49:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnUZs026424; Mon, 10 May 2021 13:49:30 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:30 GMT Message-Id: <202105101349.14ADnUZs026424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: b2c871b1387e - stable/13 - bhyve: Set SO_REUSEADDR on the gdb stub socket MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b2c871b1387e8b7561c35ebc46c7bac764196faf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:30 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b2c871b1387e8b7561c35ebc46c7bac764196faf commit b2c871b1387e8b7561c35ebc46c7bac764196faf Author: Mark Johnston AuthorDate: 2021-05-03 16:42:54 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:35:04 +0000 bhyve: Set SO_REUSEADDR on the gdb stub socket Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30037 (cherry picked from commit 02e7a6514e63ceca680fade40797280aef1bf55f) --- usr.sbin/bhyve/gdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index b0f0c034b2c7..6ebc8d4fcd54 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -1810,7 +1810,7 @@ void init_gdb(struct vmctx *_ctx, int sport, bool wait) { struct sockaddr_in sin; - int error, flags, s; + int error, flags, optval, s; debug("==> starting on %d, %swaiting\n", sport, wait ? "" : "not "); @@ -1826,6 +1826,9 @@ init_gdb(struct vmctx *_ctx, int sport, bool wait) if (s < 0) err(1, "gdb socket create"); + optval = 1; + (void)setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY); From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1118638083; Mon, 10 May 2021 13:49:31 +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 4Ff2V34gcBz3Nx1; Mon, 10 May 2021 13:49:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7F82B2579C; Mon, 10 May 2021 13:49:31 +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 14ADnVFc026452; Mon, 10 May 2021 13:49:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnV1C026451; Mon, 10 May 2021 13:49:31 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:31 GMT Message-Id: <202105101349.14ADnV1C026451@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 44d26e9e781f - stable/13 - smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 44d26e9e781fdf47fe0e1e6c987d519a751b14fa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:32 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=44d26e9e781fdf47fe0e1e6c987d519a751b14fa commit 44d26e9e781fdf47fe0e1e6c987d519a751b14fa Author: Mark Johnston AuthorDate: 2021-05-03 16:43:00 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:35:53 +0000 smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry() Otherwise, if !smp_started is true, then smp_rendezvous_cpus_done() will harmlessly perform an atomic RMW on an uninitialized variable. Reported by: KMSAN Sponsored by: The FreeBSD Foundation (cherry picked from commit cdfcfc607acc10c8b1b2b6a427c9e1ed7e94ebb3) --- sys/kern/subr_smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 093622d8f6aa..d4f8aac9e751 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -895,6 +895,8 @@ smp_rendezvous_cpus_retry(cpuset_t map, { int cpu; + CPU_COPY(&map, &arg->cpus); + /* * Only one CPU to execute on. */ @@ -914,7 +916,6 @@ smp_rendezvous_cpus_retry(cpuset_t map, * Execute an action on all specified CPUs while retrying until they * all acknowledge completion. */ - CPU_COPY(&map, &arg->cpus); for (;;) { smp_rendezvous_cpus( arg->cpus, From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D02A2637D4E; Mon, 10 May 2021 13:49:32 +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 4Ff2V45BlKz3PP6; Mon, 10 May 2021 13:49:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9B0E2258F2; Mon, 10 May 2021 13:49:32 +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 14ADnWpo026474; Mon, 10 May 2021 13:49:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnWq2026473; Mon, 10 May 2021 13:49:32 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:32 GMT Message-Id: <202105101349.14ADnWq2026473@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: eafeee082c50 - stable/13 - divert: Fix mbuf ownership confusion in div_output() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eafeee082c50850c2577f4fce0eaa7acb034f565 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:32 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=eafeee082c50850c2577f4fce0eaa7acb034f565 commit eafeee082c50850c2577f4fce0eaa7acb034f565 Author: Mark Johnston AuthorDate: 2021-05-07 18:27:58 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:36:08 +0000 divert: Fix mbuf ownership confusion in div_output() div_output_outbound() and div_output_inbound() relied on the caller to free the mbuf if an error occurred. However, this is contrary to the semantics of their callees, ip_output(), ip6_output() and netisr_queue_src(), which always consume the mbuf. So, if one of these functions returned an error, that would get propagated up to div_output(), resulting in a double free. Fix the problem by making div_output_outbound() and div_output_inbound() responsible for freeing the mbuf in all cases. Reported by: Michael Schmiedgen Tested by: Michael Schmiedgen Reviewed by: donner Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30129 (cherry picked from commit a1fadf7de25b973a308b86d04c4ada4fa8be193f) --- sys/netinet/ip_divert.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index c3f9c43b8f70..31b28656ece7 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -402,17 +402,13 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin, } NET_EPOCH_EXIT(et); - if (error != 0) - m_freem(m); - return (error); } /* * Sends mbuf @m to the wire via ip[6]_output(). * - * Returns 0 on success, @m is consumed. - * On failure, returns error code. It is caller responsibility to free @m. + * Returns 0 on success or an errno value on failure. @m is always consumed. */ static int div_output_outbound(int family, struct socket *so, struct mbuf *m) @@ -435,6 +431,7 @@ div_output_outbound(int family, struct socket *so, struct mbuf *m) inp->inp_options != NULL) || ((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) { INP_RUNLOCK(inp); + m_freem(m); return (EINVAL); } break; @@ -446,6 +443,7 @@ div_output_outbound(int family, struct socket *so, struct mbuf *m) /* Don't allow packet length sizes that will crash */ if (((u_short)ntohs(ip6->ip6_plen) > m->m_pkthdr.len)) { INP_RUNLOCK(inp); + m_freem(m); return (EINVAL); } break; @@ -485,6 +483,7 @@ div_output_outbound(int family, struct socket *so, struct mbuf *m) options = m_dup(inp->inp_options, M_NOWAIT); if (options == NULL) { INP_RUNLOCK(inp); + m_freem(m); return (ENOBUFS); } } @@ -512,8 +511,7 @@ div_output_outbound(int family, struct socket *so, struct mbuf *m) /* * Schedules mbuf @m for local processing via IPv4/IPv6 netisr queue. * - * Returns 0 on success, @m is consumed. - * Returns error code on failure. It is caller responsibility to free @m. + * Returns 0 on success or an errno value on failure. @m is always consumed. */ static int div_output_inbound(int family, struct socket *so, struct mbuf *m, @@ -533,8 +531,10 @@ div_output_inbound(int family, struct socket *so, struct mbuf *m, bzero(sin->sin_zero, sizeof(sin->sin_zero)); sin->sin_port = 0; ifa = ifa_ifwithaddr((struct sockaddr *) sin); - if (ifa == NULL) + if (ifa == NULL) { + m_freem(m); return (EADDRNOTAVAIL); + } m->m_pkthdr.rcvif = ifa->ifa_ifp; } #ifdef MAC @@ -560,6 +560,7 @@ div_output_inbound(int family, struct socket *so, struct mbuf *m, break; #endif default: + m_freem(m); return (EINVAL); } From owner-dev-commits-src-all@freebsd.org Mon May 10 13:49:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3C220638183; Mon, 10 May 2021 13:49:34 +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 4Ff2V572dRz3PRL; Mon, 10 May 2021 13:49:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C4C6E25729; Mon, 10 May 2021 13:49:33 +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 14ADnXVM026495; Mon, 10 May 2021 13:49:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADnXFg026494; Mon, 10 May 2021 13:49:33 GMT (envelope-from git) Date: Mon, 10 May 2021 13:49:33 GMT Message-Id: <202105101349.14ADnXFg026494@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 8a4f990338fe - stable/13 - kern/intr: declare interrupt vectors unsigned MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8a4f990338febd281ec328b31b86a8fb173756f2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:34 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8a4f990338febd281ec328b31b86a8fb173756f2 commit 8a4f990338febd281ec328b31b86a8fb173756f2 Author: Elliott Mitchell AuthorDate: 2021-05-03 16:50:17 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:36:20 +0000 kern/intr: declare interrupt vectors unsigned These should never get values large enough for sign to matter, but one of them becoming negative could cause problems. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D29327 (cherry picked from commit a3c7da3d08eec921f16a32c4c716b896385264e9) --- sys/kern/subr_intr.c | 8 ++++---- sys/sys/intr.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c index 7f99d194e971..df6bf9e63ba0 100644 --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -143,7 +143,7 @@ static bool irq_assign_cpu = false; #endif #endif -int intr_nirq = NIRQ; +u_int intr_nirq = NIRQ; SYSCTL_UINT(_machdep, OID_AUTO, nirq, CTLFLAG_RDTUN, &intr_nirq, 0, "Number of IRQs"); @@ -166,7 +166,7 @@ static void intr_map_copy_map_data(u_int res_id, device_t *dev, intptr_t *xref, static void intr_irq_init(void *dummy __unused) { - int intrcnt_count; + u_int intrcnt_count; SLIST_INIT(&pic_list); mtx_init(&pic_list_lock, "intr pic list", NULL, MTX_DEF); @@ -1576,8 +1576,8 @@ struct intr_map_entry /* XXX Convert irq_map[] to dynamicaly expandable one. */ static struct intr_map_entry **irq_map; -static int irq_map_count; -static int irq_map_first_free_idx; +static u_int irq_map_count; +static u_int irq_map_first_free_idx; static struct mtx irq_map_lock; static struct intr_irqsrc * diff --git a/sys/sys/intr.h b/sys/sys/intr.h index c922b10f3368..b373a6f23bf0 100644 --- a/sys/sys/intr.h +++ b/sys/sys/intr.h @@ -165,6 +165,6 @@ u_long * intr_ipi_setup_counters(const char *name); #endif -extern int intr_nirq; /* number of IRQs on intrng platforms */ +extern u_int intr_nirq; /* number of IRQs on intrng platforms */ #endif /* _SYS_INTR_H */ From owner-dev-commits-src-all@freebsd.org Mon May 10 13:50:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 411FD638142; Mon, 10 May 2021 13:50:06 +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 4Ff2Vk1QQwz3PQr; Mon, 10 May 2021 13:50:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 23B4C25919; Mon, 10 May 2021 13:50:06 +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 14ADo6wH029110; Mon, 10 May 2021 13:50:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ADo6v1029107; Mon, 10 May 2021 13:50:06 GMT (envelope-from git) Date: Mon, 10 May 2021 13:50:06 GMT Message-Id: <202105101350.14ADo6v1029107@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9186e4eb65c0 - stable/12 - bhyve: Set SO_REUSEADDR on the gdb stub socket MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9186e4eb65c0fcff07729893f395b4dfbb9f09c6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:50:06 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9186e4eb65c0fcff07729893f395b4dfbb9f09c6 commit 9186e4eb65c0fcff07729893f395b4dfbb9f09c6 Author: Mark Johnston AuthorDate: 2021-05-03 16:42:54 +0000 Commit: Mark Johnston CommitDate: 2021-05-10 13:35:25 +0000 bhyve: Set SO_REUSEADDR on the gdb stub socket Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30037 (cherry picked from commit 02e7a6514e63ceca680fade40797280aef1bf55f) --- usr.sbin/bhyve/gdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c index 0539c461bdb3..0cf8637fd280 100644 --- a/usr.sbin/bhyve/gdb.c +++ b/usr.sbin/bhyve/gdb.c @@ -1809,7 +1809,7 @@ void init_gdb(struct vmctx *_ctx, int sport, bool wait) { struct sockaddr_in sin; - int error, flags, s; + int error, flags, optval, s; debug("==> starting on %d, %swaiting\n", sport, wait ? "" : "not "); @@ -1825,6 +1825,9 @@ init_gdb(struct vmctx *_ctx, int sport, bool wait) if (s < 0) err(1, "gdb socket create"); + optval = 1; + (void)setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY); From owner-dev-commits-src-all@freebsd.org Mon May 10 14:11:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE26F6393F1; Mon, 10 May 2021 14:11:26 +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 4Ff2zL5xHnz3Qqq; Mon, 10 May 2021 14:11:26 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 BE9C225D9B; Mon, 10 May 2021 14:11:26 +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 14AEBQV9063972; Mon, 10 May 2021 14:11:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEBQJx063971; Mon, 10 May 2021 14:11:26 GMT (envelope-from git) Date: Mon, 10 May 2021 14:11:26 GMT Message-Id: <202105101411.14AEBQJx063971@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2ef5d803e384 - main - in6_mcast: Return EADDRINUSE when we've already joined the group MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2ef5d803e3847f56771c107d9517ec560cf318c9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:11:26 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2ef5d803e3847f56771c107d9517ec560cf318c9 commit 2ef5d803e3847f56771c107d9517ec560cf318c9 Author: Kristof Provost AuthorDate: 2021-05-04 17:23:15 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 07:48:51 +0000 in6_mcast: Return EADDRINUSE when we've already joined the group Distinguish between truly invalid requests and those that fail because we've already joined the group. Both cases fail, but differentiating them allows userspace to make more informed decisions about what the error means. For example. radvd tries to join the all-routers group on every SIGHUP. This fails, because it's already joined it, but this failure should be ignored (rather than treated as a sign that the interface's multicast is broken). This puts us in line with OpenBSD, NetBSD and Linux. Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30111 --- sys/netinet6/in6_mcast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index 9b04c87d22a0..0744a1178fc7 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -2030,7 +2030,7 @@ in6p_join_group(struct inpcb *inp, struct sockopt *sopt) * state at t1, because allocation of a filter * is atomic with allocation of a membership. */ - error = EINVAL; + error = EADDRINUSE; goto out_in6p_locked; } } From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC38E639F09; Mon, 10 May 2021 14:32:43 +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 4Ff3Rv5PWhz3hP6; Mon, 10 May 2021 14:32:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AC654261DF; Mon, 10 May 2021 14:32:43 +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 14AEWh9S092903; Mon, 10 May 2021 14:32:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWhR0092902; Mon, 10 May 2021 14:32:43 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:43 GMT Message-Id: <202105101432.14AEWhR0092902@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 9312bcb2e9f6 - stable/13 - if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching, similarly to the Linux driver, by a tunable read only sysctl. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9312bcb2e9f6c13b99b52bb3d4e2a31c95c3076a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:43 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=9312bcb2e9f6c13b99b52bb3d4e2a31c95c3076a commit 9312bcb2e9f6c13b99b52bb3d4e2a31c95c3076a Author: Hans Petter Selasky AuthorDate: 2021-04-11 18:24:41 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:11:19 +0000 if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching, similarly to the Linux driver, by a tunable read only sysctl. Submitted by: Oleg Sidorkin PR: 254884 Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 5a3426f453f970edda38367bea5ebf7385c3819d) --- sys/dev/usb/net/if_smsc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c index 84610c894f4d..85cc955b9fbf 100644 --- a/sys/dev/usb/net/if_smsc.c +++ b/sys/dev/usb/net/if_smsc.c @@ -119,11 +119,19 @@ __FBSDID("$FreeBSD$"); #include "miibus_if.h" +SYSCTL_NODE(_hw_usb, OID_AUTO, smsc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "USB smsc"); + +static bool smsc_rx_packet_batching = 1; + +SYSCTL_BOOL(_hw_usb_smsc, OID_AUTO, smsc_rx_packet_batching, CTLFLAG_RDTUN, + &smsc_rx_packet_batching, 0, + "If set, allows packet batching to increase throughput and latency. " + "Else throughput and latency is decreased."); + #ifdef USB_DEBUG static int smsc_debug = 0; -SYSCTL_NODE(_hw_usb, OID_AUTO, smsc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, - "USB smsc"); SYSCTL_INT(_hw_usb_smsc, OID_AUTO, debug, CTLFLAG_RWTUN, &smsc_debug, 0, "Debug level"); #endif @@ -1377,7 +1385,9 @@ smsc_chip_init(struct smsc_softc *sc) * Burst capability is the number of URBs that can be in a burst of data/ * ethernet frames. */ - if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_HIGH) + if (!smsc_rx_packet_batching) + burst_cap = 0; + else if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_HIGH) burst_cap = 37; else burst_cap = 128; @@ -1404,7 +1414,8 @@ smsc_chip_init(struct smsc_softc *sc) /* The following setings are used for 'turbo mode', a.k.a multiple frames * per Rx transaction (again info taken form Linux driver). */ - reg_val |= (SMSC_HW_CFG_MEF | SMSC_HW_CFG_BCE); + if (smsc_rx_packet_batching) + reg_val |= (SMSC_HW_CFG_MEF | SMSC_HW_CFG_BCE); smsc_write_reg(sc, SMSC_HW_CFG, reg_val); From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 115C1639C9E; Mon, 10 May 2021 14:32:45 +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 4Ff3Rw6wYLz3hLR; Mon, 10 May 2021 14:32:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DAC6D26055; Mon, 10 May 2021 14:32:44 +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 14AEWit7092924; Mon, 10 May 2021 14:32:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWiIk092923; Mon, 10 May 2021 14:32:44 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:44 GMT Message-Id: <202105101432.14AEWiIk092923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 30c20249b973 - stable/13 - Fix build of stand/usb . MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 30c20249b973baeb934d966c1989998abc00469c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:45 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=30c20249b973baeb934d966c1989998abc00469c commit 30c20249b973baeb934d966c1989998abc00469c Author: Hans Petter Selasky AuthorDate: 2021-04-12 14:12:18 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:11:19 +0000 Fix build of stand/usb . Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 7497dd58890131251441ab992016c9457295094b) --- stand/kshim/bsd_kernel.h | 2 ++ sys/sys/gpio.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stand/kshim/bsd_kernel.h b/stand/kshim/bsd_kernel.h index 3ec1f54f74e4..9e870475127f 100644 --- a/stand/kshim/bsd_kernel.h +++ b/stand/kshim/bsd_kernel.h @@ -242,6 +242,8 @@ typedef signed long ssize_t; #define _OFF_T_DECLARED typedef unsigned long off_t; +typedef int64_t sbintime_t; + typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; diff --git a/sys/sys/gpio.h b/sys/sys/gpio.h index 50b9b9dbb0e5..9ea1d6636c20 100644 --- a/sys/sys/gpio.h +++ b/sys/sys/gpio.h @@ -53,7 +53,7 @@ #define __GPIO_H__ #include -#ifndef _KERNEL +#if !defined(_KERNEL) && !defined(_STANDALONE) #include #endif From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 553E5639D18; Mon, 10 May 2021 14:32:46 +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 4Ff3Ry1Tbhz3hFS; Mon, 10 May 2021 14:32:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1F47426385; Mon, 10 May 2021 14:32:46 +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 14AEWjI5092947; Mon, 10 May 2021 14:32:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWjQX092946; Mon, 10 May 2021 14:32:45 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:45 GMT Message-Id: <202105101432.14AEWjQX092946@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 74ef3f740dcf - stable/13 - Add more USB quirks for Kingston devices. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 74ef3f740dcfe4c660e192fda7a81a87cf0c67c2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:46 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=74ef3f740dcfe4c660e192fda7a81a87cf0c67c2 commit 74ef3f740dcfe4c660e192fda7a81a87cf0c67c2 Author: Hans Petter Selasky AuthorDate: 2021-04-22 10:40:17 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:11:19 +0000 Add more USB quirks for Kingston devices. PR: 253855 Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 47bc8fc9ae6ba7aa708e0d4ee059a377ae707e5a) --- sys/dev/usb/quirk/usb_quirk.c | 1 + sys/dev/usb/usbdevs | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c index e792523dd472..143a6be6d85d 100644 --- a/sys/dev/usb/quirk/usb_quirk.c +++ b/sys/dev/usb/quirk/usb_quirk.c @@ -291,6 +291,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE), USB_QUIRK(KINGSTON, HYPERX3_0, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), + USB_QUIRK(KINGSTON, DATATRAVELER3_0, 0x0000, 0xffff, UQ_MSC_NO_PREVENT_ALLOW, UQ_MSC_NO_SYNC_CACHE), USB_QUIRK(KYOCERA, FINECAM_L3, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), USB_QUIRK(KYOCERA, FINECAM_S3X, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index ab1d1339d587..55299365b7d8 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -2724,6 +2724,7 @@ product KEYSPAN UIA11 0x0202 UIA-11 remote control product KINGSTON XX1 0x0008 Ethernet product KINGSTON KNU101TX 0x000a KNU101TX USB Ethernet product KINGSTON HYPERX3_0 0x162b DT HyperX 3.0 +product KINGSTON DATATRAVELER3_0 0x1666 DataTraveler 3.0 /* Kawasaki products */ product KLSI DUH3E10BT 0x0008 USB Ethernet From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6B79D639DA1; Mon, 10 May 2021 14:32:47 +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 4Ff3Rz1Z1Bz3hg1; Mon, 10 May 2021 14:32:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1CC8325FEE; Mon, 10 May 2021 14:32:47 +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 14AEWlJ1092973; Mon, 10 May 2021 14:32:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWlsL092972; Mon, 10 May 2021 14:32:47 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:47 GMT Message-Id: <202105101432.14AEWlsL092972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 0d1e6e9413e9 - stable/13 - Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver. Since then, the FreeBSD USB stack has got proper USB RNDIS support. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0d1e6e9413e9913c296d829d2712a07f816e3ce0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:47 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=0d1e6e9413e9913c296d829d2712a07f816e3ce0 commit 0d1e6e9413e9913c296d829d2712a07f816e3ce0 Author: Hans Petter Selasky AuthorDate: 2021-04-22 10:22:39 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:11:19 +0000 Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver. Since then, the FreeBSD USB stack has got proper USB RNDIS support. PR: 254345 Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit d2c87140648f61a6f139a2ecdf831e6a08cc4de2) --- sys/dev/usb/net/if_cdce.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c index 7bdb81f97b38..96df8b73f8ce 100644 --- a/sys/dev/usb/net/if_cdce.c +++ b/sys/dev/usb/net/if_cdce.c @@ -268,7 +268,6 @@ static const STRUCT_USB_HOST_ID cdce_host_devs[] = { {USB_VPI(USB_VENDOR_GMATE, USB_PRODUCT_GMATE_YP3X00, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_USBLAN, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_USBLAN2, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, - {USB_VPI(USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_ETHERNETGADGET, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2501, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SL5500, CDCE_FLAG_ZAURUS)}, {USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SL5600, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)}, From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80087639F1E; Mon, 10 May 2021 14:32:48 +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 4Ff3S02sPjz3hRH; Mon, 10 May 2021 14:32:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4A584261E0; Mon, 10 May 2021 14:32:48 +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 14AEWmS4092994; Mon, 10 May 2021 14:32:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWm4I092993; Mon, 10 May 2021 14:32:48 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:48 GMT Message-Id: <202105101432.14AEWm4I092993@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: a122a5ebdee2 - stable/13 - Add more USB quirks for Garmin devices. Sort the Garmin products while at it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a122a5ebdee28f7bbd50d21558a7328bf730c195 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:48 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=a122a5ebdee28f7bbd50d21558a7328bf730c195 commit a122a5ebdee28f7bbd50d21558a7328bf730c195 Author: Hans Petter Selasky AuthorDate: 2021-04-22 10:31:33 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:11:19 +0000 Add more USB quirks for Garmin devices. Sort the Garmin products while at it. PR: 254664 Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 28af0c4814f5fb8ce047d4ac0bbf26997ac5cc8f) --- sys/dev/usb/quirk/usb_quirk.c | 2 ++ sys/dev/usb/usbdevs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c index 143a6be6d85d..cab6f1b7c074 100644 --- a/sys/dev/usb/quirk/usb_quirk.c +++ b/sys/dev/usb/quirk/usb_quirk.c @@ -243,6 +243,8 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { USB_QUIRK(GARMIN, DAKOTA20, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), USB_QUIRK(GARMIN, FORERUNNER230, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), USB_QUIRK(GARMIN, GPSMAP62S, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), + USB_QUIRK(GARMIN, EDGETOURINGPLUS, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), + USB_QUIRK(GARMIN, INSTINCTSOLAR, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE), diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 55299365b7d8..6012f6484d52 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -2254,10 +2254,12 @@ product FUJITSU AH_F401U 0x105b AH-F401U Air H device product FUJITSUSIEMENS SCR 0x0009 Fujitsu-Siemens SCR USB Reader /* Garmin products */ -product GARMIN DAKOTA20 0x23c0 Dakota 20 +product GARMIN IQUE_3600 0x0004 iQue 3600 product GARMIN FORERUNNER230 0x086d ForeRunner 230 +product GARMIN INSTINCTSOLAR 0x0d8a Instinct Solar +product GARMIN DAKOTA20 0x23c0 Dakota 20 product GARMIN GPSMAP62S 0x2459 GPSMAP 62s -product GARMIN IQUE_3600 0x0004 iQue 3600 +product GARMIN EDGETOURINGPLUS 0x26c8 Edge Touring+ /* Gemalto products */ product GEMALTO PROXPU 0x5501 Prox-PU/CU RFID Card Reader From owner-dev-commits-src-all@freebsd.org Mon May 10 14:32:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AD767639C2F; Mon, 10 May 2021 14:32:49 +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 4Ff3S13JcTz3hhb; Mon, 10 May 2021 14:32:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5BA64260D8; Mon, 10 May 2021 14:32:49 +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 14AEWntE093015; Mon, 10 May 2021 14:32:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AEWnIx093014; Mon, 10 May 2021 14:32:49 GMT (envelope-from git) Date: Mon, 10 May 2021 14:32:49 GMT Message-Id: <202105101432.14AEWnIx093014@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: b7622437f5fb - stable/13 - net: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7622437f5fb6bce84b42f3607e86729ad2a84b6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 14:32:49 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=b7622437f5fb6bce84b42f3607e86729ad2a84b6 commit b7622437f5fb6bce84b42f3607e86729ad2a84b6 Author: Hans Petter Selasky AuthorDate: 2021-05-10 14:30:44 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-10 14:30:44 +0000 net: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros Introduce convenience macros to retrieve the DSCP, ECN or traffic class bits from an IPv6 header. Use them where appropriate. Reviewed by: ae (previous version), rscheff, tuexen, rgrimes Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29056 (cherry picked from commit bb4a7d94b99fbf7f59c876ffff8ded5f6a5b5c3e) --- sys/net/altq/altq_subr.c | 2 +- sys/net/if_stf.c | 4 ++-- sys/netinet/ip6.h | 4 ++++ sys/netinet/tcp_input.c | 2 +- sys/netinet/tcp_stacks/rack_bbr_common.c | 2 +- sys/netinet6/frag6.c | 5 ++--- sys/netinet6/in6_gif.c | 2 +- sys/netinet6/ip6_output.c | 4 ++-- sys/netinet6/sctp6_usrreq.c | 2 +- sys/netpfil/pf/pf.c | 2 +- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sys/net/altq/altq_subr.c b/sys/net/altq/altq_subr.c index 9d998c40485c..ba1d3af5f5fd 100644 --- a/sys/net/altq/altq_subr.c +++ b/sys/net/altq/altq_subr.c @@ -1063,7 +1063,7 @@ altq_extractflow(m, af, flow, filt_bmask) fin6->fi6_family = AF_INET6; fin6->fi6_proto = ip6->ip6_nxt; - fin6->fi6_tclass = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + fin6->fi6_tclass = IPV6_TRAFFIC_CLASS(ip6); fin6->fi6_flowlabel = ip6->ip6_flow & htonl(0x000fffff); fin6->fi6_src = ip6->ip6_src; diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index c3f26db3f6e6..40f8a6f3a30a 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -455,7 +455,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } } ip6 = mtod(m, struct ip6_hdr *); - tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + tos = IPV6_TRAFFIC_CLASS(ip6); /* * Pickup the right outer dst addr from the list of candidates. @@ -665,7 +665,7 @@ in_stf_input(struct mbuf *m, int off, int proto, void *arg) return (IPPROTO_DONE); } - itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + itos = IPV6_TRAFFIC_CLASS(ip6); if ((ifp->if_flags & IFF_LINK1) != 0) ip_ecn_egress(ECN_ALLOWED, &otos, &itos); else diff --git a/sys/netinet/ip6.h b/sys/netinet/ip6.h index 44c46fd3b71d..1bc79a98e689 100644 --- a/sys/netinet/ip6.h +++ b/sys/netinet/ip6.h @@ -106,6 +106,10 @@ struct ip6_hdr { #endif #define IPV6_FLOWLABEL_LEN 20 +#define IPV6_TRAFFIC_CLASS(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0xff) +#define IPV6_DSCP(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0xfc) +#define IPV6_ECN(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0x03) + /* * Extension Headers */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index eec722d8097e..b3d4ef5cf5de 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -690,7 +690,7 @@ tcp_input(struct mbuf **mp, int *offp, int proto) /* XXX stat */ goto drop; } - iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + iptos = IPV6_TRAFFIC_CLASS(ip6); } #endif #if defined(INET) && defined(INET6) diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c index e73a3e60fd64..b86a5d85fc76 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.c +++ b/sys/netinet/tcp_stacks/rack_bbr_common.c @@ -334,7 +334,7 @@ skip_vnet: m_freem(m); goto skipped_pkt; } - iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + iptos = IPV6_TRAFFIC_CLASS(ip6); break; } #endif diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index f227930743b7..1903b01e03d4 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -554,8 +554,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) q6->ip6q_ttl = IPV6_FRAGTTL; q6->ip6q_src = ip6->ip6_src; q6->ip6q_dst = ip6->ip6_dst; - q6->ip6q_ecn = - (ntohl(ip6->ip6_flow) >> 20) & IPTOS_ECN_MASK; + q6->ip6q_ecn = IPV6_ECN(ip6); q6->ip6q_unfrglen = -1; /* The 1st fragment has not arrived. */ /* Add the fragemented packet to the bucket. */ @@ -688,7 +687,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) * if CE is set, do not lose CE. * Drop if CE and not-ECT are mixed for the same packet. */ - ecn = (ntohl(ip6->ip6_flow) >> 20) & IPTOS_ECN_MASK; + ecn = IPV6_ECN(ip6); ecn0 = q6->ip6q_ecn; if (ecn == IPTOS_ECN_CE) { if (ecn0 == IPTOS_ECN_NOTECT) { diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index 33cc06d065b8..54cb81c6130f 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -344,7 +344,7 @@ in6_gif_input(struct mbuf *m, int off, int proto, void *arg) gifp = GIF2IFP(sc); if ((gifp->if_flags & IFF_UP) != 0) { ip6 = mtod(m, struct ip6_hdr *); - ecn = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + ecn = IPV6_TRAFFIC_CLASS(ip6); m_adj(m, off); gif_input(m, gifp, proto, ecn); } else { diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 58334788b05b..2b49a9f7c351 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -656,9 +656,9 @@ again: if (opt && opt->ip6po_tclass >= 0) { int mask = 0; - if ((ip6->ip6_flow & htonl(0xfc << 20)) == 0) + if (IPV6_DSCP(ip6) == 0) mask |= 0xfc; - if ((ip6->ip6_flow & htonl(0x03 << 20)) == 0) + if (IPV6_ECN(ip6) == 0) mask |= 0x03; if (mask != 0) ip6->ip6_flow |= htonl((opt->ip6po_tclass & mask) << 20); diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index b544d2975c6a..fcf15e4f81bf 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -141,7 +141,7 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port) if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { goto out; } - ecn_bits = ((ntohl(ip6->ip6_flow) >> 20) & 0x000000ff); + ecn_bits = IPV6_TRAFFIC_CLASS(ip6); if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { SCTP_STAT_INCR(sctps_recvhwcrc); compute_crc = 0; diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 20c3d160188f..815b847b6355 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6401,7 +6401,7 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb pd.sidx = (dir == PF_IN) ? 0 : 1; pd.didx = (dir == PF_IN) ? 1 : 0; pd.af = AF_INET6; - pd.tos = (ntohl(h->ip6_flow) >> 20) & 0xfc; + pd.tos = IPV6_DSCP(h); pd.tot_len = ntohs(h->ip6_plen) + sizeof(struct ip6_hdr); off = ((caddr_t)h - m->m_data) + sizeof(struct ip6_hdr); From owner-dev-commits-src-all@freebsd.org Mon May 10 15:02:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4405B63AB82; Mon, 10 May 2021 15:02:44 +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 4Ff46X19l5z3k7y; Mon, 10 May 2021 15:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 10C7C2692C; Mon, 10 May 2021 15:02:44 +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 14AF2h2O033253; Mon, 10 May 2021 15:02:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AF2hS6033252; Mon, 10 May 2021 15:02:43 GMT (envelope-from git) Date: Mon, 10 May 2021 15:02:43 GMT Message-Id: <202105101502.14AF2hS6033252@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 5e1753891a09 - stable/13 - nfsd: fix session slot handling for failed callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5e1753891a09df5411627e87bad7dc66226607d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:02:44 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=5e1753891a09df5411627e87bad7dc66226607d7 commit 5e1753891a09df5411627e87bad7dc66226607d7 Author: Rick Macklem AuthorDate: 2021-04-23 22:24:47 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 14:57:51 +0000 nfsd: fix session slot handling for failed callbacks When the NFSv4.1/4.2 server does a callback to a client on the back channel, it will use a session slot in the back channel session. If the back channel has failed, the callback will fail and, without this patch, the session slot will not be released. As more callbacks are attempted, all session slots can become busy and then the nfsd thread gets stuck waiting for a back channel session slot. This patch frees the session slot upon callback failure to avoid this problem. Without this patch, the problem can be avoided by leaving delegations disabled in the NFS server. (cherry picked from commit 4281bfec36285e2212f41568459c077bf4dbd91c) --- sys/fs/nfsserver/nfs_nfsdstate.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 60647ab288d8..430f09844b83 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -166,7 +166,8 @@ static int nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, int trunc, fhandle_t *fhp, struct nfsvattr *nap, nfsattrbit_t *attrbitp, int laytype, NFSPROC_T *p); static int nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, - uint32_t callback, int op, const char *optag, struct nfsdsession **sepp); + uint32_t callback, int op, const char *optag, struct nfsdsession **sepp, + int *slotposp); static u_int32_t nfsrv_nextclientindex(void); static u_int32_t nfsrv_nextstateindex(struct nfsclient *clp); static void nfsrv_markstable(struct nfsclient *clp); @@ -201,7 +202,7 @@ static void nfsrv_unlocklf(struct nfslockfile *lfp); static struct nfsdsession *nfsrv_findsession(uint8_t *sessionid); static int nfsrv_freesession(struct nfsdsession *sep, uint8_t *sessionid); static int nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, - int dont_replycache, struct nfsdsession **sepp); + int dont_replycache, struct nfsdsession **sepp, int *slotposp); static int nfsv4_getcbsession(struct nfsclient *clp, struct nfsdsession **sepp); static int nfsrv_addlayout(struct nfsrv_descript *nd, struct nfslayout **lypp, nfsv4stateid_t *stateidp, char *layp, int *layoutlenp, NFSPROC_T *p); @@ -4434,7 +4435,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, u_int32_t *tl; struct nfsrv_descript *nd; struct ucred *cred; - int error = 0; + int error = 0, slotpos; u_int32_t callback; struct nfsdsession *sep = NULL; uint64_t tval; @@ -4492,7 +4493,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (procnum == NFSV4OP_CBGETATTR) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBGETATTR, - "CB Getattr", &sep); + "CB Getattr", &sep, &slotpos); if (error != 0) { m_freem(nd->nd_mreq); goto errout; @@ -4502,7 +4503,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, } else if (procnum == NFSV4OP_CBRECALL) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBRECALL, - "CB Recall", &sep); + "CB Recall", &sep, &slotpos); if (error != 0) { m_freem(nd->nd_mreq); goto errout; @@ -4521,7 +4522,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, NFSD_DEBUG(4, "docallback layout recall\n"); nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, - NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep); + NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep, &slotpos); NFSD_DEBUG(4, "aft cbcallargs=%d\n", error); if (error != 0) { m_freem(nd->nd_mreq); @@ -4570,6 +4571,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (clp->lc_req.nr_client == NULL) { if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; + if (procnum != NFSV4PROC_CBNULL) + nfsv4_freeslot(&sep->sess_cbsess, slotpos); nfsrv_freesession(sep, NULL); } else if (nd->nd_procnum == NFSV4PROC_CBNULL) error = newnfs_connect(NULL, &clp->lc_req, cred, @@ -4601,6 +4604,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, error = ECONNREFUSED; } NFSD_DEBUG(4, "aft newnfs_request=%d\n", error); + if (error != 0 && procnum != NFSV4PROC_CBNULL) + nfsv4_freeslot(&sep->sess_cbsess, slotpos); nfsrv_freesession(sep, NULL); } else error = newnfs_request(nd, NULL, clp, &clp->lc_req, @@ -4663,7 +4668,8 @@ errout: */ static int nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, - uint32_t callback, int op, const char *optag, struct nfsdsession **sepp) + uint32_t callback, int op, const char *optag, struct nfsdsession **sepp, + int *slotposp) { uint32_t *tl; int error, len; @@ -4679,7 +4685,7 @@ nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, *tl++ = txdr_unsigned(callback); *tl++ = txdr_unsigned(2); *tl = txdr_unsigned(NFSV4OP_CBSEQUENCE); - error = nfsv4_setcbsequence(nd, clp, 1, sepp); + error = nfsv4_setcbsequence(nd, clp, 1, sepp, slotposp); if (error != 0) return (error); NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); @@ -6599,11 +6605,11 @@ nfsrv_teststateid(struct nfsrv_descript *nd, nfsv4stateid_t *stateidp, */ static int nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, - int dont_replycache, struct nfsdsession **sepp) + int dont_replycache, struct nfsdsession **sepp, int *slotposp) { struct nfsdsession *sep; uint32_t *tl, slotseq = 0; - int maxslot, slotpos; + int maxslot; uint8_t sessionid[NFSX_V4SESSIONID]; int error; @@ -6611,7 +6617,7 @@ nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, if (error != 0) return (error); sep = *sepp; - (void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, &slotpos, &maxslot, + (void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, slotposp, &maxslot, &slotseq, sessionid); KASSERT(maxslot >= 0, ("nfsv4_setcbsequence neg maxslot")); @@ -6621,7 +6627,7 @@ nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, tl += NFSX_V4SESSIONID / NFSX_UNSIGNED; nd->nd_slotseq = tl; *tl++ = txdr_unsigned(slotseq); - *tl++ = txdr_unsigned(slotpos); + *tl++ = txdr_unsigned(*slotposp); *tl++ = txdr_unsigned(maxslot); if (dont_replycache == 0) *tl++ = newnfs_true; From owner-dev-commits-src-all@freebsd.org Mon May 10 15:08:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6308963AB7B; Mon, 10 May 2021 15:08:10 +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 4Ff4Dp2PWzz3jyH; Mon, 10 May 2021 15:08:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4541A26744; Mon, 10 May 2021 15:08:10 +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 14AF8AdF033711; Mon, 10 May 2021 15:08:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AF8Avq033710; Mon, 10 May 2021 15:08:10 GMT (envelope-from git) Date: Mon, 10 May 2021 15:08:10 GMT Message-Id: <202105101508.14AF8Avq033710@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 272f39942254 - stable/13 - nfsd: fix the slot sequence# when a callback fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 272f39942254ea721a06413241ae2632cdd45077 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:08:10 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=272f39942254ea721a06413241ae2632cdd45077 commit 272f39942254ea721a06413241ae2632cdd45077 Author: Rick Macklem AuthorDate: 2021-04-26 23:24:10 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 15:01:42 +0000 nfsd: fix the slot sequence# when a callback fails Commit 4281bfec3628 patched the server so that the callback session slot would be free'd for reuse when a callback attempt fails. However, this can often result in the sequence# for the session slot to be advanced such that the client end will reply NFSERR_SEQMISORDERED. To avoid the NFSERR_SEQMISORDERED client reply, this patch negates the sequence# advance for the case where the callback has failed. The common case is a failed back channel, where the callback cannot be sent to the client, and not advancing the sequence# is correct for this case. For the uncommon case where the client's reply to the callback is lost, not advancing the sequence# will indicate to the client that the next callback is a retry and not a new callback. But, since the FreeBSD server always sets "csa_cachethis" false in the callback sequence operation, a retry and a new callback should be handled the same way by the client, so this should not matter. Until you have this patch in your NFSv4.1/4.2 server, you should consider avoiding the use of delegations. Even with this patch, interoperation with the Linux NFSv4.1/4.2 client in kernel versions prior to 5.3 can result in frequent 15second delays if delegations are enabled. This occurs because, for kernels prior to 5.3, the Linux client does a TCP reconnect every time it sees multiple concurrent callbacks and then it takes 15seconds to recover the back channel after doing so. (cherry picked from commit 87597731488105dd1ab921a95e39bb62e1abe668) --- sys/fs/nfs/nfs_commonkrpc.c | 4 ++-- sys/fs/nfs/nfs_commonsubs.c | 4 +++- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsserver/nfs_nfsdstate.c | 23 ++++++++++++++++++++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index daf8082fa1c3..6e766abcf4b1 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -871,7 +871,7 @@ tryagain: sep->nfsess_slotseq[nd->nd_slotid] += 10; mtx_unlock(&sep->nfsess_mtx); /* And free the slot. */ - nfsv4_freeslot(sep, nd->nd_slotid); + nfsv4_freeslot(sep, nd->nd_slotid, false); } NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = ENXIO; @@ -1108,7 +1108,7 @@ tryagain: if ((nd->nd_flag & ND_NFSV4) != 0) { /* Free the slot, as required. */ if (freeslot != -1) - nfsv4_freeslot(sep, freeslot); + nfsv4_freeslot(sep, freeslot, false); /* * If this op is Putfh, throw its results away. */ diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index a30ee458e06c..539cbbbde7d2 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -4811,7 +4811,7 @@ nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsclsession *sep, * Free a session slot. */ void -nfsv4_freeslot(struct nfsclsession *sep, int slot) +nfsv4_freeslot(struct nfsclsession *sep, int slot, bool resetseq) { uint64_t bitval; @@ -4819,6 +4819,8 @@ nfsv4_freeslot(struct nfsclsession *sep, int slot) if (slot > 0) bitval <<= slot; mtx_lock(&sep->nfsess_mtx); + if (resetseq) + sep->nfsess_slotseq[slot]--; if ((bitval & sep->nfsess_slots) == 0) printf("freeing free slot!!\n"); sep->nfsess_slots &= ~bitval; diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 0297b52015f8..23ba0e3893db 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -355,7 +355,7 @@ void nfsv4_setsequence(struct nfsmount *, struct nfsrv_descript *, struct nfsclsession *, int); int nfsv4_sequencelookup(struct nfsmount *, struct nfsclsession *, int *, int *, uint32_t *, uint8_t *); -void nfsv4_freeslot(struct nfsclsession *, int); +void nfsv4_freeslot(struct nfsclsession *, int, bool); struct ucred *nfsrv_getgrpscred(struct ucred *); struct nfsdevice *nfsv4_findmirror(struct nfsmount *); void nfsm_set(struct nfsrv_descript *, u_int); diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 430f09844b83..3aebddad0962 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -4572,7 +4572,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; if (procnum != NFSV4PROC_CBNULL) - nfsv4_freeslot(&sep->sess_cbsess, slotpos); + nfsv4_freeslot(&sep->sess_cbsess, slotpos, + true); nfsrv_freesession(sep, NULL); } else if (nd->nd_procnum == NFSV4PROC_CBNULL) error = newnfs_connect(NULL, &clp->lc_req, cred, @@ -4604,8 +4605,24 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, error = ECONNREFUSED; } NFSD_DEBUG(4, "aft newnfs_request=%d\n", error); - if (error != 0 && procnum != NFSV4PROC_CBNULL) - nfsv4_freeslot(&sep->sess_cbsess, slotpos); + if (error != 0 && procnum != NFSV4PROC_CBNULL) { + /* + * It is likely that the callback was never + * processed by the client and, as such, + * the sequence# for the session slot needs + * to be backed up by one to avoid a + * NFSERR_SEQMISORDERED error reply. + * For the unlikely case where the callback + * was processed by the client, this will + * make the next callback on the slot + * appear to be a retry. + * Since callbacks never specify that the + * reply be cached, this "apparent retry" + * should not be a problem. + */ + nfsv4_freeslot(&sep->sess_cbsess, slotpos, + true); + } nfsrv_freesession(sep, NULL); } else error = newnfs_request(nd, NULL, clp, &clp->lc_req, From owner-dev-commits-src-all@freebsd.org Mon May 10 15:17:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFF9A63AC78; Mon, 10 May 2021 15:17:37 +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 4Ff4Rj6SMQz3kPx; Mon, 10 May 2021 15:17:37 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CC4E926B96; Mon, 10 May 2021 15:17:37 +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 14AFHbO3046754; Mon, 10 May 2021 15:17:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AFHbil046753; Mon, 10 May 2021 15:17:37 GMT (envelope-from git) Date: Mon, 10 May 2021 15:17:37 GMT Message-Id: <202105101517.14AFHbil046753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 8f81f190a640 - stable/13 - param.h: Bump __FreeBSD_version to 1300505 for 272f39942254 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8f81f190a640e211dd814bdde7811982b9491fb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:17:38 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=8f81f190a640e211dd814bdde7811982b9491fb0 commit 8f81f190a640e211dd814bdde7811982b9491fb0 Author: Rick Macklem AuthorDate: 2021-05-10 15:14:57 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 15:14:57 +0000 param.h: Bump __FreeBSD_version to 1300505 for 272f39942254 Commit 272f39942254 changed the internal KAPI between the nscl.ko and nfscommon.ko modules, so they both need to be rebuilt from sources. --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index db5a31d60267..3d1ab448eae4 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300504 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300505 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-all@freebsd.org Mon May 10 15:23:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86F4963B193; Mon, 10 May 2021 15:23:26 +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 4Ff4ZQ3TPpz3l3T; Mon, 10 May 2021 15:23:26 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6A60E26EFC; Mon, 10 May 2021 15:23:26 +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 14AFNQQn059480; Mon, 10 May 2021 15:23:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AFNQJ3059479; Mon, 10 May 2021 15:23:26 GMT (envelope-from git) Date: Mon, 10 May 2021 15:23:26 GMT Message-Id: <202105101523.14AFNQJ3059479@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 4e1c728f1926 - stable/13 - UPDATING: Add an entry for commit 272f39942254 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4e1c728f1926b8563358ffb2df2e6e9d79000db9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:23:26 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=4e1c728f1926b8563358ffb2df2e6e9d79000db9 commit 4e1c728f1926b8563358ffb2df2e6e9d79000db9 Author: Rick Macklem AuthorDate: 2021-05-10 15:20:48 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 15:20:48 +0000 UPDATING: Add an entry for commit 272f39942254 --- UPDATING | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPDATING b/UPDATING index 7a07f2d8fe35..f7e3996e8d48 100644 --- a/UPDATING +++ b/UPDATING @@ -12,6 +12,11 @@ Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before updating system packages and/or ports. +20210510: + Commit 272f39942254 changed the internal KAPI between the + nscl.ko and nfscommon.ko modules, so they both need to be + rebuilt from sources. + 20210429: Commit 5a45802b3c8c changed the internal KAPI between the krpc and NFS. As such, the krpc, nfscommon and From owner-dev-commits-src-all@freebsd.org Mon May 10 15:31:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7753D63B070; Mon, 10 May 2021 15:31:21 +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 4Ff4lY30Pmz3l7f; Mon, 10 May 2021 15:31:21 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 59B8F26B59; Mon, 10 May 2021 15:31: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 14AFVLRi069109; Mon, 10 May 2021 15:31:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AFVLcE069108; Mon, 10 May 2021 15:31:21 GMT (envelope-from git) Date: Mon, 10 May 2021 15:31:21 GMT Message-Id: <202105101531.14AFVLcE069108@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 9867224bab3f - main - tcp:Host cache and rack ending up with incorrect values. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9867224bab3f247ac875d89c2472aa4bc855fe3b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:31:21 -0000 The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=9867224bab3f247ac875d89c2472aa4bc855fe3b commit 9867224bab3f247ac875d89c2472aa4bc855fe3b Author: Randall Stewart AuthorDate: 2021-05-10 15:25:51 +0000 Commit: Randall Stewart CommitDate: 2021-05-10 15:25:51 +0000 tcp:Host cache and rack ending up with incorrect values. The hostcache up to now as been updated in the discard callback but without checking if we are all done (the race where there are more than one calls and the counter has not yet reached zero). This means that when the race occurs, we end up calling the hc_upate more than once. Also alternate stacks can keep there srtt/rttvar in different formats (example rack keeps its values in microseconds). Since we call the hc_update *before* the stack fini() then the values will be in the wrong format. Rack on the other hand, needs to convert items pulled from the hostcache into its internal format else it may end up with very much incorrect values from the hostcache. In the process lets commonize the update mechanism for srtt/rttvar since we now have more than one place that needs to call it. Reviewed by: Michael Tuexen Sponsored by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30172 --- sys/netinet/tcp_stacks/rack.c | 102 ++++++++++++++++++++---------------- sys/netinet/tcp_subr.c | 118 ++++++++++++++++++++++-------------------- 2 files changed, 119 insertions(+), 101 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 7c59d8097e22..865e54c90e6a 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -6563,13 +6563,65 @@ rack_remxt_tmr(struct tcpcb *tp) rack->r_ctl.rc_snd_max_at_rto = tp->snd_max; } +static void +rack_convert_rtts(struct tcpcb *tp) +{ + if (tp->t_srtt > 1) { + uint32_t val, frac; + + val = tp->t_srtt >> TCP_RTT_SHIFT; + frac = tp->t_srtt & 0x1f; + tp->t_srtt = TICKS_2_USEC(val); + /* + * frac is the fractional part of the srtt (if any) + * but its in ticks and every bit represents + * 1/32nd of a hz. + */ + if (frac) { + if (hz == 1000) { + frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); + } else { + frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); + } + tp->t_srtt += frac; + } + } + if (tp->t_rttvar) { + uint32_t val, frac; + + val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; + frac = tp->t_rttvar & 0x1f; + tp->t_rttvar = TICKS_2_USEC(val); + /* + * frac is the fractional part of the srtt (if any) + * but its in ticks and every bit represents + * 1/32nd of a hz. + */ + if (frac) { + if (hz == 1000) { + frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); + } else { + frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); + } + tp->t_rttvar += frac; + } + } + RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), + rack_rto_min, rack_rto_max); +} + static void rack_cc_conn_init(struct tcpcb *tp) { struct tcp_rack *rack; rack = (struct tcp_rack *)tp->t_fb_ptr; + cc_conn_init(tp); + /* + * Now convert to rack's internal format. + */ + rack_convert_rtts(tp); /* * We want a chance to stay in slowstart as * we create a connection. TCP spec says that @@ -11916,9 +11968,9 @@ rack_init_fsb_block(struct tcpcb *tp, struct tcp_rack *rack) static int rack_init_fsb(struct tcpcb *tp, struct tcp_rack *rack) { - /* - * Allocate the larger of spaces V6 if available else just - * V4 and include udphdr (overbook) + /* + * Allocate the larger of spaces V6 if available else just + * V4 and include udphdr (overbook) */ #ifdef INET6 rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + sizeof(struct udphdr); @@ -12147,47 +12199,7 @@ rack_init(struct tcpcb *tp) * bit decimal so we have to carefully convert * these to get the full precision. */ - if (tp->t_srtt > 1) { - uint32_t val, frac; - - val = tp->t_srtt >> TCP_RTT_SHIFT; - frac = tp->t_srtt & 0x1f; - tp->t_srtt = TICKS_2_USEC(val); - /* - * frac is the fractional part of the srtt (if any) - * but its in ticks and every bit represents - * 1/32nd of a hz. - */ - if (frac) { - if (hz == 1000) { - frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); - } else { - frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); - } - tp->t_srtt += frac; - } - } - if (tp->t_rttvar) { - uint32_t val, frac; - - val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; - frac = tp->t_rttvar & 0x1f; - tp->t_rttvar = TICKS_2_USEC(val); - /* - * frac is the fractional part of the srtt (if any) - * but its in ticks and every bit represents - * 1/32nd of a hz. - */ - if (frac) { - if (hz == 1000) { - frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); - } else { - frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); - } - tp->t_rttvar += frac; - } - } - tp->t_rxtcur = TICKS_2_USEC(tp->t_rxtcur); + rack_convert_rtts(tp); tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); if (rack_def_profile) rack_set_profile(rack, rack_def_profile); @@ -12230,7 +12242,7 @@ rack_init(struct tcpcb *tp) rack_stop_all_timers(tp); /* Lets setup the fsb block */ rack_start_hpts_timer(rack, tp, tcp_get_usecs(NULL), 0, 0, 0); - rack_log_rtt_shrinks(rack, us_cts, 0, + rack_log_rtt_shrinks(rack, us_cts, tp->t_rxtcur, __LINE__, RACK_RTTS_INIT); return (0); } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 51bb749c99d8..5f2997163471 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2309,62 +2309,6 @@ tcp_discardcb(struct tcpcb *tp) tp->t_fb->tfb_tcp_timer_stop_all(tp); } - /* - * If we got enough samples through the srtt filter, - * save the rtt and rttvar in the routing entry. - * 'Enough' is arbitrarily defined as 4 rtt samples. - * 4 samples is enough for the srtt filter to converge - * to within enough % of the correct value; fewer samples - * and we could save a bogus rtt. The danger is not high - * as tcp quickly recovers from everything. - * XXX: Works very well but needs some more statistics! - */ - if (tp->t_rttupdated >= 4) { - struct hc_metrics_lite metrics; - uint32_t ssthresh; - - bzero(&metrics, sizeof(metrics)); - /* - * Update the ssthresh always when the conditions below - * are satisfied. This gives us better new start value - * for the congestion avoidance for new connections. - * ssthresh is only set if packet loss occurred on a session. - * - * XXXRW: 'so' may be NULL here, and/or socket buffer may be - * being torn down. Ideally this code would not use 'so'. - */ - ssthresh = tp->snd_ssthresh; - if (ssthresh != 0 && ssthresh < so->so_snd.sb_hiwat / 2) { - /* - * convert the limit from user data bytes to - * packets then to packet data bytes. - */ - ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg; - if (ssthresh < 2) - ssthresh = 2; - ssthresh *= (tp->t_maxseg + -#ifdef INET6 - (isipv6 ? sizeof (struct ip6_hdr) + - sizeof (struct tcphdr) : -#endif - sizeof (struct tcpiphdr) -#ifdef INET6 - ) -#endif - ); - } else - ssthresh = 0; - metrics.rmx_ssthresh = ssthresh; - - metrics.rmx_rtt = tp->t_srtt; - metrics.rmx_rttvar = tp->t_rttvar; - metrics.rmx_cwnd = tp->snd_cwnd; - metrics.rmx_sendpipe = 0; - metrics.rmx_recvpipe = 0; - - tcp_hc_update(&inp->inp_inc, &metrics); - } - /* free the reassembly queue, if any */ tcp_reass_flush(tp); @@ -2404,6 +2348,68 @@ tcp_discardcb(struct tcpcb *tp) TCPSTATES_DEC(tp->t_state); if (tp->t_fb->tfb_tcp_fb_fini) (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1); + + /* + * If we got enough samples through the srtt filter, + * save the rtt and rttvar in the routing entry. + * 'Enough' is arbitrarily defined as 4 rtt samples. + * 4 samples is enough for the srtt filter to converge + * to within enough % of the correct value; fewer samples + * and we could save a bogus rtt. The danger is not high + * as tcp quickly recovers from everything. + * XXX: Works very well but needs some more statistics! + * + * XXXRRS: Updating must be after the stack fini() since + * that may be converting some internal representation of + * say srtt etc into the general one used by other stacks. + * Lets also at least protect against the so being NULL + * as RW stated below. + */ + if ((tp->t_rttupdated >= 4) && (so != NULL)) { + struct hc_metrics_lite metrics; + uint32_t ssthresh; + + bzero(&metrics, sizeof(metrics)); + /* + * Update the ssthresh always when the conditions below + * are satisfied. This gives us better new start value + * for the congestion avoidance for new connections. + * ssthresh is only set if packet loss occurred on a session. + * + * XXXRW: 'so' may be NULL here, and/or socket buffer may be + * being torn down. Ideally this code would not use 'so'. + */ + ssthresh = tp->snd_ssthresh; + if (ssthresh != 0 && ssthresh < so->so_snd.sb_hiwat / 2) { + /* + * convert the limit from user data bytes to + * packets then to packet data bytes. + */ + ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg; + if (ssthresh < 2) + ssthresh = 2; + ssthresh *= (tp->t_maxseg + +#ifdef INET6 + (isipv6 ? sizeof (struct ip6_hdr) + + sizeof (struct tcphdr) : +#endif + sizeof (struct tcpiphdr) +#ifdef INET6 + ) +#endif + ); + } else + ssthresh = 0; + metrics.rmx_ssthresh = ssthresh; + + metrics.rmx_rtt = tp->t_srtt; + metrics.rmx_rttvar = tp->t_rttvar; + metrics.rmx_cwnd = tp->snd_cwnd; + metrics.rmx_sendpipe = 0; + metrics.rmx_recvpipe = 0; + + tcp_hc_update(&inp->inp_inc, &metrics); + } refcount_release(&tp->t_fb->tfb_refcnt); tp->t_inpcb = NULL; uma_zfree(V_tcpcb_zone, tp); From owner-dev-commits-src-all@freebsd.org Mon May 10 15:54:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54FE463C0A7; Mon, 10 May 2021 15:54:25 +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 4Ff5G91yNSz3mhv; Mon, 10 May 2021 15:54:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 360F62715C; Mon, 10 May 2021 15:54:25 +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 14AFsPqC098898; Mon, 10 May 2021 15:54:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AFsPcD098897; Mon, 10 May 2021 15:54:25 GMT (envelope-from git) Date: Mon, 10 May 2021 15:54:25 GMT Message-Id: <202105101554.14AFsPcD098897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: c86420ea7dcd - stable/12 - nfsd: fix session slot handling for failed callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c86420ea7dcda16b4fd32c19cde54b128677f371 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:54:25 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=c86420ea7dcda16b4fd32c19cde54b128677f371 commit c86420ea7dcda16b4fd32c19cde54b128677f371 Author: Rick Macklem AuthorDate: 2021-04-23 22:24:47 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 15:51:18 +0000 nfsd: fix session slot handling for failed callbacks When the NFSv4.1/4.2 server does a callback to a client on the back channel, it will use a session slot in the back channel session. If the back channel has failed, the callback will fail and, without this patch, the session slot will not be released. As more callbacks are attempted, all session slots can become busy and then the nfsd thread gets stuck waiting for a back channel session slot. This patch frees the session slot upon callback failure to avoid this problem. Without this patch, the problem can be avoided by leaving delegations disabled in the NFS server. (cherry picked from commit 4281bfec36285e2212f41568459c077bf4dbd91c) --- sys/fs/nfsserver/nfs_nfsdstate.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index f0c72487121c..a093d5db9a18 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -166,7 +166,8 @@ static int nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, int trunc, fhandle_t *fhp, struct nfsvattr *nap, nfsattrbit_t *attrbitp, int laytype, NFSPROC_T *p); static int nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, - uint32_t callback, int op, const char *optag, struct nfsdsession **sepp); + uint32_t callback, int op, const char *optag, struct nfsdsession **sepp, + int *slotposp); static u_int32_t nfsrv_nextclientindex(void); static u_int32_t nfsrv_nextstateindex(struct nfsclient *clp); static void nfsrv_markstable(struct nfsclient *clp); @@ -201,7 +202,7 @@ static void nfsrv_unlocklf(struct nfslockfile *lfp); static struct nfsdsession *nfsrv_findsession(uint8_t *sessionid); static int nfsrv_freesession(struct nfsdsession *sep, uint8_t *sessionid); static int nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, - int dont_replycache, struct nfsdsession **sepp); + int dont_replycache, struct nfsdsession **sepp, int *slotposp); static int nfsv4_getcbsession(struct nfsclient *clp, struct nfsdsession **sepp); static int nfsrv_addlayout(struct nfsrv_descript *nd, struct nfslayout **lypp, nfsv4stateid_t *stateidp, char *layp, int *layoutlenp, NFSPROC_T *p); @@ -4430,7 +4431,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, u_int32_t *tl; struct nfsrv_descript *nd; struct ucred *cred; - int error = 0; + int error = 0, slotpos; u_int32_t callback; struct nfsdsession *sep = NULL; uint64_t tval; @@ -4485,7 +4486,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (procnum == NFSV4OP_CBGETATTR) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBGETATTR, - "CB Getattr", &sep); + "CB Getattr", &sep, &slotpos); if (error != 0) { mbuf_freem(nd->nd_mreq); goto errout; @@ -4495,7 +4496,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, } else if (procnum == NFSV4OP_CBRECALL) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBRECALL, - "CB Recall", &sep); + "CB Recall", &sep, &slotpos); if (error != 0) { mbuf_freem(nd->nd_mreq); goto errout; @@ -4514,7 +4515,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, NFSD_DEBUG(4, "docallback layout recall\n"); nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, - NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep); + NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep, &slotpos); NFSD_DEBUG(4, "aft cbcallargs=%d\n", error); if (error != 0) { mbuf_freem(nd->nd_mreq); @@ -4560,6 +4561,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (clp->lc_req.nr_client == NULL) { if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; + if (procnum != NFSV4PROC_CBNULL) + nfsv4_freeslot(&sep->sess_cbsess, slotpos); nfsrv_freesession(sep, NULL); } else if (nd->nd_procnum == NFSV4PROC_CBNULL) error = newnfs_connect(NULL, &clp->lc_req, cred, @@ -4591,6 +4594,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, error = ECONNREFUSED; } NFSD_DEBUG(4, "aft newnfs_request=%d\n", error); + if (error != 0 && procnum != NFSV4PROC_CBNULL) + nfsv4_freeslot(&sep->sess_cbsess, slotpos); nfsrv_freesession(sep, NULL); } else error = newnfs_request(nd, NULL, clp, &clp->lc_req, @@ -4653,7 +4658,8 @@ errout: */ static int nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, - uint32_t callback, int op, const char *optag, struct nfsdsession **sepp) + uint32_t callback, int op, const char *optag, struct nfsdsession **sepp, + int *slotposp) { uint32_t *tl; int error, len; @@ -4666,7 +4672,7 @@ nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, *tl++ = txdr_unsigned(callback); *tl++ = txdr_unsigned(2); *tl = txdr_unsigned(NFSV4OP_CBSEQUENCE); - error = nfsv4_setcbsequence(nd, clp, 1, sepp); + error = nfsv4_setcbsequence(nd, clp, 1, sepp, slotposp); if (error != 0) return (error); NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); @@ -6575,11 +6581,11 @@ nfsrv_teststateid(struct nfsrv_descript *nd, nfsv4stateid_t *stateidp, */ static int nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, - int dont_replycache, struct nfsdsession **sepp) + int dont_replycache, struct nfsdsession **sepp, int *slotposp) { struct nfsdsession *sep; uint32_t *tl, slotseq = 0; - int maxslot, slotpos; + int maxslot; uint8_t sessionid[NFSX_V4SESSIONID]; int error; @@ -6587,7 +6593,7 @@ nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, if (error != 0) return (error); sep = *sepp; - (void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, &slotpos, &maxslot, + (void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, slotposp, &maxslot, &slotseq, sessionid); KASSERT(maxslot >= 0, ("nfsv4_setcbsequence neg maxslot")); @@ -6597,7 +6603,7 @@ nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, tl += NFSX_V4SESSIONID / NFSX_UNSIGNED; nd->nd_slotseq = tl; *tl++ = txdr_unsigned(slotseq); - *tl++ = txdr_unsigned(slotpos); + *tl++ = txdr_unsigned(*slotposp); *tl++ = txdr_unsigned(maxslot); if (dont_replycache == 0) *tl++ = newnfs_true; From owner-dev-commits-src-all@freebsd.org Mon May 10 15:56:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DC9463C043; Mon, 10 May 2021 15:56:17 +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 4Ff5JK0s4Nz3mfn; Mon, 10 May 2021 15:56:17 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1034F2715F; Mon, 10 May 2021 15:56:17 +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 14AFuGkP099147; Mon, 10 May 2021 15:56:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AFuGN9099146; Mon, 10 May 2021 15:56:16 GMT (envelope-from git) Date: Mon, 10 May 2021 15:56:16 GMT Message-Id: <202105101556.14AFuGN9099146@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: e9959506d2cc - stable/12 - nfsd: fix the slot sequence# when a callback fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e9959506d2cc2fd728be8cef5babbcd019c4fcd2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 15:56:17 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=e9959506d2cc2fd728be8cef5babbcd019c4fcd2 commit e9959506d2cc2fd728be8cef5babbcd019c4fcd2 Author: Rick Macklem AuthorDate: 2021-04-26 23:24:10 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 15:53:15 +0000 nfsd: fix the slot sequence# when a callback fails Commit 4281bfec3628 patched the server so that the callback session slot would be free'd for reuse when a callback attempt fails. However, this can often result in the sequence# for the session slot to be advanced such that the client end will reply NFSERR_SEQMISORDERED. To avoid the NFSERR_SEQMISORDERED client reply, this patch negates the sequence# advance for the case where the callback has failed. The common case is a failed back channel, where the callback cannot be sent to the client, and not advancing the sequence# is correct for this case. For the uncommon case where the client's reply to the callback is lost, not advancing the sequence# will indicate to the client that the next callback is a retry and not a new callback. But, since the FreeBSD server always sets "csa_cachethis" false in the callback sequence operation, a retry and a new callback should be handled the same way by the client, so this should not matter. Until you have this patch in your NFSv4.1/4.2 server, you should consider avoiding the use of delegations. Even with this patch, interoperation with the Linux NFSv4.1/4.2 client in kernel versions prior to 5.3 can result in frequent 15second delays if delegations are enabled. This occurs because, for kernels prior to 5.3, the Linux client does a TCP reconnect every time it sees multiple concurrent callbacks and then it takes 15seconds to recover the back channel after doing so. (cherry picked from commit 87597731488105dd1ab921a95e39bb62e1abe668) --- sys/fs/nfs/nfs_commonkrpc.c | 4 ++-- sys/fs/nfs/nfs_commonsubs.c | 4 +++- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsserver/nfs_nfsdstate.c | 23 ++++++++++++++++++++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 78b6d0ed6985..449b3ad5e4a7 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -866,7 +866,7 @@ tryagain: sep->nfsess_slotseq[nd->nd_slotid] += 10; mtx_unlock(&sep->nfsess_mtx); /* And free the slot. */ - nfsv4_freeslot(sep, nd->nd_slotid); + nfsv4_freeslot(sep, nd->nd_slotid, false); } NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = ENXIO; @@ -1103,7 +1103,7 @@ tryagain: if ((nd->nd_flag & ND_NFSV4) != 0) { /* Free the slot, as required. */ if (freeslot != -1) - nfsv4_freeslot(sep, freeslot); + nfsv4_freeslot(sep, freeslot, false); /* * If this op is Putfh, throw its results away. */ diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 39cf9e9fc819..390d6e91535f 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -4751,7 +4751,7 @@ nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsclsession *sep, * Free a session slot. */ void -nfsv4_freeslot(struct nfsclsession *sep, int slot) +nfsv4_freeslot(struct nfsclsession *sep, int slot, bool resetseq) { uint64_t bitval; @@ -4759,6 +4759,8 @@ nfsv4_freeslot(struct nfsclsession *sep, int slot) if (slot > 0) bitval <<= slot; mtx_lock(&sep->nfsess_mtx); + if (resetseq) + sep->nfsess_slotseq[slot]--; if ((bitval & sep->nfsess_slots) == 0) printf("freeing free slot!!\n"); sep->nfsess_slots &= ~bitval; diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 9c8942e27132..bee66d15b016 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -345,7 +345,7 @@ void nfsv4_setsequence(struct nfsmount *, struct nfsrv_descript *, struct nfsclsession *, int); int nfsv4_sequencelookup(struct nfsmount *, struct nfsclsession *, int *, int *, uint32_t *, uint8_t *); -void nfsv4_freeslot(struct nfsclsession *, int); +void nfsv4_freeslot(struct nfsclsession *, int, bool); struct ucred *nfsrv_getgrpscred(struct ucred *); struct nfsdevice *nfsv4_findmirror(struct nfsmount *); diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index a093d5db9a18..9171891478c1 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -4562,7 +4562,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; if (procnum != NFSV4PROC_CBNULL) - nfsv4_freeslot(&sep->sess_cbsess, slotpos); + nfsv4_freeslot(&sep->sess_cbsess, slotpos, + true); nfsrv_freesession(sep, NULL); } else if (nd->nd_procnum == NFSV4PROC_CBNULL) error = newnfs_connect(NULL, &clp->lc_req, cred, @@ -4594,8 +4595,24 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, error = ECONNREFUSED; } NFSD_DEBUG(4, "aft newnfs_request=%d\n", error); - if (error != 0 && procnum != NFSV4PROC_CBNULL) - nfsv4_freeslot(&sep->sess_cbsess, slotpos); + if (error != 0 && procnum != NFSV4PROC_CBNULL) { + /* + * It is likely that the callback was never + * processed by the client and, as such, + * the sequence# for the session slot needs + * to be backed up by one to avoid a + * NFSERR_SEQMISORDERED error reply. + * For the unlikely case where the callback + * was processed by the client, this will + * make the next callback on the slot + * appear to be a retry. + * Since callbacks never specify that the + * reply be cached, this "apparent retry" + * should not be a problem. + */ + nfsv4_freeslot(&sep->sess_cbsess, slotpos, + true); + } nfsrv_freesession(sep, NULL); } else error = newnfs_request(nd, NULL, clp, &clp->lc_req, From owner-dev-commits-src-all@freebsd.org Mon May 10 16:03:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3ECB63C495; Mon, 10 May 2021 16:03:27 +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 4Ff5Sb4mj3z3mvj; Mon, 10 May 2021 16:03:27 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 96D122770F; Mon, 10 May 2021 16:03:27 +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 14AG3RGa012881; Mon, 10 May 2021 16:03:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AG3RPr012880; Mon, 10 May 2021 16:03:27 GMT (envelope-from git) Date: Mon, 10 May 2021 16:03:27 GMT Message-Id: <202105101603.14AG3RPr012880@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 1e279fe9deae - stable/12 - param.h: Bump __FreeBSD_version to 1202507 for commit e9959506d2cc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1e279fe9deaea1c5e3503117dd3077dcffb1276d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 16:03:27 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=1e279fe9deaea1c5e3503117dd3077dcffb1276d commit 1e279fe9deaea1c5e3503117dd3077dcffb1276d Author: Rick Macklem AuthorDate: 2021-05-10 16:00:50 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 16:00:50 +0000 param.h: Bump __FreeBSD_version to 1202507 for commit e9959506d2cc Commit e9959506d2cc changed the internal KAPI between the nfscl.ko and nfscommon.ko modules, so they both need to be rebuilt from sources. --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 89ab74bc07a6..1e3fd909956a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1202506 /* Master, propagated to newvers */ +#define __FreeBSD_version 1202507 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-all@freebsd.org Mon May 10 16:07:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77C8863C541; Mon, 10 May 2021 16:07:53 +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 4Ff5Yj316Cz3nFN; Mon, 10 May 2021 16:07:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5A31D2747E; Mon, 10 May 2021 16:07:53 +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 14AG7rQV013439; Mon, 10 May 2021 16:07:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AG7rlX013438; Mon, 10 May 2021 16:07:53 GMT (envelope-from git) Date: Mon, 10 May 2021 16:07:53 GMT Message-Id: <202105101607.14AG7rlX013438@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 304e740b7ea8 - stable/12 - UPDATING: Add an entry for commit e9959506d2cc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 304e740b7ea89c508efa5e47cbd9317d41e8e52f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 16:07:53 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=304e740b7ea89c508efa5e47cbd9317d41e8e52f commit 304e740b7ea89c508efa5e47cbd9317d41e8e52f Author: Rick Macklem AuthorDate: 2021-05-10 16:05:10 +0000 Commit: Rick Macklem CommitDate: 2021-05-10 16:05:10 +0000 UPDATING: Add an entry for commit e9959506d2cc --- UPDATING | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPDATING b/UPDATING index 225f0ca05baa..f1dceda848e2 100644 --- a/UPDATING +++ b/UPDATING @@ -17,6 +17,11 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210510: + Commit e9959506d2cc changed the internal KAPI between the + nscl.ko and nfscommon.ko modules, so they both need to be + rebuilt from sources. + 20210430: Commit 0a1fdb867c72 changed the internal KAPI between the krpc and NFS. As such, the krpc, nfscommon and From owner-dev-commits-src-all@freebsd.org Mon May 10 16:57:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D10A363DB82; Mon, 10 May 2021 16:57:28 +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 4Ff6fw5dXRz3qHW; Mon, 10 May 2021 16:57:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B433027F70; Mon, 10 May 2021 16:57:28 +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 14AGvSlB080051; Mon, 10 May 2021 16:57:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AGvSWf080050; Mon, 10 May 2021 16:57:28 GMT (envelope-from git) Date: Mon, 10 May 2021 16:57:28 GMT Message-Id: <202105101657.14AGvSWf080050@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 988b1bb0c54e - main - sh: implement persistent history storage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 988b1bb0c54e50654112f0bd649aee68307a5a80 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 16:57:28 -0000 The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=988b1bb0c54e50654112f0bd649aee68307a5a80 commit 988b1bb0c54e50654112f0bd649aee68307a5a80 Author: Baptiste Daroussin AuthorDate: 2021-03-30 08:28:08 +0000 Commit: Baptiste Daroussin CommitDate: 2021-05-10 16:57:13 +0000 sh: implement persistent history storage Implement persistent history storage: the strategy is simple at start: loads the existing .sh_history file at exit dump it. The implementation respects the HISTFILE variable and its POSIX definition: ~/.sh_history is used if HISTFILE is not set. to avoid sh to create the history file, set HISTSIZE to 0 or HISTFILE to en empty value Co-authored-by: pstef Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D29493 --- bin/sh/histedit.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/sh/main.c | 7 +++++++ bin/sh/myhistedit.h | 3 ++- bin/sh/sh.1 | 11 +++++++++- bin/sh/trap.c | 3 +++ 5 files changed, 81 insertions(+), 2 deletions(-) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index ba2bec357181..596145790f31 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -78,6 +79,64 @@ static int comparator(const void *, const void *, void *); static char **sh_matches(const char *, int, int); static unsigned char sh_complete(EditLine *, int); +static const char * +get_histfile(void) +{ + const char *histfile; + + /* don't try to save if the history size is 0 */ + if (hist == NULL || histsizeval() == 0) + return (NULL); + histfile = expandstr("${HISTFILE-${HOME-}/.sh_history}"); + + if (histfile[0] == '\0') + return (NULL); + return (histfile); +} + +void +histsave(void) +{ + HistEvent he; + char *histtmpname = NULL; + const char *histfile; + int fd; + FILE *f; + + if ((histfile = get_histfile()) == NULL) + return; + INTOFF; + asprintf(&histtmpname, "%s.XXXXXXXXXX", histfile); + if (histtmpname == NULL) { + INTON; + return; + } + fd = mkstemp(histtmpname); + if (fd == -1 || (f = fdopen(fd, "w")) == NULL) { + free(histtmpname); + INTON; + return; + } + if (history(hist, &he, H_SAVE_FP, f) < 1 || + rename(histtmpname, histfile) == -1) + unlink(histtmpname); + fclose(f); + free(histtmpname); + INTON; + +} + +void +histload(void) +{ + const char *histfile; + HistEvent he; + + if ((histfile = get_histfile()) == NULL) + return; + history(hist, &he, H_LOAD, histfile); +} + /* * Set history and editing status. Called whenever the status may * have changed (figures out what to do). diff --git a/bin/sh/main.c b/bin/sh/main.c index cbe026e13640..b0a5fac6fd4e 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -75,6 +75,9 @@ __FBSDID("$FreeBSD$"); #include "cd.h" #include "redir.h" #include "builtins.h" +#ifndef NO_HISTORY +#include "myhistedit.h" +#endif int rootpid; int rootshell; @@ -157,6 +160,10 @@ state2: read_profile(shinit); } } +#ifndef NO_HISTORY + if (iflag) + histload(); +#endif state3: state = 4; popstackmark(&smark2); diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index 968d23c9c1f8..1f513f0ae206 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -43,4 +43,5 @@ extern int displayhist; void histedit(void); void sethistsize(const char *); void setterm(const char *); - +void histload(void); +void histsave(void); diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 76335cfaa2cd..ca3faeff13af 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd July 6, 2020 +.Dd May 10, 2021 .Dt SH 1 .Os .Sh NAME @@ -1351,6 +1351,15 @@ If not set, the default editor is The default editor used with the .Ic fc built-in. +.It Va HISTFILE +File used for persistent history storage. +If unset +.Pa ~/.sh_history +will be used. +If set but empty or +.Va HISTSIZE +is set to 0 +the shell will not load and save the history. .It Va HISTSIZE The number of previous commands that are accessible. .It Va HOME diff --git a/bin/sh/trap.c b/bin/sh/trap.c index d7ef40274270..2dd394035ca4 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -535,6 +535,9 @@ exitshell_savedstatus(void) flushall(); #if JOBS setjobctl(0); +#endif +#ifndef NO_HISTORY + histsave(); #endif } if (sig != 0 && sig != SIGSTOP && sig != SIGTSTP && sig != SIGTTIN && From owner-dev-commits-src-all@freebsd.org Mon May 10 17:11:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE62763E322; Mon, 10 May 2021 17:11:31 +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 4Ff6z74csGz3rKX; Mon, 10 May 2021 17:11:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 91D781F8; Mon, 10 May 2021 17:11:31 +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 14AHBVPF006203; Mon, 10 May 2021 17:11:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AHBVbr006202; Mon, 10 May 2021 17:11:31 GMT (envelope-from git) Date: Mon, 10 May 2021 17:11:31 GMT Message-Id: <202105101711.14AHBVbr006202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 0471a8c73402 - main - tcp: SACK Lost Retransmission Detection (LRD) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0471a8c7340274a5cd4b8c963965493f459c9662 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 17:11:31 -0000 The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=0471a8c7340274a5cd4b8c963965493f459c9662 commit 0471a8c7340274a5cd4b8c963965493f459c9662 Author: Richard Scheffenegger AuthorDate: 2021-05-10 16:47:47 +0000 Commit: Richard Scheffenegger CommitDate: 2021-05-10 17:06:20 +0000 tcp: SACK Lost Retransmission Detection (LRD) Recover from excessive losses without reverting to a retransmission timeout (RTO). Disabled by default, enable with sysctl net.inet.tcp.do_lrd=1 Reviewed By: #transport, rrs, tuexen, #manpages Sponsored by: Netapp, Inc. Differential Revision: https://reviews.freebsd.org/D28931 --- share/man/man4/tcp.4 | 7 +++++ sys/netinet/tcp.h | 1 + sys/netinet/tcp_input.c | 14 ++++++++-- sys/netinet/tcp_output.c | 8 ++++++ sys/netinet/tcp_sack.c | 73 ++++++++++++++++++++++++++++++++++++++++++++---- sys/netinet/tcp_subr.c | 2 ++ sys/netinet/tcp_usrreq.c | 9 ++++++ sys/netinet/tcp_var.h | 9 ++++-- usr.bin/netstat/inet.c | 2 ++ 9 files changed, 114 insertions(+), 11 deletions(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index d06630aa8d44..93d1e075e92d 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -547,6 +547,13 @@ This gently reduces the congestion window during periods, where TCP is application limited and the network bandwidth is not utilized completely. That prevents self-inflicted packet losses once the application starts to transmit data at a higher speed. +.It Va do_lrd +Enable Lost Retransmission Detection for SACK-enabled sessions, disabled by +default. +Under severe congestion, a retransmission can be lost which then leads to a +mandatory Retransmission Timeout (RTO), followed by slow-start. +LRD will try to resend the repeatedly lost packet, preventing the time-consuming +RTO and performance reducing slow-start. .It Va do_prr Perform SACK loss recovery using the Proportional Rate Reduction (PRR) algorithm described in RFC6937. diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h index 50f0811a6517..7ba99df51ed3 100644 --- a/sys/netinet/tcp.h +++ b/sys/netinet/tcp.h @@ -199,6 +199,7 @@ struct tcphdr { #define TCP_PROC_ACCOUNTING 76 /* Do accounting on tcp cpu usage and counts */ #define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */ #define TCP_PERF_INFO 78 /* retrieve accounting counters */ +#define TCP_LRD 79 /* toggle Lost Retransmission Detection for A/B testing */ #define TCP_KEEPINIT 128 /* N, time to establish connection */ #define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */ #define TCP_KEEPINTVL 512 /* L,N interval between keepalives */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index bfa95feb7eee..49db8cc63cb3 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -164,6 +164,11 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, do_prr, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_prr), 1, "Enable Proportional Rate Reduction per RFC 6937"); +VNET_DEFINE(int, tcp_do_lrd) = 0; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, do_lrd, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(tcp_do_lrd), 1, + "Perform Lost Retransmission Detection"); + VNET_DEFINE(int, tcp_do_newcwv) = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, newcwv, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_newcwv), 0, @@ -2523,9 +2528,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, } if ((tp->t_flags & TF_SACK_PERMIT) && ((to.to_flags & TOF_SACK) || - !TAILQ_EMPTY(&tp->snd_holes))) - sack_changed = tcp_sack_doack(tp, &to, th->th_ack); - else + !TAILQ_EMPTY(&tp->snd_holes))) { + if (((sack_changed = tcp_sack_doack(tp, &to, th->th_ack)) != 0) && + (tp->t_flags & TF_LRD)) { + tcp_sack_lost_retransmission(tp, th); + } + } else /* * Reset the value so that previous (valid) value * from the last ack with SACK doesn't get used. diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 5bda2be14df0..20b9c0371122 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1264,6 +1264,14 @@ send: } else { th->th_seq = htonl(p->rxmit); p->rxmit += len; + /* + * Lost Retransmission Detection + * trigger resending of a (then + * still existing) hole, when + * fack acks recoverypoint. + */ + if ((tp->t_flags & TF_LRD) && SEQ_GEQ(p->rxmit, p->end)) + p->rxmit = tp->snd_recover; tp->sackhint.sack_bytes_rexmit += len; } if (IN_RECOVERY(tp->t_flags)) { diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index 96056b5efd4d..9753536926d5 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -119,6 +119,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef TCPDEBUG #include #endif /* TCPDEBUG */ @@ -730,7 +731,8 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) cur = TAILQ_PREV(cur, sackhole_head, scblink); continue; } - tp->sackhint.sack_bytes_rexmit -= (cur->rxmit - cur->start); + tp->sackhint.sack_bytes_rexmit -= + (SEQ_MIN(cur->rxmit, cur->end) - cur->start); KASSERT(tp->sackhint.sack_bytes_rexmit >= 0, ("sackhint bytes rtx >= 0")); sack_changed = 1; @@ -761,6 +763,8 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) delivered_data += (cur->end - sblkp->start); cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, cur->end); + if ((tp->t_flags & TF_LRD) && SEQ_GEQ(cur->rxmit, cur->end)) + cur->rxmit = tp->snd_recover; } else { /* * ACKs some data in middle of a hole; need @@ -771,18 +775,21 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) if (temp != NULL) { if (SEQ_GT(cur->rxmit, temp->rxmit)) { temp->rxmit = cur->rxmit; - tp->sackhint.sack_bytes_rexmit - += (temp->rxmit - - temp->start); + tp->sackhint.sack_bytes_rexmit += + (SEQ_MIN(temp->rxmit, + temp->end) - temp->start); } cur->end = sblkp->start; cur->rxmit = SEQ_MIN(cur->rxmit, cur->end); + if ((tp->t_flags & TF_LRD) && SEQ_GEQ(cur->rxmit, cur->end)) + cur->rxmit = tp->snd_recover; delivered_data += (sblkp->end - sblkp->start); } } } - tp->sackhint.sack_bytes_rexmit += (cur->rxmit - cur->start); + tp->sackhint.sack_bytes_rexmit += + (SEQ_MIN(cur->rxmit, cur->end) - cur->start); /* * Testing sblkp->start against cur->start tells us whether * we're done with the sack block or the sack hole. @@ -912,7 +919,7 @@ tcp_sack_output_debug(struct tcpcb *tp, int *sack_bytes_rexmt) *sack_bytes_rexmt += (p->rxmit - p->start); break; } - *sack_bytes_rexmt += (p->rxmit - p->start); + *sack_bytes_rexmt += (SEQ_MIN(p->rxmit, p->end) - p->start); } return (p); } @@ -989,3 +996,57 @@ tcp_sack_adjust(struct tcpcb *tp) return; tp->snd_nxt = tp->snd_fack; } + +/* + * Lost Retransmission Detection + * Check is FACK is beyond the rexmit of the leftmost hole. + * If yes, we restart sending from still existing holes, + * and adjust cwnd via the congestion control module. + */ +void +tcp_sack_lost_retransmission(struct tcpcb *tp, struct tcphdr *th) +{ + struct sackhole *temp; + uint32_t prev_cwnd; + if (IN_RECOVERY(tp->t_flags) && + SEQ_GT(tp->snd_fack, tp->snd_recover) && + ((temp = TAILQ_FIRST(&tp->snd_holes)) != NULL) && + SEQ_GEQ(temp->rxmit, temp->end) && + SEQ_GEQ(tp->snd_fack, temp->rxmit)) { + TCPSTAT_INC(tcps_sack_lostrexmt); + /* + * Start retransmissions from the first hole, and + * subsequently all other remaining holes, including + * those, which had been sent completely before. + */ + tp->sackhint.nexthole = temp; + TAILQ_FOREACH(temp, &tp->snd_holes, scblink) { + if (SEQ_GEQ(tp->snd_fack, temp->rxmit) && + SEQ_GEQ(temp->rxmit, temp->end)) + temp->rxmit = temp->start; + } + /* + * Remember the old ssthresh, to deduct the beta factor used + * by the CC module. Finally, set cwnd to ssthresh just + * prior to invoking another cwnd reduction by the CC + * module, to not shrink it excessively. + */ + prev_cwnd = tp->snd_cwnd; + tp->snd_cwnd = tp->snd_ssthresh; + /* + * Formally exit recovery, and let the CC module adjust + * ssthresh as intended. + */ + EXIT_RECOVERY(tp->t_flags); + cc_cong_signal(tp, th, CC_NDUPACK); + /* + * For PRR, adjust recover_fs as if this new reduction + * initialized this variable. + * cwnd will be adjusted by SACK or PRR processing + * subsequently, only set it to a safe value here. + */ + tp->snd_cwnd = tcp_maxseg(tp); + tp->sackhint.recover_fs = (tp->snd_max - tp->snd_una) - + tp->sackhint.recover_fs; + } +} diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 5f2997163471..c44f26f78a2f 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2171,6 +2171,8 @@ tcp_newtcpcb(struct inpcb *inp) if (V_tcp_perconn_stats_enable == 1) tp->t_stats = stats_blob_alloc(V_tcp_perconn_stats_dflt_tpl, 0); #endif + if (V_tcp_do_lrd) + tp->t_flags |= TF_LRD; return (tp); /* XXX */ } diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index cbc36860bf32..061681ddc2bc 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -2001,6 +2001,7 @@ tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp case TCP_NODELAY: case TCP_NOOPT: + case TCP_LRD: INP_WUNLOCK(inp); error = sooptcopyin(sopt, &optval, sizeof optval, sizeof optval); @@ -2015,6 +2016,9 @@ tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp case TCP_NOOPT: opt = TF_NOOPT; break; + case TCP_LRD: + opt = TF_LRD; + break; default: opt = 0; /* dead code to fool gcc */ break; @@ -2562,6 +2566,11 @@ unhold: error = sooptcopyout(sopt, &optval, sizeof(optval)); break; #endif + case TCP_LRD: + optval = tp->t_flags & TF_LRD; + INP_WUNLOCK(inp); + error = sooptcopyout(sopt, &optval, sizeof optval); + break; default: INP_WUNLOCK(inp); error = ENOPROTOOPT; diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 515362c6bf9e..b80746b1ede4 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -410,7 +410,7 @@ TAILQ_HEAD(tcp_funchead, tcp_function); #define TF_TOE 0x02000000 /* this connection is offloaded */ #define TF_WAKESOW 0x04000000 /* wake up send socket */ #define TF_UNUSED1 0x08000000 /* unused */ -#define TF_UNUSED2 0x10000000 /* unused */ +#define TF_LRD 0x10000000 /* Lost Retransmission Detection */ #define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */ #define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */ #define TF_FASTOPEN 0x80000000 /* TCP Fast Open indication */ @@ -673,6 +673,7 @@ struct tcpstat { uint64_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ uint64_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */ uint64_t tcps_sack_send_blocks; /* SACK blocks (options) sent */ + uint64_t tcps_sack_lostrexmt; /* SACK lost retransmission recovered */ uint64_t tcps_sack_sboverflow; /* times scoreboard overflowed */ /* ECN related stats */ @@ -697,7 +698,7 @@ struct tcpstat { uint64_t tcps_tunneled_pkts; /* Packets encap's in UDP received */ uint64_t tcps_tunneled_errs; /* Packets that had errors that were UDP encaped */ - uint64_t _pad[10]; /* 6 UTO, 6 TBD */ + uint64_t _pad[9]; /* 6 UTO, 3 TBD */ }; #define tcps_rcvmemdrop tcps_rcvreassfull /* compat */ @@ -859,6 +860,7 @@ VNET_DECLARE(int, tcp_delack_enabled); VNET_DECLARE(int, tcp_do_autorcvbuf); VNET_DECLARE(int, tcp_do_autosndbuf); VNET_DECLARE(int, tcp_do_ecn); +VNET_DECLARE(int, tcp_do_lrd); VNET_DECLARE(int, tcp_do_prr); VNET_DECLARE(int, tcp_do_prr_conservative); VNET_DECLARE(int, tcp_do_newcwv); @@ -893,6 +895,7 @@ VNET_DECLARE(int, tcp_udp_tunneling_port); VNET_DECLARE(struct inpcbhead, tcb); VNET_DECLARE(struct inpcbinfo, tcbinfo); +#define V_tcp_do_lrd VNET(tcp_do_lrd) #define V_tcp_do_prr VNET(tcp_do_prr) #define V_tcp_do_prr_conservative VNET(tcp_do_prr_conservative) #define V_tcp_do_newcwv VNET(tcp_do_newcwv) @@ -1091,8 +1094,10 @@ void tcp_clean_sackreport(struct tcpcb *tp); void tcp_sack_adjust(struct tcpcb *tp); struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *); +void tcp_lost_retransmission(struct tcpcb *, struct tcphdr *); void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); void tcp_free_sackholes(struct tcpcb *tp); +void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *); int tcp_newreno(struct tcpcb *, struct tcphdr *); int tcp_compute_pipe(struct tcpcb *); uint32_t tcp_compute_initwnd(uint32_t); diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 49478c4a9247..45b107b42d39 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -809,6 +809,8 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) "{N:/SACK option%s (SACK blocks) received}\n"); p(tcps_sack_send_blocks, "\t{:sent-option-blocks/%ju} " "{N:/SACK option%s (SACK blocks) sent}\n"); + p(tcps_sack_lostrexmit, "\t{:lost-retransmissions/%ju} " + "{N:/SACK retransmission%s lost}\n"); p1a(tcps_sack_sboverflow, "\t{:scoreboard-overflows/%ju} " "{N:/SACK scoreboard overflow}\n"); From owner-dev-commits-src-all@freebsd.org Mon May 10 18:50:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C53546403FA; Mon, 10 May 2021 18:50: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 4Ff98n53kxz3wHg; Mon, 10 May 2021 18:50:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9C74F18F6; Mon, 10 May 2021 18:50:01 +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 14AIo17Y028779; Mon, 10 May 2021 18:50:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AIo1WJ028764; Mon, 10 May 2021 18:50:01 GMT (envelope-from git) Date: Mon, 10 May 2021 18:50:01 GMT Message-Id: <202105101850.14AIo1WJ028764@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: c55b340f824d - main - netstat: fix typo from 0471a8c73402 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c55b340f824d353b7581e8ccf94ecd4929a41ea5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 18:50:01 -0000 The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=c55b340f824d353b7581e8ccf94ecd4929a41ea5 commit c55b340f824d353b7581e8ccf94ecd4929a41ea5 Author: Richard Scheffenegger AuthorDate: 2021-05-10 18:49:19 +0000 Commit: Richard Scheffenegger CommitDate: 2021-05-10 18:49:19 +0000 netstat: fix typo from 0471a8c73402 --- usr.bin/netstat/inet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 45b107b42d39..1143c09734e4 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -809,7 +809,7 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) "{N:/SACK option%s (SACK blocks) received}\n"); p(tcps_sack_send_blocks, "\t{:sent-option-blocks/%ju} " "{N:/SACK option%s (SACK blocks) sent}\n"); - p(tcps_sack_lostrexmit, "\t{:lost-retransmissions/%ju} " + p(tcps_sack_lostrexmt, "\t{:lost-retransmissions/%ju} " "{N:/SACK retransmission%s lost}\n"); p1a(tcps_sack_sboverflow, "\t{:scoreboard-overflows/%ju} " "{N:/SACK scoreboard overflow}\n"); From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F378641A38; Mon, 10 May 2021 19:49:48 +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 4FfBTm3fNVz4T7Y; Mon, 10 May 2021 19:49:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7008527D3; Mon, 10 May 2021 19:49:48 +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 14AJnm3N006337; Mon, 10 May 2021 19:49:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnmiu006336; Mon, 10 May 2021 19:49:48 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:48 GMT Message-Id: <202105101949.14AJnmiu006336@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: b8b6ee3554eb - stable/13 - pf: Fix parsing of long table names MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b8b6ee3554eb331e215db13d3feac34df20a8f39 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:48 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b8b6ee3554eb331e215db13d3feac34df20a8f39 commit b8b6ee3554eb331e215db13d3feac34df20a8f39 Author: Kristof Provost AuthorDate: 2021-04-24 13:55:24 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:56 +0000 pf: Fix parsing of long table names When parsing the nvlist for a struct pf_addr_wrap we unconditionally tried to parse "ifname". This broke for PF_ADDR_TABLE when the table name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than IFNAMSIZ, so this is a valid configuration. Only parse (or return) ifname or tblname for the corresponding pf_addr_wrap type. This manifested as a failure to set rules such as these, where the pfctl optimiser generated an automatic table: pass in proto tcp to 192.168.0.1 port ssh pass in proto tcp to 192.168.0.2 port ssh pass in proto tcp to 192.168.0.3 port ssh pass in proto tcp to 192.168.0.4 port ssh pass in proto tcp to 192.168.0.5 port ssh pass in proto tcp to 192.168.0.6 port ssh pass in proto tcp to 192.168.0.7 port ssh Reported by: Florian Smeets Tested by: Florian Smeets Reviewed by: donner X-MFC-With: 5c11c5a3655842a176124ef2334fcdf830422c8a MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29962 (cherry picked from commit 402dfb0a8d2c6417cb9bff4460ef250a42b0aa05) --- lib/libpfctl/libpfctl.c | 15 ++++++++++----- sys/netpfil/pf/pf_ioctl.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 6d5397cb64b2..69c51ec6c897 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -148,8 +148,10 @@ pfctl_nv_add_addr_wrap(nvlist_t *nvparent, const char *name, nvlist_add_number(nvl, "type", addr->type); nvlist_add_number(nvl, "iflags", addr->iflags); - nvlist_add_string(nvl, "ifname", addr->v.ifname); - nvlist_add_string(nvl, "tblname", addr->v.tblname); + if (addr->type == PF_ADDR_DYNIFTL) + nvlist_add_string(nvl, "ifname", addr->v.ifname); + if (addr->type == PF_ADDR_TABLE) + nvlist_add_string(nvl, "tblname", addr->v.tblname); pfctl_nv_add_addr(nvl, "addr", &addr->v.a.addr); pfctl_nv_add_addr(nvl, "mask", &addr->v.a.mask); @@ -161,9 +163,12 @@ pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr) { addr->type = nvlist_get_number(nvl, "type"); addr->iflags = nvlist_get_number(nvl, "iflags"); - strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); - strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"), - PF_TABLE_NAME_SIZE); + if (addr->type == PF_ADDR_DYNIFTL) + strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"), + IFNAMSIZ); + if (addr->type == PF_ADDR_TABLE) + strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"), + PF_TABLE_NAME_SIZE); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &addr->v.a.addr); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "mask"), &addr->v.a.mask); diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 522f6a6a8f54..40a68a65bfd5 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1703,10 +1703,12 @@ pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr) PFNV_CHK(pf_nvuint8(nvl, "type", &addr->type)); PFNV_CHK(pf_nvuint8(nvl, "iflags", &addr->iflags)); - PFNV_CHK(pf_nvstring(nvl, "ifname", addr->v.ifname, - sizeof(addr->v.ifname))); - PFNV_CHK(pf_nvstring(nvl, "tblname", addr->v.tblname, - sizeof(addr->v.tblname))); + if (addr->type == PF_ADDR_DYNIFTL) + PFNV_CHK(pf_nvstring(nvl, "ifname", addr->v.ifname, + sizeof(addr->v.ifname))); + if (addr->type == PF_ADDR_TABLE) + PFNV_CHK(pf_nvstring(nvl, "tblname", addr->v.tblname, + sizeof(addr->v.tblname))); if (! nvlist_exists_nvlist(nvl, "addr")) return (EINVAL); @@ -1746,8 +1748,10 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr) nvlist_add_number(nvl, "type", addr->type); nvlist_add_number(nvl, "iflags", addr->iflags); - nvlist_add_string(nvl, "ifname", addr->v.ifname); - nvlist_add_string(nvl, "tblname", addr->v.tblname); + if (addr->type == PF_ADDR_DYNIFTL) + nvlist_add_string(nvl, "ifname", addr->v.ifname); + if (addr->type == PF_ADDR_TABLE) + nvlist_add_string(nvl, "tblname", addr->v.tblname); tmp = pf_addr_to_nvaddr(&addr->v.a.addr); if (tmp == NULL) From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E3A3641A39; Mon, 10 May 2021 19:49:49 +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 4FfBTn2NgQz4T2y; Mon, 10 May 2021 19:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 450E927D4; Mon, 10 May 2021 19:49:49 +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 14AJnnuY006434; Mon, 10 May 2021 19:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnn5g006433; Mon, 10 May 2021 19:49:49 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:49 GMT Message-Id: <202105101949.14AJnn5g006433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 39ed63e07489 - stable/12 - pf: Fix parsing of long table names MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 39ed63e074892f49e7c458715b08fc4f604ebcea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:49 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=39ed63e074892f49e7c458715b08fc4f604ebcea commit 39ed63e074892f49e7c458715b08fc4f604ebcea Author: Kristof Provost AuthorDate: 2021-04-24 13:55:24 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pf: Fix parsing of long table names When parsing the nvlist for a struct pf_addr_wrap we unconditionally tried to parse "ifname". This broke for PF_ADDR_TABLE when the table name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than IFNAMSIZ, so this is a valid configuration. Only parse (or return) ifname or tblname for the corresponding pf_addr_wrap type. This manifested as a failure to set rules such as these, where the pfctl optimiser generated an automatic table: pass in proto tcp to 192.168.0.1 port ssh pass in proto tcp to 192.168.0.2 port ssh pass in proto tcp to 192.168.0.3 port ssh pass in proto tcp to 192.168.0.4 port ssh pass in proto tcp to 192.168.0.5 port ssh pass in proto tcp to 192.168.0.6 port ssh pass in proto tcp to 192.168.0.7 port ssh Reported by: Florian Smeets Tested by: Florian Smeets Reviewed by: donner X-MFC-With: 5c11c5a3655842a176124ef2334fcdf830422c8a MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29962 (cherry picked from commit 402dfb0a8d2c6417cb9bff4460ef250a42b0aa05) --- lib/libpfctl/libpfctl.c | 15 ++++++++++----- sys/netpfil/pf/pf_ioctl.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 6d5397cb64b2..69c51ec6c897 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -148,8 +148,10 @@ pfctl_nv_add_addr_wrap(nvlist_t *nvparent, const char *name, nvlist_add_number(nvl, "type", addr->type); nvlist_add_number(nvl, "iflags", addr->iflags); - nvlist_add_string(nvl, "ifname", addr->v.ifname); - nvlist_add_string(nvl, "tblname", addr->v.tblname); + if (addr->type == PF_ADDR_DYNIFTL) + nvlist_add_string(nvl, "ifname", addr->v.ifname); + if (addr->type == PF_ADDR_TABLE) + nvlist_add_string(nvl, "tblname", addr->v.tblname); pfctl_nv_add_addr(nvl, "addr", &addr->v.a.addr); pfctl_nv_add_addr(nvl, "mask", &addr->v.a.mask); @@ -161,9 +163,12 @@ pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr) { addr->type = nvlist_get_number(nvl, "type"); addr->iflags = nvlist_get_number(nvl, "iflags"); - strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); - strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"), - PF_TABLE_NAME_SIZE); + if (addr->type == PF_ADDR_DYNIFTL) + strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"), + IFNAMSIZ); + if (addr->type == PF_ADDR_TABLE) + strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"), + PF_TABLE_NAME_SIZE); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &addr->v.a.addr); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "mask"), &addr->v.a.mask); diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 99bf8efcca1a..1eaad66b2cdb 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1704,10 +1704,12 @@ pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr) PFNV_CHK(pf_nvuint8(nvl, "type", &addr->type)); PFNV_CHK(pf_nvuint8(nvl, "iflags", &addr->iflags)); - PFNV_CHK(pf_nvstring(nvl, "ifname", addr->v.ifname, - sizeof(addr->v.ifname))); - PFNV_CHK(pf_nvstring(nvl, "tblname", addr->v.tblname, - sizeof(addr->v.tblname))); + if (addr->type == PF_ADDR_DYNIFTL) + PFNV_CHK(pf_nvstring(nvl, "ifname", addr->v.ifname, + sizeof(addr->v.ifname))); + if (addr->type == PF_ADDR_TABLE) + PFNV_CHK(pf_nvstring(nvl, "tblname", addr->v.tblname, + sizeof(addr->v.tblname))); if (! nvlist_exists_nvlist(nvl, "addr")) return (EINVAL); @@ -1747,8 +1749,10 @@ pf_addr_wrap_to_nvaddr_wrap(const struct pf_addr_wrap *addr) nvlist_add_number(nvl, "type", addr->type); nvlist_add_number(nvl, "iflags", addr->iflags); - nvlist_add_string(nvl, "ifname", addr->v.ifname); - nvlist_add_string(nvl, "tblname", addr->v.tblname); + if (addr->type == PF_ADDR_DYNIFTL) + nvlist_add_string(nvl, "ifname", addr->v.ifname); + if (addr->type == PF_ADDR_TABLE) + nvlist_add_string(nvl, "tblname", addr->v.tblname); tmp = pf_addr_to_nvaddr(&addr->v.a.addr); if (tmp == NULL) From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5FDE64194A; Mon, 10 May 2021 19:49:49 +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 4FfBTn4fhSz4T7Z; Mon, 10 May 2021 19:49:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 913D42802; Mon, 10 May 2021 19:49:49 +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 14AJnnC4006459; Mon, 10 May 2021 19:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnn7T006457; Mon, 10 May 2021 19:49:49 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:49 GMT Message-Id: <202105101949.14AJnn7T006457@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: a599304a6c7f - stable/13 - pf tests: Test automatically generated tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a599304a6c7f82b84beae2763acea4c0ea1e0dcf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a599304a6c7f82b84beae2763acea4c0ea1e0dcf commit a599304a6c7f82b84beae2763acea4c0ea1e0dcf Author: Kristof Provost AuthorDate: 2021-04-26 09:14:44 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:57 +0000 pf tests: Test automatically generated tables Add a test case where the pfctl optimizer will generate a table automatically. These tables have long names, which we accidentally broke in the nvlist ADDRULE ioctl. Reviewed by: melifaro MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29989 (cherry picked from commit 08d77308211f823b8532d27790e8fd29eaf75c77) --- tests/sys/netpfil/pf/table.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index 516895ae1759..379b715e767a 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -177,10 +177,48 @@ network_cleanup() pft_cleanup } +atf_test_case "automatic" "cleanup" +automatic_head() +{ + atf_set descr "Test automatic - optimizer generated - tables" + atf_set require.user root +} + +automatic_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "block in" \ + "pass in proto icmp from 192.0.2.1" \ + "pass in proto icmp from 192.0.2.3" \ + "pass in proto icmp from 192.0.2.4" \ + "pass in proto icmp from 192.0.2.5" \ + "pass in proto icmp from 192.0.2.6" \ + "pass in proto icmp from 192.0.2.7" \ + "pass in proto icmp from 192.0.2.8" \ + "pass in proto icmp from 192.0.2.9" + + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 +} + +automatic_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4_counters" atf_add_test_case "v6_counters" atf_add_test_case "pr251414" atf_add_test_case "network" + atf_add_test_case "automatic" } From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 449CF641AEF; Mon, 10 May 2021 19:49:51 +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 4FfBTp5xpJz4TMM; Mon, 10 May 2021 19:49:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A98FA27D5; Mon, 10 May 2021 19:49:50 +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 14AJno7A006504; Mon, 10 May 2021 19:49:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJno2F006503; Mon, 10 May 2021 19:49:50 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:50 GMT Message-Id: <202105101949.14AJno2F006503@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: c93907df7bb0 - stable/13 - pf: Allow multiple labels to be set on a rule MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c93907df7bb095d900861eb294b83c70995faf42 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:51 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c93907df7bb095d900861eb294b83c70995faf42 commit c93907df7bb095d900861eb294b83c70995faf42 Author: Kristof Provost AuthorDate: 2021-04-20 09:04:48 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:57 +0000 pf: Allow multiple labels to be set on a rule Allow up to 5 labels to be set on each rule. This offers more flexibility in using labels. For example, it replaces the customer 'schedule' keyword used by pfSense to terminate states according to a schedule. Reviewed by: glebius MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29936 (cherry picked from commit 6fcc8e042ac480f9276177339f7de1ad0f95c1b0) --- lib/libpfctl/libpfctl.c | 18 ++++++++-- lib/libpfctl/libpfctl.h | 2 +- sbin/pfctl/parse.y | 59 ++++++++++++++++++------------- sbin/pfctl/pfctl.c | 16 ++++++--- sbin/pfctl/pfctl_parser.c | 5 +-- sys/net/pfvar.h | 2 +- sys/netpfil/pf/pf.h | 1 + sys/netpfil/pf/pf_ioctl.c | 55 ++++++++++++++++++++++++---- usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 2 +- 9 files changed, 116 insertions(+), 44 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 69c51ec6c897..6b191514320e 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -282,7 +282,8 @@ static void pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) { const uint64_t *skip; - size_t skipcount; + const char *const *labels; + size_t skipcount, labelcount; rule->nr = nvlist_get_number(nvl, "nr"); @@ -295,7 +296,10 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) for (int i = 0; i < PF_SKIP_COUNT; i++) rule->skip[i].nr = skip[i]; - strlcpy(rule->label, nvlist_get_string(nvl, "label"), PF_RULE_LABEL_SIZE); + labels = nvlist_get_string_array(nvl, "labels", &labelcount); + assert(labelcount <= PF_RULE_MAX_LABEL_COUNT); + for (size_t i = 0; i < labelcount; i++) + strlcpy(rule->label[i], labels[i], PF_RULE_LABEL_SIZE); strlcpy(rule->ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); strlcpy(rule->qname, nvlist_get_string(nvl, "qname"), PF_QNAME_SIZE); strlcpy(rule->pqname, nvlist_get_string(nvl, "pqname"), PF_QNAME_SIZE); @@ -385,6 +389,7 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, u_int64_t timeouts[PFTM_MAX]; u_int64_t set_prio[2]; nvlist_t *nvl, *nvlr; + size_t labelcount; int ret; nvl = nvlist_create(0); @@ -399,7 +404,14 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, pfctl_nv_add_rule_addr(nvlr, "src", &r->src); pfctl_nv_add_rule_addr(nvlr, "dst", &r->dst); - nvlist_add_string(nvlr, "label", r->label); + labelcount = 0; + while (r->label[labelcount][0] != 0 && + labelcount < PF_RULE_MAX_LABEL_COUNT) { + nvlist_append_string_array(nvlr, "labels", + r->label[labelcount]); + labelcount++; + } + nvlist_add_string(nvlr, "ifname", r->ifname); nvlist_add_string(nvlr, "qname", r->qname); nvlist_add_string(nvlr, "pqname", r->pqname); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 38108de769f4..921b072a7753 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -52,7 +52,7 @@ struct pfctl_rule { struct pf_rule_addr src; struct pf_rule_addr dst; union pf_rule_ptr skip[PF_SKIP_COUNT]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 08da7e6bddd6..73d1b77a7445 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -241,7 +242,8 @@ static struct filter_opts { } keep; int fragment; int allowopts; - char *label; + char *label[PF_RULE_MAX_LABEL_COUNT]; + int labelcount; struct node_qassign queues; char *tag; char *match_tag; @@ -256,7 +258,8 @@ static struct filter_opts { } filter_opts; static struct antispoof_opts { - char *label; + char *label[PF_RULE_MAX_LABEL_COUNT]; + int labelcount; u_int rtableid; } antispoof_opts; @@ -348,7 +351,7 @@ int expand_skip_interface(struct node_if *); int check_rulestate(int); int getservice(char *); -int rule_label(struct pfctl_rule *, char *); +int rule_label(struct pfctl_rule *, char *s[PF_RULE_MAX_LABEL_COUNT]); int rt_tableid_max(void); void mv_rules(struct pfctl_ruleset *, struct pfctl_ruleset *); @@ -883,7 +886,8 @@ anchorrule : ANCHOR anchorname dir quick interface af proto fromto r.match_tag_not = $9.match_tag_not; if (rule_label(&r, $9.label)) YYERROR; - free($9.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($9.label[i]); r.flags = $9.flags.b1; r.flagset = $9.flags.b2; if (($9.flags.b1 & $9.flags.b2) != $9.flags.b1) { @@ -1329,7 +1333,8 @@ antispoof : ANTISPOOF logquick antispoof_ifspc af antispoof_opts { } else free(hh); } - free($5.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($5.label[i]); } ; @@ -1370,11 +1375,11 @@ antispoof_opts_l : antispoof_opts_l antispoof_opt ; antispoof_opt : label { - if (antispoof_opts.label) { - yyerror("label cannot be redefined"); + if (antispoof_opts.labelcount >= PF_RULE_MAX_LABEL_COUNT) { + yyerror("label can only be used %d times", PF_RULE_MAX_LABEL_COUNT); YYERROR; } - antispoof_opts.label = $1; + antispoof_opts.label[antispoof_opts.labelcount++] = $1; } | RTABLE NUMBER { if ($2 < 0 || $2 > rt_tableid_max()) { @@ -2089,7 +2094,8 @@ pfrule : action dir logquick interface route af proto fromto r.match_tag_not = $9.match_tag_not; if (rule_label(&r, $9.label)) YYERROR; - free($9.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($9.label[i]); r.flags = $9.flags.b1; r.flagset = $9.flags.b2; if (($9.flags.b1 & $9.flags.b2) != $9.flags.b1) { @@ -2527,11 +2533,11 @@ filter_opt : USER uids { filter_opts.allowopts = 1; } | label { - if (filter_opts.label) { - yyerror("label cannot be redefined"); + if (filter_opts.labelcount >= PF_RULE_MAX_LABEL_COUNT) { + yyerror("label can only be used %d times", PF_RULE_MAX_LABEL_COUNT); YYERROR; } - filter_opts.label = $1; + filter_opts.label[filter_opts.labelcount++] = $1; } | qname { if (filter_opts.queues.qname) { @@ -5259,15 +5265,15 @@ expand_rule(struct pfctl_rule *r, sa_family_t af = r->af; int added = 0, error = 0; char ifname[IF_NAMESIZE]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char tagname[PF_TAG_NAME_SIZE]; char match_tagname[PF_TAG_NAME_SIZE]; struct pf_pooladdr *pa; struct node_host *h; u_int8_t flags, flagset, keep_state; - if (strlcpy(label, r->label, sizeof(label)) >= sizeof(label)) - errx(1, "expand_rule: strlcpy"); + memcpy(label, r->label, sizeof(r->label)); + assert(sizeof(r->label) == sizeof(label)); if (strlcpy(tagname, r->tagname, sizeof(tagname)) >= sizeof(tagname)) errx(1, "expand_rule: strlcpy"); if (strlcpy(match_tagname, r->match_tagname, sizeof(match_tagname)) >= @@ -5316,17 +5322,17 @@ expand_rule(struct pfctl_rule *r, else memset(r->ifname, '\0', sizeof(r->ifname)); - if (strlcpy(r->label, label, sizeof(r->label)) >= - sizeof(r->label)) - errx(1, "expand_rule: strlcpy"); + memcpy(r->label, label, sizeof(r->label)); if (strlcpy(r->tagname, tagname, sizeof(r->tagname)) >= sizeof(r->tagname)) errx(1, "expand_rule: strlcpy"); if (strlcpy(r->match_tagname, match_tagname, sizeof(r->match_tagname)) >= sizeof(r->match_tagname)) errx(1, "expand_rule: strlcpy"); - expand_label(r->label, PF_RULE_LABEL_SIZE, r->ifname, r->af, - src_host, src_port, dst_host, dst_port, proto->proto); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + expand_label(r->label[i], PF_RULE_LABEL_SIZE, + r->ifname, r->af, src_host, src_port, dst_host, + dst_port, proto->proto); expand_label(r->tagname, PF_TAG_NAME_SIZE, r->ifname, r->af, src_host, src_port, dst_host, dst_port, proto->proto); expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r->ifname, @@ -6214,13 +6220,16 @@ getservice(char *n) } int -rule_label(struct pfctl_rule *r, char *s) +rule_label(struct pfctl_rule *r, char *s[PF_RULE_MAX_LABEL_COUNT]) { - if (s) { - if (strlcpy(r->label, s, sizeof(r->label)) >= - sizeof(r->label)) { + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) { + if (s[i] == NULL) + return (0); + + if (strlcpy(r->label[i], s[i], sizeof(r->label[0])) >= + sizeof(r->label[0])) { yyerror("rule label too long (max %d chars)", - sizeof(r->label)-1); + sizeof(r->label[0])-1); return (-1); } } diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 9f6b3d2e36ea..8fa8ef44813a 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -996,11 +996,18 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, goto error; switch (format) { - case PFCTL_SHOW_LABELS: - if (rule.label[0]) { - printf("%s %llu %llu %llu %llu" + case PFCTL_SHOW_LABELS: { + bool show = false; + int i = 0; + + while (rule.label[i][0]) { + printf("%s ", rule.label[i++]); + show = true; + } + + if (show) { + printf("%llu %llu %llu %llu" " %llu %llu %llu %ju\n", - rule.label, (unsigned long long)rule.evaluations, (unsigned long long)(rule.packets[0] + rule.packets[1]), @@ -1013,6 +1020,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, (uintmax_t)rule.states_tot); } break; + } case PFCTL_SHOW_RULES: brace = 0; if (rule.label[0] && (opts & PF_OPT_SHOWALL)) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index bc06ac46787c..826ba25b08d5 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1016,8 +1016,9 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer printf(" fragment reassemble"); } - if (r->label[0]) - printf(" label \"%s\"", r->label); + i = 0; + while (r->label[i][0]) + printf(" label \"%s\"", r->label[i++]); if (r->qname[0] && r->pqname[0]) printf(" queue(%s, %s)", r->qname, r->pqname); else if (r->qname[0]) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index a6510560bb0e..d68932db975f 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -323,7 +323,7 @@ struct pf_krule { struct pf_rule_addr src; struct pf_rule_addr dst; union pf_krule_ptr skip[PF_SKIP_COUNT]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index 3e358de8aba5..45a3efe91efb 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -444,6 +444,7 @@ struct pf_rule { #define PF_SKIP_COUNT 8 union pf_rule_ptr skip[PF_SKIP_COUNT]; #define PF_RULE_LABEL_SIZE 64 +#define PF_RULE_MAX_LABEL_COUNT 5 char label[PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 40a68a65bfd5..66726b754a97 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -991,7 +991,8 @@ pf_hash_rule(MD5_CTX *ctx, struct pf_krule *rule) pf_hash_rule_addr(ctx, &rule->src); pf_hash_rule_addr(ctx, &rule->dst); - PF_MD5_UPD_STR(rule, label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + PF_MD5_UPD_STR(rule, label[i]); PF_MD5_UPD_STR(rule, ifname); PF_MD5_UPD_STR(rule, match_tagname); PF_MD5_UPD_HTONS(rule, match_tag, x); /* dup? */ @@ -1516,7 +1517,7 @@ pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) rule->skip[i].nr = krule->skip[i].ptr->nr; } - strlcpy(rule->label, krule->label, sizeof(rule->label)); + strlcpy(rule->label, krule->label[0], sizeof(rule->label)); strlcpy(rule->ifname, krule->ifname, sizeof(rule->ifname)); strlcpy(rule->qname, krule->qname, sizeof(rule->qname)); strlcpy(rule->pqname, krule->pqname, sizeof(rule->pqname)); @@ -1901,7 +1902,30 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &rule->dst)); - PFNV_CHK(pf_nvstring(nvl, "label", rule->label, sizeof(rule->label))); + if (nvlist_exists_string(nvl, "label")) { + PFNV_CHK(pf_nvstring(nvl, "label", rule->label[0], + sizeof(rule->label[0]))); + } else if (nvlist_exists_string_array(nvl, "labels")) { + const char *const *strs; + size_t items; + int ret; + + strs = nvlist_get_string_array(nvl, "labels", &items); + if (items > PF_RULE_MAX_LABEL_COUNT) { + error = E2BIG; + goto errout; + } + + for (size_t i = 0; i < items; i++) { + ret = strlcpy(rule->label[i], strs[i], + sizeof(rule->label[0])); + if (ret >= sizeof(rule->label[0])) { + error = E2BIG; + goto errout; + } + } + } + PFNV_CHK(pf_nvstring(nvl, "ifname", rule->ifname, sizeof(rule->ifname))); PFNV_CHK(pf_nvstring(nvl, "qname", rule->qname, sizeof(rule->qname))); @@ -2075,7 +2099,10 @@ pf_krule_to_nvrule(const struct pf_krule *rule) rule->skip[i].ptr ? rule->skip[i].ptr->nr : -1); } - nvlist_add_string(nvl, "label", rule->label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) { + nvlist_append_string_array(nvl, "labels", rule->label[i]); + } + nvlist_add_string(nvl, "label", rule->label[0]); nvlist_add_string(nvl, "ifname", rule->ifname); nvlist_add_string(nvl, "qname", rule->qname); nvlist_add_string(nvl, "pqname", rule->pqname); @@ -2208,7 +2235,7 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) bcopy(&rule->src, &krule->src, sizeof(rule->src)); bcopy(&rule->dst, &krule->dst, sizeof(rule->dst)); - strlcpy(krule->label, rule->label, sizeof(rule->label)); + strlcpy(krule->label[0], rule->label, sizeof(rule->label)); strlcpy(krule->ifname, rule->ifname, sizeof(rule->ifname)); strlcpy(krule->qname, rule->qname, sizeof(rule->qname)); strlcpy(krule->pqname, rule->pqname, sizeof(rule->pqname)); @@ -2288,6 +2315,20 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) return (0); } +static bool +pf_label_match(const struct pf_krule *rule, const char *label) +{ + int i = 0; + + while (*rule->label[i]) { + if (strcmp(rule->label[i], label) == 0) + return (true); + i++; + } + + return (false); +} + static int pf_killstates_row(struct pfioc_state_kill *psk, struct pf_idhash *ih) { @@ -2337,8 +2378,8 @@ relock_DIOCKILLSTATES: psk->psk_dst.port[0], psk->psk_dst.port[1], dstport)) continue; - if (psk->psk_label[0] && (! s->rule.ptr->label[0] || - strcmp(psk->psk_label, s->rule.ptr->label))) + if (psk->psk_label[0] && + ! pf_label_match(s->rule.ptr, psk->psk_label)) continue; if (psk->psk_ifname[0] && strcmp(psk->psk_ifname, diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c index 018f3751ca57..51d940f20c99 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -1545,7 +1545,7 @@ pfl_scan_ruleset(const char *path) strlcpy(e->name, path, sizeof(e->name)); if (path[0]) strlcat(e->name, "/", sizeof(e->name)); - strlcat(e->name, rule.label, sizeof(e->name)); + strlcat(e->name, rule.label[0], sizeof(e->name)); e->evals = rule.evaluations; e->bytes[IN] = rule.bytes[IN]; From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AEFD641B47; Mon, 10 May 2021 19:49: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 4FfBTq5QWrz4T3B; Mon, 10 May 2021 19:49:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 89F852804; Mon, 10 May 2021 19:49: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 14AJnp4r006525; Mon, 10 May 2021 19:49:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnpeI006524; Mon, 10 May 2021 19:49:51 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:51 GMT Message-Id: <202105101949.14AJnpeI006524@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 95881f65a401 - stable/12 - pf: Allow multiple labels to be set on a rule MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 95881f65a401d80954e0575e80a3b8d647043a02 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:52 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=95881f65a401d80954e0575e80a3b8d647043a02 commit 95881f65a401d80954e0575e80a3b8d647043a02 Author: Kristof Provost AuthorDate: 2021-04-20 09:04:48 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pf: Allow multiple labels to be set on a rule Allow up to 5 labels to be set on each rule. This offers more flexibility in using labels. For example, it replaces the customer 'schedule' keyword used by pfSense to terminate states according to a schedule. Reviewed by: glebius MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29936 (cherry picked from commit 6fcc8e042ac480f9276177339f7de1ad0f95c1b0) --- lib/libpfctl/libpfctl.c | 18 ++++++++-- lib/libpfctl/libpfctl.h | 2 +- sbin/pfctl/parse.y | 59 ++++++++++++++++++------------- sbin/pfctl/pfctl.c | 16 ++++++--- sbin/pfctl/pfctl_parser.c | 5 +-- sys/net/pfvar.h | 2 +- sys/netpfil/pf/pf.h | 1 + sys/netpfil/pf/pf_ioctl.c | 55 ++++++++++++++++++++++++---- usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 2 +- 9 files changed, 116 insertions(+), 44 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 69c51ec6c897..6b191514320e 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -282,7 +282,8 @@ static void pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) { const uint64_t *skip; - size_t skipcount; + const char *const *labels; + size_t skipcount, labelcount; rule->nr = nvlist_get_number(nvl, "nr"); @@ -295,7 +296,10 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule) for (int i = 0; i < PF_SKIP_COUNT; i++) rule->skip[i].nr = skip[i]; - strlcpy(rule->label, nvlist_get_string(nvl, "label"), PF_RULE_LABEL_SIZE); + labels = nvlist_get_string_array(nvl, "labels", &labelcount); + assert(labelcount <= PF_RULE_MAX_LABEL_COUNT); + for (size_t i = 0; i < labelcount; i++) + strlcpy(rule->label[i], labels[i], PF_RULE_LABEL_SIZE); strlcpy(rule->ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ); strlcpy(rule->qname, nvlist_get_string(nvl, "qname"), PF_QNAME_SIZE); strlcpy(rule->pqname, nvlist_get_string(nvl, "pqname"), PF_QNAME_SIZE); @@ -385,6 +389,7 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, u_int64_t timeouts[PFTM_MAX]; u_int64_t set_prio[2]; nvlist_t *nvl, *nvlr; + size_t labelcount; int ret; nvl = nvlist_create(0); @@ -399,7 +404,14 @@ pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, pfctl_nv_add_rule_addr(nvlr, "src", &r->src); pfctl_nv_add_rule_addr(nvlr, "dst", &r->dst); - nvlist_add_string(nvlr, "label", r->label); + labelcount = 0; + while (r->label[labelcount][0] != 0 && + labelcount < PF_RULE_MAX_LABEL_COUNT) { + nvlist_append_string_array(nvlr, "labels", + r->label[labelcount]); + labelcount++; + } + nvlist_add_string(nvlr, "ifname", r->ifname); nvlist_add_string(nvlr, "qname", r->qname); nvlist_add_string(nvlr, "pqname", r->pqname); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 38108de769f4..921b072a7753 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -52,7 +52,7 @@ struct pfctl_rule { struct pf_rule_addr src; struct pf_rule_addr dst; union pf_rule_ptr skip[PF_SKIP_COUNT]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index ff4eca03f4cf..ddc37984e114 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -241,7 +242,8 @@ static struct filter_opts { } keep; int fragment; int allowopts; - char *label; + char *label[PF_RULE_MAX_LABEL_COUNT]; + int labelcount; struct node_qassign queues; char *tag; char *match_tag; @@ -256,7 +258,8 @@ static struct filter_opts { } filter_opts; static struct antispoof_opts { - char *label; + char *label[PF_RULE_MAX_LABEL_COUNT]; + int labelcount; u_int rtableid; } antispoof_opts; @@ -348,7 +351,7 @@ int expand_skip_interface(struct node_if *); int check_rulestate(int); int getservice(char *); -int rule_label(struct pfctl_rule *, char *); +int rule_label(struct pfctl_rule *, char *s[PF_RULE_MAX_LABEL_COUNT]); int rt_tableid_max(void); void mv_rules(struct pfctl_ruleset *, struct pfctl_ruleset *); @@ -875,7 +878,8 @@ anchorrule : ANCHOR anchorname dir quick interface af proto fromto r.match_tag_not = $9.match_tag_not; if (rule_label(&r, $9.label)) YYERROR; - free($9.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($9.label[i]); r.flags = $9.flags.b1; r.flagset = $9.flags.b2; if (($9.flags.b1 & $9.flags.b2) != $9.flags.b1) { @@ -1321,7 +1325,8 @@ antispoof : ANTISPOOF logquick antispoof_ifspc af antispoof_opts { } else free(hh); } - free($5.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($5.label[i]); } ; @@ -1362,11 +1367,11 @@ antispoof_opts_l : antispoof_opts_l antispoof_opt ; antispoof_opt : label { - if (antispoof_opts.label) { - yyerror("label cannot be redefined"); + if (antispoof_opts.labelcount >= PF_RULE_MAX_LABEL_COUNT) { + yyerror("label can only be used %d times", PF_RULE_MAX_LABEL_COUNT); YYERROR; } - antispoof_opts.label = $1; + antispoof_opts.label[antispoof_opts.labelcount++] = $1; } | RTABLE NUMBER { if ($2 < 0 || $2 > rt_tableid_max()) { @@ -2081,7 +2086,8 @@ pfrule : action dir logquick interface route af proto fromto r.match_tag_not = $9.match_tag_not; if (rule_label(&r, $9.label)) YYERROR; - free($9.label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + free($9.label[i]); r.flags = $9.flags.b1; r.flagset = $9.flags.b2; if (($9.flags.b1 & $9.flags.b2) != $9.flags.b1) { @@ -2519,11 +2525,11 @@ filter_opt : USER uids { filter_opts.allowopts = 1; } | label { - if (filter_opts.label) { - yyerror("label cannot be redefined"); + if (filter_opts.labelcount >= PF_RULE_MAX_LABEL_COUNT) { + yyerror("label can only be used %d times", PF_RULE_MAX_LABEL_COUNT); YYERROR; } - filter_opts.label = $1; + filter_opts.label[filter_opts.labelcount++] = $1; } | qname { if (filter_opts.queues.qname) { @@ -5251,15 +5257,15 @@ expand_rule(struct pfctl_rule *r, sa_family_t af = r->af; int added = 0, error = 0; char ifname[IF_NAMESIZE]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char tagname[PF_TAG_NAME_SIZE]; char match_tagname[PF_TAG_NAME_SIZE]; struct pf_pooladdr *pa; struct node_host *h; u_int8_t flags, flagset, keep_state; - if (strlcpy(label, r->label, sizeof(label)) >= sizeof(label)) - errx(1, "expand_rule: strlcpy"); + memcpy(label, r->label, sizeof(r->label)); + assert(sizeof(r->label) == sizeof(label)); if (strlcpy(tagname, r->tagname, sizeof(tagname)) >= sizeof(tagname)) errx(1, "expand_rule: strlcpy"); if (strlcpy(match_tagname, r->match_tagname, sizeof(match_tagname)) >= @@ -5308,17 +5314,17 @@ expand_rule(struct pfctl_rule *r, else memset(r->ifname, '\0', sizeof(r->ifname)); - if (strlcpy(r->label, label, sizeof(r->label)) >= - sizeof(r->label)) - errx(1, "expand_rule: strlcpy"); + memcpy(r->label, label, sizeof(r->label)); if (strlcpy(r->tagname, tagname, sizeof(r->tagname)) >= sizeof(r->tagname)) errx(1, "expand_rule: strlcpy"); if (strlcpy(r->match_tagname, match_tagname, sizeof(r->match_tagname)) >= sizeof(r->match_tagname)) errx(1, "expand_rule: strlcpy"); - expand_label(r->label, PF_RULE_LABEL_SIZE, r->ifname, r->af, - src_host, src_port, dst_host, dst_port, proto->proto); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + expand_label(r->label[i], PF_RULE_LABEL_SIZE, + r->ifname, r->af, src_host, src_port, dst_host, + dst_port, proto->proto); expand_label(r->tagname, PF_TAG_NAME_SIZE, r->ifname, r->af, src_host, src_port, dst_host, dst_port, proto->proto); expand_label(r->match_tagname, PF_TAG_NAME_SIZE, r->ifname, @@ -6206,13 +6212,16 @@ getservice(char *n) } int -rule_label(struct pfctl_rule *r, char *s) +rule_label(struct pfctl_rule *r, char *s[PF_RULE_MAX_LABEL_COUNT]) { - if (s) { - if (strlcpy(r->label, s, sizeof(r->label)) >= - sizeof(r->label)) { + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) { + if (s[i] == NULL) + return (0); + + if (strlcpy(r->label[i], s[i], sizeof(r->label[0])) >= + sizeof(r->label[0])) { yyerror("rule label too long (max %d chars)", - sizeof(r->label)-1); + sizeof(r->label[0])-1); return (-1); } } diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 9f6b3d2e36ea..8fa8ef44813a 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -996,11 +996,18 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, goto error; switch (format) { - case PFCTL_SHOW_LABELS: - if (rule.label[0]) { - printf("%s %llu %llu %llu %llu" + case PFCTL_SHOW_LABELS: { + bool show = false; + int i = 0; + + while (rule.label[i][0]) { + printf("%s ", rule.label[i++]); + show = true; + } + + if (show) { + printf("%llu %llu %llu %llu" " %llu %llu %llu %ju\n", - rule.label, (unsigned long long)rule.evaluations, (unsigned long long)(rule.packets[0] + rule.packets[1]), @@ -1013,6 +1020,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, (uintmax_t)rule.states_tot); } break; + } case PFCTL_SHOW_RULES: brace = 0; if (rule.label[0] && (opts & PF_OPT_SHOWALL)) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index b2300df880ca..81da3c9ad9ba 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1016,8 +1016,9 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer printf(" fragment reassemble"); } - if (r->label[0]) - printf(" label \"%s\"", r->label); + i = 0; + while (r->label[i][0]) + printf(" label \"%s\"", r->label[i++]); if (r->qname[0] && r->pqname[0]) printf(" queue(%s, %s)", r->qname, r->pqname); else if (r->qname[0]) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 1c0359fcbfbf..dc2c6f014923 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -323,7 +323,7 @@ struct pf_krule { struct pf_rule_addr src; struct pf_rule_addr dst; union pf_krule_ptr skip[PF_SKIP_COUNT]; - char label[PF_RULE_LABEL_SIZE]; + char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index 3e358de8aba5..45a3efe91efb 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -444,6 +444,7 @@ struct pf_rule { #define PF_SKIP_COUNT 8 union pf_rule_ptr skip[PF_SKIP_COUNT]; #define PF_RULE_LABEL_SIZE 64 +#define PF_RULE_MAX_LABEL_COUNT 5 char label[PF_RULE_LABEL_SIZE]; char ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 1eaad66b2cdb..7d2f67ad13e9 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -991,7 +991,8 @@ pf_hash_rule(MD5_CTX *ctx, struct pf_krule *rule) pf_hash_rule_addr(ctx, &rule->src); pf_hash_rule_addr(ctx, &rule->dst); - PF_MD5_UPD_STR(rule, label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) + PF_MD5_UPD_STR(rule, label[i]); PF_MD5_UPD_STR(rule, ifname); PF_MD5_UPD_STR(rule, match_tagname); PF_MD5_UPD_HTONS(rule, match_tag, x); /* dup? */ @@ -1517,7 +1518,7 @@ pf_krule_to_rule(const struct pf_krule *krule, struct pf_rule *rule) rule->skip[i].nr = krule->skip[i].ptr->nr; } - strlcpy(rule->label, krule->label, sizeof(rule->label)); + strlcpy(rule->label, krule->label[0], sizeof(rule->label)); strlcpy(rule->ifname, krule->ifname, sizeof(rule->ifname)); strlcpy(rule->qname, krule->qname, sizeof(rule->qname)); strlcpy(rule->pqname, krule->pqname, sizeof(rule->pqname)); @@ -1902,7 +1903,30 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &rule->dst)); - PFNV_CHK(pf_nvstring(nvl, "label", rule->label, sizeof(rule->label))); + if (nvlist_exists_string(nvl, "label")) { + PFNV_CHK(pf_nvstring(nvl, "label", rule->label[0], + sizeof(rule->label[0]))); + } else if (nvlist_exists_string_array(nvl, "labels")) { + const char *const *strs; + size_t items; + int ret; + + strs = nvlist_get_string_array(nvl, "labels", &items); + if (items > PF_RULE_MAX_LABEL_COUNT) { + error = E2BIG; + goto errout; + } + + for (size_t i = 0; i < items; i++) { + ret = strlcpy(rule->label[i], strs[i], + sizeof(rule->label[0])); + if (ret >= sizeof(rule->label[0])) { + error = E2BIG; + goto errout; + } + } + } + PFNV_CHK(pf_nvstring(nvl, "ifname", rule->ifname, sizeof(rule->ifname))); PFNV_CHK(pf_nvstring(nvl, "qname", rule->qname, sizeof(rule->qname))); @@ -2076,7 +2100,10 @@ pf_krule_to_nvrule(const struct pf_krule *rule) rule->skip[i].ptr ? rule->skip[i].ptr->nr : -1); } - nvlist_add_string(nvl, "label", rule->label); + for (int i = 0; i < PF_RULE_MAX_LABEL_COUNT; i++) { + nvlist_append_string_array(nvl, "labels", rule->label[i]); + } + nvlist_add_string(nvl, "label", rule->label[0]); nvlist_add_string(nvl, "ifname", rule->ifname); nvlist_add_string(nvl, "qname", rule->qname); nvlist_add_string(nvl, "pqname", rule->pqname); @@ -2209,7 +2236,7 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) bcopy(&rule->src, &krule->src, sizeof(rule->src)); bcopy(&rule->dst, &krule->dst, sizeof(rule->dst)); - strlcpy(krule->label, rule->label, sizeof(rule->label)); + strlcpy(krule->label[0], rule->label, sizeof(rule->label)); strlcpy(krule->ifname, rule->ifname, sizeof(rule->ifname)); strlcpy(krule->qname, rule->qname, sizeof(rule->qname)); strlcpy(krule->pqname, rule->pqname, sizeof(rule->pqname)); @@ -2289,6 +2316,20 @@ pf_rule_to_krule(const struct pf_rule *rule, struct pf_krule *krule) return (0); } +static bool +pf_label_match(const struct pf_krule *rule, const char *label) +{ + int i = 0; + + while (*rule->label[i]) { + if (strcmp(rule->label[i], label) == 0) + return (true); + i++; + } + + return (false); +} + static int pf_killstates_row(struct pfioc_state_kill *psk, struct pf_idhash *ih) { @@ -2338,8 +2379,8 @@ relock_DIOCKILLSTATES: psk->psk_dst.port[0], psk->psk_dst.port[1], dstport)) continue; - if (psk->psk_label[0] && (! s->rule.ptr->label[0] || - strcmp(psk->psk_label, s->rule.ptr->label))) + if (psk->psk_label[0] && + ! pf_label_match(s->rule.ptr, psk->psk_label)) continue; if (psk->psk_ifname[0] && strcmp(psk->psk_ifname, diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c index 018f3751ca57..51d940f20c99 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -1545,7 +1545,7 @@ pfl_scan_ruleset(const char *path) strlcpy(e->name, path, sizeof(e->name)); if (path[0]) strlcat(e->name, "/", sizeof(e->name)); - strlcat(e->name, rule.label, sizeof(e->name)); + strlcat(e->name, rule.label[0], sizeof(e->name)); e->evals = rule.evaluations; e->bytes[IN] = rule.bytes[IN]; From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B200564194F; Mon, 10 May 2021 19:49:50 +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 4FfBTp3n5Bz4T5h; Mon, 10 May 2021 19:49:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 68D6326A4; Mon, 10 May 2021 19:49:50 +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 14AJnogQ006483; Mon, 10 May 2021 19:49:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnoMY006482; Mon, 10 May 2021 19:49:50 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:50 GMT Message-Id: <202105101949.14AJnoMY006482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: aacfedcef1b2 - stable/12 - pf tests: Test automatically generated tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: aacfedcef1b279f97286885fa62baa21ff1da09a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:51 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=aacfedcef1b279f97286885fa62baa21ff1da09a commit aacfedcef1b279f97286885fa62baa21ff1da09a Author: Kristof Provost AuthorDate: 2021-04-26 09:14:44 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pf tests: Test automatically generated tables Add a test case where the pfctl optimizer will generate a table automatically. These tables have long names, which we accidentally broke in the nvlist ADDRULE ioctl. Reviewed by: melifaro MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29989 (cherry picked from commit 08d77308211f823b8532d27790e8fd29eaf75c77) --- tests/sys/netpfil/pf/table.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index 5826fab245d8..ff2a68b81224 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -177,10 +177,48 @@ network_cleanup() pft_cleanup } +atf_test_case "automatic" "cleanup" +automatic_head() +{ + atf_set descr "Test automatic - optimizer generated - tables" + atf_set require.user root +} + +automatic_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "block in" \ + "pass in proto icmp from 192.0.2.1" \ + "pass in proto icmp from 192.0.2.3" \ + "pass in proto icmp from 192.0.2.4" \ + "pass in proto icmp from 192.0.2.5" \ + "pass in proto icmp from 192.0.2.6" \ + "pass in proto icmp from 192.0.2.7" \ + "pass in proto icmp from 192.0.2.8" \ + "pass in proto icmp from 192.0.2.9" + + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 +} + +automatic_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4_counters" atf_add_test_case "v6_counters" atf_add_test_case "pr251414" atf_add_test_case "network" + atf_add_test_case "automatic" } From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44E7C641AF9; Mon, 10 May 2021 19:49: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 4FfBTq6kBXz4T7k; Mon, 10 May 2021 19:49:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C9D4B26A5; Mon, 10 May 2021 19:49: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 14AJnphH006546; Mon, 10 May 2021 19:49:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnp4O006545; Mon, 10 May 2021 19:49:51 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:51 GMT Message-Id: <202105101949.14AJnp4O006545@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: ac81c2a641b3 - stable/13 - pf tests: Test killing states with multiple labels MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ac81c2a641b360778b8ae35aaa03d1f38f3c65ab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:53 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ac81c2a641b360778b8ae35aaa03d1f38f3c65ab commit ac81c2a641b360778b8ae35aaa03d1f38f3c65ab Author: Kristof Provost AuthorDate: 2021-04-21 14:12:48 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:57 +0000 pf tests: Test killing states with multiple labels Now that we support having multiple labels on a rule ensure that we can use each rule label to kill states. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29938 (cherry picked from commit 5632f585355ad380cb9ef932c419e2efdb1fc46b) --- tests/sys/netpfil/pf/killstate.sh | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index d54858d5452c..dddf844e6231 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -240,9 +240,88 @@ label_cleanup() pft_cleanup } +atf_test_case "multilabel" "cleanup" +multilabel_head() +{ + atf_set descr 'Test killing states with multiple labels by label' + atf_set require.user root + atf_set require.progs scapy +} + +multilabel_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp label foo label bar" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing a label on a different rules keeps the state + jexec alcatraz pfctl -k label -k baz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing the state with the last label works + jexec alcatraz pfctl -k label -k bar + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp label foo label bar" + + # Reestablish state + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Killing with the first label works too + jexec alcatraz pfctl -k label -k foo + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +multilabel_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "v6" atf_add_test_case "label" + atf_add_test_case "multilabel" } From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7122641C76; Mon, 10 May 2021 19:49:54 +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 4FfBTt1m9lz4TGl; Mon, 10 May 2021 19:49:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0D38C2373; Mon, 10 May 2021 19:49:54 +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 14AJnrsN006630; Mon, 10 May 2021 19:49:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnrnO006629; Mon, 10 May 2021 19:49:53 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:53 GMT Message-Id: <202105101949.14AJnrnO006629@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: f341925a5868 - stable/13 - pf: Trivial typo fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f341925a5868d2355cb31a71ab9b19bc0e2fcb66 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:55 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f341925a5868d2355cb31a71ab9b19bc0e2fcb66 commit f341925a5868d2355cb31a71ab9b19bc0e2fcb66 Author: Kristof Provost AuthorDate: 2021-04-29 08:34:00 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:57 +0000 pf: Trivial typo fix PV -> PF MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit eaabed8ac449dbd9a7f4f567e9378bda4636221e) --- sys/netpfil/pf/pf_nv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index d88c0b14e435..8a2082d3e0bb 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); #include -#define PV_NV_IMPL_UINT(fnname, type, max) \ +#define PF_NV_IMPL_UINT(fnname, type, max) \ int \ pf_nv ## fnname(const nvlist_t *nvl, const char *name, type *val) \ { \ @@ -101,9 +101,9 @@ pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, return (0); } -PV_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX) -PV_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); -PV_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX) +PF_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX); +PF_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); +PF_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX); int pf_nvint(const nvlist_t *nvl, const char *name, int *val) From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 94555641B50; Mon, 10 May 2021 19:49:55 +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 4FfBTv17tjz4TKX; Mon, 10 May 2021 19:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C44CF25B0; Mon, 10 May 2021 19:49:53 +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 14AJnrxx006609; Mon, 10 May 2021 19:49:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnrUC006608; Mon, 10 May 2021 19:49:53 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:53 GMT Message-Id: <202105101949.14AJnrUC006608@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 1574be6bd101 - stable/12 - pfsync: Expose PFSYNCF_OK flag to userspace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1574be6bd101cc72f9ba1ce42c78eb3c6de1465f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:55 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1574be6bd101cc72f9ba1ce42c78eb3c6de1465f commit 1574be6bd101cc72f9ba1ce42c78eb3c6de1465f Author: Kristof Provost AuthorDate: 2021-04-23 12:24:59 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pfsync: Expose PFSYNCF_OK flag to userspace Add 'syncok' field to ifconfig's pfsync interface output. This allows userspace to figure out when pfsync has completed the initial bulk import. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29948 (cherry picked from commit 5f5bf88949df421ec3ccd7e14a999e8d8b9251bf) --- sbin/ifconfig/ifpfsync.c | 5 ++++- sys/net/if_pfsync.h | 2 ++ sys/netpfil/pf/if_pfsync.c | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c index 6df38c1ac997..60e3d4360aa3 100644 --- a/sbin/ifconfig/ifpfsync.c +++ b/sbin/ifconfig/ifpfsync.c @@ -206,7 +206,10 @@ pfsync_status(int s) if (preq.pfsyncr_syncdev[0] != '\0' || preq.pfsyncr_syncpeer.s_addr != htonl(INADDR_PFSYNC_GROUP)) { printf("maxupd: %d ", preq.pfsyncr_maxupdates); - printf("defer: %s\n", preq.pfsyncr_defer ? "on" : "off"); + printf("defer: %s\n", + (preq.pfsyncr_defer & PFSYNCF_DEFER) ? "on" : "off"); + printf("\tsyncok: %d\n", + (preq.pfsyncr_defer & PFSYNCF_OK) ? 1 : 0); } } diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h index 3715fdb55afa..75c2df865bcb 100644 --- a/sys/net/if_pfsync.h +++ b/sys/net/if_pfsync.h @@ -237,6 +237,8 @@ struct pfsyncreq { char pfsyncr_syncdev[IFNAMSIZ]; struct in_addr pfsyncr_syncpeer; int pfsyncr_maxupdates; +#define PFSYNCF_OK 0x00000001 +#define PFSYNCF_DEFER 0x00000002 int pfsyncr_defer; }; diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 65dd64b02bbd..bc1dcd02f36c 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -215,8 +215,6 @@ struct pfsync_softc { struct ip_moptions sc_imo; struct in_addr sc_sync_peer; uint32_t sc_flags; -#define PFSYNCF_OK 0x00000001 -#define PFSYNCF_DEFER 0x00000002 uint8_t sc_maxupdates; struct ip sc_template; struct mtx sc_mtx; @@ -1377,8 +1375,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } pfsyncr.pfsyncr_syncpeer = sc->sc_sync_peer; pfsyncr.pfsyncr_maxupdates = sc->sc_maxupdates; - pfsyncr.pfsyncr_defer = (PFSYNCF_DEFER == - (sc->sc_flags & PFSYNCF_DEFER)); + pfsyncr.pfsyncr_defer = sc->sc_flags; PFSYNC_UNLOCK(sc); return (copyout(&pfsyncr, ifr_data_get_ptr(ifr), sizeof(pfsyncr))); From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4BAF641C79; Mon, 10 May 2021 19:49:55 +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 4FfBTv1Dz0z4TDj; Mon, 10 May 2021 19:49:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E574224DE; Mon, 10 May 2021 19:49:54 +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 14AJnsAg006651; Mon, 10 May 2021 19:49:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJns5X006650; Mon, 10 May 2021 19:49:54 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:54 GMT Message-Id: <202105101949.14AJns5X006650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 852b394f6f60 - stable/12 - pf: Trivial typo fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 852b394f6f607f02c3c504de3354731f44ecdc0d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:56 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=852b394f6f607f02c3c504de3354731f44ecdc0d commit 852b394f6f607f02c3c504de3354731f44ecdc0d Author: Kristof Provost AuthorDate: 2021-04-29 08:34:00 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pf: Trivial typo fix PV -> PF MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit eaabed8ac449dbd9a7f4f567e9378bda4636221e) --- sys/netpfil/pf/pf_nv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index d88c0b14e435..8a2082d3e0bb 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); #include -#define PV_NV_IMPL_UINT(fnname, type, max) \ +#define PF_NV_IMPL_UINT(fnname, type, max) \ int \ pf_nv ## fnname(const nvlist_t *nvl, const char *name, type *val) \ { \ @@ -101,9 +101,9 @@ pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, return (0); } -PV_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX) -PV_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); -PV_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX) +PF_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX); +PF_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); +PF_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX); int pf_nvint(const nvlist_t *nvl, const char *name, int *val) From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66EE76418E3; Mon, 10 May 2021 19:49:54 +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 4FfBTs137lz4T5w; Mon, 10 May 2021 19:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 F39902372; Mon, 10 May 2021 19:49:52 +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 14AJnqgC006588; Mon, 10 May 2021 19:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnqHl006587; Mon, 10 May 2021 19:49:52 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:52 GMT Message-Id: <202105101949.14AJnqHl006587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: fbbcc07976b8 - stable/13 - pfsync: Expose PFSYNCF_OK flag to userspace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fbbcc07976b80907afad51399b09cce1e9ffac35 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:54 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=fbbcc07976b80907afad51399b09cce1e9ffac35 commit fbbcc07976b80907afad51399b09cce1e9ffac35 Author: Kristof Provost AuthorDate: 2021-04-23 12:24:59 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:45:57 +0000 pfsync: Expose PFSYNCF_OK flag to userspace Add 'syncok' field to ifconfig's pfsync interface output. This allows userspace to figure out when pfsync has completed the initial bulk import. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29948 (cherry picked from commit 5f5bf88949df421ec3ccd7e14a999e8d8b9251bf) --- sbin/ifconfig/ifpfsync.c | 5 ++++- sys/net/if_pfsync.h | 2 ++ sys/netpfil/pf/if_pfsync.c | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c index 6df38c1ac997..60e3d4360aa3 100644 --- a/sbin/ifconfig/ifpfsync.c +++ b/sbin/ifconfig/ifpfsync.c @@ -206,7 +206,10 @@ pfsync_status(int s) if (preq.pfsyncr_syncdev[0] != '\0' || preq.pfsyncr_syncpeer.s_addr != htonl(INADDR_PFSYNC_GROUP)) { printf("maxupd: %d ", preq.pfsyncr_maxupdates); - printf("defer: %s\n", preq.pfsyncr_defer ? "on" : "off"); + printf("defer: %s\n", + (preq.pfsyncr_defer & PFSYNCF_DEFER) ? "on" : "off"); + printf("\tsyncok: %d\n", + (preq.pfsyncr_defer & PFSYNCF_OK) ? 1 : 0); } } diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h index f26a2ae34eed..e0b67ad95fcd 100644 --- a/sys/net/if_pfsync.h +++ b/sys/net/if_pfsync.h @@ -236,6 +236,8 @@ struct pfsyncreq { char pfsyncr_syncdev[IFNAMSIZ]; struct in_addr pfsyncr_syncpeer; int pfsyncr_maxupdates; +#define PFSYNCF_OK 0x00000001 +#define PFSYNCF_DEFER 0x00000002 int pfsyncr_defer; }; diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 06bad556e885..96813fd11dc3 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -215,8 +215,6 @@ struct pfsync_softc { struct ip_moptions sc_imo; struct in_addr sc_sync_peer; uint32_t sc_flags; -#define PFSYNCF_OK 0x00000001 -#define PFSYNCF_DEFER 0x00000002 uint8_t sc_maxupdates; struct ip sc_template; struct mtx sc_mtx; @@ -1375,8 +1373,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } pfsyncr.pfsyncr_syncpeer = sc->sc_sync_peer; pfsyncr.pfsyncr_maxupdates = sc->sc_maxupdates; - pfsyncr.pfsyncr_defer = (PFSYNCF_DEFER == - (sc->sc_flags & PFSYNCF_DEFER)); + pfsyncr.pfsyncr_defer = sc->sc_flags; PFSYNC_UNLOCK(sc); return (copyout(&pfsyncr, ifr_data_get_ptr(ifr), sizeof(pfsyncr))); From owner-dev-commits-src-all@freebsd.org Mon May 10 19:49:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E094641AFE; Mon, 10 May 2021 19:49:53 +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 4FfBTr5wrcz4T5v; Mon, 10 May 2021 19:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AD7C02371; Mon, 10 May 2021 19:49:52 +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 14AJnqhS006567; Mon, 10 May 2021 19:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14AJnqlj006566; Mon, 10 May 2021 19:49:52 GMT (envelope-from git) Date: Mon, 10 May 2021 19:49:52 GMT Message-Id: <202105101949.14AJnqlj006566@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 7f82514a6c01 - stable/12 - pf tests: Test killing states with multiple labels MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7f82514a6c016ac3d380accaa075110a65c6fbd3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 19:49:53 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7f82514a6c016ac3d380accaa075110a65c6fbd3 commit 7f82514a6c016ac3d380accaa075110a65c6fbd3 Author: Kristof Provost AuthorDate: 2021-04-21 14:12:48 +0000 Commit: Kristof Provost CommitDate: 2021-05-10 19:46:06 +0000 pf tests: Test killing states with multiple labels Now that we support having multiple labels on a rule ensure that we can use each rule label to kill states. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29938 (cherry picked from commit 5632f585355ad380cb9ef932c419e2efdb1fc46b) --- tests/sys/netpfil/pf/killstate.sh | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 994ce130a814..94363ed69ecc 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -168,8 +168,87 @@ label_cleanup() pft_cleanup } +atf_test_case "multilabel" "cleanup" +multilabel_head() +{ + atf_set descr 'Test killing states with multiple labels by label' + atf_set require.user root + atf_set require.progs scapy +} + +multilabel_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp label foo label bar" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing a label on a different rules keeps the state + jexec alcatraz pfctl -k label -k baz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing the state with the last label works + jexec alcatraz pfctl -k label -k bar + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp label foo label bar" + + # Reestablish state + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Killing with the first label works too + jexec alcatraz pfctl -k label -k foo + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +multilabel_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "label" + atf_add_test_case "multilabel" } From owner-dev-commits-src-all@freebsd.org Mon May 10 23:40:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0CDC46460A1; Mon, 10 May 2021 23:40:03 +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 4FfHbQ70KLz4dw2; Mon, 10 May 2021 23:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D865D5A91; Mon, 10 May 2021 23:40:02 +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 14ANe28D012139; Mon, 10 May 2021 23:40:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ANe2ro012136; Mon, 10 May 2021 23:40:02 GMT (envelope-from git) Date: Mon, 10 May 2021 23:40:02 GMT Message-Id: <202105102340.14ANe2ro012136@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 5e7cdf181792 - main - openat(2): add O_EMPTY_PATH MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5e7cdf1817924f8ae0333c0b53c2da32f35b65ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 23:40:03 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5e7cdf1817924f8ae0333c0b53c2da32f35b65ea commit 5e7cdf1817924f8ae0333c0b53c2da32f35b65ea Author: Konstantin Belousov AuthorDate: 2021-05-06 17:16:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 23:39:24 +0000 openat(2): add O_EMPTY_PATH It reopens the passed file descriptor, checking the file backing vnode' current access rights against open mode. In particular, this flag allows to convert file descriptor opened with O_PATH, into operable file descriptor, assuming permissions allow that. Reviewed by: markj Tested by: Andrew Walker Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30148 --- lib/libc/sys/open.2 | 18 +++++++++++++++++- sys/kern/vfs_vnops.c | 2 ++ sys/sys/fcntl.h | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index a7806df69daf..5a6f161291f6 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd March 18, 2021 +.Dd May 6, 2021 .Dt OPEN 2 .Os .Sh NAME @@ -169,6 +169,7 @@ O_CLOEXEC set FD_CLOEXEC upon open O_VERIFY verify the contents of the file O_RESOLVE_BENEATH path resolution must not cross the fd directory O_PATH record only the target path in the opened descriptor +O_EMPTY_PATH openat, open file referenced by fd if path is empty .Ed .Pp Opening a file with @@ -355,6 +356,21 @@ are not allowed. File opened with the .Dv O_PATH flag does not prevent non-forced unmount of the volume it belongs to. +.Pp +A file descriptor created with the +.Dv O_PATH +flag can be opened into normal (operable) file descriptor by +specifying it as the +.Fa fd +argument to +.Fn openat +with empty +.Fa path +and flag +.Dv O_EMPTY_PATH . +Such an open behaves as if the current path of the file referenced by +.Fa fd +is passed, except that the path walk permissions are not checked. See also the description of .Dv AT_EMPTY_PATH flag for diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index d4396f67a67b..670bc4bf8fcc 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -200,6 +200,8 @@ open2nameif(int fmode, u_int vn_open_flags) res = ISOPEN | LOCKLEAF; if ((fmode & O_RESOLVE_BENEATH) != 0) res |= RBENEATH; + if ((fmode & O_EMPTY_PATH) != 0) + res |= EMPTYPATH; if ((vn_open_flags & VN_OPEN_NOAUDIT) == 0) res |= AUDITVNODE1; if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0) diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 58d46ae26338..8fa52aeacafd 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -141,6 +141,9 @@ typedef __pid_t pid_t; #endif #define O_DSYNC 0x01000000 /* POSIX data sync */ +#if __BSD_VISIBLE +#define O_EMPTY_PATH 0x02000000 +#endif /* * XXX missing O_RSYNC. From owner-dev-commits-src-all@freebsd.org Mon May 10 23:48:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5AA30645FE4; Mon, 10 May 2021 23:48:29 +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 4FfHn924tHz4djg; Mon, 10 May 2021 23:48:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3AE8255EF; Mon, 10 May 2021 23:48:29 +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 14ANmTMi023125; Mon, 10 May 2021 23:48:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ANmTFC023124; Mon, 10 May 2021 23:48:29 GMT (envelope-from git) Date: Mon, 10 May 2021 23:48:29 GMT Message-Id: <202105102348.14ANmTFC023124@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 630caa95d461 - main - rtld: preserve the 'seen' state of the dlerror message in errmsg_save() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 630caa95d46191220dd457c2ae2d06460cb4f71b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 23:48:29 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=630caa95d46191220dd457c2ae2d06460cb4f71b commit 630caa95d46191220dd457c2ae2d06460cb4f71b Author: Konstantin Belousov AuthorDate: 2021-05-10 19:02:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-10 23:47:00 +0000 rtld: preserve the 'seen' state of the dlerror message in errmsg_save() rtld preserves its current error message around calls to user init/fini lists, to not override original error with potential secondary errors caused by user code recursing into rtld. After 4d9128da54f8f8e2a29190, the preservation of the string itself is not enough, the 'seen' indicator must be preserved as well. Otherwise, since new code does not clear string (it cannot), call to _rtld_error() from errmsg_restore() revived whatever message was consumed last. Change errmsg_save() to return structure recording both 'seen' indicator and the message, if any. PR: 255698 Reported by: Eugene M. Kim Sponsored by: The FreeBSD Foundation MFC after: 3 days --- libexec/rtld-elf/rtld.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index fce455a0ee79..75c502e8cc85 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -81,6 +81,10 @@ extern struct r_debug r_debug; /* For GDB */ extern int _thread_autoinit_dummy_decl; extern void (*__cleanup)(void); +struct dlerror_save { + int seen; + char *msg; +}; /* * Function declarations. @@ -100,8 +104,8 @@ static Obj_Entry *dlopen_object(const char *name, int fd, Obj_Entry *refobj, static Obj_Entry *do_load_object(int, const char *, char *, struct stat *, int); static int do_search_info(const Obj_Entry *obj, int, struct dl_serinfo *); static bool donelist_check(DoneList *, const Obj_Entry *); -static void errmsg_restore(char *); -static char *errmsg_save(void); +static void errmsg_restore(struct dlerror_save *); +static struct dlerror_save *errmsg_save(void); static void *fill_search_info(const char *, size_t, void *); static char *find_library(const char *, const Obj_Entry *, int *); static const char *gethints(bool); @@ -941,10 +945,16 @@ _rtld_error(const char *fmt, ...) /* * Return a dynamically-allocated copy of the current error message, if any. */ -static char * +static struct dlerror_save * errmsg_save(void) { - return (xstrdup(lockinfo.dlerror_loc())); + struct dlerror_save *res; + + res = xmalloc(sizeof(*res)); + res->seen = *lockinfo.dlerror_seen(); + if (res->seen == 0) + res->msg = xstrdup(lockinfo.dlerror_loc()); + return (res); } /* @@ -952,14 +962,17 @@ errmsg_save(void) * by errmsg_save(). The copy is freed. */ static void -errmsg_restore(char *saved_msg) +errmsg_restore(struct dlerror_save *saved_msg) { - if (saved_msg == NULL) - _rtld_error(""); - else { - _rtld_error("%s", saved_msg); - free(saved_msg); + if (saved_msg == NULL || saved_msg->seen == 1) { + *lockinfo.dlerror_seen() = 1; + } else { + *lockinfo.dlerror_seen() = 0; + strlcpy(lockinfo.dlerror_loc(), saved_msg->msg, + lockinfo.dlerror_loc_sz); + free(saved_msg->msg); } + free(saved_msg); } static const char * @@ -2736,7 +2749,7 @@ static void objlist_call_fini(Objlist *list, Obj_Entry *root, RtldLockState *lockstate) { Objlist_Entry *elm; - char *saved_msg; + struct dlerror_save *saved_msg; Elf_Addr *fini_addr; int index; @@ -2812,7 +2825,7 @@ objlist_call_init(Objlist *list, RtldLockState *lockstate) { Objlist_Entry *elm; Obj_Entry *obj; - char *saved_msg; + struct dlerror_save *saved_msg; Elf_Addr *init_addr; void (*reg)(void (*)(void)); int index; From owner-dev-commits-src-all@freebsd.org Tue May 11 00:25:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C8FD64757F; Tue, 11 May 2021 00:25: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 4FfJbk0H8Jz4gd0; Tue, 11 May 2021 00:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EC5F56168; Tue, 11 May 2021 00:25: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 14B0PLNY076266; Tue, 11 May 2021 00:25:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B0PLN0076265; Tue, 11 May 2021 00:25:21 GMT (envelope-from git) Date: Tue, 11 May 2021 00:25:21 GMT Message-Id: <202105110025.14B0PLN0076265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c8bbb1272c8b - main - vfs: Fix error handling in vn_fullpath_hardlink() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c8bbb1272c8bc103cfaa42c7a1639f42b62483dd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 00:25:22 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c8bbb1272c8bc103cfaa42c7a1639f42b62483dd commit c8bbb1272c8bc103cfaa42c7a1639f42b62483dd Author: Mark Johnston AuthorDate: 2021-05-11 00:18:00 +0000 Commit: Mark Johnston CommitDate: 2021-05-11 00:22:27 +0000 vfs: Fix error handling in vn_fullpath_hardlink() vn_fullpath_any_smr() will return a positive error number if the caller-supplied buffer isn't big enough. In this case the error must be propagated up, otherwise we may copy out uninitialized bytes. Reported by: syzkaller+KMSAN Reviewed by: mjg, kib MFC aftr: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30198 --- sys/kern/vfs_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 2aaaecb5cd4d..607b1e67a40a 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -3646,9 +3646,9 @@ vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, error = vn_fullpath_dir(vp, pwd->pwd_rdir, buf, retbuf, buflen, addend); pwd_drop(pwd); - if (error != 0) - goto out_bad; } + if (error != 0) + goto out_bad; *freebuf = buf; From owner-dev-commits-src-all@freebsd.org Tue May 11 00:27:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6B9C647AD7; Tue, 11 May 2021 00:27:59 +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 4FfJfl4qMrz4hDy; Tue, 11 May 2021 00:27:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 98B4D5EDE; Tue, 11 May 2021 00:27:59 +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 14B0RxgT076997; Tue, 11 May 2021 00:27:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B0RxvB076996; Tue, 11 May 2021 00:27:59 GMT (envelope-from git) Date: Tue, 11 May 2021 00:27:59 GMT Message-Id: <202105110027.14B0RxvB076996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 1db8c60c4d0f - stable/13 - nfsclient: Copy only initialized fields in nfs_getattr() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1db8c60c4d0f3c2ab8be44bc477df4e3d8f43a93 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 00:27:59 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1db8c60c4d0f3c2ab8be44bc477df4e3d8f43a93 commit 1db8c60c4d0f3c2ab8be44bc477df4e3d8f43a93 Author: Mark Johnston AuthorDate: 2021-05-04 12:53:57 +0000 Commit: Mark Johnston CommitDate: 2021-05-11 00:27:51 +0000 nfsclient: Copy only initialized fields in nfs_getattr() When loading attributes from the cache, the NFS client is careful to copy only the fields that it initialized. After fetching attributes from the server, however, it would copy the entire vattr structure initialized from the RPC response, so uninitialized stack bytes would end up being copied to userspace. In particular, va_birthtime (v2 and v3) and va_gen (v3) had this problem. Use a common subroutine to copy fields provided by the NFS client, and ensure that we provide a dummy va_gen for the v3 case. Reviewed by: rmacklem Reported by: KMSAN Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30090 (cherry picked from commit 8bde6d15d1fa9a947c2bdc5eddae36cfbb1076dc) --- sys/fs/nfs/nfsport.h | 1 + sys/fs/nfsclient/nfs_clcomsubs.c | 1 + sys/fs/nfsclient/nfs_clport.c | 24 +++++++++++++++++++++++- sys/fs/nfsclient/nfs_clvnops.c | 19 ++----------------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index 6777dc72f6a3..cb82666ab397 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -1001,6 +1001,7 @@ int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, int, int); int newnfs_realign(struct mbuf **, int); bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep); +void ncl_copy_vattr(struct vattr *dst, struct vattr *src); /* * If the port runs on an SMP box that can enforce Atomic ops with low diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c index 6a36aed478d9..8a51d51f093f 100644 --- a/sys/fs/nfsclient/nfs_clcomsubs.c +++ b/sys/fs/nfsclient/nfs_clcomsubs.c @@ -285,6 +285,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvattr *nap) fxdr_nfsv3time(&fp->fa3_ctime, &nap->na_ctime); fxdr_nfsv3time(&fp->fa3_mtime, &nap->na_mtime); nap->na_flags = 0; + nap->na_gen = 0; nap->na_filerev = 0; } else { NFSM_DISSECT(fp, struct nfs_fattr *, NFSX_V2FATTR); diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 81a0e05c3234..64820cd11f1c 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -400,6 +400,28 @@ nfscl_warn_fileid(struct nfsmount *nmp, struct nfsvattr *oldnap, ncl_fileid_maxwarnings); } +void +ncl_copy_vattr(struct vattr *dst, struct vattr *src) +{ + dst->va_type = src->va_type; + dst->va_mode = src->va_mode; + dst->va_nlink = src->va_nlink; + dst->va_uid = src->va_uid; + dst->va_gid = src->va_gid; + dst->va_fsid = src->va_fsid; + dst->va_fileid = src->va_fileid; + dst->va_size = src->va_size; + dst->va_blocksize = src->va_blocksize; + dst->va_atime = src->va_atime; + dst->va_mtime = src->va_mtime; + dst->va_ctime = src->va_ctime; + dst->va_gen = src->va_gen; + dst->va_flags = src->va_flags; + dst->va_rdev = src->va_rdev; + dst->va_bytes = src->va_bytes; + dst->va_filerev = src->va_filerev; +} + /* * Load the attribute cache (that lives in the nfsnode entry) with * the attributes of the second argument and @@ -551,7 +573,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper, KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); } if (vaper != NULL) { - NFSBCOPY((caddr_t)vap, (caddr_t)vaper, sizeof(*vap)); + ncl_copy_vattr(vaper, vap); if (np->n_flag & NCHG) { if (np->n_flag & NACC) vaper->va_atime = np->n_atim; diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 217290b080b3..5f81bb5b42a4 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -962,23 +962,8 @@ nfs_getattr(struct vop_getattr_args *ap) * First look in the cache. */ if (ncl_getattrcache(vp, &vattr) == 0) { - vap->va_type = vattr.va_type; - vap->va_mode = vattr.va_mode; - vap->va_nlink = vattr.va_nlink; - vap->va_uid = vattr.va_uid; - vap->va_gid = vattr.va_gid; - vap->va_fsid = vattr.va_fsid; - vap->va_fileid = vattr.va_fileid; - vap->va_size = vattr.va_size; - vap->va_blocksize = vattr.va_blocksize; - vap->va_atime = vattr.va_atime; - vap->va_mtime = vattr.va_mtime; - vap->va_ctime = vattr.va_ctime; - vap->va_gen = vattr.va_gen; - vap->va_flags = vattr.va_flags; - vap->va_rdev = vattr.va_rdev; - vap->va_bytes = vattr.va_bytes; - vap->va_filerev = vattr.va_filerev; + ncl_copy_vattr(vap, &vattr); + /* * Get the local modify time for the case of a write * delegation. From owner-dev-commits-src-all@freebsd.org Tue May 11 00:28:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1CCC4647DB5; Tue, 11 May 2021 00:28:36 +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 4FfJgS0P3Hz4hHX; Tue, 11 May 2021 00:28:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0062661AE; Tue, 11 May 2021 00:28:36 +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 14B0SZOU077171; Tue, 11 May 2021 00:28:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B0SZVY077170; Tue, 11 May 2021 00:28:35 GMT (envelope-from git) Date: Tue, 11 May 2021 00:28:35 GMT Message-Id: <202105110028.14B0SZVY077170@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2bad237ec94f - stable/12 - nfsclient: Copy only initialized fields in nfs_getattr() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2bad237ec94f701e3041c146db136f03e6c89324 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 00:28:36 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2bad237ec94f701e3041c146db136f03e6c89324 commit 2bad237ec94f701e3041c146db136f03e6c89324 Author: Mark Johnston AuthorDate: 2021-05-04 12:53:57 +0000 Commit: Mark Johnston CommitDate: 2021-05-11 00:28:22 +0000 nfsclient: Copy only initialized fields in nfs_getattr() When loading attributes from the cache, the NFS client is careful to copy only the fields that it initialized. After fetching attributes from the server, however, it would copy the entire vattr structure initialized from the RPC response, so uninitialized stack bytes would end up being copied to userspace. In particular, va_birthtime (v2 and v3) and va_gen (v3) had this problem. Use a common subroutine to copy fields provided by the NFS client, and ensure that we provide a dummy va_gen for the v3 case. Reviewed by: rmacklem Reported by: KMSAN Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30090 (cherry picked from commit 8bde6d15d1fa9a947c2bdc5eddae36cfbb1076dc) --- sys/fs/nfs/nfsport.h | 1 + sys/fs/nfsclient/nfs_clcomsubs.c | 1 + sys/fs/nfsclient/nfs_clport.c | 24 +++++++++++++++++++++++- sys/fs/nfsclient/nfs_clvnops.c | 19 ++----------------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index a0181df0bde7..5371f29d00de 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -880,6 +880,7 @@ int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, int, int); int newnfs_realign(struct mbuf **, int); bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep); +void ncl_copy_vattr(struct vattr *dst, struct vattr *src); /* * If the port runs on an SMP box that can enforce Atomic ops with low diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c index e49b276ec66d..f0ac1a0b09ca 100644 --- a/sys/fs/nfsclient/nfs_clcomsubs.c +++ b/sys/fs/nfsclient/nfs_clcomsubs.c @@ -234,6 +234,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvattr *nap) fxdr_nfsv3time(&fp->fa3_ctime, &nap->na_ctime); fxdr_nfsv3time(&fp->fa3_mtime, &nap->na_mtime); nap->na_flags = 0; + nap->na_gen = 0; nap->na_filerev = 0; } else { NFSM_DISSECT(fp, struct nfs_fattr *, NFSX_V2FATTR); diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 7f6bbe622180..20500a290ff0 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -399,6 +399,28 @@ nfscl_warn_fileid(struct nfsmount *nmp, struct nfsvattr *oldnap, ncl_fileid_maxwarnings); } +void +ncl_copy_vattr(struct vattr *dst, struct vattr *src) +{ + dst->va_type = src->va_type; + dst->va_mode = src->va_mode; + dst->va_nlink = src->va_nlink; + dst->va_uid = src->va_uid; + dst->va_gid = src->va_gid; + dst->va_fsid = src->va_fsid; + dst->va_fileid = src->va_fileid; + dst->va_size = src->va_size; + dst->va_blocksize = src->va_blocksize; + dst->va_atime = src->va_atime; + dst->va_mtime = src->va_mtime; + dst->va_ctime = src->va_ctime; + dst->va_gen = src->va_gen; + dst->va_flags = src->va_flags; + dst->va_rdev = src->va_rdev; + dst->va_bytes = src->va_bytes; + dst->va_filerev = src->va_filerev; +} + /* * Load the attribute cache (that lives in the nfsnode entry) with * the attributes of the second argument and @@ -550,7 +572,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper, KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); } if (vaper != NULL) { - NFSBCOPY((caddr_t)vap, (caddr_t)vaper, sizeof(*vap)); + ncl_copy_vattr(vaper, vap); if (np->n_flag & NCHG) { if (np->n_flag & NACC) vaper->va_atime = np->n_atim; diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index fadcf26c686a..17859a16424b 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -916,23 +916,8 @@ nfs_getattr(struct vop_getattr_args *ap) * First look in the cache. */ if (ncl_getattrcache(vp, &vattr) == 0) { - vap->va_type = vattr.va_type; - vap->va_mode = vattr.va_mode; - vap->va_nlink = vattr.va_nlink; - vap->va_uid = vattr.va_uid; - vap->va_gid = vattr.va_gid; - vap->va_fsid = vattr.va_fsid; - vap->va_fileid = vattr.va_fileid; - vap->va_size = vattr.va_size; - vap->va_blocksize = vattr.va_blocksize; - vap->va_atime = vattr.va_atime; - vap->va_mtime = vattr.va_mtime; - vap->va_ctime = vattr.va_ctime; - vap->va_gen = vattr.va_gen; - vap->va_flags = vattr.va_flags; - vap->va_rdev = vattr.va_rdev; - vap->va_bytes = vattr.va_bytes; - vap->va_filerev = vattr.va_filerev; + ncl_copy_vattr(vap, &vattr); + /* * Get the local modify time for the case of a write * delegation. From owner-dev-commits-src-all@freebsd.org Tue May 11 00:28:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67631647AFA; Tue, 11 May 2021 00:28:53 +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 4FfJgn2Ty1z4hHw; Tue, 11 May 2021 00:28:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 478826353; Tue, 11 May 2021 00:28:53 +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 14B0Sr9f077315; Tue, 11 May 2021 00:28:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B0SrJ2077314; Tue, 11 May 2021 00:28:53 GMT (envelope-from git) Date: Tue, 11 May 2021 00:28:53 GMT Message-Id: <202105110028.14B0SrJ2077314@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 65a160cd0b0b - stable/13 - path_test: Add a few new test cases MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 65a160cd0b0bc6e2f8af852ededec924401d62d5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 00:28:53 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=65a160cd0b0bc6e2f8af852ededec924401d62d5 commit 65a160cd0b0bc6e2f8af852ededec924401d62d5 Author: Mark Johnston AuthorDate: 2021-05-04 12:56:31 +0000 Commit: Mark Johnston CommitDate: 2021-05-11 00:28:44 +0000 path_test: Add a few new test cases Sponsored by: The FreeBSD Foundation (cherry picked from commit b59851e99c20f3a72c34bdf9919e3bf49b894e4e) --- tests/sys/file/path_test.c | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c index a8354f88b091..e1f5240374c4 100644 --- a/tests/sys/file/path_test.c +++ b/tests/sys/file/path_test.c @@ -38,10 +38,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -49,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -205,6 +208,47 @@ ATF_TC_BODY(path_capsicum, tc) waitchild(child, 4); } +/* Make sure that ptrace(PT_COREDUMP) cannot be used to write to a path fd. */ +ATF_TC_WITHOUT_HEAD(path_coredump); +ATF_TC_BODY(path_coredump, tc) +{ + char path[PATH_MAX]; + struct ptrace_coredump pc; + int error, pathfd, status; + pid_t child; + + mktdir(path, "path_coredump.XXXXXX"); + + child = fork(); + ATF_REQUIRE_MSG(child != -1, FMT_ERR("fork")); + if (child == 0) { + while (true) + (void)sleep(1); + } + + pathfd = open(path, O_PATH); + ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open")); + + error = ptrace(PT_ATTACH, child, 0, 0); + ATF_REQUIRE_MSG(error == 0, FMT_ERR("ptrace")); + error = waitpid(child, &status, 0); + ATF_REQUIRE_MSG(error != -1, FMT_ERR("waitpid")); + ATF_REQUIRE_MSG(WIFSTOPPED(status), "unexpected status %d", status); + + pc.pc_fd = pathfd; + pc.pc_flags = 0; + pc.pc_limit = 0; + error = ptrace(PT_COREDUMP, child, (void *)&pc, sizeof(pc)); + ATF_REQUIRE_ERRNO(EBADF, error == -1); + + error = ptrace(PT_DETACH, child, 0, 0); + ATF_REQUIRE_MSG(error == 0, FMT_ERR("ptrace")); + + ATF_REQUIRE_MSG(kill(child, SIGKILL) == 0, FMT_ERR("kill")); + + CHECKED_CLOSE(pathfd); +} + /* Verify operations on directory path descriptors. */ ATF_TC_WITHOUT_HEAD(path_directory); ATF_TC_BODY(path_directory, tc) @@ -506,6 +550,33 @@ ATF_TC_BODY(path_fexecve, tc) ATF_REQUIRE_ERRNO(EACCES, pathfd < 0); } +/* Make sure that O_PATH restrictions apply to named pipes as well. */ +ATF_TC_WITHOUT_HEAD(path_fifo); +ATF_TC_BODY(path_fifo, tc) +{ + char path[PATH_MAX], buf[BUFSIZ]; + struct kevent ev; + int kq, pathfd; + + snprintf(path, sizeof(path), "path_fifo.XXXXXX"); + ATF_REQUIRE_MSG(mktemp(path) == path, FMT_ERR("mktemp")); + + ATF_REQUIRE_MSG(mkfifo(path, 0666) == 0, FMT_ERR("mkfifo")); + + pathfd = open(path, O_PATH); + ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open")); + memset(buf, 0, sizeof(buf)); + ATF_REQUIRE_ERRNO(EBADF, write(pathfd, buf, sizeof(buf))); + ATF_REQUIRE_ERRNO(EBADF, read(pathfd, buf, sizeof(buf))); + + kq = kqueue(); + ATF_REQUIRE_MSG(kq >= 0, FMT_ERR("kqueue")); + EV_SET(&ev, pathfd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); + ATF_REQUIRE_ERRNO(EBADF, kevent(kq, &ev, 1, NULL, 0, NULL) == -1); + + CHECKED_CLOSE(pathfd); +} + /* Files may be unlinked using a path fd. */ ATF_TC_WITHOUT_HEAD(path_funlinkat); ATF_TC_BODY(path_funlinkat, tc) @@ -755,11 +826,38 @@ ATF_TC_BODY(path_rights, tc) CHECKED_CLOSE(sd[1]); } +/* Verify that a local socket can't be opened with O_PATH. */ +ATF_TC_WITHOUT_HEAD(path_unix); +ATF_TC_BODY(path_unix, tc) +{ + char path[PATH_MAX]; + struct sockaddr_un sun; + int pathfd, sd; + + snprintf(path, sizeof(path), "path_unix.XXXXXX"); + ATF_REQUIRE_MSG(mktemp(path) == path, FMT_ERR("mktemp")); + + sd = socket(PF_LOCAL, SOCK_STREAM, 0); + ATF_REQUIRE_MSG(sd >= 0, FMT_ERR("socket")); + + memset(&sun, 0, sizeof(sun)); + sun.sun_family = PF_LOCAL; + (void)strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); + ATF_REQUIRE_MSG(bind(sd, (struct sockaddr *)&sun, SUN_LEN(&sun)) == 0, + FMT_ERR("bind")); + + pathfd = open(path, O_RDONLY); + ATF_REQUIRE_ERRNO(EOPNOTSUPP, pathfd < 0); + + CHECKED_CLOSE(sd); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, path_access); ATF_TP_ADD_TC(tp, path_aio); ATF_TP_ADD_TC(tp, path_capsicum); + ATF_TP_ADD_TC(tp, path_coredump); ATF_TP_ADD_TC(tp, path_directory); ATF_TP_ADD_TC(tp, path_directory_not_root); ATF_TP_ADD_TC(tp, path_empty); @@ -768,11 +866,13 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, path_event); ATF_TP_ADD_TC(tp, path_fcntl); ATF_TP_ADD_TC(tp, path_fexecve); + ATF_TP_ADD_TC(tp, path_fifo); ATF_TP_ADD_TC(tp, path_funlinkat); ATF_TP_ADD_TC(tp, path_io); ATF_TP_ADD_TC(tp, path_ioctl); ATF_TP_ADD_TC(tp, path_lock); ATF_TP_ADD_TC(tp, path_rights); + ATF_TP_ADD_TC(tp, path_unix); return (atf_no_error()); } From owner-dev-commits-src-all@freebsd.org Tue May 11 00:38:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47FB6647FAB; Tue, 11 May 2021 00:38:08 +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 4FfJtS1bFlz4hDP; Tue, 11 May 2021 00:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 298926721; Tue, 11 May 2021 00:38:08 +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 14B0c8vI091406; Tue, 11 May 2021 00:38:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B0c8m6091405; Tue, 11 May 2021 00:38:08 GMT (envelope-from git) Date: Tue, 11 May 2021 00:38:08 GMT Message-Id: <202105110038.14B0c8m6091405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: cb07628d9e7c - main - nfscl: Delete unneeded redundant MODULE_DEPEND() calls MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cb07628d9e7c84019f99e2dfeadbe0957e5c22e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 00:38:08 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=cb07628d9e7c84019f99e2dfeadbe0957e5c22e8 commit cb07628d9e7c84019f99e2dfeadbe0957e5c22e8 Author: Rick Macklem AuthorDate: 2021-05-11 00:34:29 +0000 Commit: Rick Macklem CommitDate: 2021-05-11 00:34:29 +0000 nfscl: Delete unneeded redundant MODULE_DEPEND() calls There are two module declarations in the nfscl.ko module for "nfscl" and "nfs". Both of these declarations had MODULE_DEPEND() calls. This patch deletes the MODULE_DEPEND() calls for "nfs" to avoid confusion with respect to what modules this module is dependent upon. The patch also adds comments explaining why there are two module declarations within the module. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D30102 --- sys/fs/nfsclient/nfs_clport.c | 9 +++++++++ sys/fs/nfsclient/nfs_clvfsops.c | 14 ++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 492b93340e4e..4676f09f8e86 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -1438,6 +1438,14 @@ static moduledata_t nfscl_mod = { nfscl_modevent, NULL, }; +/* + * This is the main module declaration for the NFS client. The + * nfscl_modevent() function is needed to ensure that the module + * cannot be unloaded, among other things. + * There is also a module declaration in sys/fs/nfsclient/nfs_clvfsops.c + * for the name "nfs" within the VFS_SET() macro that defines the "nfs" + * file system type. + */ DECLARE_MODULE(nfscl, nfscl_mod, SI_SUB_VFS, SI_ORDER_FIRST); /* So that loader and kldload(2) can find us, wherever we are.. */ @@ -1445,3 +1453,4 @@ MODULE_VERSION(nfscl, 1); MODULE_DEPEND(nfscl, nfscommon, 1, 1, 1); MODULE_DEPEND(nfscl, krpc, 1, 1, 1); MODULE_DEPEND(nfscl, nfssvc, 1, 1, 1); +MODULE_DEPEND(nfscl, xdr, 1, 1, 1); diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 08a25c6fe632..847bf72acf0c 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -148,14 +147,17 @@ static struct vfsops nfs_vfsops = { .vfs_sysctl = nfs_sysctl, .vfs_purge = nfs_purge, }; +/* + * This macro declares that the file system type is named "nfs". + * It also declares a module name of "nfs" and uses vfs_modevent() + * as the event handling function. + * The main module declaration is found in sys/fs/nfsclient/nfs_clport.c + * for "nfscl" and is needed so that a custom event handling + * function gets called. MODULE_DEPEND() macros are found there. + */ VFS_SET(nfs_vfsops, nfs, VFCF_NETWORK | VFCF_SBDRY); -/* So that loader and kldload(2) can find us, wherever we are.. */ MODULE_VERSION(nfs, 1); -MODULE_DEPEND(nfs, nfscommon, 1, 1, 1); -MODULE_DEPEND(nfs, krpc, 1, 1, 1); -MODULE_DEPEND(nfs, nfssvc, 1, 1, 1); -MODULE_DEPEND(nfs, xdr, 1, 1, 1); /* * This structure is now defined in sys/nfs/nfs_diskless.c so that it From owner-dev-commits-src-all@freebsd.org Tue May 11 01:15:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 242AE649B15; Tue, 11 May 2021 01:15:50 +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 4FfKjy0DP1z4kRQ; Tue, 11 May 2021 01:15:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EEC44701B; Tue, 11 May 2021 01:15:49 +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 14B1FnHj044615; Tue, 11 May 2021 01:15:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B1FnHQ044614; Tue, 11 May 2021 01:15:49 GMT (envelope-from git) Date: Tue, 11 May 2021 01:15:49 GMT Message-Id: <202105110115.14B1FnHQ044614@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 3e67975a0c08 - stable/13 - nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3e67975a0c0807073daff24a3b6fa8942d3305d2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 01:15:50 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3e67975a0c0807073daff24a3b6fa8942d3305d2 commit 3e67975a0c0807073daff24a3b6fa8942d3305d2 Author: Rick Macklem AuthorDate: 2021-04-27 22:32:35 +0000 Commit: Rick Macklem CommitDate: 2021-05-11 01:12:21 +0000 nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT It was reported that a NFSv4.1 Linux client mount against a FreeBSD12 server was hung, with the TCP connection in CLOSE_WAIT state on the server. When a NFSv4.1/4.2 mount is done and the back channel is bound to the TCP connection, the soclose() is delayed until a new TCP connection is bound to the back channel, due to a reference count being held on the SVCXPRT structure in the krpc for the socket. Without the soclose() call, the socket will remain in CLOSE_WAIT and this somehow caused the Linux client to hang. This patch adds calls to soshutdown(.., SHUT_WR) that are performed when the server side krpc sees that the socket is no longer usable. Since this can be done before the back channel is bound to a new TCP connection, it allows the TCP connection to proceed to CLOSED state. PR: 254590 (cherry picked from commit db8c27f499105dcc9872dcc46e88bdd570c24fee) --- sys/rpc/svc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index a059096e7b77..be0f08ebca9d 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -203,6 +203,8 @@ svcpool_cleanup(SVCPOOL *pool) mtx_unlock(&grp->sg_lock); } TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) { + if (xprt->xp_socket != NULL) + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } @@ -388,6 +390,8 @@ xprt_unregister(SVCXPRT *xprt) xprt_unregister_locked(xprt); mtx_unlock(&grp->sg_lock); + if (xprt->xp_socket != NULL) + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } @@ -1078,6 +1082,7 @@ svc_checkidle(SVCGROUP *grp) mtx_unlock(&grp->sg_lock); TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) { + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } mtx_lock(&grp->sg_lock); From owner-dev-commits-src-all@freebsd.org Tue May 11 01:17:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B627649DBF; Tue, 11 May 2021 01:17:18 +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 4FfKlf1vVlz4kr8; Tue, 11 May 2021 01:17:18 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 34A257091; Tue, 11 May 2021 01:17:18 +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 14B1HI7q044826; Tue, 11 May 2021 01:17:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B1HIVK044825; Tue, 11 May 2021 01:17:18 GMT (envelope-from git) Date: Tue, 11 May 2021 01:17:18 GMT Message-Id: <202105110117.14B1HIVK044825@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 3bcaad593004 - stable/13 - nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3bcaad5930046d64645923dd2286dff3dce09eed Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 01:17:18 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3bcaad5930046d64645923dd2286dff3dce09eed commit 3bcaad5930046d64645923dd2286dff3dce09eed Author: Rick Macklem AuthorDate: 2021-04-27 00:48:21 +0000 Commit: Rick Macklem CommitDate: 2021-05-11 01:14:20 +0000 nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs For a pNFS mount, the NFSv4.1/4.2 client uses compound RPCs that have both Open and LayoutGet operations in them. If the pNFS server were tp reply NFSERR_DELAY for one of these compounds, the retry after a delay cannot be handled by newnfs_request(), since there is a reference held on the open state for the Open operation in them. Fix this by adding these RPCs to the "don't do delay here" list in newnfs_request(). This patch is only needed if the mount is using pNFS (the "pnfs" mount option) and probably only matters if the MDS server is issuing delegations as well as pNFS layouts. Found by code inspection. (cherry picked from commit f5ff282bc025f0395afcef40f5b6e778202c4181) --- sys/fs/nfs/nfs_commonkrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 6e766abcf4b1..49c68da45a69 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -1067,7 +1067,9 @@ tryagain: nd->nd_procnum != NFSPROC_WRITE && nd->nd_procnum != NFSPROC_WRITEDS && nd->nd_procnum != NFSPROC_OPEN && + nd->nd_procnum != NFSPROC_OPENLAYGET && nd->nd_procnum != NFSPROC_CREATE && + nd->nd_procnum != NFSPROC_CREATELAYGET && nd->nd_procnum != NFSPROC_OPENCONFIRM && nd->nd_procnum != NFSPROC_OPENDOWNGRADE && nd->nd_procnum != NFSPROC_CLOSE && From owner-dev-commits-src-all@freebsd.org Tue May 11 01:23:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7D0F464A364; Tue, 11 May 2021 01:23:38 +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 4FfKty37F7z4l9c; Tue, 11 May 2021 01:23:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5E86B6EBF; Tue, 11 May 2021 01:23:38 +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 14B1Ncwn057465; Tue, 11 May 2021 01:23:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B1NcHY057464; Tue, 11 May 2021 01:23:38 GMT (envelope-from git) Date: Tue, 11 May 2021 01:23:38 GMT Message-Id: <202105110123.14B1NcHY057464@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 16e172a410bf - stable/12 - nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 16e172a410bff6d2c67523fe949424ab055b46a6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 01:23:38 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=16e172a410bff6d2c67523fe949424ab055b46a6 commit 16e172a410bff6d2c67523fe949424ab055b46a6 Author: Rick Macklem AuthorDate: 2021-04-27 22:32:35 +0000 Commit: Rick Macklem CommitDate: 2021-05-11 01:19:54 +0000 nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT It was reported that a NFSv4.1 Linux client mount against a FreeBSD12 server was hung, with the TCP connection in CLOSE_WAIT state on the server. When a NFSv4.1/4.2 mount is done and the back channel is bound to the TCP connection, the soclose() is delayed until a new TCP connection is bound to the back channel, due to a reference count being held on the SVCXPRT structure in the krpc for the socket. Without the soclose() call, the socket will remain in CLOSE_WAIT and this somehow caused the Linux client to hang. This patch adds calls to soshutdown(.., SHUT_WR) that are performed when the server side krpc sees that the socket is no longer usable. Since this can be done before the back channel is bound to a new TCP connection, it allows the TCP connection to proceed to CLOSED state. PR: 254590 (cherry picked from commit db8c27f499105dcc9872dcc46e88bdd570c24fee) --- sys/rpc/svc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index cd44b8fd53b7..8fe457c63cc3 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -203,6 +203,8 @@ svcpool_cleanup(SVCPOOL *pool) mtx_unlock(&grp->sg_lock); } TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) { + if (xprt->xp_socket != NULL) + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } @@ -388,6 +390,8 @@ xprt_unregister(SVCXPRT *xprt) xprt_unregister_locked(xprt); mtx_unlock(&grp->sg_lock); + if (xprt->xp_socket != NULL) + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } @@ -1076,6 +1080,7 @@ svc_checkidle(SVCGROUP *grp) mtx_unlock(&grp->sg_lock); TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) { + soshutdown(xprt->xp_socket, SHUT_WR); SVC_RELEASE(xprt); } mtx_lock(&grp->sg_lock); From owner-dev-commits-src-all@freebsd.org Tue May 11 01:25:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CCA3B64A8E9; Tue, 11 May 2021 01:25:50 +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 4FfKxV5TnMz4lZq; Tue, 11 May 2021 01:25:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AC55D7051; Tue, 11 May 2021 01:25:50 +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 14B1PoZt057728; Tue, 11 May 2021 01:25:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B1PoZo057727; Tue, 11 May 2021 01:25:50 GMT (envelope-from git) Date: Tue, 11 May 2021 01:25:50 GMT Message-Id: <202105110125.14B1PoZo057727@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: d0c90712df75 - stable/12 - nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d0c90712df75e588cc1fa1f68a93f67ba9ff80c6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 01:25:50 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=d0c90712df75e588cc1fa1f68a93f67ba9ff80c6 commit d0c90712df75e588cc1fa1f68a93f67ba9ff80c6 Author: Rick Macklem AuthorDate: 2021-04-27 00:48:21 +0000 Commit: Rick Macklem CommitDate: 2021-05-11 01:23:12 +0000 nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs For a pNFS mount, the NFSv4.1/4.2 client uses compound RPCs that have both Open and LayoutGet operations in them. If the pNFS server were tp reply NFSERR_DELAY for one of these compounds, the retry after a delay cannot be handled by newnfs_request(), since there is a reference held on the open state for the Open operation in them. Fix this by adding these RPCs to the "don't do delay here" list in newnfs_request(). This patch is only needed if the mount is using pNFS (the "pnfs" mount option) and probably only matters if the MDS server is issuing delegations as well as pNFS layouts. Found by code inspection. (cherry picked from commit f5ff282bc025f0395afcef40f5b6e778202c4181) --- sys/fs/nfs/nfs_commonkrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 449b3ad5e4a7..b6fe49b8e470 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -1062,7 +1062,9 @@ tryagain: nd->nd_procnum != NFSPROC_WRITE && nd->nd_procnum != NFSPROC_WRITEDS && nd->nd_procnum != NFSPROC_OPEN && + nd->nd_procnum != NFSPROC_OPENLAYGET && nd->nd_procnum != NFSPROC_CREATE && + nd->nd_procnum != NFSPROC_CREATELAYGET && nd->nd_procnum != NFSPROC_OPENCONFIRM && nd->nd_procnum != NFSPROC_OPENDOWNGRADE && nd->nd_procnum != NFSPROC_CLOSE && From owner-dev-commits-src-all@freebsd.org Tue May 11 02:26:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6C8E64C1B8; Tue, 11 May 2021 02:26:20 +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 4FfMHJ6Cmlz4nxC; Tue, 11 May 2021 02:26:20 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C821F7C40; Tue, 11 May 2021 02:26:20 +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 14B2QKOP037484; Tue, 11 May 2021 02:26:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B2QKrm037483; Tue, 11 May 2021 02:26:20 GMT (envelope-from git) Date: Tue, 11 May 2021 02:26:20 GMT Message-Id: <202105110226.14B2QKrm037483@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: 31c3770ee5b7 - main - powerpc/mmu: Actually use the Radix pmap_align_superpage function 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: 31c3770ee5b7017ecee79ff9b98db915f2b97653 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 02:26:21 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=31c3770ee5b7017ecee79ff9b98db915f2b97653 commit 31c3770ee5b7017ecee79ff9b98db915f2b97653 Author: Justin Hibbits AuthorDate: 2021-05-11 02:23:04 +0000 Commit: Justin Hibbits CommitDate: 2021-05-11 02:26:14 +0000 powerpc/mmu: Actually use the Radix pmap_align_superpage function This was missed in the conversion to ifuncs. It might help improve promotion rates. --- sys/powerpc/aim/mmu_radix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index bb43b64febff..5c1bd6e7ea02 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -512,6 +512,7 @@ static struct pmap_funcs mmu_radix_methods = { .dumpsys_map_chunk = mmu_radix_dumpsys_map, .page_is_mapped = mmu_radix_page_is_mapped, .ps_enabled = mmu_radix_ps_enabled, + .align_superpage = mmu_radix_align_superpage, .object_init_pt = mmu_radix_object_init_pt, .protect = mmu_radix_protect, /* pmap dispatcher interface */ From owner-dev-commits-src-all@freebsd.org Tue May 11 02:26:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5155964C41B; Tue, 11 May 2021 02:26: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 4FfMHL0MGmz4nhv; Tue, 11 May 2021 02:26:22 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EA6477C41; Tue, 11 May 2021 02:26: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 14B2QLMU037505; Tue, 11 May 2021 02:26:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B2QLDx037504; Tue, 11 May 2021 02:26:21 GMT (envelope-from git) Date: Tue, 11 May 2021 02:26:21 GMT Message-Id: <202105110226.14B2QLDx037504@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: a436e6653142 - main - powerpc/radix pmap: Convert stat counters from ulongs to counters 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: a436e665314276c8ab4cb3264f5f7cb0f29d7506 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 02:26:22 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=a436e665314276c8ab4cb3264f5f7cb0f29d7506 commit a436e665314276c8ab4cb3264f5f7cb0f29d7506 Author: Justin Hibbits AuthorDate: 2021-05-11 02:23:14 +0000 Commit: Justin Hibbits CommitDate: 2021-05-11 02:26:14 +0000 powerpc/radix pmap: Convert stat counters from ulongs to counters This should help performance a hair, for concurrent stat updates, by reducing contention on cache lines. --- sys/powerpc/aim/mmu_radix.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index 5c1bd6e7ea02..01fcc94bafb5 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -2366,28 +2366,28 @@ mmu_radix_cpu_bootstrap(int ap) static SYSCTL_NODE(_vm_pmap, OID_AUTO, l3e, CTLFLAG_RD, 0, "2MB page mapping counters"); -static u_long pmap_l3e_demotions; -SYSCTL_ULONG(_vm_pmap_l3e, OID_AUTO, demotions, CTLFLAG_RD, - &pmap_l3e_demotions, 0, "2MB page demotions"); +static COUNTER_U64_DEFINE_EARLY(pmap_l3e_demotions); +SYSCTL_COUNTER_U64(_vm_pmap_l3e, OID_AUTO, demotions, CTLFLAG_RD, + &pmap_l3e_demotions, "2MB page demotions"); -static u_long pmap_l3e_mappings; -SYSCTL_ULONG(_vm_pmap_l3e, OID_AUTO, mappings, CTLFLAG_RD, - &pmap_l3e_mappings, 0, "2MB page mappings"); +static COUNTER_U64_DEFINE_EARLY(pmap_l3e_mappings); +SYSCTL_COUNTER_U64(_vm_pmap_l3e, OID_AUTO, mappings, CTLFLAG_RD, + &pmap_l3e_mappings, "2MB page mappings"); -static u_long pmap_l3e_p_failures; -SYSCTL_ULONG(_vm_pmap_l3e, OID_AUTO, p_failures, CTLFLAG_RD, - &pmap_l3e_p_failures, 0, "2MB page promotion failures"); +static COUNTER_U64_DEFINE_EARLY(pmap_l3e_p_failures); +SYSCTL_COUNTER_U64(_vm_pmap_l3e, OID_AUTO, p_failures, CTLFLAG_RD, + &pmap_l3e_p_failures, "2MB page promotion failures"); -static u_long pmap_l3e_promotions; -SYSCTL_ULONG(_vm_pmap_l3e, OID_AUTO, promotions, CTLFLAG_RD, - &pmap_l3e_promotions, 0, "2MB page promotions"); +static COUNTER_U64_DEFINE_EARLY(pmap_l3e_promotions); +SYSCTL_COUNTER_U64(_vm_pmap_l3e, OID_AUTO, promotions, CTLFLAG_RD, + &pmap_l3e_promotions, "2MB page promotions"); static SYSCTL_NODE(_vm_pmap, OID_AUTO, l2e, CTLFLAG_RD, 0, "1GB page mapping counters"); -static u_long pmap_l2e_demotions; -SYSCTL_ULONG(_vm_pmap_l2e, OID_AUTO, demotions, CTLFLAG_RD, - &pmap_l2e_demotions, 0, "1GB page demotions"); +static COUNTER_U64_DEFINE_EARLY(pmap_l2e_demotions); +SYSCTL_COUNTER_U64(_vm_pmap_l2e, OID_AUTO, demotions, CTLFLAG_RD, + &pmap_l2e_demotions, "1GB page demotions"); void mmu_radix_clear_modify(vm_page_t m) @@ -2559,7 +2559,7 @@ mmu_radix_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, *l3e = htobe64(srcptepaddr & ~PG_W); pmap_resident_count_inc(dst_pmap, L3_PAGE_SIZE / PAGE_SIZE); - atomic_add_long(&pmap_l3e_mappings, 1); + counter_u64_add(pmap_l3e_mappings, 1); } else dst_pdpg->ref_count--; continue; @@ -2784,12 +2784,12 @@ setpte: pte_store(pde, PG_PROMOTED | newpde); ptesync(); - atomic_add_long(&pmap_l3e_promotions, 1); + counter_u64_add(pmap_l3e_promotions, 1); CTR2(KTR_PMAP, "pmap_promote_l3e: success for va %#lx" " in pmap %p", va, pmap); return (0); fail: - atomic_add_long(&pmap_l3e_p_failures, 1); + counter_u64_add(pmap_l3e_p_failures, 1); return (KERN_FAILURE); } #endif /* VM_NRESERVLEVEL > 0 */ @@ -3246,7 +3246,7 @@ pmap_enter_l3e(pmap_t pmap, vm_offset_t va, pml3_entry_t newpde, u_int flags, pte_store(l3e, newpde); ptesync(); - atomic_add_long(&pmap_l3e_mappings, 1); + counter_u64_add(pmap_l3e_mappings, 1); CTR2(KTR_PMAP, "pmap_enter_pde: success for va %#lx" " in pmap %p", va, pmap); return (KERN_SUCCESS); @@ -4037,7 +4037,7 @@ mmu_radix_object_init_pt(pmap_t pmap, vm_offset_t addr, pa |= PG_M | PG_A | PG_RW; pte_store(l3e, pa); pmap_resident_count_inc(pmap, L3_PAGE_SIZE / PAGE_SIZE); - atomic_add_long(&pmap_l3e_mappings, 1); + counter_u64_add(pmap_l3e_mappings, 1); } else { /* Continue on if the PDE is already valid. */ pdpg->ref_count--; @@ -4953,7 +4953,7 @@ pmap_demote_l3e_locked(pmap_t pmap, pml3_entry_t *l3e, vm_offset_t va, if ((oldpde & PG_MANAGED) != 0) pmap_pv_demote_l3e(pmap, va, oldpde & PG_PS_FRAME, lockp); - atomic_add_long(&pmap_l3e_demotions, 1); + counter_u64_add(pmap_l3e_demotions, 1); CTR2(KTR_PMAP, "pmap_demote_l3e: success for va %#lx" " in pmap %p", va, pmap); return (TRUE); @@ -5950,7 +5950,7 @@ pmap_demote_l2e(pmap_t pmap, pml2_entry_t *l2e, vm_offset_t va) */ pmap_invalidate_all(pmap); - pmap_l2e_demotions++; + counter_u64_add(pmap_l2e_demotions, 1); CTR2(KTR_PMAP, "pmap_demote_pdpe: success for va %#lx" " in pmap %p", va, pmap); return (TRUE); From owner-dev-commits-src-all@freebsd.org Tue May 11 04:30:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C6EFA64EC63; Tue, 11 May 2021 04:30:19 +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 4FfQ2M5KBTz4th6; Tue, 11 May 2021 04:30:19 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A9F631174A; Tue, 11 May 2021 04:30:19 +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 14B4UJ08003822; Tue, 11 May 2021 04:30:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B4UJxA003819; Tue, 11 May 2021 04:30:19 GMT (envelope-from git) Date: Tue, 11 May 2021 04:30:19 GMT Message-Id: <202105110430.14B4UJxA003819@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 12288bd999ca - main - cache: fix lockless absolute symlink traversal to non-fp mounts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12288bd999ca3a493b8dc4cba109e5a8fa838c45 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 04:30:19 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=12288bd999ca3a493b8dc4cba109e5a8fa838c45 commit 12288bd999ca3a493b8dc4cba109e5a8fa838c45 Author: Mateusz Guzik AuthorDate: 2021-05-11 03:48:08 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-11 04:30:12 +0000 cache: fix lockless absolute symlink traversal to non-fp mounts Said lookups would incorrectly fail with EOPNOTSUP. Reported by: kib --- sys/kern/vfs_cache.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 607b1e67a40a..5b978511db17 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -3904,6 +3904,7 @@ struct cache_fpl { #endif }; +static bool cache_fplookup_mp_supported(struct mount *mp); static bool cache_fplookup_is_mp(struct cache_fpl *fpl); static int cache_fplookup_cross_mount(struct cache_fpl *fpl); static int cache_fplookup_partial_setup(struct cache_fpl *fpl); @@ -5142,6 +5143,19 @@ cache_fplookup_symlink(struct cache_fpl *fpl) if (seqc_in_modify(fpl->dvp_seqc)) { return (cache_fpl_aborted(fpl)); } + /* + * The main loop assumes that ->dvp points to a vnode belonging + * to a filesystem which can do lockless lookup, but the absolute + * symlink can be wandering off to one which does not. + */ + mp = atomic_load_ptr(&fpl->dvp->v_mount); + if (__predict_false(mp == NULL)) { + return (cache_fpl_aborted(fpl)); + } + if (!cache_fplookup_mp_supported(mp)) { + cache_fpl_checkpoint(fpl); + return (cache_fpl_partial(fpl)); + } } return (0); } From owner-dev-commits-src-all@freebsd.org Tue May 11 06:12:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F4D0629493; Tue, 11 May 2021 06:12:10 +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 4FfSHt3kBZz3Fl5; Tue, 11 May 2021 06:12:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 72D8913491; Tue, 11 May 2021 06:12:10 +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 14B6CAlV043051; Tue, 11 May 2021 06:12:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B6CAF0043050; Tue, 11 May 2021 06:12:10 GMT (envelope-from git) Date: Tue, 11 May 2021 06:12:10 GMT Message-Id: <202105110612.14B6CAF0043050@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 9e16b9530aab - main - Clean up copyright messages. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e16b9530aab5e1c4efee2a8fe2feaf33340c764 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 06:12:10 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=9e16b9530aab5e1c4efee2a8fe2feaf33340c764 commit 9e16b9530aab5e1c4efee2a8fe2feaf33340c764 Author: Kirk McKusick AuthorDate: 2021-05-11 06:01:58 +0000 Commit: Kirk McKusick CommitDate: 2021-05-11 06:14:35 +0000 Clean up copyright messages. Reported by: Yoshihiro Ota MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D29354 --- usr.bin/systat/sysput.c | 9 ++++----- usr.bin/systat/zarc.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/usr.bin/systat/sysput.c b/usr.bin/systat/sysput.c index 10401cee772a..e089c5c2ff55 100644 --- a/usr.bin/systat/sysput.c +++ b/usr.bin/systat/sysput.c @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2019, 2020 Yoshihiro Ota * * Redistribution and use in source and binary forms, with or without @@ -9,14 +11,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) diff --git a/usr.bin/systat/zarc.c b/usr.bin/systat/zarc.c index bb6aada8581c..41efe136779d 100644 --- a/usr.bin/systat/zarc.c +++ b/usr.bin/systat/zarc.c @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2014 - 2017, 2019 Yoshihiro Ota * * Redistribution and use in source and binary forms, with or without @@ -9,14 +11,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) From owner-dev-commits-src-all@freebsd.org Tue May 11 08:45:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D846762DB39; Tue, 11 May 2021 08:45:58 +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 4FfWjL3SlTz3N3D; Tue, 11 May 2021 08:45:58 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6A091151B7; Tue, 11 May 2021 08:45:58 +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 14B8jwQ1041863; Tue, 11 May 2021 08:45:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B8jwdY041862; Tue, 11 May 2021 08:45:58 GMT (envelope-from git) Date: Tue, 11 May 2021 08:45:58 GMT Message-Id: <202105110845.14B8jwdY041862@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: f6f297871d46 - main - sbin/ipfw: Allow tablearg as hostname MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f6f297871d469daf808f78faead8f950a2c81e36 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 08:45:58 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=f6f297871d469daf808f78faead8f950a2c81e36 commit f6f297871d469daf808f78faead8f950a2c81e36 Author: Lutz Donnerhacke AuthorDate: 2021-05-11 08:22:16 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-11 08:44:33 +0000 sbin/ipfw: Allow tablearg as hostname Hostnames starting with "tablearg" are considered as a functional argument instead of a literal. Reported by: ae Reviewers: ae MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30208 --- sbin/ipfw/ipfw2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 498da22e6599..fb1d9a4a180b 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -4021,7 +4021,8 @@ chkarg: NEED1("missing forward address[:port]"); - if (strncmp(*av, "tablearg", 8) == 0) + if (strncmp(*av, "tablearg", 8) == 0 && + ((*av)[8] == '\0' || (*av)[8] == ',' || (*av)[8] == ':')) memcpy(++(*av), "0.0.0.0", 7); /* From owner-dev-commits-src-all@freebsd.org Tue May 11 09:53:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E97E4630213; Tue, 11 May 2021 09:53:39 +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 4FfYCR6HTVz3hFy; Tue, 11 May 2021 09:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CAA0F16129; Tue, 11 May 2021 09:53:39 +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 14B9rdpM035167; Tue, 11 May 2021 09:53:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14B9rdFw035166; Tue, 11 May 2021 09:53:39 GMT (envelope-from git) Date: Tue, 11 May 2021 09:53:39 GMT Message-Id: <202105110953.14B9rdFw035166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 3cbad8287aa0 - main - truss: Add missing underscore to compat_prefix for FreeBSD32 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3cbad8287aa0ed72e07df1130ce2ae490642e63a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 09:53:40 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=3cbad8287aa0ed72e07df1130ce2ae490642e63a commit 3cbad8287aa0ed72e07df1130ce2ae490642e63a Author: Alex Richardson AuthorDate: 2021-05-11 09:52:56 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 09:53:02 +0000 truss: Add missing underscore to compat_prefix for FreeBSD32 I accidentally dropped this in the final version of D27625, so it didn't actually work as intended. I found this while testing the MFC to stable/13. MFC after: immediately Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments") --- usr.bin/truss/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 31c20d656b6a..78be0c7f570f 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -106,7 +106,7 @@ static struct procabi freebsd32 = { .type = "FreeBSD32", .abi = SYSDECODE_ABI_FREEBSD32, .pointer_size = sizeof(uint32_t), - .compat_prefix = "freebsd32", + .compat_prefix = "freebsd32_", .extra_syscalls = STAILQ_HEAD_INITIALIZER(freebsd32.extra_syscalls), .syscalls = { NULL } }; From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 963A3631AB7; Tue, 11 May 2021 10:31:04 +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 4FfZ2c3tNqz3k0S; Tue, 11 May 2021 10:31:04 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 78324166E7; Tue, 11 May 2021 10:31:04 +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 14BAV43Q084713; Tue, 11 May 2021 10:31:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAV48b084712; Tue, 11 May 2021 10:31:04 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:04 GMT Message-Id: <202105111031.14BAV48b084712@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: eec6f94ea578 - stable/13 - truss: split counting of syscalls and syscall calling convention MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eec6f94ea5782766f50288919def194b8c969aa5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:04 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=eec6f94ea5782766f50288919def194b8c969aa5 commit eec6f94ea5782766f50288919def194b8c969aa5 Author: Alex Richardson AuthorDate: 2021-03-04 18:28:25 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:23 +0000 truss: split counting of syscalls and syscall calling convention This change is a refactoring cleanup to improve support for compat32 syscalls (and compat64 on CHERI systems). Each process ABI now has it's own struct sycall instead of using one global list. The list of all syscalls is replaced with a list of seen syscalls. Looking up the syscall argument passing convention now interates over the fixed-size array instead of using a link-list that's populated on startup so we no longer need the init_syscall() function. The actual functional changes are in D27625. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27636 (cherry picked from commit 6019514b0b53c3fc151868b88357405b6d67f308) --- usr.bin/truss/main.c | 1 - usr.bin/truss/setup.c | 19 ++++++----- usr.bin/truss/syscall.h | 25 +++++++++----- usr.bin/truss/syscalls.c | 85 +++++++++++++++++++++++------------------------- 4 files changed, 67 insertions(+), 63 deletions(-) diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index c10301b6680d..1a3aae75be88 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -87,7 +87,6 @@ main(int ac, char **av) trussinfo->strsize = 32; trussinfo->curthread = NULL; LIST_INIT(&trussinfo->proclist); - init_syscalls(); while ((c = getopt(ac, av, "p:o:facedDs:SH")) != -1) { switch (c) { case 'p': /* specified pid */ diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index d21ec133f483..2ea1bce8919b 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -463,8 +463,8 @@ enter_syscall(struct trussinfo *info, struct threadinfo *t, fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n", t->proc->abi->type, t->cs.number); - t->cs.nargs = sc->nargs; - assert(sc->nargs <= nitems(t->cs.s_args)); + t->cs.nargs = sc->decode.nargs; + assert(sc->decode.nargs <= nitems(t->cs.s_args)); t->cs.sc = sc; @@ -480,11 +480,12 @@ enter_syscall(struct trussinfo *info, struct threadinfo *t, #endif for (i = 0; i < t->cs.nargs; i++) { #if DEBUG - fprintf(stderr, "0x%lx%s", t->cs.args[sc->args[i].offset], + fprintf(stderr, "0x%lx%s", + t->cs.args[sc->decode.args[i].offset], i < (t->cs.nargs - 1) ? "," : ""); #endif - if (!(sc->args[i].type & OUT)) { - t->cs.s_args[i] = print_arg(&sc->args[i], + if (!(sc->decode.args[i].type & OUT)) { + t->cs.s_args[i] = print_arg(&sc->decode.args[i], t->cs.args, NULL, info); } } @@ -542,19 +543,19 @@ exit_syscall(struct trussinfo *info, struct ptrace_lwpinfo *pl) * Here, we only look for arguments that have OUT masked in -- * otherwise, they were handled in enter_syscall(). */ - for (i = 0; i < sc->nargs; i++) { + for (i = 0; i < sc->decode.nargs; i++) { char *temp; - if (sc->args[i].type & OUT) { + if (sc->decode.args[i].type & OUT) { /* * If an error occurred, then don't bother * getting the data; it may not be valid. */ if (psr.sr_error != 0) { asprintf(&temp, "0x%lx", - t->cs.args[sc->args[i].offset]); + t->cs.args[sc->decode.args[i].offset]); } else { - temp = print_arg(&sc->args[i], + temp = print_arg(&sc->decode.args[i], t->cs.args, psr.sr_retval, info); } t->cs.s_args[i] = temp; diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index af918fed4f1b..fc1630677242 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -218,18 +218,28 @@ enum Argtype { _Static_assert(ARG_MASK > MAX_ARG_TYPE, "ARG_MASK overlaps with Argtype values"); -struct syscall_args { +struct syscall_arg { enum Argtype type; int offset; }; +struct syscall_decode { + const char *name; /* Name for calling convention lookup. */ + /* + * Syscall return type: + * 0: no return value (e.g. exit) + * 1: normal return value (a single int/long/pointer) + * 2: off_t return value (two values for 32-bit ABIs) + */ + u_int ret_type; + u_int nargs; /* number of meaningful arguments */ + struct syscall_arg args[10]; /* Hopefully no syscalls with > 10 args */ +}; + struct syscall { STAILQ_ENTRY(syscall) entries; - const char *name; - u_int ret_type; /* 0, 1, or 2 return values */ - u_int nargs; /* actual number of meaningful arguments */ - /* Hopefully, no syscalls with > 10 args */ - struct syscall_args args[10]; + const char *name; /* Name to be displayed, might be malloc()'d */ + struct syscall_decode decode; struct timespec time; /* Time spent for this call */ int ncalls; /* Number of calls */ int nerror; /* Number of calls that returned with error */ @@ -237,7 +247,7 @@ struct syscall { }; struct syscall *get_syscall(struct threadinfo *, u_int, u_int); -char *print_arg(struct syscall_args *, unsigned long*, register_t *, +char *print_arg(struct syscall_arg *, unsigned long *, register_t *, struct trussinfo *); /* @@ -280,7 +290,6 @@ struct linux_socketcall_args { char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; }; -void init_syscalls(void); void print_syscall(struct trussinfo *); void print_syscall_ret(struct trussinfo *, int, register_t *); void print_summary(struct trussinfo *trussinfo); diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index f52a82ed97c0..91ddc65e457f 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -47,8 +47,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #define _WANT_FREEBSD11_STAT #include @@ -66,8 +68,6 @@ __FBSDID("$FreeBSD$"); #define _WANT_KERNEL_ERRNO #include #include -#include -#include #include #include #include @@ -85,8 +85,13 @@ __FBSDID("$FreeBSD$"); /* * This should probably be in its own file, sorted alphabetically. + * + * Note: We only scan this table on the initial syscall number to calling + * convention lookup, i.e. once each time a new syscall is encountered. This + * is unlikely to be a performance issue, but if it is we could sort this array + * and use a binary search instead. */ -static struct syscall decoded_syscalls[] = { +static const struct syscall_decode decoded_syscalls[] = { /* Native ABI */ { .name = "__acl_aclcheck_fd", .ret_type = 1, .nargs = 3, .args = { { Int, 0 }, { Acltype, 1 }, { Ptr, 2 } } }, @@ -706,10 +711,8 @@ static struct syscall decoded_syscalls[] = { { .name = "cloudabi_sys_thread_exit", .ret_type = 1, .nargs = 2, .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, { .name = "cloudabi_sys_thread_yield", .ret_type = 1, .nargs = 0 }, - - { .name = 0 }, }; -static STAILQ_HEAD(, syscall) syscalls; +static STAILQ_HEAD(, syscall) seen_syscalls; /* Xlat idea taken from strace */ struct xlat { @@ -969,7 +972,7 @@ print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), FILE *fp, * decoding arguments. */ static void -quad_fixup(struct syscall *sc) +quad_fixup(struct syscall_decode *sc) { int offset, prev; u_int i; @@ -1007,20 +1010,6 @@ quad_fixup(struct syscall *sc) } #endif -void -init_syscalls(void) -{ - struct syscall *sc; - - STAILQ_INIT(&syscalls); - for (sc = decoded_syscalls; sc->name != NULL; sc++) { -#ifndef __LP64__ - quad_fixup(sc); -#endif - STAILQ_INSERT_HEAD(&syscalls, sc, entries); - } -} - static struct syscall * find_syscall(struct procabi *abi, u_int number) { @@ -1040,6 +1029,11 @@ add_syscall(struct procabi *abi, u_int number, struct syscall *sc) { struct extra_syscall *es; +#ifndef __LP64__ + /* FIXME: should be based on syscall ABI not truss ABI */ + quad_fixup(&sc->decode); +#endif + if (number < nitems(abi->syscalls)) { assert(abi->syscalls[number] == NULL); abi->syscalls[number] = sc; @@ -1049,6 +1043,8 @@ add_syscall(struct procabi *abi, u_int number, struct syscall *sc) es->number = number; STAILQ_INSERT_TAIL(&abi->extra_syscalls, es, entries); } + + STAILQ_INSERT_HEAD(&seen_syscalls, sc, entries); } /* @@ -1059,24 +1055,28 @@ struct syscall * get_syscall(struct threadinfo *t, u_int number, u_int nargs) { struct syscall *sc; + const char *sysdecode_name; const char *name; - char *new_name; u_int i; sc = find_syscall(t->proc->abi, number); if (sc != NULL) return (sc); - name = sysdecode_syscallname(t->proc->abi->abi, number); - if (name == NULL) { - asprintf(&new_name, "#%d", number); - name = new_name; - } else - new_name = NULL; - STAILQ_FOREACH(sc, &syscalls, entries) { - if (strcmp(name, sc->name) == 0) { + /* Memory is not explicitly deallocated, it's released on exit(). */ + sysdecode_name = sysdecode_syscallname(t->proc->abi->abi, number); + if (sysdecode_name == NULL) + asprintf(__DECONST(char **, &name), "#%d", number); + else + name = sysdecode_name; + + sc = calloc(1, sizeof(*sc)); + sc->name = name; + + for (i = 0; i < nitems(decoded_syscalls); i++) { + if (strcmp(name, decoded_syscalls[i].name) == 0) { + sc->decode = decoded_syscalls[i]; add_syscall(t->proc->abi, number, sc); - free(new_name); return (sc); } } @@ -1086,21 +1086,15 @@ get_syscall(struct threadinfo *t, u_int number, u_int nargs) fprintf(stderr, "unknown syscall %s -- setting args to %d\n", name, nargs); #endif - - sc = calloc(1, sizeof(struct syscall)); - sc->name = name; - if (new_name != NULL) - sc->unknown = true; - sc->ret_type = 1; - sc->nargs = nargs; + sc->unknown = sysdecode_name == NULL; + sc->decode.ret_type = 1; /* Assume 1 return value. */ + sc->decode.nargs = nargs; for (i = 0; i < nargs; i++) { - sc->args[i].offset = i; + sc->decode.args[i].offset = i; /* Treat all unknown arguments as LongHex. */ - sc->args[i].type = LongHex; + sc->decode.args[i].type = LongHex; } - STAILQ_INSERT_HEAD(&syscalls, sc, entries); add_syscall(t->proc->abi, number, sc); - return (sc); } @@ -1717,7 +1711,7 @@ print_sysctl(FILE *fp, int *oid, size_t len) * an array of all of the system call arguments. */ char * -print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval, +print_arg(struct syscall_arg *sc, unsigned long *args, register_t *retval, struct trussinfo *trussinfo) { FILE *fp; @@ -2992,7 +2986,7 @@ print_syscall_ret(struct trussinfo *trussinfo, int error, register_t *retval) strerror(error)); } #ifndef __LP64__ - else if (sc->ret_type == 2) { + else if (sc->decode.ret_type == 2) { off_t off; #if _BYTE_ORDER == _LITTLE_ENDIAN @@ -3019,7 +3013,7 @@ print_summary(struct trussinfo *trussinfo) fprintf(trussinfo->outfile, "%-20s%15s%8s%8s\n", "syscall", "seconds", "calls", "errors"); ncall = nerror = 0; - STAILQ_FOREACH(sc, &syscalls, entries) + STAILQ_FOREACH(sc, &seen_syscalls, entries) { if (sc->ncalls) { fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n", sc->name, (intmax_t)sc->time.tv_sec, @@ -3028,6 +3022,7 @@ print_summary(struct trussinfo *trussinfo) ncall += sc->ncalls; nerror += sc->nerror; } + } fprintf(trussinfo->outfile, "%20s%15s%8s%8s\n", "", "-------------", "-------", "-------"); fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n", From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E14A2631B39; Tue, 11 May 2021 10:31:05 +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 4FfZ2d5L9lz3jxf; Tue, 11 May 2021 10:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A1D61168EF; Tue, 11 May 2021 10:31:05 +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 14BAV52X084734; Tue, 11 May 2021 10:31:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAV5e7084733; Tue, 11 May 2021 10:31:05 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:05 GMT Message-Id: <202105111031.14BAV5e7084733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 46c255b6325d - stable/13 - truss: improved support for decoding compat32 arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 46c255b6325d4a84ca22a663cfbedb762ac12b02 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:06 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=46c255b6325d4a84ca22a663cfbedb762ac12b02 commit 46c255b6325d4a84ca22a663cfbedb762ac12b02 Author: Alex Richardson AuthorDate: 2021-03-25 11:12:17 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:24 +0000 truss: improved support for decoding compat32 arguments Currently running `truss -a -e` does not decode any argument values for freebsd32_* syscalls (open/readlink/etc.) This change checks whether a syscall starts with freebsd{32,64}_ and if so strips that prefix when looking up the syscall information. To ensure that the truss logs include the real syscall name we create a copy of the syscall information struct with the updated. The other problem is that when reading string array values, truss naively iterates over an array of char* and fetches the pointer value. This will result in arguments not being loaded if the pointer is not aligned to sizeof(void*), which can happens in the compat32 case. If it happens to be aligned, we would end up printing every other value. To fix this problem, this changes adds a pointer_size member to the procabi struct and uses that to correctly read indirect arguments as 64/32 bit addresses in the the compat32 case (and also compat64 on CheriBSD). The motivating use-case for this change is using truss for 64-bit programs on a CHERI system, but most of the diff also applies to 32-bit compat on a 64-bit system, so I'm upstreaming this instead of keeping it as a local CheriBSD patch. Output of `truss -aef ldd32 /usr/bin/ldd32` before: 39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000) 39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0) /usr/bin/ldd32: 39113: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 39113: fork() = 39114 (0x98ca) 39114: 39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN 39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000) 39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0) 39114: issetugid() = 0 (0x0) 39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80) 39114: freebsd32_fstat(0x3,0xffffbd98) = 0 (0x0) 39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23) 39114: close(3) = 0 (0x0) 39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3) 39114: freebsd32_fstat(0x3,0xffffc7d0) = 0 (0x0) 39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000) After: 783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000) 783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0) = 0 (0x0) /usr/bin/ldd32: 783: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 784: 783: fork() = 784 (0x310) 784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN 784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000) 784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0) 784: issetugid() = 0 (0x0) 784: sigfastblock(0x1,0x204234fc) = 0 (0x0) 784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80) 784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0) 784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb) Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27625 (cherry picked from commit 7daca4e2043fa8d88658eb8c2fc195128cb5c3da) --- usr.bin/truss/setup.c | 71 ++++++++++++++++++++++++++++-------------------- usr.bin/truss/syscalls.c | 59 +++++++++++++++++++++++++++++----------- usr.bin/truss/truss.h | 2 ++ 3 files changed, 87 insertions(+), 45 deletions(-) diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 2ea1bce8919b..31c20d656b6a 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -74,59 +74,72 @@ static void new_proc(struct trussinfo *, pid_t, lwpid_t); static struct procabi cloudabi32 = { - "CloudABI32", - SYSDECODE_ABI_CLOUDABI32, - STAILQ_HEAD_INITIALIZER(cloudabi32.extra_syscalls), - { NULL } + .type = "CloudABI32", + .abi = SYSDECODE_ABI_CLOUDABI32, + .pointer_size = sizeof(uint32_t), + .extra_syscalls = STAILQ_HEAD_INITIALIZER(cloudabi32.extra_syscalls), + .syscalls = { NULL } }; static struct procabi cloudabi64 = { - "CloudABI64", - SYSDECODE_ABI_CLOUDABI64, - STAILQ_HEAD_INITIALIZER(cloudabi64.extra_syscalls), - { NULL } + .type = "CloudABI64", + .abi = SYSDECODE_ABI_CLOUDABI64, + .pointer_size = sizeof(uint64_t), + .extra_syscalls = STAILQ_HEAD_INITIALIZER(cloudabi64.extra_syscalls), + .syscalls = { NULL } }; static struct procabi freebsd = { - "FreeBSD", - SYSDECODE_ABI_FREEBSD, - STAILQ_HEAD_INITIALIZER(freebsd.extra_syscalls), - { NULL } + .type = "FreeBSD", + .abi = SYSDECODE_ABI_FREEBSD, + .pointer_size = sizeof(void *), + .extra_syscalls = STAILQ_HEAD_INITIALIZER(freebsd.extra_syscalls), + .syscalls = { NULL } }; -#ifdef __LP64__ +#if !defined(__SIZEOF_POINTER__) +#error "Use a modern compiler." +#endif + +#if __SIZEOF_POINTER__ > 4 static struct procabi freebsd32 = { - "FreeBSD32", - SYSDECODE_ABI_FREEBSD32, - STAILQ_HEAD_INITIALIZER(freebsd32.extra_syscalls), - { NULL } + .type = "FreeBSD32", + .abi = SYSDECODE_ABI_FREEBSD32, + .pointer_size = sizeof(uint32_t), + .compat_prefix = "freebsd32", + .extra_syscalls = STAILQ_HEAD_INITIALIZER(freebsd32.extra_syscalls), + .syscalls = { NULL } }; #endif static struct procabi linux = { - "Linux", - SYSDECODE_ABI_LINUX, - STAILQ_HEAD_INITIALIZER(linux.extra_syscalls), - { NULL } + .type = "Linux", + .abi = SYSDECODE_ABI_LINUX, + .pointer_size = sizeof(void *), + .extra_syscalls = STAILQ_HEAD_INITIALIZER(linux.extra_syscalls), + .syscalls = { NULL } }; -#ifdef __LP64__ +#if __SIZEOF_POINTER__ > 4 static struct procabi linux32 = { - "Linux32", - SYSDECODE_ABI_LINUX32, - STAILQ_HEAD_INITIALIZER(linux32.extra_syscalls), - { NULL } + .type = "Linux32", + .abi = SYSDECODE_ABI_LINUX32, + .pointer_size = sizeof(uint32_t), + .extra_syscalls = STAILQ_HEAD_INITIALIZER(linux32.extra_syscalls), + .syscalls = { NULL } }; #endif static struct procabi_table abis[] = { { "CloudABI ELF32", &cloudabi32 }, { "CloudABI ELF64", &cloudabi64 }, -#ifdef __LP64__ +#if __SIZEOF_POINTER__ == 4 + { "FreeBSD ELF32", &freebsd }, +#elif __SIZEOF_POINTER__ == 8 { "FreeBSD ELF64", &freebsd }, { "FreeBSD ELF32", &freebsd32 }, #else - { "FreeBSD ELF32", &freebsd }, +#error "Unsupported pointer size" #endif #if defined(__powerpc64__) { "FreeBSD ELF64 V2", &freebsd }, @@ -137,7 +150,7 @@ static struct procabi_table abis[] = { #if defined(__i386__) { "FreeBSD a.out", &freebsd }, #endif -#ifdef __LP64__ +#if __SIZEOF_POINTER__ >= 8 { "Linux ELF64", &linux }, { "Linux ELF32", &linux32 }, #else diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 91ddc65e457f..eaea3ad96765 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -963,7 +963,6 @@ print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), FILE *fp, fprintf(fp, "|0x%x", rem); } -#ifndef __LP64__ /* * Add argument padding to subsequent system calls after Quad * syscall arguments as needed. This used to be done by hand in the @@ -1008,7 +1007,6 @@ quad_fixup(struct syscall_decode *sc) } } } -#endif static struct syscall * find_syscall(struct procabi *abi, u_int number) @@ -1029,10 +1027,13 @@ add_syscall(struct procabi *abi, u_int number, struct syscall *sc) { struct extra_syscall *es; -#ifndef __LP64__ - /* FIXME: should be based on syscall ABI not truss ABI */ - quad_fixup(&sc->decode); -#endif + /* + * quad_fixup() is currently needed for all 32-bit ABIs. + * TODO: This should probably be a function pointer inside struct + * procabi instead. + */ + if (abi->pointer_size == 4) + quad_fixup(&sc->decode); if (number < nitems(abi->syscalls)) { assert(abi->syscalls[number] == NULL); @@ -1055,16 +1056,19 @@ struct syscall * get_syscall(struct threadinfo *t, u_int number, u_int nargs) { struct syscall *sc; + struct procabi *procabi; const char *sysdecode_name; + const char *lookup_name; const char *name; u_int i; - sc = find_syscall(t->proc->abi, number); + procabi = t->proc->abi; + sc = find_syscall(procabi, number); if (sc != NULL) return (sc); /* Memory is not explicitly deallocated, it's released on exit(). */ - sysdecode_name = sysdecode_syscallname(t->proc->abi->abi, number); + sysdecode_name = sysdecode_syscallname(procabi->abi, number); if (sysdecode_name == NULL) asprintf(__DECONST(char **, &name), "#%d", number); else @@ -1073,8 +1077,14 @@ get_syscall(struct threadinfo *t, u_int number, u_int nargs) sc = calloc(1, sizeof(*sc)); sc->name = name; + /* Also decode compat syscalls arguments by stripping the prefix. */ + lookup_name = name; + if (procabi->compat_prefix != NULL && strncmp(procabi->compat_prefix, + name, strlen(procabi->compat_prefix)) == 0) + lookup_name += strlen(procabi->compat_prefix); + for (i = 0; i < nitems(decoded_syscalls); i++) { - if (strcmp(name, decoded_syscalls[i].name) == 0) { + if (strcmp(lookup_name, decoded_syscalls[i].name) == 0) { sc->decode = decoded_syscalls[i]; add_syscall(t->proc->abi, number, sc); return (sc); @@ -1817,12 +1827,15 @@ print_arg(struct syscall_arg *sc, unsigned long *args, register_t *retval, case StringArray: { uintptr_t addr; union { - char *strarray[0]; + int32_t strarray32[PAGE_SIZE / sizeof(int32_t)]; + int64_t strarray64[PAGE_SIZE / sizeof(int64_t)]; char buf[PAGE_SIZE]; } u; char *string; size_t len; u_int first, i; + size_t pointer_size = + trussinfo->curthread->proc->abi->pointer_size; /* * Only parse argv[] and environment arrays from exec calls @@ -1842,7 +1855,7 @@ print_arg(struct syscall_arg *sc, unsigned long *args, register_t *retval, * a partial page. */ addr = args[sc->offset]; - if (addr % sizeof(char *) != 0) { + if (addr % pointer_size != 0) { print_pointer(fp, args[sc->offset]); break; } @@ -1852,22 +1865,36 @@ print_arg(struct syscall_arg *sc, unsigned long *args, register_t *retval, print_pointer(fp, args[sc->offset]); break; } + assert(len > 0); fputc('[', fp); first = 1; i = 0; - while (u.strarray[i] != NULL) { - string = get_string(pid, (uintptr_t)u.strarray[i], 0); + for (;;) { + uintptr_t straddr; + if (pointer_size == 4) { + if (u.strarray32[i] == 0) + break; + /* sign-extend 32-bit pointers */ + straddr = (intptr_t)u.strarray32[i]; + } else if (pointer_size == 8) { + if (u.strarray64[i] == 0) + break; + straddr = (intptr_t)u.strarray64[i]; + } else { + errx(1, "Unsupported pointer size: %zu", + pointer_size); + } + string = get_string(pid, straddr, 0); fprintf(fp, "%s \"%s\"", first ? "" : ",", string); free(string); first = 0; i++; - if (i == len / sizeof(char *)) { + if (i == len / pointer_size) { addr += len; len = PAGE_SIZE; - if (get_struct(pid, addr, u.buf, len) == - -1) { + if (get_struct(pid, addr, u.buf, len) == -1) { fprintf(fp, ", "); break; } diff --git a/usr.bin/truss/truss.h b/usr.bin/truss/truss.h index 5154515848bf..a3ce8f27d953 100644 --- a/usr.bin/truss/truss.h +++ b/usr.bin/truss/truss.h @@ -58,6 +58,8 @@ struct extra_syscall { struct procabi { const char *type; enum sysdecode_abi abi; + size_t pointer_size; + const char *compat_prefix; STAILQ_HEAD(, extra_syscall) extra_syscalls; struct syscall *syscalls[SYSCALL_NORMAL_COUNT]; }; From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 309D8631D1B; Tue, 11 May 2021 10:31:07 +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 4FfZ2f6YVYz3k7R; Tue, 11 May 2021 10:31:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C1A89168F0; Tue, 11 May 2021 10:31:06 +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 14BAV6eF084755; Tue, 11 May 2021 10:31:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAV6GL084754; Tue, 11 May 2021 10:31:06 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:06 GMT Message-Id: <202105111031.14BAV6GL084754@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: f66ada750493 - stable/13 - bsd.compiler.mk: detect Apple Clang for cross-builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f66ada75049376e9f36d502ca83a4e66b8fb4f24 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:07 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=f66ada75049376e9f36d502ca83a4e66b8fb4f24 commit f66ada75049376e9f36d502ca83a4e66b8fb4f24 Author: Alex Richardson AuthorDate: 2021-04-20 00:46:36 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:25 +0000 bsd.compiler.mk: detect Apple Clang for cross-builds Apple clang uses a different versioning scheme, so if we enable or disable certain warnings for Clang 11+, those might not be supported in Apple Clang 11+. This adds 'apple-clang' to COMPILER_FEATURES, so that bootstrap tools Makefiles can avoid warnings on macOS. Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D29680 (cherry picked from commit ba1182e26376987fe424707b2abc4d6532b28623) --- share/mk/bsd.compiler.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk index fa8e6c44a17e..4c14e3811f6e 100644 --- a/share/mk/bsd.compiler.mk +++ b/share/mk/bsd.compiler.mk @@ -26,6 +26,12 @@ # mitigation. # - init-all: supports stack variable initialization. # +# When bootstrapping on macOS, 'apple-clang' will be set in COMPILER_FEATURES +# to differentiate Apple's version of Clang. Apple Clang uses a different +# versioning scheme and may not support the same -W/-Wno warning flags. For a +# mapping of Apple Clang versions to upstream clang versions see +# https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-_12.x_(since_Free_On-Device_Development) +# # These variables with an X_ prefix will also be provided if XCC is set. # # This file may be included multiple times, but only has effect the first time. @@ -202,6 +208,10 @@ ${X_}COMPILER_TYPE:= gcc .if !defined(${X_}COMPILER_VERSION) ${X_}COMPILER_VERSION!=echo "${_v:M[1-9]*.[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' .endif +# Detect apple clang when bootstrapping to select appropriate warning flags. +.if !defined(${X_}COMPILER_FEATURES) && ${_v:[*]:M*Apple clang version*} +${X_}COMPILER_FEATURES= apple-clang +.endif .undef _v .endif .if !defined(${X_}COMPILER_FREEBSD_VERSION) @@ -218,7 +228,7 @@ ${X_}COMPILER_FREEBSD_VERSION= unknown ${X_}COMPILER_RESOURCE_DIR!= ${${cc}:N${CCACHE_BIN}} -print-resource-dir 2>/dev/null || echo unknown .endif -${X_}COMPILER_FEATURES= c++11 c++14 +${X_}COMPILER_FEATURES+= c++11 c++14 .if ${${X_}COMPILER_TYPE} == "clang" || \ (${${X_}COMPILER_TYPE} == "gcc" && ${${X_}COMPILER_VERSION} >= 70000) ${X_}COMPILER_FEATURES+= c++17 From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62F096318DE; Tue, 11 May 2021 10:31:08 +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 4FfZ2h0M5dz3k5M; Tue, 11 May 2021 10:31:08 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E9AC6167B1; Tue, 11 May 2021 10:31:07 +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 14BAV7uJ085410; Tue, 11 May 2021 10:31:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAV7I0085403; Tue, 11 May 2021 10:31:07 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:07 GMT Message-Id: <202105111031.14BAV7I0085403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 0e1e71400a0f - stable/13 - libc/string/bcopy.c: Use intptr_t as the copy type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0e1e71400a0fa3ac6fe5a90c4d830b06eef3e71e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:08 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0e1e71400a0fa3ac6fe5a90c4d830b06eef3e71e commit 0e1e71400a0fa3ac6fe5a90c4d830b06eef3e71e Author: Alex Richardson AuthorDate: 2021-04-19 23:15:57 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:26 +0000 libc/string/bcopy.c: Use intptr_t as the copy type While most 64-bit architectures have an assembly implementation of this file RISC-V does not. As we now copy 8 bytes instead of 4 it should speed up RISC-V. Using intptr_t instead of int also allows using this file for CHERI pure-capability code since trying to copy pointers using integer loads/stores will invalidate pointers. Reviewed By: kib Obtained from: CheriBSD (partially) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29535 (cherry picked from commit 0b4ad01d91a3b24cea00d54d25beed0f487c0183) --- lib/libc/string/bcopy.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c index 141416d0afec..84715d0432e3 100644 --- a/lib/libc/string/bcopy.c +++ b/lib/libc/string/bcopy.c @@ -40,11 +40,7 @@ __FBSDID("$FreeBSD$"); #include -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef int word; /* "word" used for optimal copy speed */ +typedef intptr_t word; /* "word" used for optimal copy speed */ #define wsize sizeof(word) #define wmask (wsize - 1) @@ -105,7 +101,8 @@ bcopy(const void *src0, void *dst0, size_t length) * Copy whole words, then mop up any trailing bytes. */ t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + TLOOP(*(word *)(void *)dst = *(const word *)(const void *)src; + src += wsize; dst += wsize); t = length & wmask; TLOOP(*dst++ = *src++); } else { @@ -126,7 +123,8 @@ bcopy(const void *src0, void *dst0, size_t length) TLOOP1(*--dst = *--src); } t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); + TLOOP(src -= wsize; dst -= wsize; + *(word *)(void *)dst = *(const word *)(const void *)src); t = length & wmask; TLOOP(*--dst = *--src); } From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38303631ABC; Tue, 11 May 2021 10:31:09 +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 4FfZ2j0gVLz3k5T; Tue, 11 May 2021 10:31:09 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 067A716901; Tue, 11 May 2021 10:31:09 +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 14BAV8lL085664; Tue, 11 May 2021 10:31:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAV8f0085663; Tue, 11 May 2021 10:31:08 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:08 GMT Message-Id: <202105111031.14BAV8f0085663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: fc19e3cb4fd1 - stable/13 - libc/string/memset.c: Use unsigned long for stores MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fc19e3cb4fd1403a6c6dba3c9879db031faa9df3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:09 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=fc19e3cb4fd1403a6c6dba3c9879db031faa9df3 commit fc19e3cb4fd1403a6c6dba3c9879db031faa9df3 Author: Alex Richardson AuthorDate: 2021-04-19 23:19:20 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:27 +0000 libc/string/memset.c: Use unsigned long for stores While most 64-bit architectures have an assembly implementation of this file, RISC-V does not. As we now store 8 bytes instead of 4 it should speed up RISC-V. Reviewed By: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29536 (cherry picked from commit ab147542b7c0bbc41f7f0499b16933bd8f3f31d7) --- lib/libc/string/memset.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c index 7d9909a76083..e2d4027eea0c 100644 --- a/lib/libc/string/memset.c +++ b/lib/libc/string/memset.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include -#define wsize sizeof(u_int) +#define wsize sizeof(u_long) #define wmask (wsize - 1) #ifdef BZERO @@ -67,7 +67,7 @@ memset(void *dst0, int c0, size_t length) { size_t t; #ifndef BZERO - u_int c; + u_long c; #endif u_char *dst; @@ -84,6 +84,9 @@ memset(void *dst0, int c0, size_t length) * * but we use a minimum of 3 here since the overhead of the code * to do word writes is substantial. + * + * TODO: This threshold might not be sensible for 64-bit u_long. + * We should benchmark and revisit this decision. */ if (length < 3 * wsize) { while (length != 0) { @@ -95,12 +98,12 @@ memset(void *dst0, int c0, size_t length) #ifndef BZERO if ((c = (u_char)c0) != 0) { /* Fill the word. */ - c = (c << 8) | c; /* u_int is 16 bits. */ -#if UINT_MAX > 0xffff - c = (c << 16) | c; /* u_int is 32 bits. */ + c = (c << 8) | c; /* u_long is 16 bits. */ +#if ULONG_MAX > 0xffff + c = (c << 16) | c; /* u_long is 32 bits. */ #endif -#if UINT_MAX > 0xffffffff - c = (c << 32) | c; /* u_int is 64 bits. */ +#if ULONG_MAX > 0xffffffff + c = (c << 32) | c; /* u_long is 64 bits. */ #endif } #endif @@ -116,7 +119,7 @@ memset(void *dst0, int c0, size_t length) /* Fill words. Length was >= 2*words so we know t >= 1 here. */ t = length / wsize; do { - *(u_int *)dst = WIDEVAL; + *(u_long *)(void *)dst = WIDEVAL; dst += wsize; } while (--t != 0); From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ABC32631C7A; Tue, 11 May 2021 10:31:10 +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 4FfZ2k2TLNz3jvh; Tue, 11 May 2021 10:31:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 226F8168F1; Tue, 11 May 2021 10:31:10 +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 14BAVAsV086826; Tue, 11 May 2021 10:31:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAVAEk086814; Tue, 11 May 2021 10:31:10 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:10 GMT Message-Id: <202105111031.14BAVAEk086814@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: f3e14553329b - stable/13 - linker_set: fix globl/weak symbol redefinitions to work on clang 12 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f3e14553329b33e7d61ece97fd2eda6963fd1fec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:10 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=f3e14553329b33e7d61ece97fd2eda6963fd1fec commit f3e14553329b33e7d61ece97fd2eda6963fd1fec Author: Greg V AuthorDate: 2021-04-20 00:47:15 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:28 +0000 linker_set: fix globl/weak symbol redefinitions to work on clang 12 In clang 12.0.0.rc2, going from weak to global is now a hard error: ``` /usr/src/stand/libsa/amd64/_setjmp.S:67:25: error: _longjmp changed binding to STB_GLOBAL .text; .p2align 4,0x90; .globl _longjmp; .type _longjmp,@function; _longjmp:; .cfi_startproc ``` And the other way is a warning, but we have -Werror: ``` error: __start_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm] error: __stop_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm] ``` ref: https://reviews.llvm.org/D90108 Reviewed By: arichardson MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29159 (cherry picked from commit 32231805fbe2b9438c2de50c229b43c016207a08) --- sys/sys/cdefs.h | 4 ++-- sys/sys/linker_set.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index d11bee96e10a..3acb165dad05 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -563,8 +563,8 @@ #endif /* __STDC__ */ #endif /* __GNUC__ */ -#define __GLOBL1(sym) __asm__(".globl " #sym) -#define __GLOBL(sym) __GLOBL1(sym) +#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym)) +#define __WEAK(sym) __asm__(".weak " __XSTRING(sym)) #if defined(__GNUC__) #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") diff --git a/sys/sys/linker_set.h b/sys/sys/linker_set.h index 6169a3499dad..f957858ada04 100644 --- a/sys/sys/linker_set.h +++ b/sys/sys/linker_set.h @@ -60,8 +60,8 @@ */ #ifdef __GNUCLIKE___SECTION #define __MAKE_SET_QV(set, sym, qv) \ - __GLOBL(__CONCAT(__start_set_,set)); \ - __GLOBL(__CONCAT(__stop_set_,set)); \ + __WEAK(__CONCAT(__start_set_,set)); \ + __WEAK(__CONCAT(__stop_set_,set)); \ static void const * qv \ __set_##set##_sym_##sym __section("set_" #set) \ __nosanitizeaddress \ From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF3DC631E81; Tue, 11 May 2021 10:31:12 +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 4FfZ2m3FjSz3jvr; Tue, 11 May 2021 10:31:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5DCB2165EA; Tue, 11 May 2021 10:31:12 +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 14BAVCZ3088683; Tue, 11 May 2021 10:31:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAVCx1088682; Tue, 11 May 2021 10:31:12 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:12 GMT Message-Id: <202105111031.14BAVCx1088682@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 7736adb5e64b - stable/13 - usr.bin/lex: regenerate bootstrap files after d37f81e35b MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7736adb5e64b460fb568b626551a8fd7c0f0c939 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:13 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=7736adb5e64b460fb568b626551a8fd7c0f0c939 commit 7736adb5e64b460fb568b626551a8fd7c0f0c939 Author: Alex Richardson AuthorDate: 2021-04-21 09:50:33 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:30 +0000 usr.bin/lex: regenerate bootstrap files after d37f81e35b Reviewed by: jkim (cherry picked from commit c6e66cbfbbd1c5dec215cf91a79689037255171c) --- usr.bin/lex/initscan.c | 16 +++++----------- usr.bin/lex/initskel.c | 8 +------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/usr.bin/lex/initscan.c b/usr.bin/lex/initscan.c index 9b6fb4ae5183..5c2701d060da 100644 --- a/usr.bin/lex/initscan.c +++ b/usr.bin/lex/initscan.c @@ -15,12 +15,6 @@ /* First, we deal with platform-specific or compiler-specific issues. */ -#if defined(__FreeBSD__) -#include -#else -#define __dead2 -#endif - /* begin standard C headers. */ #include #include @@ -348,7 +342,7 @@ extern char *yytext; static yy_state_type yy_get_previous_state ( void ); static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); static int yy_get_next_buffer ( void ); -static void yynoreturn yy_fatal_error ( const char* msg ) __dead2; +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -1971,9 +1965,9 @@ extern int yylval; if (!indented_code) line_directive_out(NULL, 0);\ } while (0) -#line 1974 "" +#line 1968 "" -#line 1976 "" +#line 1970 "" #define INITIAL 0 #define SECT2 1 @@ -2239,7 +2233,7 @@ YY_DECL char nmdef[MAXLINE]; -#line 2242 "" +#line 2236 "" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -4140,7 +4134,7 @@ YY_RULE_SETUP #line 1014 "scan.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 4143 "" +#line 4137 "" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(SECT2): case YY_STATE_EOF(CODEBLOCK): diff --git a/usr.bin/lex/initskel.c b/usr.bin/lex/initskel.c index 53a0ae452aa8..746ad6405c2a 100644 --- a/usr.bin/lex/initskel.c +++ b/usr.bin/lex/initskel.c @@ -446,12 +446,6 @@ const char *skel[] = { "", "/* First, we deal with platform-specific or compiler-specific issues. */", "", - "#if defined(__FreeBSD__)", - "#include ", - "#else", - "#define __dead2", - "#endif", - "", "/* begin standard C headers. */", "%if-c-only", "#include ", @@ -943,7 +937,7 @@ const char *skel[] = { "static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG );", "static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG);", "static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG );", - "static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ) __dead2;", + "static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG );", "]])", "", "%endif", From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5F05631BCB; Tue, 11 May 2021 10:31:13 +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 4FfZ2n4Fr4z3k7t; Tue, 11 May 2021 10:31:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7881B1637D; Tue, 11 May 2021 10:31:13 +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 14BAVDQ0088710; Tue, 11 May 2021 10:31:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAVDJ5088709; Tue, 11 May 2021 10:31:13 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:13 GMT Message-Id: <202105111031.14BAVDJ5088709@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 9f9c2745e8e7 - stable/13 - tools/build/bootstrap-m4: regenerate after d37f81e35b MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9f9c2745e8e7446c01b7e55679cb4fcb18634da1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:14 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=9f9c2745e8e7446c01b7e55679cb4fcb18634da1 commit 9f9c2745e8e7446c01b7e55679cb4fcb18634da1 Author: Alex Richardson AuthorDate: 2021-04-21 09:53:04 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:30 +0000 tools/build/bootstrap-m4: regenerate after d37f81e35b Reviewed by: jkim (cherry picked from commit f8e57f89f3f550501c54ce839213a08981ff9250) --- tools/build/bootstrap-m4/inittokenizer.c | 414 ++++++++++++++++--------------- 1 file changed, 219 insertions(+), 195 deletions(-) diff --git a/tools/build/bootstrap-m4/inittokenizer.c b/tools/build/bootstrap-m4/inittokenizer.c index 0c07f1ec2275..a014012ad756 100644 --- a/tools/build/bootstrap-m4/inittokenizer.c +++ b/tools/build/bootstrap-m4/inittokenizer.c @@ -1,4 +1,6 @@ +#line 1 "tokenizer.c" +#line 3 "tokenizer.c" #define YY_INT_ALIGNED short int @@ -6,24 +8,14 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ -#if defined(__FreeBSD__) -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#include -#include -#else -#define __dead2 -#endif - /* begin standard C headers. */ #include #include @@ -93,65 +85,61 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ +/* begin standard C++ headers. */ -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -168,15 +156,16 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t yyleng; +extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@ -191,7 +180,6 @@ extern FILE *yyin, *yyout; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -206,12 +194,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -234,7 +222,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -262,7 +250,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -274,7 +262,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) #define yy_current_buffer YY_CURRENT_BUFFER - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -282,11 +269,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -295,85 +282,81 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); #define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ -#define yywrap() 1 +#define yywrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; extern int yylineno; - int yylineno = 1; extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ) __dead2; +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - #define YY_NUM_RULES 14 #define YY_END_OF_BUFFER 15 /* This struct is not used in this scanner, @@ -383,7 +366,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[35] = +static const flex_int16_t yy_accept[35] = { 0, 0, 0, 15, 13, 1, 1, 13, 13, 13, 2, 2, 13, 13, 13, 13, 1, 9, 10, 12, 2, @@ -391,7 +374,7 @@ static yyconst flex_int16_t yy_accept[35] = 2, 0, 3, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -423,13 +406,13 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[19] = +static const YY_CHAR yy_meta[19] = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 3, 4, 4, 4, 1 } ; -static yyconst flex_int16_t yy_base[39] = +static const flex_int16_t yy_base[39] = { 0, 0, 0, 48, 49, 17, 19, 35, 41, 39, 16, 0, 14, 32, 15, 25, 27, 49, 49, 49, 27, @@ -437,7 +420,7 @@ static yyconst flex_int16_t yy_base[39] = 0, 0, 0, 49, 39, 29, 34, 36 } ; -static yyconst flex_int16_t yy_def[39] = +static const flex_int16_t yy_def[39] = { 0, 34, 1, 34, 34, 34, 34, 34, 34, 34, 34, 35, 34, 34, 34, 34, 34, 34, 34, 34, 34, @@ -445,7 +428,7 @@ static yyconst flex_int16_t yy_def[39] = 37, 38, 38, 0, 34, 34, 34, 34 } ; -static yyconst flex_int16_t yy_nxt[68] = +static const flex_int16_t yy_nxt[68] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 11, 4, 12, 13, 14, 4, 4, 4, 4, 15, 16, 16, @@ -456,7 +439,7 @@ static yyconst flex_int16_t yy_nxt[68] = 34, 34, 34, 34, 34, 34, 34 } ; -static yyconst flex_int16_t yy_chk[68] = +static const flex_int16_t yy_chk[68] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, @@ -481,7 +464,9 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; +#line 1 "tokenizer.l" #define YY_NO_INPUT 1 +#line 3 "tokenizer.l" /* $OpenBSD: tokenizer.l,v 1.9 2017/06/15 13:48:42 bcallah Exp $ */ /* * Copyright (c) 2004 Marc Espie @@ -516,6 +501,8 @@ int32_t parse_radix(void); extern int yylex(void); #define YY_DECL int yylex(void) +#line 504 "tokenizer.c" +#line 505 "tokenizer.c" #define INITIAL 0 @@ -531,36 +518,36 @@ extern int yylex(void); #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); +int yylex_destroy ( void ); -int yyget_debug (void ); +int yyget_debug ( void ); -void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *yyget_in (void ); +FILE *yyget_in ( void ); -void yyset_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *yyget_out (void ); +FILE *yyget_out ( void ); -void yyset_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t yyget_leng (void ); + int yyget_leng ( void ); -char *yyget_text (void ); +char *yyget_text ( void ); -int yyget_lineno (void ); +int yyget_lineno ( void ); -void yyset_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -568,33 +555,41 @@ void yyset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); +#endif #endif + +#ifndef YY_NO_UNPUT + #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -602,7 +597,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -613,7 +608,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -626,7 +621,7 @@ static int input (void ); else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -681,7 +676,7 @@ extern int yylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ @@ -695,8 +690,6 @@ YY_DECL char *yy_cp, *yy_bp; int yy_act; - - if ( !(yy_init) ) { (yy_init) = 1; @@ -717,13 +710,18 @@ YY_DECL if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_load_buffer_state( ); + yy_load_buffer_state( ); } - while ( 1 ) /* loops until end-of-file is reached */ + { +#line 48 "tokenizer.l" + +#line 722 "tokenizer.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -749,9 +747,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 35 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 49 ); @@ -781,14 +779,17 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP +#line 49 "tokenizer.l" {/* just skip it */} YY_BREAK case 2: YY_RULE_SETUP +#line 50 "tokenizer.l" { yylval = number(); return(NUMBER); } YY_BREAK case 3: YY_RULE_SETUP +#line 51 "tokenizer.l" { if (mimic_gnu) { yylval = parse_radix(); return(NUMBER); } else { @@ -798,48 +799,60 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP +#line 57 "tokenizer.l" { return(LE); } YY_BREAK case 5: YY_RULE_SETUP +#line 58 "tokenizer.l" { return(GE); } YY_BREAK case 6: YY_RULE_SETUP +#line 59 "tokenizer.l" { return(LSHIFT); } YY_BREAK case 7: YY_RULE_SETUP +#line 60 "tokenizer.l" { return(RSHIFT); } YY_BREAK case 8: YY_RULE_SETUP +#line 61 "tokenizer.l" { return(EQ); } YY_BREAK case 9: YY_RULE_SETUP +#line 62 "tokenizer.l" { return(NE); } YY_BREAK case 10: YY_RULE_SETUP +#line 63 "tokenizer.l" { return(LAND); } YY_BREAK case 11: YY_RULE_SETUP +#line 64 "tokenizer.l" { return(LOR); } YY_BREAK case 12: YY_RULE_SETUP +#line 65 "tokenizer.l" { if (mimic_gnu) { return (EXPONENT); } } YY_BREAK case 13: YY_RULE_SETUP +#line 66 "tokenizer.l" { return yytext[0]; } YY_BREAK case 14: YY_RULE_SETUP +#line 67 "tokenizer.l" ECHO; YY_BREAK +#line 855 "tokenizer.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -917,7 +930,7 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -970,6 +983,7 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer @@ -1012,7 +1026,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1025,7 +1039,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1039,7 +1053,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1048,11 +1062,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1080,7 +1095,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); + yyrestart( yyin ); } else @@ -1094,12 +1109,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1132,9 +1150,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 35 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1160,14 +1178,18 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 35 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 34); return yy_is_jam ? 0 : yy_current_state; } +#ifndef YY_NO_UNPUT + +#endif + #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1192,7 +1214,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1209,14 +1231,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - yyrestart(yyin ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1253,11 +1275,11 @@ static int yy_get_next_buffer (void) if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. @@ -1285,7 +1307,7 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1313,7 +1335,7 @@ static void yy_load_buffer_state (void) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1322,13 +1344,13 @@ static void yy_load_buffer_state (void) /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } @@ -1347,9 +1369,9 @@ static void yy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - yyfree((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. @@ -1361,7 +1383,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - yy_flush_buffer(b ); + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1404,7 +1426,7 @@ static void yy_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -1435,7 +1457,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -1454,7 +1476,7 @@ void yypop_buffer_state (void) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1472,15 +1494,15 @@ static void yyensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1489,7 +1511,7 @@ static void yyensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc @@ -1509,7 +1531,7 @@ static void yyensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { @@ -1519,23 +1541,23 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; *** 216 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A427D631AC0; Tue, 11 May 2021 10:31:11 +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 4FfZ2l3Hq8z3k0g; Tue, 11 May 2021 10:31:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3B20B166EB; Tue, 11 May 2021 10:31:11 +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 14BAVBxx088049; Tue, 11 May 2021 10:31:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAVBs1088041; Tue, 11 May 2021 10:31:11 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:11 GMT Message-Id: <202105111031.14BAVBs1088041@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 25fb1c01f86e - stable/13 - contrib/flex: Drop local __dead2 patch MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 25fb1c01f86e68b9712506bb67d46b8ab53c4964 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:11 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=25fb1c01f86e68b9712506bb67d46b8ab53c4964 commit 25fb1c01f86e68b9712506bb67d46b8ab53c4964 Author: Alex Richardson AuthorDate: 2021-04-21 09:48:55 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 08:39:29 +0000 contrib/flex: Drop local __dead2 patch Upstream flex has added a yynoreturn macro, so this diff is no longer needed. Partially reverts r181269. Reviewed By: jkim Differential Revision: https://reviews.freebsd.org/D29679 (cherry picked from commit d37f81e35b6e8f114b04315e06bab2cf0c03946c) --- contrib/flex/src/flex.skl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/contrib/flex/src/flex.skl b/contrib/flex/src/flex.skl index c23b944ea473..304e664e4c62 100644 --- a/contrib/flex/src/flex.skl +++ b/contrib/flex/src/flex.skl @@ -216,12 +216,6 @@ m4_ifdef( [[M4_YY_TABLES_EXTERNAL]], /* First, we deal with platform-specific or compiler-specific issues. */ -#if defined(__FreeBSD__) -#include -#else -#define __dead2 -#endif - /* begin standard C headers. */ %if-c-only #include @@ -653,7 +647,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]], static yy_state_type yy_get_previous_state ( M4_YY_PROTO_ONLY_ARG ); static yy_state_type yy_try_NUL_trans ( yy_state_type current_state M4_YY_PROTO_LAST_ARG); static int yy_get_next_buffer ( M4_YY_PROTO_ONLY_ARG ); -static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ) __dead2; +static void yynoreturn yy_fatal_error ( const char* msg M4_YY_PROTO_LAST_ARG ); ]]) %endif From owner-dev-commits-src-all@freebsd.org Tue May 11 10:31:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B554631E87; Tue, 11 May 2021 10:31:15 +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 4FfZ2p5t1Fz3kDB; Tue, 11 May 2021 10:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AD8E4166EC; Tue, 11 May 2021 10:31:14 +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 14BAVEoR088735; Tue, 11 May 2021 10:31:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAVE3B088734; Tue, 11 May 2021 10:31:14 GMT (envelope-from git) Date: Tue, 11 May 2021 10:31:14 GMT Message-Id: <202105111031.14BAVE3B088734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: 0d0eb707b43e - stable/13 - truss: Add missing underscore to compat_prefix for FreeBSD32 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0d0eb707b43e2b222434a98265db1fe7c3e3f3a8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:31:15 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0d0eb707b43e2b222434a98265db1fe7c3e3f3a8 commit 0d0eb707b43e2b222434a98265db1fe7c3e3f3a8 Author: Alex Richardson AuthorDate: 2021-05-11 09:52:56 +0000 Commit: Alex Richardson CommitDate: 2021-05-11 09:54:06 +0000 truss: Add missing underscore to compat_prefix for FreeBSD32 I accidentally dropped this in the final version of D27625, so it didn't actually work as intended. I found this while testing the MFC to stable/13. MFC after: immediately Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments") (cherry picked from commit 3cbad8287aa0ed72e07df1130ce2ae490642e63a) --- usr.bin/truss/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 31c20d656b6a..78be0c7f570f 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -106,7 +106,7 @@ static struct procabi freebsd32 = { .type = "FreeBSD32", .abi = SYSDECODE_ABI_FREEBSD32, .pointer_size = sizeof(uint32_t), - .compat_prefix = "freebsd32", + .compat_prefix = "freebsd32_", .extra_syscalls = STAILQ_HEAD_INITIALIZER(freebsd32.extra_syscalls), .syscalls = { NULL } }; From owner-dev-commits-src-all@freebsd.org Tue May 11 10:37:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 229896323C9; Tue, 11 May 2021 10:37:32 +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 4FfZB40VGsz3kVZ; Tue, 11 May 2021 10:37:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 040E5167D3; Tue, 11 May 2021 10:37:32 +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 14BAbVeq090519; Tue, 11 May 2021 10:37:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAbVuU090518; Tue, 11 May 2021 10:37:31 GMT (envelope-from git) Date: Tue, 11 May 2021 10:37:31 GMT Message-Id: <202105111037.14BAbVuU090518@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 65634ae748e7 - main - mroute: fix race condition during mrouter shutting down MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 65634ae748e7f6b7b9f11e8838c65060c3f31347 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:37:32 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=65634ae748e7f6b7b9f11e8838c65060c3f31347 commit 65634ae748e7f6b7b9f11e8838c65060c3f31347 Author: Wojciech Macek AuthorDate: 2021-04-23 03:57:03 +0000 Commit: Wojciech Macek CommitDate: 2021-05-11 10:34:20 +0000 mroute: fix race condition during mrouter shutting down There is a race condition between V_ip_mrouter de-init and ip_mforward handling. It might happen that mrouted is cleaned up after V_ip_mrouter check and before processing packet in ip_mforward. Use epoch call aproach, similar to IPSec which also handles such case. Reported by: Damien Deville Obtained from: Stormshield Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D29946 --- sys/netinet/ip_input.c | 9 ++++++++- sys/netinet/ip_mroute.c | 2 ++ sys/netinet/ip_mroute.h | 5 +++++ sys/netinet/ip_output.c | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index a85f8ac7b567..43d375c2385f 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -451,6 +452,7 @@ ip_direct_input(struct mbuf *m) void ip_input(struct mbuf *m) { + MROUTER_RLOCK_TRACKER; struct rm_priotracker in_ifa_tracker; struct ip *ip = NULL; struct in_ifaddr *ia = NULL; @@ -743,6 +745,7 @@ passin: return; } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { + MROUTER_RLOCK(); if (V_ip_mrouter) { /* * If we are acting as a multicast router, all @@ -753,6 +756,7 @@ passin: * must be discarded, else it may be accepted below. */ if (ip_mforward && ip_mforward(ip, ifp, m, 0) != 0) { + MROUTER_RUNLOCK(); IPSTAT_INC(ips_cantforward); m_freem(m); return; @@ -763,10 +767,13 @@ passin: * all multicast IGMP packets, whether or not this * host belongs to their destination groups. */ - if (ip->ip_p == IPPROTO_IGMP) + if (ip->ip_p == IPPROTO_IGMP) { + MROUTER_RUNLOCK(); goto ours; + } IPSTAT_INC(ips_forward); } + MROUTER_RUNLOCK(); /* * Assume the packet is for us, to avoid prematurely taking * a lock on the in_multi hash. Protocols must perform diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index b66fe8df0793..8ecc983ea58f 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -720,6 +720,8 @@ X_ip_mrouter_done(void) ip_mrouter_cnt--; V_mrt_api_config = 0; + MROUTER_WAIT(); + VIF_LOCK(); /* diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h index 054eb921d3df..6ef99c0172f3 100644 --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -355,6 +355,11 @@ extern int (*ip_mrouter_get)(struct socket *, struct sockopt *); extern int (*ip_mrouter_done)(void); extern int (*mrt_ioctl)(u_long, caddr_t, int); +#define MROUTER_RLOCK_TRACKER struct epoch_tracker mrouter_et +#define MROUTER_RLOCK() epoch_enter_preempt(net_epoch_preempt, &mrouter_et) +#define MROUTER_RUNLOCK() epoch_exit_preempt(net_epoch_preempt, &mrouter_et) +#define MROUTER_WAIT() epoch_wait_preempt(net_epoch_preempt) + #endif /* _KERNEL */ #endif /* _NETINET_IP_MROUTE_H_ */ diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 405490e890c0..f913a2591fcc 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -319,6 +320,7 @@ int ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, struct ip_moptions *imo, struct inpcb *inp) { + MROUTER_RLOCK_TRACKER; struct rm_priotracker in_ifa_tracker; struct ip *ip; struct ifnet *ifp = NULL; /* keep compiler happy */ @@ -613,6 +615,7 @@ again: * above, will be forwarded by the ip_input() routine, * if necessary. */ + MROUTER_RLOCK(); if (V_ip_mrouter && (flags & IP_FORWARDING) == 0) { /* * If rsvp daemon is not running, do not @@ -624,10 +627,12 @@ again: imo = NULL; if (ip_mforward && ip_mforward(ip, ifp, m, imo) != 0) { + MROUTER_RUNLOCK(); m_freem(m); goto done; } } + MROUTER_RUNLOCK(); } /* From owner-dev-commits-src-all@freebsd.org Tue May 11 10:37:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B69E6324A2; Tue, 11 May 2021 10:37:33 +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 4FfZB51RMnz3kXw; Tue, 11 May 2021 10:37:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2182016A10; Tue, 11 May 2021 10:37:33 +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 14BAbXrA090542; Tue, 11 May 2021 10:37:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BAbXtl090541; Tue, 11 May 2021 10:37:33 GMT (envelope-from git) Date: Tue, 11 May 2021 10:37:33 GMT Message-Id: <202105111037.14BAbXtl090541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 0b103f72376b - main - mrouter: do not loopback packets unconditionally MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b103f72376b5ec7c9a9d574c976e42805ae88a4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 10:37:33 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=0b103f72376b5ec7c9a9d574c976e42805ae88a4 commit 0b103f72376b5ec7c9a9d574c976e42805ae88a4 Author: Wojciech Macek AuthorDate: 2021-04-23 06:49:27 +0000 Commit: Wojciech Macek CommitDate: 2021-05-11 10:36:07 +0000 mrouter: do not loopback packets unconditionally Looping back router multicast traffic signifficantly stresses network stack. Add possibility to disable or enable loopbacked based on sysctl value. Reported by: Daniel Deville Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D29947 --- sys/netinet/ip_mroute.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 8ecc983ea58f..b8e677ba9af1 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -244,6 +244,8 @@ static const struct encaptab *pim_encap_cookie; static int pim_encapcheck(const struct mbuf *, int, int, void *); static int pim_input(struct mbuf *, int, int, void *); +extern int in_mcast_loop; + static const struct encap_config ipv4_encap_cfg = { .proto = IPPROTO_PIM, .min_length = sizeof(struct ip) + PIM_MINLEN, @@ -1685,7 +1687,7 @@ send_packet(struct vif *vifp, struct mbuf *m) imo.imo_multicast_ifp = vifp->v_ifp; imo.imo_multicast_ttl = mtod(m, struct ip *)->ip_ttl - 1; - imo.imo_multicast_loop = 1; + imo.imo_multicast_loop = !!in_mcast_loop; imo.imo_multicast_vif = -1; STAILQ_INIT(&imo.imo_head); From owner-dev-commits-src-all@freebsd.org Tue May 11 12:18:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A499B635C62; Tue, 11 May 2021 12:18:25 +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 4FfcQT4Hjrz3q2b; Tue, 11 May 2021 12:18:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8621417E27; Tue, 11 May 2021 12:18:25 +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 14BCIPJg022990; Tue, 11 May 2021 12:18:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BCIP72022989; Tue, 11 May 2021 12:18:25 GMT (envelope-from git) Date: Tue, 11 May 2021 12:18:25 GMT Message-Id: <202105111218.14BCIP72022989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 4b86a24a76a4 - main - tcp: In rack, we must only convert restored rtt when the hostcache does restore them. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b86a24a76a4d58c1d870fcb2252b321f61cb3cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 12:18:25 -0000 The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=4b86a24a76a4d58c1d870fcb2252b321f61cb3cc commit 4b86a24a76a4d58c1d870fcb2252b321f61cb3cc Author: Randall Stewart AuthorDate: 2021-05-11 12:15:05 +0000 Commit: Randall Stewart CommitDate: 2021-05-11 12:15:05 +0000 tcp: In rack, we must only convert restored rtt when the hostcache does restore them. Rack now after the previous commit is very careful to translate any value in the hostcache for srtt/rttvar into its proper format. However there is a snafu here in that if tp->srtt is 0 is the only time that the HC will actually restore the srtt. We need to then only convert the srtt restored when it is actually restored. We do this by making sure it was zero before the call to cc_conn_init and it is non-zero afterwards. Reviewed by: Michael Tuexen Sponsored by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30213 --- sys/netinet/tcp_stacks/rack.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 865e54c90e6a..e6b2ef60cef7 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -6614,14 +6614,17 @@ static void rack_cc_conn_init(struct tcpcb *tp) { struct tcp_rack *rack; + uint32_t srtt; rack = (struct tcp_rack *)tp->t_fb_ptr; - + srtt = tp->t_srtt; cc_conn_init(tp); /* - * Now convert to rack's internal format. + * Now convert to rack's internal format, + * if required. */ - rack_convert_rtts(tp); + if ((srtt == 0) && (tp->t_srtt != 0)) + rack_convert_rtts(tp); /* * We want a chance to stay in slowstart as * we create a connection. TCP spec says that From owner-dev-commits-src-all@freebsd.org Tue May 11 14:15:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 289F563957F; Tue, 11 May 2021 14:15:42 +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 4Ffg1p0f3Xz3wTs; Tue, 11 May 2021 14:15:42 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 04A94196CF; Tue, 11 May 2021 14:15:42 +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 14BEFf5J083214; Tue, 11 May 2021 14:15:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BEFfNJ083213; Tue, 11 May 2021 14:15:41 GMT (envelope-from git) Date: Tue, 11 May 2021 14:15:41 GMT Message-Id: <202105111415.14BEFfNJ083213@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: git: 4772e86beb08 - main - xen/blkback: fix reconnection of backend MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4772e86beb089ee08a3bff8ad359e83a4c623238 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 14:15:42 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=4772e86beb089ee08a3bff8ad359e83a4c623238 commit 4772e86beb089ee08a3bff8ad359e83a4c623238 Author: Roger Pau Monné AuthorDate: 2021-05-11 10:19:29 +0000 Commit: Roger Pau Monné CommitDate: 2021-05-11 13:43:42 +0000 xen/blkback: fix reconnection of backend The hotplug script will be executed only once for each backend, regardless of the frontend triggering reconnections. Fix blkback to deal with the hotplug script being executed only once, so that reconnections don't stall waiting for a hotplug script execution that will never happen. As a result of the fix move the initialization of dev_mode, dev_type and dev_name to the watch callback, as they should be set only once the first time the backend connects. This fix is specially relevant for guests wanting to use UEFI OVMF firmware, because OVMF will use Xen PV block devices and disconnect afterwards, thus allowing them to be used by the guest OS. Without this change the guest OS will stall waiting for the block backed to attach. Fixes: de0bad00010c ('blkback: add support for hotplug scripts') MFC after: 1 week Sponsored by: Citrix Systems R&D --- sys/dev/xen/blkback/blkback.c | 83 +++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 678472cc2ab8..010e737740b8 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -3412,7 +3412,6 @@ xbb_shutdown(struct xbb_softc *xbb) free(xbb->hotplug_watch.node, M_XENBLOCKBACK); xbb->hotplug_watch.node = NULL; } - xbb->hotplug_done = false; if (xenbus_get_state(xbb->dev) < XenbusStateClosing) xenbus_set_state(xbb->dev, XenbusStateClosing); @@ -3597,39 +3596,14 @@ xbb_setup_sysctl(struct xbb_softc *xbb) } static void -xbb_attach_disk(struct xs_watch *watch, const char **vec, unsigned int len) +xbb_attach_disk(device_t dev) { - device_t dev; struct xbb_softc *xbb; int error; - dev = (device_t) watch->callback_data; xbb = device_get_softc(dev); - error = xs_gather(XST_NIL, xenbus_get_node(dev), "physical-device-path", - NULL, &xbb->dev_name, NULL); - if (error != 0) - return; - - xs_unregister_watch(watch); - free(watch->node, M_XENBLOCKBACK); - watch->node = NULL; - - /* Collect physical device information. */ - error = xs_gather(XST_NIL, xenbus_get_otherend_path(xbb->dev), - "device-type", NULL, &xbb->dev_type, - NULL); - if (error != 0) - xbb->dev_type = NULL; - - error = xs_gather(XST_NIL, xenbus_get_node(dev), - "mode", NULL, &xbb->dev_mode, - NULL); - if (error != 0) { - xbb_attach_failed(xbb, error, "reading backend fields at %s", - xenbus_get_node(dev)); - return; - } + KASSERT(xbb->hotplug_done, ("Missing hotplug execution")); /* Parse fopen style mode flags. */ if (strchr(xbb->dev_mode, 'w') == NULL) @@ -3693,13 +3667,48 @@ xbb_attach_disk(struct xs_watch *watch, const char **vec, unsigned int len) return; } - xbb->hotplug_done = true; - /* The front end might be waiting for the backend, attach if so. */ if (xenbus_get_otherend_state(xbb->dev) == XenbusStateInitialised) xbb_connect(xbb); } +static void +xbb_attach_cb(struct xs_watch *watch, const char **vec, unsigned int len) +{ + device_t dev; + struct xbb_softc *xbb; + int error; + + dev = (device_t)watch->callback_data; + xbb = device_get_softc(dev); + + error = xs_gather(XST_NIL, xenbus_get_node(dev), "physical-device-path", + NULL, &xbb->dev_name, NULL); + if (error != 0) + return; + + xs_unregister_watch(watch); + free(watch->node, M_XENBLOCKBACK); + watch->node = NULL; + xbb->hotplug_done = true; + + /* Collect physical device information. */ + error = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), "device-type", + NULL, &xbb->dev_type, NULL); + if (error != 0) + xbb->dev_type = NULL; + + error = xs_gather(XST_NIL, xenbus_get_node(dev), "mode", NULL, + &xbb->dev_mode, NULL); + if (error != 0) { + xbb_attach_failed(xbb, error, "reading backend fields at %s", + xenbus_get_node(dev)); + return; + } + + xbb_attach_disk(dev); +} + /** * Attach to a XenBus device that has been claimed by our probe routine. * @@ -3757,14 +3766,21 @@ xbb_attach(device_t dev) return (error); } + /* Tell the toolstack blkback has attached. */ + xenbus_set_state(dev, XenbusStateInitWait); + + if (xbb->hotplug_done) { + xbb_attach_disk(dev); + return (0); + } + /* * We need to wait for hotplug script execution before * moving forward. */ - KASSERT(!xbb->hotplug_done, ("Hotplug scripts already executed")); watch_path = xs_join(xenbus_get_node(xbb->dev), "physical-device-path"); xbb->hotplug_watch.callback_data = (uintptr_t)dev; - xbb->hotplug_watch.callback = xbb_attach_disk; + xbb->hotplug_watch.callback = xbb_attach_cb; KASSERT(xbb->hotplug_watch.node == NULL, ("watch node already setup")); xbb->hotplug_watch.node = strdup(sbuf_data(watch_path), M_XENBLOCKBACK); /* @@ -3782,9 +3798,6 @@ xbb_attach(device_t dev) return (error); } - /* Tell the toolstack blkback has attached. */ - xenbus_set_state(dev, XenbusStateInitWait); - return (0); } From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AD4A63A9F0; Tue, 11 May 2021 15:06:44 +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 4Ffh8h3392z4T0y; Tue, 11 May 2021 15:06:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5BB361A504; Tue, 11 May 2021 15:06:44 +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 14BF6iUm049405; Tue, 11 May 2021 15:06:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6ifU049404; Tue, 11 May 2021 15:06:44 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:44 GMT Message-Id: <202105111506.14BF6ifU049404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: b0b9525172ba - stable/12 - pf: Implement the NAT source port selection of MAP-E Customer Edge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b0b9525172ba9f8704f810d974f56d4ee3aad51f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:44 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b0b9525172ba9f8704f810d974f56d4ee3aad51f commit b0b9525172ba9f8704f810d974f56d4ee3aad51f Author: Kurosawa Takahiro AuthorDate: 2021-04-13 08:50:00 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 08:27:57 +0000 pf: Implement the NAT source port selection of MAP-E Customer Edge MAP-E (RFC 7597) requires special care for selecting source ports in NAT operation on the Customer Edge because a part of bits of the port numbers are used by the Border Relay to distinguish another side of the IPv4-over-IPv6 tunnel. PR: 254577 Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D29468 (cherry picked from commit 2aa21096c7349390f22aa5d06b373a575baed1b4) --- lib/libpfctl/libpfctl.c | 24 ++++++++++++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 57 ++++++++++++++++++++++++++- sbin/pfctl/pfctl_parser.c | 3 ++ share/man/man5/pf.conf.5 | 24 +++++++++++- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf.h | 6 +++ sys/netpfil/pf/pf_ioctl.c | 40 +++++++++++++++++++ sys/netpfil/pf/pf_lb.c | 65 +++++++++++++++++++++++++++---- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/map_e.sh | 91 +++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 303 insertions(+), 10 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 6b191514320e..c2147e1b04c1 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -201,6 +201,18 @@ pf_nvrule_addr_to_rule_addr(const nvlist_t *nvl, struct pf_rule_addr *addr) addr->port_op = nvlist_get_number(nvl, "port_op"); } +static void +pfctl_nv_add_mape(nvlist_t *nvparent, const char *name, + const struct pf_mape_portset *mape) +{ + nvlist_t *nvl = nvlist_create(0); + + nvlist_add_number(nvl, "offset", mape->offset); + nvlist_add_number(nvl, "psidlen", mape->psidlen); + nvlist_add_number(nvl, "psid", mape->psid); + nvlist_add_nvlist(nvparent, name, nvl); +} + static void pfctl_nv_add_pool(nvlist_t *nvparent, const char *name, const struct pfctl_pool *pool) @@ -216,10 +228,19 @@ pfctl_nv_add_pool(nvlist_t *nvparent, const char *name, ports[1] = pool->proxy_port[1]; nvlist_add_number_array(nvl, "proxy_port", ports, 2); nvlist_add_number(nvl, "opts", pool->opts); + pfctl_nv_add_mape(nvl, "mape", &pool->mape); nvlist_add_nvlist(nvparent, name, nvl); } +static void +pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape) +{ + mape->offset = nvlist_get_number(nvl, "offset"); + mape->psidlen = nvlist_get_number(nvl, "psidlen"); + mape->psid = nvlist_get_number(nvl, "psid"); +} + static void pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool) { @@ -235,6 +256,9 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool) pool->tblidx = nvlist_get_number(nvl, "tblidx"); pf_nvuint_16_array(nvl, "proxy_port", 2, pool->proxy_port, NULL); pool->opts = nvlist_get_number(nvl, "opts"); + + if (nvlist_exists_nvlist(nvl, "mape")) + pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"), &pool->mape); } static void diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 921b072a7753..0f4f5c908738 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -43,6 +43,7 @@ struct pfctl_pool { struct pf_pooladdr *cur; struct pf_poolhashkey key; struct pf_addr counter; + struct pf_mape_portset mape; int tblidx; u_int16_t proxy_port[2]; u_int8_t opts; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index ddc37984e114..0d0f6fea76be 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -309,6 +309,7 @@ static struct pool_opts { int type; int staticport; struct pf_poolhashkey *key; + struct pf_mape_portset mape; } pool_opts; @@ -464,7 +465,7 @@ int parseport(char *, struct range *r, int); %token SET OPTIMIZATION TIMEOUT LIMIT LOGINTERFACE BLOCKPOLICY FAILPOLICY %token RANDOMID REQUIREORDER SYNPROXY FINGERPRINTS NOSYNC DEBUG SKIP HOSTID %token ANTISPOOF FOR INCLUDE -%token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY +%token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY MAPEPORTSET %token ALTQ CBQ CODEL PRIQ HFSC FAIRQ BANDWIDTH TBRSIZE LINKSHARE REALTIME %token UPPERLIMIT QUEUE PRIORITY QLIMIT HOGS BUCKETS RTABLE TARGET INTERVAL %token LOAD RULESET_OPTIMIZATION PRIO @@ -4013,6 +4014,36 @@ pool_opt : BITMASK { pool_opts.marker |= POM_STICKYADDRESS; pool_opts.opts |= PF_POOL_STICKYADDR; } + | MAPEPORTSET number '/' number '/' number { + if (pool_opts.mape.offset) { + yyerror("map-e-portset cannot be redefined"); + YYERROR; + } + if (pool_opts.type) { + yyerror("map-e-portset cannot be used with " + "address pools"); + YYERROR; + } + if ($2 <= 0 || $2 >= 16) { + yyerror("MAP-E PSID offset must be 1-15"); + YYERROR; + } + if ($4 < 0 || $4 >= 16 || $2 + $4 > 16) { + yyerror("Invalid MAP-E PSID length"); + YYERROR; + } else if ($4 == 0) { + yyerror("PSID Length = 0: this means" + " you do not need MAP-E"); + YYERROR; + } + if ($6 < 0 || $6 > 65535) { + yyerror("Invalid MAP-E PSID"); + YYERROR; + } + pool_opts.mape.offset = $2; + pool_opts.mape.psidlen = $4; + pool_opts.mape.psid = $6; + } ; redirection : /* empty */ { $$ = NULL; } @@ -4218,6 +4249,29 @@ natrule : nataction interface af proto fromto tag tagged rtable r.rpool.proxy_port[1] = 0; } + if ($10.mape.offset) { + if (r.action != PF_NAT) { + yyerror("the 'map-e-portset' option is" + " only valid with nat rules"); + YYERROR; + } + if ($10.staticport) { + yyerror("the 'map-e-portset' option" + " can't be used 'static-port'"); + YYERROR; + } + if (r.rpool.proxy_port[0] != + PF_NAT_PROXY_PORT_LOW && + r.rpool.proxy_port[1] != + PF_NAT_PROXY_PORT_HIGH) { + yyerror("the 'map-e-portset' option" + " can't be used when specifying" + " a port range"); + YYERROR; + } + r.rpool.mape = $10.mape; + } + expand_rule(&r, $2, $9 == NULL ? NULL : $9->host, $4, $5.src_os, $5.src.host, $5.src.port, $5.dst.host, $5.dst.port, 0, 0, 0, ""); @@ -5543,6 +5597,7 @@ lookup(char *s) { "load", LOAD}, { "log", LOG}, { "loginterface", LOGINTERFACE}, + { "map-e-portset", MAPEPORTSET}, { "max", MAXIMUM}, { "max-mss", MAXMSS}, { "max-src-conn", MAXSRCCONN}, diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 81da3c9ad9ba..ee0f9f8318a9 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -486,6 +486,9 @@ print_pool(struct pfctl_pool *pool, u_int16_t p1, u_int16_t p2, printf(" sticky-address"); if (id == PF_NAT && p1 == 0 && p2 == 0) printf(" static-port"); + if (pool->mape.offset > 0) + printf(" map-e-portset %u/%u/%u", + pool->mape.offset, pool->mape.psidlen, pool->mape.psid); } const char * const pf_reasons[PFRES_MAX+1] = PFRES_NAMES; diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5 index d8c18252ea91..86870319df2a 100644 --- a/share/man/man5/pf.conf.5 +++ b/share/man/man5/pf.conf.5 @@ -1999,6 +1999,27 @@ rules, the option prevents .Xr pf 4 from modifying the source port on TCP and UDP packets. +.It Xo Ar map-e-portset Aq Ar psid-offset +.No / Aq Ar psid-len +.No / Aq Ar psid +.Xc +With +.Ar nat +rules, the +.Ar map-e-portset +option enables the source port translation of MAP-E (RFC 7597) Customer Edge. +In order to make the host act as a MAP-E Customer Edge, setting up a tunneling +interface and pass rules for encapsulated packets are required in addition +to the map-e-portset nat rule. +.Pp +For example: +.Bd -literal -offset indent +nat on $gif_mape_if from $int_if:network to any \e + -> $ipv4_mape_src map-e-portset 6/8/0x34 +.Ed +.Pp +sets PSID offset 6, PSID length 8, PSID 0x34. +.Ed .El .Pp Additionally, the @@ -2894,7 +2915,8 @@ nat-rule = [ "no" ] "nat" [ "pass" [ "log" [ "(" logopts ")" ] ] ] [ "on" ifspec ] [ af ] [ protospec ] hosts [ "tag" string ] [ "tagged" string ] [ "-\*(Gt" ( redirhost | "{" redirhost-list "}" ) - [ portspec ] [ pooltype ] [ "static-port" ] ] + [ portspec ] [ pooltype ] [ "static-port" ] + [ "map-e-portset" number "/" number "/" number ] ] binat-rule = [ "no" ] "binat" [ "pass" [ "log" [ "(" logopts ")" ] ] ] [ "on" interface-name ] [ af ] diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index dc2c6f014923..6101f5f0ff54 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -309,6 +309,7 @@ struct pf_kpool { struct pf_kpooladdr *cur; struct pf_poolhashkey key; struct pf_addr counter; + struct pf_mape_portset mape; int tblidx; u_int16_t proxy_port[2]; u_int8_t opts; diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index 45a3efe91efb..011d69a746dd 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -317,6 +317,12 @@ struct pf_poolhashkey { #define key32 pfk.key32 }; +struct pf_mape_portset { + u_int8_t offset; + u_int8_t psidlen; + u_int16_t psid; +}; + struct pf_pool { struct pf_palist list; struct pf_pooladdr *cur; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 7d2f67ad13e9..dd57d4ac5c0f 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1646,6 +1646,36 @@ pf_addr_to_nvaddr(const struct pf_addr *paddr) return (nvl); } +static int +pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape) +{ + int error = 0; + + bzero(mape, sizeof(*mape)); + PFNV_CHK(pf_nvuint8(nvl, "offset", &mape->offset)); + PFNV_CHK(pf_nvuint8(nvl, "psidlen", &mape->psidlen)); + PFNV_CHK(pf_nvuint16(nvl, "psid", &mape->psid)); + +errout: + return (error); +} + +static nvlist_t * +pf_mape_to_nvmape(const struct pf_mape_portset *mape) +{ + nvlist_t *nvl; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + nvlist_add_number(nvl, "offset", mape->offset); + nvlist_add_number(nvl, "psidlen", mape->psidlen); + nvlist_add_number(nvl, "psid", mape->psid); + + return (nvl); +} + static int pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool) { @@ -1665,6 +1695,11 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool) NULL)); PFNV_CHK(pf_nvuint8(nvl, "opts", &kpool->opts)); + if (nvlist_exists_nvlist(nvl, "mape")) { + PFNV_CHK(pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"), + &kpool->mape)); + } + errout: return (error); } @@ -1689,6 +1724,11 @@ pf_pool_to_nvpool(const struct pf_kpool *pool) pf_uint16_array_nv(nvl, "proxy_port", pool->proxy_port, 2); nvlist_add_number(nvl, "opts", pool->opts); + tmp = pf_mape_to_nvmape(&pool->mape); + if (tmp == NULL) + goto error; + nvlist_add_nvlist(nvl, "mape", tmp); + return (nvl); error: diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index 1eb57fd34213..d8f8ae00fb8a 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -224,11 +224,6 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, if (pf_map_addr(af, r, saddr, naddr, &init_addr, sn)) return (1); - if (proto == IPPROTO_ICMP) { - low = 1; - high = 65535; - } - bzero(&key, sizeof(key)); key.af = af; key.proto = proto; @@ -306,6 +301,42 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, return (1); /* none available */ } +static int +pf_get_mape_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, + struct pf_addr *saddr, uint16_t sport, struct pf_addr *daddr, + uint16_t dport, struct pf_addr *naddr, uint16_t *nport, + struct pf_ksrc_node **sn) +{ + uint16_t psmask, low, highmask; + uint16_t i, ahigh, cut; + int ashift, psidshift; + + ashift = 16 - r->rpool.mape.offset; + psidshift = ashift - r->rpool.mape.psidlen; + psmask = r->rpool.mape.psid & ((1U << r->rpool.mape.psidlen) - 1); + psmask = psmask << psidshift; + highmask = (1U << psidshift) - 1; + + ahigh = (1U << r->rpool.mape.offset) - 1; + cut = arc4random() & ahigh; + if (cut == 0) + cut = 1; + + for (i = cut; i <= ahigh; i++) { + low = (i << ashift) | psmask; + if (!pf_get_sport(af, proto, r, saddr, sport, daddr, dport, + naddr, nport, low, low | highmask, sn)) + return (0); + } + for (i = cut - 1; i > 0; i--) { + low = (i << ashift) | psmask; + if (!pf_get_sport(af, proto, r, saddr, sport, daddr, dport, + naddr, nport, low, low | highmask, sn)) + return (0); + } + return (1); +} + int pf_map_addr(sa_family_t af, struct pf_krule *r, struct pf_addr *saddr, struct pf_addr *naddr, struct pf_addr *init_addr, struct pf_ksrc_node **sn) @@ -526,6 +557,7 @@ pf_get_translation(struct pf_pdesc *pd, struct mbuf *m, int off, int direction, struct pf_krule *r = NULL; struct pf_addr *naddr; uint16_t *nport; + uint16_t low, high; PF_RULES_RASSERT(); KASSERT(*skp == NULL, ("*skp not NULL")); @@ -573,9 +605,26 @@ pf_get_translation(struct pf_pdesc *pd, struct mbuf *m, int off, int direction, switch (r->action) { case PF_NAT: - if (pf_get_sport(pd->af, pd->proto, r, saddr, sport, daddr, - dport, naddr, nport, r->rpool.proxy_port[0], - r->rpool.proxy_port[1], sn)) { + if (pd->proto == IPPROTO_ICMP) { + low = 1; + high = 65535; + } else { + low = r->rpool.proxy_port[0]; + high = r->rpool.proxy_port[1]; + } + if (r->rpool.mape.offset > 0) { + if (pf_get_mape_sport(pd->af, pd->proto, r, saddr, + sport, daddr, dport, naddr, nport, sn)) { + DPFPRINTF(PF_DEBUG_MISC, + ("pf: MAP-E port allocation (%u/%u/%u)" + " failed\n", + r->rpool.mape.offset, + r->rpool.mape.psidlen, + r->rpool.mape.psid)); + goto notrans; + } + } else if (pf_get_sport(pd->af, pd->proto, r, saddr, sport, + daddr, dport, naddr, nport, low, high, sn)) { DPFPRINTF(PF_DEBUG_MISC, ("pf: NAT proxy port allocation (%u-%u) failed\n", r->rpool.proxy_port[0], r->rpool.proxy_port[1])); diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index b4f2a5a988f9..34740ca9dca2 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -12,6 +12,7 @@ ATF_TESTS_SH+= anchor \ fragmentation \ icmp \ killstate \ + map_e \ names \ nat \ rules_counter \ diff --git a/tests/sys/netpfil/pf/map_e.sh b/tests/sys/netpfil/pf/map_e.sh new file mode 100644 index 000000000000..cc68fe26be5e --- /dev/null +++ b/tests/sys/netpfil/pf/map_e.sh @@ -0,0 +1,91 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 KUROSAWA Takahiro +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "map_e" "cleanup" +map_e_head() +{ + atf_set descr 'map-e-portset test' + atf_set require.user root +} + +map_e_body() +{ + NC_TRY_COUNT=12 + + pft_init + + epair_map_e=$(vnet_mkepair) + epair_echo=$(vnet_mkepair) + + vnet_mkjail map_e ${epair_map_e}b ${epair_echo}a + vnet_mkjail echo ${epair_echo}b + + ifconfig ${epair_map_e}a 192.0.2.2/24 up + route add -net 198.51.100.0/24 192.0.2.1 + + jexec map_e ifconfig ${epair_map_e}b 192.0.2.1/24 up + jexec map_e ifconfig ${epair_echo}a 198.51.100.1/24 up + jexec map_e sysctl net.inet.ip.forwarding=1 + + jexec echo ifconfig ${epair_echo}b 198.51.100.2/24 up + jexec echo /usr/sbin/inetd -p inetd-echo.pid $(atf_get_srcdir)/echo_inetd.conf + + # Enable pf! + jexec map_e pfctl -e + pft_set_rules map_e \ + "nat pass on ${epair_echo}a inet from 192.0.2.0/24 to any -> (${epair_echo}a) map-e-portset 2/12/0x342" + + # Only allow specified ports. + jexec echo pfctl -e + pft_set_rules echo "block return all" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 19720:19723 to (${epair_echo}b) port 7" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 36104:36107 to (${epair_echo}b) port 7" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 52488:52491 to (${epair_echo}b) port 7" + + i=0 + while [ ${i} -lt ${NC_TRY_COUNT} ] + do + echo "foo ${i}" | timeout 2 nc -N 198.51.100.2 7 + if [ $? -ne 0 ]; then + atf_fail "nc failed (${i})" + fi + i=$((${i}+1)) + done +} + +map_e_cleanup() +{ + rm -f inetd-echo.pid + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "map_e" +} From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B81C563AC18; Tue, 11 May 2021 15:06:45 +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 4Ffh8j4GGQz4Sft; Tue, 11 May 2021 15:06:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7EEB91A505; Tue, 11 May 2021 15:06:45 +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 14BF6jEe049426; Tue, 11 May 2021 15:06:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6j60049425; Tue, 11 May 2021 15:06:45 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:45 GMT Message-Id: <202105111506.14BF6j60049425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: a5a03901798c - stable/12 - pf: Optionally attempt to preserve rule counter values across ruleset updates MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a5a03901798c76f1f7c77535a2282a60f54b0ec2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:45 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a5a03901798c76f1f7c77535a2282a60f54b0ec2 commit a5a03901798c76f1f7c77535a2282a60f54b0ec2 Author: Kristof Provost AuthorDate: 2021-04-15 14:12:11 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 08:28:22 +0000 pf: Optionally attempt to preserve rule counter values across ruleset updates Usually rule counters are reset to zero on every update of the ruleset. With keepcounters set pf will attempt to find matching rules between old and new rulesets and preserve the rule counters. MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29780 (cherry picked from commit 42ec75f83aa321fcea8d2eddc4e9099724f0669e) --- lib/libpfctl/libpfctl.c | 22 +++++++++++++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 6 +++- sbin/pfctl/pfctl.c | 4 +++ sbin/pfctl/pfctl_parser.h | 1 + share/man/man5/pf.conf.5 | 12 +++++-- sys/net/pfvar.h | 3 ++ sys/netpfil/pf/pf_ioctl.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 126 insertions(+), 4 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index c2147e1b04c1..b07fcda9bd5a 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -586,3 +586,25 @@ int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, return (0); } + +int +pfctl_set_keepcounters(int dev, bool keep) +{ + struct pfioc_nv nv; + nvlist_t *nvl; + int ret; + + nvl = nvlist_create(0); + + nvlist_add_bool(nvl, "keep_counters", keep); + + nv.data = nvlist_pack(nvl, &nv.len); + nv.size = nv.len; + + nvlist_destroy(nvl); + + ret = ioctl(dev, DIOCKEEPCOUNTERS, &nv); + + free(nv.data); + return (ret); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 0f4f5c908738..e19187fc2526 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -188,5 +188,6 @@ int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket); +int pfctl_set_keepcounters(int dev, bool keep); #endif diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 0d0f6fea76be..903bbd47d660 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -464,7 +464,7 @@ int parseport(char *, struct range *r, int); %token REASSEMBLE FRAGDROP FRAGCROP ANCHOR NATANCHOR RDRANCHOR BINATANCHOR %token SET OPTIMIZATION TIMEOUT LIMIT LOGINTERFACE BLOCKPOLICY FAILPOLICY %token RANDOMID REQUIREORDER SYNPROXY FINGERPRINTS NOSYNC DEBUG SKIP HOSTID -%token ANTISPOOF FOR INCLUDE +%token ANTISPOOF FOR INCLUDE KEEPCOUNTERS %token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY MAPEPORTSET %token ALTQ CBQ CODEL PRIQ HFSC FAIRQ BANDWIDTH TBRSIZE LINKSHARE REALTIME %token UPPERLIMIT QUEUE PRIORITY QLIMIT HOGS BUCKETS RTABLE TARGET INTERVAL @@ -722,6 +722,9 @@ option : SET OPTIMIZATION STRING { } keep_state_defaults = $3; } + | SET KEEPCOUNTERS { + pf->keep_counters = true; + } ; stringall : STRING { $$ = $1; } @@ -5591,6 +5594,7 @@ lookup(char *s) { "inet6", INET6}, { "interval", INTERVAL}, { "keep", KEEP}, + { "keepcounters", KEEPCOUNTERS}, { "label", LABEL}, { "limit", LIMIT}, { "linkshare", LINKSHARE}, diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 8fa8ef44813a..af2ae6fe3bf0 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1753,6 +1753,10 @@ pfctl_load_options(struct pfctl *pf) if (pfctl_load_hostid(pf, pf->hostid)) error = 1; + /* load keepcounters */ + if (pfctl_set_keepcounters(pf->dev, pf->keep_counters)) + error = 1; + return (error); } diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 43d8488dcab8..0c66d5dda97a 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -98,6 +98,7 @@ struct pfctl { u_int32_t debug; u_int32_t hostid; char *ifname; + bool keep_counters; u_int8_t timeout_set[PFTM_MAX]; u_int8_t limit_set[PF_LIMIT_MAX]; diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5 index 86870319df2a..ca0f0da02047 100644 --- a/share/man/man5/pf.conf.5 +++ b/share/man/man5/pf.conf.5 @@ -28,7 +28,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd March 10, 2019 +.Dd April 19, 2021 .Dt PF.CONF 5 .Os .Sh NAME @@ -619,6 +619,13 @@ Generate debug messages for various errors. .It Ar loud Generate debug messages for common conditions. .El +.It Ar set keepcounters +Preserve rule counters across rule updates. +Usually rule counters are reset to zero on every update of the ruleset. +With +.Ar keepcounters +set pf will attempt to find matching rules between old and new rulesets +and preserve the rule counters. .El .Sh TRAFFIC NORMALIZATION Traffic normalization is used to sanitize packet content in such @@ -2889,7 +2896,8 @@ option = "set" ( [ "timeout" ( timeout | "{" timeout-list "}" ) ] | [ "require-order" ( "yes" | "no" ) ] [ "fingerprints" filename ] | [ "skip on" ifspec ] | - [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] ) + [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] + [ "keepcounters" ] ) pf-rule = action [ ( "in" | "out" ) ] [ "log" [ "(" logopts ")"] ] [ "quick" ] diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 6101f5f0ff54..dd69713d8574 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -994,6 +994,7 @@ struct pf_kstatus { uint32_t hostid; char ifname[IFNAMSIZ]; uint8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; + bool keep_counters; }; struct pf_divert { @@ -1303,6 +1304,8 @@ struct pfioc_iface { #define DIOCSETIFFLAG _IOWR('D', 89, struct pfioc_iface) #define DIOCCLRIFFLAG _IOWR('D', 90, struct pfioc_iface) #define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) +#define DIOCKEEPCOUNTERS _IOWR('D', 92, struct pfioc_nv) + struct pf_ifspeed_v0 { char ifname[IFNAMSIZ]; u_int32_t baudrate; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index dd57d4ac5c0f..4cedaba60504 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -197,6 +197,7 @@ static void pf_clear_states(void); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); +static int pf_keepcounters(struct pfioc_nv *); static void pf_tbladdr_copyout(struct pf_addr_wrap *); /* @@ -1023,11 +1024,27 @@ pf_hash_rule(MD5_CTX *ctx, struct pf_krule *rule) PF_MD5_UPD(rule, tos); } +static bool +pf_krule_compare(struct pf_krule *a, struct pf_krule *b) +{ + MD5_CTX ctx[2]; + u_int8_t digest[2][PF_MD5_DIGEST_LENGTH]; + + MD5Init(&ctx[0]); + MD5Init(&ctx[1]); + pf_hash_rule(&ctx[0], a); + pf_hash_rule(&ctx[1], b); + MD5Final(digest[0], &ctx[0]); + MD5Final(digest[1], &ctx[1]); + + return (memcmp(digest[0], digest[1], PF_MD5_DIGEST_LENGTH) == 0); +} + static int pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) { struct pf_kruleset *rs; - struct pf_krule *rule, **old_array; + struct pf_krule *rule, **old_array, *tail; struct pf_krulequeue *old_rules; int error; u_int32_t old_rcount; @@ -1059,6 +1076,29 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) rs->rules[rs_num].inactive.ptr_array; rs->rules[rs_num].active.rcount = rs->rules[rs_num].inactive.rcount; + + /* Attempt to preserve counter information. */ + if (V_pf_status.keep_counters) { + TAILQ_FOREACH(rule, rs->rules[rs_num].active.ptr, + entries) { + tail = TAILQ_FIRST(old_rules); + while ((tail != NULL) && ! pf_krule_compare(tail, rule)) + tail = TAILQ_NEXT(tail, entries); + if (tail != NULL) { + counter_u64_add(rule->evaluations, + counter_u64_fetch(tail->evaluations)); + counter_u64_add(rule->packets[0], + counter_u64_fetch(tail->packets[0])); + counter_u64_add(rule->packets[1], + counter_u64_fetch(tail->packets[1])); + counter_u64_add(rule->bytes[0], + counter_u64_fetch(tail->bytes[0])); + counter_u64_add(rule->bytes[1], + counter_u64_fetch(tail->bytes[1])); + } + } + } + rs->rules[rs_num].inactive.ptr = old_rules; rs->rules[rs_num].inactive.ptr_array = old_array; rs->rules[rs_num].inactive.rcount = old_rcount; @@ -5022,6 +5062,10 @@ DIOCCHANGEADDR_error: pf_kill_srcnodes((struct pfioc_src_node_kill *)addr); break; + case DIOCKEEPCOUNTERS: + error = pf_keepcounters((struct pfioc_nv *)addr); + break; + case DIOCSETHOSTID: { u_int32_t *hostid = (u_int32_t *)addr; @@ -5301,6 +5345,41 @@ pf_kill_srcnodes(struct pfioc_src_node_kill *psnk) psnk->psnk_killed = pf_free_src_nodes(&kill); } +static int +pf_keepcounters(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + +#define ERROUT(x) do { error = (x); goto on_error; } while (0) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + if (! nvlist_exists_bool(nvl, "keep_counters")) + ERROUT(EBADMSG); + + V_pf_status.keep_counters = nvlist_get_bool(nvl, "keep_counters"); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 286E363A8F5; Tue, 11 May 2021 15:06:47 +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 4Ffh8l0W6xz4StL; Tue, 11 May 2021 15:06:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 00D961A4AB; Tue, 11 May 2021 15:06:47 +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 14BF6kC3049542; Tue, 11 May 2021 15:06:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6kKO049541; Tue, 11 May 2021 15:06:46 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:46 GMT Message-Id: <202105111506.14BF6kKO049541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: e49799dcf14e - stable/13 - pf: Implement the NAT source port selection of MAP-E Customer Edge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e49799dcf14e7026f377d26a70fe0a3a3d15390a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:47 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e49799dcf14e7026f377d26a70fe0a3a3d15390a commit e49799dcf14e7026f377d26a70fe0a3a3d15390a Author: Kurosawa Takahiro AuthorDate: 2021-04-13 08:50:00 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 15:04:45 +0000 pf: Implement the NAT source port selection of MAP-E Customer Edge MAP-E (RFC 7597) requires special care for selecting source ports in NAT operation on the Customer Edge because a part of bits of the port numbers are used by the Border Relay to distinguish another side of the IPv4-over-IPv6 tunnel. PR: 254577 Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D29468 (cherry picked from commit 2aa21096c7349390f22aa5d06b373a575baed1b4) --- lib/libpfctl/libpfctl.c | 24 ++++++++++++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 57 ++++++++++++++++++++++++++- sbin/pfctl/pfctl_parser.c | 3 ++ share/man/man5/pf.conf.5 | 24 +++++++++++- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf.h | 6 +++ sys/netpfil/pf/pf_ioctl.c | 40 +++++++++++++++++++ sys/netpfil/pf/pf_lb.c | 65 +++++++++++++++++++++++++++---- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/map_e.sh | 91 +++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 303 insertions(+), 10 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 6b191514320e..c2147e1b04c1 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -201,6 +201,18 @@ pf_nvrule_addr_to_rule_addr(const nvlist_t *nvl, struct pf_rule_addr *addr) addr->port_op = nvlist_get_number(nvl, "port_op"); } +static void +pfctl_nv_add_mape(nvlist_t *nvparent, const char *name, + const struct pf_mape_portset *mape) +{ + nvlist_t *nvl = nvlist_create(0); + + nvlist_add_number(nvl, "offset", mape->offset); + nvlist_add_number(nvl, "psidlen", mape->psidlen); + nvlist_add_number(nvl, "psid", mape->psid); + nvlist_add_nvlist(nvparent, name, nvl); +} + static void pfctl_nv_add_pool(nvlist_t *nvparent, const char *name, const struct pfctl_pool *pool) @@ -216,10 +228,19 @@ pfctl_nv_add_pool(nvlist_t *nvparent, const char *name, ports[1] = pool->proxy_port[1]; nvlist_add_number_array(nvl, "proxy_port", ports, 2); nvlist_add_number(nvl, "opts", pool->opts); + pfctl_nv_add_mape(nvl, "mape", &pool->mape); nvlist_add_nvlist(nvparent, name, nvl); } +static void +pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape) +{ + mape->offset = nvlist_get_number(nvl, "offset"); + mape->psidlen = nvlist_get_number(nvl, "psidlen"); + mape->psid = nvlist_get_number(nvl, "psid"); +} + static void pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool) { @@ -235,6 +256,9 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool) pool->tblidx = nvlist_get_number(nvl, "tblidx"); pf_nvuint_16_array(nvl, "proxy_port", 2, pool->proxy_port, NULL); pool->opts = nvlist_get_number(nvl, "opts"); + + if (nvlist_exists_nvlist(nvl, "mape")) + pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"), &pool->mape); } static void diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 921b072a7753..0f4f5c908738 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -43,6 +43,7 @@ struct pfctl_pool { struct pf_pooladdr *cur; struct pf_poolhashkey key; struct pf_addr counter; + struct pf_mape_portset mape; int tblidx; u_int16_t proxy_port[2]; u_int8_t opts; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 73d1b77a7445..5cc3d188e800 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -309,6 +309,7 @@ static struct pool_opts { int type; int staticport; struct pf_poolhashkey *key; + struct pf_mape_portset mape; } pool_opts; @@ -464,7 +465,7 @@ int parseport(char *, struct range *r, int); %token SET OPTIMIZATION TIMEOUT LIMIT LOGINTERFACE BLOCKPOLICY FAILPOLICY %token RANDOMID REQUIREORDER SYNPROXY FINGERPRINTS NOSYNC DEBUG SKIP HOSTID %token ANTISPOOF FOR INCLUDE -%token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY +%token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY MAPEPORTSET %token ALTQ CBQ CODEL PRIQ HFSC FAIRQ BANDWIDTH TBRSIZE LINKSHARE REALTIME %token UPPERLIMIT QUEUE PRIORITY QLIMIT HOGS BUCKETS RTABLE TARGET INTERVAL %token LOAD RULESET_OPTIMIZATION PRIO @@ -4021,6 +4022,36 @@ pool_opt : BITMASK { pool_opts.marker |= POM_STICKYADDRESS; pool_opts.opts |= PF_POOL_STICKYADDR; } + | MAPEPORTSET number '/' number '/' number { + if (pool_opts.mape.offset) { + yyerror("map-e-portset cannot be redefined"); + YYERROR; + } + if (pool_opts.type) { + yyerror("map-e-portset cannot be used with " + "address pools"); + YYERROR; + } + if ($2 <= 0 || $2 >= 16) { + yyerror("MAP-E PSID offset must be 1-15"); + YYERROR; + } + if ($4 < 0 || $4 >= 16 || $2 + $4 > 16) { + yyerror("Invalid MAP-E PSID length"); + YYERROR; + } else if ($4 == 0) { + yyerror("PSID Length = 0: this means" + " you do not need MAP-E"); + YYERROR; + } + if ($6 < 0 || $6 > 65535) { + yyerror("Invalid MAP-E PSID"); + YYERROR; + } + pool_opts.mape.offset = $2; + pool_opts.mape.psidlen = $4; + pool_opts.mape.psid = $6; + } ; redirection : /* empty */ { $$ = NULL; } @@ -4226,6 +4257,29 @@ natrule : nataction interface af proto fromto tag tagged rtable r.rpool.proxy_port[1] = 0; } + if ($10.mape.offset) { + if (r.action != PF_NAT) { + yyerror("the 'map-e-portset' option is" + " only valid with nat rules"); + YYERROR; + } + if ($10.staticport) { + yyerror("the 'map-e-portset' option" + " can't be used 'static-port'"); + YYERROR; + } + if (r.rpool.proxy_port[0] != + PF_NAT_PROXY_PORT_LOW && + r.rpool.proxy_port[1] != + PF_NAT_PROXY_PORT_HIGH) { + yyerror("the 'map-e-portset' option" + " can't be used when specifying" + " a port range"); + YYERROR; + } + r.rpool.mape = $10.mape; + } + expand_rule(&r, $2, $9 == NULL ? NULL : $9->host, $4, $5.src_os, $5.src.host, $5.src.port, $5.dst.host, $5.dst.port, 0, 0, 0, ""); @@ -5551,6 +5605,7 @@ lookup(char *s) { "load", LOAD}, { "log", LOG}, { "loginterface", LOGINTERFACE}, + { "map-e-portset", MAPEPORTSET}, { "max", MAXIMUM}, { "max-mss", MAXMSS}, { "max-src-conn", MAXSRCCONN}, diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 826ba25b08d5..ce460ab691ca 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -486,6 +486,9 @@ print_pool(struct pfctl_pool *pool, u_int16_t p1, u_int16_t p2, printf(" sticky-address"); if (id == PF_NAT && p1 == 0 && p2 == 0) printf(" static-port"); + if (pool->mape.offset > 0) + printf(" map-e-portset %u/%u/%u", + pool->mape.offset, pool->mape.psidlen, pool->mape.psid); } const char * const pf_reasons[PFRES_MAX+1] = PFRES_NAMES; diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5 index d31d20e29bea..52a7331c7cb2 100644 --- a/share/man/man5/pf.conf.5 +++ b/share/man/man5/pf.conf.5 @@ -1998,6 +1998,27 @@ rules, the option prevents .Xr pf 4 from modifying the source port on TCP and UDP packets. +.It Xo Ar map-e-portset Aq Ar psid-offset +.No / Aq Ar psid-len +.No / Aq Ar psid +.Xc +With +.Ar nat +rules, the +.Ar map-e-portset +option enables the source port translation of MAP-E (RFC 7597) Customer Edge. +In order to make the host act as a MAP-E Customer Edge, setting up a tunneling +interface and pass rules for encapsulated packets are required in addition +to the map-e-portset nat rule. +.Pp +For example: +.Bd -literal -offset indent +nat on $gif_mape_if from $int_if:network to any \e + -> $ipv4_mape_src map-e-portset 6/8/0x34 +.Ed +.Pp +sets PSID offset 6, PSID length 8, PSID 0x34. +.Ed .El .Pp Additionally, the @@ -2893,7 +2914,8 @@ nat-rule = [ "no" ] "nat" [ "pass" [ "log" [ "(" logopts ")" ] ] ] [ "on" ifspec ] [ af ] [ protospec ] hosts [ "tag" string ] [ "tagged" string ] [ "-\*(Gt" ( redirhost | "{" redirhost-list "}" ) - [ portspec ] [ pooltype ] [ "static-port" ] ] + [ portspec ] [ pooltype ] [ "static-port" ] + [ "map-e-portset" number "/" number "/" number ] ] binat-rule = [ "no" ] "binat" [ "pass" [ "log" [ "(" logopts ")" ] ] ] [ "on" interface-name ] [ af ] diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index d68932db975f..e4f31dde873a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -309,6 +309,7 @@ struct pf_kpool { struct pf_kpooladdr *cur; struct pf_poolhashkey key; struct pf_addr counter; + struct pf_mape_portset mape; int tblidx; u_int16_t proxy_port[2]; u_int8_t opts; diff --git a/sys/netpfil/pf/pf.h b/sys/netpfil/pf/pf.h index 45a3efe91efb..011d69a746dd 100644 --- a/sys/netpfil/pf/pf.h +++ b/sys/netpfil/pf/pf.h @@ -317,6 +317,12 @@ struct pf_poolhashkey { #define key32 pfk.key32 }; +struct pf_mape_portset { + u_int8_t offset; + u_int8_t psidlen; + u_int16_t psid; +}; + struct pf_pool { struct pf_palist list; struct pf_pooladdr *cur; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 66726b754a97..5312e48c2f76 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -1645,6 +1645,36 @@ pf_addr_to_nvaddr(const struct pf_addr *paddr) return (nvl); } +static int +pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape) +{ + int error = 0; + + bzero(mape, sizeof(*mape)); + PFNV_CHK(pf_nvuint8(nvl, "offset", &mape->offset)); + PFNV_CHK(pf_nvuint8(nvl, "psidlen", &mape->psidlen)); + PFNV_CHK(pf_nvuint16(nvl, "psid", &mape->psid)); + +errout: + return (error); +} + +static nvlist_t * +pf_mape_to_nvmape(const struct pf_mape_portset *mape) +{ + nvlist_t *nvl; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + nvlist_add_number(nvl, "offset", mape->offset); + nvlist_add_number(nvl, "psidlen", mape->psidlen); + nvlist_add_number(nvl, "psid", mape->psid); + + return (nvl); +} + static int pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool) { @@ -1664,6 +1694,11 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pf_kpool *kpool) NULL)); PFNV_CHK(pf_nvuint8(nvl, "opts", &kpool->opts)); + if (nvlist_exists_nvlist(nvl, "mape")) { + PFNV_CHK(pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"), + &kpool->mape)); + } + errout: return (error); } @@ -1688,6 +1723,11 @@ pf_pool_to_nvpool(const struct pf_kpool *pool) pf_uint16_array_nv(nvl, "proxy_port", pool->proxy_port, 2); nvlist_add_number(nvl, "opts", pool->opts); + tmp = pf_mape_to_nvmape(&pool->mape); + if (tmp == NULL) + goto error; + nvlist_add_nvlist(nvl, "mape", tmp); + return (nvl); error: diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index 0892d13d9575..3796ab9fb80a 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -224,11 +224,6 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, if (pf_map_addr(af, r, saddr, naddr, &init_addr, sn)) return (1); - if (proto == IPPROTO_ICMP) { - low = 1; - high = 65535; - } - bzero(&key, sizeof(key)); key.af = af; key.proto = proto; @@ -310,6 +305,42 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, return (1); /* none available */ } +static int +pf_get_mape_sport(sa_family_t af, u_int8_t proto, struct pf_krule *r, + struct pf_addr *saddr, uint16_t sport, struct pf_addr *daddr, + uint16_t dport, struct pf_addr *naddr, uint16_t *nport, + struct pf_ksrc_node **sn) +{ + uint16_t psmask, low, highmask; + uint16_t i, ahigh, cut; + int ashift, psidshift; + + ashift = 16 - r->rpool.mape.offset; + psidshift = ashift - r->rpool.mape.psidlen; + psmask = r->rpool.mape.psid & ((1U << r->rpool.mape.psidlen) - 1); + psmask = psmask << psidshift; + highmask = (1U << psidshift) - 1; + + ahigh = (1U << r->rpool.mape.offset) - 1; + cut = arc4random() & ahigh; + if (cut == 0) + cut = 1; + + for (i = cut; i <= ahigh; i++) { + low = (i << ashift) | psmask; + if (!pf_get_sport(af, proto, r, saddr, sport, daddr, dport, + naddr, nport, low, low | highmask, sn)) + return (0); + } + for (i = cut - 1; i > 0; i--) { + low = (i << ashift) | psmask; + if (!pf_get_sport(af, proto, r, saddr, sport, daddr, dport, + naddr, nport, low, low | highmask, sn)) + return (0); + } + return (1); +} + int pf_map_addr(sa_family_t af, struct pf_krule *r, struct pf_addr *saddr, struct pf_addr *naddr, struct pf_addr *init_addr, struct pf_ksrc_node **sn) @@ -530,6 +561,7 @@ pf_get_translation(struct pf_pdesc *pd, struct mbuf *m, int off, int direction, struct pf_krule *r = NULL; struct pf_addr *naddr; uint16_t *nport; + uint16_t low, high; PF_RULES_RASSERT(); KASSERT(*skp == NULL, ("*skp not NULL")); @@ -577,9 +609,26 @@ pf_get_translation(struct pf_pdesc *pd, struct mbuf *m, int off, int direction, switch (r->action) { case PF_NAT: - if (pf_get_sport(pd->af, pd->proto, r, saddr, sport, daddr, - dport, naddr, nport, r->rpool.proxy_port[0], - r->rpool.proxy_port[1], sn)) { + if (pd->proto == IPPROTO_ICMP) { + low = 1; + high = 65535; + } else { + low = r->rpool.proxy_port[0]; + high = r->rpool.proxy_port[1]; + } + if (r->rpool.mape.offset > 0) { + if (pf_get_mape_sport(pd->af, pd->proto, r, saddr, + sport, daddr, dport, naddr, nport, sn)) { + DPFPRINTF(PF_DEBUG_MISC, + ("pf: MAP-E port allocation (%u/%u/%u)" + " failed\n", + r->rpool.mape.offset, + r->rpool.mape.psidlen, + r->rpool.mape.psid)); + goto notrans; + } + } else if (pf_get_sport(pd->af, pd->proto, r, saddr, sport, + daddr, dport, naddr, nport, low, high, sn)) { DPFPRINTF(PF_DEBUG_MISC, ("pf: NAT proxy port allocation (%u-%u) failed\n", r->rpool.proxy_port[0], r->rpool.proxy_port[1])); diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index e422da3b9e3d..d2dbbcdd18f6 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -12,6 +12,7 @@ ATF_TESTS_SH+= anchor \ fragmentation \ icmp \ killstate \ + map_e \ names \ nat \ pass_block \ diff --git a/tests/sys/netpfil/pf/map_e.sh b/tests/sys/netpfil/pf/map_e.sh new file mode 100644 index 000000000000..cc68fe26be5e --- /dev/null +++ b/tests/sys/netpfil/pf/map_e.sh @@ -0,0 +1,91 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 KUROSAWA Takahiro +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "map_e" "cleanup" +map_e_head() +{ + atf_set descr 'map-e-portset test' + atf_set require.user root +} + +map_e_body() +{ + NC_TRY_COUNT=12 + + pft_init + + epair_map_e=$(vnet_mkepair) + epair_echo=$(vnet_mkepair) + + vnet_mkjail map_e ${epair_map_e}b ${epair_echo}a + vnet_mkjail echo ${epair_echo}b + + ifconfig ${epair_map_e}a 192.0.2.2/24 up + route add -net 198.51.100.0/24 192.0.2.1 + + jexec map_e ifconfig ${epair_map_e}b 192.0.2.1/24 up + jexec map_e ifconfig ${epair_echo}a 198.51.100.1/24 up + jexec map_e sysctl net.inet.ip.forwarding=1 + + jexec echo ifconfig ${epair_echo}b 198.51.100.2/24 up + jexec echo /usr/sbin/inetd -p inetd-echo.pid $(atf_get_srcdir)/echo_inetd.conf + + # Enable pf! + jexec map_e pfctl -e + pft_set_rules map_e \ + "nat pass on ${epair_echo}a inet from 192.0.2.0/24 to any -> (${epair_echo}a) map-e-portset 2/12/0x342" + + # Only allow specified ports. + jexec echo pfctl -e + pft_set_rules echo "block return all" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 19720:19723 to (${epair_echo}b) port 7" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 36104:36107 to (${epair_echo}b) port 7" \ + "pass in on ${epair_echo}b inet proto tcp from 198.51.100.1 port 52488:52491 to (${epair_echo}b) port 7" + + i=0 + while [ ${i} -lt ${NC_TRY_COUNT} ] + do + echo "foo ${i}" | timeout 2 nc -N 198.51.100.2 7 + if [ $? -ne 0 ]; then + atf_fail "nc failed (${i})" + fi + i=$((${i}+1)) + done +} + +map_e_cleanup() +{ + rm -f inetd-echo.pid + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "map_e" +} From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6793C63A8F7; Tue, 11 May 2021 15:06:48 +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 4Ffh8l6B37z4Sqy; Tue, 11 May 2021 15:06:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C0E931A2B6; Tue, 11 May 2021 15:06:47 +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 14BF6l0R049563; Tue, 11 May 2021 15:06:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6l1I049562; Tue, 11 May 2021 15:06:47 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:47 GMT Message-Id: <202105111506.14BF6l1I049562@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 15e63883abde - stable/12 - pf: Error tracing SDTs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 15e63883abde66a538878158eebb46e3221aca86 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:48 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=15e63883abde66a538878158eebb46e3221aca86 commit 15e63883abde66a538878158eebb46e3221aca86 Author: Kristof Provost AuthorDate: 2021-04-20 09:18:26 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 08:29:08 +0000 pf: Error tracing SDTs Add additional DTrace static trace points to facilitate debugging failing pf ioctl calls. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 6b146f3b9b665c9baf6ba2cb038bbee359cb738a) --- sys/netpfil/pf/pf_ioctl.c | 102 +++++++++++++++++++++++++--------------------- sys/netpfil/pf/pf_nv.h | 1 + 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 4cedaba60504..e738300e3ae7 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -93,6 +94,12 @@ __FBSDID("$FreeBSD$"); #include #endif +SDT_PROVIDER_DECLARE(pf); +SDT_PROBE_DEFINE3(pf, ioctl, ioctl, error, "int", "int", "int"); +SDT_PROBE_DEFINE3(pf, ioctl, function, error, "char *", "int", "int"); +SDT_PROBE_DEFINE2(pf, ioctl, addrule, error, "int", "int"); +SDT_PROBE_DEFINE2(pf, ioctl, nvchk, error, "int", "int"); + static struct pf_kpool *pf_get_kpool(char *, u_int32_t, u_int8_t, u_int32_t, u_int8_t, u_int8_t, u_int8_t); @@ -260,6 +267,14 @@ pflog_packet_t *pflog_packet_ptr = NULL; extern u_long pf_ioctl_maxcount; +#define ERROUT_FUNCTION(target, x) \ + do { \ + error = (x); \ + SDT_PROBE3(pf, ioctl, function, error, __func__, error, \ + __LINE__); \ + goto target; \ + } while (0) + static void pfattach_vnet(void) { @@ -1963,23 +1978,23 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) struct pf_krule *rule; int error = 0; +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK | M_ZERO); PFNV_CHK(pf_nvuint32(nvl, "nr", &rule->nr)); - if (! nvlist_exists_nvlist(nvl, "src")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "src")) + ERROUT(EINVAL); + error = pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "src"), &rule->src); if (error != 0) - goto errout; + ERROUT(error); + + if (! nvlist_exists_nvlist(nvl, "dst")) + ERROUT(EINVAL); - if (! nvlist_exists_nvlist(nvl, "dst")) { - error = EINVAL; - goto errout; - } PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &rule->dst)); @@ -1992,18 +2007,14 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) int ret; strs = nvlist_get_string_array(nvl, "labels", &items); - if (items > PF_RULE_MAX_LABEL_COUNT) { - error = E2BIG; - goto errout; - } + if (items > PF_RULE_MAX_LABEL_COUNT) + ERROUT(E2BIG); for (size_t i = 0; i < items; i++) { ret = strlcpy(rule->label[i], strs[i], sizeof(rule->label[0])); - if (ret >= sizeof(rule->label[0])) { - error = E2BIG; - goto errout; - } + if (ret >= sizeof(rule->label[0])) + ERROUT(E2BIG); } } @@ -2019,10 +2030,8 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvstring(nvl, "overload_tblname", rule->overload_tblname, sizeof(rule->overload_tblname))); - if (! nvlist_exists_nvlist(nvl, "rpool")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "rpool")) + ERROUT(EINVAL); PFNV_CHK(pf_nvpool_to_pool(nvlist_get_nvlist(nvl, "rpool"), &rule->rpool)); @@ -2048,17 +2057,13 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvuint16(nvl, "max_mss", &rule->max_mss)); PFNV_CHK(pf_nvuint16(nvl, "scrub_flags", &rule->scrub_flags)); - if (! nvlist_exists_nvlist(nvl, "uid")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "uid")) + ERROUT(EINVAL); PFNV_CHK(pf_nvrule_uid_to_rule_uid(nvlist_get_nvlist(nvl, "uid"), &rule->uid)); - if (! nvlist_exists_nvlist(nvl, "gid")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "gid")) + ERROUT(EINVAL); PFNV_CHK(pf_nvrule_gid_to_rule_gid(nvlist_get_nvlist(nvl, "gid"), &rule->gid)); @@ -2096,10 +2101,8 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) if (nvlist_exists_nvlist(nvl, "divert")) { const nvlist_t *nvldivert = nvlist_get_nvlist(nvl, "divert"); - if (! nvlist_exists_nvlist(nvldivert, "addr")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvldivert, "addr")) + ERROUT(EINVAL); PFNV_CHK(pf_nvaddr_to_addr(nvlist_get_nvlist(nvldivert, "addr"), &rule->divert.addr)); PFNV_CHK(pf_nvuint16(nvldivert, "port", &rule->divert.port)); @@ -2107,16 +2110,12 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) /* Validation */ #ifndef INET - if (rule->af == AF_INET) { - error = EAFNOSUPPORT; - goto errout; - } + if (rule->af == AF_INET) + ERROUT(EAFNOSUPPORT); #endif /* INET */ #ifndef INET6 - if (rule->af == AF_INET6) { - error = EAFNOSUPPORT; - goto errout; - } + if (rule->af == AF_INET6) + ERROUT(EAFNOSUPPORT); #endif /* INET6 */ PFNV_CHK(pf_check_rule_addr(&rule->src)); @@ -2126,6 +2125,7 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) return (0); +#undef ERROUT errout: pf_krule_free(rule); *prule = NULL; @@ -2493,7 +2493,7 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, goto errout_unlocked; } -#define ERROUT(x) { error = (x); goto errout; } +#define ERROUT(x) ERROUT_FUNCTION(errout, x) if (rule->ifname[0]) kif = pf_kkif_create(M_WAITOK); @@ -2640,6 +2640,14 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td int error = 0; PF_RULES_RLOCK_TRACKER; +#define ERROUT_IOCTL(target, x) \ + do { \ + error = (x); \ + SDT_PROBE3(pf, ioctl, ioctl, error, cmd, error, __LINE__); \ + goto target; \ + } while (0) + + /* XXX keep in sync with switch() below */ if (securelevel_gt(td->td_ucred, 2)) switch (cmd) { @@ -2804,7 +2812,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td const char *anchor = "", *anchor_call = ""; uint32_t ticket = 0, pool_ticket = 0; -#define ERROUT(x) do { error = (x); goto DIOCADDRULENV_error; } while (0) +#define ERROUT(x) ERROUT_IOCTL(DIOCADDRULENV_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); @@ -2973,7 +2981,7 @@ DIOCADDRULENV_error: int rs_num, nr; bool clear_counter = false; -#define ERROUT(x) do { error = (x); goto DIOCGETRULENV_error; } while (0) +#define ERROUT(x) ERROUT_IOCTL(DIOCGETRULENV_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); @@ -4011,7 +4019,7 @@ DIOCGETSTATES_full: newpa->kif = NULL; } -#define ERROUT(x) { error = (x); goto DIOCCHANGEADDR_error; } +#define ERROUT(x) ERROUT_IOCTL(DIOCCHANGEADDR_error, x) PF_RULES_WLOCK(); ruleset = pf_find_kruleset(pca->anchor); if (ruleset == NULL) @@ -5144,6 +5152,8 @@ fail: sx_xunlock(&pf_ioctl_lock); CURVNET_RESTORE(); +#undef ERROUT_IOCTL + return (error); } @@ -5352,7 +5362,7 @@ pf_keepcounters(struct pfioc_nv *nv) void *nvlpacked = NULL; int error = 0; -#define ERROUT(x) do { error = (x); goto on_error; } while (0) +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 0a0f9beeef40..d50f46a1f5cd 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -53,6 +53,7 @@ int pf_nvstring(const nvlist_t *, const char *, char *, size_t); #define PFNV_CHK(x) do { \ error = (x); \ + SDT_PROBE2(pf, ioctl, nvchk, error, error, __LINE__); \ if (error != 0) \ goto errout; \ } while (0) From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0EEA563A8F8; Tue, 11 May 2021 15:06:49 +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 4Ffh8m3SkBz4StV; Tue, 11 May 2021 15:06:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 20AAD1A158; Tue, 11 May 2021 15:06:48 +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 14BF6mhd049584; Tue, 11 May 2021 15:06:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6lL6049583; Tue, 11 May 2021 15:06:47 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:47 GMT Message-Id: <202105111506.14BF6lL6049583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 898407819d81 - stable/13 - pf: Optionally attempt to preserve rule counter values across ruleset updates MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 898407819d8158154692a6cceb7757c9d7aa2d8b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=898407819d8158154692a6cceb7757c9d7aa2d8b commit 898407819d8158154692a6cceb7757c9d7aa2d8b Author: Kristof Provost AuthorDate: 2021-04-15 14:12:11 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 15:04:45 +0000 pf: Optionally attempt to preserve rule counter values across ruleset updates Usually rule counters are reset to zero on every update of the ruleset. With keepcounters set pf will attempt to find matching rules between old and new rulesets and preserve the rule counters. MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29780 (cherry picked from commit 42ec75f83aa321fcea8d2eddc4e9099724f0669e) --- lib/libpfctl/libpfctl.c | 22 +++++++++++++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 6 +++- sbin/pfctl/pfctl.c | 4 +++ sbin/pfctl/pfctl_parser.h | 1 + share/man/man5/pf.conf.5 | 12 +++++-- sys/net/pfvar.h | 3 ++ sys/netpfil/pf/pf_ioctl.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 126 insertions(+), 4 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index c2147e1b04c1..b07fcda9bd5a 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -586,3 +586,25 @@ int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, return (0); } + +int +pfctl_set_keepcounters(int dev, bool keep) +{ + struct pfioc_nv nv; + nvlist_t *nvl; + int ret; + + nvl = nvlist_create(0); + + nvlist_add_bool(nvl, "keep_counters", keep); + + nv.data = nvlist_pack(nvl, &nv.len); + nv.size = nv.len; + + nvlist_destroy(nvl); + + ret = ioctl(dev, DIOCKEEPCOUNTERS, &nv); + + free(nv.data); + return (ret); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 0f4f5c908738..e19187fc2526 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -188,5 +188,6 @@ int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket, int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket); +int pfctl_set_keepcounters(int dev, bool keep); #endif diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 5cc3d188e800..6acfefbf5ad3 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -464,7 +464,7 @@ int parseport(char *, struct range *r, int); %token REASSEMBLE FRAGDROP FRAGCROP ANCHOR NATANCHOR RDRANCHOR BINATANCHOR %token SET OPTIMIZATION TIMEOUT LIMIT LOGINTERFACE BLOCKPOLICY FAILPOLICY %token RANDOMID REQUIREORDER SYNPROXY FINGERPRINTS NOSYNC DEBUG SKIP HOSTID -%token ANTISPOOF FOR INCLUDE +%token ANTISPOOF FOR INCLUDE KEEPCOUNTERS %token BITMASK RANDOM SOURCEHASH ROUNDROBIN STATICPORT PROBABILITY MAPEPORTSET %token ALTQ CBQ CODEL PRIQ HFSC FAIRQ BANDWIDTH TBRSIZE LINKSHARE REALTIME %token UPPERLIMIT QUEUE PRIORITY QLIMIT HOGS BUCKETS RTABLE TARGET INTERVAL @@ -722,6 +722,9 @@ option : SET OPTIMIZATION STRING { } keep_state_defaults = $3; } + | SET KEEPCOUNTERS { + pf->keep_counters = true; + } ; stringall : STRING { $$ = $1; } @@ -5599,6 +5602,7 @@ lookup(char *s) { "inet6", INET6}, { "interval", INTERVAL}, { "keep", KEEP}, + { "keepcounters", KEEPCOUNTERS}, { "label", LABEL}, { "limit", LIMIT}, { "linkshare", LINKSHARE}, diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 8fa8ef44813a..af2ae6fe3bf0 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1753,6 +1753,10 @@ pfctl_load_options(struct pfctl *pf) if (pfctl_load_hostid(pf, pf->hostid)) error = 1; + /* load keepcounters */ + if (pfctl_set_keepcounters(pf->dev, pf->keep_counters)) + error = 1; + return (error); } diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 43d8488dcab8..0c66d5dda97a 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -98,6 +98,7 @@ struct pfctl { u_int32_t debug; u_int32_t hostid; char *ifname; + bool keep_counters; u_int8_t timeout_set[PFTM_MAX]; u_int8_t limit_set[PF_LIMIT_MAX]; diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5 index 52a7331c7cb2..00fbd4421e7f 100644 --- a/share/man/man5/pf.conf.5 +++ b/share/man/man5/pf.conf.5 @@ -28,7 +28,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 7, 2019 +.Dd April 19, 2021 .Dt PF.CONF 5 .Os .Sh NAME @@ -618,6 +618,13 @@ Generate debug messages for various errors. .It Ar loud Generate debug messages for common conditions. .El +.It Ar set keepcounters +Preserve rule counters across rule updates. +Usually rule counters are reset to zero on every update of the ruleset. +With +.Ar keepcounters +set pf will attempt to find matching rules between old and new rulesets +and preserve the rule counters. .El .Sh TRAFFIC NORMALIZATION Traffic normalization is used to sanitize packet content in such @@ -2888,7 +2895,8 @@ option = "set" ( [ "timeout" ( timeout | "{" timeout-list "}" ) ] | [ "require-order" ( "yes" | "no" ) ] [ "fingerprints" filename ] | [ "skip on" ifspec ] | - [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] ) + [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] + [ "keepcounters" ] ) pf-rule = action [ ( "in" | "out" ) ] [ "log" [ "(" logopts ")"] ] [ "quick" ] diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index e4f31dde873a..c6761a5d87f1 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -994,6 +994,7 @@ struct pf_kstatus { uint32_t hostid; char ifname[IFNAMSIZ]; uint8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; + bool keep_counters; }; struct pf_divert { @@ -1302,6 +1303,8 @@ struct pfioc_iface { #define DIOCSETIFFLAG _IOWR('D', 89, struct pfioc_iface) #define DIOCCLRIFFLAG _IOWR('D', 90, struct pfioc_iface) #define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) +#define DIOCKEEPCOUNTERS _IOWR('D', 92, struct pfioc_nv) + struct pf_ifspeed_v0 { char ifname[IFNAMSIZ]; u_int32_t baudrate; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 5312e48c2f76..36e3fb8ff332 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -197,6 +197,7 @@ static void pf_clear_states(void); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); +static int pf_keepcounters(struct pfioc_nv *); static void pf_tbladdr_copyout(struct pf_addr_wrap *); /* @@ -1023,11 +1024,27 @@ pf_hash_rule(MD5_CTX *ctx, struct pf_krule *rule) PF_MD5_UPD(rule, tos); } +static bool +pf_krule_compare(struct pf_krule *a, struct pf_krule *b) +{ + MD5_CTX ctx[2]; + u_int8_t digest[2][PF_MD5_DIGEST_LENGTH]; + + MD5Init(&ctx[0]); + MD5Init(&ctx[1]); + pf_hash_rule(&ctx[0], a); + pf_hash_rule(&ctx[1], b); + MD5Final(digest[0], &ctx[0]); + MD5Final(digest[1], &ctx[1]); + + return (memcmp(digest[0], digest[1], PF_MD5_DIGEST_LENGTH) == 0); +} + static int pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) { struct pf_kruleset *rs; - struct pf_krule *rule, **old_array; + struct pf_krule *rule, **old_array, *tail; struct pf_krulequeue *old_rules; int error; u_int32_t old_rcount; @@ -1059,6 +1076,29 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) rs->rules[rs_num].inactive.ptr_array; rs->rules[rs_num].active.rcount = rs->rules[rs_num].inactive.rcount; + + /* Attempt to preserve counter information. */ + if (V_pf_status.keep_counters) { + TAILQ_FOREACH(rule, rs->rules[rs_num].active.ptr, + entries) { + tail = TAILQ_FIRST(old_rules); + while ((tail != NULL) && ! pf_krule_compare(tail, rule)) + tail = TAILQ_NEXT(tail, entries); + if (tail != NULL) { + counter_u64_add(rule->evaluations, + counter_u64_fetch(tail->evaluations)); + counter_u64_add(rule->packets[0], + counter_u64_fetch(tail->packets[0])); + counter_u64_add(rule->packets[1], + counter_u64_fetch(tail->packets[1])); + counter_u64_add(rule->bytes[0], + counter_u64_fetch(tail->bytes[0])); + counter_u64_add(rule->bytes[1], + counter_u64_fetch(tail->bytes[1])); + } + } + } + rs->rules[rs_num].inactive.ptr = old_rules; rs->rules[rs_num].inactive.ptr_array = old_array; rs->rules[rs_num].inactive.rcount = old_rcount; @@ -5007,6 +5047,10 @@ DIOCCHANGEADDR_error: pf_kill_srcnodes((struct pfioc_src_node_kill *)addr); break; + case DIOCKEEPCOUNTERS: + error = pf_keepcounters((struct pfioc_nv *)addr); + break; + case DIOCSETHOSTID: { u_int32_t *hostid = (u_int32_t *)addr; @@ -5286,6 +5330,41 @@ pf_kill_srcnodes(struct pfioc_src_node_kill *psnk) psnk->psnk_killed = pf_free_src_nodes(&kill); } +static int +pf_keepcounters(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + +#define ERROUT(x) do { error = (x); goto on_error; } while (0) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + if (! nvlist_exists_bool(nvl, "keep_counters")) + ERROUT(EBADMSG); + + V_pf_status.keep_counters = nvlist_get_bool(nvl, "keep_counters"); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AEFB363ABEC; Tue, 11 May 2021 15:06:51 +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 4Ffh8q2cRbz4T4L; Tue, 11 May 2021 15:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6EAEC1A159; Tue, 11 May 2021 15:06:50 +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 14BF6o0W049671; Tue, 11 May 2021 15:06:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6oHn049670; Tue, 11 May 2021 15:06:50 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:50 GMT Message-Id: <202105111506.14BF6oHn049670@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 09db9de2fea8 - stable/13 - pf: Error tracing SDTs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 09db9de2fea847de2ebc35acd7333c97390dc8f8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:51 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=09db9de2fea847de2ebc35acd7333c97390dc8f8 commit 09db9de2fea847de2ebc35acd7333c97390dc8f8 Author: Kristof Provost AuthorDate: 2021-04-20 09:18:26 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 15:04:45 +0000 pf: Error tracing SDTs Add additional DTrace static trace points to facilitate debugging failing pf ioctl calls. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 6b146f3b9b665c9baf6ba2cb038bbee359cb738a) --- sys/netpfil/pf/pf_ioctl.c | 102 +++++++++++++++++++++++++--------------------- sys/netpfil/pf/pf_nv.h | 1 + 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 36e3fb8ff332..d9e313f62683 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -93,6 +94,12 @@ __FBSDID("$FreeBSD$"); #include #endif +SDT_PROVIDER_DECLARE(pf); +SDT_PROBE_DEFINE3(pf, ioctl, ioctl, error, "int", "int", "int"); +SDT_PROBE_DEFINE3(pf, ioctl, function, error, "char *", "int", "int"); +SDT_PROBE_DEFINE2(pf, ioctl, addrule, error, "int", "int"); +SDT_PROBE_DEFINE2(pf, ioctl, nvchk, error, "int", "int"); + static struct pf_kpool *pf_get_kpool(char *, u_int32_t, u_int8_t, u_int32_t, u_int8_t, u_int8_t, u_int8_t); @@ -260,6 +267,14 @@ pflog_packet_t *pflog_packet_ptr = NULL; extern u_long pf_ioctl_maxcount; +#define ERROUT_FUNCTION(target, x) \ + do { \ + error = (x); \ + SDT_PROBE3(pf, ioctl, function, error, __func__, error, \ + __LINE__); \ + goto target; \ + } while (0) + static void pfattach_vnet(void) { @@ -1962,23 +1977,23 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) struct pf_krule *rule; int error = 0; +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK | M_ZERO); PFNV_CHK(pf_nvuint32(nvl, "nr", &rule->nr)); - if (! nvlist_exists_nvlist(nvl, "src")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "src")) + ERROUT(EINVAL); + error = pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "src"), &rule->src); if (error != 0) - goto errout; + ERROUT(error); + + if (! nvlist_exists_nvlist(nvl, "dst")) + ERROUT(EINVAL); - if (! nvlist_exists_nvlist(nvl, "dst")) { - error = EINVAL; - goto errout; - } PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &rule->dst)); @@ -1991,18 +2006,14 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) int ret; strs = nvlist_get_string_array(nvl, "labels", &items); - if (items > PF_RULE_MAX_LABEL_COUNT) { - error = E2BIG; - goto errout; - } + if (items > PF_RULE_MAX_LABEL_COUNT) + ERROUT(E2BIG); for (size_t i = 0; i < items; i++) { ret = strlcpy(rule->label[i], strs[i], sizeof(rule->label[0])); - if (ret >= sizeof(rule->label[0])) { - error = E2BIG; - goto errout; - } + if (ret >= sizeof(rule->label[0])) + ERROUT(E2BIG); } } @@ -2018,10 +2029,8 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvstring(nvl, "overload_tblname", rule->overload_tblname, sizeof(rule->overload_tblname))); - if (! nvlist_exists_nvlist(nvl, "rpool")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "rpool")) + ERROUT(EINVAL); PFNV_CHK(pf_nvpool_to_pool(nvlist_get_nvlist(nvl, "rpool"), &rule->rpool)); @@ -2047,17 +2056,13 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) PFNV_CHK(pf_nvuint16(nvl, "max_mss", &rule->max_mss)); PFNV_CHK(pf_nvuint16(nvl, "scrub_flags", &rule->scrub_flags)); - if (! nvlist_exists_nvlist(nvl, "uid")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "uid")) + ERROUT(EINVAL); PFNV_CHK(pf_nvrule_uid_to_rule_uid(nvlist_get_nvlist(nvl, "uid"), &rule->uid)); - if (! nvlist_exists_nvlist(nvl, "gid")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvl, "gid")) + ERROUT(EINVAL); PFNV_CHK(pf_nvrule_gid_to_rule_gid(nvlist_get_nvlist(nvl, "gid"), &rule->gid)); @@ -2095,10 +2100,8 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) if (nvlist_exists_nvlist(nvl, "divert")) { const nvlist_t *nvldivert = nvlist_get_nvlist(nvl, "divert"); - if (! nvlist_exists_nvlist(nvldivert, "addr")) { - error = EINVAL; - goto errout; - } + if (! nvlist_exists_nvlist(nvldivert, "addr")) + ERROUT(EINVAL); PFNV_CHK(pf_nvaddr_to_addr(nvlist_get_nvlist(nvldivert, "addr"), &rule->divert.addr)); PFNV_CHK(pf_nvuint16(nvldivert, "port", &rule->divert.port)); @@ -2106,16 +2109,12 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) /* Validation */ #ifndef INET - if (rule->af == AF_INET) { - error = EAFNOSUPPORT; - goto errout; - } + if (rule->af == AF_INET) + ERROUT(EAFNOSUPPORT); #endif /* INET */ #ifndef INET6 - if (rule->af == AF_INET6) { - error = EAFNOSUPPORT; - goto errout; - } + if (rule->af == AF_INET6) + ERROUT(EAFNOSUPPORT); #endif /* INET6 */ PFNV_CHK(pf_check_rule_addr(&rule->src)); @@ -2125,6 +2124,7 @@ pf_nvrule_to_krule(const nvlist_t *nvl, struct pf_krule **prule) return (0); +#undef ERROUT errout: pf_krule_free(rule); *prule = NULL; @@ -2492,7 +2492,7 @@ pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, goto errout_unlocked; } -#define ERROUT(x) { error = (x); goto errout; } +#define ERROUT(x) ERROUT_FUNCTION(errout, x) if (rule->ifname[0]) kif = pf_kkif_create(M_WAITOK); @@ -2639,6 +2639,14 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td int error = 0; PF_RULES_RLOCK_TRACKER; +#define ERROUT_IOCTL(target, x) \ + do { \ + error = (x); \ + SDT_PROBE3(pf, ioctl, ioctl, error, cmd, error, __LINE__); \ + goto target; \ + } while (0) + + /* XXX keep in sync with switch() below */ if (securelevel_gt(td->td_ucred, 2)) switch (cmd) { @@ -2793,7 +2801,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td const char *anchor = "", *anchor_call = ""; uint32_t ticket = 0, pool_ticket = 0; -#define ERROUT(x) do { error = (x); goto DIOCADDRULENV_error; } while (0) +#define ERROUT(x) ERROUT_IOCTL(DIOCADDRULENV_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); @@ -2962,7 +2970,7 @@ DIOCADDRULENV_error: int rs_num, nr; bool clear_counter = false; -#define ERROUT(x) do { error = (x); goto DIOCGETRULENV_error; } while (0) +#define ERROUT(x) ERROUT_IOCTL(DIOCGETRULENV_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); @@ -3997,7 +4005,7 @@ DIOCGETSTATES_full: kif = pf_kkif_create(M_WAITOK); newpa->kif = NULL; } -#define ERROUT(x) { error = (x); goto DIOCCHANGEADDR_error; } +#define ERROUT(x) ERROUT_IOCTL(DIOCCHANGEADDR_error, x) PF_RULES_WLOCK(); ruleset = pf_find_kruleset(pca->anchor); if (ruleset == NULL) @@ -5129,6 +5137,8 @@ fail: sx_xunlock(&pf_ioctl_lock); CURVNET_RESTORE(); +#undef ERROUT_IOCTL + return (error); } @@ -5337,7 +5347,7 @@ pf_keepcounters(struct pfioc_nv *nv) void *nvlpacked = NULL; int error = 0; -#define ERROUT(x) do { error = (x); goto on_error; } while (0) +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) if (nv->len > pf_ioctl_maxcount) ERROUT(ENOMEM); diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 0a0f9beeef40..d50f46a1f5cd 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -53,6 +53,7 @@ int pf_nvstring(const nvlist_t *, const char *, char *, size_t); #define PFNV_CHK(x) do { \ error = (x); \ + SDT_PROBE2(pf, ioctl, nvchk, error, error, __LINE__); \ if (error != 0) \ goto errout; \ } while (0) From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0362463AC9A; Tue, 11 May 2021 15:06:47 +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 4Ffh8k5LDDz4Sg0; Tue, 11 May 2021 15:06:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9D37D1A2B5; Tue, 11 May 2021 15:06:46 +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 14BF6klf049460; Tue, 11 May 2021 15:06:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6kem049455; Tue, 11 May 2021 15:06:46 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:46 GMT Message-Id: <202105111506.14BF6kem049455@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 6790b1257b63 - stable/12 - pf tests: Test set keepcounters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6790b1257b634ba212142d3c8968e1f2fbe08fa5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:47 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6790b1257b634ba212142d3c8968e1f2fbe08fa5 commit 6790b1257b634ba212142d3c8968e1f2fbe08fa5 Author: Kristof Provost AuthorDate: 2021-04-15 14:53:16 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 08:28:33 +0000 pf tests: Test set keepcounters MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29781 (cherry picked from commit e14d56f370184fdf7ef33ec57883a45f4a220cff) --- tests/sys/netpfil/pf/rules_counter.sh | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tests/sys/netpfil/pf/rules_counter.sh b/tests/sys/netpfil/pf/rules_counter.sh index 56dc159f49c8..567bf439b0ef 100644 --- a/tests/sys/netpfil/pf/rules_counter.sh +++ b/tests/sys/netpfil/pf/rules_counter.sh @@ -73,7 +73,89 @@ get_clear_cleanup() pft_cleanup } +atf_test_case "keepcounters" "cleanup" +keepcounters_head() +{ + atf_set descr 'Test keepcounter functionality' + atf_set require.user root +} + +keepcounters_body() +{ + pft_init + + epair_send=$(vnet_mkepair) + ifconfig ${epair_send}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair_send}b + jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "pass all" + + # Expect zero counters + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # Ensure the rule matched packets, so we can verify non-zero counters + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + + # Expect non-zero counters + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: [1-9][0-9]*[[:space:]]*Packets: [1-9][0-9]*[[:space:]]*Bytes: [1-9][0-9]*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # As we set the (same) rules again we'd expect the counters to return + # to zero + pft_set_rules noflush alcatraz \ + "pass all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # Increment rule counters + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + + # Now set new rules with 'keepcounters' set, so we'd expect nonzero + # counters + pft_set_rules noflush alcatraz \ + "set keepcounters" \ + "pass all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: [1-9][0-9]*[[:space:]]*Packets: [1-9][0-9]*[[:space:]]*Bytes: [1-9][0-9]*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # However, if we set a different rule it should return to zero + pft_set_rules noflush alcatraz \ + "set keepcounters" \ + "pass inet all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # If we generate traffic and don't set keepcounters we also see zero + # counts when setting new rules + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + pft_set_rules noflush alcatraz \ + "pass inet all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v +} + +keepcounters_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "get_clear" + atf_add_test_case "keepcounters" } From owner-dev-commits-src-all@freebsd.org Tue May 11 15:06:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6D9863AD11; Tue, 11 May 2021 15:06:49 +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 4Ffh8n32DNz4Stb; Tue, 11 May 2021 15:06:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 449001A3DD; Tue, 11 May 2021 15:06:49 +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 14BF6nO3049650; Tue, 11 May 2021 15:06:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BF6nsw049649; Tue, 11 May 2021 15:06:49 GMT (envelope-from git) Date: Tue, 11 May 2021 15:06:49 GMT Message-Id: <202105111506.14BF6nsw049649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 5c371d922aa8 - stable/13 - pf tests: Test set keepcounters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5c371d922aa859f7d674bea4ada22a15dee7bb0c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5c371d922aa859f7d674bea4ada22a15dee7bb0c commit 5c371d922aa859f7d674bea4ada22a15dee7bb0c Author: Kristof Provost AuthorDate: 2021-04-15 14:53:16 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 15:04:45 +0000 pf tests: Test set keepcounters MFC after: 4 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29781 (cherry picked from commit e14d56f370184fdf7ef33ec57883a45f4a220cff) --- tests/sys/netpfil/pf/rules_counter.sh | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tests/sys/netpfil/pf/rules_counter.sh b/tests/sys/netpfil/pf/rules_counter.sh index 56dc159f49c8..567bf439b0ef 100644 --- a/tests/sys/netpfil/pf/rules_counter.sh +++ b/tests/sys/netpfil/pf/rules_counter.sh @@ -73,7 +73,89 @@ get_clear_cleanup() pft_cleanup } +atf_test_case "keepcounters" "cleanup" +keepcounters_head() +{ + atf_set descr 'Test keepcounter functionality' + atf_set require.user root +} + +keepcounters_body() +{ + pft_init + + epair_send=$(vnet_mkepair) + ifconfig ${epair_send}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair_send}b + jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "pass all" + + # Expect zero counters + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # Ensure the rule matched packets, so we can verify non-zero counters + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + + # Expect non-zero counters + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: [1-9][0-9]*[[:space:]]*Packets: [1-9][0-9]*[[:space:]]*Bytes: [1-9][0-9]*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # As we set the (same) rules again we'd expect the counters to return + # to zero + pft_set_rules noflush alcatraz \ + "pass all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # Increment rule counters + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + + # Now set new rules with 'keepcounters' set, so we'd expect nonzero + # counters + pft_set_rules noflush alcatraz \ + "set keepcounters" \ + "pass all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: [1-9][0-9]*[[:space:]]*Packets: [1-9][0-9]*[[:space:]]*Bytes: [1-9][0-9]*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # However, if we set a different rule it should return to zero + pft_set_rules noflush alcatraz \ + "set keepcounters" \ + "pass inet all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v + + # If we generate traffic and don't set keepcounters we also see zero + # counts when setting new rules + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + pft_set_rules noflush alcatraz \ + "pass inet all" + + atf_check -s exit:0 -e ignore \ + -o match:'Evaluations: 0[[:space:]]*Packets: 0*[[:space:]]*Bytes: 0*[[:space:]]*' \ + jexec alcatraz pfctl -s r -v +} + +keepcounters_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "get_clear" + atf_add_test_case "keepcounters" } From owner-dev-commits-src-all@freebsd.org Tue May 11 15:23:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AB37363BD52; Tue, 11 May 2021 15:23:46 +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 4FfhXL4V5Hz4VHD; Tue, 11 May 2021 15:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8CD331A88C; Tue, 11 May 2021 15:23:46 +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 14BFNkDk075692; Tue, 11 May 2021 15:23:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BFNkpD075691; Tue, 11 May 2021 15:23:46 GMT (envelope-from git) Date: Tue, 11 May 2021 15:23:46 GMT Message-Id: <202105111523.14BFNkpD075691@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 80430c15caac - main - netinet6 tests: Fix Python warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80430c15caac0c10832455f868fa01c912996982 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:23:46 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=80430c15caac0c10832455f868fa01c912996982 commit 80430c15caac0c10832455f868fa01c912996982 Author: Kristof Provost AuthorDate: 2021-05-11 13:47:45 +0000 Commit: Kristof Provost CommitDate: 2021-05-11 15:10:42 +0000 netinet6 tests: Fix Python warning Python 3.8 warns about line 112: 'SyntaxWarning: "is" with a literal. Did you mean "=="?' Use '==' as Python suggests. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netinet6/frag6/frag6_16.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/netinet6/frag6/frag6_16.py b/tests/sys/netinet6/frag6/frag6_16.py index c38f5da4dea9..42ac8e2b4675 100644 --- a/tests/sys/netinet6/frag6/frag6_16.py +++ b/tests/sys/netinet6/frag6/frag6_16.py @@ -109,7 +109,7 @@ def main(): foffset=(int)(1288/8) mbit=1 for i in range(1,30): - if i is 29: + if i == 29: mbit=0 ip6f0n = sp.Ether() / \ sp.IPv6(src=args.src[0], dst=args.to[0]) / \ From owner-dev-commits-src-all@freebsd.org Tue May 11 15:40:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2EA163C3D6; Tue, 11 May 2021 15:40:32 +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 4Ffhvh6YjXz4W8f; Tue, 11 May 2021 15:40:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D41DF1A46B; Tue, 11 May 2021 15:40:32 +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 14BFeW5X098033; Tue, 11 May 2021 15:40:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BFeWG9098032; Tue, 11 May 2021 15:40:32 GMT (envelope-from git) Date: Tue, 11 May 2021 15:40:32 GMT Message-Id: <202105111540.14BFeWG9098032@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 802637be0645 - main - ipfw.8: Fix table example MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 802637be06457c7593692bdf79f8466fa5f54d4a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:40:33 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=802637be06457c7593692bdf79f8466fa5f54d4a commit 802637be06457c7593692bdf79f8466fa5f54d4a Author: Lutz Donnerhacke AuthorDate: 2021-05-10 18:31:52 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-11 15:38:26 +0000 ipfw.8: Fix table example Fix some erronous lines in the example section. PR: 248943 Submitted by: Jose Luis Duran MFC after: 2 weeks Reviewers: ae, manpages (gbe) Differential Revision: https://reviews.freebsd.org/D30191 --- sbin/ipfw/ipfw.8 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index 439738a54e34..2380c6c344ec 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 7, 2021 +.Dd May 11, 2021 .Dt IPFW 8 .Os .Sh NAME @@ -4451,11 +4451,11 @@ Using the .Cm fwd action, the table entries may include hostnames and IP addresses. .Pp -.Dl "ipfw table T2 create type addr ftype ip" +.Dl "ipfw table T2 create type addr valtype ipv4" .Dl "ipfw table T2 add 192.168.2.0/24 10.23.2.1" -.Dl "ipfw table T21 add 192.168.0.0/27 router1.dmz" +.Dl "ipfw table T2 add 192.168.0.0/27 router1.dmz" .Dl "..." -.Dl "ipfw add 100 fwd tablearg ip from any to table(1)" +.Dl "ipfw add 100 fwd tablearg ip from any to 'table(T2)'" .Pp In the following example per-interface firewall is created: .Pp From owner-dev-commits-src-all@freebsd.org Tue May 11 19:02:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E6CE642483; Tue, 11 May 2021 19:02:38 +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 4FfnNt39Txz4hPx; Tue, 11 May 2021 19:02:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5FE801D35F; Tue, 11 May 2021 19:02:38 +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 14BJ2ceX069956; Tue, 11 May 2021 19:02:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BJ2c6Z069955; Tue, 11 May 2021 19:02:38 GMT (envelope-from git) Date: Tue, 11 May 2021 19:02:38 GMT Message-Id: <202105111902.14BJ2c6Z069955@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 904390b4787d - main - Implement read-only VM_SHARED flag in the LinuxKPI. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 19:02:38 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c commit 904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c Author: Hans Petter Selasky AuthorDate: 2021-05-11 18:49:13 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-11 19:00:14 +0000 Implement read-only VM_SHARED flag in the LinuxKPI. For use by mmap(2) callbacks. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/compat/linuxkpi/common/include/linux/mm.h | 1 + sys/compat/linuxkpi/common/src/linux_compat.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index f6f53afbc8a9..68a0f34acaf3 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -63,6 +63,7 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0); #define VM_DONTCOPY (1 << 14) #define VM_DONTEXPAND (1 << 15) #define VM_DONTDUMP (1 << 16) +#define VM_SHARED (1 << 17) #define VMA_MAX_PREFAULT_RECORD 1 diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 630ee30e73e2..ee41e5e2b30d 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1232,7 +1232,7 @@ linux_file_kqfilter(struct file *file, struct knote *kn) static int linux_file_mmap_single(struct file *fp, const struct file_operations *fop, vm_ooffset_t *offset, vm_size_t size, struct vm_object **object, - int nprot, struct thread *td) + int nprot, bool is_shared, struct thread *td) { struct task_struct *task; struct vm_area_struct *vmap; @@ -1267,6 +1267,8 @@ linux_file_mmap_single(struct file *fp, const struct file_operations *fop, vmap->vm_pgoff = *offset / PAGE_SIZE; vmap->vm_pfn = 0; vmap->vm_flags = vmap->vm_page_prot = (nprot & VM_PROT_ALL); + if (is_shared) + vmap->vm_flags |= VM_SHARED; vmap->vm_ops = NULL; vmap->vm_file = get_file(filp); vmap->vm_mm = mm; @@ -1601,21 +1603,21 @@ linux_file_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *cred, static int linux_file_mmap_sub(struct thread *td, vm_size_t objsize, vm_prot_t prot, - vm_prot_t *maxprotp, int *flagsp, struct file *fp, + vm_prot_t maxprot, int flags, struct file *fp, vm_ooffset_t *foff, const struct file_operations *fop, vm_object_t *objp) { /* * Character devices do not provide private mappings * of any kind: */ - if ((*maxprotp & VM_PROT_WRITE) == 0 && + if ((maxprot & VM_PROT_WRITE) == 0 && (prot & VM_PROT_WRITE) != 0) return (EACCES); - if ((*flagsp & (MAP_PRIVATE | MAP_COPY)) != 0) + if ((flags & (MAP_PRIVATE | MAP_COPY)) != 0) return (EINVAL); return (linux_file_mmap_single(fp, fop, foff, objsize, objp, - (int)prot, td)); + (int)prot, (flags & MAP_SHARED) ? true : false, td)); } static int @@ -1673,7 +1675,7 @@ linux_file_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size maxprot &= cap_maxprot; linux_get_fop(filp, &fop, &ldev); - error = linux_file_mmap_sub(td, size, prot, &maxprot, &flags, fp, + error = linux_file_mmap_sub(td, size, prot, maxprot, flags, fp, &foff, fop, &object); if (error != 0) goto out; From owner-dev-commits-src-all@freebsd.org Tue May 11 19:02:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8D8A642484; Tue, 11 May 2021 19:02:39 +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 4FfnNv57Crz4h4t; Tue, 11 May 2021 19:02:39 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8A6021D360; Tue, 11 May 2021 19:02:39 +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 14BJ2dum069977; Tue, 11 May 2021 19:02:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BJ2dqR069976; Tue, 11 May 2021 19:02:39 GMT (envelope-from git) Date: Tue, 11 May 2021 19:02:39 GMT Message-Id: <202105111902.14BJ2dqR069976@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 67807f5066a0 - main - cdev_del() should only put it's kernel object in the LinuxKPI. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 67807f5066a012254da9a4535c0f225377afb66d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 19:02:40 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=67807f5066a012254da9a4535c0f225377afb66d commit 67807f5066a012254da9a4535c0f225377afb66d Author: Hans Petter Selasky AuthorDate: 2021-05-11 18:51:35 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-11 19:00:23 +0000 cdev_del() should only put it's kernel object in the LinuxKPI. The destructor takes care of the rest. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/compat/linuxkpi/common/include/linux/cdev.h | 4 ---- sys/compat/linuxkpi/common/src/linux_compat.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/cdev.h b/sys/compat/linuxkpi/common/include/linux/cdev.h index 2a472da91866..bdfb7e76c9a7 100644 --- a/sys/compat/linuxkpi/common/include/linux/cdev.h +++ b/sys/compat/linuxkpi/common/include/linux/cdev.h @@ -135,13 +135,9 @@ cdev_add_ext(struct linux_cdev *cdev, dev_t dev, uid_t uid, gid_t gid, int mode) return (0); } -void linux_destroy_dev(struct linux_cdev *); - static inline void cdev_del(struct linux_cdev *cdev) { - - linux_destroy_dev(cdev); kobject_put(&cdev->kobj); } diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index ee41e5e2b30d..dcbbc3a80b8a 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -115,6 +115,7 @@ MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat"); #undef cdev #define RB_ROOT(head) (head)->rbh_root +static void linux_destroy_dev(struct linux_cdev *); static void linux_cdev_deref(struct linux_cdev *ldev); static struct vm_area_struct *linux_cdev_handle_find(void *handle); @@ -2243,7 +2244,7 @@ linux_cdev_static_release(struct kobject *kobj) kobject_put(kobj->parent); } -void +static void linux_destroy_dev(struct linux_cdev *ldev) { From owner-dev-commits-src-all@freebsd.org Tue May 11 19:02:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 46702642458; Tue, 11 May 2021 19:02:41 +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 4FfnNx05PPz4h50; Tue, 11 May 2021 19:02:40 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B03361D878; Tue, 11 May 2021 19:02:40 +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 14BJ2eSW069998; Tue, 11 May 2021 19:02:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BJ2e8K069997; Tue, 11 May 2021 19:02:40 GMT (envelope-from git) Date: Tue, 11 May 2021 19:02:40 GMT Message-Id: <202105111902.14BJ2e8K069997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: b8f113cab91f - main - Implement cdev_device_add() and cdev_device_del() in the LinuxKPI. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8f113cab91f288e5d5e29d21184d1601b87cfdd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 19:02:41 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=b8f113cab91f288e5d5e29d21184d1601b87cfdd commit b8f113cab91f288e5d5e29d21184d1601b87cfdd Author: Hans Petter Selasky AuthorDate: 2021-05-11 18:51:59 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-11 19:00:23 +0000 Implement cdev_device_add() and cdev_device_del() in the LinuxKPI. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/compat/linuxkpi/common/include/linux/cdev.h | 11 ++++++- sys/compat/linuxkpi/common/src/linux_compat.c | 38 ++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/cdev.h b/sys/compat/linuxkpi/common/include/linux/cdev.h index bdfb7e76c9a7..39a65472e921 100644 --- a/sys/compat/linuxkpi/common/include/linux/cdev.h +++ b/sys/compat/linuxkpi/common/include/linux/cdev.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2021 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ #include +struct device; struct file_operations; struct inode; struct module; @@ -143,6 +144,14 @@ cdev_del(struct linux_cdev *cdev) struct linux_cdev *linux_find_cdev(const char *name, unsigned major, unsigned minor); +int linux_cdev_device_add(struct linux_cdev *, struct device *); +void linux_cdev_device_del(struct linux_cdev *, struct device *); + +#define cdev_device_add(...) \ + linux_cdev_device_add(__VA_ARGS__) +#define cdev_device_del(...) \ + linux_cdev_device_del(__VA_ARGS__) + #define cdev linux_cdev #endif /* _LINUX_CDEV_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index dcbbc3a80b8a..a8f090ed0bd5 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2018 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2021 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -2244,6 +2244,42 @@ linux_cdev_static_release(struct kobject *kobj) kobject_put(kobj->parent); } +int +linux_cdev_device_add(struct linux_cdev *ldev, struct device *dev) +{ + int ret; + + if (dev->devt != 0) { + /* Set parent kernel object. */ + ldev->kobj.parent = &dev->kobj; + + /* + * Unlike Linux we require the kobject of the + * character device structure to have a valid name + * before calling this function: + */ + if (ldev->kobj.name == NULL) + return (-EINVAL); + + ret = cdev_add(ldev, dev->devt, 1); + if (ret) + return (ret); + } + ret = device_add(dev); + if (ret != 0 && dev->devt != 0) + cdev_del(ldev); + return (ret); +} + +void +linux_cdev_device_del(struct linux_cdev *ldev, struct device *dev) +{ + device_del(dev); + + if (dev->devt != 0) + cdev_del(ldev); +} + static void linux_destroy_dev(struct linux_cdev *ldev) { From owner-dev-commits-src-all@freebsd.org Tue May 11 21:36:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 30BAE645E89; Tue, 11 May 2021 21:36:36 +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 4FfrpX0qr3z4pWb; Tue, 11 May 2021 21:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0F6B51F72D; Tue, 11 May 2021 21:36:36 +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 14BLaZ4F070273; Tue, 11 May 2021 21:36:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BLaZwn070272; Tue, 11 May 2021 21:36:35 GMT (envelope-from git) Date: Tue, 11 May 2021 21:36:35 GMT Message-Id: <202105112136.14BLaZwn070272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 1a04f0156c4e - main - cryptodev: Fix some input validation bugs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a04f0156c4e6abfc01d5841341a94179f317f31 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 21:36:36 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1a04f0156c4e6abfc01d5841341a94179f317f31 commit 1a04f0156c4e6abfc01d5841341a94179f317f31 Author: Mark Johnston AuthorDate: 2021-05-11 21:36:12 +0000 Commit: Mark Johnston CommitDate: 2021-05-11 21:36:12 +0000 cryptodev: Fix some input validation bugs - When we do not have a separate IV, make sure that the IV length specified by the session is not larger than the payload size. - Disallow AEAD requests without a separate IV. crp_sanity() asserts that CRYPTO_F_IV_SEPARATE is set for AEAD requests, and some (but not all) drivers require it. - Return EINVAL for AEAD requests if an IV is specified but the transform does not expect one. Reported by: syzbot+c9e8f6ff5cb7fa6a1250@syzkaller.appspotmail.com Reported by: syzbot+007341439ae295cee74f@syzkaller.appspotmail.com Reported by: syzbot+46e0cc42a428b3b0a40d@syzkaller.appspotmail.com Reported by: syzbot+2c4d670173b8bdb947df@syzkaller.appspotmail.com Reported by: syzbot+220faa5eeb4d47b23877@syzkaller.appspotmail.com Reported by: syzbot+e83434b40f05843722f7@syzkaller.appspotmail.com Reviewed by: jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30154 --- sys/opencrypto/cryptodev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index f102b59b82ac..d179dd6348e5 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -878,6 +878,11 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) } crp->crp_flags |= CRYPTO_F_IV_SEPARATE; } else if (cse->ivsize != 0) { + if (crp->crp_payload_length < cse->ivsize) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } crp->crp_iv_start = 0; crp->crp_payload_start += cse->ivsize; crp->crp_payload_length -= cse->ivsize; @@ -1058,6 +1063,11 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) cse->ivsize == AES_XTS_IV_LEN) caead->ivlen = AES_XTS_IV_LEN; + if (cse->ivsize == 0) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } if (caead->ivlen != cse->ivsize) { error = EINVAL; SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); @@ -1071,10 +1081,9 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) } crp->crp_flags |= CRYPTO_F_IV_SEPARATE; } else { - crp->crp_iv_start = crp->crp_payload_start; - crp->crp_payload_start += cse->ivsize; - crp->crp_payload_length -= cse->ivsize; - dst += cse->ivsize; + error = EINVAL; + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + goto bail; } if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { From owner-dev-commits-src-all@freebsd.org Tue May 11 21:48:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BABB46461D1; Tue, 11 May 2021 21:48:34 +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 4Ffs4L4ydKz4qGy; Tue, 11 May 2021 21:48:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9D3531FB13; Tue, 11 May 2021 21:48:34 +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 14BLmYrQ083579; Tue, 11 May 2021 21:48:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BLmYwu083578; Tue, 11 May 2021 21:48:34 GMT (envelope-from git) Date: Tue, 11 May 2021 21:48:34 GMT Message-Id: <202105112148.14BLmYwu083578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: a3628327e7b6 - main - Ensure that files with no allocated blocks are trimmed to zero length. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a3628327e7b62c955e7bad9e43044cdb01984d80 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 21:48:34 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=a3628327e7b62c955e7bad9e43044cdb01984d80 commit a3628327e7b62c955e7bad9e43044cdb01984d80 Author: Kirk McKusick AuthorDate: 2021-05-11 21:51:06 +0000 Commit: Kirk McKusick CommitDate: 2021-05-11 21:52:26 +0000 Ensure that files with no allocated blocks are trimmed to zero length. UFS does not allow files to end with a hole; it requires that the last block of a file be allocated. As fsck_ffs(8) initially scans each allocated inode, it tracks the last allocated block in the inode. It then checks that the inode's size falls in the last allocated block. If the last allocated block falls before the size, a `file size beyond end of allocated file' warning is issued and the file is shortened to reference the last allocated block (to avoid having it reference a hole at its end). If the last allocated block falls after the size, a `partially truncated file' warning is issued and all blocks following the block referenced by the size are freed. Because of an incorrect unsigned comparison, this test was failing to handle files with no allocated blocks but non-zero size (which should have had their size reset to zero). Once that was fixed the test started incorrectly complaining about short symbolic links that place the link path in the inode rather than in a disk block. Because these symbolic links have a non-zero size, but no allocated blocks, fsck_ffs wanted to zero out their size. This patch has to detect and avoid changing the size of such symbolic links. Reported by: Chuck Silvers Tested by: Chuck Silvers MFC after: 1 week Sponsored by: Netflix --- sbin/fsck_ffs/pass1.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index c1f1b1ec04f5..319a324cc070 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -248,7 +248,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) off_t kernmaxfilesize; ufs2_daddr_t ndb; mode_t mode; - uintmax_t fixsize; + intmax_t size, fixsize; int j, ret, offset; if ((dp = getnextinode(inumber, rebuildcg)) == NULL) @@ -429,25 +429,37 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) } } /* + * UFS does not allow files to end with a hole; it requires that + * the last block of a file be allocated. The last allocated block + * in a file is tracked in id_lballoc. Here, we check for a size + * past the last allocated block of the file and if that is found, + * shorten the file to reference the last allocated block to avoid + * having it reference a hole at its end. + * * Soft updates will always ensure that the file size is correct * for files that contain only direct block pointers. However * soft updates does not roll back sizes for files with indirect * blocks that it has set to unallocated because their contents * have not yet been written to disk. Hence, the file can appear * to have a hole at its end because the block pointer has been - * rolled back to zero. Thus, id_lballoc tracks the last allocated - * block in the file. Here, for files that extend into indirect - * blocks, we check for a size past the last allocated block of - * the file and if that is found, shorten the file to reference - * the last allocated block to avoid having it reference a hole - * at its end. + * rolled back to zero. Thus finding a hole at the end of a file + * that is located in an indirect block receives only a warning + * while finding a hole at the end of a file in a direct block + * receives a fatal error message. */ - if (DIP(dp, di_size) > UFS_NDADDR * sblock.fs_bsize && - idesc->id_lballoc < lblkno(&sblock, DIP(dp, di_size) - 1)) { - fixsize = lblktosize(&sblock, idesc->id_lballoc + 1); - pwarn("INODE %lu: FILE SIZE %ju BEYOND END OF ALLOCATED FILE, " - "SIZE SHOULD BE %ju", (u_long)inumber, - (uintmax_t)DIP(dp, di_size), fixsize); + size = DIP(dp, di_size); + if (idesc->id_lballoc < lblkno(&sblock, size - 1) && + /* exclude embedded symbolic links */ + ((mode != IFLNK) || size >= sblock.fs_maxsymlinklen)) { + fixsize = lblktosize(&sblock, idesc->id_lballoc + 1); + if (size > UFS_NDADDR * sblock.fs_bsize) + pwarn("INODE %lu: FILE SIZE %ju BEYOND END OF " + "ALLOCATED FILE, SIZE SHOULD BE %ju", + (u_long)inumber, size, fixsize); + else + pfatal("INODE %lu: FILE SIZE %ju BEYOND END OF " + "ALLOCATED FILE, SIZE SHOULD BE %ju", + (u_long)inumber, size, fixsize); if (preen) printf(" (ADJUSTED)\n"); else if (reply("ADJUST") == 0) From owner-dev-commits-src-all@freebsd.org Tue May 11 21:56:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 50A4E628507; Tue, 11 May 2021 21:56:50 +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 4FfsFt1RwLz4t1g; Tue, 11 May 2021 21:56:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2184E1F96A; Tue, 11 May 2021 21:56:50 +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 14BLunsd002341; Tue, 11 May 2021 21:56:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BLunli002340; Tue, 11 May 2021 21:56:49 GMT (envelope-from git) Date: Tue, 11 May 2021 21:56:49 GMT Message-Id: <202105112156.14BLunli002340@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ed93deba1106 - main - Remove a write-only variable. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed93deba1106da2cd4755a61612c37bb67edc914 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 21:56:51 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ed93deba1106da2cd4755a61612c37bb67edc914 commit ed93deba1106da2cd4755a61612c37bb67edc914 Author: John Baldwin AuthorDate: 2021-05-11 21:56:23 +0000 Commit: John Baldwin CommitDate: 2021-05-11 21:56:23 +0000 Remove a write-only variable. While refactoring an earlier series of changes during review, the 'saved_data' variable stopped being used at the bottom of if_ioctl(). Suggested by: brooks Reviewed by: brooks, imp, kib Fixes: d17e0940f79f Rework compat shims in ifioctl(). Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D30197 --- sys/net/if.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index e444faa54cb0..e18ed3e275ac 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2901,7 +2901,6 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) struct ifgroupreq ifgr; struct ifmediareq ifmr; } thunk; - caddr_t saved_data; u_long saved_cmd; struct ifconf32 *ifc32; struct ifdrv32 *ifd32; @@ -2928,7 +2927,6 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) #ifdef COMPAT_FREEBSD32 saved_cmd = cmd; - saved_data = data; switch (cmd) { case SIOCGIFCONF32: ifc32 = (struct ifconf32 *)data; From owner-dev-commits-src-all@freebsd.org Tue May 11 22:59:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8830C629541; Tue, 11 May 2021 22:59:45 +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 4FftfT3Sftz4vx1; Tue, 11 May 2021 22:59:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 69B4B20971; Tue, 11 May 2021 22:59:45 +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 14BMxjK9081317; Tue, 11 May 2021 22:59:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BMxjX2081316; Tue, 11 May 2021 22:59:45 GMT (envelope-from git) Date: Tue, 11 May 2021 22:59:45 GMT Message-Id: <202105112259.14BMxjX2081316@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 9db7da1f55b3 - main - Polish source to WARNS=6 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9db7da1f55b3f793c9b0e7d8fca5fbbc26c90691 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 22:59:45 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=9db7da1f55b3f793c9b0e7d8fca5fbbc26c90691 commit 9db7da1f55b3f793c9b0e7d8fca5fbbc26c90691 Author: Poul-Henning Kamp AuthorDate: 2021-05-11 22:59:23 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-11 22:59:23 +0000 Polish source to WARNS=6 --- usr.sbin/i2c/Makefile | 2 +- usr.sbin/i2c/i2c.c | 55 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/usr.sbin/i2c/Makefile b/usr.sbin/i2c/Makefile index 9f377e6ac577..681f4b7b89d2 100644 --- a/usr.sbin/i2c/Makefile +++ b/usr.sbin/i2c/Makefile @@ -3,6 +3,6 @@ PROG= i2c MAN= i2c.8 -WARNS?= 2 +WARNS?= 6 .include diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 0fcdd56e7373..1df12cf44460 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -29,6 +29,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -36,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -122,12 +122,13 @@ skip_get_tokens(char *skip_addr, int *sk_addr, int max_index) } static int -scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr) +scan_bus(const char *dev, int skip, char *skip_addr) { + struct iiccmd cmd; struct iic_msg rdmsg; struct iic_rdwr_data rdwrdata; struct skip_range addr_range = { 0, 0 }; - int *tokens, fd, error, i, index, j; + int *tokens = NULL, fd, error, i, idx = 0, j; int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 0; uint8_t rdbyte; @@ -139,6 +140,7 @@ scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr) } if (skip) { + assert(skip_addr != NULL); len = strlen(skip_addr); if (strstr(skip_addr, "..") != NULL) { addr_range = skip_get_range(skip_addr); @@ -151,7 +153,7 @@ scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr) error = -1; goto out; } - index = skip_get_tokens(skip_addr, tokens, + idx = skip_get_tokens(skip_addr, tokens, len / 2 + 1); } @@ -166,7 +168,7 @@ scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr) start_over: if (use_read_xfer) { - fprintf(stderr, + fprintf(stderr, "Hardware may not support START/STOP scanning; " "trying less-reliable read method.\n"); } @@ -177,13 +179,15 @@ start_over: if (i >= addr_range.start && i <= addr_range.end) continue; - } else if (skip && no_range) - for (j = 0; j < index; j++) { + } else if (skip && no_range) { + assert (tokens != NULL); + for (j = 0; j < idx; j++) { if (tokens[j] == i) { do_skip = 1; break; } } + } if (do_skip) { do_skip = 0; @@ -241,6 +245,8 @@ out: close(fd); if (skip && no_range) free(tokens); + else + assert(tokens == NULL); if (error) { fprintf(stderr, "Error scanning I2C controller (%s): %s\n", @@ -251,8 +257,9 @@ out: } static int -reset_bus(struct iiccmd cmd, char *dev) +reset_bus(const char *dev) { + struct iiccmd cmd; int fd, error; fd = open(dev, O_RDWR); @@ -295,11 +302,12 @@ prepare_buf(int size, uint32_t off) } static int -i2c_write(char *dev, struct options i2c_opt, char *i2c_buf) +i2c_write(const char *dev, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; int error, fd, bufsize; - char *err_msg, *buf; + char *buf; + const char *err_msg; fd = open(dev, O_RDWR); if (fd == -1) { @@ -404,7 +412,7 @@ i2c_write(char *dev, struct options i2c_opt, char *i2c_buf) break; case I2C_MODE_NONE: /* fall through */ - default: + default: buf = realloc(buf, bufsize + i2c_opt.count); if (buf == NULL) { err_msg = "error: data malloc"; @@ -448,11 +456,12 @@ err2: } static int -i2c_read(char *dev, struct options i2c_opt, char *i2c_buf) +i2c_read(const char *dev, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; int fd, error, bufsize; - char *err_msg, data = 0, *buf; + char data = 0, *buf; + const char *err_msg; fd = open(dev, O_RDWR); if (fd == -1) @@ -556,7 +565,7 @@ err2: * driver to be handled as a single transfer. */ static int -i2c_rdwr_transfer(char *dev, struct options i2c_opt, char *i2c_buf) +i2c_rdwr_transfer(const char *dev, struct options i2c_opt, char *i2c_buf) { struct iic_msg msgs[2]; struct iic_rdwr_data xfer; @@ -613,9 +622,9 @@ i2c_rdwr_transfer(char *dev, struct options i2c_opt, char *i2c_buf) int main(int argc, char** argv) { - struct iiccmd cmd; struct options i2c_opt; - char *dev, *skip_addr, *i2c_buf; + char *skip_addr = NULL, *i2c_buf; + const char *dev; int error, chunk_size, i, j, ch; errno = 0; @@ -700,6 +709,10 @@ main(int argc, char** argv) } argc -= optind; argv += optind; + if (argc > 0) { + fprintf(stderr, "Too many arguments\n"); + usage(); + } /* Set default mode if option -m is not specified */ if (i2c_opt.mode == I2C_MODE_NOTSET) { @@ -722,20 +735,20 @@ main(int argc, char** argv) if ((i2c_opt.addr_set == 0) || !(i2c_opt.width == 0 || i2c_opt.width == 8 || i2c_opt.width == 16)) - usage(); + usage(); } if (i2c_opt.verbose) fprintf(stderr, "dev: %s, addr: 0x%x, r/w: %c, " - "offset: 0x%02x, width: %u, count: %u\n", dev, + "offset: 0x%02x, width: %d, count: %d\n", dev, i2c_opt.addr >> 1, i2c_opt.dir, i2c_opt.off, i2c_opt.width, i2c_opt.count); if (i2c_opt.scan) - exit(scan_bus(cmd, dev, i2c_opt.skip, skip_addr)); + exit(scan_bus(dev, i2c_opt.skip, skip_addr)); if (i2c_opt.reset) - exit(reset_bus(cmd, dev)); + exit(reset_bus(dev)); i2c_buf = malloc(i2c_opt.count); if (i2c_buf == NULL) @@ -746,7 +759,7 @@ main(int argc, char** argv) */ if (i2c_opt.dir == 'w') { if (i2c_opt.verbose && !i2c_opt.binary) - fprintf(stderr, "Enter %u bytes of data: ", + fprintf(stderr, "Enter %d bytes of data: ", i2c_opt.count); for (i = 0; i < i2c_opt.count; i++) { ch = getchar(); From owner-dev-commits-src-all@freebsd.org Tue May 11 23:07:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61FD4629B46; Tue, 11 May 2021 23:07:59 +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 4Fftqz2LNQz3CWW; Tue, 11 May 2021 23:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3ECE520B0F; Tue, 11 May 2021 23:07:59 +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 14BN7x77094910; Tue, 11 May 2021 23:07:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BN7xUk094908; Tue, 11 May 2021 23:07:59 GMT (envelope-from git) Date: Tue, 11 May 2021 23:07:59 GMT Message-Id: <202105112307.14BN7xUk094908@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: b2ae176d914a - main - Sixteen bit I2c addresses are always little endian. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2ae176d914acd63247e24d7e23dbe8f239fbfb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 23:07:59 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=b2ae176d914acd63247e24d7e23dbe8f239fbfb0 commit b2ae176d914acd63247e24d7e23dbe8f239fbfb0 Author: Poul-Henning Kamp AuthorDate: 2021-05-11 23:07:06 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-11 23:07:06 +0000 Sixteen bit I2c addresses are always little endian. --- usr.sbin/i2c/i2c.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 1df12cf44460..23613ee744f9 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -570,22 +571,18 @@ i2c_rdwr_transfer(const char *dev, struct options i2c_opt, char *i2c_buf) struct iic_msg msgs[2]; struct iic_rdwr_data xfer; int fd, i; - union { - uint8_t buf[2]; - uint8_t off8; - uint16_t off16; - } off; + uint8_t off_buf[2]; i = 0; if (i2c_opt.width > 0) { msgs[i].flags = IIC_M_WR | IIC_M_NOSTOP; msgs[i].slave = i2c_opt.addr; - msgs[i].buf = off.buf; + msgs[i].buf = off_buf; if (i2c_opt.width == 8) { - off.off8 = (uint8_t)i2c_opt.off; + off_buf[0] = i2c_opt.off; msgs[i].len = 1; } else { - off.off16 = (uint16_t)i2c_opt.off; + le16enc(off_buf, i2c_opt.off); msgs[i].len = 2; } ++i; From owner-dev-commits-src-all@freebsd.org Tue May 11 23:15:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4594262A28E; Tue, 11 May 2021 23:15:17 +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 4Ffv0P1Z8sz3D3H; Tue, 11 May 2021 23:15:17 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 28B7620F08; Tue, 11 May 2021 23:15:17 +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 14BNFHYO008390; Tue, 11 May 2021 23:15:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BNFHMt008389; Tue, 11 May 2021 23:15:17 GMT (envelope-from git) Date: Tue, 11 May 2021 23:15:17 GMT Message-Id: <202105112315.14BNFHMt008389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: a7f81b488df2 - main - libvmm: explicitly save and restore errno in vm_open() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a7f81b488df2d4a5dcd785b4112e04ffb6ca0442 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 23:15:17 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=a7f81b488df2d4a5dcd785b4112e04ffb6ca0442 commit a7f81b488df2d4a5dcd785b4112e04ffb6ca0442 Author: Robert Wing AuthorDate: 2021-03-11 19:27:43 +0000 Commit: Robert Wing CommitDate: 2021-05-11 23:11:52 +0000 libvmm: explicitly save and restore errno in vm_open() In commit 6bb140e3ca895a14, vm_destroy() was replaced with free() to preserve errno. However, it's possible that free() may change the errno as well. Keep the free() call, but explicitly save and restore errno. Noted by: jhb Fixes: 6bb140e3ca895a14 --- lib/libvmmapi/vmmapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 7faa2fc545ea..5810274c9a73 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -118,6 +118,7 @@ struct vmctx * vm_open(const char *name) { struct vmctx *vm; + int saved_errno; vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); assert(vm != NULL); @@ -133,7 +134,9 @@ vm_open(const char *name) return (vm); err: + saved_errno = errno; free(vm); + errno = saved_errno; return (NULL); } From owner-dev-commits-src-all@freebsd.org Wed May 12 00:12:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBE3062B895; Wed, 12 May 2021 00:12:54 +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 4FfwGt4qT1z3GRw; Wed, 12 May 2021 00:12:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9885821758; Wed, 12 May 2021 00:12:54 +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 14C0CsnT087201; Wed, 12 May 2021 00:12:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C0CsCo087200; Wed, 12 May 2021 00:12:54 GMT (envelope-from git) Date: Wed, 12 May 2021 00:12:54 GMT Message-Id: <202105120012.14C0CsCo087200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: 6fa8a157705d - stable/13 - autofs: best effort to maintain mounttab and mountdtab MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6fa8a157705debef78e86de378f8a929207d62dc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 00:12:54 -0000 The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=6fa8a157705debef78e86de378f8a929207d62dc commit 6fa8a157705debef78e86de378f8a929207d62dc Author: Robert Wing AuthorDate: 2021-02-17 07:51:38 +0000 Commit: Robert Wing CommitDate: 2021-05-11 23:48:44 +0000 autofs: best effort to maintain mounttab and mountdtab When an automounted filesystem is successfully unmounted, call rpc.umntall(8) with the -k flag. rpc.umntall(8) is used to clean up /var/db/mounttab on the client and /var/db/mountdtab on the server. This is only useful for NFSv3. PR: 251906 Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D27801 (cherry picked from commit 88e531f38c2412bf030f4e8dd563efc45b70797e) --- usr.sbin/autofs/automount.c | 2 ++ usr.sbin/autofs/autounmountd.c | 3 ++- usr.sbin/autofs/common.c | 13 +++++++++++++ usr.sbin/autofs/common.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index e28129eee5b8..cd29c910bce2 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -80,6 +80,8 @@ unmount_by_statfs(const struct statfs *sb, bool force) free(fsid_str); if (error != 0) log_warn("cannot unmount %s", sb->f_mntonname); + else + rpc_umntall(); return (error); } diff --git a/usr.sbin/autofs/autounmountd.c b/usr.sbin/autofs/autounmountd.c index 92bc8a03c96f..33b3a366cb8d 100644 --- a/usr.sbin/autofs/autounmountd.c +++ b/usr.sbin/autofs/autounmountd.c @@ -170,7 +170,8 @@ unmount_by_fsid(const fsid_t fsid, const char *mountpoint) log_warn("cannot unmount %s (%s)", mountpoint, fsid_str); } - } + } else + rpc_umntall(); free(fsid_str); diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 7c8df4205a86..4581e5c4f2f9 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -1204,6 +1204,19 @@ lesser_daemon(void) } } +/* + * Applicable to NFSv3 only, see rpc.umntall(8). + */ +void +rpc_umntall(void) +{ + FILE *f; + + f = auto_popen("rpc.umntall", "-k", NULL); + assert(f != NULL); + auto_pclose(f); +} + int main(int argc, char **argv) { diff --git a/usr.sbin/autofs/common.h b/usr.sbin/autofs/common.h index 34257c1caeff..e68a0be5f7c8 100644 --- a/usr.sbin/autofs/common.h +++ b/usr.sbin/autofs/common.h @@ -96,6 +96,7 @@ char *defined_expand(const char *string); void defined_init(void); void defined_parse_and_add(char *def); void lesser_daemon(void); +void rpc_umntall(void); int main_automount(int argc, char **argv); int main_automountd(int argc, char **argv); From owner-dev-commits-src-all@freebsd.org Wed May 12 02:03:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF84162DBDB; Wed, 12 May 2021 02:03:25 +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 4FfykP6TR0z3LBm; Wed, 12 May 2021 02:03:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D14ED23020; Wed, 12 May 2021 02:03:25 +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 14C23PEw033395; Wed, 12 May 2021 02:03:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C23PQx033394; Wed, 12 May 2021 02:03:25 GMT (envelope-from git) Date: Wed, 12 May 2021 02:03:25 GMT Message-Id: <202105120203.14C23PQx033394@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: 30659d1dcbcc - main - Add support for adding default routes for other FIBs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 30659d1dcbcc92016833f0956461314ed501ac83 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:03:26 -0000 The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=30659d1dcbcc92016833f0956461314ed501ac83 commit 30659d1dcbcc92016833f0956461314ed501ac83 Author: Andrew Fengler AuthorDate: 2021-05-12 01:59:10 +0000 Commit: Allan Jude CommitDate: 2021-05-12 01:59:10 +0000 Add support for adding default routes for other FIBs Make rc.d/routing read defaultrouter_fibN and ipv6_defaultrouter_fibN, and set it as the default gateway for FIB N, where N is from 1 to (net.fibs - 1) This allows adding gateways for multiple FIBs in the same format as the main gateway. (FIB 0) Reviewed by: olivier, rgrimes, bcr (man page) Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D22706 --- libexec/rc/rc.conf | 2 ++ libexec/rc/rc.d/routing | 38 ++++++++++++++++++++++++++++++++++++-- share/man/man5/rc.conf.5 | 11 ++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 998cd3fd14d6..d941a20b6e07 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -437,6 +437,7 @@ bsnmpd_flags="" # Flags for bsnmpd. ### Network routing options: ### defaultrouter="NO" # Set to default gateway (or NO). +#defaultrouter_fibN="192.0.2.1" # Use this form to set a gateway for FIB N static_arp_pairs="" # Set to static ARP list (or leave empty). static_ndp_pairs="" # Set to static NDP list (or leave empty). static_routes="" # Set to static route list (or leave empty). @@ -499,6 +500,7 @@ ipv6_activate_all_interfaces="NO" # If NO, interfaces which have no # reason. ipv6_defaultrouter="NO" # Set to IPv6 default gateway (or NO). #ipv6_defaultrouter="2002:c058:6301::" # Use this for 6to4 (RFC 3068) +#ipv6_defaultrouter_fibN="2001:db8::" # Use this form to set a gateway for FIB N ipv6_static_routes="" # Set to static route list (or leave empty). #ipv6_static_routes="xxx" # An example to set fec0:0000:0000:0006::/64 # route toward loopback interface. diff --git a/libexec/rc/rc.d/routing b/libexec/rc/rc.d/routing index 043c5b15fbaa..37b3da0f0cef 100755 --- a/libexec/rc/rc.d/routing +++ b/libexec/rc/rc.d/routing @@ -140,11 +140,12 @@ get_fibmod() static_inet() { - local _action _if _skip _fibmod + local _action _if _skip _fibmod _fibs _action=$1 _if=$2 _fibmod=`get_fibmod` + _fibs=$((`${SYSCTL_N} net.fibs` - 1)) # Provide loopback route in all routing tables. This has to come # first so that any following routes can be added. @@ -161,6 +162,22 @@ static_inet() ;; esac + # Add default routes for fibs + if [ ${_fibs} -gt 0 ]; then + for _fibnum in `jot ${_fibs}` ; do + eval _fib_gw=\${defaultrouter_fib${_fibnum}} + case ${_fib_gw} in + [Nn][Oo] | '') + ;; + *) + static_routes="${static_routes} _default_fib${_fibnum}" + eval route__default_fib${fibnum}="'default ${_fib_gw} -fib ${_fibnum}'" + ;; + esac + done + fi + + # Install configured routes. if [ -n "${static_routes}" ]; then for i in ${static_routes}; do @@ -185,11 +202,12 @@ static_inet() static_inet6() { - local _action _if _skip fibmod allfibs + local _action _if _skip fibmod _fibs _action=$1 _if=$2 fibmod=`get_fibmod` + _fibs=$((`${SYSCTL_N} net.fibs` - 1)) # Add pre-defined static routes first. ipv6_static_routes="_v4mapped _v4compat ${ipv6_static_routes}" @@ -221,6 +239,22 @@ static_inet6() ;; esac + # Add default routes for fibs + if [ ${_fibs} -gt 0 ]; then + for _fibnum in `jot ${_fibs}` ; do + eval _fib_gw=\${ipv6_defaultrouter_fib${_fibnum}} + case ${_fib_gw} in + [Nn][Oo] | '') + ;; + *) + ipv6_static_routes="${static_routes} _default_fib${_fibnum}" + eval ipv6_route__default_fib${fibnum}="'default ${_fib_gw} -fib ${_fibnum}'" + ;; + esac + done + fi + + # Install configured routes. if [ -n "${ipv6_static_routes}" ]; then for i in ${ipv6_static_routes}; do diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 01c4a8436496..6baf3b22b024 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2021 +.Dd May 11, 2021 .Dt RC.CONF 5 .Os .Sh NAME @@ -2818,10 +2818,19 @@ If not set to create a default route to this host name or IP address (use an IP address if this router is also required to get to the name server!). +.It Va defaultrouter_fibN +.Pq Vt str +If not set to +.Dq Li NO , +create a default route in FIB N to this host name or IP address. .It Va ipv6_defaultrouter .Pq Vt str The IPv6 equivalent of .Va defaultrouter . +.It Va ipv6_defaultrouter_fibN +.Pq Vt str +The IPv6 equivalent of +.Va defaultrouter_fibN . .It Va static_arp_pairs .Pq Vt str Set to the list of static ARP pairs that are to be added at system From owner-dev-commits-src-all@freebsd.org Wed May 12 02:19:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C6DF362DE80; Wed, 12 May 2021 02:19:10 +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 4Ffz4Z5JQzz3LL4; Wed, 12 May 2021 02:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A90872328D; Wed, 12 May 2021 02:19:10 +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 14C2JASC046632; Wed, 12 May 2021 02:19:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C2JAxG046631; Wed, 12 May 2021 02:19:10 GMT (envelope-from git) Date: Wed, 12 May 2021 02:19:10 GMT Message-Id: <202105120219.14C2JAxG046631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 7e35a8a28c6f - stable/13 - nfscl: return delegations in the NFS VOP_RECLAIM() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7e35a8a28c6f719ad4e8b8e33bbc0b7a5901e008 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:19:10 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=7e35a8a28c6f719ad4e8b8e33bbc0b7a5901e008 commit 7e35a8a28c6f719ad4e8b8e33bbc0b7a5901e008 Author: Rick Macklem AuthorDate: 2021-04-26 00:57:55 +0000 Commit: Rick Macklem CommitDate: 2021-05-12 02:15:26 +0000 nfscl: return delegations in the NFS VOP_RECLAIM() After a vnode is recycled it can no longer be acquired via vfs_hash_get() and, as such, a delegation for the vnode cannot be recalled. In the unlikely event that a delegation still exists when the vnode is being recycled, return the delegation since it will no longer be recallable. Until you have this patch in your NFSv4 client, you should consider avoiding the use of delegations. (cherry picked from commit aad780464fad1e32c97316515a4044d661413a6b) --- sys/fs/nfs/nfs_var.h | 1 + sys/fs/nfsclient/nfs_clnode.c | 10 ++++++++- sys/fs/nfsclient/nfs_clstate.c | 49 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 23ba0e3893db..f23d56050449 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -604,6 +604,7 @@ void nfscl_lockinit(struct nfsv4lock *); void nfscl_lockexcl(struct nfsv4lock *, void *); void nfscl_lockunlock(struct nfsv4lock *); void nfscl_lockderef(struct nfsv4lock *); +void nfscl_delegreturnvp(vnode_t, NFSPROC_T *); void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *); void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *, int); diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index a59b96bf3c8b..43c2286726f7 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -303,7 +303,7 @@ ncl_reclaim(struct vop_reclaim_args *ap) ncl_releasesillyrename(vp, td); NFSUNLOCKNODE(np); - if (NFS_ISV4(vp) && vp->v_type == VREG) + if (NFS_ISV4(vp) && vp->v_type == VREG) { /* * We can now safely close any remaining NFSv4 Opens for * this file. Most opens will have already been closed by @@ -311,6 +311,14 @@ ncl_reclaim(struct vop_reclaim_args *ap) * called, so we need to do it again here. */ (void) nfsrpc_close(vp, 1, td); + /* + * It it unlikely a delegation will still exist, but + * if one does, it must be returned before calling + * vfs_hash_remove(), since it cannot be recalled once the + * nfs node is no longer available. + */ + nfscl_delegreturnvp(vp, td); + } vfs_hash_remove(vp); diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 6cff58331c97..bbc1c6ccbc2f 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -152,7 +152,8 @@ static int nfscl_trylock(struct nfsmount *, vnode_t , u_int8_t *, struct ucred *, NFSPROC_T *); static int nfsrpc_reopen(struct nfsmount *, u_int8_t *, int, u_int32_t, struct nfsclopen *, struct nfscldeleg **, struct ucred *, NFSPROC_T *); -static void nfscl_freedeleg(struct nfscldeleghead *, struct nfscldeleg *); +static void nfscl_freedeleg(struct nfscldeleghead *, struct nfscldeleg *, + bool); static int nfscl_errmap(struct nfsrv_descript *, u_int32_t); static void nfscl_cleanup_common(struct nfsclclient *, u_int8_t *); static int nfscl_recalldeleg(struct nfsclclient *, struct nfsmount *, @@ -1622,12 +1623,13 @@ nfscl_cleandeleg(struct nfscldeleg *dp) * Free a delegation. */ static void -nfscl_freedeleg(struct nfscldeleghead *hdp, struct nfscldeleg *dp) +nfscl_freedeleg(struct nfscldeleghead *hdp, struct nfscldeleg *dp, bool freeit) { TAILQ_REMOVE(hdp, dp, nfsdl_list); LIST_REMOVE(dp, nfsdl_hash); - free(dp, M_NFSCLDELEG); + if (freeit) + free(dp, M_NFSCLDELEG); nfsstatsv1.cldelegates--; nfscl_delegcnt--; } @@ -1725,7 +1727,7 @@ nfscl_expireclient(struct nfsclclient *clp, struct nfsmount *nmp, printf("nfsv4 expired locks lost\n"); } nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); dp = ndp; } if (!TAILQ_EMPTY(&clp->nfsc_deleg)) @@ -2257,7 +2259,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, * away. Ouch!! */ nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } else { LIST_INSERT_HEAD(&extra_open, nop, nfso_list); } @@ -3280,11 +3282,40 @@ nfscl_delegreturnall(struct nfsclclient *clp, NFSPROC_T *p) TAILQ_FOREACH_SAFE(dp, &clp->nfsc_deleg, nfsdl_list, ndp) { nfscl_cleandeleg(dp); (void) nfscl_trydelegreturn(dp, cred, clp->nfsc_nmp, p); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } NFSFREECRED(cred); } +/* + * Return any delegation for this vp. + */ +void +nfscl_delegreturnvp(vnode_t vp, NFSPROC_T *p) +{ + struct nfsclclient *clp; + struct nfscldeleg *dp; + struct ucred *cred; + struct nfsnode *np; + + np = VTONFS(vp); + cred = newnfs_getcred(); + NFSLOCKCLSTATE(); + clp = VFSTONFS(vp->v_mount)->nm_clp; + dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, + np->n_fhp->nfh_len); + if (dp != NULL) { + nfscl_cleandeleg(dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, false); + NFSUNLOCKCLSTATE(); + newnfs_copycred(&dp->nfsdl_cred, cred); + nfscl_trydelegreturn(dp, cred, clp->nfsc_nmp, p); + free(dp, M_NFSCLDELEG); + } else + NFSUNLOCKCLSTATE(); + NFSFREECRED(cred); +} + /* * Do a callback RPC. */ @@ -4515,7 +4546,7 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) *stp = dp->nfsdl_stateid; retcnt = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } if (igotlock) nfsv4_unlock(&clp->nfsc_lock, 0); @@ -4615,7 +4646,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, retcnt++; *gotfdp = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } if (igotlock) { nfsv4_unlock(&clp->nfsc_lock, 0); @@ -4651,7 +4682,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, retcnt++; *gottdp = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } } NFSUNLOCKCLSTATE(); From owner-dev-commits-src-all@freebsd.org Wed May 12 02:22:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1300F62DDED; Wed, 12 May 2021 02:22:05 +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 4Ffz7x04tLz3Ltn; Wed, 12 May 2021 02:22:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E9ED42329F; Wed, 12 May 2021 02:22:04 +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 14C2M4HM055976; Wed, 12 May 2021 02:22:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C2M4uW055975; Wed, 12 May 2021 02:22:04 GMT (envelope-from git) Date: Wed, 12 May 2021 02:22:04 GMT Message-Id: <202105120222.14C2M4uW055975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: f6bc043b7a16 - stable/13 - nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f6bc043b7a16529fa475b1759011a1bdf83f9652 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:22:05 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f6bc043b7a16529fa475b1759011a1bdf83f9652 commit f6bc043b7a16529fa475b1759011a1bdf83f9652 Author: Rick Macklem AuthorDate: 2021-04-28 00:30:16 +0000 Commit: Rick Macklem CommitDate: 2021-05-12 02:18:17 +0000 nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp() Commit aad780464fad added a function called nfscl_delegreturnvp() to return delegations during the NFS VOP_RECLAIM(). The function erroneously assumed that nm_clp would be non-NULL. It will be NULL for NFSV4.0 mounts until a regular file is opened. It will also be NULL during vflush() in nfs_unmount() for a forced dismount. This patch adds a check for clp == NULL to fix this. Also, since it makes no sense to call nfscl_delegreturnvp() during a forced dismount, the patch adds a check for that case and does not do the call during forced dismounts. PR: 255436 (cherry picked from commit f6fec55fe30088bbefd3efe70b62565399a7b9b8) --- sys/fs/nfsclient/nfs_clnode.c | 9 ++++++++- sys/fs/nfsclient/nfs_clstate.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index 43c2286726f7..1c0e855ff5a9 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -289,8 +289,10 @@ ncl_reclaim(struct vop_reclaim_args *ap) struct nfsnode *np = VTONFS(vp); struct nfsdmap *dp, *dp2; struct thread *td; + struct mount *mp; td = curthread; + mp = vp->v_mount; /* * If the NLM is running, give it a chance to abort pending @@ -317,7 +319,12 @@ ncl_reclaim(struct vop_reclaim_args *ap) * vfs_hash_remove(), since it cannot be recalled once the * nfs node is no longer available. */ - nfscl_delegreturnvp(vp, td); + MNT_ILOCK(mp); + if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0) { + MNT_IUNLOCK(mp); + nfscl_delegreturnvp(vp, td); + } else + MNT_IUNLOCK(mp); } vfs_hash_remove(vp); diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index bbc1c6ccbc2f..8b5f07b5aa2a 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -3300,10 +3300,12 @@ nfscl_delegreturnvp(vnode_t vp, NFSPROC_T *p) np = VTONFS(vp); cred = newnfs_getcred(); + dp = NULL; NFSLOCKCLSTATE(); clp = VFSTONFS(vp->v_mount)->nm_clp; - dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, - np->n_fhp->nfh_len); + if (clp != NULL) + dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, + np->n_fhp->nfh_len); if (dp != NULL) { nfscl_cleandeleg(dp); nfscl_freedeleg(&clp->nfsc_deleg, dp, false); From owner-dev-commits-src-all@freebsd.org Wed May 12 02:37:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D587962E34D; Wed, 12 May 2021 02:37:38 +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 4FfzTt5lHGz3M8H; Wed, 12 May 2021 02:37:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B8194232CC; Wed, 12 May 2021 02:37:38 +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 14C2bcqp073111; Wed, 12 May 2021 02:37:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C2bciZ073110; Wed, 12 May 2021 02:37:38 GMT (envelope-from git) Date: Wed, 12 May 2021 02:37:38 GMT Message-Id: <202105120237.14C2bciZ073110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 44d99af3c545 - stable/12 - nfscl: return delegations in the NFS VOP_RECLAIM() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 44d99af3c545398c5bbc01b20c611fe63ccdad76 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:37:38 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=44d99af3c545398c5bbc01b20c611fe63ccdad76 commit 44d99af3c545398c5bbc01b20c611fe63ccdad76 Author: Rick Macklem AuthorDate: 2021-04-26 00:57:55 +0000 Commit: Rick Macklem CommitDate: 2021-05-12 02:32:12 +0000 nfscl: return delegations in the NFS VOP_RECLAIM() After a vnode is recycled it can no longer be acquired via vfs_hash_get() and, as such, a delegation for the vnode cannot be recalled. In the unlikely event that a delegation still exists when the vnode is being recycled, return the delegation since it will no longer be recallable. Until you have this patch in your NFSv4 client, you should consider avoiding the use of delegations. (cherry picked from commit aad780464fad1e32c97316515a4044d661413a6b) --- sys/fs/nfs/nfs_var.h | 1 + sys/fs/nfsclient/nfs_clnode.c | 10 ++++++++- sys/fs/nfsclient/nfs_clstate.c | 49 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index bee66d15b016..0f656601e531 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -578,6 +578,7 @@ void nfscl_lockinit(struct nfsv4lock *); void nfscl_lockexcl(struct nfsv4lock *, void *); void nfscl_lockunlock(struct nfsv4lock *); void nfscl_lockderef(struct nfsv4lock *); +void nfscl_delegreturnvp(vnode_t, NFSPROC_T *); void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *); void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *, int); diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index f41cb8749020..cdebf9c56631 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -303,7 +303,7 @@ ncl_reclaim(struct vop_reclaim_args *ap) */ vnode_destroy_vobject(vp); - if (NFS_ISV4(vp) && vp->v_type == VREG) + if (NFS_ISV4(vp) && vp->v_type == VREG) { /* * We can now safely close any remaining NFSv4 Opens for * this file. Most opens will have already been closed by @@ -311,6 +311,14 @@ ncl_reclaim(struct vop_reclaim_args *ap) * called, so we need to do it again here. */ (void) nfsrpc_close(vp, 1, ap->a_td); + /* + * It it unlikely a delegation will still exist, but + * if one does, it must be returned before calling + * vfs_hash_remove(), since it cannot be recalled once the + * nfs node is no longer available. + */ + nfscl_delegreturnvp(vp, td); + } vfs_hash_remove(vp); diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 03c046c36ccc..5d2641e1f4b0 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -148,7 +148,8 @@ static int nfscl_trylock(struct nfsmount *, vnode_t , u_int8_t *, struct ucred *, NFSPROC_T *); static int nfsrpc_reopen(struct nfsmount *, u_int8_t *, int, u_int32_t, struct nfsclopen *, struct nfscldeleg **, struct ucred *, NFSPROC_T *); -static void nfscl_freedeleg(struct nfscldeleghead *, struct nfscldeleg *); +static void nfscl_freedeleg(struct nfscldeleghead *, struct nfscldeleg *, + bool); static int nfscl_errmap(struct nfsrv_descript *, u_int32_t); static void nfscl_cleanup_common(struct nfsclclient *, u_int8_t *); static int nfscl_recalldeleg(struct nfsclclient *, struct nfsmount *, @@ -1610,12 +1611,13 @@ nfscl_cleandeleg(struct nfscldeleg *dp) * Free a delegation. */ static void -nfscl_freedeleg(struct nfscldeleghead *hdp, struct nfscldeleg *dp) +nfscl_freedeleg(struct nfscldeleghead *hdp, struct nfscldeleg *dp, bool freeit) { TAILQ_REMOVE(hdp, dp, nfsdl_list); LIST_REMOVE(dp, nfsdl_hash); - free(dp, M_NFSCLDELEG); + if (freeit) + free(dp, M_NFSCLDELEG); nfsstatsv1.cldelegates--; nfscl_delegcnt--; } @@ -1713,7 +1715,7 @@ nfscl_expireclient(struct nfsclclient *clp, struct nfsmount *nmp, printf("nfsv4 expired locks lost\n"); } nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); dp = ndp; } if (!TAILQ_EMPTY(&clp->nfsc_deleg)) @@ -2230,7 +2232,7 @@ nfscl_recover(struct nfsclclient *clp, struct ucred *cred, NFSPROC_T *p) * away. Ouch!! */ nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } else { LIST_INSERT_HEAD(&extra_open, nop, nfso_list); } @@ -3247,11 +3249,40 @@ nfscl_delegreturnall(struct nfsclclient *clp, NFSPROC_T *p) TAILQ_FOREACH_SAFE(dp, &clp->nfsc_deleg, nfsdl_list, ndp) { nfscl_cleandeleg(dp); (void) nfscl_trydelegreturn(dp, cred, clp->nfsc_nmp, p); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } NFSFREECRED(cred); } +/* + * Return any delegation for this vp. + */ +void +nfscl_delegreturnvp(vnode_t vp, NFSPROC_T *p) +{ + struct nfsclclient *clp; + struct nfscldeleg *dp; + struct ucred *cred; + struct nfsnode *np; + + np = VTONFS(vp); + cred = newnfs_getcred(); + NFSLOCKCLSTATE(); + clp = VFSTONFS(vp->v_mount)->nm_clp; + dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, + np->n_fhp->nfh_len); + if (dp != NULL) { + nfscl_cleandeleg(dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, false); + NFSUNLOCKCLSTATE(); + newnfs_copycred(&dp->nfsdl_cred, cred); + nfscl_trydelegreturn(dp, cred, clp->nfsc_nmp, p); + free(dp, M_NFSCLDELEG); + } else + NFSUNLOCKCLSTATE(); + NFSFREECRED(cred); +} + /* * Do a callback RPC. */ @@ -4478,7 +4509,7 @@ nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) *stp = dp->nfsdl_stateid; retcnt = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } if (igotlock) nfsv4_unlock(&clp->nfsc_lock, 0); @@ -4578,7 +4609,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, retcnt++; *gotfdp = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } if (igotlock) { nfsv4_unlock(&clp->nfsc_lock, 0); @@ -4614,7 +4645,7 @@ nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, retcnt++; *gottdp = 1; nfscl_cleandeleg(dp); - nfscl_freedeleg(&clp->nfsc_deleg, dp); + nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } } NFSUNLOCKCLSTATE(); From owner-dev-commits-src-all@freebsd.org Wed May 12 02:43:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DE1362E8D1; Wed, 12 May 2021 02:43:16 +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 4FfzcN1lP9z3MS7; Wed, 12 May 2021 02:43:16 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2EDAC23A50; Wed, 12 May 2021 02:43:16 +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 14C2hGo2085680; Wed, 12 May 2021 02:43:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C2hGmQ085679; Wed, 12 May 2021 02:43:16 GMT (envelope-from git) Date: Wed, 12 May 2021 02:43:16 GMT Message-Id: <202105120243.14C2hGmQ085679@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 8686e00fdfac - stable/12 - nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8686e00fdfac505cded6d8f4a4bcf8e51fc10349 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:43:16 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=8686e00fdfac505cded6d8f4a4bcf8e51fc10349 commit 8686e00fdfac505cded6d8f4a4bcf8e51fc10349 Author: Rick Macklem AuthorDate: 2021-04-28 00:30:16 +0000 Commit: Rick Macklem CommitDate: 2021-05-12 02:38:42 +0000 nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp() Commit aad780464fad added a function called nfscl_delegreturnvp() to return delegations during the NFS VOP_RECLAIM(). The function erroneously assumed that nm_clp would be non-NULL. It will be NULL for NFSV4.0 mounts until a regular file is opened. It will also be NULL during vflush() in nfs_unmount() for a forced dismount. This patch adds a check for clp == NULL to fix this. Also, since it makes no sense to call nfscl_delegreturnvp() during a forced dismount, the patch adds a check for that case and does not do the call during forced dismounts. PR: 255436 (cherry picked from commit f6fec55fe30088bbefd3efe70b62565399a7b9b8) --- sys/fs/nfsclient/nfs_clnode.c | 10 +++++++++- sys/fs/nfsclient/nfs_clstate.c | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index cdebf9c56631..278d4f4900fe 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -286,6 +286,9 @@ ncl_reclaim(struct vop_reclaim_args *ap) struct vnode *vp = ap->a_vp; struct nfsnode *np = VTONFS(vp); struct nfsdmap *dp, *dp2; + struct mount *mp; + + mp = vp->v_mount; /* * If the NLM is running, give it a chance to abort pending @@ -317,7 +320,12 @@ ncl_reclaim(struct vop_reclaim_args *ap) * vfs_hash_remove(), since it cannot be recalled once the * nfs node is no longer available. */ - nfscl_delegreturnvp(vp, td); + MNT_ILOCK(mp); + if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0) { + MNT_IUNLOCK(mp); + nfscl_delegreturnvp(vp, td); + } else + MNT_IUNLOCK(mp); } vfs_hash_remove(vp); diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 5d2641e1f4b0..e705af31185b 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -3267,10 +3267,12 @@ nfscl_delegreturnvp(vnode_t vp, NFSPROC_T *p) np = VTONFS(vp); cred = newnfs_getcred(); + dp = NULL; NFSLOCKCLSTATE(); clp = VFSTONFS(vp->v_mount)->nm_clp; - dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, - np->n_fhp->nfh_len); + if (clp != NULL) + dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, + np->n_fhp->nfh_len); if (dp != NULL) { nfscl_cleandeleg(dp); nfscl_freedeleg(&clp->nfsc_deleg, dp, false); From owner-dev-commits-src-all@freebsd.org Wed May 12 02:49:26 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 96A3A62EA2B; Wed, 12 May 2021 02:49:26 +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 4FfzlV3wvvz3MJw; Wed, 12 May 2021 02:49:26 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 75912237AF; Wed, 12 May 2021 02:49:26 +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 14C2nQCY086204; Wed, 12 May 2021 02:49:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C2nQE4086203; Wed, 12 May 2021 02:49:26 GMT (envelope-from git) Date: Wed, 12 May 2021 02:49:26 GMT Message-Id: <202105120249.14C2nQE4086203@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 83e7630f3246 - stable/12 - nfscl: Fix mis-merge in cherry-pick commit 44d99af3c545 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 83e7630f324649ed95a07d0be440553e672ba725 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 02:49:26 -0000 The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=83e7630f324649ed95a07d0be440553e672ba725 commit 83e7630f324649ed95a07d0be440553e672ba725 Author: Rick Macklem AuthorDate: 2021-05-12 02:46:46 +0000 Commit: Rick Macklem CommitDate: 2021-05-12 02:46:46 +0000 nfscl: Fix mis-merge in cherry-pick commit 44d99af3c545 This is a direct commit. --- sys/fs/nfsclient/nfs_clnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c index 278d4f4900fe..096770e5da59 100644 --- a/sys/fs/nfsclient/nfs_clnode.c +++ b/sys/fs/nfsclient/nfs_clnode.c @@ -323,7 +323,7 @@ ncl_reclaim(struct vop_reclaim_args *ap) MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0) { MNT_IUNLOCK(mp); - nfscl_delegreturnvp(vp, td); + nfscl_delegreturnvp(vp, ap->a_td); } else MNT_IUNLOCK(mp); } From owner-dev-commits-src-all@freebsd.org Wed May 12 05:18:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8F01631499; Wed, 12 May 2021 05:18:03 +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 4Fg32z4Nkyz3j4n; Wed, 12 May 2021 05:18:03 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 89940253D8; Wed, 12 May 2021 05:18:03 +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 14C5I3an086275; Wed, 12 May 2021 05:18:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5I3u1086274; Wed, 12 May 2021 05:18:03 GMT (envelope-from git) Date: Wed, 12 May 2021 05:18:03 GMT Message-Id: <202105120518.14C5I3u1086274@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: e5092308d94e - main - Vendor import of Gavin D. Howard's bc version 4.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e5092308d94ef05d9af0ea4d5edfe8b0ce323ec3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:18:03 -0000 The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=e5092308d94ef05d9af0ea4d5edfe8b0ce323ec3 commit e5092308d94ef05d9af0ea4d5edfe8b0ce323ec3 Author: Stefan Eßer AuthorDate: 2021-05-12 05:15:24 +0000 Commit: Stefan Eßer CommitDate: 2021-05-12 05:17:15 +0000 Vendor import of Gavin D. Howard's bc version 4.0.2 --- contrib/bc/NEWS.md | 9 +++++++++ contrib/bc/include/history.h | 1 + contrib/bc/include/version.h | 2 +- contrib/bc/src/history.c | 5 ++++- contrib/bc/src/vm.c | 2 ++ contrib/bc/tests/other.sh | 5 ++--- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index c66e7b164c8a..c78bddd27e76 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,14 @@ # News +## 4.0.2 + +This is a production release that fixes two bugs: + +1. If no files are used and the first statement on `stdin` is invalid, `scale` + would not be set to `20` even if `-l` was used. +2. When using history, `bc` failed to respond properly to `SIGSTOP` and + `SIGTSTP`. + ## 4.0.1 This is a production release that only adds one thing: flushing output when it diff --git a/contrib/bc/include/history.h b/contrib/bc/include/history.h index 469785a118a9..444a2a107ac5 100644 --- a/contrib/bc/include/history.h +++ b/contrib/bc/include/history.h @@ -165,6 +165,7 @@ typedef enum BcHistoryAction { BC_ACTION_ENTER = 13, BC_ACTION_CTRL_N = 14, BC_ACTION_CTRL_P = 16, + BC_ACTION_CTRL_S = 19, BC_ACTION_CTRL_T = 20, BC_ACTION_CTRL_U = 21, BC_ACTION_CTRL_W = 23, diff --git a/contrib/bc/include/version.h b/contrib/bc/include/version.h index ab4823bd7c2a..42eb3a11d2c0 100644 --- a/contrib/bc/include/version.h +++ b/contrib/bc/include/version.h @@ -36,6 +36,6 @@ #ifndef BC_VERSION_H #define BC_VERSION_H -#define VERSION 4.0.1 +#define VERSION 4.0.2 #endif // BC_VERSION_H diff --git a/contrib/bc/src/history.c b/contrib/bc/src/history.c index c0d54fe35234..317d9193036c 100644 --- a/contrib/bc/src/history.c +++ b/contrib/bc/src/history.c @@ -1281,8 +1281,11 @@ static BcStatus bc_history_edit(BcHistory *h, const char *prompt) { default: { - if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) + if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) { bc_history_printCtrl(h, c); + if (c == BC_ACTION_CTRL_Z) raise(SIGTSTP); + if (c == BC_ACTION_CTRL_S) raise(SIGSTOP); + } else bc_history_edit_insert(h, cbuf, nread); break; } diff --git a/contrib/bc/src/vm.c b/contrib/bc/src/vm.c index e7ee8d35ba54..d01c8fd6860f 100644 --- a/contrib/bc/src/vm.c +++ b/contrib/bc/src/vm.c @@ -835,6 +835,8 @@ static void bc_vm_exec(void) { #if BC_ENABLE_EXTRA_MATH if (!BC_IS_POSIX) bc_vm_load(bc_lib2_name, bc_lib2); #endif // BC_ENABLE_EXTRA_MATH + + bc_program_exec(&vm.prog); } #endif // BC_ENABLED diff --git a/contrib/bc/tests/other.sh b/contrib/bc/tests/other.sh index d2ef4f6d0694..e13891fcad89 100755 --- a/contrib/bc/tests/other.sh +++ b/contrib/bc/tests/other.sh @@ -138,7 +138,7 @@ else set +e - printf 'three\n' | head -c3 > /dev/null + printf 'three\n' | cut -c1-3 > /dev/null err=$? if [ "$err" -eq 0 ]; then @@ -156,8 +156,7 @@ else printf '4 April 2021\n' > "$easter_res" - "$testdir/dc/scripts/easter.sh" "$exe" 2021 | head -c12 > "$easter_out" - printf '\n' >> "$easter_out" + "$testdir/dc/scripts/easter.sh" "$exe" 2021 | cut -c1-12 > "$easter_out" err="$?" checktest "$d" "$err" "Easter script" "$easter_res" "$easter_out" From owner-dev-commits-src-all@freebsd.org Wed May 12 05:25:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CEC5663137F; Wed, 12 May 2021 05:25:03 +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 4Fg3C35Tn6z3k0G; Wed, 12 May 2021 05:25:03 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AEDA925C98; Wed, 12 May 2021 05:25:03 +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 14C5P3pn099042; Wed, 12 May 2021 05:25:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5P3nh099041; Wed, 12 May 2021 05:25:03 GMT (envelope-from git) Date: Wed, 12 May 2021 05:25:03 GMT Message-Id: <202105120525.14C5P3nh099041@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: e681dd3e2c12 - main - Revert "Vendor import of Gavin D. Howard's bc version 4.0.2" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e681dd3e2c1221fcf81cc8bc36a70decc50d9ebb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:25:03 -0000 The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=e681dd3e2c1221fcf81cc8bc36a70decc50d9ebb commit e681dd3e2c1221fcf81cc8bc36a70decc50d9ebb Author: Stefan Eßer AuthorDate: 2021-05-12 05:22:37 +0000 Commit: Stefan Eßer CommitDate: 2021-05-12 05:22:37 +0000 Revert "Vendor import of Gavin D. Howard's bc version 4.0.2" The update had been performed on a check-out of the vendor branch, but the final push lacked the target designation vendor/bc. --- contrib/bc/NEWS.md | 9 --------- contrib/bc/include/history.h | 1 - contrib/bc/include/version.h | 2 +- contrib/bc/src/history.c | 5 +---- contrib/bc/src/vm.c | 2 -- contrib/bc/tests/other.sh | 5 +++-- 6 files changed, 5 insertions(+), 19 deletions(-) diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index c78bddd27e76..c66e7b164c8a 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,14 +1,5 @@ # News -## 4.0.2 - -This is a production release that fixes two bugs: - -1. If no files are used and the first statement on `stdin` is invalid, `scale` - would not be set to `20` even if `-l` was used. -2. When using history, `bc` failed to respond properly to `SIGSTOP` and - `SIGTSTP`. - ## 4.0.1 This is a production release that only adds one thing: flushing output when it diff --git a/contrib/bc/include/history.h b/contrib/bc/include/history.h index 444a2a107ac5..469785a118a9 100644 --- a/contrib/bc/include/history.h +++ b/contrib/bc/include/history.h @@ -165,7 +165,6 @@ typedef enum BcHistoryAction { BC_ACTION_ENTER = 13, BC_ACTION_CTRL_N = 14, BC_ACTION_CTRL_P = 16, - BC_ACTION_CTRL_S = 19, BC_ACTION_CTRL_T = 20, BC_ACTION_CTRL_U = 21, BC_ACTION_CTRL_W = 23, diff --git a/contrib/bc/include/version.h b/contrib/bc/include/version.h index 42eb3a11d2c0..ab4823bd7c2a 100644 --- a/contrib/bc/include/version.h +++ b/contrib/bc/include/version.h @@ -36,6 +36,6 @@ #ifndef BC_VERSION_H #define BC_VERSION_H -#define VERSION 4.0.2 +#define VERSION 4.0.1 #endif // BC_VERSION_H diff --git a/contrib/bc/src/history.c b/contrib/bc/src/history.c index 317d9193036c..c0d54fe35234 100644 --- a/contrib/bc/src/history.c +++ b/contrib/bc/src/history.c @@ -1281,11 +1281,8 @@ static BcStatus bc_history_edit(BcHistory *h, const char *prompt) { default: { - if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) { + if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) bc_history_printCtrl(h, c); - if (c == BC_ACTION_CTRL_Z) raise(SIGTSTP); - if (c == BC_ACTION_CTRL_S) raise(SIGSTOP); - } else bc_history_edit_insert(h, cbuf, nread); break; } diff --git a/contrib/bc/src/vm.c b/contrib/bc/src/vm.c index d01c8fd6860f..e7ee8d35ba54 100644 --- a/contrib/bc/src/vm.c +++ b/contrib/bc/src/vm.c @@ -835,8 +835,6 @@ static void bc_vm_exec(void) { #if BC_ENABLE_EXTRA_MATH if (!BC_IS_POSIX) bc_vm_load(bc_lib2_name, bc_lib2); #endif // BC_ENABLE_EXTRA_MATH - - bc_program_exec(&vm.prog); } #endif // BC_ENABLED diff --git a/contrib/bc/tests/other.sh b/contrib/bc/tests/other.sh index e13891fcad89..d2ef4f6d0694 100755 --- a/contrib/bc/tests/other.sh +++ b/contrib/bc/tests/other.sh @@ -138,7 +138,7 @@ else set +e - printf 'three\n' | cut -c1-3 > /dev/null + printf 'three\n' | head -c3 > /dev/null err=$? if [ "$err" -eq 0 ]; then @@ -156,7 +156,8 @@ else printf '4 April 2021\n' > "$easter_res" - "$testdir/dc/scripts/easter.sh" "$exe" 2021 | cut -c1-12 > "$easter_out" + "$testdir/dc/scripts/easter.sh" "$exe" 2021 | head -c12 > "$easter_out" + printf '\n' >> "$easter_out" err="$?" checktest "$d" "$err" "Easter script" "$easter_res" "$easter_out" From owner-dev-commits-src-all@freebsd.org Wed May 12 05:36:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0878E631B60 for ; Wed, 12 May 2021 05:36:47 +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 4Fg3SZ6w4Pz3kWL; Wed, 12 May 2021 05:36:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E025F259BF; Wed, 12 May 2021 05:36:46 +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 14C5akij012258; Wed, 12 May 2021 05:36:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5akKQ012257; Wed, 12 May 2021 05:36:46 GMT (envelope-from git) Date: Wed, 12 May 2021 05:36:46 GMT Message-Id: <202105120536.14C5akKQ012257@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: 2858419a0ee2 - vendor/bc - Vendor import of Gavin D. Howard's bc version 4.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/vendor/bc X-Git-Reftype: branch X-Git-Commit: 2858419a0ee2b8f5827de72c00618bcd69ebc5fc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:36:47 -0000 The branch vendor/bc has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=2858419a0ee2b8f5827de72c00618bcd69ebc5fc commit 2858419a0ee2b8f5827de72c00618bcd69ebc5fc Author: Stefan Eßer AuthorDate: 2021-05-12 05:35:58 +0000 Commit: Stefan Eßer CommitDate: 2021-05-12 05:35:58 +0000 Vendor import of Gavin D. Howard's bc version 4.0.2 --- NEWS.md | 9 +++++++++ include/history.h | 1 + include/version.h | 2 +- src/history.c | 5 ++++- src/vm.c | 2 ++ tests/other.sh | 5 ++--- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index c66e7b164c8a..c78bddd27e76 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,14 @@ # News +## 4.0.2 + +This is a production release that fixes two bugs: + +1. If no files are used and the first statement on `stdin` is invalid, `scale` + would not be set to `20` even if `-l` was used. +2. When using history, `bc` failed to respond properly to `SIGSTOP` and + `SIGTSTP`. + ## 4.0.1 This is a production release that only adds one thing: flushing output when it diff --git a/include/history.h b/include/history.h index 469785a118a9..444a2a107ac5 100644 --- a/include/history.h +++ b/include/history.h @@ -165,6 +165,7 @@ typedef enum BcHistoryAction { BC_ACTION_ENTER = 13, BC_ACTION_CTRL_N = 14, BC_ACTION_CTRL_P = 16, + BC_ACTION_CTRL_S = 19, BC_ACTION_CTRL_T = 20, BC_ACTION_CTRL_U = 21, BC_ACTION_CTRL_W = 23, diff --git a/include/version.h b/include/version.h index ab4823bd7c2a..42eb3a11d2c0 100644 --- a/include/version.h +++ b/include/version.h @@ -36,6 +36,6 @@ #ifndef BC_VERSION_H #define BC_VERSION_H -#define VERSION 4.0.1 +#define VERSION 4.0.2 #endif // BC_VERSION_H diff --git a/src/history.c b/src/history.c index c0d54fe35234..317d9193036c 100644 --- a/src/history.c +++ b/src/history.c @@ -1281,8 +1281,11 @@ static BcStatus bc_history_edit(BcHistory *h, const char *prompt) { default: { - if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) + if (c >= BC_ACTION_CTRL_A && c <= BC_ACTION_CTRL_Z) { bc_history_printCtrl(h, c); + if (c == BC_ACTION_CTRL_Z) raise(SIGTSTP); + if (c == BC_ACTION_CTRL_S) raise(SIGSTOP); + } else bc_history_edit_insert(h, cbuf, nread); break; } diff --git a/src/vm.c b/src/vm.c index e7ee8d35ba54..d01c8fd6860f 100644 --- a/src/vm.c +++ b/src/vm.c @@ -835,6 +835,8 @@ static void bc_vm_exec(void) { #if BC_ENABLE_EXTRA_MATH if (!BC_IS_POSIX) bc_vm_load(bc_lib2_name, bc_lib2); #endif // BC_ENABLE_EXTRA_MATH + + bc_program_exec(&vm.prog); } #endif // BC_ENABLED diff --git a/tests/other.sh b/tests/other.sh index d2ef4f6d0694..e13891fcad89 100755 --- a/tests/other.sh +++ b/tests/other.sh @@ -138,7 +138,7 @@ else set +e - printf 'three\n' | head -c3 > /dev/null + printf 'three\n' | cut -c1-3 > /dev/null err=$? if [ "$err" -eq 0 ]; then @@ -156,8 +156,7 @@ else printf '4 April 2021\n' > "$easter_res" - "$testdir/dc/scripts/easter.sh" "$exe" 2021 | head -c12 > "$easter_out" - printf '\n' >> "$easter_out" + "$testdir/dc/scripts/easter.sh" "$exe" 2021 | cut -c1-12 > "$easter_out" err="$?" checktest "$d" "$err" "Easter script" "$easter_res" "$easter_out" From owner-dev-commits-src-all@freebsd.org Wed May 12 05:36:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C219631BC6 for ; Wed, 12 May 2021 05:36:48 +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 4Fg3Sc1kxDz3kN3; Wed, 12 May 2021 05:36:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2510525BB8; Wed, 12 May 2021 05:36:48 +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 14C5alUO012287; Wed, 12 May 2021 05:36:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5al9q012286; Wed, 12 May 2021 05:36:47 GMT (envelope-from git) Date: Wed, 12 May 2021 05:36:47 GMT Message-Id: <202105120536.14C5al9q012286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: af1d893e3f89 - Create tag vendor/bc/4.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/tags/vendor/bc/4.0.2 X-Git-Reftype: annotated tag X-Git-Commit: af1d893e3f89c5c8b8d58c9ab66d2cc0bdd6214e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:36:48 -0000 The annotated tag vendor/bc/4.0.2 has been created by se: URL: https://cgit.FreeBSD.org/src/tag/?h=vendor/bc/4.0.2 tag vendor/bc/4.0.2 Tagger: Stefan Eßer TaggerDate: 2021-05-12 05:36:15 +0000 Tag Gavin D. Howard's bc version 4.0.2 commit 2858419a0ee2b8f5827de72c00618bcd69ebc5fc Author: Stefan Eßer AuthorDate: 2021-05-12 05:35:58 +0000 Commit: Stefan Eßer CommitDate: 2021-05-12 05:35:58 +0000 Vendor import of Gavin D. Howard's bc version 4.0.2 From owner-dev-commits-src-all@freebsd.org Wed May 12 05:52:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC274631DD1; Wed, 12 May 2021 05:52:49 +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 4Fg3q55QD1z3lCN; Wed, 12 May 2021 05:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 ACFB526108; Wed, 12 May 2021 05:52:49 +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 14C5qnYA038697; Wed, 12 May 2021 05:52:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5qnbf038696; Wed, 12 May 2021 05:52:49 GMT (envelope-from git) Date: Wed, 12 May 2021 05:52:49 GMT Message-Id: <202105120552.14C5qnbf038696@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?U3RlZmFuIEXDn2Vy?= Subject: git: 8c39e25220bb - main - contrib/bc: update to version 4.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c39e25220bb88cd027d0c3b0fe86e52f6abd150 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:52:49 -0000 The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=8c39e25220bb88cd027d0c3b0fe86e52f6abd150 commit 8c39e25220bb88cd027d0c3b0fe86e52f6abd150 Merge: e681dd3e2c12 2858419a0ee2 Author: Stefan Eßer AuthorDate: 2021-05-12 05:49:19 +0000 Commit: Stefan Eßer CommitDate: 2021-05-12 05:50:59 +0000 contrib/bc: update to version 4.0.2 Merge commit '2858419a0ee2b8f5827de72c00618bcd69ebc5fc' This update fixes the initialization of "scale" to 20 if started with -l and the initial statement leads to an error (e.g. contains a syntax error). Scale was initialized to 0 in that case. Another change is the support of job control in interactive mode with line editing enabled. The control characters have been interpreted as editing commands only, prior to this version. MFC after: 3 days contrib/bc/NEWS.md | 9 +++++++++ contrib/bc/include/history.h | 1 + contrib/bc/include/version.h | 2 +- contrib/bc/src/history.c | 5 ++++- contrib/bc/src/vm.c | 2 ++ contrib/bc/tests/other.sh | 5 ++--- 6 files changed, 19 insertions(+), 5 deletions(-) From owner-dev-commits-src-all@freebsd.org Wed May 12 05:55:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 63E36631EE0 for ; Wed, 12 May 2021 05:55:34 +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 4Fg3tG2S4dz3kwL; Wed, 12 May 2021 05:55:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4737525ED3; Wed, 12 May 2021 05:55:34 +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 14C5tY2H038997; Wed, 12 May 2021 05:55:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C5tYBa038996; Wed, 12 May 2021 05:55:34 GMT (envelope-from git) Date: Wed, 12 May 2021 05:55:34 GMT Message-Id: <202105120555.14C5tYBa038996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: Philip Paeps Subject: git: f3ba20efca13 - internal/admin - mentors: release khng from mentorship MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/internal/admin X-Git-Reftype: branch X-Git-Commit: f3ba20efca134c3438b609518c5c4746565917da Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 05:55:34 -0000 The branch internal/admin has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=f3ba20efca134c3438b609518c5c4746565917da commit f3ba20efca134c3438b609518c5c4746565917da Author: Philip Paeps AuthorDate: 2021-05-12 05:54:35 +0000 Commit: Philip Paeps CommitDate: 2021-05-12 05:54:35 +0000 mentors: release khng from mentorship Ka Ho is ready to fly solo. We'll stop slowing him down. Approved by: lwhsu (co-mentor), core (implicit) --- mentors | 1 - 1 file changed, 1 deletion(-) diff --git a/mentors b/mentors index 259b9fb3fe42..b0171f788b35 100644 --- a/mentors +++ b/mentors @@ -18,7 +18,6 @@ gordon delphij Co-mentor: emaste jceel trasz jkh rwatson kadesai ken Co-mentor: scottl, ambrisko -khng philip Co-mentor: lwhsu mjoras rstone nick philip Co-mentor: kp oh manu From owner-dev-commits-src-all@freebsd.org Wed May 12 08:15:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3522C6353BC; Wed, 12 May 2021 08:15:36 +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 4Fg6zr11XMz3r1f; Wed, 12 May 2021 08:15:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 157EC27ACC; Wed, 12 May 2021 08:15:36 +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 14C8FZ6T026433; Wed, 12 May 2021 08:15:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C8FZYX026432; Wed, 12 May 2021 08:15:35 GMT (envelope-from git) Date: Wed, 12 May 2021 08:15:35 GMT Message-Id: <202105120815.14C8FZYX026432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: 699e490dfc21 - stable/13 - full(4): Use correct section name for AUTHORS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 699e490dfc2194e562aea5d17ede50b5c2b9ffff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 08:15:36 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=699e490dfc2194e562aea5d17ede50b5c2b9ffff commit 699e490dfc2194e562aea5d17ede50b5c2b9ffff Author: Gordon Bergling AuthorDate: 2021-05-09 15:31:52 +0000 Commit: Gordon Bergling CommitDate: 2021-05-12 08:15:19 +0000 full(4): Use correct section name for AUTHORS PR: 255715 Reported by: Christos Margiolis (cherry picked from commit 416051f5818e3270e019ef8978e2f1168f2628fc) --- share/man/man4/full.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/full.4 b/share/man/man4/full.4 index 5265e2ab2612..6f1b3606258d 100644 --- a/share/man/man4/full.4 +++ b/share/man/man4/full.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 29, 2014 +.Dd May 9, 2021 .Dt FULL 4 .Os .Sh NAME @@ -42,6 +42,6 @@ However, it will always be full when writing to it. .Sh SEE ALSO .Xr null 4 , .Xr zero 4 -.Sh Author +.Sh AUTHORS This device and man page was written by .An Eitan Adler Aq Mt eadler@FreeBSD.org . From owner-dev-commits-src-all@freebsd.org Wed May 12 08:16:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79A0A6353DC; Wed, 12 May 2021 08:16:28 +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 4Fg70r33gHz3rFS; Wed, 12 May 2021 08:16:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5C0BA27BE7; Wed, 12 May 2021 08:16:28 +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 14C8GSW7026606; Wed, 12 May 2021 08:16:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14C8GSYo026605; Wed, 12 May 2021 08:16:28 GMT (envelope-from git) Date: Wed, 12 May 2021 08:16:28 GMT Message-Id: <202105120816.14C8GSYo026605@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: d99e1e90e9b2 - stable/12 - full(4): Use correct section name for AUTHORS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d99e1e90e9b22a9e7d305cb5ede3dda3d4b035c3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 08:16:28 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=d99e1e90e9b22a9e7d305cb5ede3dda3d4b035c3 commit d99e1e90e9b22a9e7d305cb5ede3dda3d4b035c3 Author: Gordon Bergling AuthorDate: 2021-05-09 15:31:52 +0000 Commit: Gordon Bergling CommitDate: 2021-05-12 08:16:06 +0000 full(4): Use correct section name for AUTHORS PR: 255715 Reported by: Christos Margiolis (cherry picked from commit 416051f5818e3270e019ef8978e2f1168f2628fc) --- share/man/man4/full.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/full.4 b/share/man/man4/full.4 index 5265e2ab2612..6f1b3606258d 100644 --- a/share/man/man4/full.4 +++ b/share/man/man4/full.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 29, 2014 +.Dd May 9, 2021 .Dt FULL 4 .Os .Sh NAME @@ -42,6 +42,6 @@ However, it will always be full when writing to it. .Sh SEE ALSO .Xr null 4 , .Xr zero 4 -.Sh Author +.Sh AUTHORS This device and man page was written by .An Eitan Adler Aq Mt eadler@FreeBSD.org . From owner-dev-commits-src-all@freebsd.org Wed May 12 09:13:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F058863710F for ; Wed, 12 May 2021 09:13:06 +0000 (UTC) (envelope-from sales88@bansion.cn) Received: from smtpbg506.qq.com (smtpbg506.qq.com [203.205.250.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fg8G73VQZz3tW6 for ; Wed, 12 May 2021 09:13:02 +0000 (UTC) (envelope-from sales88@bansion.cn) X-QQ-mid: bizesmtp53t1620810776te5junfo Received: from Andrew-Wang (unknown [113.88.112.5]) by esmtp6.qq.com (ESMTP) with SMTP id 0 for ; Wed, 12 May 2021 17:12:55 +0800 (CST) X-QQ-SSF: 0020000J002000M0J000B00A0000000 X-QQ-FEAT: MS67FA/ZMAbdoVorPDcnUmVHCaTcvYo8nHfc17spYGfjqBzoUkibTLimXLxlY jRz7PMqZ8hZzEQOxQVCi/hHGXEk+WujufGYG8NLS1DtQWamU9sKWy7mGijWvnCzOeqN/akN vNLFYapiNs1nWSDvEelhnS8XEoMEnkW6jjylnn43nL9cAO3ADwcJ3mUD6stJqyyLK0IBfI5 HMsAKXA5ei55uwhtzGaboaX152N1fK6URRwxAFWGAhitVq1GVLpOAreG4KwKJ6hCUgj88UG KE0rK3WgZJYwZ0uTZcXVx/cbLVpen6HIuFmy9wQ/61EGcKLYO5bb929BBFhFU2nQOxC4wbS v9bmrdrDQFmjp2TgVnEVPWX0v2p5HMTlYPnAicLt07GnHcj46U3d8yeRUJDmg== X-QQ-GoodBg: 0 Message-Id: <217464DE07D8CE0F3B4302ABDAD15D44@bansion.cn> Date: Wed, 12 May 2021 17:12:56 +0800 Priority: urgent X-Priority: 1 Importance: high X-DM-Templet-ReadReply: 1 X-Mailer: DM Pro6 [GB - 6.3.2.325] From: "sales88" Subject: RE: interactive display, interactive whiteboard, interactive flat panel To: "dev-commits-src-all" Reply-To: andrew@bansion.com X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:bansion.cn:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 X-Rspamd-Queue-Id: 4Fg8G73VQZz3tW6 X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of sales88@bansion.cn designates 203.205.250.33 as permitted sender) smtp.mailfrom=sales88@bansion.cn X-Spamd-Result: default: False [2.82 / 15.00]; HAS_REPLYTO(0.00)[andrew@bansion.com]; R_SPF_ALLOW(-0.20)[+ip4:203.205.250.0/24]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MIME_BASE64_TEXT(0.10)[]; RECEIVED_SPAMHAUS_PBL(0.00)[113.88.112.5:received]; MIME_TRACE(0.00)[0:~]; HAS_X_PRIO_ONE(0.00)[1]; PHISHING(0.72)[bansion->s8ke]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:132203, ipnet:203.205.250.0/23, country:CN]; FAKE_REPLY(1.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HEADER_FORGED_MDN(2.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-all@freebsd.org]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[203.205.250.33:from]; MIME_HTML_ONLY(0.20)[]; DMARC_NA(0.00)[bansion.cn]; RWL_MAILSPIKE_VERYGOOD(0.00)[203.205.250.33:from]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all] MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 09:13:07 -0000 From owner-dev-commits-src-all@freebsd.org Wed May 12 13:31:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D124863E6B6; Wed, 12 May 2021 13:31:14 +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 4FgG024rWDz4bfr; Wed, 12 May 2021 13:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 996CA40AC; Wed, 12 May 2021 13:31:14 +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 14CDVEUd045991; Wed, 12 May 2021 13:31:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CDVEoJ045990; Wed, 12 May 2021 13:31:14 GMT (envelope-from git) Date: Wed, 12 May 2021 13:31:14 GMT Message-Id: <202105121331.14CDVEoJ045990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 12dda000ed32 - main - sctp: fix locking in case of error handling during a restart MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12dda000ed32efa16f59909a6294e4d4b5a771ba Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 13:31:14 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=12dda000ed32efa16f59909a6294e4d4b5a771ba commit 12dda000ed32efa16f59909a6294e4d4b5a771ba Author: Michael Tuexen AuthorDate: 2021-05-12 13:29:06 +0000 Commit: Michael Tuexen CommitDate: 2021-05-12 13:29:06 +0000 sctp: fix locking in case of error handling during a restart Thanks to Taylor Brandstetter for finding the issue and providing a patch for the userland stack. MFC after: 3 days --- sys/netinet/sctp_input.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 050f30d145b7..f066cc100ac2 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1395,6 +1395,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, vrf_id, net->port); if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 2; + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* @@ -1409,9 +1410,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, (uint8_t *)&init_buf); if (init_cp == NULL) { /* could not pull a INIT chunk in cookie */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (init_cp->ch.chunk_type != SCTP_INITIATION) { + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* @@ -1424,9 +1427,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, (uint8_t *)&initack_buf); if (initack_cp == NULL) { /* could not pull INIT-ACK chunk in cookie */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (initack_cp->ch.chunk_type != SCTP_INITIATION_ACK) { + SCTP_TCB_UNLOCK(stcb); return (NULL); } if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) && @@ -1452,6 +1457,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 17; + SCTP_TCB_UNLOCK(stcb); return (NULL); } switch (SCTP_GET_STATE(stcb)) { @@ -1567,6 +1573,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, */ if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 6; + SCTP_TCB_UNLOCK(stcb); return (NULL); } /* @@ -1592,6 +1599,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, sctp_send_abort(m, iphlen, src, dst, sh, 0, op_err, mflowtype, mflowid, inp->fibnum, vrf_id, port); + SCTP_TCB_UNLOCK(stcb); return (NULL); } if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) && @@ -1622,6 +1630,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 7; + SCTP_TCB_UNLOCK(stcb); return (NULL); } if (how_indx < sizeof(asoc->cookie_how)) @@ -1952,6 +1961,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 16; /* all other cases... */ + SCTP_TCB_UNLOCK(stcb); return (NULL); } From owner-dev-commits-src-all@freebsd.org Wed May 12 13:31:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5FA463E871; Wed, 12 May 2021 13:31:48 +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 4FgG0h3dMmz4bmj; Wed, 12 May 2021 13:31:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6C036450B; Wed, 12 May 2021 13:31:48 +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 14CDVmIc046151; Wed, 12 May 2021 13:31:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CDVm4E046150; Wed, 12 May 2021 13:31:48 GMT (envelope-from git) Date: Wed, 12 May 2021 13:31:48 GMT Message-Id: <202105121331.14CDVm4E046150@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 82c84b850146 - stable/13 - igmp: Avoid an out-of-bounds access when zeroing counters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 82c84b850146e9c2ef7e6ea1b96e5d886d8cb2ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 13:31:48 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=82c84b850146e9c2ef7e6ea1b96e5d886d8cb2ad commit 82c84b850146e9c2ef7e6ea1b96e5d886d8cb2ad Author: Mark Johnston AuthorDate: 2021-05-05 21:06:23 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 13:31:39 +0000 igmp: Avoid an out-of-bounds access when zeroing counters When verifying, byte-by-byte, that the user-supplied counters are zero-filled, sysctl_igmp_stat() would check for zero before checking the loop bound. Perform the checks in the correct order. Reported by: KASAN Sponsored by: The FreeBSD Foundation (cherry picked from commit 6c34dde83ee61fc0ba095dcfdac2f381f6bae007) --- sys/netinet/igmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 21bce1ff885a..ef0da5e5cb46 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -382,7 +382,7 @@ sysctl_igmp_stat(SYSCTL_HANDLER_ARGS) * igps0 must be "all zero". */ p = (char *)&igps0; - while (*p == '\0' && p < (char *)&igps0 + sizeof(igps0)) + while (p < (char *)&igps0 + sizeof(igps0) && *p == '\0') p++; if (p != (char *)&igps0 + sizeof(igps0)) { error = EINVAL; From owner-dev-commits-src-all@freebsd.org Wed May 12 14:48:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CBED7640D92; Wed, 12 May 2021 14:48:40 +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 4FgHjN5RkZz4g8Y; Wed, 12 May 2021 14:48:40 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AE2BC5227; Wed, 12 May 2021 14:48:40 +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 14CEmeah042734; Wed, 12 May 2021 14:48:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CEmeUm042733; Wed, 12 May 2021 14:48:40 GMT (envelope-from git) Date: Wed, 12 May 2021 14:48:40 GMT Message-Id: <202105121448.14CEmeUm042733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Glen Barber Subject: git: 3f25cfea5592 - main - release: update release.sh to use Git for ports tree checkouts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f25cfea55922780fe47eb6ebcef49ca15297261 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 14:48:40 -0000 The branch main has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=3f25cfea55922780fe47eb6ebcef49ca15297261 commit 3f25cfea55922780fe47eb6ebcef49ca15297261 Author: Glen Barber AuthorDate: 2021-05-12 14:27:21 +0000 Commit: Glen Barber CommitDate: 2021-05-12 14:27:21 +0000 release: update release.sh to use Git for ports tree checkouts MFC after: immediately (pending re approval) Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/release/release.sh b/release/release.sh index aa2ef4e6b3da..84a7813205f9 100755 --- a/release/release.sh +++ b/release/release.sh @@ -86,7 +86,7 @@ env_setup() { # and ports/. GITROOT="https://git.FreeBSD.org/" SRCBRANCH="main" - PORTBRANCH="head" + PORTBRANCH="main" GITSRC="src.git" GITPORTS="ports.git" @@ -141,8 +141,7 @@ env_check() { # Prefix the branches with the GITROOT for the full checkout URL. SRC="${GITROOT}${GITSRC}" - #PORT="${GITROOT}${GITPORTS}" - PORT="svn://svn.freebsd.org/ports/" + PORT="${GITROOT}${GITPORTS}" if [ -n "${EMBEDDEDBUILD}" ]; then WITH_DVD= From owner-dev-commits-src-all@freebsd.org Wed May 12 14:48:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BF44640D34; Wed, 12 May 2021 14:48:42 +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 4FgHjP6sLhz4gYC; Wed, 12 May 2021 14:48:41 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D9FB35514; Wed, 12 May 2021 14:48:41 +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 14CEmfBX042755; Wed, 12 May 2021 14:48:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CEmfJH042754; Wed, 12 May 2021 14:48:41 GMT (envelope-from git) Date: Wed, 12 May 2021 14:48:41 GMT Message-Id: <202105121448.14CEmfJH042754@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Glen Barber Subject: git: fb6e261c20eb - main - release: follow-up to previous commit to use Git for the ports tree MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb6e261c20ebcd94875d623e167369802721f2dd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 14:48:42 -0000 The branch main has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=fb6e261c20ebcd94875d623e167369802721f2dd commit fb6e261c20ebcd94875d623e167369802721f2dd Author: Glen Barber AuthorDate: 2021-05-12 14:29:53 +0000 Commit: Glen Barber CommitDate: 2021-05-12 14:29:53 +0000 release: follow-up to previous commit to use Git for the ports tree MFC after: immediately (pending re approval) Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/release/release.sh b/release/release.sh index 84a7813205f9..87e22e669fd1 100755 --- a/release/release.sh +++ b/release/release.sh @@ -222,16 +222,8 @@ chroot_setup() { fi fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then - # git -C ${CHROOTDIR}/usr/ports pull -q - # XXX: Workaround for the overlap in the Git conversion timeframe. - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then - ${SVNCMD} update ${CHROOTDIR}/usr/ports - else - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports - # XXX: Workaround for the overlap in the Git - # conversion timeframe. - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then + git -C ${CHROOTDIR}/usr/ports pull -q fi fi From owner-dev-commits-src-all@freebsd.org Wed May 12 14:48:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2A9C1640E16; Wed, 12 May 2021 14:48:43 +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 4FgHjR0fftz4gfP; Wed, 12 May 2021 14:48:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 09871505E; Wed, 12 May 2021 14:48:43 +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 14CEmgR6042778; Wed, 12 May 2021 14:48:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CEmgAB042777; Wed, 12 May 2021 14:48:42 GMT (envelope-from git) Date: Wed, 12 May 2021 14:48:42 GMT Message-Id: <202105121448.14CEmgAB042777@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Glen Barber Subject: git: 69b6abb7b2bb - main - release: remove logic to locate the svn{, lite} binary MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 69b6abb7b2bb2b07600b27660d864ddcd0b28cec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 14:48:43 -0000 The branch main has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=69b6abb7b2bb2b07600b27660d864ddcd0b28cec commit 69b6abb7b2bb2b07600b27660d864ddcd0b28cec Author: Glen Barber AuthorDate: 2021-05-12 14:32:03 +0000 Commit: Glen Barber CommitDate: 2021-05-12 14:32:03 +0000 release: remove logic to locate the svn{,lite} binary Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/release/release.sh b/release/release.sh index 87e22e669fd1..a448361b86a6 100755 --- a/release/release.sh +++ b/release/release.sh @@ -65,17 +65,6 @@ env_setup() { [ ! -z "${VCSCMD}" ] && break 2 done - # Find the Subversion binary to use. This is a workaround to use - # the source of truth for the ports tree, as the conversion to Git - # is targeted to occur slightly after the currently-scheduled 13.0 - # release. - for _dir in /usr/bin /usr/local/bin; do - for _svn in svn svnlite; do - [ -x "${_dir}/${_svn}" ] && SVNCMD="${_dir}/${_svn}" - [ ! -z "${SVNCMD}" ] && break 2 - done - done - if [ -z "${VCSCMD}" -a -z "${NOGIT}" ]; then echo "*** The devel/git port/package is required." exit 1 From owner-dev-commits-src-all@freebsd.org Wed May 12 15:50:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B110F642A5E; Wed, 12 May 2021 15:50:43 +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 4FgK4z4hPHz4lwc; Wed, 12 May 2021 15:50:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8961C5A72; Wed, 12 May 2021 15:50:43 +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 14CFohwA031652; Wed, 12 May 2021 15:50:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFohJI031651; Wed, 12 May 2021 15:50:43 GMT (envelope-from git) Date: Wed, 12 May 2021 15:50:43 GMT Message-Id: <202105121550.14CFohJI031651@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 716f5ae59ae7 - stable/13 - release: permanently remove the 'reldoc' target and associates MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 716f5ae59ae7abed4a1c4c16d82e2156f3264317 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:50:43 -0000 The branch stable/13 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=716f5ae59ae7abed4a1c4c16d82e2156f3264317 commit 716f5ae59ae7abed4a1c4c16d82e2156f3264317 Author: Glen Barber AuthorDate: 2021-02-18 04:00:03 +0000 Commit: Glen Barber CommitDate: 2021-05-12 14:49:08 +0000 release: permanently remove the 'reldoc' target and associates Following 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac, the structure for the reldoc target has significantly changed as result of the ASCIIDoctor/Hugo migration. As the release notes related files on the installation medium are inherently out of date, purge them entirely. Discussed within: re, doceng No objection: re (silence), doceng (silence) Timeout: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit f61e92ca5a23450bc28169bbdd71d7674df98c19) --- release/Makefile | 41 ------------------------------- release/arm/GENERICSD.conf | 1 - release/arm/RPI-B.conf | 1 - release/arm64/PINE64-LTS.conf | 1 - release/arm64/PINE64.conf | 1 - release/arm64/PINEBOOK.conf | 1 - release/arm64/ROCK64.conf | 1 - release/arm64/ROCKPRO64.conf | 1 - release/arm64/RPI.conf | 1 - release/release.conf.sample | 7 ------ release/release.sh | 56 +++++-------------------------------------- release/riscv/GENERICSD.conf | 1 - 12 files changed, 6 insertions(+), 107 deletions(-) diff --git a/release/Makefile b/release/Makefile index 4bde39efb22b..067eb268a2cd 100644 --- a/release/Makefile +++ b/release/Makefile @@ -20,12 +20,10 @@ # WORLDDIR: location of src tree -- must have built world and default kernel # (by default, the directory above this one) # PORTSDIR: location of ports tree to distribute (default: /usr/ports) -# DOCDIR: location of doc tree (default: /usr/doc) # XTRADIR: xtra-bits-dir argument for /mkisoimages.sh # NOPKG: if set, do not distribute third-party packages # NOPORTS: if set, do not distribute ports tree # NOSRC: if set, do not distribute source tree -# NODOC: if set, do not generate release documentation # WITH_DVD: if set, generate dvd1.iso # WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) # (uncompressed images are not removed) @@ -38,7 +36,6 @@ WORLDDIR?= ${.CURDIR}/.. PORTSDIR?= /usr/ports -DOCDIR?= /usr/doc RELNOTES_LANG?= en_US.ISO8859-1 .if !defined(TARGET) || empty(TARGET) @@ -74,9 +71,6 @@ VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH} VOLUME_LABEL= FreeBSD_Install .endif -.if !exists(${DOCDIR}) -NODOC= true -.endif .if !exists(${PORTSDIR}) NOPORTS= true .endif @@ -88,9 +82,6 @@ EXTRA_PACKAGES+= ports.txz .if !defined(NOSRC) EXTRA_PACKAGES+= src.txz .endif -#.if !defined(NODOC) -#EXTRA_PACKAGES+= reldoc -#.endif RELEASE_TARGETS= ftp IMAGES= @@ -119,9 +110,6 @@ CLEANFILES+= ${I}.xz CLEANFILES+= pkg-stage .endif CLEANDIRS= dist ftp disc1 bootonly dvd -#.if !defined(NODOC) -#CLEANDIRS+= reldoc rdoc -#.endif beforeclean: chflags -R noschg . .include @@ -161,23 +149,6 @@ ports.txz: --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ ${XZ_CMD} > ${.OBJDIR}/ports.txz -#reldoc: -# cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \ -# env MAN4DIR=${WORLDDIR}/share/man/man4 \ -# _BRANCH=${BRANCH} \ -# ${MAKE} all install clean "FORMATS=html txt" \ -# INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \ -# WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc -# mkdir -p reldoc -#.for i in hardware readme relnotes errata -# ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \ -# reldoc/${i:tu}.TXT -# ln -f ${.OBJDIR}/rdoc/${i:tl}.html \ -# reldoc/${i:tu}.HTML -#.endfor -# cp ${.OBJDIR}/rdoc/docbook.css \ -# reldoc/ - disc1: packagesystem # Install system mkdir -p ${.TARGET} @@ -193,10 +164,6 @@ disc1: packagesystem for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -220,10 +187,6 @@ bootonly: packagesystem # Copy manifest only (no distfiles) to get checksums mkdir -p ${.TARGET}/usr/freebsd-dist cp MANIFEST ${.TARGET}/usr/freebsd-dist -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -244,10 +207,6 @@ dvd: packagesystem for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf diff --git a/release/arm/GENERICSD.conf b/release/arm/GENERICSD.conf index 8749f5fd95cf..c76829b22b04 100644 --- a/release/arm/GENERICSD.conf +++ b/release/arm/GENERICSD.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 BBB_UBOOT_DIR="/usr/local/share/u-boot/u-boot-beaglebone" RPI_UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2" RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware" diff --git a/release/arm/RPI-B.conf b/release/arm/RPI-B.conf index 27fa6aac2644..f164edd25b90 100644 --- a/release/arm/RPI-B.conf +++ b/release/arm/RPI-B.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="RPI-B" MD_ARGS="-x 63 -y 255" -NODOC=1 UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi" RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware" OL_DIR="${RPI_FIRMWARE_DIR}/overlays" diff --git a/release/arm64/PINE64-LTS.conf b/release/arm64/PINE64-LTS.conf index 60de485703c8..4006f6273307 100644 --- a/release/arm64/PINE64-LTS.conf +++ b/release/arm64/PINE64-LTS.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64-LTS" diff --git a/release/arm64/PINE64.conf b/release/arm64/PINE64.conf index 12435e38730d..87cb9c584c54 100644 --- a/release/arm64/PINE64.conf +++ b/release/arm64/PINE64.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64" diff --git a/release/arm64/PINEBOOK.conf b/release/arm64/PINEBOOK.conf index 20e5b7713161..da5d31149c04 100644 --- a/release/arm64/PINEBOOK.conf +++ b/release/arm64/PINEBOOK.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINEBOOK" diff --git a/release/arm64/ROCK64.conf b/release/arm64/ROCK64.conf index 02041dd789d7..e77930b73661 100644 --- a/release/arm64/ROCK64.conf +++ b/release/arm64/ROCK64.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" export BOARDNAME="ROCK64" diff --git a/release/arm64/ROCKPRO64.conf b/release/arm64/ROCKPRO64.conf index fc454e30ec72..e09c3a8b491f 100644 --- a/release/arm64/ROCKPRO64.conf +++ b/release/arm64/ROCKPRO64.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" export BOARDNAME="ROCKPRO64" diff --git a/release/arm64/RPI.conf b/release/arm64/RPI.conf index 2dfe23547ae9..e7fd12f95090 100644 --- a/release/arm64/RPI.conf +++ b/release/arm64/RPI.conf @@ -14,7 +14,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 OL_DIR="${DTB_DIR}/overlays" OVERLAYS="mmc.dtbo pwm.dtbo disable-bt.dtbo" PART_SCHEME="MBR" diff --git a/release/release.conf.sample b/release/release.conf.sample index a70a8bb3bd80..f9cebf82491b 100644 --- a/release/release.conf.sample +++ b/release/release.conf.sample @@ -16,11 +16,9 @@ CHROOTDIR="/scratch" GITROOT="https://git.freebsd.org/" GITSRC="src.git" GITPORTS="ports.git" -GITDOC="doc.git" ## Set the src/, ports/, and doc/ branches or tags. SRCBRANCH="stable/13" -DOCBRANCH="main" PORTBRANCH="main" ## Sample configuration for using git from ports. @@ -45,7 +43,6 @@ PORTBRANCH="main" #KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))" ## Set miscellaneous 'make release' settings. -#NODOC= #NOPORTS= #NOSRC= #WITH_DVD= @@ -80,10 +77,6 @@ PORTBRANCH="main" ## the chroot. This is intended for use when /usr/src already exists. #SRC_UPDATE_SKIP= -## Set to a non-empty value skip checkout or update of /usr/doc in -## the chroot. This is intended for use when /usr/doc already exists. -#DOC_UPDATE_SKIP= - ## Set to a non-empty value skip checkout or update of /usr/ports in ## the chroot. This is intended for use when /usr/ports already exists. #PORTS_UPDATE_SKIP= diff --git a/release/release.sh b/release/release.sh index 0c38f2ed45b1..aa2ef4e6b3da 100755 --- a/release/release.sh +++ b/release/release.sh @@ -86,11 +86,9 @@ env_setup() { # and ports/. GITROOT="https://git.FreeBSD.org/" SRCBRANCH="main" - DOCBRANCH="main" PORTBRANCH="head" GITSRC="src.git" GITPORTS="ports.git" - GITDOC="doc.git" # Set for embedded device builds. EMBEDDEDBUILD= @@ -112,8 +110,6 @@ env_setup() { KERNEL="GENERIC" # Set to non-empty value to disable checkout of doc/ and/or ports/. - # Disabling ports/ checkout also forces NODOC to be set. - NODOC= NOPORTS= # Set to non-empty value to disable distributing source tree. @@ -145,14 +141,12 @@ env_check() { # Prefix the branches with the GITROOT for the full checkout URL. SRC="${GITROOT}${GITSRC}" - DOC="${GITROOT}${GITDOC}" #PORT="${GITROOT}${GITPORTS}" PORT="svn://svn.freebsd.org/ports/" if [ -n "${EMBEDDEDBUILD}" ]; then WITH_DVD= WITH_COMPRESSED_IMAGES= - NODOC=yes case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in arm:arm*|arm64:aarch64|riscv:riscv64*) chroot_build_release_cmd="chroot_arm_build_release" @@ -162,26 +156,15 @@ env_check() { esac fi - # If PORTS is set and NODOC is unset, force NODOC=yes because the ports - # tree is required to build the documentation set. - if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then - echo "*** NOTICE: Setting NODOC=1 since ports tree is required" - echo " and NOPORTS is set." - NODOC=yes - fi - - # If NOSRC, NOPORTS and/or NODOC are unset, they must not pass to make + # If NOSRC and/or NOPORTS are unset, they must not pass to make # as variables. The release makefile verifies definedness of the - # NOPORTS/NODOC variables instead of their values. - SRCDOCPORTS= + # NOPORTS variable instead of its value. + SRCPORTS= if [ -n "${NOPORTS}" ]; then - SRCDOCPORTS="NOPORTS=yes" - fi - if [ -n "${NODOC}" ]; then - SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NODOC=yes" + SRCPORTS="NOPORTS=yes" fi if [ -n "${NOSRC}" ]; then - SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NOSRC=yes" + SRCPORTS="${SRCPORTS}${SRCPORTS:+ }NOSRC=yes" fi # The aggregated build-time flags based upon variables defined within @@ -220,7 +203,7 @@ env_check() { RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \ KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \ - KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCDOCPORTS} \ + KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCPORTS} \ WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \ WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}" @@ -239,13 +222,6 @@ chroot_setup() { ${VCSCMD} ${SRC} -b ${SRCBRANCH} ${CHROOTDIR}/usr/src fi fi - if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then - if [ -d "${CHROOTDIR}/usr/doc/.git" ]; then - git -C ${CHROOTDIR}/usr/doc pull -q - else - ${VCSCMD} ${DOC} -b ${DOCBRANCH} ${CHROOTDIR}/usr/doc - fi - fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then # git -C ${CHROOTDIR}/usr/ports pull -q @@ -327,26 +303,6 @@ extra_chroot_setup() { pkg clean -y fi fi - if [ -z "${NODOC}" ] && [ -d ${CHROOTDIR}/usr/ports ]; then - # Trick the ports 'run-autotools-fixup' target to do the right - # thing. - _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) - REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) - BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) - UNAME_r=${REVISION}-${BRANCH} - if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then - PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes" - PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}" - PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" - PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports" - PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles" - chroot ${CHROOTDIR} env ${PBUILD_FLAGS} \ - OPTIONS_UNSET="AVAHI FOP IGOR" make -C \ - /usr/ports/textproc/docproj \ - FORCE_PKG_REGISTER=1 \ - install clean distclean - fi - fi if [ ! -z "${EMBEDDEDPORTS}" ]; then _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) diff --git a/release/riscv/GENERICSD.conf b/release/riscv/GENERICSD.conf index 52734b1dd8e8..d85a8ff7cd93 100644 --- a/release/riscv/GENERICSD.conf +++ b/release/riscv/GENERICSD.conf @@ -11,6 +11,5 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" export BOARDNAME="GENERICSD" From owner-dev-commits-src-all@freebsd.org Wed May 12 15:51:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5FBCC642DA2; Wed, 12 May 2021 15:51:00 +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 4FgK5J2JpVz4m4m; Wed, 12 May 2021 15:51:00 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4273F5E5E; Wed, 12 May 2021 15:51:00 +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 14CFp0lh032507; Wed, 12 May 2021 15:51:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFp0Yv032506; Wed, 12 May 2021 15:51:00 GMT (envelope-from git) Date: Wed, 12 May 2021 15:51:00 GMT Message-Id: <202105121551.14CFp0Yv032506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: ae0b4bec3af0 - stable/12 - release: disable the 'reldoc' target after the ASCIIDoctor switch MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ae0b4bec3af0787091afb735acb060f6c616d792 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:51:00 -0000 The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=ae0b4bec3af0787091afb735acb060f6c616d792 commit ae0b4bec3af0787091afb735acb060f6c616d792 Author: Glen Barber AuthorDate: 2021-02-05 16:46:49 +0000 Commit: Glen Barber CommitDate: 2021-05-12 14:55:06 +0000 release: disable the 'reldoc' target after the ASCIIDoctor switch The 'reldoc' target includes release-related documentation on installation medium. Since the switch from XML to ASCIIDoctor, the file locations have moved, and it will take some time to sort out how this target should work now. Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac) --- release/Makefile | 72 ++++++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/release/Makefile b/release/Makefile index f4c640b844fa..db6a56296c6a 100644 --- a/release/Makefile +++ b/release/Makefile @@ -88,18 +88,9 @@ EXTRA_PACKAGES+= ports.txz .if !defined(NOSRC) EXTRA_PACKAGES+= src.txz .endif -.if !defined(NODOC) -EXTRA_PACKAGES+= reldoc -. if !defined(SVN) || empty(SVN) -. for S in svn svnlite -. for D in /usr/local/bin /usr/bin -. if(exists(${D}/${S})) -SVN?= ${D}/${S} -. endif -. endfor -. endfor -. endif -.endif +#.if !defined(NODOC) +#EXTRA_PACKAGES+= reldoc +#.endif RELEASE_TARGETS= ftp IMAGES= @@ -128,9 +119,9 @@ CLEANFILES+= ${I}.xz CLEANFILES+= pkg-stage .endif CLEANDIRS= dist ftp disc1 bootonly dvd -.if !defined(NODOC) -CLEANDIRS+= reldoc rdoc -.endif +#.if !defined(NODOC) +#CLEANDIRS+= reldoc rdoc +#.endif beforeclean: chflags -R noschg . .include @@ -170,23 +161,22 @@ ports.txz: --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ ${XZ_CMD} > ${.OBJDIR}/ports.txz -reldoc: - cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \ - env MAN4DIR=${WORLDDIR}/share/man/man4 \ - SVN=${SVN} \ - _BRANCH=${BRANCH} \ - ${MAKE} all install clean "FORMATS=html txt" \ - INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \ - WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc - mkdir -p reldoc -.for i in hardware readme relnotes errata - ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \ - reldoc/${i:tu}.TXT - ln -f ${.OBJDIR}/rdoc/${i:tl}.html \ - reldoc/${i:tu}.HTML -.endfor - cp ${.OBJDIR}/rdoc/docbook.css \ - reldoc/ +#reldoc: +# cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \ +# env MAN4DIR=${WORLDDIR}/share/man/man4 \ +# _BRANCH=${BRANCH} \ +# ${MAKE} all install clean "FORMATS=html txt" \ +# INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \ +# WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc +# mkdir -p reldoc +#.for i in hardware readme relnotes errata +# ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \ +# reldoc/${i:tu}.TXT +# ln -f ${.OBJDIR}/rdoc/${i:tl}.html \ +# reldoc/${i:tu}.HTML +#.endfor +# cp ${.OBJDIR}/rdoc/docbook.css \ +# reldoc/ disc1: packagesystem # Install system @@ -204,9 +194,9 @@ disc1: packagesystem do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done # Copy documentation, if generated -.if !defined(NODOC) - cp reldoc/* ${.TARGET} -.endif +#.if !defined(NODOC) +# cp reldoc/* ${.TARGET} +#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -231,9 +221,9 @@ bootonly: packagesystem mkdir -p ${.TARGET}/usr/freebsd-dist cp MANIFEST ${.TARGET}/usr/freebsd-dist # Copy documentation, if generated -.if !defined(NODOC) - cp reldoc/* ${.TARGET} -.endif +#.if !defined(NODOC) +# cp reldoc/* ${.TARGET} +#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -255,9 +245,9 @@ dvd: packagesystem do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done # Copy documentation, if generated -.if !defined(NODOC) - cp reldoc/* ${.TARGET} -.endif +#.if !defined(NODOC) +# cp reldoc/* ${.TARGET} +#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf From owner-dev-commits-src-all@freebsd.org Wed May 12 15:51:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85262642CC5; Wed, 12 May 2021 15:51: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 4FgK5K383Wz4ltX; Wed, 12 May 2021 15:51:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5CBD4619D; Wed, 12 May 2021 15:51:01 +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 14CFp1PR032528; Wed, 12 May 2021 15:51:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFp1mq032527; Wed, 12 May 2021 15:51:01 GMT (envelope-from git) Date: Wed, 12 May 2021 15:51:01 GMT Message-Id: <202105121551.14CFp1mq032527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: db83952138a9 - stable/12 - release: permanently remove the 'reldoc' target and associates MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: db83952138a9c65ba9ac77b2fb5801159fd1e915 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:51:01 -0000 The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=db83952138a9c65ba9ac77b2fb5801159fd1e915 commit db83952138a9c65ba9ac77b2fb5801159fd1e915 Author: Glen Barber AuthorDate: 2021-02-18 04:00:03 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:11:18 +0000 release: permanently remove the 'reldoc' target and associates Following 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac, the structure for the reldoc target has significantly changed as result of the ASCIIDoctor/Hugo migration. As the release notes related files on the installation medium are inherently out of date, purge them entirely. Discussed within: re, doceng No objection: re (silence), doceng (silence) Timeout: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit f61e92ca5a23450bc28169bbdd71d7674df98c19) --- release/Makefile | 41 ----------------------- release/arm/GENERICSD.conf | 6 +++- release/arm/RPI-B.conf | 1 - release/arm64/PINE64-LTS.conf | 1 - release/arm64/PINE64.conf | 1 - release/arm64/PINEBOOK.conf | 1 - release/arm64/ROCKPRO64.conf | 1 - release/release.conf.sample | 17 ++++++---- release/release.sh | 77 +++++++++++++++++++++---------------------- 9 files changed, 52 insertions(+), 94 deletions(-) diff --git a/release/Makefile b/release/Makefile index db6a56296c6a..09b1b6a2c855 100644 --- a/release/Makefile +++ b/release/Makefile @@ -20,12 +20,10 @@ # WORLDDIR: location of src tree -- must have built world and default kernel # (by default, the directory above this one) # PORTSDIR: location of ports tree to distribute (default: /usr/ports) -# DOCDIR: location of doc tree (default: /usr/doc) # XTRADIR: xtra-bits-dir argument for /mkisoimages.sh # NOPKG: if set, do not distribute third-party packages # NOPORTS: if set, do not distribute ports tree # NOSRC: if set, do not distribute source tree -# NODOC: if set, do not generate release documentation # WITH_DVD: if set, generate dvd1.iso # WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) # (uncompressed images are not removed) @@ -38,7 +36,6 @@ WORLDDIR?= ${.CURDIR}/.. PORTSDIR?= /usr/ports -DOCDIR?= /usr/doc RELNOTES_LANG?= en_US.ISO8859-1 .if !defined(TARGET) || empty(TARGET) @@ -74,9 +71,6 @@ VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH} VOLUME_LABEL= FreeBSD_Install .endif -.if !exists(${DOCDIR}) -NODOC= true -.endif .if !exists(${PORTSDIR}) NOPORTS= true .endif @@ -88,9 +82,6 @@ EXTRA_PACKAGES+= ports.txz .if !defined(NOSRC) EXTRA_PACKAGES+= src.txz .endif -#.if !defined(NODOC) -#EXTRA_PACKAGES+= reldoc -#.endif RELEASE_TARGETS= ftp IMAGES= @@ -119,9 +110,6 @@ CLEANFILES+= ${I}.xz CLEANFILES+= pkg-stage .endif CLEANDIRS= dist ftp disc1 bootonly dvd -#.if !defined(NODOC) -#CLEANDIRS+= reldoc rdoc -#.endif beforeclean: chflags -R noschg . .include @@ -161,23 +149,6 @@ ports.txz: --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ ${XZ_CMD} > ${.OBJDIR}/ports.txz -#reldoc: -# cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \ -# env MAN4DIR=${WORLDDIR}/share/man/man4 \ -# _BRANCH=${BRANCH} \ -# ${MAKE} all install clean "FORMATS=html txt" \ -# INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \ -# WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc -# mkdir -p reldoc -#.for i in hardware readme relnotes errata -# ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \ -# reldoc/${i:tu}.TXT -# ln -f ${.OBJDIR}/rdoc/${i:tl}.html \ -# reldoc/${i:tu}.HTML -#.endfor -# cp ${.OBJDIR}/rdoc/docbook.css \ -# reldoc/ - disc1: packagesystem # Install system mkdir -p ${.TARGET} @@ -193,10 +164,6 @@ disc1: packagesystem for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -220,10 +187,6 @@ bootonly: packagesystem # Copy manifest only (no distfiles) to get checksums mkdir -p ${.TARGET}/usr/freebsd-dist cp MANIFEST ${.TARGET}/usr/freebsd-dist -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf @@ -244,10 +207,6 @@ dvd: packagesystem for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \ do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ done -# Copy documentation, if generated -#.if !defined(NODOC) -# cp reldoc/* ${.TARGET} -#.endif # Set up installation environment ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf diff --git a/release/arm/GENERICSD.conf b/release/arm/GENERICSD.conf index 17086ba59185..98af1ef0d228 100644 --- a/release/arm/GENERICSD.conf +++ b/release/arm/GENERICSD.conf @@ -11,6 +11,10 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 +BBB_UBOOT_DIR="/usr/local/share/u-boot/u-boot-beaglebone" +RPI_UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2" +RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware" +RPI_OL_DIR="${RPI_FIRMWARE_DIR}/overlays" +OVERLAYS="mmc.dtbo" PART_SCHEME="MBR" export BOARDNAME="GENERICSD" diff --git a/release/arm/RPI-B.conf b/release/arm/RPI-B.conf index 27fa6aac2644..f164edd25b90 100644 --- a/release/arm/RPI-B.conf +++ b/release/arm/RPI-B.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="RPI-B" MD_ARGS="-x 63 -y 255" -NODOC=1 UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi" RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware" OL_DIR="${RPI_FIRMWARE_DIR}/overlays" diff --git a/release/arm64/PINE64-LTS.conf b/release/arm64/PINE64-LTS.conf index 39fff59563f1..2605cfde486d 100644 --- a/release/arm64/PINE64-LTS.conf +++ b/release/arm64/PINE64-LTS.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="MBR" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64-LTS" diff --git a/release/arm64/PINE64.conf b/release/arm64/PINE64.conf index ed433f78caf6..377b8ffe96a6 100644 --- a/release/arm64/PINE64.conf +++ b/release/arm64/PINE64.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="MBR" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINE64" diff --git a/release/arm64/PINEBOOK.conf b/release/arm64/PINEBOOK.conf index cb09047b9c87..a4304a76b0ef 100644 --- a/release/arm64/PINEBOOK.conf +++ b/release/arm64/PINEBOOK.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="2560M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="MBR" FDT_OVERLAYS="sun50i-a64-timer,sun50i-a64-opp" export BOARDNAME="PINEBOOK" diff --git a/release/arm64/ROCKPRO64.conf b/release/arm64/ROCKPRO64.conf index 29d19bd8a46f..29946b2e3935 100644 --- a/release/arm64/ROCKPRO64.conf +++ b/release/arm64/ROCKPRO64.conf @@ -12,7 +12,6 @@ FAT_TYPE="16" IMAGE_SIZE="3072M" KERNEL="GENERIC" MD_ARGS="-x 63 -y 255" -NODOC=1 PART_SCHEME="GPT" export BOARDNAME="ROCKPRO64" diff --git a/release/release.conf.sample b/release/release.conf.sample index 7619670cecc8..8488be7587c7 100644 --- a/release/release.conf.sample +++ b/release/release.conf.sample @@ -17,8 +17,7 @@ SVNROOT="svn://svn.FreeBSD.org/" ## Set the src/, ports/, and doc/ branches or tags. SRCBRANCH="base/stable/12@rHEAD" -DOCBRANCH="doc/head@rHEAD" -PORTBRANCH="ports/head@rHEAD" +PORTBRANCH="main" ## Run svn co --force for src checkout. #SRC_FORCE_CHECKOUT=yes @@ -29,6 +28,15 @@ PORTBRANCH="ports/head@rHEAD" #SRCBRANCH="https://github.com/freebsd/freebsd" #DOCBRANCH="https://github.com/freebsd/freebsd-doc" #PORTBRANCH="https://github.com/freebsd/freebsd-ports" +## Do not explicitly require the devel/git port to be installed. +#NOGIT=1 +## Set the version control system host. +GITROOT="https://git.freebsd.org/" +GITSRC="src.git" +GITPORTS="ports.git" + +## Sample configuration for using git from ports. +#GITCMD="/usr/local/bin/git clone -q --branch main" ## Set to override the default target architecture. #TARGET="amd64" @@ -49,7 +57,6 @@ PORTBRANCH="ports/head@rHEAD" #KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))" ## Set miscellaneous 'make release' settings. -#NODOC= #NOPORTS= #NOSRC= #WITH_DVD= @@ -84,10 +91,6 @@ PORTBRANCH="ports/head@rHEAD" ## the chroot. This is intended for use when /usr/src already exists. #SRC_UPDATE_SKIP= -## Set to a non-empty value skip checkout or update of /usr/doc in -## the chroot. This is intended for use when /usr/doc already exists. -#DOC_UPDATE_SKIP= - ## Set to a non-empty value skip checkout or update of /usr/ports in ## the chroot. This is intended for use when /usr/ports already exists. #PORTS_UPDATE_SKIP= diff --git a/release/release.sh b/release/release.sh index c7ae9959e7dc..47c64e796404 100755 --- a/release/release.sh +++ b/release/release.sh @@ -70,9 +70,10 @@ env_setup() { # The default svn checkout server, and svn branches for src/, doc/, # and ports/. SVNROOT="svn://svn.FreeBSD.org/" - SRCBRANCH="base/head@rHEAD" - DOCBRANCH="doc/head@rHEAD" - PORTBRANCH="ports/head@rHEAD" + SRCBRANCH="base/stable/12@rHEAD" + PORTBRANCH="main" + GITROOT="https://git.FreeBSD.org/" + GITPORTS="ports.git" # Set for embedded device builds. EMBEDDEDBUILD= @@ -98,8 +99,6 @@ env_setup() { KERNEL="GENERIC" # Set to non-empty value to disable checkout of doc/ and/or ports/. - # Disabling ports/ checkout also forces NODOC to be set. - NODOC= NOPORTS= # Set to non-empty value to disable distributing source tree. @@ -140,13 +139,12 @@ env_check() { # Prefix the branches with the SVNROOT for the full checkout URL. SRCBRANCH="${SVNROOT}${SRCBRANCH}" - DOCBRANCH="${SVNROOT}${DOCBRANCH}" - PORTBRANCH="${SVNROOT}${PORTBRANCH}" + # Prefix the branches with the GITROOT for the full checkout URL. + PORT="${GITROOT}${GITPORTS}" if [ -n "${EMBEDDEDBUILD}" ]; then WITH_DVD= WITH_COMPRESSED_IMAGES= - NODOC=yes case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in arm:arm*|arm64:aarch64) chroot_build_release_cmd="chroot_arm_build_release" @@ -156,26 +154,15 @@ env_check() { esac fi - # If PORTS is set and NODOC is unset, force NODOC=yes because the ports - # tree is required to build the documentation set. - if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then - echo "*** NOTICE: Setting NODOC=1 since ports tree is required" - echo " and NOPORTS is set." - NODOC=yes - fi - - # If NOSRC, NOPORTS and/or NODOC are unset, they must not pass to make + # If NOSRC and/or NOPORTS are unset, they must not pass to make # as variables. The release makefile verifies definedness of the - # NOPORTS/NODOC variables instead of their values. - SRCDOCPORTS= + # NOPORTS variable instead of its value. + SRCPORTS= if [ -n "${NOPORTS}" ]; then - SRCDOCPORTS="NOPORTS=yes" - fi - if [ -n "${NODOC}" ]; then - SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NODOC=yes" + SRCPORTS="NOPORTS=yes" fi if [ -n "${NOSRC}" ]; then - SRCDOCPORTS="${SRCDOCPORTS}${SRCDOCPORTS:+ }NOSRC=yes" + SRCPORTS="${SRCPORTS}${SRCPORTS:+ }NOSRC=yes" fi # The aggregated build-time flags based upon variables defined within @@ -218,7 +205,7 @@ env_check() { RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \ KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}" RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \ - KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCDOCPORTS} \ + KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${SRCPORTS} \ WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \ WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}" @@ -233,9 +220,6 @@ chroot_setup() { if [ -z "${SRC_UPDATE_SKIP}" ]; then ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src fi - if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then - ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc - fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports fi @@ -274,24 +258,37 @@ extra_chroot_setup() { cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF} fi - if [ -d ${CHROOTDIR}/usr/ports ]; then - # Trick the ports 'run-autotools-fixup' target to do the right - # thing. - _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) - REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) - BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) - UNAME_r=${REVISION}-${BRANCH} - if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then + if [ -z "${NOGIT}" ]; then + # Install git from ports or packages if the ports tree is + # available and VCSCMD is unset. + _gitcmd="$(which git)" + if [ -d ${CHROOTDIR}/usr/ports -a -z "${_gitcmd}" ]; then + # Trick the ports 'run-autotools-fixup' target to do the right + # thing. + _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) + REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) + BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) + UNAME_r=${REVISION}-${BRANCH} + GITUNSETOPTS="CONTRIB CURL CVS GITWEB GUI HTMLDOCS" + GITUNSETOPTS="${GITUNSETOPTS} ICONV NLS P4 PERL" + GITUNSETOPTS="${GITUNSETOPTS} SEND_EMAIL SUBTREE SVN" + GITUNSETOPTS="${GITUNSETOPTS} PCRE PCRE2" PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes" PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}" PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports" PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles" - chroot ${CHROOTDIR} env ${PBUILD_FLAGS} \ - OPTIONS_UNSET="AVAHI FOP IGOR" make -C \ - /usr/ports/textproc/docproj \ - FORCE_PKG_REGISTER=1 \ + eval chroot ${CHROOTDIR} env OPTIONS_UNSET=\"${GITUNSETOPTS}\" \ + ${PBUILD_FLAGS} \ + make -C /usr/ports/devel/git FORCE_PKG_REGISTER=1 \ + WRKDIRPREFIX=/tmp/ports \ + DISTDIR=/tmp/distfiles \ install clean distclean + else + eval chroot ${CHROOTDIR} env ASSUME_ALWAYS_YES=yes \ + pkg install -y devel/git + eval chroot ${CHROOTDIR} env ASSUME_ALWAYS_YES=yes \ + pkg clean -y fi fi From owner-dev-commits-src-all@freebsd.org Wed May 12 15:51:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2472C642A66; Wed, 12 May 2021 15:51:03 +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 4FgK5L6ZX8z4lx1; Wed, 12 May 2021 15:51:02 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8CDD85A76; Wed, 12 May 2021 15:51:02 +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 14CFp2al032549; Wed, 12 May 2021 15:51:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFp2cP032548; Wed, 12 May 2021 15:51:02 GMT (envelope-from git) Date: Wed, 12 May 2021 15:51:02 GMT Message-Id: <202105121551.14CFp2cP032548@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: a87bab2feb1f - stable/12 - release: fix command to check out ports tree MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a87bab2feb1fc71dc2121ec2f4dd852748a1648c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:51:03 -0000 The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=a87bab2feb1fc71dc2121ec2f4dd852748a1648c commit a87bab2feb1fc71dc2121ec2f4dd852748a1648c Author: Glen Barber AuthorDate: 2021-05-12 15:12:34 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:12:34 +0000 release: fix command to check out ports tree This is a direct commit to stable/12. Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/release.sh b/release/release.sh index 47c64e796404..9ea6c5ee2cae 100755 --- a/release/release.sh +++ b/release/release.sh @@ -221,7 +221,7 @@ chroot_setup() { ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then - ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports + git -C ${CHROOTDIR}/usr/ports -b ${PORTBRANCH} clone fi if [ -z "${CHROOTBUILD_SKIP}" ]; then From owner-dev-commits-src-all@freebsd.org Wed May 12 15:51:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F420F642E31; Wed, 12 May 2021 15:51:03 +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 4FgK5M60SBz4m52; Wed, 12 May 2021 15:51:03 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AC1A4617C; Wed, 12 May 2021 15:51:03 +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 14CFp3lc032578; Wed, 12 May 2021 15:51:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFp3Hq032577; Wed, 12 May 2021 15:51:03 GMT (envelope-from git) Date: Wed, 12 May 2021 15:51:03 GMT Message-Id: <202105121551.14CFp3Hq032577@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 41f27ff22956 - stable/12 - release: fix logic for ports update/checkout if the directory exists MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 41f27ff229564baab3f1c92be6222ea52fb0417d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:51:04 -0000 The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=41f27ff229564baab3f1c92be6222ea52fb0417d commit 41f27ff229564baab3f1c92be6222ea52fb0417d Author: Glen Barber AuthorDate: 2021-05-12 15:29:54 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:29:54 +0000 release: fix logic for ports update/checkout if the directory exists This is a direct commit to stable/12. Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/release/release.sh b/release/release.sh index 9ea6c5ee2cae..7326157a8562 100755 --- a/release/release.sh +++ b/release/release.sh @@ -221,7 +221,11 @@ chroot_setup() { ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then - git -C ${CHROOTDIR}/usr/ports -b ${PORTBRANCH} clone + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then + git -C ${CHROOTDIR}/usr/ports pull -q + else + git -C ${CHROOTDIR}/usr/ports -b ${PORTBRANCH} clone + fi fi if [ -z "${CHROOTBUILD_SKIP}" ]; then From owner-dev-commits-src-all@freebsd.org Wed May 12 15:57:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 00FED643B97; Wed, 12 May 2021 15:57:10 +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 4FgKDP6bpTz4mVk; Wed, 12 May 2021 15:57:09 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D5BCF5EC9; Wed, 12 May 2021 15:57:09 +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 14CFv9xN037031; Wed, 12 May 2021 15:57:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFv9J6037030; Wed, 12 May 2021 15:57:09 GMT (envelope-from git) Date: Wed, 12 May 2021 15:57:09 GMT Message-Id: <202105121557.14CFv9J6037030@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 18fe4221391f - stable/13 - release: update release.sh to use Git for ports tree checkouts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 18fe4221391f78bb91bb172c6d2cb2e0ef27cfef Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:57:10 -0000 The branch stable/13 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=18fe4221391f78bb91bb172c6d2cb2e0ef27cfef commit 18fe4221391f78bb91bb172c6d2cb2e0ef27cfef Author: Glen Barber AuthorDate: 2021-05-12 14:27:21 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:51:53 +0000 release: update release.sh to use Git for ports tree checkouts Approved by: re (delphij, insta-MFC) Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 3f25cfea55922780fe47eb6ebcef49ca15297261) --- release/release.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/release/release.sh b/release/release.sh index aa2ef4e6b3da..84a7813205f9 100755 --- a/release/release.sh +++ b/release/release.sh @@ -86,7 +86,7 @@ env_setup() { # and ports/. GITROOT="https://git.FreeBSD.org/" SRCBRANCH="main" - PORTBRANCH="head" + PORTBRANCH="main" GITSRC="src.git" GITPORTS="ports.git" @@ -141,8 +141,7 @@ env_check() { # Prefix the branches with the GITROOT for the full checkout URL. SRC="${GITROOT}${GITSRC}" - #PORT="${GITROOT}${GITPORTS}" - PORT="svn://svn.freebsd.org/ports/" + PORT="${GITROOT}${GITPORTS}" if [ -n "${EMBEDDEDBUILD}" ]; then WITH_DVD= From owner-dev-commits-src-all@freebsd.org Wed May 12 15:57:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5A68B643AA8; Wed, 12 May 2021 15:57:11 +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 4FgKDR0JD5z4mVn; Wed, 12 May 2021 15:57:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 ED6C9606D; Wed, 12 May 2021 15:57:10 +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 14CFvAj3037054; Wed, 12 May 2021 15:57:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFvA9e037053; Wed, 12 May 2021 15:57:10 GMT (envelope-from git) Date: Wed, 12 May 2021 15:57:10 GMT Message-Id: <202105121557.14CFvA9e037053@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 929bf5b637c3 - stable/13 - release: follow-up to previous commit to use Git for the ports tree MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 929bf5b637c3cfdfdabdd2fbf95e786fd7e64141 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:57:11 -0000 The branch stable/13 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=929bf5b637c3cfdfdabdd2fbf95e786fd7e64141 commit 929bf5b637c3cfdfdabdd2fbf95e786fd7e64141 Author: Glen Barber AuthorDate: 2021-05-12 14:29:53 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:52:23 +0000 release: follow-up to previous commit to use Git for the ports tree Approved by: re (delphij, insta-MFC) Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit fb6e261c20ebcd94875d623e167369802721f2dd) --- release/release.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/release/release.sh b/release/release.sh index 84a7813205f9..87e22e669fd1 100755 --- a/release/release.sh +++ b/release/release.sh @@ -222,16 +222,8 @@ chroot_setup() { fi fi if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then - # git -C ${CHROOTDIR}/usr/ports pull -q - # XXX: Workaround for the overlap in the Git conversion timeframe. - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then - ${SVNCMD} update ${CHROOTDIR}/usr/ports - else - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports - # XXX: Workaround for the overlap in the Git - # conversion timeframe. - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then + git -C ${CHROOTDIR}/usr/ports pull -q fi fi From owner-dev-commits-src-all@freebsd.org Wed May 12 15:57:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B881643C84; Wed, 12 May 2021 15:57:12 +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 4FgKDS2fQwz4mW0; Wed, 12 May 2021 15:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2A6FF61CA; Wed, 12 May 2021 15:57:12 +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 14CFvCr3037075; Wed, 12 May 2021 15:57:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CFvC4g037074; Wed, 12 May 2021 15:57:12 GMT (envelope-from git) Date: Wed, 12 May 2021 15:57:12 GMT Message-Id: <202105121557.14CFvC4g037074@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: 0ed1051313c1 - stable/13 - release: remove logic to locate the svn{, lite} binary MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0ed1051313c12644f7b9582eded1a5e68c1e7598 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 15:57:12 -0000 The branch stable/13 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=0ed1051313c12644f7b9582eded1a5e68c1e7598 commit 0ed1051313c12644f7b9582eded1a5e68c1e7598 Author: Glen Barber AuthorDate: 2021-05-12 14:32:03 +0000 Commit: Glen Barber CommitDate: 2021-05-12 15:52:53 +0000 release: remove logic to locate the svn{,lite} binary Approved by: re (delphij, insta-MFC) Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 69b6abb7b2bb2b07600b27660d864ddcd0b28cec) --- release/release.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/release/release.sh b/release/release.sh index 87e22e669fd1..a448361b86a6 100755 --- a/release/release.sh +++ b/release/release.sh @@ -65,17 +65,6 @@ env_setup() { [ ! -z "${VCSCMD}" ] && break 2 done - # Find the Subversion binary to use. This is a workaround to use - # the source of truth for the ports tree, as the conversion to Git - # is targeted to occur slightly after the currently-scheduled 13.0 - # release. - for _dir in /usr/bin /usr/local/bin; do - for _svn in svn svnlite; do - [ -x "${_dir}/${_svn}" ] && SVNCMD="${_dir}/${_svn}" - [ ! -z "${SVNCMD}" ] && break 2 - done - done - if [ -z "${VCSCMD}" -a -z "${NOGIT}" ]; then echo "*** The devel/git port/package is required." exit 1 From owner-dev-commits-src-all@freebsd.org Wed May 12 16:04:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 981C2643F55; Wed, 12 May 2021 16:04:31 +0000 (UTC) (envelope-from yasu@utahime.org) Received: from maybe.home.utahime.org (gate.home.utahime.org [183.180.29.210]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4FgKNv26q7z4nFd; Wed, 12 May 2021 16:04:30 +0000 (UTC) (envelope-from yasu@utahime.org) Received: from eastasia.home.utahime.org (eastasia.home.utahime.org [192.168.174.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by maybe.home.utahime.org (Postfix) with ESMTPS id 068D72EAED; Thu, 13 May 2021 01:04:26 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=utahime.org; s=maybe2019112701; t=1620835466; bh=jI0h5E0Jpa44AqE+3T43HONXHiHdnyKK4DGFlkdII4Y=; h=Date:To:Cc:Subject:From:In-Reply-To:References; b=u1Eke5sJ6KXxHXCNuodx8BDzVaP6Zn7GtVX+vbsSYAz4qpLDIX/BoCv3zFEw3Nu5n 0a4LxWWZvXsB2BBB6oxzMrNVGTpSxhVASHwEtfcFJ8hgF9PgInCMQvnIDNxpqRDiqF wl8El7T8tytH/x9Djzx0uWlbJ66awqJjy+/dr+NnJQgtm6KK/rkmxBoJNWOXr4uQii 4NFfOy3X0dC7B8wflpah0ATP3taV3WPG920rL0zITuDymPhJq32eOgmRz2Ik51fX7v WksKbbZdVPIl4QaGDXs0hWUMTh80nMh+htIp15iF7FAyPjQHsoDGVVUIjBu18/AnWG onaV9KJc9V6UA== Received: from localhost (rolling.home.utahime.org [192.168.174.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by eastasia.home.utahime.org (Postfix) with ESMTPSA id F13C43B410; Thu, 13 May 2021 01:04:24 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at eastasia.home.utahime.org Date: Thu, 13 May 2021 01:03:37 +0900 (JST) Message-Id: <20210513.010337.560902240722301845.yasu@utahime.org> To: gjb@FreeBSD.org Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: fb6e261c20eb - main - release: follow-up to previous commit to use Git for the ports tree From: Yasuhiro Kimura In-Reply-To: <202105121448.14CEmfJH042754@gitrepo.freebsd.org> References: <202105121448.14CEmfJH042754@gitrepo.freebsd.org> X-Mailer: Mew version 6.8 on Emacs 27.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FgKNv26q7z4nFd X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:04:31 -0000 Hello Glen, From: Glen Barber Subject: git: fb6e261c20eb - main - release: follow-up to previous commit to use Git for the ports tree Date: Wed, 12 May 2021 14:48:41 GMT > diff --git a/release/release.sh b/release/release.sh > index 84a7813205f9..87e22e669fd1 100755 > --- a/release/release.sh > +++ b/release/release.sh > @@ -222,16 +222,8 @@ chroot_setup() { > fi > fi > if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then > - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > - # git -C ${CHROOTDIR}/usr/ports pull -q > - # XXX: Workaround for the overlap in the Git conversion timeframe. > - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then > - ${SVNCMD} update ${CHROOTDIR}/usr/ports > - else > - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > - # XXX: Workaround for the overlap in the Git > - # conversion timeframe. > - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports > + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > + git -C ${CHROOTDIR}/usr/ports pull -q > fi > fi This should be such as following. ---------------------------------------------------------------------- if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then - # git -C ${CHROOTDIR}/usr/ports pull -q - # XXX: Workaround for the overlap in the Git conversion timeframe. - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then - ${SVNCMD} update ${CHROOTDIR}/usr/ports - else - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports - # XXX: Workaround for the overlap in the Git - # conversion timeframe. - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then + git -C ${CHROOTDIR}/usr/ports pull -q + else + ${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports fi fi ---------------------------------------------------------------------- Or ports tree isn't checked out when build is from scratch. --- Yasuhiro Kimura From owner-dev-commits-src-all@freebsd.org Wed May 12 16:06:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B61B0644056; Wed, 12 May 2021 16:06:47 +0000 (UTC) (envelope-from gjb@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FgKRW4nGpz4nP5; Wed, 12 May 2021 16:06:47 +0000 (UTC) (envelope-from gjb@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1620835607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iM/6S/XBpIHR3FKh83auetAQd0nHp17ge8Ep90ukPs4=; b=Kjnc9ydulKwJ4FEEW6htLj7eJmft7N1yCx9i+vS3LN48oR7zi2cEJ+U+Y1osHSfXlV5Vbt Q5qVsPvplgyll6of5wb/zZhimnEKEQZBK3MH7NVBq8PmdcK4HdcSmEH25drqNXMpcmeCqW e4y+CfdRNM/+z4cj00VCFzs7yr0QlyjkMWN4Hp2pSPDzgaBek5rh/I7vNQLzdZ+zmcVUOG vrWg9b3IlS3ENPUHQINBGZR4XC031N1bw59adl/b1iGALN9DvqleEE6TgK/dD95CMoKXVh nIr2niOTnh2sDXzsj9gkkc037IeIBBAJfO3xoHv6DBfa+ebu/MjpBJinYAet9w== Received: from FreeBSD.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id 31BF818C07; Wed, 12 May 2021 16:06:47 +0000 (UTC) (envelope-from gjb@freebsd.org) Date: Wed, 12 May 2021 16:06:45 +0000 From: Glen Barber To: Yasuhiro Kimura Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: fb6e261c20eb - main - release: follow-up to previous commit to use Git for the ports tree Message-ID: <20210512160645.GJ92026@FreeBSD.org> References: <202105121448.14CEmfJH042754@gitrepo.freebsd.org> <20210513.010337.560902240722301845.yasu@utahime.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QFQuXaHm0gDucWbk" Content-Disposition: inline In-Reply-To: <20210513.010337.560902240722301845.yasu@utahime.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1620835607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iM/6S/XBpIHR3FKh83auetAQd0nHp17ge8Ep90ukPs4=; b=wJmfwqtzZJaRHh90jewE8Fjzm+gZ9VpHeV9AQvdr/Ov/MRXxnCqYwPIvph1a0M9rxpQAJM ZrG+hQuVPEWSv6brJtC1Ql7jeA5FES4LDrAsImkbaLrggYV3+Sr4EGxfMIawzUif/oe0ua i0yPOK3NsBfmz026KqHMVHkE7MRNy8ELh4mCn6ANP5znPm+P/LXmZvTrZjxnpRo9EJMgKa 8u1cZWxmUbOCI1QYBXmeGVgHPiKrcdlzz4HsfJUxYl9Y63kBRLWU6tC1mpu0lbgRE01qRe Md+1G/biBV4VvzwSJGz9WsdID717oyjuFrHd/MgBkj14Mddj4qbTM/cHla99yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1620835607; a=rsa-sha256; cv=none; b=iE+2vhOtTM7+rRbhfXN9olLQtdHhDG/s0Ffhq9ogABDK6dOeAuUZUNHD6h8EjPE19F+3U9 9AQkJ635VADipvOnwUlqblb/Kb+LotHkvPWAa1fYG0qbJkkr8x4tKvwZ+GHEPTauEGKVEW osAq3kcani7w1rJGEAt7Mtt4+OIS0KpFGNr4mBNUj63hMvEhdc1KaMJhjhxgJd3Kn27yS0 3TmK2PcmWZp50fvKRL2z8+C45ZmwHzxdHBFtWpRqYAtO3eW7AxKI/8l4db0f2oHasoXXOC o9jvMzwHzD8QJ+yZWb/RBPE0HO0LPjgSU8v9+1OEopllZo+IJKt8Kr06kQvL6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:06:47 -0000 --QFQuXaHm0gDucWbk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 13, 2021 at 01:03:37AM +0900, Yasuhiro Kimura wrote: > Hello Glen, >=20 > From: Glen Barber > Subject: git: fb6e261c20eb - main - release: follow-up to previous commit= to use Git for the ports tree > Date: Wed, 12 May 2021 14:48:41 GMT >=20 > > diff --git a/release/release.sh b/release/release.sh > > index 84a7813205f9..87e22e669fd1 100755 > > --- a/release/release.sh > > +++ b/release/release.sh > > @@ -222,16 +222,8 @@ chroot_setup() { > > fi > > fi > > if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then > > - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > - # git -C ${CHROOTDIR}/usr/ports pull -q > > - # XXX: Workaround for the overlap in the Git conversion timeframe. > > - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then > > - ${SVNCMD} update ${CHROOTDIR}/usr/ports > > - else > > - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > > - # XXX: Workaround for the overlap in the Git > > - # conversion timeframe. > > - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports > > + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > + git -C ${CHROOTDIR}/usr/ports pull -q > > fi > > fi >=20 > This should be such as following. >=20 > ---------------------------------------------------------------------- > if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then > - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > - # git -C ${CHROOTDIR}/usr/ports pull -q > - # XXX: Workaround for the overlap in the Git conversion timeframe. > - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then > - ${SVNCMD} update ${CHROOTDIR}/usr/ports > - else > - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > - # XXX: Workaround for the overlap in the Git > - # conversion timeframe. > - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports > + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > + git -C ${CHROOTDIR}/usr/ports pull -q > + else > + ${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > fi > fi > ---------------------------------------------------------------------- >=20 > Or ports tree isn't checked out when build is from scratch. >=20 Bah, you're right. I fixed it in stable/13 without noticing it was needed here, too. Thanks for spotting this. Glen --QFQuXaHm0gDucWbk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEjRJAPC5sqwhs9k2jAxRYpUeP4pMFAmCb/RQACgkQAxRYpUeP 4pN75Q/+Jebv7Kefjt7Q9E+aFj0SHLl8Dt+p2xetVJAyPejm+UEZvrZ4D7kP1A57 fJXgPehfZ6TEYhW0sZIUyMInX+RCmhgcgN6Lhhf/LU9GuHIsLpDjdluv5tOiY4Wr iitAYvmmycvxZBReyQmEHw1tw5IuHvuys6/RxO2rfUXYLz90CgERykqJ6fUCHM54 5D+RHw/Mio3Daa8F+srCxUkXhKmeFWOsBiKxWdNffVGeYxQispuVQjLmtOoveZRN pS6e8hdg7ZSFzaDLfW8/Vx2D7Ek3k5i/xPi/aHB0yBLGH+y5JVRGS3fi52dr1zOl qBRCOdHvwv7Qa9aRM29bBtG/aEzhRF+sskUf2NbT6w7KBGfxopYETNRt90T6Z4qn 73wz8yimmFwkBwfN8IQYOLKNwSuTZEjJN55LnmxLotX5ClyCv2dTWGTqYtqlD+MH 6xgCOXLLHMOHxHW3400vF5zZW1xGGEqL1R5GQeM8w11uj7zQae0I8D3z837erlCT 2VciT6QxDAmgIpbGf8iNSFGalecimYo+3S+io38NtkF+2HCPjs2Wp382vYYvKL9O P4AAAHkSTDfsDPg+J65nARQCvdKYENTMup5PVoEypVXm78Rv+37COZr8GfWNizef ygTgo5Ktl4iYN68XhDQDINSdh0g/tUuBBLdjkDqKOaUfm+gxU3A= =lSKz -----END PGP SIGNATURE----- --QFQuXaHm0gDucWbk-- From owner-dev-commits-src-all@freebsd.org Wed May 12 16:09:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 44EB16445BD; Wed, 12 May 2021 16:09:20 +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 4FgKVS1WPgz4njp; Wed, 12 May 2021 16:09:20 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 231136427; Wed, 12 May 2021 16:09:20 +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 14CG9K0m051533; Wed, 12 May 2021 16:09:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CG9J2F051532; Wed, 12 May 2021 16:09:19 GMT (envelope-from git) Date: Wed, 12 May 2021 16:09:19 GMT Message-Id: <202105121609.14CG9J2F051532@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Glen Barber Subject: git: c0dbc49ab3f7 - main - release: fix ports checkout if /usr/ports does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c0dbc49ab3f7e43a2972c932fcd2b2ed4d06448b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:09:20 -0000 The branch main has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=c0dbc49ab3f7e43a2972c932fcd2b2ed4d06448b commit c0dbc49ab3f7e43a2972c932fcd2b2ed4d06448b Author: Glen Barber AuthorDate: 2021-05-12 16:08:59 +0000 Commit: Glen Barber CommitDate: 2021-05-12 16:08:59 +0000 release: fix ports checkout if /usr/ports does not exist Reported by: Yasuhiro Kimura Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/release.sh b/release/release.sh index a448361b86a6..75278a12daa6 100755 --- a/release/release.sh +++ b/release/release.sh @@ -213,6 +213,8 @@ chroot_setup() { if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then git -C ${CHROOTDIR}/usr/ports pull -q + else + ${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports fi fi From owner-dev-commits-src-all@freebsd.org Wed May 12 16:10:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5E93644636; Wed, 12 May 2021 16:10:18 +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 4FgKWZ4KFzz4nm2; Wed, 12 May 2021 16:10:18 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8774263AB; Wed, 12 May 2021 16:10:18 +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 14CGAIpp058371; Wed, 12 May 2021 16:10:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CGAI9w058364; Wed, 12 May 2021 16:10:18 GMT (envelope-from git) Date: Wed, 12 May 2021 16:10:18 GMT Message-Id: <202105121610.14CGAI9w058364@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: e2872019983d - stable/13 - release: fix ports checkout if /usr/ports does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e2872019983d73c6a290f742775639d40aa2d79e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:10:18 -0000 The branch stable/13 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=e2872019983d73c6a290f742775639d40aa2d79e commit e2872019983d73c6a290f742775639d40aa2d79e Author: Glen Barber AuthorDate: 2021-05-12 16:08:59 +0000 Commit: Glen Barber CommitDate: 2021-05-12 16:10:09 +0000 release: fix ports checkout if /usr/ports does not exist Reported by: Yasuhiro Kimura Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit c0dbc49ab3f7e43a2972c932fcd2b2ed4d06448b) --- release/release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release/release.sh b/release/release.sh index a448361b86a6..75278a12daa6 100755 --- a/release/release.sh +++ b/release/release.sh @@ -213,6 +213,8 @@ chroot_setup() { if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then git -C ${CHROOTDIR}/usr/ports pull -q + else + ${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports fi fi From owner-dev-commits-src-all@freebsd.org Wed May 12 16:10:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 226556446BE; Wed, 12 May 2021 16:10:51 +0000 (UTC) (envelope-from gjb@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FgKXC0SKSz4ngT; Wed, 12 May 2021 16:10:51 +0000 (UTC) (envelope-from gjb@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1620835851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YuRK6vs4aeCb/p8Z+t1qHEjnFu/7tia3v7UUFSp14+g=; b=oFEbPFjSNIsC2iG3+xC5r6HRq2I3y3eaY8+e6svPuxIspdA9BTFZfS7CZj4nFY872WqGpW 1gtnOU0PfKHn3gf/ra2u3CG66hlDB7/ew4el7+kG+i46yYtLNwHEsH1XfWvHD9CbWInNSU diUiAu7gZHw1KnBPfupQZbC95XJQVpi3qow+iOlfB2ZE0vjUDie+GnlyaMYDIJ3TZ5pE4F /3oVuh/adlbCiX6gPtmSGGM7LMiFd/mHn19JsChbQkrO7mAl9Ug4d4f+LLEIrYmWYvCppO Aq6LZ/0GDYSnukGpDDYfRsthm7sjnXTYr3dzQZXzZ4xSYgNz86mviHxDpvb7Cw== Received: from FreeBSD.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id 95AFC18C19; Wed, 12 May 2021 16:10:50 +0000 (UTC) (envelope-from gjb@freebsd.org) Date: Wed, 12 May 2021 16:10:48 +0000 From: Glen Barber To: Yasuhiro Kimura Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: fb6e261c20eb - main - release: follow-up to previous commit to use Git for the ports tree Message-ID: <20210512161048.GK92026@FreeBSD.org> References: <202105121448.14CEmfJH042754@gitrepo.freebsd.org> <20210513.010337.560902240722301845.yasu@utahime.org> <20210512160645.GJ92026@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+yydNiOxrtWvz4sx" Content-Disposition: inline In-Reply-To: <20210512160645.GJ92026@FreeBSD.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1620835851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YuRK6vs4aeCb/p8Z+t1qHEjnFu/7tia3v7UUFSp14+g=; b=mMFWGhhCCWpgqPTPkxUGMYtBCNcEpQjj/SVNVhi36YuGJ7JaRktMlcWROxB1ttFtOcIgcJ i4udx/XLtaVNu+k/lMP7Rs1tZFNmYXeGSDHuJLocrltPTcCIqI9neqrC6G8+y7mZO74Z2/ khBEU0rkb3ZdHbBCnhN/vFiu/da/cwstf6DO3F+cAlgKWVqY7Wl/Wl2MY0+xRm9z4tc/Zp uR1NUEqXmbBJ0Vc0lHpczzBb/iq0spmrFaAddlu3mnmx8+k6whMA91Bmd1zzIU0hr63D2m wq1EOl2OxB0xICYuxBcdpWxxePCEcRrS1cxIuB0b8b68p2zKhBAo9d4UcdX1ag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1620835851; a=rsa-sha256; cv=none; b=ykVRhs3u07rNzkOdpN3Y5Flcgb8KLEISlRsq0qDNsrRQxZiHUFcLt4MvPB40Jy9PL270KU 5SNg3ZR3KVgjZQ3MVcaVVwgjK+7iSpUfrZ4J75xW5NLUuYyKGntX2jaqg/hgQEabdeedki VX70ewjggezlwen9ABP0nGu73678WWwmcFpAtNVWXiyj79TE986SkBJWoHBrsUyKSdxTqW aKTXeAswAbekRb3gWwNPjLtnyDQ0i6koCnY0BlLwieu7HMEbFYbn2r63vqP1kkyA2MiTk9 s9IDXrthlMnSKlGVQmdGCXsWF6BV+eW5SI+ZgHZVgVRMTt/i6IRJL846pZC+lg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:10:51 -0000 --+yydNiOxrtWvz4sx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 12, 2021 at 04:06:45PM +0000, Glen Barber wrote: > On Thu, May 13, 2021 at 01:03:37AM +0900, Yasuhiro Kimura wrote: > > Hello Glen, > >=20 > > From: Glen Barber > > Subject: git: fb6e261c20eb - main - release: follow-up to previous comm= it to use Git for the ports tree > > Date: Wed, 12 May 2021 14:48:41 GMT > >=20 > > > diff --git a/release/release.sh b/release/release.sh > > > index 84a7813205f9..87e22e669fd1 100755 > > > --- a/release/release.sh > > > +++ b/release/release.sh > > > @@ -222,16 +222,8 @@ chroot_setup() { > > > fi > > > fi > > > if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then > > > - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > > - # git -C ${CHROOTDIR}/usr/ports pull -q > > > - # XXX: Workaround for the overlap in the Git conversion timeframe. > > > - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then > > > - ${SVNCMD} update ${CHROOTDIR}/usr/ports > > > - else > > > - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > > > - # XXX: Workaround for the overlap in the Git > > > - # conversion timeframe. > > > - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports > > > + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > > + git -C ${CHROOTDIR}/usr/ports pull -q > > > fi > > > fi > >=20 > > This should be such as following. > >=20 > > ---------------------------------------------------------------------- > > if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then > > - # if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > - # git -C ${CHROOTDIR}/usr/ports pull -q > > - # XXX: Workaround for the overlap in the Git conversion timeframe. > > - if [ -d "${CHROOTDIR}/usr/ports/.svn" ]; then > > - ${SVNCMD} update ${CHROOTDIR}/usr/ports > > - else > > - #${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > > - # XXX: Workaround for the overlap in the Git > > - # conversion timeframe. > > - ${SVNCMD} co ${PORT}/${PORTBRANCH} ${CHROOTDIR}/usr/ports > > + if [ -d "${CHROOTDIR}/usr/ports/.git" ]; then > > + git -C ${CHROOTDIR}/usr/ports pull -q > > + else > > + ${VCSCMD} ${PORT} -b ${PORTBRANCH} ${CHROOTDIR}/usr/ports > > fi > > fi > > ---------------------------------------------------------------------- > >=20 > > Or ports tree isn't checked out when build is from scratch. > >=20 >=20 > Bah, you're right. I fixed it in stable/13 without noticing it was > needed here, too. >=20 > Thanks for spotting this. >=20 Oops. It turns out I did not fix this in stable/13. I pushed an update there, too. Glen --+yydNiOxrtWvz4sx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEjRJAPC5sqwhs9k2jAxRYpUeP4pMFAmCb/ggACgkQAxRYpUeP 4pOopg//exr/7nEUuIMBv3rUEn97TCTRwi6Bl3bRFo2249u/AfZDSiQnCNcCN7pL CpVJo05vOGZVO96jNudq1pxrJqoolevep0wnrz898M73IgiVfoktuhU8i+dqfKHZ imXaDDlt5sDfi0BNbraXZ7OEUFtI2LklwIiilHQYiC5oA4+nbfFKJDnmnZLbEv4T u7CXZ8Fi1E7TR/tZx7lSzXxsclUcAfUi1y90kJL0S7+yYTAKcd16PD95N6NE2SQG 8oh1p642DNuXuqxqLXnfD4gcs8x6BNraPT4GhJIoG/SX9iyWesnGJBish6iopbXV 8Pjujg58EEwH0dOjDrgA3nroXBcLoydYf7JbkI7xcIFNxH5UFBTiECmv295RKNQW g90zeGswCDz/2P/7Vc8mVPER1Ndjdcn1skBEMu6dYD2bFpOJPC69SfndKEarTCdP PcDd+PJmICG2Nleg1fpBfZG/vawIXIZjA5ljpktS1WjgVUN13R7/vMauH0n0MgLU EIrum5FR2z0kA9w2eNls+g5cLqgN5L419D9xnkjJ2rpLVgKQNhs0Ih/0hLLRwVut uL7MQ4pxC1ObeLVjYSYWNfgCbLivEGt9jTisiMZGA+d0vlCuoosetjc7nbwncapP +nM7GdJtj7kZ9ji4RV8+pzYRlGI5yLp8MIORr2i1iuFfZWeXwpQ= =iLd8 -----END PGP SIGNATURE----- --+yydNiOxrtWvz4sx-- From owner-dev-commits-src-all@freebsd.org Wed May 12 16:11:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12FEA6449A6; Wed, 12 May 2021 16:11:57 +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 4FgKYT01wJz4nhK; Wed, 12 May 2021 16:11:57 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E7C766835; Wed, 12 May 2021 16:11:56 +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 14CGBunh061093; Wed, 12 May 2021 16:11:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CGBud7061092; Wed, 12 May 2021 16:11:56 GMT (envelope-from git) Date: Wed, 12 May 2021 16:11:56 GMT Message-Id: <202105121611.14CGBud7061092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 251842c63927 - main - tcp rack: improve initialisation of retransmit timeout MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 251842c63927fc4af63bdc61989bbfbf3823c679 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:11:57 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=251842c63927fc4af63bdc61989bbfbf3823c679 commit 251842c63927fc4af63bdc61989bbfbf3823c679 Author: Michael Tuexen AuthorDate: 2021-05-12 15:58:56 +0000 Commit: Michael Tuexen CommitDate: 2021-05-12 16:02:21 +0000 tcp rack: improve initialisation of retransmit timeout When the TCP is in the front states, don't take the slop variable into account. This improves consistency with the base stack. Reviewed by: rrs@ Differential Revision: https://reviews.freebsd.org/D30230 MFC after: 1 week Sponsored by: Netflix, Inc. --- sys/netinet/tcp_stacks/rack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index e6b2ef60cef7..115f5f2ee44b 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -6606,8 +6606,13 @@ rack_convert_rtts(struct tcpcb *tp) tp->t_rttvar += frac; } } - RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), - rack_rto_min, rack_rto_max); + tp->t_rxtcur = RACK_REXMTVAL(tp); + if (TCPS_HAVEESTABLISHED(tp->t_state)) { + tp->t_rxtcur += TICKS_2_USEC(tcp_rexmit_slop); + } + if (tp->t_rxtcur > rack_rto_max) { + tp->t_rxtcur = rack_rto_max; + } } static void From owner-dev-commits-src-all@freebsd.org Wed May 12 16:36:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8CF9B645227; Wed, 12 May 2021 16:36:32 +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 4FgL5r3ZNlz4ptX; Wed, 12 May 2021 16:36:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6DC386943; Wed, 12 May 2021 16:36:32 +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 14CGaWpL091709; Wed, 12 May 2021 16:36:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CGaW94091708; Wed, 12 May 2021 16:36:32 GMT (envelope-from git) Date: Wed, 12 May 2021 16:36:32 GMT Message-Id: <202105121636.14CGaW94091708@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 93f7be080f3a - main - Update the EFI timer to be called once a second MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 93f7be080f3ad0bd71190d87aa2043d714270206 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 16:36:32 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=93f7be080f3ad0bd71190d87aa2043d714270206 commit 93f7be080f3ad0bd71190d87aa2043d714270206 Author: Andrew Turner AuthorDate: 2021-05-12 08:59:04 +0000 Commit: Andrew Turner CommitDate: 2021-05-12 14:12:34 +0000 Update the EFI timer to be called once a second There is no need to call it evert 10ms when we need 1s granularity. Update to update the time every second. Reviewed by: imp, manu, tsoome Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D30227 --- stand/efi/libefi/time_event.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stand/efi/libefi/time_event.c b/stand/efi/libefi/time_event.c index f96f1d845f6a..f171bf997078 100644 --- a/stand/efi/libefi/time_event.c +++ b/stand/efi/libefi/time_event.c @@ -40,7 +40,7 @@ static void time_update(EFI_EVENT event, void *context) { - curtime += 10; + curtime++; } void @@ -50,8 +50,8 @@ efi_time_init(void) /* Create a timer event */ BS->CreateEvent(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, time_update, 0, &time_event); - /* Use a 10ms timer */ - BS->SetTimer(time_event, TimerPeriodic, 100000); + /* Use a 1s timer */ + BS->SetTimer(time_event, TimerPeriodic, 10000000); } void @@ -68,7 +68,7 @@ time(time_t *tloc) { time_t t; - t = curtime / 1000; + t = curtime; if (tloc != NULL) *tloc = t; From owner-dev-commits-src-all@freebsd.org Wed May 12 17:09:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34EF1646112; Wed, 12 May 2021 17:09:32 +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 4FgLqw11V6z4rH9; Wed, 12 May 2021 17:09:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 15B4D738D; Wed, 12 May 2021 17:09:32 +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 14CH9VUc031710; Wed, 12 May 2021 17:09:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CH9Vrp031709; Wed, 12 May 2021 17:09:31 GMT (envelope-from git) Date: Wed, 12 May 2021 17:09:31 GMT Message-Id: <202105121709.14CH9Vrp031709@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: cd497bd40bb6 - main - truss: Decode FreeBSD 11 mknod(2) and mknodat(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd497bd40bb65b5e4603d57614eb15ca7d947a10 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 17:09:32 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cd497bd40bb65b5e4603d57614eb15ca7d947a10 commit cd497bd40bb65b5e4603d57614eb15ca7d947a10 Author: Mark Johnston AuthorDate: 2021-05-12 13:42:11 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 16:52:05 +0000 truss: Decode FreeBSD 11 mknod(2) and mknodat(2) MFC after: 1 week Sponsored by: The FreeBSD Foundation --- usr.bin/truss/syscalls.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 798cd299582c..b9c6ff4ad361 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -193,6 +193,10 @@ static const struct syscall_decode decoded_syscalls[] = { { Kevent11 | OUT, 3 }, { Int, 4 }, { Timespec, 5 } } }, { .name = "compat11.lstat", .ret_type = 1, .nargs = 2, .args = { { Name | IN, 0 }, { Stat11 | OUT, 1 } } }, + { .name = "compat11.mknod", .ret_type = 1, .nargs = 3, + .args = { { Name, 0 }, { Octal, 1 }, { Int, 2 } } }, + { .name = "compat11.mknodat", .ret_type = 1, .nargs = 4, + .args = { { Atfd, 0 }, { Name, 1 }, { Octal, 2 }, { Int, 3 } } }, { .name = "compat11.stat", .ret_type = 1, .nargs = 2, .args = { { Name | IN, 0 }, { Stat11 | OUT, 1 } } }, { .name = "connect", .ret_type = 1, .nargs = 3, @@ -372,9 +376,9 @@ static const struct syscall_decode decoded_syscalls[] = { { .name = "mkfifoat", .ret_type = 1, .nargs = 3, .args = { { Atfd, 0 }, { Name, 1 }, { Octal, 2 } } }, { .name = "mknod", .ret_type = 1, .nargs = 3, - .args = { { Name, 0 }, { Octal, 1 }, { Int, 2 } } }, + .args = { { Name, 0 }, { Octal, 1 }, { Quad, 2 } } }, { .name = "mknodat", .ret_type = 1, .nargs = 4, - .args = { { Atfd, 0 }, { Name, 1 }, { Octal, 2 }, { Int, 3 } } }, + .args = { { Atfd, 0 }, { Name, 1 }, { Octal, 2 }, { Quad, 3 } } }, { .name = "mlock", .ret_type = 1, .nargs = 2, .args = { { Ptr, 0 }, { Sizet, 1 } } }, { .name = "mlockall", .ret_type = 1, .nargs = 1, From owner-dev-commits-src-all@freebsd.org Wed May 12 17:09:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61007645FD8; Wed, 12 May 2021 17:09:33 +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 4FgLqx23PKz4rKT; Wed, 12 May 2021 17:09:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 37F0E70DD; Wed, 12 May 2021 17:09:33 +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 14CH9XWe031731; Wed, 12 May 2021 17:09:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CH9Xug031730; Wed, 12 May 2021 17:09:33 GMT (envelope-from git) Date: Wed, 12 May 2021 17:09:33 GMT Message-Id: <202105121709.14CH9Xug031730@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 06d1fd9f42fa - main - swap_pager: Zero swap info before exporting to userspace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 06d1fd9f42fa9c060fad8f3a71fcaada3baaf200 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 17:09:33 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=06d1fd9f42fa9c060fad8f3a71fcaada3baaf200 commit 06d1fd9f42fa9c060fad8f3a71fcaada3baaf200 Author: Mark Johnston AuthorDate: 2021-05-12 13:42:44 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 16:52:05 +0000 swap_pager: Zero swap info before exporting to userspace Otherwise padding bytes are leaked. Reported by: KMSAN MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/vm/swap_pager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index b0b0b41d2148..57c953542a88 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2706,11 +2706,14 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS) if (arg2 != 1) /* name length */ return (EINVAL); + + memset(&xs, 0, sizeof(xs)); error = swap_dev_info(*(int *)arg1, &xs, NULL, 0); if (error != 0) return (error); #if defined(__amd64__) && defined(COMPAT_FREEBSD32) if (req->oldlen == sizeof(xs32)) { + memset(&xs32, 0, sizeof(xs32)); xs32.xsw_version = XSWDEV_VERSION; xs32.xsw_dev1 = xs.xsw_dev; xs32.xsw_dev2 = xs.xsw_dev >> 32; @@ -2723,6 +2726,7 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS) #endif #if defined(COMPAT_FREEBSD11) if (req->oldlen == sizeof(xs11)) { + memset(&xs11, 0, sizeof(xs11)); xs11.xsw_version = XSWDEV_VERSION_11; xs11.xsw_dev = xs.xsw_dev; /* truncation */ xs11.xsw_flags = xs.xsw_flags; From owner-dev-commits-src-all@freebsd.org Wed May 12 17:09:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85C45645C76; Wed, 12 May 2021 17:09:34 +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 4FgLqy2mjYz4rQP; Wed, 12 May 2021 17:09:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 49FBC72B8; Wed, 12 May 2021 17:09:34 +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 14CH9YQZ031752; Wed, 12 May 2021 17:09:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CH9Yf5031751; Wed, 12 May 2021 17:09:34 GMT (envelope-from git) Date: Wed, 12 May 2021 17:09:34 GMT Message-Id: <202105121709.14CH9Yf5031751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ad22ba2b9f3b - main - if: Remove unnecessary validation in the SIOCSIFNAME handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 17:09:34 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4 commit ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4 Author: Mark Johnston AuthorDate: 2021-05-12 14:05:37 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 16:52:06 +0000 if: Remove unnecessary validation in the SIOCSIFNAME handler A successful copyinstr() call guarantees that the returned string is nul-terminated. Furthermore, the removed check would harmlessly compare an uninitialized byte with '\0' if the new name is shorter than IFNAMESIZ - 1. Reported by: KMSAN MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/net/if.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index e18ed3e275ac..f615d82636be 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2653,11 +2653,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) return (error); if (new_name[0] == '\0') return (EINVAL); - if (new_name[IFNAMSIZ-1] != '\0') { - new_name[IFNAMSIZ-1] = '\0'; - if (strlen(new_name) == IFNAMSIZ-1) - return (EINVAL); - } if (strcmp(new_name, ifp->if_xname) == 0) break; if (ifunit(new_name) != NULL) From owner-dev-commits-src-all@freebsd.org Wed May 12 17:09:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7059645C7A; Wed, 12 May 2021 17:09:35 +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 4FgLqz52MDz4rHD; Wed, 12 May 2021 17:09:35 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 70F567320; Wed, 12 May 2021 17:09:35 +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 14CH9ZrI031773; Wed, 12 May 2021 17:09:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CH9ZN5031772; Wed, 12 May 2021 17:09:35 GMT (envelope-from git) Date: Wed, 12 May 2021 17:09:35 GMT Message-Id: <202105121709.14CH9ZN5031772@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c1dd4d642fa0 - main - nd6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1dd4d642fa0e2c8ea4f9a879f2cc4e5d6c39211 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 17:09:35 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c1dd4d642fa0e2c8ea4f9a879f2cc4e5d6c39211 commit c1dd4d642fa0e2c8ea4f9a879f2cc4e5d6c39211 Author: Mark Johnston AuthorDate: 2021-05-12 15:49:24 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 16:52:06 +0000 nd6: Avoid using an uninitialized sockaddr in nd6_prefix_offlink() Commit 81728a538 ("Split rtinit() into multiple functions.") removed the initialization of sa6, but not one of its uses. This meant that we were passing an uninitialized sockaddr as the address to lltable_prefix_free(). Remove the variable outright to fix the problem. The caller is expected to hold a reference on pr. Fixes: 81728a538 ("Split rtinit() into multiple functions.") Reported by: KMSAN Reviewed by: donner MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30166 --- sys/netinet6/nd6_rtr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 2f721b4edcc3..2960b6cad951 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -2165,7 +2165,6 @@ nd6_prefix_offlink(struct nd_prefix *pr) int error = 0; struct ifnet *ifp = pr->ndpr_ifp; struct nd_prefix *opr; - struct sockaddr_in6 sa6; char ip6buf[INET6_ADDRSTRLEN]; uint64_t genid; int a_failure; @@ -2240,7 +2239,8 @@ restart: } if (a_failure) - lltable_prefix_free(AF_INET6, (struct sockaddr *)&sa6, + lltable_prefix_free(AF_INET6, + (struct sockaddr *)&pr->ndpr_prefix, (struct sockaddr *)&mask6, LLE_STATIC); return (error); From owner-dev-commits-src-all@freebsd.org Wed May 12 17:09:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED54664619D; Wed, 12 May 2021 17:09:36 +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 4FgLr05Trpz4rKk; Wed, 12 May 2021 17:09:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 94763713B; Wed, 12 May 2021 17:09:36 +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 14CH9a6A031795; Wed, 12 May 2021 17:09:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CH9ak4031794; Wed, 12 May 2021 17:09:36 GMT (envelope-from git) Date: Wed, 12 May 2021 17:09:36 GMT Message-Id: <202105121709.14CH9ak4031794@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d8acd2681bcf - main - Fix mbuf leaks in various pru_send implementations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8acd2681bcfb2ff7eb154df82f268b1cb191b4c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 17:09:37 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d8acd2681bcfb2ff7eb154df82f268b1cb191b4c commit d8acd2681bcfb2ff7eb154df82f268b1cb191b4c Author: Mark Johnston AuthorDate: 2021-05-12 13:39:36 +0000 Commit: Mark Johnston CommitDate: 2021-05-12 17:00:09 +0000 Fix mbuf leaks in various pru_send implementations The various protocol implementations are not very consistent about freeing mbufs in error paths. In general, all protocols must free both "m" and "control" upon an error, except if PRUS_NOTREADY is specified (this is only implemented by TCP and unix(4) and requires further work not handled in this diff), in which case "control" still must be freed. This diff plugs various leaks in the pru_send implementations. Reviewed by: tuexen MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30151 --- sys/kern/uipc_socket.c | 6 +++- sys/netinet/ip_divert.c | 2 ++ sys/netinet/raw_ip.c | 19 +++++++---- sys/netinet/tcp_usrreq.c | 77 ++++++++++++++++++--------------------------- sys/netinet/udp_usrreq.c | 1 + sys/netinet6/raw_ip6.c | 40 ++++++++++++----------- sys/netinet6/sctp6_usrreq.c | 25 +++++++++++++++ sys/netinet6/send.c | 3 ++ 8 files changed, 100 insertions(+), 73 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index ae678136bade..ea86f66556ea 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -3741,7 +3741,11 @@ pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { - return EOPNOTSUPP; + if (control != NULL) + m_freem(control); + if ((flags & PRUS_NOTREADY) == 0) + m_freem(m); + return (EOPNOTSUPP); } int diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index f83a42cb36c9..77a4bfcd08ac 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -677,6 +677,8 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, if (m->m_len < sizeof (struct ip) && (m = m_pullup(m, sizeof (struct ip))) == NULL) { KMOD_IPSTAT_INC(ips_toosmall); + if (control != NULL) + m_freem(control); m_freem(m); return EINVAL; } diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 89ab6a6bbdad..1db73a6da68c 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1077,13 +1077,18 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, inp = sotoinpcb(so); KASSERT(inp != NULL, ("rip_send: inp == NULL")); + if (control != NULL) { + m_freem(control); + control = NULL; + } + /* * Note: 'dst' reads below are unlocked. */ if (so->so_state & SS_ISCONNECTED) { if (nam) { - m_freem(m); - return (EISCONN); + error = EISCONN; + goto release; } dst = inp->inp_faddr.s_addr; /* Unlocked read. */ } else { @@ -1094,13 +1099,15 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, error = EAFNOSUPPORT; else if (nam->sa_len != sizeof(struct sockaddr_in)) error = EINVAL; - if (error != 0) { - m_freem(m); - return (error); - } + if (error != 0) + goto release; dst = ((struct sockaddr_in *)nam)->sin_addr.s_addr; } return (rip_output(m, so, dst)); + +release: + m_freem(m); + return (error); } #endif /* INET */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 061681ddc2bc..693cf553de44 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -993,21 +993,31 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { if (control) m_freem(control); + /* * In case of PRUS_NOTREADY, tcp_usr_ready() is responsible * for freeing memory. */ - if (m && (flags & PRUS_NOTREADY) == 0) + if ((flags & PRUS_NOTREADY) == 0) m_freem(m); error = ECONNRESET; goto out; } + if (control != NULL) { + /* TCP doesn't do control messages (rights, creds, etc) */ + if (control->m_len) { + m_freem(control); + m_freem(m); + error = EINVAL; + goto out; + } + m_freem(control); /* empty control, just free it */ + control = NULL; + } tp = intotcpcb(inp); if (flags & PRUS_OOB) { if ((error = tcp_pru_options_support(tp, PRUS_OOB)) != 0) { - if (control) - m_freem(control); - if (m && (flags & PRUS_NOTREADY) == 0) + if ((flags & PRUS_NOTREADY) == 0) m_freem(m); goto out; } @@ -1019,33 +1029,28 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, case AF_INET: sinp = (struct sockaddr_in *)nam; if (sinp->sin_len != sizeof(struct sockaddr_in)) { - if (m) - m_freem(m); + m_freem(m); error = EINVAL; goto out; } if ((inp->inp_vflag & INP_IPV6) != 0) { - if (m) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } if (IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) { - if (m) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } if (ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) { - if (m) - m_freem(m); + m_freem(m); error = EACCES; goto out; } if ((error = prison_remote_ip4(td->td_ucred, &sinp->sin_addr))) { - if (m) - m_freem(m); + m_freem(m); goto out; } #ifdef INET6 @@ -1060,20 +1065,17 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, sin6 = (struct sockaddr_in6 *)nam; if (sin6->sin6_len != sizeof(*sin6)) { - if (m) - m_freem(m); + m_freem(m); error = EINVAL; goto out; } if ((inp->inp_vflag & INP_IPV6PROTO) == 0) { - if (m != NULL) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { - if (m) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } @@ -1081,14 +1083,12 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, #ifdef INET if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) { error = EINVAL; - if (m) - m_freem(m); + m_freem(m); goto out; } if ((inp->inp_vflag & INP_IPV4) == 0) { error = EAFNOSUPPORT; - if (m) - m_freem(m); + m_freem(m); goto out; } restoreflags = true; @@ -1098,27 +1098,23 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (IN_MULTICAST( ntohl(sinp->sin_addr.s_addr))) { error = EAFNOSUPPORT; - if (m) - m_freem(m); + m_freem(m); goto out; } if ((error = prison_remote_ip4(td->td_ucred, &sinp->sin_addr))) { - if (m) - m_freem(m); + m_freem(m); goto out; } isipv6 = 0; #else /* !INET */ error = EAFNOSUPPORT; - if (m) - m_freem(m); + m_freem(m); goto out; #endif /* INET */ } else { if ((inp->inp_vflag & INP_IPV6) == 0) { - if (m) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } @@ -1127,8 +1123,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, inp->inp_inc.inc_flags |= INC_ISIPV6; if ((error = prison_remote_ip6(td->td_ucred, &sin6->sin6_addr))) { - if (m) - m_freem(m); + m_freem(m); goto out; } isipv6 = 1; @@ -1137,23 +1132,11 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, } #endif /* INET6 */ default: - if (m) - m_freem(m); + m_freem(m); error = EAFNOSUPPORT; goto out; } } - if (control) { - /* TCP doesn't do control messages (rights, creds, etc) */ - if (control->m_len) { - m_freem(control); - if (m) - m_freem(m); - error = EINVAL; - goto out; - } - m_freem(control); /* empty control, just free it */ - } if (!(flags & PRUS_OOB)) { sbappendstream(&so->so_snd, m, flags); if (nam && tp->t_state < TCPS_SYN_SENT) { diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 16ae0a89bb15..62a07701df6c 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1273,6 +1273,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, break; } m_freem(control); + control = NULL; } if (error) goto release; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 3d2af6e5c9e6..a369abb04bfc 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -867,7 +867,7 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct inpcb *inp; struct sockaddr_in6 tmp; struct sockaddr_in6 *dst; - int ret; + int error; inp = sotoinpcb(so); KASSERT(inp != NULL, ("rip6_send: inp == NULL")); @@ -876,8 +876,8 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, /* Unlocked read. */ if (so->so_state & SS_ISCONNECTED) { if (nam) { - m_freem(m); - return (EISCONN); + error = EISCONN; + goto release; } /* XXX */ bzero(&tmp, sizeof(tmp)); @@ -889,18 +889,15 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, INP_RUNLOCK(inp); dst = &tmp; } else { - if (nam == NULL) { - m_freem(m); - return (ENOTCONN); - } - if (nam->sa_family != AF_INET6) { - m_freem(m); - return (EAFNOSUPPORT); - } - if (nam->sa_len != sizeof(struct sockaddr_in6)) { - m_freem(m); - return (EINVAL); - } + error = 0; + if (nam == NULL) + error = ENOTCONN; + else if (nam->sa_family != AF_INET6) + error = EAFNOSUPPORT; + else if (nam->sa_len != sizeof(struct sockaddr_in6)) + error = EINVAL; + if (error != 0) + goto release; tmp = *(struct sockaddr_in6 *)nam; dst = &tmp; @@ -914,12 +911,17 @@ rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, "unspec. Assume AF_INET6\n"); dst->sin6_family = AF_INET6; } else if (dst->sin6_family != AF_INET6) { - m_freem(m); - return(EAFNOSUPPORT); + error = EAFNOSUPPORT; + goto release; } } - ret = rip6_output(m, so, dst, control); - return (ret); + return (rip6_output(m, so, dst, control)); + +release: + if (control != NULL) + m_freem(control); + m_freem(m); + return (error); } struct pr_usrreqs rip6_usrreqs = { diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index 1030fe1bbb68..3be7a3e25de8 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -713,6 +713,11 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, #ifdef INET case AF_INET: if (addr->sa_len != sizeof(struct sockaddr_in)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } @@ -721,12 +726,22 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, #ifdef INET6 case AF_INET6: if (addr->sa_len != sizeof(struct sockaddr_in6)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } break; #endif default: + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } @@ -738,10 +753,20 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * v4 addr or v4-mapped addr */ if (addr->sa_family == AF_INET) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + if (control) { + SCTP_RELEASE_PKT(control); + control = NULL; + } + SCTP_RELEASE_PKT(m); SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); return (EINVAL); } diff --git a/sys/netinet6/send.c b/sys/netinet6/send.c index aef2ee400c0e..677a83ab94cc 100644 --- a/sys/netinet6/send.c +++ b/sys/netinet6/send.c @@ -250,8 +250,11 @@ send_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, m = NULL; err: + if (control != NULL) + m_freem(control); if (m != NULL) m_freem(m); + return (error); } From owner-dev-commits-src-all@freebsd.org Wed May 12 18:35:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34479648824; Wed, 12 May 2021 18:35: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 4FgNkY0rB9z3Byy; Wed, 12 May 2021 18:35:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0F82B10469; Wed, 12 May 2021 18:35:01 +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 14CIZ0Ai050471; Wed, 12 May 2021 18:35:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CIZ0Sa050470; Wed, 12 May 2021 18:35:00 GMT (envelope-from git) Date: Wed, 12 May 2021 18:35:00 GMT Message-Id: <202105121835.14CIZ0Sa050470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 98454e3f825e - main - Correct location of libcap_random.so in ObsoleteFiles.inc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98454e3f825e086e47d107e7ff4ddf4239285dbe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 18:35:01 -0000 The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=98454e3f825e086e47d107e7ff4ddf4239285dbe commit 98454e3f825e086e47d107e7ff4ddf4239285dbe Author: Dimitry Andric AuthorDate: 2021-05-12 18:33:46 +0000 Commit: Dimitry Andric CommitDate: 2021-05-12 18:34:23 +0000 Correct location of libcap_random.so in ObsoleteFiles.inc --- ObsoleteFiles.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 62a4dcc5df31..7bc4f435f869 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -5678,7 +5678,7 @@ OLD_FILES+=usr/include/sys/inflate.h # 20190722: cap_random(3) removed OLD_LIBS+=lib/casper/libcap_random.so.1 OLD_FILES+=usr/include/casper/cap_random.h -OLD_LIBS+=usr/lib/casper/libcap_random.so +OLD_LIBS+=usr/lib/libcap_random.so OLD_FILES+=usr/share/man/man3/libcap_random.3.gz OLD_FILES+=usr/share/man/man3/cap_random.3.gz OLD_FILES+=usr/share/man/man3/cap_random_buf.3.gz From owner-dev-commits-src-all@freebsd.org Wed May 12 18:54:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 41BDE648E49; Wed, 12 May 2021 18:54:48 +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 4FgP9N10dMz3CkN; Wed, 12 May 2021 18:54:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0AF38107EF; Wed, 12 May 2021 18:54:48 +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 14CIslfL078009; Wed, 12 May 2021 18:54:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CIslqW078008; Wed, 12 May 2021 18:54:47 GMT (envelope-from git) Date: Wed, 12 May 2021 18:54:47 GMT Message-Id: <202105121854.14CIslqW078008@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: a26e895f3d80 - main - tests: Only log critical errors from scapy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a26e895f3d803cc1f4ee1c2b33c61330998808b9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 18:54:48 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a26e895f3d803cc1f4ee1c2b33c61330998808b9 commit a26e895f3d803cc1f4ee1c2b33c61330998808b9 Author: Kristof Provost AuthorDate: 2021-05-12 17:13:40 +0000 Commit: Kristof Provost CommitDate: 2021-05-12 18:54:30 +0000 tests: Only log critical errors from scapy Since 2.4.5 scapy started issuing warnings about a few different configurations during our tests. These are harmless, but they generate stderr output, which upsets atf_check. Configure scapy to only log critical errors (and thus not warnings) to fix these tests. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/common/divert.py | 2 ++ tests/sys/common/sender.py | 2 ++ tests/sys/net/stp.py | 2 ++ tests/sys/netinet6/exthdr.py | 2 ++ tests/sys/netinet6/frag6/frag6_01.py | 2 ++ tests/sys/netinet6/frag6/frag6_02.py | 2 ++ tests/sys/netinet6/frag6/frag6_03.py | 2 ++ tests/sys/netinet6/frag6/frag6_04.py | 2 ++ tests/sys/netinet6/frag6/frag6_05.py | 2 ++ tests/sys/netinet6/frag6/frag6_06.py | 2 ++ tests/sys/netinet6/frag6/frag6_07.py | 2 ++ tests/sys/netinet6/frag6/frag6_08.py | 2 ++ tests/sys/netinet6/frag6/frag6_09.py | 2 ++ tests/sys/netinet6/frag6/frag6_10.py | 2 ++ tests/sys/netinet6/frag6/frag6_11.py | 2 ++ tests/sys/netinet6/frag6/frag6_12.py | 2 ++ tests/sys/netinet6/frag6/frag6_13.py | 2 ++ tests/sys/netinet6/frag6/frag6_14.py | 2 ++ tests/sys/netinet6/frag6/frag6_15.py | 2 ++ tests/sys/netinet6/frag6/frag6_16.py | 2 ++ tests/sys/netinet6/frag6/frag6_17.py | 2 ++ tests/sys/netinet6/frag6/frag6_18.py | 2 ++ tests/sys/netinet6/frag6/frag6_19.py | 2 ++ tests/sys/netinet6/frag6/frag6_20.py | 2 ++ tests/sys/netinet6/frag6/sniffer.py | 2 ++ tests/sys/netinet6/mld.py | 2 ++ tests/sys/netinet6/redirect.py | 2 ++ tests/sys/netinet6/scapyi386.py | 2 ++ tests/sys/netpfil/common/pft_ping.py | 2 ++ tests/sys/netpfil/pf/CVE-2019-5597.py | 2 ++ tests/sys/netpfil/pf/CVE-2019-5598.py | 2 ++ 31 files changed, 62 insertions(+) diff --git a/tests/sys/common/divert.py b/tests/sys/common/divert.py index 1861f87402ad..f23fbe857cbb 100755 --- a/tests/sys/common/divert.py +++ b/tests/sys/common/divert.py @@ -30,6 +30,8 @@ import socket +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sc import argparse diff --git a/tests/sys/common/sender.py b/tests/sys/common/sender.py index 483210e54fcb..2ff699a8ef6d 100755 --- a/tests/sys/common/sender.py +++ b/tests/sys/common/sender.py @@ -31,6 +31,8 @@ from functools import partial import socket +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sc import argparse import time diff --git a/tests/sys/net/stp.py b/tests/sys/net/stp.py index 4c4c0af4c728..3e7d011efdd1 100644 --- a/tests/sys/net/stp.py +++ b/tests/sys/net/stp.py @@ -27,6 +27,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import sys import os diff --git a/tests/sys/netinet6/exthdr.py b/tests/sys/netinet6/exthdr.py index 7c09f44c5b58..52739a9cfa11 100644 --- a/tests/sys/netinet6/exthdr.py +++ b/tests/sys/netinet6/exthdr.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_01.py b/tests/sys/netinet6/frag6/frag6_01.py index 5a6b327337c6..efa99ce65759 100644 --- a/tests/sys/netinet6/frag6/frag6_01.py +++ b/tests/sys/netinet6/frag6/frag6_01.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_02.py b/tests/sys/netinet6/frag6/frag6_02.py index 945b428c3dac..794801b4a819 100644 --- a/tests/sys/netinet6/frag6/frag6_02.py +++ b/tests/sys/netinet6/frag6/frag6_02.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_03.py b/tests/sys/netinet6/frag6/frag6_03.py index 341de7915bd8..434dfe554a5a 100644 --- a/tests/sys/netinet6/frag6/frag6_03.py +++ b/tests/sys/netinet6/frag6/frag6_03.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_04.py b/tests/sys/netinet6/frag6/frag6_04.py index 6c35d4858ccb..8f0a20e003da 100644 --- a/tests/sys/netinet6/frag6/frag6_04.py +++ b/tests/sys/netinet6/frag6/frag6_04.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_05.py b/tests/sys/netinet6/frag6/frag6_05.py index d67c35581bbf..f9bc947d5465 100644 --- a/tests/sys/netinet6/frag6/frag6_05.py +++ b/tests/sys/netinet6/frag6/frag6_05.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_06.py b/tests/sys/netinet6/frag6/frag6_06.py index 42c8b02042cd..ca4e9b1a5ca0 100644 --- a/tests/sys/netinet6/frag6/frag6_06.py +++ b/tests/sys/netinet6/frag6/frag6_06.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_07.py b/tests/sys/netinet6/frag6/frag6_07.py index c84a783137d3..231f49eac2e0 100644 --- a/tests/sys/netinet6/frag6/frag6_07.py +++ b/tests/sys/netinet6/frag6/frag6_07.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_08.py b/tests/sys/netinet6/frag6/frag6_08.py index fa17e1e5c774..25f57f702e71 100644 --- a/tests/sys/netinet6/frag6/frag6_08.py +++ b/tests/sys/netinet6/frag6/frag6_08.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_09.py b/tests/sys/netinet6/frag6/frag6_09.py index 6e9771bc7d58..63ec646e1175 100644 --- a/tests/sys/netinet6/frag6/frag6_09.py +++ b/tests/sys/netinet6/frag6/frag6_09.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_10.py b/tests/sys/netinet6/frag6/frag6_10.py index 02d25bd96450..fcd331190c02 100644 --- a/tests/sys/netinet6/frag6/frag6_10.py +++ b/tests/sys/netinet6/frag6/frag6_10.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_11.py b/tests/sys/netinet6/frag6/frag6_11.py index a5c8e1918430..6b9643337597 100644 --- a/tests/sys/netinet6/frag6/frag6_11.py +++ b/tests/sys/netinet6/frag6/frag6_11.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_12.py b/tests/sys/netinet6/frag6/frag6_12.py index 68ea180599e1..a683782f2b69 100644 --- a/tests/sys/netinet6/frag6/frag6_12.py +++ b/tests/sys/netinet6/frag6/frag6_12.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_13.py b/tests/sys/netinet6/frag6/frag6_13.py index da3b2afe239f..e377a4272fa1 100644 --- a/tests/sys/netinet6/frag6/frag6_13.py +++ b/tests/sys/netinet6/frag6/frag6_13.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_14.py b/tests/sys/netinet6/frag6/frag6_14.py index 915571cfc36f..b53a65e67529 100644 --- a/tests/sys/netinet6/frag6/frag6_14.py +++ b/tests/sys/netinet6/frag6/frag6_14.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_15.py b/tests/sys/netinet6/frag6/frag6_15.py index f9922aaa9717..fff5c1efbe17 100644 --- a/tests/sys/netinet6/frag6/frag6_15.py +++ b/tests/sys/netinet6/frag6/frag6_15.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_16.py b/tests/sys/netinet6/frag6/frag6_16.py index 42ac8e2b4675..bf5b78cb6d6b 100644 --- a/tests/sys/netinet6/frag6/frag6_16.py +++ b/tests/sys/netinet6/frag6/frag6_16.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_17.py b/tests/sys/netinet6/frag6/frag6_17.py index a4d6deea0a24..b4a1a1898c2e 100644 --- a/tests/sys/netinet6/frag6/frag6_17.py +++ b/tests/sys/netinet6/frag6/frag6_17.py @@ -30,6 +30,8 @@ import argparse import random as random +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_18.py b/tests/sys/netinet6/frag6/frag6_18.py index a4d6deea0a24..b4a1a1898c2e 100644 --- a/tests/sys/netinet6/frag6/frag6_18.py +++ b/tests/sys/netinet6/frag6/frag6_18.py @@ -30,6 +30,8 @@ import argparse import random as random +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_19.py b/tests/sys/netinet6/frag6/frag6_19.py index 9248f5f40c43..f8613f757573 100644 --- a/tests/sys/netinet6/frag6/frag6_19.py +++ b/tests/sys/netinet6/frag6/frag6_19.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/frag6_20.py b/tests/sys/netinet6/frag6/frag6_20.py index 4e935a1f640a..6dd4c2379357 100755 --- a/tests/sys/netinet6/frag6/frag6_20.py +++ b/tests/sys/netinet6/frag6/frag6_20.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/frag6/sniffer.py b/tests/sys/netinet6/frag6/sniffer.py index 2c5f460488db..7e1d283dbf91 100644 --- a/tests/sys/netinet6/frag6/sniffer.py +++ b/tests/sys/netinet6/frag6/sniffer.py @@ -1,6 +1,8 @@ # $FreeBSD$ import threading +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp class Sniffer(threading.Thread): diff --git a/tests/sys/netinet6/mld.py b/tests/sys/netinet6/mld.py index b1fcf2f8e50a..1f43cee5d6ad 100644 --- a/tests/sys/netinet6/mld.py +++ b/tests/sys/netinet6/mld.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netinet6/redirect.py b/tests/sys/netinet6/redirect.py index 7066f8066518..4f785c615f62 100644 --- a/tests/sys/netinet6/redirect.py +++ b/tests/sys/netinet6/redirect.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sc import socket import sys diff --git a/tests/sys/netinet6/scapyi386.py b/tests/sys/netinet6/scapyi386.py index 745c01b45881..ac0c877380c4 100644 --- a/tests/sys/netinet6/scapyi386.py +++ b/tests/sys/netinet6/scapyi386.py @@ -29,6 +29,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netpfil/common/pft_ping.py b/tests/sys/netpfil/common/pft_ping.py index de673f026c77..9cc7c5d5c5c0 100644 --- a/tests/sys/netpfil/common/pft_ping.py +++ b/tests/sys/netpfil/common/pft_ping.py @@ -27,6 +27,8 @@ # import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import socket import sys diff --git a/tests/sys/netpfil/pf/CVE-2019-5597.py b/tests/sys/netpfil/pf/CVE-2019-5597.py index 1050af506f8d..1b25809cbedf 100644 --- a/tests/sys/netpfil/pf/CVE-2019-5597.py +++ b/tests/sys/netpfil/pf/CVE-2019-5597.py @@ -26,6 +26,8 @@ # SUCH DAMAGE. import random +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import sys diff --git a/tests/sys/netpfil/pf/CVE-2019-5598.py b/tests/sys/netpfil/pf/CVE-2019-5598.py index ac1e4f3438f5..603a1aef376f 100644 --- a/tests/sys/netpfil/pf/CVE-2019-5598.py +++ b/tests/sys/netpfil/pf/CVE-2019-5598.py @@ -26,6 +26,8 @@ # SUCH DAMAGE. import argparse +import logging +logging.getLogger("scapy").setLevel(logging.CRITICAL) import scapy.all as sp import sys from sniffer import Sniffer From owner-dev-commits-src-all@freebsd.org Wed May 12 19:44:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9717E64A5B3; Wed, 12 May 2021 19:44:23 +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 4FgQGb3t5yz3Gbd; Wed, 12 May 2021 19:44:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 77DB211810; Wed, 12 May 2021 19:44:23 +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 14CJiNiZ046675; Wed, 12 May 2021 19:44:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CJiNHQ046674; Wed, 12 May 2021 19:44:23 GMT (envelope-from git) Date: Wed, 12 May 2021 19:44:23 GMT Message-Id: <202105121944.14CJiNHQ046674@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 38a4732f395b - main - Centralize open/close of /dev/iic%d devices MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 38a4732f395b1a529bf2358326a458c2c8c90cf0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 19:44:23 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=38a4732f395b1a529bf2358326a458c2c8c90cf0 commit 38a4732f395b1a529bf2358326a458c2c8c90cf0 Author: Poul-Henning Kamp AuthorDate: 2021-05-12 19:43:44 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-12 19:43:44 +0000 Centralize open/close of /dev/iic%d devices --- usr.sbin/i2c/i2c.c | 77 +++++++++++++++++++----------------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 23613ee744f9..604460625ecf 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -123,23 +123,16 @@ skip_get_tokens(char *skip_addr, int *sk_addr, int max_index) } static int -scan_bus(const char *dev, int skip, char *skip_addr) +scan_bus(const char *dev, int fd, int skip, char *skip_addr) { struct iiccmd cmd; struct iic_msg rdmsg; struct iic_rdwr_data rdwrdata; struct skip_range addr_range = { 0, 0 }; - int *tokens = NULL, fd, error, i, idx = 0, j; + int *tokens = NULL, error, i, idx = 0, j; int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 0; uint8_t rdbyte; - fd = open(dev, O_RDWR); - if (fd == -1) { - fprintf(stderr, "Error opening I2C controller (%s) for " - "scanning: %s\n", dev, strerror(errno)); - return (EX_NOINPUT); - } - if (skip) { assert(skip_addr != NULL); len = strlen(skip_addr); @@ -220,7 +213,7 @@ start_over: use_read_xfer = 1; goto start_over; } - ioctl(fd, I2CSTOP); + (void)ioctl(fd, I2CSTOP); } if (error == 0) { ++num_found; @@ -243,7 +236,6 @@ start_over: error = ioctl(fd, I2CRSTCARD, &cmd); out: - close(fd); if (skip && no_range) free(tokens); else @@ -258,21 +250,13 @@ out: } static int -reset_bus(const char *dev) +reset_bus(const char *dev, int fd) { struct iiccmd cmd; - int fd, error; - - fd = open(dev, O_RDWR); - if (fd == -1) { - fprintf(stderr, "Error opening I2C controller (%s) for " - "resetting: %s\n", dev, strerror(errno)); - return (EX_NOINPUT); - } + int error; printf("Resetting I2C controller on %s: ", dev); error = ioctl(fd, I2CRSTCARD, &cmd); - close (fd); if (error) { printf("error: %s\n", strerror(errno)); @@ -303,19 +287,13 @@ prepare_buf(int size, uint32_t off) } static int -i2c_write(const char *dev, struct options i2c_opt, char *i2c_buf) +i2c_write(int fd, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; - int error, fd, bufsize; + int error, bufsize; char *buf; const char *err_msg; - fd = open(dev, O_RDWR); - if (fd == -1) { - free(i2c_buf); - err(1, "open failed"); - } - cmd.slave = i2c_opt.addr; error = ioctl(fd, I2CSTART, &cmd); if (error == -1) { @@ -441,7 +419,6 @@ i2c_write(const char *dev, struct options i2c_opt, char *i2c_buf) goto err2; } - close(fd); return (0); err1: @@ -452,22 +429,17 @@ err2: if (err_msg) fprintf(stderr, "%s\n", err_msg); - close(fd); return (1); } static int -i2c_read(const char *dev, struct options i2c_opt, char *i2c_buf) +i2c_read(int fd, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; - int fd, error, bufsize; + int error, bufsize; char data = 0, *buf; const char *err_msg; - fd = open(dev, O_RDWR); - if (fd == -1) - err(1, "open failed"); - bzero(&cmd, sizeof(cmd)); if (i2c_opt.width) { @@ -539,7 +511,6 @@ i2c_read(const char *dev, struct options i2c_opt, char *i2c_buf) goto err2; } - close(fd); return (0); err1: @@ -550,7 +521,6 @@ err2: if (err_msg) fprintf(stderr, "%s\n", err_msg); - close(fd); return (1); } @@ -566,11 +536,11 @@ err2: * driver to be handled as a single transfer. */ static int -i2c_rdwr_transfer(const char *dev, struct options i2c_opt, char *i2c_buf) +i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) { struct iic_msg msgs[2]; struct iic_rdwr_data xfer; - int fd, i; + int i; uint8_t off_buf[2]; i = 0; @@ -607,11 +577,8 @@ i2c_rdwr_transfer(const char *dev, struct options i2c_opt, char *i2c_buf) xfer.msgs = msgs; xfer.nmsgs = i; - if ((fd = open(dev, O_RDWR)) == -1) - err(1, "open(%s) failed", dev); if (ioctl(fd, I2CRDWR, &xfer) == -1 ) err(1, "ioctl(I2CRDWR) failed"); - close(fd); return (0); } @@ -622,7 +589,7 @@ main(int argc, char** argv) struct options i2c_opt; char *skip_addr = NULL, *i2c_buf; const char *dev; - int error, chunk_size, i, j, ch; + int fd, error, chunk_size, i, j, ch; errno = 0; error = 0; @@ -741,11 +708,18 @@ main(int argc, char** argv) i2c_opt.addr >> 1, i2c_opt.dir, i2c_opt.off, i2c_opt.width, i2c_opt.count); + fd = open(dev, O_RDWR); + if (fd == -1) { + fprintf(stderr, "Error opening I2C controller (%s): %s\n", + dev, strerror(errno)); + return (EX_NOINPUT); + } + if (i2c_opt.scan) - exit(scan_bus(dev, i2c_opt.skip, skip_addr)); + exit(scan_bus(dev, fd, i2c_opt.skip, skip_addr)); if (i2c_opt.reset) - exit(reset_bus(dev)); + exit(reset_bus(dev, fd)); i2c_buf = malloc(i2c_opt.count); if (i2c_buf == NULL) @@ -769,17 +743,20 @@ main(int argc, char** argv) } if (i2c_opt.mode == I2C_MODE_TRANSFER) - error = i2c_rdwr_transfer(dev, i2c_opt, i2c_buf); + error = i2c_rdwr_transfer(fd, i2c_opt, i2c_buf); else if (i2c_opt.dir == 'w') - error = i2c_write(dev, i2c_opt, i2c_buf); + error = i2c_write(fd, i2c_opt, i2c_buf); else - error = i2c_read(dev, i2c_opt, i2c_buf); + error = i2c_read(fd, i2c_opt, i2c_buf); if (error != 0) { free(i2c_buf); return (1); } + error = close(fd); + assert(error == 0); + if (i2c_opt.verbose) fprintf(stderr, "\nData %s (hex):\n", i2c_opt.dir == 'r' ? "read" : "written"); From owner-dev-commits-src-all@freebsd.org Wed May 12 20:02:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF86964A76D; Wed, 12 May 2021 20:02:07 +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 4FgQg34wPgz3GqJ; Wed, 12 May 2021 20:02:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9C03511467; Wed, 12 May 2021 20:02:07 +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 14CK27ii074257; Wed, 12 May 2021 20:02:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CK27Db074256; Wed, 12 May 2021 20:02:07 GMT (envelope-from git) Date: Wed, 12 May 2021 20:02:07 GMT Message-Id: <202105122002.14CK27Db074256@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: e06874f3f6d1 - main - Centralize offset width handling, and make it possible to specify explicit endianess. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e06874f3f6d1f9a737f4d6489a3de676a5cdc9ec Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 20:02:07 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=e06874f3f6d1f9a737f4d6489a3de676a5cdc9ec commit e06874f3f6d1f9a737f4d6489a3de676a5cdc9ec Author: Poul-Henning Kamp AuthorDate: 2021-05-12 20:01:14 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-12 20:01:14 +0000 Centralize offset width handling, and make it possible to specify explicit endianess. --- usr.sbin/i2c/i2c.8 | 5 +- usr.sbin/i2c/i2c.c | 214 ++++++++++++++++++++++++----------------------------- 2 files changed, 101 insertions(+), 118 deletions(-) diff --git a/usr.sbin/i2c/i2c.8 b/usr.sbin/i2c/i2c.8 index 7e6fe0e7bd49..1c5174e63f32 100644 --- a/usr.sbin/i2c/i2c.8 +++ b/usr.sbin/i2c/i2c.8 @@ -36,7 +36,7 @@ .Cm -a Ar address .Op Fl f Ar device .Op Fl d Ar r|w -.Op Fl w Ar 0|8|16 +.Op Fl w Ar 0|8|16|16LE|16BE .Op Fl o Ar offset .Op Fl c Ar count .Op Fl m Ar tr|ss|rs|no @@ -112,7 +112,7 @@ reset the controller. scan the bus for devices. .It Fl v be verbose. -.It Fl w Ar 0|8|16 +.It Fl w Ar 0|8|16|16LE|16BE device addressing width (in bits). This is used to determine how to pass .Ar offset @@ -120,6 +120,7 @@ specified with .Fl o to the slave. Zero means that the offset is ignored and not passed to the slave at all. +The endianess defaults to little-endian. .El .Sh WARNINGS Great care must be taken when manipulating slave I2C devices with the diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 604460625ecf..64233366a0a8 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -51,18 +51,20 @@ __FBSDID("$FreeBSD$"); #define I2C_MODE_TRANSFER 4 struct options { - int width; - int count; - int verbose; - int addr_set; - int binary; - int scan; - int skip; - int reset; - int mode; - char dir; + const char *width; + int count; + int verbose; + int addr_set; + int binary; + int scan; + int skip; + int reset; + int mode; + char dir; uint32_t addr; uint32_t off; + uint8_t off_buf[2]; + size_t off_len; }; struct skip_range { @@ -267,30 +269,56 @@ reset_bus(const char *dev, int fd) } } -static char * -prepare_buf(int size, uint32_t off) +static const char * +encode_offset(const char *width, unsigned address, uint8_t *dst, size_t *len) { - char *buf; - - buf = malloc(size); - if (buf == NULL) - return (buf); - if (size == 1) - buf[0] = off & 0xff; - else if (size == 2) { - buf[0] = (off >> 8) & 0xff; - buf[1] = off & 0xff; + if (!strcmp(width, "0")) { + *len = 0; + return (NULL); + } + if (!strcmp(width, "8")) { + if (address > 0xff) + return ("Invalid 8-bit address\n"); + *dst = address; + *len = 1; + return (NULL); } + if (address > 0xffff) + return ("Invalid 16-bit address\n"); + if (!strcmp(width, "16LE") || !strcmp(width, "16")) { + le16enc(dst, address); + *len = 2; + return (NULL); + } + if (!strcmp(width, "16BE")) { + be16enc(dst, address); + *len = 2; + return (NULL); + } + return ("Invalid offset width, must be: 0|8|16|16LE|16BE\n"); +} - return (buf); +static const char * +write_offset(int fd, struct options i2c_opt, struct iiccmd *cmd) +{ + int error; + + if (i2c_opt.off_len > 0) { + cmd->count = i2c_opt.off_len; + cmd->buf = i2c_opt.off_buf; + error = ioctl(fd, I2CWRITE, cmd); + if (error == -1) + return ("ioctl: error writing offset\n"); + } + return (NULL); } static int i2c_write(int fd, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; - int error, bufsize; + int error; char *buf; const char *err_msg; @@ -301,33 +329,11 @@ i2c_write(int fd, struct options i2c_opt, char *i2c_buf) goto err1; } - if (i2c_opt.width) { - bufsize = i2c_opt.width / 8; - buf = prepare_buf(bufsize, i2c_opt.off); - if (buf == NULL) { - err_msg = "error: offset malloc"; - goto err1; - } - } else { - bufsize = 0; - buf = NULL; - } - switch(i2c_opt.mode) { case I2C_MODE_STOP_START: - /* - * Write offset where the data will go - */ - if (i2c_opt.width) { - cmd.count = bufsize; - cmd.buf = buf; - error = ioctl(fd, I2CWRITE, &cmd); - free(buf); - if (error == -1) { - err_msg = "ioctl: error writing offset"; - goto err1; - } - } + err_msg = write_offset(fd, i2c_opt, &cmd); + if (err_msg != NULL) + goto err1; error = ioctl(fd, I2CSTOP); if (error == -1) { @@ -355,19 +361,9 @@ i2c_write(int fd, struct options i2c_opt, char *i2c_buf) break; case I2C_MODE_REPEATED_START: - /* - * Write offset where the data will go - */ - if (i2c_opt.width) { - cmd.count = bufsize; - cmd.buf = buf; - error = ioctl(fd, I2CWRITE, &cmd); - free(buf); - if (error == -1) { - err_msg = "ioctl: error writing offset"; - goto err1; - } - } + err_msg = write_offset(fd, i2c_opt, &cmd); + if (err_msg != NULL) + goto err1; cmd.slave = i2c_opt.addr; error = ioctl(fd, I2CRPTSTART, &cmd); @@ -392,17 +388,18 @@ i2c_write(int fd, struct options i2c_opt, char *i2c_buf) case I2C_MODE_NONE: /* fall through */ default: - buf = realloc(buf, bufsize + i2c_opt.count); + buf = malloc(i2c_opt.off_len + i2c_opt.count); if (buf == NULL) { err_msg = "error: data malloc"; goto err1; } + memcpy(buf, i2c_opt.off_buf, i2c_opt.off_len); - memcpy(buf + bufsize, i2c_buf, i2c_opt.count); + memcpy(buf + i2c_opt.off_len, i2c_buf, i2c_opt.count); /* * Write offset and data */ - cmd.count = bufsize + i2c_opt.count; + cmd.count = i2c_opt.off_len + i2c_opt.count; cmd.buf = buf; cmd.last = 0; error = ioctl(fd, I2CWRITE, &cmd); @@ -436,13 +433,13 @@ static int i2c_read(int fd, struct options i2c_opt, char *i2c_buf) { struct iiccmd cmd; - int error, bufsize; - char data = 0, *buf; + int error; + char data = 0; const char *err_msg; bzero(&cmd, sizeof(cmd)); - if (i2c_opt.width) { + if (i2c_opt.off_len) { cmd.slave = i2c_opt.addr; cmd.count = 1; cmd.last = 0; @@ -452,22 +449,10 @@ i2c_read(int fd, struct options i2c_opt, char *i2c_buf) err_msg = "ioctl: error sending start condition"; goto err1; } - bufsize = i2c_opt.width / 8; - buf = prepare_buf(bufsize, i2c_opt.off); - if (buf == NULL) { - err_msg = "error: offset malloc"; - goto err1; - } - cmd.count = bufsize; - cmd.buf = buf; - cmd.last = 0; - error = ioctl(fd, I2CWRITE, &cmd); - free(buf); - if (error == -1) { - err_msg = "ioctl: error writing offset"; + err_msg = write_offset(fd, i2c_opt, &cmd); + if (err_msg != NULL) goto err1; - } if (i2c_opt.mode == I2C_MODE_STOP_START) { error = ioctl(fd, I2CSTOP); @@ -481,7 +466,7 @@ i2c_read(int fd, struct options i2c_opt, char *i2c_buf) cmd.count = 1; cmd.last = 0; cmd.buf = &data; - if (i2c_opt.mode == I2C_MODE_STOP_START || i2c_opt.width == 0) { + if (i2c_opt.mode == I2C_MODE_STOP_START || i2c_opt.off_len == 0) { error = ioctl(fd, I2CSTART, &cmd); if (error == -1) { err_msg = "ioctl: error sending start condition"; @@ -538,24 +523,17 @@ err2: static int i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) { - struct iic_msg msgs[2]; + struct iic_msg msgs[2], *msgp = msgs; struct iic_rdwr_data xfer; - int i; - uint8_t off_buf[2]; - - i = 0; - if (i2c_opt.width > 0) { - msgs[i].flags = IIC_M_WR | IIC_M_NOSTOP; - msgs[i].slave = i2c_opt.addr; - msgs[i].buf = off_buf; - if (i2c_opt.width == 8) { - off_buf[0] = i2c_opt.off; - msgs[i].len = 1; - } else { - le16enc(off_buf, i2c_opt.off); - msgs[i].len = 2; - } - ++i; + int flag = 0; + + if (i2c_opt.off_len) { + msgp->flags = IIC_M_WR | IIC_M_NOSTOP; + msgp->slave = i2c_opt.addr; + msgp->buf = i2c_opt.off_buf; + msgp->len = i2c_opt.off_len; + msgp++; + flag = IIC_M_NOSTART; } /* @@ -566,16 +544,16 @@ i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) * because of the NOSTOP flag used above. */ if (i2c_opt.dir == 'w') - msgs[i].flags = IIC_M_WR | ((i > 0) ? IIC_M_NOSTART : 0); + msgp->flags = IIC_M_WR | flag; else - msgs[i].flags = IIC_M_RD; - msgs[i].slave = i2c_opt.addr; - msgs[i].len = i2c_opt.count; - msgs[i].buf = i2c_buf; - ++i; + msgp->flags = IIC_M_RD; + msgp->slave = i2c_opt.addr; + msgp->len = i2c_opt.count; + msgp->buf = i2c_buf; + msgp++; xfer.msgs = msgs; - xfer.nmsgs = i; + xfer.nmsgs = msgp - msgs; if (ioctl(fd, I2CRDWR, &xfer) == -1 ) err(1, "ioctl(I2CRDWR) failed"); @@ -588,7 +566,7 @@ main(int argc, char** argv) { struct options i2c_opt; char *skip_addr = NULL, *i2c_buf; - const char *dev; + const char *dev, *err_msg; int fd, error, chunk_size, i, j, ch; errno = 0; @@ -604,7 +582,7 @@ main(int argc, char** argv) i2c_opt.off = 0; i2c_opt.verbose = 0; i2c_opt.dir = 'r'; /* direction = read */ - i2c_opt.width = 8; + i2c_opt.width = "8"; i2c_opt.count = 1; i2c_opt.binary = 0; /* ASCII text output */ i2c_opt.scan = 0; /* no bus scan */ @@ -633,7 +611,7 @@ main(int argc, char** argv) error = 1; break; case 'w': - i2c_opt.width = atoi(optarg); + i2c_opt.width = optarg; break; case 'c': i2c_opt.count = atoi(optarg); @@ -686,6 +664,15 @@ main(int argc, char** argv) i2c_opt.mode = I2C_MODE_NONE; } + if (i2c_opt.addr_set) { + err_msg = encode_offset(i2c_opt.width, i2c_opt.off, + i2c_opt.off_buf, &i2c_opt.off_len); + if (err_msg != NULL) { + fprintf(stderr, "%s", err_msg); + exit(EX_USAGE); + } + } + /* Basic sanity check of command line arguments */ if (i2c_opt.scan) { if (i2c_opt.addr_set) @@ -695,16 +682,11 @@ main(int argc, char** argv) usage(); } else if (error) { usage(); - } else if ((i2c_opt.dir == 'r' || i2c_opt.dir == 'w')) { - if ((i2c_opt.addr_set == 0) || - !(i2c_opt.width == 0 || i2c_opt.width == 8 || - i2c_opt.width == 16)) - usage(); } if (i2c_opt.verbose) fprintf(stderr, "dev: %s, addr: 0x%x, r/w: %c, " - "offset: 0x%02x, width: %d, count: %d\n", dev, + "offset: 0x%02x, width: %s, count: %d\n", dev, i2c_opt.addr >> 1, i2c_opt.dir, i2c_opt.off, i2c_opt.width, i2c_opt.count); From owner-dev-commits-src-all@freebsd.org Wed May 12 21:16:00 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 902F964C66C; Wed, 12 May 2021 21:16:00 +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 4FgSJJ3hVTz3Lmw; Wed, 12 May 2021 21:16:00 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 71BAF12938; Wed, 12 May 2021 21:16:00 +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 14CLG0iW067379; Wed, 12 May 2021 21:16:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CLG0F3067378; Wed, 12 May 2021 21:16:00 GMT (envelope-from git) Date: Wed, 12 May 2021 21:16:00 GMT Message-Id: <202105122116.14CLG0F3067378@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: eec6aed5b8c8 - main - sctp: fix another locking bug in COOKIE handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eec6aed5b8c848841ae8d25940e0a333e5039ce9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 21:16:00 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=eec6aed5b8c848841ae8d25940e0a333e5039ce9 commit eec6aed5b8c848841ae8d25940e0a333e5039ce9 Author: Michael Tuexen AuthorDate: 2021-05-12 21:02:31 +0000 Commit: Michael Tuexen CommitDate: 2021-05-12 21:05:28 +0000 sctp: fix another locking bug in COOKIE handling Thanks to Tolya Korniltsev for reporting the issue for the userland stack and testing the fix. MFC after: 3 days --- sys/netinet/sctp_input.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index f066cc100ac2..442e58afd0ff 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1752,17 +1752,23 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, struct sctpasochead *head; if (asoc->peer_supports_nat) { + struct sctp_tcb *local_stcb; + /* * This is a gross gross hack. Just call the * cookie_new code since we are allowing a duplicate * association. I hope this works... */ - return (sctp_process_cookie_new(m, iphlen, offset, src, dst, + local_stcb = sctp_process_cookie_new(m, iphlen, offset, src, dst, sh, cookie, cookie_len, inp, netp, init_src, notification, auth_skipped, auth_offset, auth_len, mflowtype, mflowid, - vrf_id, port)); + vrf_id, port); + if (local_stcb == NULL) { + SCTP_TCB_UNLOCK(stcb); + } + return (local_stcb); } /* * case A in Section 5.2.4 Table 2: XXMM (peer restarted) From owner-dev-commits-src-all@freebsd.org Wed May 12 21:39:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4972464D0F6; Wed, 12 May 2021 21:39:30 +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 4FgSqQ1cmfz3MLl; Wed, 12 May 2021 21:39:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2022512CD5; Wed, 12 May 2021 21:39:30 +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 14CLdUMU093840; Wed, 12 May 2021 21:39:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CLdU54093839; Wed, 12 May 2021 21:39:30 GMT (envelope-from git) Date: Wed, 12 May 2021 21:39:30 GMT Message-Id: <202105122139.14CLdU54093839@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 5ab41ff8e92d - main - More refactoring: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ab41ff8e92da548acf06b50384df538737aa8ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 21:39:30 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=5ab41ff8e92da548acf06b50384df538737aa8ee commit 5ab41ff8e92da548acf06b50384df538737aa8ee Author: Poul-Henning Kamp AuthorDate: 2021-05-12 21:34:58 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-12 21:39:19 +0000 More refactoring: Extract the '-a' mode into a separate function, and simplify the hexdumping logic. Dont call usage() without telling why. --- usr.sbin/i2c/i2c.8 | 36 +++-------- usr.sbin/i2c/i2c.c | 181 +++++++++++++++++++++++++---------------------------- 2 files changed, 97 insertions(+), 120 deletions(-) diff --git a/usr.sbin/i2c/i2c.8 b/usr.sbin/i2c/i2c.8 index 1c5174e63f32..352b13157968 100644 --- a/usr.sbin/i2c/i2c.8 +++ b/usr.sbin/i2c/i2c.8 @@ -64,12 +64,12 @@ The options are as follows: 7-bit address on the I2C device to operate on (hex). .It Fl b binary mode - when performing a read operation, the data read from the device -is output in binary format on stdout; when doing a write, the binary data to -be written to the device is read from stdin. +is output in binary format on stdout. .It Fl c Ar count -number of bytes to transfer (dec). +number of bytes to transfer (decimal). .It Fl d Ar r|w transfer direction: r - read, w - write. +Data to be written is read from stdin as binary bytes. .It Fl f Ar device I2C bus to use (default is /dev/iic0). .It Fl m Ar tr|ss|rs|no @@ -113,7 +113,7 @@ scan the bus for devices. .It Fl v be verbose. .It Fl w Ar 0|8|16|16LE|16BE -device addressing width (in bits). +device offset width (in bits). This is used to determine how to pass .Ar offset specified with @@ -122,28 +122,6 @@ to the slave. Zero means that the offset is ignored and not passed to the slave at all. The endianess defaults to little-endian. .El -.Sh WARNINGS -Great care must be taken when manipulating slave I2C devices with the -.Nm -utility. -Often times important configuration data for the system is kept in non-volatile -but write enabled memories located on the I2C bus, for example Ethernet hardware -addresses, RAM module parameters (SPD), processor reset configuration word etc. -.Pp -It is very easy to render the whole system unusable when such configuration -data is deleted or altered, so use the -.Dq -d w -(write) command only if you know exactly what you are doing. -.Pp -Also avoid ungraceful interrupting of an ongoing transaction on the I2C bus, -as it can lead to potentially dangerous effects. -Consider the following scenario: when the host CPU is reset (for whatever reason) -in the middle of a started I2C transaction, the I2C slave device could be left -in write mode waiting for data or offset to arrive. -When the CPU reinitializes itself and talks to this I2C slave device again, -the commands and other control info it sends are treated by the slave device -as data or offset it was waiting for, and there's great potential for -corruption if such a write is performed. .Sh EXAMPLES .Bl -bullet .It @@ -177,9 +155,15 @@ Reset the controller: .Pp i2c -f /dev/iic1 -r .El +.Sh WARNING +Many systems store critical low-level information in I2C memories, and +may contain other I2C devices, such as temperature or voltage sensors. +Reading these can disturb the firmware's operation and writing to them +can "brick" the hardware. .Sh SEE ALSO .Xr iic 4 , .Xr iicbus 4 +.Xr smbus 4 .Sh HISTORY The .Nm diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 64233366a0a8..c862666fc9a7 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -73,9 +73,11 @@ struct skip_range { }; __dead2 static void -usage(void) +usage(const char *msg) { + if (msg != NULL) + fprintf(stderr, "%s\n", msg); fprintf(stderr, "usage: %s -a addr [-f device] [-d [r|w]] [-o offset] " "[-w [0|8|16]] [-c count] [-m [tr|ss|rs|no]] [-b] [-v]\n", getprogname()); @@ -561,19 +563,71 @@ i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) return (0); } +static int +access_bus(int fd, struct options i2c_opt) +{ + char *i2c_buf; + int error, chunk_size = 16, i, ch; + + i2c_buf = malloc(i2c_opt.count); + if (i2c_buf == NULL) + err(1, "data malloc"); + + /* + * For a write, read the data to be written to the chip from stdin. + */ + if (i2c_opt.dir == 'w') { + if (i2c_opt.verbose && !i2c_opt.binary) + fprintf(stderr, "Enter %d bytes of data: ", + i2c_opt.count); + for (i = 0; i < i2c_opt.count; i++) { + ch = getchar(); + if (ch == EOF) { + free(i2c_buf); + err(1, "not enough data, exiting\n"); + } + i2c_buf[i] = ch; + } + } + + if (i2c_opt.mode == I2C_MODE_TRANSFER) + error = i2c_rdwr_transfer(fd, i2c_opt, i2c_buf); + else if (i2c_opt.dir == 'w') + error = i2c_write(fd, i2c_opt, i2c_buf); + else + error = i2c_read(fd, i2c_opt, i2c_buf); + + if (error == 0) { + if (i2c_opt.dir == 'r' && i2c_opt.binary) { + (void)fwrite(i2c_buf, 1, i2c_opt.count, stdout); + } else if (i2c_opt.verbose || i2c_opt.dir == 'r') { + if (i2c_opt.verbose) + fprintf(stderr, "\nData %s (hex):\n", + i2c_opt.dir == 'r' ? "read" : "written"); + + for (i = 0; i < i2c_opt.count; i++) { + fprintf (stderr, "%02hhx ", i2c_buf[i]); + if ((i % chunk_size) == chunk_size - 1) + fprintf(stderr, "\n"); + } + if ((i % chunk_size) != 0) + fprintf(stderr, "\n"); + } + } + + free(i2c_buf); + return (error); +} + int main(int argc, char** argv) { struct options i2c_opt; - char *skip_addr = NULL, *i2c_buf; + char *skip_addr = NULL; const char *dev, *err_msg; - int fd, error, chunk_size, i, j, ch; + int fd, error, ch; errno = 0; - error = 0; - - /* Line-break the output every chunk_size bytes */ - chunk_size = 16; dev = I2C_DEV; @@ -595,9 +649,8 @@ main(int argc, char** argv) case 'a': i2c_opt.addr = (strtoul(optarg, 0, 16) << 1); if (i2c_opt.addr == 0 && errno == EINVAL) - i2c_opt.addr_set = 0; - else - i2c_opt.addr_set = 1; + usage("Bad -a argument (hex)"); + i2c_opt.addr_set = 1; break; case 'f': dev = optarg; @@ -608,13 +661,15 @@ main(int argc, char** argv) case 'o': i2c_opt.off = strtoul(optarg, 0, 16); if (i2c_opt.off == 0 && errno == EINVAL) - error = 1; + usage("Bad -o argument (hex)"); break; case 'w': i2c_opt.width = optarg; break; case 'c': - i2c_opt.count = atoi(optarg); + i2c_opt.count = (strtoul(optarg, 0, 10)); + if (i2c_opt.count == 0 && errno == EINVAL) + usage("Bad -c argument (decimal)"); break; case 'm': if (!strcmp(optarg, "no")) @@ -626,7 +681,7 @@ main(int argc, char** argv) else if (!strcmp(optarg, "tr")) i2c_opt.mode = I2C_MODE_TRANSFER; else - usage(); + usage("Bad -m argument ([no|ss|rs|tr])"); break; case 'n': i2c_opt.skip = 1; @@ -645,16 +700,16 @@ main(int argc, char** argv) i2c_opt.reset = 1; break; case 'h': + usage("Help:"); + break; default: - usage(); + usage("Bad argument"); } } argc -= optind; argv += optind; - if (argc > 0) { - fprintf(stderr, "Too many arguments\n"); - usage(); - } + if (argc > 0) + usage("Too many arguments"); /* Set default mode if option -m is not specified */ if (i2c_opt.mode == I2C_MODE_NOTSET) { @@ -664,24 +719,20 @@ main(int argc, char** argv) i2c_opt.mode = I2C_MODE_NONE; } - if (i2c_opt.addr_set) { - err_msg = encode_offset(i2c_opt.width, i2c_opt.off, - i2c_opt.off_buf, &i2c_opt.off_len); - if (err_msg != NULL) { - fprintf(stderr, "%s", err_msg); - exit(EX_USAGE); - } + err_msg = encode_offset(i2c_opt.width, i2c_opt.off, + i2c_opt.off_buf, &i2c_opt.off_len); + if (err_msg != NULL) { + fprintf(stderr, "%s", err_msg); + exit(EX_USAGE); } /* Basic sanity check of command line arguments */ if (i2c_opt.scan) { if (i2c_opt.addr_set) - usage(); + usage("-s and -a are incompatible"); } else if (i2c_opt.reset) { if (i2c_opt.addr_set) - usage(); - } else if (error) { - usage(); + usage("-r and -a are incompatible"); } if (i2c_opt.verbose) @@ -698,71 +749,13 @@ main(int argc, char** argv) } if (i2c_opt.scan) - exit(scan_bus(dev, fd, i2c_opt.skip, skip_addr)); - - if (i2c_opt.reset) - exit(reset_bus(dev, fd)); - - i2c_buf = malloc(i2c_opt.count); - if (i2c_buf == NULL) - err(1, "data malloc"); - - /* - * For a write, read the data to be written to the chip from stdin. - */ - if (i2c_opt.dir == 'w') { - if (i2c_opt.verbose && !i2c_opt.binary) - fprintf(stderr, "Enter %d bytes of data: ", - i2c_opt.count); - for (i = 0; i < i2c_opt.count; i++) { - ch = getchar(); - if (ch == EOF) { - free(i2c_buf); - err(1, "not enough data, exiting\n"); - } - i2c_buf[i] = ch; - } - } - - if (i2c_opt.mode == I2C_MODE_TRANSFER) - error = i2c_rdwr_transfer(fd, i2c_opt, i2c_buf); - else if (i2c_opt.dir == 'w') - error = i2c_write(fd, i2c_opt, i2c_buf); + error = scan_bus(dev, fd, i2c_opt.skip, skip_addr); + else if (i2c_opt.reset) + error = reset_bus(dev, fd); else - error = i2c_read(fd, i2c_opt, i2c_buf); - - if (error != 0) { - free(i2c_buf); - return (1); - } - - error = close(fd); - assert(error == 0); + error = access_bus(fd, i2c_opt); - if (i2c_opt.verbose) - fprintf(stderr, "\nData %s (hex):\n", i2c_opt.dir == 'r' ? - "read" : "written"); - - i = 0; - j = 0; - while (i < i2c_opt.count) { - if (i2c_opt.verbose || (i2c_opt.dir == 'r' && - !i2c_opt.binary)) - fprintf (stderr, "%02hhx ", i2c_buf[i++]); - - if (i2c_opt.dir == 'r' && i2c_opt.binary) { - fprintf(stdout, "%c", i2c_buf[j++]); - if(!i2c_opt.verbose) - i++; - } - if (!i2c_opt.verbose && (i2c_opt.dir == 'w')) - break; - if ((i % chunk_size) == 0) - fprintf(stderr, "\n"); - } - if ((i % chunk_size) != 0) - fprintf(stderr, "\n"); - - free(i2c_buf); - return (0); + ch = close(fd); + assert(ch == 0); + return (error); } From owner-dev-commits-src-all@freebsd.org Wed May 12 21:39:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7891464D233; Wed, 12 May 2021 21:39:31 +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 4FgSqR2gWzz3MYv; Wed, 12 May 2021 21:39:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4CC7812F82; Wed, 12 May 2021 21:39:31 +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 14CLdVMa093861; Wed, 12 May 2021 21:39:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CLdVRh093860; Wed, 12 May 2021 21:39:31 GMT (envelope-from git) Date: Wed, 12 May 2021 21:39:31 GMT Message-Id: <202105122139.14CLdVRh093860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 29c6e6e279b3 - main - More refactoring & polishing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 29c6e6e279b3bbab78510ff03922e7fb85f93ee2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 21:39:31 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=29c6e6e279b3bbab78510ff03922e7fb85f93ee2 commit 29c6e6e279b3bbab78510ff03922e7fb85f93ee2 Author: Poul-Henning Kamp AuthorDate: 2021-05-12 21:37:00 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-12 21:39:19 +0000 More refactoring & polishing. Do not call usage() without telling why. Extract '-a' mode into a function, and sanitize hexdumping. Revise manpage to match reality of code. --- usr.sbin/i2c/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index c862666fc9a7..588aad8592ee 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -79,7 +79,7 @@ usage(const char *msg) if (msg != NULL) fprintf(stderr, "%s\n", msg); fprintf(stderr, "usage: %s -a addr [-f device] [-d [r|w]] [-o offset] " - "[-w [0|8|16]] [-c count] [-m [tr|ss|rs|no]] [-b] [-v]\n", + "[-w [0|8|16|16LE|16BE]] [-c count] [-m [tr|ss|rs|no]] [-b] [-v]\n", getprogname()); fprintf(stderr, " %s -s [-f device] [-n skip_addr] -v\n", getprogname()); From owner-dev-commits-src-all@freebsd.org Wed May 12 23:31:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EEB364F9C9; Wed, 12 May 2021 23:31:41 +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 4FgWJs0vn6z3hfj; Wed, 12 May 2021 23:31:41 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 122C114612; Wed, 12 May 2021 23:31:41 +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 14CNVeTM050958; Wed, 12 May 2021 23:31:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CNVeKf050957; Wed, 12 May 2021 23:31:40 GMT (envelope-from git) Date: Wed, 12 May 2021 23:31:40 GMT Message-Id: <202105122331.14CNVeKf050957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 529ab5a75925 - main - rtld: initialize default dlerror_seen_val as true MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 529ab5a75925c9c1eeea0b2712911048119d06ae Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 23:31:41 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=529ab5a75925c9c1eeea0b2712911048119d06ae commit 529ab5a75925c9c1eeea0b2712911048119d06ae Author: Konstantin Belousov AuthorDate: 2021-05-11 23:36:09 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-12 23:31:29 +0000 rtld: initialize default dlerror_seen_val as true There should be no error after startup. PR: 255698 Reported by: Eugene M. Kim Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/rtld_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index 94e931c2f760..e501c03f0722 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -60,7 +60,7 @@ void _rtld_atfork_pre(int *) __exported; void _rtld_atfork_post(int *) __exported; static char def_dlerror_msg[512]; -static int def_dlerror_seen_val; +static int def_dlerror_seen_val = 1; static char * def_dlerror_loc(void) From owner-dev-commits-src-all@freebsd.org Wed May 12 23:32:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2D8764FC18; Wed, 12 May 2021 23:32:24 +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 4FgWKh6dV3z3hvL; Wed, 12 May 2021 23:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D69E0146D5; Wed, 12 May 2021 23:32:24 +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 14CNWOeB052023; Wed, 12 May 2021 23:32:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14CNWOEk052022; Wed, 12 May 2021 23:32:24 GMT (envelope-from git) Date: Wed, 12 May 2021 23:32:24 GMT Message-Id: <202105122332.14CNWOEk052022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 6de3cf14c47d - main - vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6de3cf14c47d97b423ae25d5bd1d80b896ecd9e6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 23:32:25 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6de3cf14c47d97b423ae25d5bd1d80b896ecd9e6 commit 6de3cf14c47d97b423ae25d5bd1d80b896ecd9e6 Author: Konstantin Belousov AuthorDate: 2021-05-12 19:04:44 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-12 23:32:04 +0000 vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH This combination does not make sense, and cannot be satisfied by lookup. In particular, lookup cannot supply dvp, it only can directly return vp. Reported and reviewed by: markj using syzkaller Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/kern/vfs_vnops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 670bc4bf8fcc..8f583329f067 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -233,7 +233,8 @@ restart: first_open = false; fmode = *flagp; if ((fmode & (O_CREAT | O_EXCL | O_DIRECTORY)) == (O_CREAT | - O_EXCL | O_DIRECTORY)) + O_EXCL | O_DIRECTORY) || + (fmode & (O_CREAT | O_EMPTY_PATH)) == (O_CREAT | O_EMPTY_PATH)) return (EINVAL); else if ((fmode & (O_CREAT | O_DIRECTORY)) == O_CREAT) { ndp->ni_cnd.cn_nameiop = CREATE; From owner-dev-commits-src-all@freebsd.org Thu May 13 01:33:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD60C62C7EE; Thu, 13 May 2021 01:33:33 +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 4FgZ1T5TMtz3pN6; Thu, 13 May 2021 01:33:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AEDF81602B; Thu, 13 May 2021 01:33:33 +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 14D1XX67013557; Thu, 13 May 2021 01:33:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14D1XXD6013556; Thu, 13 May 2021 01:33:33 GMT (envelope-from git) Date: Thu, 13 May 2021 01:33:33 GMT Message-Id: <202105130133.14D1XXD6013556@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: d4870e3a7256 - main - bhyve/snapshot: provide a way to send other messages/data to bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d4870e3a7256704905655e997b37a866024c2894 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 01:33:33 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=d4870e3a7256704905655e997b37a866024c2894 commit d4870e3a7256704905655e997b37a866024c2894 Author: Robert Wing AuthorDate: 2021-03-03 06:05:47 +0000 Commit: Robert Wing CommitDate: 2021-05-13 01:20:15 +0000 bhyve/snapshot: provide a way to send other messages/data to bhyve This is a step towards sending messages (other than suspend/checkpoint) from bhyvectl to bhyve. Introduce a new struct, ipc_message - this struct stores the type of message and a union containing message specific structures for the type of message being sent. Reviewed by: grehan Differential Revision: https://reviews.freebsd.org/D30221 --- usr.sbin/bhyve/snapshot.c | 16 ++++++++-------- usr.sbin/bhyve/snapshot.h | 21 ++++++++++++++++++--- usr.sbin/bhyvectl/bhyvectl.c | 15 +++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 221558b6f205..019f4fdd6cb0 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -1441,16 +1441,16 @@ done: } int -handle_message(struct checkpoint_op *checkpoint_op, struct vmctx *ctx) +handle_message(struct ipc_message *imsg, struct vmctx *ctx) { int err; - switch (checkpoint_op->op) { + switch (imsg->code) { case START_CHECKPOINT: - err = vm_checkpoint(ctx, checkpoint_op->snapshot_filename, false); + err = vm_checkpoint(ctx, imsg->data.op.snapshot_filename, false); break; case START_SUSPEND: - err = vm_checkpoint(ctx, checkpoint_op->snapshot_filename, true); + err = vm_checkpoint(ctx, imsg->data.op.snapshot_filename, true); break; default: EPRINTLN("Unrecognized checkpoint operation\n"); @@ -1469,7 +1469,7 @@ handle_message(struct checkpoint_op *checkpoint_op, struct vmctx *ctx) void * checkpoint_thread(void *param) { - struct checkpoint_op op; + struct ipc_message imsg; struct checkpoint_thread_info *thread_info; ssize_t n; @@ -1477,14 +1477,14 @@ checkpoint_thread(void *param) thread_info = (struct checkpoint_thread_info *)param; for (;;) { - n = recvfrom(thread_info->socket_fd, &op, sizeof(op), 0, NULL, 0); + n = recvfrom(thread_info->socket_fd, &imsg, sizeof(imsg), 0, NULL, 0); /* * slight sanity check: see if there's enough data to at * least determine the type of message. */ - if (n >= sizeof(op.op)) - handle_message(&op, thread_info->ctx); + if (n >= sizeof(imsg.code)) + handle_message(&imsg, thread_info->ctx); else EPRINTLN("Failed to receive message: %s\n", n == -1 ? strerror(errno) : "unknown error"); diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h index 8a6ee67ef19d..f28b56cf0a7f 100644 --- a/usr.sbin/bhyve/snapshot.h +++ b/usr.sbin/bhyve/snapshot.h @@ -60,14 +60,29 @@ struct restore_state { ucl_object_t *meta_root_obj; }; +/* Filename that will be used for save/restore */ +struct checkpoint_op { + char snapshot_filename[MAX_SNAPSHOT_FILENAME]; +}; + +/* Messages that a bhyve process understands. */ enum ipc_opcode { START_CHECKPOINT, START_SUSPEND, }; -struct checkpoint_op { - unsigned int op; - char snapshot_filename[MAX_SNAPSHOT_FILENAME]; +/* + * The type of message and associated data to + * send to a bhyve process. + */ +struct ipc_message { + enum ipc_opcode code; + union { + /* + * message specific structures + */ + struct checkpoint_op op; + } data; }; struct checkpoint_thread_info { diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index df02f7caf345..017427db4d4f 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -1684,7 +1684,7 @@ show_memseg(struct vmctx *ctx) #ifdef BHYVE_SNAPSHOT static int -send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op) +send_message(struct vmctx *ctx, void *data, size_t len) { struct sockaddr_un addr; ssize_t len_sent; @@ -1709,7 +1709,7 @@ send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op) snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", BHYVE_RUN_DIR, vmname_buf); - len_sent = sendto(socket_fd, op, sizeof(*op), 0, + len_sent = sendto(socket_fd, data, len, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)); if (len_sent < 0) { @@ -1726,12 +1726,15 @@ done: static int snapshot_request(struct vmctx *ctx, const char *file, enum ipc_opcode code) { - struct checkpoint_op op; + struct ipc_message imsg; + size_t length; - op.op = code; - strlcpy(op.snapshot_filename, file, MAX_SNAPSHOT_FILENAME); + imsg.code = code; + strlcpy(imsg.data.op.snapshot_filename, file, MAX_SNAPSHOT_FILENAME); - return (send_checkpoint_op_req(ctx, &op)); + length = offsetof(struct ipc_message, data) + sizeof(imsg.data.op); + + return (send_message(ctx, (void *)&imsg, length)); } #endif From owner-dev-commits-src-all@freebsd.org Thu May 13 01:42:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B68862D1C1; Thu, 13 May 2021 01:42:51 +0000 (UTC) (envelope-from rew@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FgZDC27CBz3pdx; Thu, 13 May 2021 01:42:51 +0000 (UTC) (envelope-from rew@freebsd.org) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: rew) by smtp.freebsd.org (Postfix) with ESMTPSA id 3954B395D; Thu, 13 May 2021 01:42:51 +0000 (UTC) (envelope-from rew@freebsd.org) Received: by mail-ot1-f44.google.com with SMTP id t4-20020a05683014c4b02902ed26dd7a60so12279005otq.7; Wed, 12 May 2021 18:42:51 -0700 (PDT) X-Gm-Message-State: AOAM533bIQqwR9ltEDJS2HIE/dje7+JhOZ8nRIf9g6Ip4jJRKaJjeeLj ddQG/a/dfXSB/kRmpSlr4UyzTqpN0BbsP6eNw6I= X-Google-Smtp-Source: ABdhPJxw3pxmTbK45iSz7Ob8/axO5IIBh57kvZ3oGYhyqnDUxwUuDLi4dVARVxFFU3VI5U3CsSoNYTIhyKynuKVvw6Q= X-Received: by 2002:a05:6830:1556:: with SMTP id l22mr33105404otp.34.1620870170349; Wed, 12 May 2021 18:42:50 -0700 (PDT) MIME-Version: 1.0 References: <202105130133.14D1XXD6013556@gitrepo.freebsd.org> In-Reply-To: <202105130133.14D1XXD6013556@gitrepo.freebsd.org> From: Rob Wing Date: Wed, 12 May 2021 17:43:08 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: d4870e3a7256 - main - bhyve/snapshot: provide a way to send other messages/data to bhyve To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 01:42:51 -0000 shoot, I messed up - the differential revision is https://reviews.freebsd.org/D29213 On Wed, May 12, 2021 at 5:33 PM Robert Wing wrote: > The branch main has been updated by rew: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=d4870e3a7256704905655e997b37a866024c2894 > > commit d4870e3a7256704905655e997b37a866024c2894 > Author: Robert Wing > AuthorDate: 2021-03-03 06:05:47 +0000 > Commit: Robert Wing > CommitDate: 2021-05-13 01:20:15 +0000 > > bhyve/snapshot: provide a way to send other messages/data to bhyve > > This is a step towards sending messages (other than suspend/checkpoint) > from bhyvectl to bhyve. > > Introduce a new struct, ipc_message - this struct stores the type of > message and a union containing message specific structures for the type > of message being sent. > > Reviewed by: grehan > Differential Revision: https://reviews.freebsd.org/D30221 > --- > usr.sbin/bhyve/snapshot.c | 16 ++++++++-------- > usr.sbin/bhyve/snapshot.h | 21 ++++++++++++++++++--- > usr.sbin/bhyvectl/bhyvectl.c | 15 +++++++++------ > 3 files changed, 35 insertions(+), 17 deletions(-) > > diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c > index 221558b6f205..019f4fdd6cb0 100644 > --- a/usr.sbin/bhyve/snapshot.c > +++ b/usr.sbin/bhyve/snapshot.c > @@ -1441,16 +1441,16 @@ done: > } > > int > -handle_message(struct checkpoint_op *checkpoint_op, struct vmctx *ctx) > +handle_message(struct ipc_message *imsg, struct vmctx *ctx) > { > int err; > > - switch (checkpoint_op->op) { > + switch (imsg->code) { > case START_CHECKPOINT: > - err = vm_checkpoint(ctx, > checkpoint_op->snapshot_filename, false); > + err = vm_checkpoint(ctx, > imsg->data.op.snapshot_filename, false); > break; > case START_SUSPEND: > - err = vm_checkpoint(ctx, > checkpoint_op->snapshot_filename, true); > + err = vm_checkpoint(ctx, > imsg->data.op.snapshot_filename, true); > break; > default: > EPRINTLN("Unrecognized checkpoint operation\n"); > @@ -1469,7 +1469,7 @@ handle_message(struct checkpoint_op *checkpoint_op, > struct vmctx *ctx) > void * > checkpoint_thread(void *param) > { > - struct checkpoint_op op; > + struct ipc_message imsg; > struct checkpoint_thread_info *thread_info; > ssize_t n; > > @@ -1477,14 +1477,14 @@ checkpoint_thread(void *param) > thread_info = (struct checkpoint_thread_info *)param; > > for (;;) { > - n = recvfrom(thread_info->socket_fd, &op, sizeof(op), 0, > NULL, 0); > + n = recvfrom(thread_info->socket_fd, &imsg, sizeof(imsg), > 0, NULL, 0); > > /* > * slight sanity check: see if there's enough data to at > * least determine the type of message. > */ > - if (n >= sizeof(op.op)) > - handle_message(&op, thread_info->ctx); > + if (n >= sizeof(imsg.code)) > + handle_message(&imsg, thread_info->ctx); > else > EPRINTLN("Failed to receive message: %s\n", > n == -1 ? strerror(errno) : "unknown error"); > diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h > index 8a6ee67ef19d..f28b56cf0a7f 100644 > --- a/usr.sbin/bhyve/snapshot.h > +++ b/usr.sbin/bhyve/snapshot.h > @@ -60,14 +60,29 @@ struct restore_state { > ucl_object_t *meta_root_obj; > }; > > +/* Filename that will be used for save/restore */ > +struct checkpoint_op { > + char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > +}; > + > +/* Messages that a bhyve process understands. */ > enum ipc_opcode { > START_CHECKPOINT, > START_SUSPEND, > }; > > -struct checkpoint_op { > - unsigned int op; > - char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > +/* > + * The type of message and associated data to > + * send to a bhyve process. > + */ > +struct ipc_message { > + enum ipc_opcode code; > + union { > + /* > + * message specific structures > + */ > + struct checkpoint_op op; > + } data; > }; > > struct checkpoint_thread_info { > diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c > index df02f7caf345..017427db4d4f 100644 > --- a/usr.sbin/bhyvectl/bhyvectl.c > +++ b/usr.sbin/bhyvectl/bhyvectl.c > @@ -1684,7 +1684,7 @@ show_memseg(struct vmctx *ctx) > > #ifdef BHYVE_SNAPSHOT > static int > -send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op) > +send_message(struct vmctx *ctx, void *data, size_t len) > { > struct sockaddr_un addr; > ssize_t len_sent; > @@ -1709,7 +1709,7 @@ send_checkpoint_op_req(struct vmctx *ctx, struct > checkpoint_op *op) > > snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", > BHYVE_RUN_DIR, vmname_buf); > > - len_sent = sendto(socket_fd, op, sizeof(*op), 0, > + len_sent = sendto(socket_fd, data, len, 0, > (struct sockaddr *)&addr, sizeof(struct sockaddr_un)); > > if (len_sent < 0) { > @@ -1726,12 +1726,15 @@ done: > static int > snapshot_request(struct vmctx *ctx, const char *file, enum ipc_opcode > code) > { > - struct checkpoint_op op; > + struct ipc_message imsg; > + size_t length; > > - op.op = code; > - strlcpy(op.snapshot_filename, file, MAX_SNAPSHOT_FILENAME); > + imsg.code = code; > + strlcpy(imsg.data.op.snapshot_filename, file, > MAX_SNAPSHOT_FILENAME); > > - return (send_checkpoint_op_req(ctx, &op)); > + length = offsetof(struct ipc_message, data) + sizeof(imsg.data.op); > + > + return (send_message(ctx, (void *)&imsg, length)); > } > #endif > > From owner-dev-commits-src-all@freebsd.org Thu May 13 04:39:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 74900630E9B; Thu, 13 May 2021 04:39:49 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fgf8P18Cbz4RNR; Thu, 13 May 2021 04:39:48 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 14D4dfTQ074721; Wed, 12 May 2021 21:39:41 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 14D4dfZ2074720; Wed, 12 May 2021 21:39:41 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202105130439.14D4dfZ2074720@gndrsh.dnsmgr.net> Subject: Re: git: d4870e3a7256 - main - bhyve/snapshot: provide a way to send other messages/data to bhyve In-Reply-To: To: Rob Wing Date: Wed, 12 May 2021 21:39:41 -0700 (PDT) CC: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4Fgf8P18Cbz4RNR X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 04:39:49 -0000 > shoot, I messed up - the differential revision is > https://reviews.freebsd.org/D29213 And it is going to take more than a comment here and remove a couple of subscribers to "undo" this mistake. If you go open https://reviews.freebsd.org/D30211 now you well see that this committed diff is what shows up in the review, and what you get if you try to download the rawdiff. I do not know how to clean this up, but the simple action of making a comment on the mailling list to "fix" these types of mistakes is leaving a lot of cruft around that can be very hard to sort out at a later date, especially since the "fix" is pretty much invisible to all the tools. > > On Wed, May 12, 2021 at 5:33 PM Robert Wing wrote: > > > The branch main has been updated by rew: > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=d4870e3a7256704905655e997b37a866024c2894 > > > > commit d4870e3a7256704905655e997b37a866024c2894 > > Author: Robert Wing > > AuthorDate: 2021-03-03 06:05:47 +0000 > > Commit: Robert Wing > > CommitDate: 2021-05-13 01:20:15 +0000 > > > > bhyve/snapshot: provide a way to send other messages/data to bhyve > > > > This is a step towards sending messages (other than suspend/checkpoint) > > from bhyvectl to bhyve. > > > > Introduce a new struct, ipc_message - this struct stores the type of > > message and a union containing message specific structures for the type > > of message being sent. > > > > Reviewed by: grehan > > Differential Revision: https://reviews.freebsd.org/D30221 > > --- > > usr.sbin/bhyve/snapshot.c | 16 ++++++++-------- > > usr.sbin/bhyve/snapshot.h | 21 ++++++++++++++++++--- > > usr.sbin/bhyvectl/bhyvectl.c | 15 +++++++++------ > > 3 files changed, 35 insertions(+), 17 deletions(-) > > > > diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c > > index 221558b6f205..019f4fdd6cb0 100644 > > --- a/usr.sbin/bhyve/snapshot.c > > +++ b/usr.sbin/bhyve/snapshot.c > > @@ -1441,16 +1441,16 @@ done: > > } > > > > int > > -handle_message(struct checkpoint_op *checkpoint_op, struct vmctx *ctx) > > +handle_message(struct ipc_message *imsg, struct vmctx *ctx) > > { > > int err; > > > > - switch (checkpoint_op->op) { > > + switch (imsg->code) { > > case START_CHECKPOINT: > > - err = vm_checkpoint(ctx, > > checkpoint_op->snapshot_filename, false); > > + err = vm_checkpoint(ctx, > > imsg->data.op.snapshot_filename, false); > > break; > > case START_SUSPEND: > > - err = vm_checkpoint(ctx, > > checkpoint_op->snapshot_filename, true); > > + err = vm_checkpoint(ctx, > > imsg->data.op.snapshot_filename, true); > > break; > > default: > > EPRINTLN("Unrecognized checkpoint operation\n"); > > @@ -1469,7 +1469,7 @@ handle_message(struct checkpoint_op *checkpoint_op, > > struct vmctx *ctx) > > void * > > checkpoint_thread(void *param) > > { > > - struct checkpoint_op op; > > + struct ipc_message imsg; > > struct checkpoint_thread_info *thread_info; > > ssize_t n; > > > > @@ -1477,14 +1477,14 @@ checkpoint_thread(void *param) > > thread_info = (struct checkpoint_thread_info *)param; > > > > for (;;) { > > - n = recvfrom(thread_info->socket_fd, &op, sizeof(op), 0, > > NULL, 0); > > + n = recvfrom(thread_info->socket_fd, &imsg, sizeof(imsg), > > 0, NULL, 0); > > > > /* > > * slight sanity check: see if there's enough data to at > > * least determine the type of message. > > */ > > - if (n >= sizeof(op.op)) > > - handle_message(&op, thread_info->ctx); > > + if (n >= sizeof(imsg.code)) > > + handle_message(&imsg, thread_info->ctx); > > else > > EPRINTLN("Failed to receive message: %s\n", > > n == -1 ? strerror(errno) : "unknown error"); > > diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h > > index 8a6ee67ef19d..f28b56cf0a7f 100644 > > --- a/usr.sbin/bhyve/snapshot.h > > +++ b/usr.sbin/bhyve/snapshot.h > > @@ -60,14 +60,29 @@ struct restore_state { > > ucl_object_t *meta_root_obj; > > }; > > > > +/* Filename that will be used for save/restore */ > > +struct checkpoint_op { > > + char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > > +}; > > + > > +/* Messages that a bhyve process understands. */ > > enum ipc_opcode { > > START_CHECKPOINT, > > START_SUSPEND, > > }; > > > > -struct checkpoint_op { > > - unsigned int op; > > - char snapshot_filename[MAX_SNAPSHOT_FILENAME]; > > +/* > > + * The type of message and associated data to > > + * send to a bhyve process. > > + */ > > +struct ipc_message { > > + enum ipc_opcode code; > > + union { > > + /* > > + * message specific structures > > + */ > > + struct checkpoint_op op; > > + } data; > > }; > > > > struct checkpoint_thread_info { > > diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c > > index df02f7caf345..017427db4d4f 100644 > > --- a/usr.sbin/bhyvectl/bhyvectl.c > > +++ b/usr.sbin/bhyvectl/bhyvectl.c > > @@ -1684,7 +1684,7 @@ show_memseg(struct vmctx *ctx) > > > > #ifdef BHYVE_SNAPSHOT > > static int > > -send_checkpoint_op_req(struct vmctx *ctx, struct checkpoint_op *op) > > +send_message(struct vmctx *ctx, void *data, size_t len) > > { > > struct sockaddr_un addr; > > ssize_t len_sent; > > @@ -1709,7 +1709,7 @@ send_checkpoint_op_req(struct vmctx *ctx, struct > > checkpoint_op *op) > > > > snprintf(addr.sun_path, sizeof(addr.sun_path), "%s%s", > > BHYVE_RUN_DIR, vmname_buf); > > > > - len_sent = sendto(socket_fd, op, sizeof(*op), 0, > > + len_sent = sendto(socket_fd, data, len, 0, > > (struct sockaddr *)&addr, sizeof(struct sockaddr_un)); > > > > if (len_sent < 0) { > > @@ -1726,12 +1726,15 @@ done: > > static int > > snapshot_request(struct vmctx *ctx, const char *file, enum ipc_opcode > > code) > > { > > - struct checkpoint_op op; > > + struct ipc_message imsg; > > + size_t length; > > > > - op.op = code; > > - strlcpy(op.snapshot_filename, file, MAX_SNAPSHOT_FILENAME); > > + imsg.code = code; > > + strlcpy(imsg.data.op.snapshot_filename, file, > > MAX_SNAPSHOT_FILENAME); > > > > - return (send_checkpoint_op_req(ctx, &op)); > > + length = offsetof(struct ipc_message, data) + sizeof(imsg.data.op); > > + > > + return (send_message(ctx, (void *)&imsg, length)); > > } > > #endif > > > > -- Rod Grimes rgrimes@freebsd.org From owner-dev-commits-src-all@freebsd.org Thu May 13 05:58:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFD7C6323CC; Thu, 13 May 2021 05:58:36 +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 4FggvJ66y1z4VG8; Thu, 13 May 2021 05:58:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C02B719548; Thu, 13 May 2021 05:58:36 +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 14D5wa57057476; Thu, 13 May 2021 05:58:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14D5wa8P057475; Thu, 13 May 2021 05:58:36 GMT (envelope-from git) Date: Thu, 13 May 2021 05:58:36 GMT Message-Id: <202105130558.14D5wa8P057475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 1025baec7b78 - main - stress2: Added two new syzkaller reproducers. Update the exclude list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1025baec7b786df46ee63bf55369cf081002b8af Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 05:58:37 -0000 The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=1025baec7b786df46ee63bf55369cf081002b8af commit 1025baec7b786df46ee63bf55369cf081002b8af Author: Peter Holm AuthorDate: 2021-05-13 05:57:32 +0000 Commit: Peter Holm CommitDate: 2021-05-13 05:57:32 +0000 stress2: Added two new syzkaller reproducers. Update the exclude list --- tools/test/stress2/misc/all.exclude | 2 - tools/test/stress2/misc/syzkaller37.sh | 99 ++++++++++++++++++++++++++++++++++ tools/test/stress2/misc/syzkaller38.sh | 63 ++++++++++++++++++++++ 3 files changed, 162 insertions(+), 2 deletions(-) diff --git a/tools/test/stress2/misc/all.exclude b/tools/test/stress2/misc/all.exclude index e388fa8957d9..9f856c1b9d2f 100644 --- a/tools/test/stress2/misc/all.exclude +++ b/tools/test/stress2/misc/all.exclude @@ -70,8 +70,6 @@ syzkaller30.sh May change policy for random threads to to domainset_fixed 20210 syzkaller31.sh panic: Bad tailq NEXT(0xfffffe0079608f00->tqh_last) != NULL 20210322 syzkaller32.sh Fatal trap 18: integer divide fault while in kernel mode 20210322 syzkaller33.sh Fatal trap 18: integer divide fault while in kernel mode 20210418 -syzkaller35.sh panic: AEAD without a separate IV 20210508 -syzkaller36.sh panic: IV outside buffer length 20210508 truss3.sh WiP 20200915 unionfs.sh insmntque: non-locked vp: xx is not exclusive locked... 20130909 unionfs2.sh insmntque: mp-safe fs and non-locked vp is not ... 20111219 diff --git a/tools/test/stress2/misc/syzkaller37.sh b/tools/test/stress2/misc/syzkaller37.sh new file mode 100755 index 000000000000..cda44530af85 --- /dev/null +++ b/tools/test/stress2/misc/syzkaller37.sh @@ -0,0 +1,99 @@ +#!/bin/sh + +# panic: crp_iv_start set when IV isn't used +# cpuid = 15 +# time = 1620460567 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe023ceef5d0 +# vpanic() at vpanic+0x181/frame 0xfffffe023ceef620 +# panic() at panic+0x43/frame 0xfffffe023ceef680 +# crp_sanity() at crp_sanity+0x236/frame 0xfffffe023ceef6b0 +# crypto_dispatch() at crypto_dispatch+0xf/frame 0xfffffe023ceef6d0 +# crypto_ioctl() at crypto_ioctl+0x1e33/frame 0xfffffe023ceef7e0 +# devfs_ioctl() at devfs_ioctl+0xcd/frame 0xfffffe023ceef830 +# VOP_IOCTL_APV() at VOP_IOCTL_APV+0x59/frame 0xfffffe023ceef850 +# vn_ioctl() at vn_ioctl+0x133/frame 0xfffffe023ceef960 +# devfs_ioctl_f() at devfs_ioctl_f+0x1e/frame 0xfffffe023ceef980 +# kern_ioctl() at kern_ioctl+0x289/frame 0xfffffe023ceef9f0 +# sys_ioctl() at sys_ioctl+0x12a/frame 0xfffffe023ceefac0 +# amd64_syscall() at amd64_syscall+0x147/frame 0xfffffe023ceefbf0 +# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe023ceefbf0 +# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x8003827da, rsp = 0x7fffffffe4e8, rbp = 0x7fffffffe540 --- +# KDB: enter: panic +# [ thread pid 18612 tid 109119 ] +# Stopped at kdb_enter+0x37: movq $0,0x1281a2e(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n246560-2018d488628: Sat May 8 08:32:52 CEST 2021 +# pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO +# db> + +[ `uname -p` != "amd64" ] && exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +cat > /tmp/syzkaller37.c < +#include +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t r[1] = {0xffffffffffffffff}; + +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + intptr_t res = 0; + memcpy((void*)0x20000340, "/dev/crypto\000", 12); + res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000340ul, 0ul, 0ul); + if (res != -1) + r[0] = res; + *(uint32_t*)0x20000040 = 0x10; + *(uint32_t*)0x20000044 = 0x1d; + *(uint32_t*)0x20000048 = 1; + *(uint64_t*)0x20000050 = 0x20000080; + memset((void*)0x20000080, 66, 1); + *(uint32_t*)0x20000058 = 0; + *(uint64_t*)0x20000060 = 0; + *(uint32_t*)0x20000068 = 0; + *(uint32_t*)0x2000006c = 0xfdffffff; + *(uint32_t*)0x20000070 = 0; + *(uint32_t*)0x20000074 = 0; + *(uint32_t*)0x20000078 = 0; + *(uint32_t*)0x2000007c = 0; + syscall(SYS_ioctl, r[0], 0xc040636aul, 0x20000040ul); + *(uint32_t*)0x20000000 = 0; + *(uint16_t*)0x20000004 = 2; + *(uint16_t*)0x20000006 = 0; + *(uint32_t*)0x20000008 = 0; + *(uint32_t*)0x2000000c = 0x10001; + *(uint32_t*)0x20000010 = 0; + *(uint64_t*)0x20000018 = 0; + *(uint64_t*)0x20000020 = 0; + *(uint64_t*)0x20000028 = 0x200001c0; + *(uint64_t*)0x20000030 = 0x20000380; + *(uint64_t*)0x20000038 = 0; + syscall(SYS_ioctl, r[0], 0xc040636dul, 0x20000000ul); + return 0; +} +EOF +mycc -o /tmp/syzkaller37 -Wall -Wextra -O0 /tmp/syzkaller37.c || + exit 1 + +kldload cryptodev.ko && loaded=1 +(cd /tmp; timeout 3m ./syzkaller37) +[ $loaded ] && kldunload cryptodev.ko + +rm -rf /tmp/syzkaller37 syzkaller37.c /tmp/syzkaller.* +exit 0 diff --git a/tools/test/stress2/misc/syzkaller38.sh b/tools/test/stress2/misc/syzkaller38.sh new file mode 100755 index 000000000000..2bd42e98a644 --- /dev/null +++ b/tools/test/stress2/misc/syzkaller38.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# panic: Assertion (cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0 failed at ../../../kern/vfs_lookup.c:490 +# cpuid = 22 +# time = 1620845561 +# KDB: stack backtrace: +# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe01499e7690 +# vpanic() at vpanic+0x181/frame 0xfffffe01499e76e0 +# panic() at panic+0x43/frame 0xfffffe01499e7740 +# namei() at namei+0xb4e/frame 0xfffffe01499e77f0 +# vn_open_cred() at vn_open_cred+0x11d/frame 0xfffffe01499e7960 +# kern_openat() at kern_openat+0x28f/frame 0xfffffe01499e7ac0 +# amd64_syscall() at amd64_syscall+0x147/frame 0xfffffe01499e7bf0 +# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe01499e7bf0 +# --- syscall (0, FreeBSD ELF64, nosys), rip = 0x80038254a, rsp = 0x7fffffffe4f8, rbp = 0x7fffffffe540 --- +# KDB: enter: panic +# [ thread pid 2990 tid 100320 ] +# Stopped at kdb_enter+0x37: movq $0,0x12819de(%rip) +# db> x/s version +# version: FreeBSD 14.0-CURRENT #0 main-n246600-e681dd3e2c1-dirty: Wed May 12 07:56:58 CEST 2021 +# pho@t2.osted.lan:/usr/src/sys/amd64/compile/PHO\012 +# db> + +# Fixed by: 6de3cf14c47d - main - vn_open_cred(): disallow O_CREAT | O_EMPTY_PATH + +[ `uname -p` != "amd64" ] && exit 0 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg +cat > /tmp/syzkaller38.c < +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(void) +{ + syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul); + + memset((void*)0x20000180, 0, 1); + syscall(SYS_open, 0x20000180ul, 0x20c0200ul, 0ul); + return 0; +} +EOF +mycc -o /tmp/syzkaller38 -Wall -Wextra -O0 /tmp/syzkaller38.c || + exit 1 + +(cd /tmp; timeout 3m ./syzkaller38) + +rm -rf /tmp/syzkaller38 syzkaller38.c /tmp/syzkaller.* +exit 0 From owner-dev-commits-src-all@freebsd.org Thu May 13 07:56:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FB8E635118; Thu, 13 May 2021 07:56:59 +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 4FgkWv3DF0z4Zwd; Thu, 13 May 2021 07:56:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 61A781AE60; Thu, 13 May 2021 07:56:59 +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 14D7uxVc016011; Thu, 13 May 2021 07:56:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14D7uxP7016010; Thu, 13 May 2021 07:56:59 GMT (envelope-from git) Date: Thu, 13 May 2021 07:56:59 GMT Message-Id: <202105130756.14D7uxP7016010@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 1760799b4c61 - main - Remove references to timed(8) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1760799b4c612b98c0e5c1abeb03814e24c33cf6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 07:56:59 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1760799b4c612b98c0e5c1abeb03814e24c33cf6 commit 1760799b4c612b98c0e5c1abeb03814e24c33cf6 Author: Ceri Davies AuthorDate: 2021-05-13 07:53:08 +0000 Commit: Gordon Bergling CommitDate: 2021-05-13 07:53:08 +0000 Remove references to timed(8) There are still references to timed(8) and timedc(8) in the base system, which were removed in 2018. PR: 255425 Reported by: Ceri Davies Reviewed by: ygy, gbe MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30232 --- lib/libc/rpc/rtime.3 | 4 +--- lib/libc/sys/adjtime.2 | 6 ++---- lib/libc/sys/clock_gettime.2 | 5 ++--- lib/libc/sys/gettimeofday.2 | 5 ++--- libexec/rc/rc.conf | 2 -- share/man/man5/rc.conf.5 | 26 +------------------------- 6 files changed, 8 insertions(+), 40 deletions(-) diff --git a/lib/libc/rpc/rtime.3 b/lib/libc/rpc/rtime.3 index 028d2beade14..e657ca50aa18 100644 --- a/lib/libc/rpc/rtime.3 +++ b/lib/libc/rpc/rtime.3 @@ -1,7 +1,7 @@ .\" @(#)rtime.3n 2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI .\" $FreeBSD$ .\" -.Dd November 22, 1987 +.Dd May 13, 2021 .Dt RTIME 3 .Os .Sh NAME @@ -46,5 +46,3 @@ however, the routine will instead use and block until a reply is received from the time server. .Sh RETURN VALUES .Rv -std rtime -.Sh SEE ALSO -.Xr timed 8 diff --git a/lib/libc/sys/adjtime.2 b/lib/libc/sys/adjtime.2 index 03a93a8ae842..18f6f368d140 100644 --- a/lib/libc/sys/adjtime.2 +++ b/lib/libc/sys/adjtime.2 @@ -28,7 +28,7 @@ .\" @(#)adjtime.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd May 13, 2021 .Dt ADJTIME 2 .Os .Sh NAME @@ -96,9 +96,7 @@ The process's effective user ID is not that of the super-user. .El .Sh SEE ALSO .Xr date 1 , -.Xr gettimeofday 2 , -.Xr timed 8 , -.Xr timedc 8 +.Xr gettimeofday 2 .Rs .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" .%A R. Gusella diff --git a/lib/libc/sys/clock_gettime.2 b/lib/libc/sys/clock_gettime.2 index 6dca19449be9..4552819ea902 100644 --- a/lib/libc/sys/clock_gettime.2 +++ b/lib/libc/sys/clock_gettime.2 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 7, 2019 +.Dd May 13, 2021 .Dt CLOCK_GETTIME 2 .Os .Sh NAME @@ -154,8 +154,7 @@ A user other than the super-user attempted to set the time. .Xr adjtime 2 , .Xr clock_getcpuclockid 3 , .Xr ctime 3 , -.Xr pthread_getcpuclockid 3 , -.Xr timed 8 +.Xr pthread_getcpuclockid 3 .Sh STANDARDS The .Fn clock_gettime , diff --git a/lib/libc/sys/gettimeofday.2 b/lib/libc/sys/gettimeofday.2 index 29f713653063..08e3979149e7 100644 --- a/lib/libc/sys/gettimeofday.2 +++ b/lib/libc/sys/gettimeofday.2 @@ -28,7 +28,7 @@ .\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95 .\" $FreeBSD$ .\" -.Dd October 27, 2018 +.Dd May 13, 2021 .Dt GETTIMEOFDAY 2 .Os .Sh NAME @@ -123,8 +123,7 @@ A user other than the super-user attempted to set the time. .Xr clock_gettime 2 , .Xr ctime 3 , .Xr timeradd 3 , -.Xr clocks 7 , -.Xr timed 8 +.Xr clocks 7 .Sh HISTORY The .Fn gettimeofday diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index d941a20b6e07..041d4b6b5321 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -391,8 +391,6 @@ tlsservd_enable="NO" # Run rpc.tlsservd needed for NFS-over-TLS nfsd tlsservd_flags="" # Flags for rpc.tlsservd ### Network Time Services options: ### -timed_enable="NO" # Run the time daemon (or NO). -timed_flags="" # Flags to timed (if enabled). ntpdate_enable="NO" # Run ntpdate to sync time on boot (or NO). ntpdate_program="/usr/sbin/ntpdate" # path to ntpdate, if you want a different one. ntpdate_flags="-b" # Flags to ntpdate (if enabled). diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 6baf3b22b024..95fa8bce4dc0 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2021 +.Dd May 13, 2021 .Dt RC.CONF 5 .Os .Sh NAME @@ -2574,29 +2574,6 @@ This is mandatory when .Va pppoed_enable is set to .Dq Li YES . -.It Va timed_enable -.Pq Vt bool -If set to -.Dq Li YES , -run the -.Xr timed 8 -service at boot time. -This command is intended for networks of -machines where a consistent -.Dq "network time" -for all hosts must be established. -This is often useful in large NFS -environments where time stamps on files are expected to be consistent -network-wide. -.It Va timed_flags -.Pq Vt str -If -.Va timed_enable -is set to -.Dq Li YES , -these are the flags to pass to the -.Xr timed 8 -service. .It Va ntpdate_enable .Pq Vt bool If set to @@ -4691,7 +4668,6 @@ it will be made permanently active. .Xr sysctl 8 , .Xr syslogd 8 , .Xr sysrc 8 , -.Xr timed 8 , .Xr unbound 8 , .Xr usbconfig 8 , .Xr wlandebug 8 , From owner-dev-commits-src-all@freebsd.org Thu May 13 08:13:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47D836357F7; Thu, 13 May 2021 08:13:36 +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 4Fgkv41WNgz4bll; Thu, 13 May 2021 08:13:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 26FB31B78B; Thu, 13 May 2021 08:13:36 +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 14D8Da0t042388; Thu, 13 May 2021 08:13:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14D8Da83042387; Thu, 13 May 2021 08:13:36 GMT (envelope-from git) Date: Thu, 13 May 2021 08:13:36 GMT Message-Id: <202105130813.14D8Da83042387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 82483ea7adfe - main - find(1): Document the -f option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 82483ea7adfe4213059f6dacf31f3bd1327b2cc0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 08:13:36 -0000 The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=82483ea7adfe4213059f6dacf31f3bd1327b2cc0 commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0 Author: Ceri Davies AuthorDate: 2021-05-13 08:10:22 +0000 Commit: Gordon Bergling CommitDate: 2021-05-13 08:10:22 +0000 find(1): Document the -f option PR: 223127 Reported by: Mathieu Arnold Reviewed by: bcr, gbe MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D30215 --- usr.bin/find/find.1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 0c5c113479a3..8bc9f9d69604 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -31,7 +31,7 @@ .\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd March 13, 2021 +.Dd May 13, 2021 .Dt FIND 1 .Os .Sh NAME @@ -135,6 +135,19 @@ primary specified by Refer to its description under .Sx PRIMARIES for more information. +.It Fl f Ar path +Add +.Ar path +to the list of paths that will be recursed into. +This is useful when +.Ar path +begins with a character that would otherwise be interpreted as an +.Ar expression , +namely +.Dq Li "!" , +.Dq Li "(" +and +.Dq Li - . .It Fl s Cause .Nm From owner-dev-commits-src-all@freebsd.org Thu May 13 09:39:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F4436384D4; Thu, 13 May 2021 09:39:41 +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 4FgmpP3dg0z4g02; Thu, 13 May 2021 09:39:41 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6FAE91C066; Thu, 13 May 2021 09:39:41 +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 14D9dfFD050148; Thu, 13 May 2021 09:39:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14D9dfBC050147; Thu, 13 May 2021 09:39:41 GMT (envelope-from git) Date: Thu, 13 May 2021 09:39:41 GMT Message-Id: <202105130939.14D9dfBC050147@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: cef8a95acbae - main - vfs: fix vnode use count leak in O_EMPTY_PATH support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cef8a95acbae0c3043d95028d8ebb24d959a82a0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 09:39:41 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=cef8a95acbae0c3043d95028d8ebb24d959a82a0 commit cef8a95acbae0c3043d95028d8ebb24d959a82a0 Author: Mateusz Guzik AuthorDate: 2021-05-13 09:23:03 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-13 09:39:27 +0000 vfs: fix vnode use count leak in O_EMPTY_PATH support The vnode returned by namei_setup is already referenced. Reported by: pho --- sys/kern/vfs_lookup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 3050275c1b6f..5336bf87ec68 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -495,8 +495,10 @@ namei_emptypath(struct nameidata *ndp) goto errout; } + /* + * Usecount on dp already provided by namei_setup. + */ ndp->ni_vp = dp; - vref(dp); namei_cleanup_cnp(cnp); pwd_drop(pwd); ndp->ni_resflags |= NIRES_EMPTYPATH; From owner-dev-commits-src-all@freebsd.org Thu May 13 10:15:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05799639ABB; Thu, 13 May 2021 10:15:13 +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 4FgnbN6kMzz4hyj; Thu, 13 May 2021 10:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D9BA01CC55; Thu, 13 May 2021 10:15:12 +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 14DAFCQu002973; Thu, 13 May 2021 10:15:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DAFClb002972; Thu, 13 May 2021 10:15:12 GMT (envelope-from git) Date: Thu, 13 May 2021 10:15:12 GMT Message-Id: <202105131015.14DAFClb002972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 8ea5eeb913b9 - main - mod_cc: cross reference CC modules consistently MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8ea5eeb913b94aa45aa7773d14b31222d509ec34 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 10:15:13 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8ea5eeb913b94aa45aa7773d14b31222d509ec34 commit 8ea5eeb913b94aa45aa7773d14b31222d509ec34 Author: Michael Tuexen AuthorDate: 2021-05-13 08:47:45 +0000 Commit: Michael Tuexen CommitDate: 2021-05-13 09:29:35 +0000 mod_cc: cross reference CC modules consistently Reviewed by: bcr, gbe MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D30240 --- share/man/man4/cc_cdg.4 | 3 ++- share/man/man4/cc_chd.4 | 4 +++- share/man/man4/cc_cubic.4 | 4 +++- share/man/man4/cc_dctcp.4 | 3 ++- share/man/man4/cc_hd.4 | 4 +++- share/man/man4/cc_htcp.4 | 4 +++- share/man/man4/cc_newreno.4 | 4 +++- share/man/man4/cc_vegas.4 | 4 +++- share/man/man9/mod_cc.9 | 3 ++- 9 files changed, 24 insertions(+), 9 deletions(-) diff --git a/share/man/man4/cc_cdg.4 b/share/man/man4/cc_cdg.4 index 38f8ed397def..1b14e094ff84 100644 --- a/share/man/man4/cc_cdg.4 +++ b/share/man/man4/cc_cdg.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 2, 2013 +.Dd May 13, 2021 .Dt CC_CDG 4 .Os .Sh NAME @@ -99,6 +99,7 @@ Default is 0. .Sh SEE ALSO .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , diff --git a/share/man/man4/cc_chd.4 b/share/man/man4/cc_chd.4 index 963d89247fde..32b0444f89d7 100644 --- a/share/man/man4/cc_chd.4 +++ b/share/man/man4/cc_chd.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2011 +.Dd May 13, 2021 .Dt CC_CHD 4 .Os .Sh NAME @@ -86,7 +86,9 @@ is used. Default is 1. .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , diff --git a/share/man/man4/cc_cubic.4 b/share/man/man4/cc_cubic.4 index 75df183fa16f..92ac8971e867 100644 --- a/share/man/man4/cc_cubic.4 +++ b/share/man/man4/cc_cubic.4 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2011 +.Dd May 13, 2021 .Dt CC_CUBIC 4 .Os .Sh NAME @@ -62,7 +62,9 @@ section below. .Sh MIB Variables There are currently no tunable MIB variables. .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , diff --git a/share/man/man4/cc_dctcp.4 b/share/man/man4/cc_dctcp.4 index 5c5be4fed96e..8c23f2eaa134 100644 --- a/share/man/man4/cc_dctcp.4 +++ b/share/man/man4/cc_dctcp.4 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 29, 2019 +.Dd May 13, 2021 .Dt CC_DCTCP 4 .Os .Sh NAME @@ -93,6 +93,7 @@ A flag if the congestion window should be reduced by one half after slow start. Valid settings 0 and 1, default 0. .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , .Xr cc_hd 4 , diff --git a/share/man/man4/cc_hd.4 b/share/man/man4/cc_hd.4 index 497e61616a0a..d56d9b77b4d9 100644 --- a/share/man/man4/cc_hd.4 +++ b/share/man/man4/cc_hd.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2011 +.Dd May 13, 2021 .Dt CC_HD 4 .Os .Sh NAME @@ -69,8 +69,10 @@ Minimum queuing delay threshold (qmin) in ticks. Default is 5. .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , .Xr cc_vegas 4 , diff --git a/share/man/man4/cc_htcp.4 b/share/man/man4/cc_htcp.4 index 0e141bb79a7d..46d94a12114a 100644 --- a/share/man/man4/cc_htcp.4 +++ b/share/man/man4/cc_htcp.4 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2011 +.Dd May 13, 2021 .Dt CC_HTCP 4 .Os .Sh NAME @@ -69,8 +69,10 @@ window increase during congestion avoidance mode invariant with respect to RTT. Default is 0 (disabled). .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_newreno 4 , .Xr cc_vegas 4 , diff --git a/share/man/man4/cc_newreno.4 b/share/man/man4/cc_newreno.4 index 8169c04c3eaa..0ac59beeec48 100644 --- a/share/man/man4/cc_newreno.4 +++ b/share/man/man4/cc_newreno.4 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 6, 2019 +.Dd May 13, 2021 .Dt CC_NEWRENO 4 .Os .Sh NAME @@ -96,8 +96,10 @@ per: cwnd = (cwnd * beta_ecn) / 100. Default is 80. .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_vegas 4 , diff --git a/share/man/man4/cc_vegas.4 b/share/man/man4/cc_vegas.4 index 45b4b6244017..ad043b218a4d 100644 --- a/share/man/man4/cc_vegas.4 +++ b/share/man/man4/cc_vegas.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2011 +.Dd May 13, 2021 .Dt CC_VEGAS 4 .Os .Sh NAME @@ -92,8 +92,10 @@ When setting beta, the value must satisfy: 0 < alpha < beta. Default is 3. .El .Sh SEE ALSO +.Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , diff --git a/share/man/man9/mod_cc.9 b/share/man/man9/mod_cc.9 index 7e9ab2488437..8be6fb2381bd 100644 --- a/share/man/man9/mod_cc.9 +++ b/share/man/man9/mod_cc.9 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 21, 2016 +.Dd May 13, 2021 .Dt MOD_CC 9 .Os .Sh NAME @@ -309,6 +309,7 @@ a large difference between the congestion window and send window. .Xr cc_cdg 4 , .Xr cc_chd 4 , .Xr cc_cubic 4 , +.Xr cc_dctcp 4 , .Xr cc_hd 4 , .Xr cc_htcp 4 , .Xr cc_newreno 4 , From owner-dev-commits-src-all@freebsd.org Thu May 13 11:39:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFA0463B964; Thu, 13 May 2021 11:39:23 +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 4FgqSW4cRzz4ly2; Thu, 13 May 2021 11:39:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 90E771DF24; Thu, 13 May 2021 11:39:23 +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 14DBdNdg008351; Thu, 13 May 2021 11:39:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DBdNVj008350; Thu, 13 May 2021 11:39:23 GMT (envelope-from git) Date: Thu, 13 May 2021 11:39:23 GMT Message-Id: <202105131139.14DBdNVj008350@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 02cffbc2507e - main - tcp: Incorrect KASSERT causes a panic in rack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02cffbc2507e83944b0c29d69d6ddf26c9386d54 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 11:39:23 -0000 The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=02cffbc2507e83944b0c29d69d6ddf26c9386d54 commit 02cffbc2507e83944b0c29d69d6ddf26c9386d54 Author: Randall Stewart AuthorDate: 2021-05-13 11:36:04 +0000 Commit: Randall Stewart CommitDate: 2021-05-13 11:36:04 +0000 tcp: Incorrect KASSERT causes a panic in rack Skyzall found an interesting panic in rack. When a SYN and FIN are both sent together a KASSERT gets tripped where it is validating that a mbuf pointer is in the sendmap. But a SYN and FIN often will not have a mbuf pointer. So the fix is two fold a) make sure that the SYN and FIN split the right way when cloning an RSM SYN on left edge and FIN on right. And also make sure the KASSERT properly accounts for the case that we have a SYN or FIN so we don't panic. Reviewed by: mtuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D30241 --- sys/netinet/tcp_stacks/rack.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 115f5f2ee44b..c4f3be02dd29 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -6054,6 +6054,12 @@ rack_clone_rsm(struct tcp_rack *rack, struct rack_sendmap *nrsm, for (idx = 0; idx < nrsm->r_rtr_cnt; idx++) { nrsm->r_tim_lastsent[idx] = rsm->r_tim_lastsent[idx]; } + /* Now if we have SYN flag we keep it on the left edge */ + if (nrsm->r_flags & RACK_HAS_SYN) + nrsm->r_flags &= ~RACK_HAS_SYN; + /* Now if we have a FIN flag we keep it on the right edge */ + if (nrsm->r_flags & RACK_HAS_FIN) + nrsm->r_flags &= ~RACK_HAS_FIN; /* * Now we need to find nrsm's new location in the mbuf chain * we basically calculate a new offset, which is soff + @@ -6061,9 +6067,11 @@ rack_clone_rsm(struct tcp_rack *rack, struct rack_sendmap *nrsm, * chain to find the righ postion, it may be the same mbuf * or maybe not. */ - KASSERT((rsm->m != NULL), + KASSERT(((rsm->m != NULL) || + (rsm->r_flags & (RACK_HAS_SYN|RACK_HAS_FIN))), ("rsm:%p nrsm:%p rack:%p -- rsm->m is NULL?", rsm, nrsm, rack)); - rack_setup_offset_for_rsm(rsm, nrsm); + if (rsm->m) + rack_setup_offset_for_rsm(rsm, nrsm); } static struct rack_sendmap * From owner-dev-commits-src-all@freebsd.org Thu May 13 12:00:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8211C63C9EC; Thu, 13 May 2021 12:00:27 +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 4Fgqwq3KD7z4nNk; Thu, 13 May 2021 12:00:27 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 651051E3E2; Thu, 13 May 2021 12:00:27 +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 14DC0R04043823; Thu, 13 May 2021 12:00:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DC0R11043822; Thu, 13 May 2021 12:00:27 GMT (envelope-from git) Date: Thu, 13 May 2021 12:00:27 GMT Message-Id: <202105131200.14DC0R11043822@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 7183d96e1ddb - main - Refactor argument processing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7183d96e1ddb71dae59b6272185cfef9a6e1112b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 12:00:27 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=7183d96e1ddb71dae59b6272185cfef9a6e1112b commit 7183d96e1ddb71dae59b6272185cfef9a6e1112b Author: Poul-Henning Kamp AuthorDate: 2021-05-13 09:52:36 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-13 11:58:35 +0000 Refactor argument processing. --- usr.sbin/i2c/i2c.c | 116 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 588aad8592ee..9bfa8c801a3e 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -54,11 +54,8 @@ struct options { const char *width; int count; int verbose; - int addr_set; int binary; - int scan; - int skip; - int reset; + char *skip; int mode; char dir; uint32_t addr; @@ -127,7 +124,7 @@ skip_get_tokens(char *skip_addr, int *sk_addr, int max_index) } static int -scan_bus(const char *dev, int fd, int skip, char *skip_addr) +scan_bus(const char *dev, int fd, char *skip) { struct iiccmd cmd; struct iic_msg rdmsg; @@ -137,11 +134,10 @@ scan_bus(const char *dev, int fd, int skip, char *skip_addr) int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 0; uint8_t rdbyte; - if (skip) { - assert(skip_addr != NULL); - len = strlen(skip_addr); - if (strstr(skip_addr, "..") != NULL) { - addr_range = skip_get_range(skip_addr); + if (skip != NULL) { + len = strlen(skip); + if (strstr(skip, "..") != NULL) { + addr_range = skip_get_range(skip); no_range = 0; } else { tokens = (int *)malloc((len / 2 + 1) * sizeof(int)); @@ -151,7 +147,7 @@ scan_bus(const char *dev, int fd, int skip, char *skip_addr) error = -1; goto out; } - idx = skip_get_tokens(skip_addr, tokens, + idx = skip_get_tokens(skip, tokens, len / 2 + 1); } @@ -173,11 +169,11 @@ start_over: for (i = 1; i < 127; i++) { - if (skip && ( addr_range.start < addr_range.end)) { + if (skip != NULL && ( addr_range.start < addr_range.end)) { if (i >= addr_range.start && i <= addr_range.end) continue; - } else if (skip && no_range) { + } else if (skip != NULL && no_range) { assert (tokens != NULL); for (j = 0; j < idx; j++) { if (tokens[j] == i) { @@ -240,7 +236,7 @@ start_over: error = ioctl(fd, I2CRSTCARD, &cmd); out: - if (skip && no_range) + if (skip != NULL && no_range) free(tokens); else assert(tokens == NULL); @@ -308,7 +304,7 @@ write_offset(int fd, struct options i2c_opt, struct iiccmd *cmd) if (i2c_opt.off_len > 0) { cmd->count = i2c_opt.off_len; - cmd->buf = i2c_opt.off_buf; + cmd->buf = (void*)i2c_opt.off_buf; error = ioctl(fd, I2CWRITE, cmd); if (error == -1) return ("ioctl: error writing offset\n"); @@ -623,39 +619,68 @@ int main(int argc, char** argv) { struct options i2c_opt; - char *skip_addr = NULL; const char *dev, *err_msg; - int fd, error, ch; - - errno = 0; + int fd, error = 0, ch; + const char *optflags = "a:f:d:o:w:c:m:n:sbvrh"; + char do_what = 0; dev = I2C_DEV; /* Default values */ - i2c_opt.addr_set = 0; i2c_opt.off = 0; i2c_opt.verbose = 0; i2c_opt.dir = 'r'; /* direction = read */ i2c_opt.width = "8"; i2c_opt.count = 1; i2c_opt.binary = 0; /* ASCII text output */ - i2c_opt.scan = 0; /* no bus scan */ - i2c_opt.skip = 0; /* scan all addresses */ - i2c_opt.reset = 0; /* no bus reset */ + i2c_opt.skip = NULL; /* scan all addresses */ i2c_opt.mode = I2C_MODE_NOTSET; + /* Find out what we are going to do */ + while ((ch = getopt(argc, argv, "a:f:d:o:w:c:m:n:sbvrh")) != -1) { + switch(ch) { + case 'a': + case 'r': + case 's': + if (do_what) + usage("Only one of [-a|-h|-r|-s]"); + do_what = ch; + break; + case 'h': + usage("Help:"); + break; + default: + break; + } + } + + /* Then handle the legal subset of arguments */ + + switch (do_what) { + case 0: usage("Pick one of [-a|-h|-r|-s]"); break; + case 'a': optflags = "a:f:d:w:o:c:m:bv"; break; + case 'r': optflags = "rf:v"; break; + case 's': optflags = "sf:n:v"; break; + default: assert("Bad do_what"); + } + + optreset = 1; + optind = 1; + + while ((ch = getopt(argc, argv, optflags)) != -1) { switch(ch) { case 'a': i2c_opt.addr = (strtoul(optarg, 0, 16) << 1); if (i2c_opt.addr == 0 && errno == EINVAL) usage("Bad -a argument (hex)"); - i2c_opt.addr_set = 1; break; case 'f': dev = optarg; break; case 'd': + if (strcmp(optarg, "r") && strcmp(optarg, "w")) + usage("Bad -d argument ([r|w])"); i2c_opt.dir = optarg[0]; break; case 'o': @@ -664,7 +689,7 @@ main(int argc, char** argv) usage("Bad -o argument (hex)"); break; case 'w': - i2c_opt.width = optarg; + i2c_opt.width = optarg; // checked later. break; case 'c': i2c_opt.count = (strtoul(optarg, 0, 10)); @@ -684,26 +709,19 @@ main(int argc, char** argv) usage("Bad -m argument ([no|ss|rs|tr])"); break; case 'n': - i2c_opt.skip = 1; - skip_addr = optarg; - break; - case 's': - i2c_opt.scan = 1; + i2c_opt.skip = optarg; break; + case 's': break; case 'b': i2c_opt.binary = 1; break; case 'v': i2c_opt.verbose = 1; break; - case 'r': - i2c_opt.reset = 1; - break; - case 'h': - usage("Help:"); - break; + case 'r': break; default: - usage("Bad argument"); + fprintf(stderr, "Illegal -%c option", ch); + usage(NULL); } } argc -= optind; @@ -726,15 +744,6 @@ main(int argc, char** argv) exit(EX_USAGE); } - /* Basic sanity check of command line arguments */ - if (i2c_opt.scan) { - if (i2c_opt.addr_set) - usage("-s and -a are incompatible"); - } else if (i2c_opt.reset) { - if (i2c_opt.addr_set) - usage("-r and -a are incompatible"); - } - if (i2c_opt.verbose) fprintf(stderr, "dev: %s, addr: 0x%x, r/w: %c, " "offset: 0x%02x, width: %s, count: %d\n", dev, @@ -748,12 +757,19 @@ main(int argc, char** argv) return (EX_NOINPUT); } - if (i2c_opt.scan) - error = scan_bus(dev, fd, i2c_opt.skip, skip_addr); - else if (i2c_opt.reset) + switch (do_what) { + case 's': + error = scan_bus(dev, fd, i2c_opt.skip); + break; + case 'r': error = reset_bus(dev, fd); - else + break; + case 'a': error = access_bus(fd, i2c_opt); + break; + default: + assert("Bad do_what"); + } ch = close(fd); assert(ch == 0); From owner-dev-commits-src-all@freebsd.org Thu May 13 12:00:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5C4763CB50; Thu, 13 May 2021 12:00:28 +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 4Fgqwr4Jnmz4nQx; Thu, 13 May 2021 12:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8539D1E4D6; Thu, 13 May 2021 12:00:28 +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 14DC0Spf043847; Thu, 13 May 2021 12:00:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DC0Sbq043845; Thu, 13 May 2021 12:00:28 GMT (envelope-from git) Date: Thu, 13 May 2021 12:00:28 GMT Message-Id: <202105131200.14DC0Sbq043845@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 63c8d31e4f9b - main - Rewrite and simplify the -n argument processing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 63c8d31e4f9bb4800be3247c9962d48257dedc94 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 12:00:28 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=63c8d31e4f9bb4800be3247c9962d48257dedc94 commit 63c8d31e4f9bb4800be3247c9962d48257dedc94 Author: Poul-Henning Kamp AuthorDate: 2021-05-13 10:55:37 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-13 11:58:35 +0000 Rewrite and simplify the -n argument processing. --- usr.sbin/i2c/i2c.8 | 18 ++-- usr.sbin/i2c/i2c.c | 246 ++++++++++++++++++++++------------------------------- 2 files changed, 107 insertions(+), 157 deletions(-) diff --git a/usr.sbin/i2c/i2c.8 b/usr.sbin/i2c/i2c.8 index 352b13157968..92cc62e983aa 100644 --- a/usr.sbin/i2c/i2c.8 +++ b/usr.sbin/i2c/i2c.8 @@ -96,10 +96,9 @@ mode creates control structures describing the transfer and submits them to the driver as a single complete transaction. This mode works on all types of I2C hardware. .It Fl n Ar skip_addr -skip address - address(es) to be skipped during bus scan. -There are two ways to specify addresses to ignore: by range 'a..b' or -using selected addresses 'a:b:c'. This option is available only when "-s" is -used. +address(es) to be skipped during bus scan. +One or more addresses ([0x]xx) or ranges of addresses +([0x]xx-[0x]xx or [0x]xx..[0x]xx) separated by commas or colons. .It Fl o Ar offset offset within the device for data transfer (hex). The default is zero. @@ -129,15 +128,10 @@ Scan the default bus (/dev/iic0) for devices: .Pp i2c -s .It -Scan the default bus (/dev/iic0) for devices and skip addresses 0x56 and -0x45. +Scan the default bus (/dev/iic0) for devices and skip addresses +0x45 to 0x47 (inclusive) and 0x56. .Pp -i2c -s -n 0x56:0x45 -.It -Scan the default bus (/dev/iic0) for devices and skip address range -0x34 to 0x56. -.Pp -i2c -s -n 0x34..0x56 +i2c -s -n 0x56,45-47 .It Read 8 bytes of data from device at address 0x56 (e.g., an EEPROM): .Pp diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 9bfa8c801a3e..753ddbf712d3 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -55,7 +56,7 @@ struct options { int count; int verbose; int binary; - char *skip; + const char *skip; int mode; char dir; uint32_t addr; @@ -64,11 +65,6 @@ struct options { size_t off_len; }; -struct skip_range { - int start; - int end; -}; - __dead2 static void usage(const char *msg) { @@ -84,169 +80,126 @@ usage(const char *msg) exit(EX_USAGE); } -static struct skip_range -skip_get_range(char *skip_addr) +static void +parse_skip(const char *skip, char blacklist[128]) { - struct skip_range addr_range; - char *token; - - addr_range.start = 0; - addr_range.end = 0; - - token = strsep(&skip_addr, ".."); - if (token) { - addr_range.start = strtoul(token, 0, 16); - token = strsep(&skip_addr, ".."); - if ((token != NULL) && !atoi(token)) { - token = strsep(&skip_addr, ".."); - if (token) - addr_range.end = strtoul(token, 0, 16); + const char *p; + unsigned x, y; + + for (p = skip; *p != '\0';) { + if (*p == '0' && p[1] == 'x') + p += 2; + if (!isxdigit(*p)) + usage("Bad -n argument, expected (first) hex-digit"); + x = digittoint(*p++) << 4; + if (!isxdigit(*p)) + usage("Bad -n argument, expected (second) hex-digit"); + x |= digittoint(*p++); + if (x == 0 || x > 0x7f) + usage("Bad -n argument, (01..7f)"); + if (*p == ':' || *p == ',' || *p == '\0') { + blacklist[x] = 1; + if (*p != '\0') + p++; + continue; } + if (*p == '-') { + p++; + } else if (*p == '.' && p[1] == '.') { + p += 2; + } else { + usage("Bad -n argument, ([:|,|..|-])"); + } + if (*p == '0' && p[1] == 'x') + p += 2; + if (!isxdigit(*p)) + usage("Bad -n argument, expected (first) hex-digit"); + y = digittoint(*p++) << 4; + if (!isxdigit(*p)) + usage("Bad -n argument, expected (second) hex-digit"); + y |= digittoint(*p++); + if (y == 0 || y > 0x7f) + usage("Bad -n argument, (01..7f)"); + if (y < x) + usage("Bad -n argument, (end < start)"); + for (;x <= y; x++) + blacklist[x] = 1; + if (*p == ':' || *p == ',') + p++; } - - return (addr_range); -} - -/* Parse the string to get hex 7 bits addresses */ -static int -skip_get_tokens(char *skip_addr, int *sk_addr, int max_index) -{ - char *token; - int i; - - for (i = 0; i < max_index; i++) { - token = strsep(&skip_addr, ":"); - if (token == NULL) - break; - sk_addr[i] = strtoul(token, 0, 16); - } - return (i); } static int -scan_bus(const char *dev, int fd, char *skip) +scan_bus(const char *dev, int fd, const char *skip) { struct iiccmd cmd; struct iic_msg rdmsg; struct iic_rdwr_data rdwrdata; - struct skip_range addr_range = { 0, 0 }; - int *tokens = NULL, error, i, idx = 0, j; - int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 0; + int error; + unsigned u; + int num_found = 0, use_read_xfer; uint8_t rdbyte; + char blacklist[128]; - if (skip != NULL) { - len = strlen(skip); - if (strstr(skip, "..") != NULL) { - addr_range = skip_get_range(skip); - no_range = 0; - } else { - tokens = (int *)malloc((len / 2 + 1) * sizeof(int)); - if (tokens == NULL) { - fprintf(stderr, "Error allocating tokens " - "buffer\n"); - error = -1; - goto out; - } - idx = skip_get_tokens(skip, tokens, - len / 2 + 1); - } + memset(blacklist, 0, sizeof blacklist); - if (!no_range && (addr_range.start > addr_range.end)) { - fprintf(stderr, "Skip address out of range\n"); - error = -1; - goto out; - } - } + if (skip != NULL) + parse_skip(skip, blacklist); - printf("Scanning I2C devices on %s: ", dev); + printf("Scanning I2C devices on %s:", dev); -start_over: - if (use_read_xfer) { - fprintf(stderr, - "Hardware may not support START/STOP scanning; " - "trying less-reliable read method.\n"); - } - - for (i = 1; i < 127; i++) { - - if (skip != NULL && ( addr_range.start < addr_range.end)) { - if (i >= addr_range.start && i <= addr_range.end) + for (use_read_xfer = 0; use_read_xfer < 2; use_read_xfer++) { + for (u = 1; u < 127; u++) { + if (blacklist[u]) continue; - } else if (skip != NULL && no_range) { - assert (tokens != NULL); - for (j = 0; j < idx; j++) { - if (tokens[j] == i) { - do_skip = 1; - break; - } - } - } - - if (do_skip) { - do_skip = 0; - continue; - } - - cmd.slave = i << 1; - cmd.last = 1; - cmd.count = 0; - error = ioctl(fd, I2CRSTCARD, &cmd); - if (error) { - fprintf(stderr, "Controller reset failed\n"); - goto out; - } - if (use_read_xfer) { - rdmsg.buf = &rdbyte; - rdmsg.len = 1; - rdmsg.flags = IIC_M_RD; - rdmsg.slave = i << 1; - rdwrdata.msgs = &rdmsg; - rdwrdata.nmsgs = 1; - error = ioctl(fd, I2CRDWR, &rdwrdata); - } else { - cmd.slave = i << 1; + cmd.slave = u << 1; cmd.last = 1; - error = ioctl(fd, I2CSTART, &cmd); - if (errno == ENODEV || errno == EOPNOTSUPP) { - /* If START not supported try reading. */ - use_read_xfer = 1; - goto start_over; + cmd.count = 0; + error = ioctl(fd, I2CRSTCARD, &cmd); + if (error) { + fprintf(stderr, "Controller reset failed\n"); + fprintf(stderr, + "Error scanning I2C controller (%s): %s\n", + dev, strerror(errno)); + return (EX_NOINPUT); + } + if (use_read_xfer) { + rdmsg.buf = &rdbyte; + rdmsg.len = 1; + rdmsg.flags = IIC_M_RD; + rdmsg.slave = u << 1; + rdwrdata.msgs = &rdmsg; + rdwrdata.nmsgs = 1; + error = ioctl(fd, I2CRDWR, &rdwrdata); + } else { + cmd.slave = u << 1; + cmd.last = 1; + error = ioctl(fd, I2CSTART, &cmd); + if (errno == ENODEV || errno == EOPNOTSUPP) + break; /* Try reads instead */ + (void)ioctl(fd, I2CSTOP); + } + if (error == 0) { + ++num_found; + printf(" %02x", u); } - (void)ioctl(fd, I2CSTOP); - } - if (error == 0) { - ++num_found; - printf("%02x ", i); } + if (num_found > 0) + break; + fprintf(stderr, + "Hardware may not support START/STOP scanning; " + "trying less-reliable read method.\n"); } - - /* - * If we found nothing, maybe START is not supported and returns a - * generic error code such as EIO or ENXIO, so try again using reads. - */ - if (num_found == 0) { - if (!use_read_xfer) { - use_read_xfer = 1; - goto start_over; - } + if (num_found == 0) printf(""); - } + printf("\n"); error = ioctl(fd, I2CRSTCARD, &cmd); -out: - if (skip != NULL && no_range) - free(tokens); - else - assert(tokens == NULL); - - if (error) { - fprintf(stderr, "Error scanning I2C controller (%s): %s\n", - dev, strerror(errno)); - return (EX_NOINPUT); - } else - return (EX_OK); + if (error) + fprintf(stderr, "Controller reset failed\n"); + return (EX_OK); } static int @@ -671,9 +624,12 @@ main(int argc, char** argv) while ((ch = getopt(argc, argv, optflags)) != -1) { switch(ch) { case 'a': - i2c_opt.addr = (strtoul(optarg, 0, 16) << 1); + i2c_opt.addr = strtoul(optarg, 0, 16); if (i2c_opt.addr == 0 && errno == EINVAL) usage("Bad -a argument (hex)"); + if (i2c_opt.addr == 0 || i2c_opt.addr > 0x7f) + usage("Bad -a argument (01..7f)"); + i2c_opt.addr <<= 1; break; case 'f': dev = optarg; From owner-dev-commits-src-all@freebsd.org Thu May 13 12:00:29 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4F9563CC16; Thu, 13 May 2021 12:00:29 +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 4Fgqws5bL2z4nNs; Thu, 13 May 2021 12:00:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A54591E4D7; Thu, 13 May 2021 12:00:29 +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 14DC0Tid043872; Thu, 13 May 2021 12:00:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DC0TYa043871; Thu, 13 May 2021 12:00:29 GMT (envelope-from git) Date: Thu, 13 May 2021 12:00:29 GMT Message-Id: <202105131200.14DC0TYa043871@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: b23362afa995 - main - Final pass of cleanup: Get rid of gotos and general polish. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b23362afa9956a22225dc4edd5dd4d5883e39de8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 12:00:30 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=b23362afa9956a22225dc4edd5dd4d5883e39de8 commit b23362afa9956a22225dc4edd5dd4d5883e39de8 Author: Poul-Henning Kamp AuthorDate: 2021-05-13 11:58:50 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-13 11:58:50 +0000 Final pass of cleanup: Get rid of gotos and general polish. NB: This changes the outputs, in particular in error conditions, in various subtle ways to be more systematic and usable. --- usr.sbin/i2c/i2c.c | 361 ++++++++++++++++++++++++----------------------------- 1 file changed, 162 insertions(+), 199 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 753ddbf712d3..ef0ca0e8fda5 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); struct options { const char *width; - int count; + unsigned count; int verbose; int binary; const char *skip; @@ -80,6 +80,80 @@ usage(const char *msg) exit(EX_USAGE); } +static int +i2c_do_stop(int fd) +{ + int i; + + i = ioctl(fd, I2CSTOP); + if (i < 0) + fprintf(stderr, "ioctl: error sending stop condition: %s\n", + strerror(errno)); + return (i); +} + +static int +i2c_do_start(int fd, struct iiccmd *cmd) +{ + int i; + + i = ioctl(fd, I2CSTART, cmd); + if (i < 0) + fprintf(stderr, "ioctl: error sending start condition: %s\n", + strerror(errno)); + return (i); +} + +static int +i2c_do_repeatstart(int fd, struct iiccmd *cmd) +{ + int i; + + i = ioctl(fd, I2CRPTSTART, cmd); + if (i < 0) + fprintf(stderr, "ioctl: error sending repeated start: %s\n", + strerror(errno)); + return (i); +} + +static int +i2c_do_write(int fd, struct iiccmd *cmd) +{ + int i; + + i = ioctl(fd, I2CWRITE, cmd); + if (i < 0) + fprintf(stderr, "ioctl: error writing: %s\n", + strerror(errno)); + return (i); +} + +static int +i2c_do_read(int fd, struct iiccmd *cmd) +{ + int i; + + i = ioctl(fd, I2CREAD, cmd); + if (i < 0) + fprintf(stderr, "ioctl: error reading: %s\n", + strerror(errno)); + return (i); +} + +static int +i2c_do_reset(int fd) +{ + struct iiccmd cmd; + int i; + + memset(&cmd, 0, sizeof cmd); + i = ioctl(fd, I2CRSTCARD, &cmd); + if (i < 0) + fprintf(stderr, "ioctl: error resetting controller: %s\n", + strerror(errno)); + return (i); +} + static void parse_skip(const char *skip, char blacklist[128]) { @@ -130,7 +204,7 @@ parse_skip(const char *skip, char blacklist[128]) } static int -scan_bus(const char *dev, int fd, const char *skip) +scan_bus(const char *dev, int fd, const char *skip, int verbose) { struct iiccmd cmd; struct iic_msg rdmsg; @@ -140,14 +214,13 @@ scan_bus(const char *dev, int fd, const char *skip) int num_found = 0, use_read_xfer; uint8_t rdbyte; char blacklist[128]; + const char *sep = ""; memset(blacklist, 0, sizeof blacklist); if (skip != NULL) parse_skip(skip, blacklist); - printf("Scanning I2C devices on %s:", dev); - for (use_read_xfer = 0; use_read_xfer < 2; use_read_xfer++) { for (u = 1; u < 127; u++) { if (blacklist[u]) @@ -156,14 +229,9 @@ scan_bus(const char *dev, int fd, const char *skip) cmd.slave = u << 1; cmd.last = 1; cmd.count = 0; - error = ioctl(fd, I2CRSTCARD, &cmd); - if (error) { - fprintf(stderr, "Controller reset failed\n"); - fprintf(stderr, - "Error scanning I2C controller (%s): %s\n", - dev, strerror(errno)); + if (i2c_do_reset(fd)) return (EX_NOINPUT); - } + if (use_read_xfer) { rdmsg.buf = &rdbyte; rdmsg.len = 1; @@ -173,51 +241,43 @@ scan_bus(const char *dev, int fd, const char *skip) rdwrdata.nmsgs = 1; error = ioctl(fd, I2CRDWR, &rdwrdata); } else { - cmd.slave = u << 1; - cmd.last = 1; error = ioctl(fd, I2CSTART, &cmd); if (errno == ENODEV || errno == EOPNOTSUPP) break; /* Try reads instead */ (void)ioctl(fd, I2CSTOP); } if (error == 0) { - ++num_found; - printf(" %02x", u); + if (!num_found++ && verbose) { + fprintf(stderr, + "Scanning I2C devices on %s:\n", + dev); + } + printf("%s%02x", sep, u); + sep = " "; } } if (num_found > 0) break; - fprintf(stderr, - "Hardware may not support START/STOP scanning; " - "trying less-reliable read method.\n"); + if (verbose && !use_read_xfer) + fprintf(stderr, + "Hardware may not support START/STOP scanning; " + "trying less-reliable read method.\n"); } - if (num_found == 0) - printf(""); + if (num_found == 0 && verbose) + printf(""); printf("\n"); - error = ioctl(fd, I2CRSTCARD, &cmd); - if (error) - fprintf(stderr, "Controller reset failed\n"); - return (EX_OK); + return (i2c_do_reset(fd)); } static int -reset_bus(const char *dev, int fd) +reset_bus(const char *dev, int fd, int verbose) { - struct iiccmd cmd; - int error; - - printf("Resetting I2C controller on %s: ", dev); - error = ioctl(fd, I2CRSTCARD, &cmd); - if (error) { - printf("error: %s\n", strerror(errno)); - return (EX_IOERR); - } else { - printf("OK\n"); - return (EX_OK); - } + if (verbose) + fprintf(stderr, "Resetting I2C controller on %s\n", dev); + return (i2c_do_reset(fd)); } static const char * @@ -250,214 +310,127 @@ encode_offset(const char *width, unsigned address, uint8_t *dst, size_t *len) return ("Invalid offset width, must be: 0|8|16|16LE|16BE\n"); } -static const char * +static int write_offset(int fd, struct options i2c_opt, struct iiccmd *cmd) { - int error; if (i2c_opt.off_len > 0) { cmd->count = i2c_opt.off_len; cmd->buf = (void*)i2c_opt.off_buf; - error = ioctl(fd, I2CWRITE, cmd); - if (error == -1) - return ("ioctl: error writing offset\n"); + return (i2c_do_write(fd, cmd)); } - return (NULL); + return (0); } static int -i2c_write(int fd, struct options i2c_opt, char *i2c_buf) +i2c_write(int fd, struct options i2c_opt, uint8_t *i2c_buf) { struct iiccmd cmd; - int error; - char *buf; - const char *err_msg; + char buf[i2c_opt.off_len + i2c_opt.count]; + memset(&cmd, 0, sizeof(cmd)); cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending start condition"; - goto err1; - } + + if (i2c_do_start(fd, &cmd)) + return (i2c_do_stop(fd) | 1); switch(i2c_opt.mode) { case I2C_MODE_STOP_START: - err_msg = write_offset(fd, i2c_opt, &cmd); - if (err_msg != NULL) - goto err1; - - error = ioctl(fd, I2CSTOP); - if (error == -1) { - err_msg = "ioctl: error sending stop condition"; - goto err2; - } - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending start condition"; - goto err1; - } + if (write_offset(fd, i2c_opt, &cmd)) + return (i2c_do_stop(fd) | 1); + + if (i2c_do_stop(fd)) + return (1); + + if (i2c_do_start(fd, &cmd)) + return (i2c_do_stop(fd) | 1); /* * Write the data */ cmd.count = i2c_opt.count; - cmd.buf = i2c_buf; + cmd.buf = (void*)i2c_buf; cmd.last = 0; - error = ioctl(fd, I2CWRITE, &cmd); - if (error == -1) { - err_msg = "ioctl: error writing"; - goto err1; - } + if (i2c_do_write(fd, &cmd)) + return (i2c_do_stop(fd) | 1); break; case I2C_MODE_REPEATED_START: - err_msg = write_offset(fd, i2c_opt, &cmd); - if (err_msg != NULL) - goto err1; - - cmd.slave = i2c_opt.addr; - error = ioctl(fd, I2CRPTSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending repeated start " - "condition"; - goto err1; - } + if (write_offset(fd, i2c_opt, &cmd)) + return (i2c_do_stop(fd) | 1); + + if (i2c_do_repeatstart(fd, &cmd)) + return (i2c_do_stop(fd) | 1); /* * Write the data */ cmd.count = i2c_opt.count; - cmd.buf = i2c_buf; + cmd.buf = (void*)i2c_buf; cmd.last = 0; - error = ioctl(fd, I2CWRITE, &cmd); - if (error == -1) { - err_msg = "ioctl: error writing"; - goto err1; - } + if (i2c_do_write(fd, &cmd)) + return (i2c_do_stop(fd) | 1); break; case I2C_MODE_NONE: /* fall through */ default: - buf = malloc(i2c_opt.off_len + i2c_opt.count); - if (buf == NULL) { - err_msg = "error: data malloc"; - goto err1; - } memcpy(buf, i2c_opt.off_buf, i2c_opt.off_len); - memcpy(buf + i2c_opt.off_len, i2c_buf, i2c_opt.count); /* * Write offset and data */ cmd.count = i2c_opt.off_len + i2c_opt.count; - cmd.buf = buf; + cmd.buf = (void*)buf; cmd.last = 0; - error = ioctl(fd, I2CWRITE, &cmd); - free(buf); - if (error == -1) { - err_msg = "ioctl: error writing"; - goto err1; - } + if (i2c_do_write(fd, &cmd)) + return (i2c_do_stop(fd) | 1); break; } - error = ioctl(fd, I2CSTOP); - if (error == -1) { - err_msg = "ioctl: error sending stop condition"; - goto err2; - } - - return (0); - -err1: - error = ioctl(fd, I2CSTOP); - if (error == -1) - fprintf(stderr, "error sending stop condition\n"); -err2: - if (err_msg) - fprintf(stderr, "%s\n", err_msg); - return (1); + return (i2c_do_stop(fd)); } static int -i2c_read(int fd, struct options i2c_opt, char *i2c_buf) +i2c_read(int fd, struct options i2c_opt, uint8_t *i2c_buf) { struct iiccmd cmd; - int error; char data = 0; - const char *err_msg; - bzero(&cmd, sizeof(cmd)); + memset(&cmd, 0, sizeof(cmd)); + cmd.slave = i2c_opt.addr; if (i2c_opt.off_len) { - cmd.slave = i2c_opt.addr; cmd.count = 1; cmd.last = 0; cmd.buf = &data; - error = ioctl(fd, I2CSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending start condition"; - goto err1; - } + if (i2c_do_start(fd, &cmd)) + return (i2c_do_stop(fd) | 1); - err_msg = write_offset(fd, i2c_opt, &cmd); - if (err_msg != NULL) - goto err1; + if (write_offset(fd, i2c_opt, &cmd)) + return (i2c_do_stop(fd) | 1); - if (i2c_opt.mode == I2C_MODE_STOP_START) { - error = ioctl(fd, I2CSTOP); - if (error == -1) { - err_msg = "error sending stop condition"; - goto err2; - } - } + if (i2c_opt.mode == I2C_MODE_STOP_START && i2c_do_stop(fd)) + return (1); } cmd.slave = i2c_opt.addr | 1; cmd.count = 1; cmd.last = 0; cmd.buf = &data; if (i2c_opt.mode == I2C_MODE_STOP_START || i2c_opt.off_len == 0) { - error = ioctl(fd, I2CSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending start condition"; - goto err2; - } + if (i2c_do_start(fd, &cmd)) + return (i2c_do_stop(fd) | 1); } else if (i2c_opt.mode == I2C_MODE_REPEATED_START) { - error = ioctl(fd, I2CRPTSTART, &cmd); - if (error == -1) { - err_msg = "ioctl: error sending repeated start " - "condition"; - goto err1; - } + if (i2c_do_repeatstart(fd, &cmd)) + return (i2c_do_stop(fd) | 1); } cmd.count = i2c_opt.count; - cmd.buf = i2c_buf; + cmd.buf = (void*)i2c_buf; cmd.last = 1; - error = ioctl(fd, I2CREAD, &cmd); - if (error == -1) { - err_msg = "ioctl: error while reading"; - goto err1; - } + if (i2c_do_read(fd, &cmd)) + return (i2c_do_stop(fd) | 1); - error = ioctl(fd, I2CSTOP); - if (error == -1) { - err_msg = "error sending stop condtion\n"; - goto err2; - } - - return (0); - -err1: - error = ioctl(fd, I2CSTOP); - if (error == -1) - fprintf(stderr, "error sending stop condition\n"); -err2: - if (err_msg) - fprintf(stderr, "%s\n", err_msg); - - return (1); + return (i2c_do_stop(fd)); } /* @@ -472,7 +445,7 @@ err2: * driver to be handled as a single transfer. */ static int -i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) +i2c_rdwr_transfer(int fd, struct options i2c_opt, uint8_t *i2c_buf) { struct iic_msg msgs[2], *msgp = msgs; struct iic_rdwr_data xfer; @@ -515,28 +488,19 @@ i2c_rdwr_transfer(int fd, struct options i2c_opt, char *i2c_buf) static int access_bus(int fd, struct options i2c_opt) { - char *i2c_buf; - int error, chunk_size = 16, i, ch; - - i2c_buf = malloc(i2c_opt.count); - if (i2c_buf == NULL) - err(1, "data malloc"); + uint8_t i2c_buf[i2c_opt.count]; + int error; + unsigned u, chunk_size = 16; /* * For a write, read the data to be written to the chip from stdin. */ if (i2c_opt.dir == 'w') { if (i2c_opt.verbose && !i2c_opt.binary) - fprintf(stderr, "Enter %d bytes of data: ", + fprintf(stderr, "Enter %u bytes of data: ", i2c_opt.count); - for (i = 0; i < i2c_opt.count; i++) { - ch = getchar(); - if (ch == EOF) { - free(i2c_buf); - err(1, "not enough data, exiting\n"); - } - i2c_buf[i] = ch; - } + if (fread(i2c_buf, 1, i2c_opt.count, stdin) != i2c_opt.count) + err(1, "not enough data, exiting\n"); } if (i2c_opt.mode == I2C_MODE_TRANSFER) @@ -554,17 +518,16 @@ access_bus(int fd, struct options i2c_opt) fprintf(stderr, "\nData %s (hex):\n", i2c_opt.dir == 'r' ? "read" : "written"); - for (i = 0; i < i2c_opt.count; i++) { - fprintf (stderr, "%02hhx ", i2c_buf[i]); - if ((i % chunk_size) == chunk_size - 1) - fprintf(stderr, "\n"); + for (u = 0; u < i2c_opt.count; u++) { + printf("%02hhx ", i2c_buf[u]); + if ((u % chunk_size) == chunk_size - 1) + printf("\n"); } - if ((i % chunk_size) != 0) - fprintf(stderr, "\n"); + if ((u % chunk_size) != 0) + printf("\n"); } } - free(i2c_buf); return (error); } @@ -702,7 +665,7 @@ main(int argc, char** argv) if (i2c_opt.verbose) fprintf(stderr, "dev: %s, addr: 0x%x, r/w: %c, " - "offset: 0x%02x, width: %s, count: %d\n", dev, + "offset: 0x%02x, width: %s, count: %u\n", dev, i2c_opt.addr >> 1, i2c_opt.dir, i2c_opt.off, i2c_opt.width, i2c_opt.count); @@ -715,10 +678,10 @@ main(int argc, char** argv) switch (do_what) { case 's': - error = scan_bus(dev, fd, i2c_opt.skip); + error = scan_bus(dev, fd, i2c_opt.skip, i2c_opt.verbose); break; case 'r': - error = reset_bus(dev, fd); + error = reset_bus(dev, fd, i2c_opt.verbose); break; case 'a': error = access_bus(fd, i2c_opt); From owner-dev-commits-src-all@freebsd.org Thu May 13 12:34:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE6F063EB6C; Thu, 13 May 2021 12:34:31 +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 4Fgrh746Sfz4qwM; Thu, 13 May 2021 12:34:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 800E91ED22; Thu, 13 May 2021 12:34:31 +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 14DCYVVG087936; Thu, 13 May 2021 12:34:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DCYVVG087935; Thu, 13 May 2021 12:34:31 GMT (envelope-from git) Date: Thu, 13 May 2021 12:34:31 GMT Message-Id: <202105131234.14DCYVVG087935@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 9246b3090cbc - main - fork: Suspend other threads if both RFPROC and RFMEM are not set MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9246b3090cbc82c54350391601b9acef2aa9a625 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 12:34:31 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9246b3090cbc82c54350391601b9acef2aa9a625 commit 9246b3090cbc82c54350391601b9acef2aa9a625 Author: Mark Johnston AuthorDate: 2021-05-13 12:33:23 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 12:33:23 +0000 fork: Suspend other threads if both RFPROC and RFMEM are not set Otherwise, a multithreaded parent process may trigger races in vm_forkproc() if one thread calls rfork() with RFMEM set and another calls rfork() without RFMEM. Also simplify vm_forkproc() a bit, vmspace_unshare() already checks to see if the address space is shared. Reported by: syzbot+0aa7c2bec74c4066c36f@syzkaller.appspotmail.com Reported by: syzbot+ea84cb06937afeae609d@syzkaller.appspotmail.com Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30220 --- sys/kern/kern_fork.c | 13 +++++++++---- sys/vm/vm_glue.c | 8 +++----- sys/vm/vm_map.c | 4 ++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 2a092b192878..0d0659b432fe 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -313,8 +313,13 @@ fork_norfproc(struct thread *td, int flags) ("fork_norfproc called with RFPROC set")); p1 = td->td_proc; - if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) && - (flags & (RFCFDG | RFFDG))) { + /* + * Quiesce other threads if necessary. If RFMEM is not specified we + * must ensure that other threads do not concurrently create a second + * process sharing the vmspace, see vmspace_unshare(). + */ + if ((p1->p_flag & (P_HADTHREADS | P_SYSTEM)) == P_HADTHREADS && + ((flags & (RFCFDG | RFFDG)) != 0 || (flags & RFMEM) == 0)) { PROC_LOCK(p1); if (thread_single(p1, SINGLE_BOUNDARY)) { PROC_UNLOCK(p1); @@ -350,8 +355,8 @@ fork_norfproc(struct thread *td, int flags) } fail: - if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) && - (flags & (RFCFDG | RFFDG))) { + if ((p1->p_flag & (P_HADTHREADS | P_SYSTEM)) == P_HADTHREADS && + ((flags & (RFCFDG | RFFDG)) != 0 || (flags & RFMEM) == 0)) { PROC_LOCK(p1); thread_single_end(p1, SINGLE_BOUNDARY); PROC_UNLOCK(p1); diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 6facf744456c..7cfb08246f9e 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -553,11 +553,9 @@ vm_forkproc(struct thread *td, struct proc *p2, struct thread *td2, * COW locally. */ if ((flags & RFMEM) == 0) { - if (refcount_load(&p1->p_vmspace->vm_refcnt) > 1) { - error = vmspace_unshare(p1); - if (error) - return (error); - } + error = vmspace_unshare(p1); + if (error) + return (error); } cpu_fork(td, p2, td2, flags); return (0); diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index d870fe3507fd..1ac4ccf72f11 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -4867,6 +4867,10 @@ vmspace_unshare(struct proc *p) struct vmspace *newvmspace; vm_ooffset_t fork_charge; + /* + * The caller is responsible for ensuring that the reference count + * cannot concurrently transition 1 -> 2. + */ if (refcount_load(&oldvmspace->vm_refcnt) == 1) return (0); fork_charge = 0; From owner-dev-commits-src-all@freebsd.org Thu May 13 12:34:32 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5D4963EE30; Thu, 13 May 2021 12:34:32 +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 4Fgrh86095z4rCZ; Thu, 13 May 2021 12:34:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 ABF0B1ECB5; Thu, 13 May 2021 12:34:32 +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 14DCYWgM087958; Thu, 13 May 2021 12:34:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DCYWxu087957; Thu, 13 May 2021 12:34:32 GMT (envelope-from git) Date: Thu, 13 May 2021 12:34:32 GMT Message-Id: <202105131234.14DCYWxu087957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 8b3c4231abf0 - main - posix timers: Check for overflow when converting to ns MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8b3c4231abf0ef6ac79655e463d0ef98ad84cd51 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 12:34:33 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8b3c4231abf0ef6ac79655e463d0ef98ad84cd51 commit 8b3c4231abf0ef6ac79655e463d0ef98ad84cd51 Author: Mark Johnston AuthorDate: 2021-05-13 12:33:37 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 12:34:03 +0000 posix timers: Check for overflow when converting to ns Disallow a time or timer period value when the conversion to nanoseconds would overflow. Otherwise it is possible to trigger a divison by zero in realtime_expire_l(), where we compute the number of overruns by dividing by the timer interval. Fixes: 7995dae9 ("posix timers: Improve the overrun calculation") Reported by: syzbot+5ab360bd3d3e3c5a6e0e@syzkaller.appspotmail.com Reported by: syzbot+157b74ff493140d86eac@syzkaller.appspotmail.com Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30233 --- sys/kern/kern_time.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index ab22ac4a1697..323ef9a1f7a0 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$"); #define MAKE_PROCESS_CPUCLOCK(pid) \ (CPUCLOCK_BIT|CPUCLOCK_PROCESS_BIT|(pid)) +#define NS_PER_SEC 1000000000 + static struct kclock posix_clocks[MAX_CLOCKS]; static uma_zone_t itimer_zone = NULL; @@ -408,8 +410,7 @@ kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats) return (error); if (clock_id != CLOCK_REALTIME) return (EINVAL); - if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000 || - ats->tv_sec < 0) + if (ats->tv_nsec < 0 || ats->tv_nsec >= NS_PER_SEC || ats->tv_sec < 0) return (EINVAL); if (!allow_insane_settime && (ats->tv_sec > 8000ULL * 365 * 24 * 60 * 60 || @@ -462,12 +463,12 @@ kern_clock_getres(struct thread *td, clockid_t clock_id, struct timespec *ts) * Rounding up is especially important if rounding down * would give 0. Perfect rounding is unimportant. */ - ts->tv_nsec = 1000000000 / tc_getfrequency() + 1; + ts->tv_nsec = NS_PER_SEC / tc_getfrequency() + 1; break; case CLOCK_VIRTUAL: case CLOCK_PROF: /* Accurately round up here because we can do so cheaply. */ - ts->tv_nsec = howmany(1000000000, hz); + ts->tv_nsec = howmany(NS_PER_SEC, hz); break; case CLOCK_SECOND: ts->tv_sec = 1; @@ -509,7 +510,7 @@ kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags, int error; bool is_abs_real; - if (rqt->tv_nsec < 0 || rqt->tv_nsec >= 1000000000) + if (rqt->tv_nsec < 0 || rqt->tv_nsec >= NS_PER_SEC) return (EINVAL); if ((flags & ~TIMER_ABSTIME) != 0) return (EINVAL); @@ -1650,7 +1651,9 @@ static int itimespecfix(struct timespec *ts) { - if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000) + if (ts->tv_sec < 0 || ts->tv_nsec < 0 || ts->tv_nsec >= NS_PER_SEC) + return (EINVAL); + if ((UINT64_MAX - ts->tv_nsec) / NS_PER_SEC < ts->tv_sec) return (EINVAL); if (ts->tv_sec == 0 && ts->tv_nsec != 0 && ts->tv_nsec < tick * 1000) ts->tv_nsec = tick * 1000; @@ -1658,10 +1661,10 @@ itimespecfix(struct timespec *ts) } #define timespectons(tsp) \ - ((uint64_t)(tsp)->tv_sec * 1000000000 + (tsp)->tv_nsec) + ((uint64_t)(tsp)->tv_sec * NS_PER_SEC + (tsp)->tv_nsec) #define timespecfromns(ns) (struct timespec){ \ - .tv_sec = (ns) / 1000000000, \ - .tv_nsec = (ns) % 1000000000 \ + .tv_sec = (ns) / NS_PER_SEC, \ + .tv_nsec = (ns) % NS_PER_SEC \ } static void From owner-dev-commits-src-all@freebsd.org Thu May 13 13:35:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C0721641126; Thu, 13 May 2021 13:35:17 +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 4Fgt2F55hxz4v2C; Thu, 13 May 2021 13:35:17 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A19FA1FBAF; Thu, 13 May 2021 13:35:17 +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 14DDZHuS067348; Thu, 13 May 2021 13:35:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DDZHu2067347; Thu, 13 May 2021 13:35:17 GMT (envelope-from git) Date: Thu, 13 May 2021 13:35:17 GMT Message-Id: <202105131335.14DDZHu2067347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fa43162c6379 - main - sort: Stop "fixing" obsolete key syntax after -- flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fa43162c63790806d0effba5ac98a1a3c6b835e1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 13:35:17 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fa43162c63790806d0effba5ac98a1a3c6b835e1 commit fa43162c63790806d0effba5ac98a1a3c6b835e1 Author: Cyril Zhang AuthorDate: 2021-05-13 12:52:51 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 13:33:19 +0000 sort: Stop "fixing" obsolete key syntax after -- flag PR: 255798 Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30234 --- usr.bin/sort/sort.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index fee6f72449e2..d5c18552d914 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -858,6 +858,11 @@ fix_obsolete_keys(int *argc, char **argv) arg1 = argv[i]; + if (strcmp(arg1, "--") == 0) { + /* Following arguments are treated as filenames. */ + break; + } + if (strlen(arg1) > 1 && arg1[0] == '+') { int c1, f1; char sopts1[128]; From owner-dev-commits-src-all@freebsd.org Thu May 13 13:35:18 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1A6464118C; Thu, 13 May 2021 13:35:18 +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 4Fgt2G6MWXz4v88; Thu, 13 May 2021 13:35:18 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C7A921FBB0; Thu, 13 May 2021 13:35:18 +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 14DDZINZ067369; Thu, 13 May 2021 13:35:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DDZIu1067368; Thu, 13 May 2021 13:35:18 GMT (envelope-from git) Date: Thu, 13 May 2021 13:35:18 GMT Message-Id: <202105131335.14DDZIu1067368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 71ec05a21257 - main - sort: Cache value of MB_CUR_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71ec05a21257e159f40d54e26ad0011bb19b5134 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 13:35:19 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71ec05a21257e159f40d54e26ad0011bb19b5134 commit 71ec05a21257e159f40d54e26ad0011bb19b5134 Author: Cyril Zhang AuthorDate: 2021-05-13 12:55:06 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 13:33:19 +0000 sort: Cache value of MB_CUR_MAX Every usage of MB_CUR_MAX results in a call to __mb_cur_max. This is inefficient and redundant. Caching the value of MB_CUR_MAX in a global variable removes these calls and speeds up the runtime of sort. For numeric sorting, runtime is almost halved in some tests. PR: 255551 PR: 255840 Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30170 --- usr.bin/sort/bwstring.c | 54 ++++++++++++++++++++++++------------------------ usr.bin/sort/bwstring.h | 9 ++++---- usr.bin/sort/radixsort.c | 4 ++-- usr.bin/sort/sort.c | 6 +++++- usr.bin/sort/sort.h | 6 ++++++ 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c index cab21324c4b3..f6200c53c83e 100644 --- a/usr.bin/sort/bwstring.c +++ b/usr.bin/sort/bwstring.c @@ -59,7 +59,7 @@ initialise_months(void) char *tmp; size_t len; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { if (cmonths == NULL) { char *m; @@ -143,7 +143,7 @@ void bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix) { - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) fprintf(f, "%s%s%s", prefix, bws->data.cstr, suffix); else fprintf(f, "%s%S%s", prefix, bws->data.wstr, suffix); @@ -158,14 +158,14 @@ const void* bwsrawdata(const struct bwstring *bws) size_t bwsrawlen(const struct bwstring *bws) { - return ((MB_CUR_MAX == 1) ? bws->len : SIZEOF_WCHAR_STRING(bws->len)); + return ((mb_cur_max == 1) ? bws->len : SIZEOF_WCHAR_STRING(bws->len)); } size_t bws_memsize(const struct bwstring *bws) { - return ((MB_CUR_MAX == 1) ? (bws->len + 2 + sizeof(struct bwstring)) : + return ((mb_cur_max == 1) ? (bws->len + 2 + sizeof(struct bwstring)) : (SIZEOF_WCHAR_STRING(bws->len + 1) + sizeof(struct bwstring))); } @@ -175,7 +175,7 @@ bws_setlen(struct bwstring *bws, size_t newlen) if (bws && newlen != bws->len && newlen <= bws->len) { bws->len = newlen; - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) bws->data.cstr[newlen] = '\0'; else bws->data.wstr[newlen] = L'\0'; @@ -190,14 +190,14 @@ bwsalloc(size_t sz) { struct bwstring *ret; - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) ret = sort_malloc(sizeof(struct bwstring) + 1 + sz); else ret = sort_malloc(sizeof(struct bwstring) + SIZEOF_WCHAR_STRING(sz + 1)); ret->len = sz; - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) ret->data.cstr[ret->len] = '\0'; else ret->data.wstr[ret->len] = L'\0'; @@ -218,7 +218,7 @@ bwsdup(const struct bwstring *s) else { struct bwstring *ret = bwsalloc(s->len); - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) memcpy(ret->data.cstr, s->data.cstr, (s->len)); else memcpy(ret->data.wstr, s->data.wstr, @@ -242,7 +242,7 @@ bwssbdup(const wchar_t *str, size_t len) ret = bwsalloc(len); - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) for (size_t i = 0; i < len; ++i) ret->data.cstr[i] = (unsigned char) str[i]; else @@ -263,7 +263,7 @@ bwscsbdup(const unsigned char *str, size_t len) ret = bwsalloc(len); if (str) { - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) memcpy(ret->data.cstr, str, len); else { mbstate_t mbs; @@ -277,7 +277,7 @@ bwscsbdup(const unsigned char *str, size_t len) memset(&mbs, 0, sizeof(mbs)); while (cptr < len) { - size_t n = MB_CUR_MAX; + size_t n = mb_cur_max; if (n > len - cptr) n = len - cptr; @@ -334,7 +334,7 @@ bwscpy(struct bwstring *dst, const struct bwstring *src) nums = dst->len; dst->len = nums; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { memcpy(dst->data.cstr, src->data.cstr, nums); dst->data.cstr[dst->len] = '\0'; } else { @@ -363,7 +363,7 @@ bwsncpy(struct bwstring *dst, const struct bwstring *src, size_t size) nums = size; dst->len = nums; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { memcpy(dst->data.cstr, src->data.cstr, nums); dst->data.cstr[dst->len] = '\0'; } else { @@ -398,7 +398,7 @@ bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset, if (nums > size) nums = size; dst->len = nums; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { memcpy(dst->data.cstr, src->data.cstr + offset, (nums)); dst->data.cstr[dst->len] = '\0'; @@ -420,7 +420,7 @@ size_t bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended) { - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { size_t len = bws->len; if (!zero_ended) { @@ -478,7 +478,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb) eols = zero_ended ? btowc('\0') : btowc('\n'); - if (!zero_ended && (MB_CUR_MAX > 1)) { + if (!zero_ended && (mb_cur_max > 1)) { wchar_t *ret; ret = fgetwln(f, len); @@ -494,7 +494,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb) } return (bwssbdup(ret, *len)); - } else if (!zero_ended && (MB_CUR_MAX == 1)) { + } else if (!zero_ended && (mb_cur_max == 1)) { char *ret; ret = fgetln(f, len); @@ -523,7 +523,7 @@ bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb) } rb->fgetwln_z_buffer[*len] = 0; - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) while (!feof(f)) { int c; @@ -603,7 +603,7 @@ bwsncmp(const struct bwstring *bws1, const struct bwstring *bws2, if (len < cmp_len) cmp_len = len; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { const unsigned char *s1, *s2; s1 = bws1->data.cstr + offset; @@ -696,7 +696,7 @@ bwscoll(const struct bwstring *bws1, const struct bwstring *bws2, size_t offset) len1 -= offset; len2 -= offset; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { const unsigned char *s1, *s2; s1 = bws1->data.cstr + offset; @@ -852,7 +852,7 @@ bwstod(struct bwstring *s0, bool *empty) { double ret = 0; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { unsigned char *end, *s; char *ep; @@ -909,7 +909,7 @@ int bws_month_score(const struct bwstring *s0) { - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { const unsigned char *end, *s; s = s0->data.cstr; @@ -949,7 +949,7 @@ struct bwstring * ignore_leading_blanks(struct bwstring *str) { - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { unsigned char *dst, *end, *src; src = str->data.cstr; @@ -1005,7 +1005,7 @@ ignore_nonprinting(struct bwstring *str) { size_t newlen = str->len; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { unsigned char *dst, *end, *src; unsigned char c; @@ -1058,7 +1058,7 @@ dictionary_order(struct bwstring *str) { size_t newlen = str->len; - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { unsigned char *dst, *end, *src; unsigned char c; @@ -1109,7 +1109,7 @@ struct bwstring * ignore_case(struct bwstring *str) { - if (MB_CUR_MAX == 1) { + if (mb_cur_max == 1) { unsigned char *end, *s; s = str->data.cstr; @@ -1137,7 +1137,7 @@ void bws_disorder_warnx(struct bwstring *s, const char *fn, size_t pos) { - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) warnx("%s:%zu: disorder: %s", fn, pos + 1, s->data.cstr); else warnx("%s:%zu: disorder: %ls", fn, pos + 1, s->data.wstr); diff --git a/usr.bin/sort/bwstring.h b/usr.bin/sort/bwstring.h index 9d62eaf37f62..b63bb97ab93f 100644 --- a/usr.bin/sort/bwstring.h +++ b/usr.bin/sort/bwstring.h @@ -38,6 +38,7 @@ #include #include +#include "sort.h" #include "mem.h" extern bool byte_sort; @@ -109,7 +110,7 @@ static inline bwstring_iterator bws_end(struct bwstring *bws) { - return ((MB_CUR_MAX == 1) ? + return ((mb_cur_max == 1) ? (bwstring_iterator) (bws->data.cstr + bws->len) : (bwstring_iterator) (bws->data.wstr + bws->len)); } @@ -118,7 +119,7 @@ static inline bwstring_iterator bws_iterator_inc(bwstring_iterator iter, size_t pos) { - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) return ((unsigned char *) iter) + pos; else return ((wchar_t*) iter) + pos; @@ -128,7 +129,7 @@ static inline wchar_t bws_get_iter_value(bwstring_iterator iter) { - if (MB_CUR_MAX == 1) + if (mb_cur_max == 1) return *((unsigned char *) iter); else return *((wchar_t*) iter); @@ -137,7 +138,7 @@ bws_get_iter_value(bwstring_iterator iter) int bws_iterator_cmp(bwstring_iterator iter1, bwstring_iterator iter2, size_t len); -#define BWS_GET(bws, pos) ((MB_CUR_MAX == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) +#define BWS_GET(bws, pos) ((mb_cur_max == 1) ? ((bws)->data.cstr[(pos)]) : (bws)->data.wstr[(pos)]) void initialise_months(void); diff --git a/usr.bin/sort/radixsort.c b/usr.bin/sort/radixsort.c index 4993566aeb77..4c448fad69e9 100644 --- a/usr.bin/sort/radixsort.c +++ b/usr.bin/sort/radixsort.c @@ -258,7 +258,7 @@ add_leaf(struct sort_level *sl, struct sort_list_item *item) static inline int get_wc_index(struct sort_list_item *sli, size_t level) { - const size_t wcfact = (MB_CUR_MAX == 1) ? 1 : sizeof(wchar_t); + const size_t wcfact = (mb_cur_max == 1) ? 1 : sizeof(wchar_t); const struct key_value *kv; const struct bwstring *bws; @@ -331,7 +331,7 @@ free_sort_level(struct sort_level *sl) static void run_sort_level_next(struct sort_level *sl) { - const size_t wcfact = (MB_CUR_MAX == 1) ? 1 : sizeof(wchar_t); + const size_t wcfact = (mb_cur_max == 1) ? 1 : sizeof(wchar_t); struct sort_level *slc; size_t i, sln, tosort_num; diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index d5c18552d914..0fbbd9284aad 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -99,6 +99,8 @@ struct sort_opts sort_opts_vals; bool debug_sort; bool need_hint; +size_t mb_cur_max; + #if defined(SORT_THREADS) unsigned int ncpu = 1; size_t nthreads = 1; @@ -305,7 +307,7 @@ conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def) if (wc && c) { int res; - res = mbtowc(wc, c, MB_CUR_MAX); + res = mbtowc(wc, c, mb_cur_max); if (res < 1) *wc = def; } @@ -322,6 +324,8 @@ set_locale(void) setlocale(LC_ALL, ""); + mb_cur_max = MB_CUR_MAX; + lc = localeconv(); if (lc) { diff --git a/usr.bin/sort/sort.h b/usr.bin/sort/sort.h index b472fd16c098..96b36a65f4e4 100644 --- a/usr.bin/sort/sort.h +++ b/usr.bin/sort/sort.h @@ -127,4 +127,10 @@ extern struct sort_opts sort_opts_vals; extern struct sort_mods * const default_sort_mods; +/* + * Cached value of MB_CUR_MAX. Because MB_CUR_MAX is used often throughout the program, + * this avoids frequent calls to __mb_cur_max. + */ +extern size_t mb_cur_max; + #endif /* __BSD_SORT_H__ */ From owner-dev-commits-src-all@freebsd.org Thu May 13 13:35:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 494A7640CE1; Thu, 13 May 2021 13:35:20 +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 4Fgt2J0ZfCz4v9g; Thu, 13 May 2021 13:35:20 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E7D7F1FC07; Thu, 13 May 2021 13:35:19 +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 14DDZJ7S067390; Thu, 13 May 2021 13:35:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DDZJcY067389; Thu, 13 May 2021 13:35:19 GMT (envelope-from git) Date: Thu, 13 May 2021 13:35:19 GMT Message-Id: <202105131335.14DDZJcY067389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: f9e565abca9b - main - sort: Make NetBSD sort tests compatible with our sort MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f9e565abca9b5880fe3203ba67c90eaf3e906e95 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 13:35:20 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f9e565abca9b5880fe3203ba67c90eaf3e906e95 commit f9e565abca9b5880fe3203ba67c90eaf3e906e95 Author: Cyril Zhang AuthorDate: 2021-05-13 12:50:23 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 13:33:47 +0000 sort: Make NetBSD sort tests compatible with our sort This diff primarily adds/removes flags to make the tests compatible with sort. Two tests are removed. One test is changed to expect fail due to a bug. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30217 --- contrib/netbsd-tests/usr.bin/sort/t_sort.sh | 57 ++++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/contrib/netbsd-tests/usr.bin/sort/t_sort.sh b/contrib/netbsd-tests/usr.bin/sort/t_sort.sh index a36457cb41ec..431d23b69f96 100755 --- a/contrib/netbsd-tests/usr.bin/sort/t_sort.sh +++ b/contrib/netbsd-tests/usr.bin/sort/t_sort.sh @@ -25,6 +25,13 @@ # POSSIBILITY OF SUCH DAMAGE. # +# The -S flag in NetBSD sort enables non-stable sorting order. This flag +# doesn't exist in FreeBSD sort, and instead indicates buffer size, so all +# instances of this flag should be removed. +# +# For tests that expect exact output, but where some lines may compare +# the same, the flag -s should be added to enforce an expected sorting order. + atf_test_case basic basic_head() { @@ -57,9 +64,9 @@ empty_file_head() empty_file_body() { touch empty - atf_check -o empty sort -S empty - atf_check sort -S -c empty - atf_check sort -S -c -u empty + atf_check -o empty sort empty + atf_check sort -c empty + atf_check sort -c -u empty } atf_test_case end_of_options @@ -70,8 +77,8 @@ end_of_options_head() end_of_options_body() { echo x >-k - atf_check -o file:-k -x "sort -S -- -k in - atf_check -o inline:'\0a\n\0b\n' sort -S in + atf_check -o inline:'\0a\n\0b\n' sort in } atf_test_case long_records @@ -126,7 +133,7 @@ long_file_head() long_file_body() { awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in - sort -S -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out + sort -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out atf_check -o file:out sort -u -r in } @@ -155,6 +162,7 @@ bflag_head() } bflag_body() { + atf_expect_fail "Behavior differs from NetBSD" cat >in <xx" + atf_check -x "sort -k2b -k2 in >xx" atf_check -e ignore sort -c -t: -k2n xx - atf_check -x "sort -S -k2,2.1b -k2 in >xx" + atf_check -x "sort -k2,2.1b -k2 in >xx" atf_check -e ignore sort -c -t: -k3n xx - atf_check -x "sort -S -k2.3 -k2 in >xx" + atf_check -x "sort -k2.3 -k2 in >xx" atf_check -e ignore sort -c -t: -k4n xx - atf_check -x "sort -S -k2b,2.3 -k2 in >xx" + atf_check -x "sort -k2b,2.3 -k2 in >xx" atf_check -e ignore sort -c -t: -k5n xx - atf_check -x "sort -S -k2.3,2.1b -k2 in >xx" + atf_check -x "sort -k2.3,2.1b -k2 in >xx" atf_check -e ignore sort -c -t: -k6n xx - atf_check -x "sort -S -k2,2.1b -k2r in >xx" + atf_check -x "sort -k2,2.1b -k2r in >xx" atf_check -e ignore sort -c -t: -k7n xx - atf_check -x "sort -S -b -k2,2 -k2 in >xx" + atf_check -x "sort -b -k2,2 -k2 in >xx" atf_check -e ignore sort -c -t: -k8n xx # XXX This test is broken. The standard is not clear on the behavior. @@ -442,7 +452,7 @@ c ca EOF - atf_check -o file:out sort -S -m in1 in2 + atf_check -o file:out sort -m in1 in2 } atf_test_case mflag_uflag @@ -585,7 +595,7 @@ oflag_displaced_head() } oflag_displaced_body() { - atf_check sort -S /dev/null -o out + atf_check sort /dev/null -o out test -f out || atf_fail "File not created" } @@ -757,7 +767,7 @@ EOF b c EOF - atf_check -o file:out sort -S -k2 in + atf_check -o file:out sort -k2 in cat >out <./+0 echo 'more contents' >in cat ./+0 in >expout @@ -926,6 +937,8 @@ plus_rflag_invalid_head() } plus_rflag_invalid_body() { + atf_expect_fail "-R flag not available on FreeBSD" + ( echo 'z b m f' echo 'y c o e' From owner-dev-commits-src-all@freebsd.org Thu May 13 13:35:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F77B640CE3; Thu, 13 May 2021 13:35:21 +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 4Fgt2K28F8z4v0f; Thu, 13 May 2021 13:35:21 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 186E01F8CE; Thu, 13 May 2021 13: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 14DDZKeN067411; Thu, 13 May 2021 13:35:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DDZKkn067410; Thu, 13 May 2021 13:35:20 GMT (envelope-from git) Date: Thu, 13 May 2021 13:35:20 GMT Message-Id: <202105131335.14DDZKkn067410@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 186ba88a7c1f - main - sort: Hook NetBSD tests up to the build MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 186ba88a7c1f2bea14eb3fb092671e8367f7187f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 13:35:21 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=186ba88a7c1f2bea14eb3fb092671e8367f7187f commit 186ba88a7c1f2bea14eb3fb092671e8367f7187f Author: Mark Johnston AuthorDate: 2021-05-13 12:57:26 +0000 Commit: Mark Johnston CommitDate: 2021-05-13 13:34:01 +0000 sort: Hook NetBSD tests up to the build MFC after: 1 week Sponsored by: The FreeBSD Foundation --- etc/mtree/BSD.tests.dist | 2 ++ usr.bin/sort/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 51cc6f8a2871..1dc756aecbc5 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -1056,6 +1056,8 @@ .. soelim .. + sort + .. stat .. tail diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile index 41feec2bdee0..d38e036b90c0 100644 --- a/usr.bin/sort/Makefile +++ b/usr.bin/sort/Makefile @@ -32,7 +32,7 @@ CFLAGS+= -DWITHOUT_NLS MAN_SUB+= -e 's|%%NLS%%|\.\\"|g' .endif -#HAS_TESTS= -#SUBDIR.${MK_TESTS}+= tests +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests .include From owner-dev-commits-src-all@freebsd.org Thu May 13 14:31:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CCD71643BCD; Thu, 13 May 2021 14:31:23 +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 4FgvGz5VrCz3FXf; Thu, 13 May 2021 14:31:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AFE212034F; Thu, 13 May 2021 14:31:23 +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 14DEVNtn043469; Thu, 13 May 2021 14:31:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DEVNvZ043468; Thu, 13 May 2021 14:31:23 GMT (envelope-from git) Date: Thu, 13 May 2021 14:31:23 GMT Message-Id: <202105131431.14DEVNvZ043468@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?RmVybmFuZG8gQXBlc3RlZ3XDrWE=?= Subject: git: 94eb6c42ab4a - main - syslog.3 - Add detail about LOG_PID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 94eb6c42ab4a2e2581e7cde6d8bd7e81c87a4442 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 14:31:23 -0000 The branch main has been updated by fernape (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=94eb6c42ab4a2e2581e7cde6d8bd7e81c87a4442 commit 94eb6c42ab4a2e2581e7cde6d8bd7e81c87a4442 Author: Fernando Apesteguía AuthorDate: 2021-05-10 15:20:06 +0000 Commit: Fernando Apesteguía CommitDate: 2021-05-13 14:23:44 +0000 syslog.3 - Add detail about LOG_PID Document that LOG_PID is ignored and can not be disabled. This change was made along with the move from RFC 3164 to RFC 5424 log messages. PR: 255664 Reported by: des.gaufres@gmail.com Reviewed by: gbe, jilles Approved by: gbe (mentor, manpages), jilles --- lib/libc/gen/syslog.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/syslog.3 b/lib/libc/gen/syslog.3 index 2cb2c0d198b3..ce7dfdccf55e 100644 --- a/lib/libc/gen/syslog.3 +++ b/lib/libc/gen/syslog.3 @@ -28,7 +28,7 @@ .\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 25, 2018 +.Dd May 13, 2021 .Dt SYSLOG 3 .Os .Sh NAME @@ -159,7 +159,7 @@ Log the process id with each message: useful for identifying instantiations of daemons. On .Fx , -this option is enabled by default. +this option is enabled by default and cannot be disabled. .El .Pp The From owner-dev-commits-src-all@freebsd.org Thu May 13 15:02:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EAAF5644DDE; Thu, 13 May 2021 15:02:57 +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 4FgvzP6Kvtz3Hcc; Thu, 13 May 2021 15:02:57 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CC31C20EA1; Thu, 13 May 2021 15:02:57 +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 14DF2vHs087224; Thu, 13 May 2021 15:02:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DF2vbc087223; Thu, 13 May 2021 15:02:57 GMT (envelope-from git) Date: Thu, 13 May 2021 15:02:57 GMT Message-Id: <202105131502.14DF2vbc087223@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: e256adf0e0d7 - stable/12 - release.sh: pass UNAME_r for embedded builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e256adf0e0d7b56f525b40b954d5ab5dae36b13a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:02:58 -0000 The branch stable/12 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=e256adf0e0d7b56f525b40b954d5ab5dae36b13a commit e256adf0e0d7b56f525b40b954d5ab5dae36b13a Author: Glen Barber AuthorDate: 2021-05-13 15:02:16 +0000 Commit: Glen Barber CommitDate: 2021-05-13 15:02:16 +0000 release.sh: pass UNAME_r for embedded builds This is a direct commit to stable/12 due to a merge conflict mistake. Sponsored by: Rubicon Communications, LLC ("Netgate") --- release/release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/release/release.sh b/release/release.sh index 7326157a8562..86e3592d068b 100755 --- a/release/release.sh +++ b/release/release.sh @@ -300,6 +300,7 @@ extra_chroot_setup() { _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U) REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION) BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH) + UNAME_r=${REVISION}-${BRANCH} PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes" PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}" PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}" From owner-dev-commits-src-all@freebsd.org Thu May 13 15:27:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CF72645783; Thu, 13 May 2021 15:27:55 +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 4FgwXC0nldz3KLj; Thu, 13 May 2021 15:27:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 09D3D21423; Thu, 13 May 2021 15:27:55 +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 14DFRsWC013666; Thu, 13 May 2021 15:27:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DFRs7U013665; Thu, 13 May 2021 15:27:54 GMT (envelope-from git) Date: Thu, 13 May 2021 15:27:54 GMT Message-Id: <202105131527.14DFRs7U013665@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: f6e0c471691e - main - netgraph/ng_bridge: move MACs via control message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f6e0c471691e0005e450ec968a9fa3b5346a3c45 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:27:55 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=f6e0c471691e0005e450ec968a9fa3b5346a3c45 commit f6e0c471691e0005e450ec968a9fa3b5346a3c45 Author: Lutz Donnerhacke AuthorDate: 2021-02-09 13:28:48 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-13 15:27:01 +0000 netgraph/ng_bridge: move MACs via control message Use the new control message to move ethernet addresses from a link to a new link in ng_bridge(4). Send this message instead of doing the work directly requires to move the loop detection into the control message processing. This will delay the loop detection by a few frames. This decouples the read-only activity from the modification under a more strict writer lock. Reviewed by: manpages (gbe) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28559 --- share/man/man4/ng_bridge.4 | 13 ++++-- sys/netgraph/ng_bridge.c | 112 ++++++++++++++++++++------------------------- 2 files changed, 59 insertions(+), 66 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index 216dea3c392a..f83bacecce40 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 17, 2021 +.Dd May 13, 2021 .Dt NG_BRIDGE 4 .Os .Sh NAME @@ -221,12 +221,19 @@ as an argument. It assigns the MAC .Va addr to the -.Va hook , -which must not be assigned yet. +.Va hook . If the .Va hook is the empty string, the incoming hook of the control message is used as fallback. +.Pp +If necessary, the MAC is removed from the currently assigned hook and +moved to the new one. +If the MAC is moved faster than +.Va minStableAge , +the hook is considered as a loop and will block traffic for +.Va loopTimeout +seconds. .Bd -literal -offset 0n struct ng_bridge_move_host { u_char addr[ETHER_ADDR_LEN]; /* ethernet address */ diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 915a18550cba..ecb00f9ba29f 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -103,7 +103,7 @@ struct ng_bridge_link_kernel_stats { counter_u64_t xmitMulticasts; /* multicast pkts xmit'd on link */ counter_u64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */ counter_u64_t loopDrops; /* pkts dropped due to loopback */ - counter_u64_t loopDetects; /* number of loop detections */ + u_int64_t loopDetects; /* number of loop detections */ counter_u64_t memoryFailures; /* times couldn't get mem or mbuf */ }; @@ -420,7 +420,6 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) link->stats.xmitMulticasts = counter_u64_alloc(M_WAITOK); link->stats.xmitBroadcasts = counter_u64_alloc(M_WAITOK); link->stats.loopDrops = counter_u64_alloc(M_WAITOK); - link->stats.loopDetects = counter_u64_alloc(M_WAITOK); link->stats.memoryFailures = counter_u64_alloc(M_WAITOK); link->hook = hook; @@ -456,7 +455,7 @@ static void ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats * p) counter_u64_zero(p->xmitMulticasts); counter_u64_zero(p->xmitBroadcasts); counter_u64_zero(p->loopDrops); - counter_u64_zero(p->loopDetects); + p->loopDetects = 0; counter_u64_zero(p->memoryFailures); }; @@ -573,7 +572,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) FETCH(xmitMulticasts); FETCH(xmitBroadcasts); FETCH(loopDrops); - FETCH(loopDetects); + rs->loopDetects = link->stats.loopDetects; FETCH(memoryFailures); #undef FETCH } @@ -619,7 +618,6 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) { struct ng_bridge_move_host *mh; hook_p hook; - struct ng_bridge_host *host; if (msg->header.arglen < sizeof(*mh)) { error = EINVAL; @@ -633,11 +631,6 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) error = ENOENT; break; } - host = ng_bridge_get(priv, mh->addr); - if (host != NULL) { - error = EADDRINUSE; - break; - } error = ng_bridge_put(priv, mh->addr, NG_HOOK_PRIVATE(hook)); break; } @@ -784,7 +777,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) counter_u64_add(ctx.incoming->stats.loopDrops, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); - return (ELOOP); /* XXX is this an appropriate error? */ + return (ELOOP); } /* Update stats */ @@ -799,56 +792,15 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } /* Look up packet's source Ethernet address in hashtable */ - if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) { + if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) /* Update time since last heard from this host. * This is safe without locking, because it's * the only operation during shared access. */ host->staleness = 0; - /* Did host jump to a different link? */ - if (host->link != ctx.incoming) { - /* - * If the host's old link was recently established - * on the old link and it's already jumped to a new - * link, declare a loopback condition. - */ - if (host->age < priv->conf.minStableAge) { - /* Log the problem */ - if (priv->conf.debugLevel >= 2) { - struct ifnet *ifp = ctx.m->m_pkthdr.rcvif; - char suffix[32]; - - if (ifp != NULL) - snprintf(suffix, sizeof(suffix), - " (%s)", ifp->if_xname); - else - *suffix = '\0'; - log(LOG_WARNING, "ng_bridge: %s:" - " loopback detected on %s%s\n", - ng_bridge_nodename(node), - NG_HOOK_NAME(hook), suffix); - } - - /* Mark link as linka non grata */ - ctx.incoming->loopCount = priv->conf.loopTimeout; - counter_u64_add(ctx.incoming->stats.loopDetects, 1); - - /* Forget all hosts on this link */ - ng_bridge_remove_hosts(priv, ctx.incoming); - - /* Drop packet */ - counter_u64_add(ctx.incoming->stats.loopDrops, 1); - NG_FREE_ITEM(item); - NG_FREE_M(ctx.m); - return (ELOOP); /* XXX appropriate? */ - } - - /* Move host over to new link */ - host->link = ctx.incoming; - host->age = 0; - } - } else if (ctx.incoming->learnMac) { + if ((host == NULL && ctx.incoming->learnMac) || + (host != NULL && host->link != ctx.incoming)) { struct ng_mesg *msg; struct ng_bridge_move_host *mh; int error = 0; @@ -871,6 +823,16 @@ ng_bridge_rcvdata(hook_p hook, item_p item) counter_u64_add(ctx.incoming->stats.memoryFailures, 1); } + if (host != NULL && host->link != ctx.incoming) { + if (host->age < priv->conf.minStableAge) { + /* Drop packet on instable links */ + counter_u64_add(ctx.incoming->stats.loopDrops, 1); + NG_FREE_ITEM(item); + NG_FREE_M(ctx.m); + return (ELOOP); + } + } + /* Run packet through ipfw processing, if enabled */ #if 0 if (priv->conf.ipfw[linkNum] && V_fw_enable && V_ip_fw_chk_ptr != NULL) { @@ -970,7 +932,6 @@ ng_bridge_disconnect(hook_p hook) counter_u64_free(link->stats.xmitMulticasts); counter_u64_free(link->stats.xmitBroadcasts); counter_u64_free(link->stats.loopDrops); - counter_u64_free(link->stats.loopDetects); counter_u64_free(link->stats.memoryFailures); free(link, M_NETGRAPH_BRIDGE); priv->numLinks--; @@ -1012,8 +973,8 @@ ng_bridge_get(priv_cp priv, const u_char *addr) } /* - * Add a new host entry to the table. This assumes the host doesn't - * already exist in the table. Returns 0 on success. + * Add a host entry to the table. If it already exists, move it + * to the new link. Returns 0 on success. */ static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link) @@ -1021,11 +982,36 @@ ng_bridge_put(priv_p priv, const u_char *addr, link_p link) const int bucket = HASH(addr, priv->hashMask); struct ng_bridge_host *host; -#ifdef INVARIANTS - /* Assert that entry does not already exist in hashtable */ - KASSERT(ng_bridge_get(priv, addr) == NULL, - ("%s: entry %6D exists in table", __func__, addr, ":")); -#endif + if ((host = ng_bridge_get(priv, addr)) != NULL) { + /* Host already on the correct link? */ + if (host->link == link) + return 0; + + /* Move old host over to new link */ + if (host->age >= priv->conf.minStableAge) { + host->link = link; + host->age = 0; + return (0); + } + /* + * If the host was recently moved to the old link and + * it's now jumping to a new link, declare a loopback + * condition. + */ + if (priv->conf.debugLevel >= 2) + log(LOG_WARNING, "ng_bridge: %s:" + " loopback detected on %s\n", + ng_bridge_nodename(priv->node), + NG_HOOK_NAME(link->hook)); + + /* Mark link as linka non grata */ + link->loopCount = priv->conf.loopTimeout; + link->stats.loopDetects++; + + /* Forget all hosts on this link */ + ng_bridge_remove_hosts(priv, link); + return (ELOOP); + } /* Allocate and initialize new hashtable entry */ host = malloc(sizeof(*host), M_NETGRAPH_BRIDGE, M_NOWAIT); From owner-dev-commits-src-all@freebsd.org Thu May 13 15:46:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2493F646116; Thu, 13 May 2021 15:46:43 +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 4Fgwxv0cqgz3LnS; Thu, 13 May 2021 15:46:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 08A4F212ED; Thu, 13 May 2021 15:46:43 +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 14DFkgCZ040551; Thu, 13 May 2021 15:46:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DFkgDV040549; Thu, 13 May 2021 15:46:42 GMT (envelope-from git) Date: Thu, 13 May 2021 15:46:42 GMT Message-Id: <202105131546.14DFkgDV040549@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 6dbde50a7e48 - main - pkgbase: Move librt to clibs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6dbde50a7e48d4779dc7a7b0bc63f922aa5bcbf5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:46:43 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=6dbde50a7e48d4779dc7a7b0bc63f922aa5bcbf5 commit 6dbde50a7e48d4779dc7a7b0bc63f922aa5bcbf5 Author: Emmanuel Vadot AuthorDate: 2021-05-03 08:12:26 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 15:41:24 +0000 pkgbase: Move librt to clibs librt implement the POSIX realtime extension library. Move it to clibs instead of utilities as a number of ports uses it so avoid a dependancy on FreeBSD-utilities. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30088 --- lib/librt/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librt/Makefile b/lib/librt/Makefile index 6a751b7a3aa3..00ae29bab26b 100644 --- a/lib/librt/Makefile +++ b/lib/librt/Makefile @@ -2,6 +2,7 @@ .include +PACKAGE=clibs LIB=rt SHLIB_MAJOR= 1 CFLAGS+=-I${SRCTOP}/lib/libc/include -I${.CURDIR} From owner-dev-commits-src-all@freebsd.org Thu May 13 15:46:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8406F645DBE; Thu, 13 May 2021 15:46:44 +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 4Fgwxw1bLqz3LnT; Thu, 13 May 2021 15:46:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 27FFB216D5; Thu, 13 May 2021 15:46:44 +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 14DFkiQ4040578; Thu, 13 May 2021 15:46:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DFkixT040577; Thu, 13 May 2021 15:46:44 GMT (envelope-from git) Date: Thu, 13 May 2021 15:46:44 GMT Message-Id: <202105131546.14DFkixT040577@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: ca179c4d74f2 - main - pkgbase: Put openssl in its own package MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ca179c4d74f2ce1e458bae1826bd77d17f28aab2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:46:44 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=ca179c4d74f2ce1e458bae1826bd77d17f28aab2 commit ca179c4d74f2ce1e458bae1826bd77d17f28aab2 Author: Emmanuel Vadot AuthorDate: 2021-05-02 15:46:17 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 15:42:29 +0000 pkgbase: Put openssl in its own package This is useful for upgrade and also to make tiny jail so they won't depend on FreeBSD-utilities (where openssl was packaged before). MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30081 --- release/packages/Makefile.package | 2 ++ secure/lib/libcrypto/Makefile | 2 +- secure/lib/libssl/Makefile | 1 + secure/usr.bin/openssl/Makefile | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/release/packages/Makefile.package b/release/packages/Makefile.package index 125732267008..dd7ce63d78a1 100644 --- a/release/packages/Makefile.package +++ b/release/packages/Makefile.package @@ -57,6 +57,8 @@ kernel_COMMENT= FreeBSD Kernel kernel_DESC= FreeBSD Kernel manuals_COMMENT= Manual Pages manuals_DESC= Manual Pages +openssl_COMMENT= OpenSSL Library and Utility +openssl_DESC= OpenSSL Library and Utility rc_COMMENT= RC Scripts rc_DESC= RC Scripts rcmds_COMMENT= Remote Command Utilities diff --git a/secure/lib/libcrypto/Makefile b/secure/lib/libcrypto/Makefile index b82b5c8d84b1..ff9303c9edae 100644 --- a/secure/lib/libcrypto/Makefile +++ b/secure/lib/libcrypto/Makefile @@ -6,7 +6,7 @@ SUBDIR= engines .include .include -PACKAGE= runtime +PACKAGE= openssl LIB= crypto SHLIB_MAJOR= 111 VERSION_MAP= ${.CURDIR}/Version.map diff --git a/secure/lib/libssl/Makefile b/secure/lib/libssl/Makefile index 74856aaa3b1f..893ea6ebed79 100644 --- a/secure/lib/libssl/Makefile +++ b/secure/lib/libssl/Makefile @@ -5,6 +5,7 @@ LIB= ssl SHLIB_MAJOR= 111 VERSION_MAP= ${.CURDIR}/Version.map +PACKAGE= openssl NO_LINT= diff --git a/secure/usr.bin/openssl/Makefile b/secure/usr.bin/openssl/Makefile index e71be39bae56..5f3bf395a149 100644 --- a/secure/usr.bin/openssl/Makefile +++ b/secure/usr.bin/openssl/Makefile @@ -3,6 +3,7 @@ CONFS= openssl.cnf CONFSDIR= /etc/ssl PROG= openssl +PACKAGE= openssl LIBADD= ssl crypto From owner-dev-commits-src-all@freebsd.org Thu May 13 15:46:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3C27645D60; Thu, 13 May 2021 15:46:45 +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 4Fgwxx3cGvz3LWP; Thu, 13 May 2021 15:46:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4A6872193B; Thu, 13 May 2021 15:46:45 +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 14DFkj5a040599; Thu, 13 May 2021 15:46:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DFkjWT040598; Thu, 13 May 2021 15:46:45 GMT (envelope-from git) Date: Thu, 13 May 2021 15:46:45 GMT Message-Id: <202105131546.14DFkjWT040598@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 1c2ab28f598a - main - UPDATING: Add a note for pkgbase user for commit ca179c4d74f2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1c2ab28f598a9598b3c50d9001c70ff51f88e445 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:46:45 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=1c2ab28f598a9598b3c50d9001c70ff51f88e445 commit 1c2ab28f598a9598b3c50d9001c70ff51f88e445 Author: Emmanuel Vadot AuthorDate: 2021-05-13 15:46:08 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 15:46:08 +0000 UPDATING: Add a note for pkgbase user for commit ca179c4d74f2 --- UPDATING | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UPDATING b/UPDATING index 2059bbddbdc0..36f9f1aea126 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 14.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20210513: + Commit ca179c4d74f2 changed the package in which the OpenSSL + libraries and utilities are packaged. + It is recommanded for pkgbase user to do : + pkg install -f FreeBSD-openssl + before pkg upgrade otherwise some dependencies might not be met + and pkg will stop working as libssl will not be present anymore + on the system. + 20210426: Commit 875977314881 changed the internal KAPI between the nfsd and nfscommon modules. As such these modules From owner-dev-commits-src-all@freebsd.org Thu May 13 15:54:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E43C64637F; Thu, 13 May 2021 15:54:07 +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 4Fgx6R2jfVz3MTL; Thu, 13 May 2021 15:54:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4FF3F217B4; Thu, 13 May 2021 15:54:07 +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 14DFs76P053531; Thu, 13 May 2021 15:54:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DFs79n053530; Thu, 13 May 2021 15:54:07 GMT (envelope-from git) Date: Thu, 13 May 2021 15:54:07 GMT Message-Id: <202105131554.14DFs79n053530@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 9674c2e68c61 - main - netgraph/ng_bridge: become SMP aware MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9674c2e68c613757ddf5a8780743842b5ac4d74f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 15:54:07 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=9674c2e68c613757ddf5a8780743842b5ac4d74f commit 9674c2e68c613757ddf5a8780743842b5ac4d74f Author: Lutz Donnerhacke AuthorDate: 2021-01-12 21:28:29 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-13 15:53:07 +0000 netgraph/ng_bridge: become SMP aware The node ng_bridge underwent a lot of changes in the last few months. All those steps were necessary to distinguish between structure modifying and read-only data transport paths. Now it's done, the node can perform frame forwarding on multiple cores in parallel. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28123 --- sys/netgraph/ng_bridge.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index ecb00f9ba29f..470c0f05f18d 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -351,15 +351,6 @@ ng_bridge_constructor(node_p node) priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE; priv->sendUnknown = 1; /* classic bridge */ - /* - * This node has all kinds of stuff that could be screwed by SMP. - * Until it gets it's own internal protection, we go through in - * single file. This could hurt a machine bridging between two - * GB ethernets so it should be fixed. - * When it's fixed the process SHOULD NOT SLEEP, spinlocks please! - * (and atomic ops ) - */ - NG_NODE_FORCE_WRITER(node); NG_NODE_SET_PRIVATE(node, priv); priv->node = node; From owner-dev-commits-src-all@freebsd.org Thu May 13 16:15:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51C8D646DAE; Thu, 13 May 2021 16:15:45 +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 4FgxbP1vQ7z3N6N; Thu, 13 May 2021 16:15:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 341F221DC8; Thu, 13 May 2021 16:15:45 +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 14DGFjDS081475; Thu, 13 May 2021 16:15:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DGFjFr081474; Thu, 13 May 2021 16:15:45 GMT (envelope-from git) Date: Thu, 13 May 2021 16:15:45 GMT Message-Id: <202105131615.14DGFjFr081474@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 9e08f82058cb - main - modules: Add sdhci_fdt module MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e08f82058cb5e3c04cdfe90fc7a0d109c7f2659 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 16:15:45 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=9e08f82058cb5e3c04cdfe90fc7a0d109c7f2659 commit 9e08f82058cb5e3c04cdfe90fc7a0d109c7f2659 Author: Emmanuel Vadot AuthorDate: 2021-04-28 13:57:39 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 16:15:31 +0000 modules: Add sdhci_fdt module This is a module for sdhci on fdt system --- sys/modules/Makefile | 2 ++ sys/modules/sdhci_fdt/Makefile | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 9d5b84ccf58f..6a5097e9ded0 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -331,6 +331,7 @@ SUBDIR= \ ${_sctp} \ sdhci \ ${_sdhci_acpi} \ + ${_sdhci_fdt} \ sdhci_pci \ sdio \ sem \ @@ -490,6 +491,7 @@ SUBDIR+= iscsi_initiator .if !empty(OPT_FDT) SUBDIR+= fdt +_sdhci_fdt= sdhci_fdt .endif # Linuxulator diff --git a/sys/modules/sdhci_fdt/Makefile b/sys/modules/sdhci_fdt/Makefile new file mode 100644 index 000000000000..cc8c8b44f2e6 --- /dev/null +++ b/sys/modules/sdhci_fdt/Makefile @@ -0,0 +1,8 @@ +# + +.PATH: ${SRCTOP}/sys/dev/sdhci + +KMOD= sdhci_fdt +SRCS= sdhci_fdt.c sdhci_fdt_gpio.c sdhci_if.h device_if.h bus_if.h mmcbr_if.h opt_mmccam.h opt_cam.h + +.include From owner-dev-commits-src-all@freebsd.org Thu May 13 16:15:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85968647055; Thu, 13 May 2021 16:15:46 +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 4FgxbQ38Khz3NBN; Thu, 13 May 2021 16:15:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5744721FC4; Thu, 13 May 2021 16:15:46 +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 14DGFkah081497; Thu, 13 May 2021 16:15:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DGFkNv081496; Thu, 13 May 2021 16:15:46 GMT (envelope-from git) Date: Thu, 13 May 2021 16:15:46 GMT Message-Id: <202105131615.14DGFkNv081496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: eb094080855e - main - arm64: rockchip: Add some DTSO to disable sd/mmc MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb094080855e1e8c28a70dbebab3e6ecbf8c1255 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 16:15:46 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=eb094080855e1e8c28a70dbebab3e6ecbf8c1255 commit eb094080855e1e8c28a70dbebab3e6ecbf8c1255 Author: Emmanuel Vadot AuthorDate: 2021-04-21 13:25:29 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 16:15:31 +0000 arm64: rockchip: Add some DTSO to disable sd/mmc This helps during developement to reduce the number of mmc controller. --- sys/dts/arm64/overlays/rk3399-mmc0-disable.dtso | 10 ++++++++++ sys/dts/arm64/overlays/rk3399-mmc1-disable.dtso | 10 ++++++++++ sys/dts/arm64/overlays/rk3399-sdhci-disable.dtso | 10 ++++++++++ sys/modules/dtb/rockchip/Makefile | 5 ++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sys/dts/arm64/overlays/rk3399-mmc0-disable.dtso b/sys/dts/arm64/overlays/rk3399-mmc0-disable.dtso new file mode 100644 index 000000000000..a638ed65c717 --- /dev/null +++ b/sys/dts/arm64/overlays/rk3399-mmc0-disable.dtso @@ -0,0 +1,10 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "rockchip,rk3399"; +}; + +&{/mmc@fe310000} { + status = "disabled"; +}; diff --git a/sys/dts/arm64/overlays/rk3399-mmc1-disable.dtso b/sys/dts/arm64/overlays/rk3399-mmc1-disable.dtso new file mode 100644 index 000000000000..333be61da216 --- /dev/null +++ b/sys/dts/arm64/overlays/rk3399-mmc1-disable.dtso @@ -0,0 +1,10 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "rockchip,rk3399"; +}; + +&{/mmc@fe320000} { + status = "disabled"; +}; diff --git a/sys/dts/arm64/overlays/rk3399-sdhci-disable.dtso b/sys/dts/arm64/overlays/rk3399-sdhci-disable.dtso new file mode 100644 index 000000000000..b386cc12e62a --- /dev/null +++ b/sys/dts/arm64/overlays/rk3399-sdhci-disable.dtso @@ -0,0 +1,10 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "rockchip,rk3399"; +}; + +&{/sdhci@fe330000} { + status = "disabled"; +}; diff --git a/sys/modules/dtb/rockchip/Makefile b/sys/modules/dtb/rockchip/Makefile index 12f59e4ee973..20df656bd148 100644 --- a/sys/modules/dtb/rockchip/Makefile +++ b/sys/modules/dtb/rockchip/Makefile @@ -15,7 +15,10 @@ DTS= \ rockchip/rk3399-firefly.dts \ rockchip/rk3399-rockpro64.dts -DTSO= rk3328-dwc3.dtso +DTSO= rk3328-dwc3.dtso \ + rk3399-mmc0-disable.dtso \ + rk3399-mmc1-disable.dtso \ + rk3399-sdhci-disable.dtso .endif .include From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D24F6286A4; Thu, 13 May 2021 17:14:13 +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 4Fgyts0MQfz3Qsv; Thu, 13 May 2021 17:14:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 F356322C9B; Thu, 13 May 2021 17:14:12 +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 14DHECTC063307; Thu, 13 May 2021 17:14:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHECkS063306; Thu, 13 May 2021 17:14:12 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:12 GMT Message-Id: <202105131714.14DHECkS063306@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 00a3fe968b84 - main - vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 00a3fe968b840ee197c32dfe4107dab730bd9915 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:13 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=00a3fe968b840ee197c32dfe4107dab730bd9915 commit 00a3fe968b840ee197c32dfe4107dab730bd9915 Author: Konstantin Belousov AuthorDate: 2021-05-07 17:46:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:10:35 +0000 vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/vm/default_pager.c | 2 ++ sys/vm/device_pager.c | 3 +++ sys/vm/phys_pager.c | 2 ++ sys/vm/sg_pager.c | 2 ++ sys/vm/swap_pager.c | 3 +++ sys/vm/vm_object.c | 35 ----------------------------------- sys/vm/vm_pager.c | 16 ++++++++++++++++ sys/vm/vm_pager.h | 1 + sys/vm/vnode_pager.c | 2 ++ 9 files changed, 31 insertions(+), 35 deletions(-) diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c index 758012692a48..d07a84f8c98e 100644 --- a/sys/vm/default_pager.c +++ b/sys/vm/default_pager.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -71,6 +72,7 @@ static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *, * object is converted to swap pager type. */ const struct pagerops defaultpagerops = { + .pgo_kvme_type = KVME_TYPE_DEFAULT, .pgo_alloc = default_pager_alloc, .pgo_dealloc = default_pager_dealloc, .pgo_getpages = default_pager_getpages, diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c index 25affb114a47..567f8fe55817 100644 --- a/sys/vm/device_pager.c +++ b/sys/vm/device_pager.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -75,6 +76,7 @@ static struct pagerlst dev_pager_object_list; static struct mtx dev_pager_mtx; const struct pagerops devicepagerops = { + .pgo_kvme_type = KVME_TYPE_DEVICE, .pgo_init = dev_pager_init, .pgo_alloc = dev_pager_alloc, .pgo_dealloc = dev_pager_dealloc, @@ -84,6 +86,7 @@ const struct pagerops devicepagerops = { }; const struct pagerops mgtdevicepagerops = { + .pgo_kvme_type = KVME_TYPE_MGTDEVICE, .pgo_alloc = dev_pager_alloc, .pgo_dealloc = dev_pager_dealloc, .pgo_getpages = dev_pager_getpages, diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c index af7b10701b16..6d7c5a4a7291 100644 --- a/sys/vm/phys_pager.c +++ b/sys/vm/phys_pager.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -299,6 +300,7 @@ phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, } const struct pagerops physpagerops = { + .pgo_kvme_type = KVME_TYPE_PHYS, .pgo_init = phys_pager_init, .pgo_alloc = phys_pager_alloc, .pgo_dealloc = phys_pager_dealloc, diff --git a/sys/vm/sg_pager.c b/sys/vm/sg_pager.c index 9b3e60bc170a..d7af2aed935a 100644 --- a/sys/vm/sg_pager.c +++ b/sys/vm/sg_pager.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -60,6 +61,7 @@ static boolean_t sg_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); const struct pagerops sgpagerops = { + .pgo_kvme_type = KVME_TYPE_SG, .pgo_alloc = sg_pager_alloc, .pgo_dealloc = sg_pager_dealloc, .pgo_getpages = sg_pager_getpages, diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 57c953542a88..37db4cbac857 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -442,6 +443,7 @@ static void swap_pager_freespace(vm_object_t object, vm_pindex_t start, vm_size_t size); const struct pagerops swappagerops = { + .pgo_kvme_type = KVME_TYPE_SWAP, .pgo_init = swap_pager_init, /* early system initialization of pager */ .pgo_alloc = swap_pager_alloc, /* allocate an OBJT_SWAP object */ .pgo_dealloc = swap_pager_dealloc, /* deallocate an OBJT_SWAP object */ @@ -456,6 +458,7 @@ const struct pagerops swappagerops = { }; const struct pagerops swaptmpfspagerops = { + .pgo_kvme_type = KVME_TYPE_VNODE, .pgo_alloc = swap_tmpfs_pager_alloc, .pgo_dealloc = swap_pager_dealloc, .pgo_getpages = swap_pager_getpages, diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 1c4e879d82ea..735ab603a09b 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2469,41 +2469,6 @@ vm_object_busy_wait(vm_object_t obj, const char *wmesg) (void)blockcount_sleep(&obj->busy, NULL, wmesg, PVM); } -/* - * Return the kvme type of the given object. - * If vpp is not NULL, set it to the object's vm_object_vnode() or NULL. - */ -int -vm_object_kvme_type(vm_object_t object, struct vnode **vpp) -{ - - VM_OBJECT_ASSERT_LOCKED(object); - if (vpp != NULL) - *vpp = vm_object_vnode(object); - switch (object->type) { - case OBJT_DEFAULT: - return (KVME_TYPE_DEFAULT); - case OBJT_VNODE: - return (KVME_TYPE_VNODE); - case OBJT_SWAP: - return (KVME_TYPE_SWAP); - case OBJT_SWAP_TMPFS: - return (KVME_TYPE_VNODE); - case OBJT_DEVICE: - return (KVME_TYPE_DEVICE); - case OBJT_PHYS: - return (KVME_TYPE_PHYS); - case OBJT_DEAD: - return (KVME_TYPE_DEAD); - case OBJT_SG: - return (KVME_TYPE_SG); - case OBJT_MGTDEVICE: - return (KVME_TYPE_MGTDEVICE); - default: - return (KVME_TYPE_UNKNOWN); - } -} - static int sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) { diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 240847903f62..9476058a75bf 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -155,6 +156,7 @@ dead_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) } static const struct pagerops deadpagerops = { + .pgo_kvme_type = KVME_TYPE_DEAD, .pgo_alloc = dead_pager_alloc, .pgo_dealloc = dead_pager_dealloc, .pgo_getpages = dead_pager_getpages, @@ -530,3 +532,17 @@ vm_object_mightbedirty(vm_object_t object) return (false); return (method(object)); } + +/* + * Return the kvme type of the given object. + * If vpp is not NULL, set it to the object's vm_object_vnode() or NULL. + */ +int +vm_object_kvme_type(vm_object_t object, struct vnode **vpp) +{ + VM_OBJECT_ASSERT_LOCKED(object); + + if (vpp != NULL) + *vpp = vm_object_vnode(object); + return (pagertab[object->type]->pgo_kvme_type); +} diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 68c5fe42351e..5e0261f818cf 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -71,6 +71,7 @@ typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start, vm_size_t size); struct pagerops { + int pgo_kvme_type; pgo_init_t *pgo_init; /* Initialize pager. */ pgo_alloc_t *pgo_alloc; /* Allocate pager. */ pgo_dealloc_t *pgo_dealloc; /* Disassociate. */ diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index fb0b4068183b..d167fcc555fb 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -108,6 +109,7 @@ static void vnode_pager_release_writecount(vm_object_t, vm_offset_t, static void vnode_pager_getvp(vm_object_t, struct vnode **, bool *); const struct pagerops vnodepagerops = { + .pgo_kvme_type = KVME_TYPE_VNODE, .pgo_alloc = vnode_pager_alloc, .pgo_dealloc = vnode_pager_dealloc, .pgo_getpages = vnode_pager_getpages, From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A7756281E5; Thu, 13 May 2021 17:14:14 +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 4Fgytt2D1Hz3Qqq; Thu, 13 May 2021 17:14:14 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 195BE22C32; Thu, 13 May 2021 17:14:14 +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 14DHEE4S063332; Thu, 13 May 2021 17:14:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHED5R063331; Thu, 13 May 2021 17:14:13 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:13 GMT Message-Id: <202105131714.14DHED5R063331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8b99833ac253 - main - procfs_map: switch to use vm_object_kvme_type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8b99833ac2538a74d013d101e2b5ec2d9e29d198 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:14 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8b99833ac2538a74d013d101e2b5ec2d9e29d198 commit 8b99833ac2538a74d013d101e2b5ec2d9e29d198 Author: Konstantin Belousov AuthorDate: 2021-05-10 15:20:42 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:10:35 +0000 procfs_map: switch to use vm_object_kvme_type to get object type, and stop enumerating OBJT_XXX constants. This also provides properly a pointer for the vnode, if object backs any. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/fs/procfs/procfs_map.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c index 9ee49b0149a2..bd4cd2c09c00 100644 --- a/sys/fs/procfs/procfs_map.c +++ b/sys/fs/procfs/procfs_map.c @@ -51,6 +51,7 @@ #include #endif #include +#include #include #include @@ -85,7 +86,8 @@ procfs_doprocmap(PFS_FILL_ARGS) char *fullpath, *freepath, *type; struct ucred *cred; vm_object_t lobj, nobj, obj, tobj; - int error, privateresident, ref_count, resident, shadow_count, flags; + int error, flags, kvme, privateresident, ref_count, resident; + int shadow_count; vm_offset_t e_start, e_end; vm_eflags_t e_eflags; vm_prot_t e_prot; @@ -155,29 +157,29 @@ procfs_doprocmap(PFS_FILL_ARGS) freepath = NULL; fullpath = "-"; if (lobj) { - vp = NULL; - switch (lobj->type) { - default: - case OBJT_DEFAULT: - type = "default"; - break; - case OBJT_VNODE: - type = "vnode"; - vp = lobj->handle; + kvme = vm_object_kvme_type(lobj, &vp); + if (vp != NULL) vref(vp); + switch (kvme) { + default: + type = "unknown"; break; - case OBJT_SWAP_TMPFS: - type = "vnode"; - if ((lobj->flags & OBJ_TMPFS) != 0) { - vp = lobj->un_pager.swp.swp_tmpfs; - vref(vp); - } + case KVME_TYPE_PHYS: + type = "phys"; break; - case OBJT_SWAP: + case KVME_TYPE_DEFAULT: + case KVME_TYPE_SWAP: type = "swap"; break; - case OBJT_SG: - case OBJT_DEVICE: + case KVME_TYPE_DEAD: + type = "dead"; + break; + case KVME_TYPE_VNODE: + type = "vnode"; + break; + case KVME_TYPE_SG: + case KVME_TYPE_DEVICE: + case KVME_TYPE_MGTDEVICE: type = "device"; break; } From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DDD676286AB; Thu, 13 May 2021 17:14:16 +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 4Fgytw3l38z3Qlf; Thu, 13 May 2021 17:14:16 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5430D22A61; Thu, 13 May 2021 17:14:16 +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 14DHEGnl063381; Thu, 13 May 2021 17:14:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHEGPY063380; Thu, 13 May 2021 17:14:16 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:16 GMT Message-Id: <202105131714.14DHEGPY063380@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7079449b0b56 - main - sys/vm: remove several other uses of OBJT_SWAP_TMPFS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7079449b0b56d13b4ae7b4039ac8eb7c45c03fb5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:17 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7079449b0b56d13b4ae7b4039ac8eb7c45c03fb5 commit 7079449b0b56d13b4ae7b4039ac8eb7c45c03fb5 Author: Konstantin Belousov AuthorDate: 2021-05-07 18:21:22 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:10:35 +0000 sys/vm: remove several other uses of OBJT_SWAP_TMPFS Mostly in cases where OBJ_SWAP flag works as well, or by reversing the condition so that object types can be listed. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/vm/vm_object.c | 5 +++-- sys/vm/vm_pageout.c | 10 ++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 1aa05093f93a..8cb4c0006c59 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -669,7 +669,8 @@ vm_object_deallocate(vm_object_t object) umtx_shm_object_terminated(object); temp = object->backing_object; if (temp != NULL) { - KASSERT(object->type != OBJT_SWAP_TMPFS, + KASSERT(object->type == OBJT_DEFAULT || + object->type == OBJT_SWAP, ("shadowed tmpfs v_object 2 %p", object)); vm_object_backing_remove(object); } @@ -950,7 +951,7 @@ vm_object_terminate(vm_object_t object) #endif KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT || - object->type == OBJT_SWAP || object->type == OBJT_SWAP_TMPFS, + (object->flags & OBJ_SWAP) != 0, ("%s: non-swap obj %p has cred", __func__, object)); /* diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 521fc4ce95f2..216e76359631 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1887,15 +1887,9 @@ vm_pageout_oom_pagecount(struct vmspace *vmspace) if ((entry->eflags & MAP_ENTRY_NEEDS_COPY) != 0 && obj->ref_count != 1) continue; - switch (obj->type) { - case OBJT_DEFAULT: - case OBJT_SWAP: - case OBJT_SWAP_TMPFS: - case OBJT_PHYS: - case OBJT_VNODE: + if (obj->type == OBJT_DEFAULT || obj->type == OBJT_PHYS || + obj->type == OBJT_VNODE || (obj->flags & OBJ_SWAP) != 0) res += obj->resident_page_count; - break; - } } return (res); } From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B710628179; Thu, 13 May 2021 17:14:15 +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 4Fgytv1jY3z3Qqy; Thu, 13 May 2021 17:14:15 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2B6BF22A60; Thu, 13 May 2021 17:14:15 +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 14DHEF2C063353; Thu, 13 May 2021 17:14:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHEF6k063352; Thu, 13 May 2021 17:14:15 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:15 GMT Message-Id: <202105131714.14DHEF6k063352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 3e7a11ca21f3 - main - vm_object_set_memattr(): handle all object types without listing them explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e7a11ca21f3a7948c50f27de5b2159f0bb56672 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:15 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3e7a11ca21f3a7948c50f27de5b2159f0bb56672 commit 3e7a11ca21f3a7948c50f27de5b2159f0bb56672 Author: Konstantin Belousov AuthorDate: 2021-05-07 18:19:30 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:10:35 +0000 vm_object_set_memattr(): handle all object types without listing them explicitly This avoids the need to know all existing object types in advance, by the cost of loosing the assert that unknown object type is handled in a sane manner. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/vm/vm_object.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 735ab603a09b..1aa05093f93a 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -330,24 +330,12 @@ vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr) { VM_OBJECT_ASSERT_WLOCKED(object); - switch (object->type) { - case OBJT_DEFAULT: - case OBJT_DEVICE: - case OBJT_MGTDEVICE: - case OBJT_PHYS: - case OBJT_SG: - case OBJT_SWAP: - case OBJT_SWAP_TMPFS: - case OBJT_VNODE: - if (!TAILQ_EMPTY(&object->memq)) - return (KERN_FAILURE); - break; - case OBJT_DEAD: + + if (object->type == OBJT_DEAD) return (KERN_INVALID_ARGUMENT); - default: - panic("vm_object_set_memattr: object %p is of undefined type", - object); - } + if (!TAILQ_EMPTY(&object->memq)) + return (KERN_FAILURE); + object->memattr = memattr; return (KERN_SUCCESS); } From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B55B362817A; Thu, 13 May 2021 17:14:17 +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 4Fgytx44vJz3R2K; Thu, 13 May 2021 17:14:17 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 793C7226D5; Thu, 13 May 2021 17:14:17 +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 14DHEH2u063402; Thu, 13 May 2021 17:14:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHEHd5063401; Thu, 13 May 2021 17:14:17 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:17 GMT Message-Id: <202105131714.14DHEHd5063401@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b730fd30b78f - main - vm: Add KPI to dynamically register pagers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b730fd30b78f502ed5dd08e5285cb2c951495d65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:17 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b730fd30b78f502ed5dd08e5285cb2c951495d65 commit b730fd30b78f502ed5dd08e5285cb2c951495d65 Author: Konstantin Belousov AuthorDate: 2021-05-07 19:06:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:12:29 +0000 vm: Add KPI to dynamically register pagers Pager is allowed to inherit part of its implementation from the existing pager, which is done by copying non-NULL virtual method slots. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/vm/vm.h | 1 + sys/vm/vm_object.c | 15 +++++++++- sys/vm/vm_object.h | 1 + sys/vm/vm_pager.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++------- sys/vm/vm_pager.h | 3 ++ 5 files changed, 91 insertions(+), 11 deletions(-) diff --git a/sys/vm/vm.h b/sys/vm/vm.h index 2aae787d7f58..ca310b15b43c 100644 --- a/sys/vm/vm.h +++ b/sys/vm/vm.h @@ -98,6 +98,7 @@ enum obj_type { OBJT_SG, OBJT_MGTDEVICE, OBJT_SWAP_TMPFS, + OBJT_FIRST_DYN, }; typedef u_char objtype_t; diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 8cb4c0006c59..73cbdfb1ece4 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -430,7 +430,8 @@ vm_object_allocate(objtype_t type, vm_pindex_t size) flags = 0; break; default: - panic("vm_object_allocate: type %d is undefined", type); + panic("vm_object_allocate: type %d is undefined or dynamic", + type); } object = (vm_object_t)uma_zalloc(obj_zone, M_WAITOK); _vm_object_allocate(type, size, flags, object, NULL); @@ -438,6 +439,18 @@ vm_object_allocate(objtype_t type, vm_pindex_t size) return (object); } +vm_object_t +vm_object_allocate_dyn(objtype_t dyntype, vm_pindex_t size, u_short flags) +{ + vm_object_t object; + + MPASS(dyntype >= OBJT_FIRST_DYN /* && dyntype < nitems(pagertab) */); + object = (vm_object_t)uma_zalloc(obj_zone, M_WAITOK); + _vm_object_allocate(dyntype, size, flags, object, NULL); + + return (object); +} + /* * vm_object_allocate_anon: * diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 0e1ed321255f..7e99288e0ff2 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -356,6 +356,7 @@ extern int umtx_shm_vnobj_persistent; vm_object_t vm_object_allocate (objtype_t, vm_pindex_t); vm_object_t vm_object_allocate_anon(vm_pindex_t, vm_object_t, struct ucred *, vm_size_t); +vm_object_t vm_object_allocate_dyn(objtype_t, vm_pindex_t, u_short); boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t, boolean_t); void vm_object_collapse (vm_object_t); diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 9476058a75bf..432a948cfe81 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -165,7 +165,7 @@ static const struct pagerops deadpagerops = { .pgo_getvp = dead_pager_getvp, }; -const struct pagerops *pagertab[] __read_mostly = { +const struct pagerops *pagertab[16] __read_mostly = { [OBJT_DEFAULT] = &defaultpagerops, [OBJT_SWAP] = &swappagerops, [OBJT_VNODE] = &vnodepagerops, @@ -176,18 +176,24 @@ const struct pagerops *pagertab[] __read_mostly = { [OBJT_MGTDEVICE] = &mgtdevicepagerops, [OBJT_SWAP_TMPFS] = &swaptmpfspagerops, }; +static struct mtx pagertab_lock; void vm_pager_init(void) { const struct pagerops **pgops; + int i; + + mtx_init(&pagertab_lock, "dynpag", NULL, MTX_DEF); /* * Initialize known pagers */ - for (pgops = pagertab; pgops < &pagertab[nitems(pagertab)]; pgops++) + for (i = 0; i < OBJT_FIRST_DYN; i++) { + pgops = &pagertab[i]; if ((*pgops)->pgo_init != NULL) (*(*pgops)->pgo_init)(); + } } static int nswbuf_max; @@ -245,15 +251,9 @@ vm_object_t vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t off, struct ucred *cred) { - vm_object_t ret; - const struct pagerops *ops; + MPASS(type < nitems(pagertab)); - ops = pagertab[type]; - if (ops) - ret = (*ops->pgo_alloc)(handle, size, prot, off, cred); - else - ret = NULL; - return (ret); + return ((*pagertab[type]->pgo_alloc)(handle, size, prot, off, cred)); } /* @@ -264,6 +264,7 @@ vm_pager_deallocate(vm_object_t object) { VM_OBJECT_ASSERT_WLOCKED(object); + MPASS(object->type < nitems(pagertab)); (*pagertab[object->type]->pgo_dealloc) (object); } @@ -315,6 +316,7 @@ vm_pager_get_pages(vm_object_t object, vm_page_t *m, int count, int *rbehind, #endif int r; + MPASS(object->type < nitems(pagertab)); vm_pager_assert_in(object, m, count); r = (*pagertab[object->type]->pgo_getpages)(object, m, count, rbehind, @@ -348,6 +350,7 @@ vm_pager_get_pages_async(vm_object_t object, vm_page_t *m, int count, int *rbehind, int *rahead, pgo_getpages_iodone_t iodone, void *arg) { + MPASS(object->type < nitems(pagertab)); vm_pager_assert_in(object, m, count); return ((*pagertab[object->type]->pgo_getpages_async)(object, m, @@ -385,6 +388,60 @@ vm_pager_object_lookup(struct pagerlst *pg_list, void *handle) return (object); } +int +vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type) +{ + int res; + + mtx_lock(&pagertab_lock); + MPASS(base_type == -1 || + (base_type >= OBJT_DEFAULT && base_type < nitems(pagertab))); + for (res = OBJT_FIRST_DYN; res < nitems(pagertab); res++) { + if (pagertab[res] == NULL) + break; + } + if (res == nitems(pagertab)) { + mtx_unlock(&pagertab_lock); + return (-1); + } + if (base_type != -1) { + MPASS(pagertab[base_type] != NULL); +#define FIX(n) \ + if (ops->pgo_##n == NULL) \ + ops->pgo_##n = pagertab[base_type]->pgo_##n + FIX(init); + FIX(alloc); + FIX(dealloc); + FIX(getpages); + FIX(getpages_async); + FIX(putpages); + FIX(haspage); + FIX(populate); + FIX(pageunswapped); + FIX(update_writecount); + FIX(release_writecount); + FIX(set_writeable_dirty); + FIX(mightbedirty); + FIX(getvp); + FIX(freespace); +#undef FIX + } + pagertab[res] = ops; /* XXXKIB should be rel, but acq is too much */ + mtx_unlock(&pagertab_lock); + return (res); +} + +void +vm_pager_free_dyn_type(objtype_t type) +{ + MPASS(type >= OBJT_FIRST_DYN && type < nitems(pagertab)); + + mtx_lock(&pagertab_lock); + MPASS(pagertab[type] != NULL); + pagertab[type] = NULL; + mtx_unlock(&pagertab_lock); +} + static int pbuf_ctor(void *mem, int size, void *arg, int flags) { @@ -517,6 +574,8 @@ vm_object_set_writeable_dirty(vm_object_t object) { pgo_set_writeable_dirty_t *method; + MPASS(object->type < nitems(pagertab)); + method = pagertab[object->type]->pgo_set_writeable_dirty; if (method != NULL) method(object); @@ -527,6 +586,8 @@ vm_object_mightbedirty(vm_object_t object) { pgo_mightbedirty_t *method; + MPASS(object->type < nitems(pagertab)); + method = pagertab[object->type]->pgo_mightbedirty; if (method == NULL) return (false); @@ -541,6 +602,7 @@ int vm_object_kvme_type(vm_object_t object, struct vnode **vpp) { VM_OBJECT_ASSERT_LOCKED(object); + MPASS(object->type < nitems(pagertab)); if (vpp != NULL) *vpp = vm_object_vnode(object); diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 5e0261f818cf..098d48ea3d9d 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -249,6 +249,9 @@ vm_pager_freespace(vm_object_t object, vm_pindex_t start, method(object, start, size); } +int vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type); +void vm_pager_free_dyn_type(objtype_t type); + struct cdev_pager_ops { int (*cdev_pg_fault)(vm_object_t vm_obj, vm_ooffset_t offset, int prot, vm_page_t *mres); From owner-dev-commits-src-all@freebsd.org Thu May 13 17:14:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2AFD662807F; Thu, 13 May 2021 17:14:19 +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 4Fgyty5Vqsz3QrH; Thu, 13 May 2021 17:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A04DC2295E; Thu, 13 May 2021 17:14:18 +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 14DHEISH063423; Thu, 13 May 2021 17:14:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DHEI6P063422; Thu, 13 May 2021 17:14:18 GMT (envelope-from git) Date: Thu, 13 May 2021 17:14:18 GMT Message-Id: <202105131714.14DHEI6P063422@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 28bc23ab92ce - main - tmpfs: dynamically register tmpfs pager MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28bc23ab92ce7393aab48da7d71ccde63592ff2d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 17:14:19 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=28bc23ab92ce7393aab48da7d71ccde63592ff2d commit 28bc23ab92ce7393aab48da7d71ccde63592ff2d Author: Konstantin Belousov AuthorDate: 2021-05-07 19:42:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-13 17:13:34 +0000 tmpfs: dynamically register tmpfs pager Remove OBJT_SWAP_TMPFS. Move tmpfs-specific swap pager bits into tmpfs_subr.c. There is no longer any code to directly support tmpfs in sys/vm, most tmpfs knowledge is shared by non-anon swap object type implementation. The tmpfs-specific methods are provided by registered tmpfs pager, which inherits from the swap pager. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30168 --- sys/fs/tmpfs/tmpfs.h | 6 ++- sys/fs/tmpfs/tmpfs_subr.c | 70 ++++++++++++++++++++++++++++++++-- sys/fs/tmpfs/tmpfs_vfsops.c | 14 ++++--- sys/fs/tmpfs/tmpfs_vnops.c | 2 +- sys/vm/swap_pager.c | 93 ++++++++++----------------------------------- sys/vm/swap_pager.h | 3 +- sys/vm/vm.h | 1 - sys/vm/vm_object.c | 1 - sys/vm/vm_object.h | 2 +- sys/vm/vm_pager.c | 1 - 10 files changed, 106 insertions(+), 87 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 28493a550252..549339d9b6d1 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -45,6 +45,8 @@ MALLOC_DECLARE(M_TMPFSNAME); #endif +#define OBJ_TMPFS OBJ_PAGERPRIV /* has tmpfs vnode allocated */ + /* * Internal representation of a tmpfs directory entry. */ @@ -514,9 +516,11 @@ tmpfs_update(struct vnode *vp) size_t tmpfs_mem_avail(void); size_t tmpfs_pages_used(struct tmpfs_mount *tmp); -void tmpfs_subr_init(void); +int tmpfs_subr_init(void); void tmpfs_subr_uninit(void); +extern int tmpfs_pager_type; + /* * Macros/functions to convert from generic data structures to tmpfs * specific ones. diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 1ea4cf23b314..67eb12598e24 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -79,6 +80,61 @@ MALLOC_DEFINE(M_TMPFSDIR, "tmpfs dir", "tmpfs dirent structure"); static uma_zone_t tmpfs_node_pool; VFS_SMR_DECLARE; +int tmpfs_pager_type = -1; + +static vm_object_t +tmpfs_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, + vm_ooffset_t offset, struct ucred *cred) +{ + vm_object_t object; + + MPASS(handle == NULL); + MPASS(offset == 0); + object = vm_object_allocate_dyn(tmpfs_pager_type, size, + OBJ_COLORED | OBJ_SWAP); + if (!swap_pager_init_object(object, NULL, NULL, size, 0)) { + vm_object_deallocate(object); + object = NULL; + } + return (object); +} + +static void +tmpfs_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) +{ + struct vnode *vp; + + /* + * Tmpfs VREG node, which was reclaimed, has tmpfs_pager_type + * type, but not OBJ_TMPFS flag. In this case there is no + * v_writecount to adjust. + */ + if (vp_heldp != NULL) + VM_OBJECT_RLOCK(object); + else + VM_OBJECT_ASSERT_LOCKED(object); + if ((object->flags & OBJ_TMPFS) != 0) { + vp = object->un_pager.swp.swp_tmpfs; + if (vp != NULL) { + *vpp = vp; + if (vp_heldp != NULL) { + vhold(vp); + *vp_heldp = true; + } + } + } + if (vp_heldp != NULL) + VM_OBJECT_RUNLOCK(object); +} + +struct pagerops tmpfs_pager_ops = { + .pgo_kvme_type = KVME_TYPE_VNODE, + .pgo_alloc = tmpfs_pager_alloc, + .pgo_set_writeable_dirty = vm_object_set_writeable_dirty_, + .pgo_mightbedirty = vm_object_mightbedirty_, + .pgo_getvp = tmpfs_pager_getvp, +}; + static int tmpfs_node_ctor(void *mem, int size, void *arg, int flags) { @@ -126,18 +182,26 @@ tmpfs_node_fini(void *mem, int size) mtx_destroy(&node->tn_interlock); } -void +int tmpfs_subr_init(void) { + tmpfs_pager_type = vm_pager_alloc_dyn_type(&tmpfs_pager_ops, + OBJT_SWAP); + if (tmpfs_pager_type == -1) + return (EINVAL); tmpfs_node_pool = uma_zcreate("TMPFS node", sizeof(struct tmpfs_node), tmpfs_node_ctor, tmpfs_node_dtor, tmpfs_node_init, tmpfs_node_fini, UMA_ALIGN_PTR, 0); VFS_SMR_ZONE_SET(tmpfs_node_pool); + return (0); } void tmpfs_subr_uninit(void) { + if (tmpfs_pager_type != -1) + vm_pager_free_dyn_type(tmpfs_pager_type); + tmpfs_pager_type = -1; uma_zdestroy(tmpfs_node_pool); } @@ -364,7 +428,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount *tmp, enum vtype type, case VREG: obj = nnode->tn_reg.tn_aobj = - vm_pager_allocate(OBJT_SWAP_TMPFS, NULL, 0, + vm_pager_allocate(tmpfs_pager_type, NULL, 0, VM_PROT_DEFAULT, 0, NULL /* XXXKIB - tmpfs needs swap reservation */); /* OBJ_TMPFS is set together with the setting of vp->v_object */ @@ -1588,7 +1652,7 @@ tmpfs_check_mtime(struct vnode *vp) if (vp->v_type != VREG) return; obj = vp->v_object; - KASSERT(obj->type == OBJT_SWAP_TMPFS && + KASSERT(obj->type == tmpfs_pager_type && (obj->flags & (OBJ_SWAP | OBJ_TMPFS)) == (OBJ_SWAP | OBJ_TMPFS), ("non-tmpfs obj")); /* unlocked read */ diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 51d097203135..4f29b5dfc6f0 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -103,8 +103,8 @@ static const char *tmpfs_updateopts[] = { * Handle updates of time from writes to mmaped regions, if allowed. * Use MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since * unmap of the tmpfs-backed vnode does not call vinactive(), due to - * vm object type is OBJT_SWAP. If lazy, only handle delayed update - * of mtime due to the writes to mapped files. + * vm object type is basically OBJT_SWAP. If lazy, only handle + * delayed update of mtime due to the writes to mapped files. */ static void tmpfs_update_mtime(struct mount *mp, bool lazy) @@ -120,7 +120,7 @@ tmpfs_update_mtime(struct mount *mp, bool lazy) continue; } obj = vp->v_object; - MPASS(obj->type == OBJT_SWAP_TMPFS); + MPASS(obj->type == tmpfs_pager_type); MPASS((obj->flags & OBJ_TMPFS) != 0); /* @@ -225,7 +225,7 @@ again: (entry->max_protection & VM_PROT_WRITE) == 0) continue; object = entry->object.vm_object; - if (object == NULL || object->type != OBJT_SWAP_TMPFS) + if (object == NULL || object->type != tmpfs_pager_type) continue; /* * No need to dig into shadow chain, mapping @@ -661,7 +661,11 @@ tmpfs_sync(struct mount *mp, int waitfor) static int tmpfs_init(struct vfsconf *conf) { - tmpfs_subr_init(); + int res; + + res = tmpfs_subr_init(); + if (res != 0) + return (res); memcpy(&tmpfs_fnops, &vnops, sizeof(struct fileops)); tmpfs_fnops.fo_close = tmpfs_fo_close; return (0); diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 401ee672b96a..43a2aa77dbbb 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -623,7 +623,7 @@ tmpfs_read_pgcache(struct vop_read_pgcache_args *v) if (object == NULL) goto out_smr; - MPASS(object->type == OBJT_SWAP_TMPFS); + MPASS(object->type == tmpfs_pager_type); MPASS((object->flags & (OBJ_ANON | OBJ_DEAD | OBJ_SWAP)) == OBJ_SWAP); if (!VN_IS_DOOMED(vp)) { diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 37db4cbac857..63f0d22ed705 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -419,9 +419,6 @@ static uma_zone_t swpctrie_zone; static vm_object_t swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t offset, struct ucred *); -static vm_object_t - swap_tmpfs_pager_alloc(void *handle, vm_ooffset_t size, - vm_prot_t prot, vm_ooffset_t offset, struct ucred *); static void swap_pager_dealloc(vm_object_t object); static int swap_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); @@ -437,8 +434,6 @@ static void swap_pager_update_writecount(vm_object_t object, vm_offset_t start, vm_offset_t end); static void swap_pager_release_writecount(vm_object_t object, vm_offset_t start, vm_offset_t end); -static void swap_tmpfs_pager_getvp(vm_object_t object, struct vnode **vpp, - bool *vp_heldp); static void swap_pager_freespace(vm_object_t object, vm_pindex_t start, vm_size_t size); @@ -457,23 +452,6 @@ const struct pagerops swappagerops = { .pgo_freespace = swap_pager_freespace, }; -const struct pagerops swaptmpfspagerops = { - .pgo_kvme_type = KVME_TYPE_VNODE, - .pgo_alloc = swap_tmpfs_pager_alloc, - .pgo_dealloc = swap_pager_dealloc, - .pgo_getpages = swap_pager_getpages, - .pgo_getpages_async = swap_pager_getpages_async, - .pgo_putpages = swap_pager_putpages, - .pgo_haspage = swap_pager_haspage, - .pgo_pageunswapped = swap_pager_unswapped, - .pgo_update_writecount = swap_pager_update_writecount, - .pgo_release_writecount = swap_pager_release_writecount, - .pgo_set_writeable_dirty = vm_object_set_writeable_dirty_, - .pgo_mightbedirty = vm_object_mightbedirty_, - .pgo_getvp = swap_tmpfs_pager_getvp, - .pgo_freespace = swap_pager_freespace, -}; - /* * swap_*() routines are externally accessible. swp_*() routines are * internal. @@ -681,18 +659,31 @@ swap_pager_swap_init(void) "reduce kern.maxswzone.\n"); } -static vm_object_t -swap_pager_alloc_init(objtype_t otype, void *handle, struct ucred *cred, +bool +swap_pager_init_object(vm_object_t object, void *handle, struct ucred *cred, vm_ooffset_t size, vm_ooffset_t offset) { - vm_object_t object; - if (cred != NULL) { if (!swap_reserve_by_cred(size, cred)) - return (NULL); + return (false); crhold(cred); } + object->un_pager.swp.writemappings = 0; + object->handle = handle; + if (cred != NULL) { + object->cred = cred; + object->charge = size; + } + return (true); +} + +static vm_object_t +swap_pager_alloc_init(objtype_t otype, void *handle, struct ucred *cred, + vm_ooffset_t size, vm_ooffset_t offset) +{ + vm_object_t object; + /* * The un_pager.swp.swp_blks trie is initialized by * vm_object_allocate() to ensure the correct order of @@ -701,11 +692,9 @@ swap_pager_alloc_init(objtype_t otype, void *handle, struct ucred *cred, object = vm_object_allocate(otype, OFF_TO_IDX(offset + PAGE_MASK + size)); - object->un_pager.swp.writemappings = 0; - object->handle = handle; - if (cred != NULL) { - object->cred = cred; - object->charge = size; + if (!swap_pager_init_object(object, handle, cred, size, offset)) { + vm_object_deallocate(object); + return (NULL); } return (object); } @@ -752,18 +741,6 @@ swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, return (object); } -static vm_object_t -swap_tmpfs_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, - vm_ooffset_t offset, struct ucred *cred) -{ - vm_object_t object; - - MPASS(handle == NULL); - object = swap_pager_alloc_init(OBJT_SWAP_TMPFS, handle, cred, - size, offset); - return (object); -} - /* * SWAP_PAGER_DEALLOC() - remove swap metadata from object * @@ -3168,31 +3145,3 @@ swap_pager_release_writecount(vm_object_t object, vm_offset_t start, object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; VM_OBJECT_WUNLOCK(object); } - -static void -swap_tmpfs_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) -{ - struct vnode *vp; - - /* - * Tmpfs VREG node, which was reclaimed, has OBJT_SWAP_TMPFS - * type, but not OBJ_TMPFS flag. In this case there is no - * v_writecount to adjust. - */ - if (vp_heldp != NULL) - VM_OBJECT_RLOCK(object); - else - VM_OBJECT_ASSERT_LOCKED(object); - if ((object->flags & OBJ_TMPFS) != 0) { - vp = object->un_pager.swp.swp_tmpfs; - if (vp != NULL) { - *vpp = vp; - if (vp_heldp != NULL) { - vhold(vp); - *vp_heldp = true; - } - } - } - if (vp_heldp != NULL) - VM_OBJECT_RUNLOCK(object); -} diff --git a/sys/vm/swap_pager.h b/sys/vm/swap_pager.h index 7a2ea12e887d..20ff70acc3d8 100644 --- a/sys/vm/swap_pager.h +++ b/sys/vm/swap_pager.h @@ -82,6 +82,7 @@ int swap_pager_reserve(vm_object_t, vm_pindex_t, vm_size_t); void swap_pager_status(int *total, int *used); u_long swap_pager_swapped_pages(vm_object_t object); void swapoff_all(void); - +bool swap_pager_init_object(vm_object_t object, void *handle, + struct ucred *cred, vm_ooffset_t size, vm_ooffset_t offset); #endif /* _KERNEL */ #endif /* _VM_SWAP_PAGER_H_ */ diff --git a/sys/vm/vm.h b/sys/vm/vm.h index ca310b15b43c..8dce853e684d 100644 --- a/sys/vm/vm.h +++ b/sys/vm/vm.h @@ -97,7 +97,6 @@ enum obj_type { OBJT_DEAD, OBJT_SG, OBJT_MGTDEVICE, - OBJT_SWAP_TMPFS, OBJT_FIRST_DYN, }; typedef u_char objtype_t; diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 73cbdfb1ece4..9bd3f416ff94 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -413,7 +413,6 @@ vm_object_allocate(objtype_t type, vm_pindex_t size) flags = OBJ_COLORED; break; case OBJT_SWAP: - case OBJT_SWAP_TMPFS: flags = OBJ_COLORED | OBJ_SWAP; break; case OBJT_DEVICE: diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 7e99288e0ff2..d159c621d2e6 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -207,7 +207,7 @@ struct vm_object { #define OBJ_COLORED 0x1000 /* pg_color is defined */ #define OBJ_ONEMAPPING 0x2000 /* One USE (a single, non-forked) mapping flag */ #define OBJ_SHADOWLIST 0x4000 /* Object is on the shadow list. */ -#define OBJ_TMPFS 0x8000 /* has tmpfs vnode allocated */ +#define OBJ_PAGERPRIV 0x8000 /* Pager private */ /* * Helpers to perform conversion between vm_object page indexes and offsets. diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 432a948cfe81..640e3d977e99 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -174,7 +174,6 @@ const struct pagerops *pagertab[16] __read_mostly = { [OBJT_DEAD] = &deadpagerops, [OBJT_SG] = &sgpagerops, [OBJT_MGTDEVICE] = &mgtdevicepagerops, - [OBJT_SWAP_TMPFS] = &swaptmpfspagerops, }; static struct mtx pagertab_lock; From owner-dev-commits-src-all@freebsd.org Thu May 13 18:11:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52D0D629C6A; Thu, 13 May 2021 18:11:09 +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 4Fh08Y1twdz3kQL; Thu, 13 May 2021 18:11:09 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 294632378C; Thu, 13 May 2021 18:11:09 +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 14DIB9Zb045613; Thu, 13 May 2021 18:11:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DIB9Lj045612; Thu, 13 May 2021 18:11:09 GMT (envelope-from git) Date: Thu, 13 May 2021 18:11:09 GMT Message-Id: <202105131811.14DIB9Lj045612@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: ad385f7b46e7 - main - makesyscalls.lua: improve generated file style(9) compliance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ad385f7b46e7636b11fb0fd56bc42b60b06b16ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 18:11:09 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ad385f7b46e7636b11fb0fd56bc42b60b06b16ad commit ad385f7b46e7636b11fb0fd56bc42b60b06b16ad Author: Ed Maste AuthorDate: 2021-05-12 20:11:44 +0000 Commit: Ed Maste CommitDate: 2021-05-13 17:59:25 +0000 makesyscalls.lua: improve generated file style(9) compliance We generally like to avoid style changes when other changes are not planned. In this case there are some makesyscalls.lua changes in the pipeline, and this cleans up style nits in generated files that were highlighted by experiments with clang-format. Reviewed by: brooks, kevans MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30235 --- sys/tools/makesyscalls.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 3b88c65c4440..dab8e0e01f82 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -648,7 +648,7 @@ local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype, ]], funcname, sysnum)) if #funcargs > 0 then - write_line("systracetmp", "\t\tswitch(ndx) {\n") + write_line("systracetmp", "\t\tswitch (ndx) {\n") write_line("systrace", string.format( "\t\tstruct %s *p = params;\n", argalias)) @@ -671,7 +671,7 @@ local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype, if isptrtype(argtype) then write_line("systrace", string.format( - "\t\tuarg[%d] = (%s) p->%s; /* %s */\n", + "\t\tuarg[%d] = (%s)p->%s; /* %s */\n", idx - 1, config["ptr_intptr_t_cast"], argname, argtype)) elseif argtype == "union l_semun" then @@ -1285,7 +1285,7 @@ write_line("systrace", string.format([[/* static void systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) { - int64_t *iarg = (int64_t *) uarg; + int64_t *iarg = (int64_t *)uarg; switch (sysnum) { ]], generated_tag, config['os_id_keyword'])) @@ -1316,7 +1316,7 @@ for _, v in pairs(compat_options) do write_line("sysinc", string.format([[ #ifdef %s -#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s,name) +#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s, name) #else #define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys #endif From owner-dev-commits-src-all@freebsd.org Thu May 13 18:11:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ECAE7629C7D; Thu, 13 May 2021 18:11:10 +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 4Fh08Z4Pkyz3k46; Thu, 13 May 2021 18:11:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8439123345; Thu, 13 May 2021 18:11:10 +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 14DIBARB045634; Thu, 13 May 2021 18:11:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DIBA1p045633; Thu, 13 May 2021 18:11:10 GMT (envelope-from git) Date: Thu, 13 May 2021 18:11:10 GMT Message-Id: <202105131811.14DIBA1p045633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 2c9764f36b6f - main - regen syscall files after d51198d63b63 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2c9764f36b6f20e9a6c71ce64a21988a394050b6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 18:11:11 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2c9764f36b6f20e9a6c71ce64a21988a394050b6 commit 2c9764f36b6f20e9a6c71ce64a21988a394050b6 Author: Ed Maste AuthorDate: 2021-05-13 17:58:04 +0000 Commit: Ed Maste CommitDate: 2021-05-13 18:09:58 +0000 regen syscall files after d51198d63b63 --- sys/amd64/linux/linux_systrace_args.c | 1052 +++++++------- sys/amd64/linux32/linux32_systrace_args.c | 1212 ++++++++-------- sys/arm/linux/linux_systrace_args.c | 946 ++++++------- sys/arm64/linux/linux_systrace_args.c | 888 ++++++------ sys/compat/cloudabi32/cloudabi32_systrace_args.c | 182 +-- sys/compat/cloudabi64/cloudabi64_systrace_args.c | 182 +-- sys/compat/freebsd32/freebsd32_sysent.c | 14 +- sys/compat/freebsd32/freebsd32_systrace_args.c | 1568 ++++++++++----------- sys/i386/linux/linux_systrace_args.c | 1232 ++++++++-------- sys/kern/init_sysent.c | 14 +- sys/kern/systrace_args.c | 1632 +++++++++++----------- 11 files changed, 4461 insertions(+), 4461 deletions(-) diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index 5aa83b94e7a3..daacb1af287c 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -9,14 +9,14 @@ static void systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) { - int64_t *iarg = (int64_t *) uarg; + int64_t *iarg = (int64_t *)uarg; switch (sysnum) { #define nosys linux_nosys /* read */ case 0: { struct read_args *p = params; iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->nbyte; /* l_size_t */ *n_args = 3; break; @@ -25,7 +25,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 1: { struct write_args *p = params; iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->nbyte; /* l_size_t */ *n_args = 3; break; @@ -33,7 +33,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_open */ case 2: { struct linux_open_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->flags; /* l_int */ iarg[2] = p->mode; /* l_mode_t */ *n_args = 3; @@ -49,8 +49,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_newstat */ case 4: { struct linux_newstat_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->buf; /* struct l_newstat * */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->buf; /* struct l_newstat * */ *n_args = 2; break; } @@ -58,22 +58,22 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 5: { struct linux_newfstat_args *p = params; iarg[0] = p->fd; /* l_uint */ - uarg[1] = (intptr_t) p->buf; /* struct l_newstat * */ + uarg[1] = (intptr_t)p->buf; /* struct l_newstat * */ *n_args = 2; break; } /* linux_newlstat */ case 6: { struct linux_newlstat_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->buf; /* struct l_newstat * */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->buf; /* struct l_newstat * */ *n_args = 2; break; } /* poll */ case 7: { struct poll_args *p = params; - uarg[0] = (intptr_t) p->fds; /* struct pollfd * */ + uarg[0] = (intptr_t)p->fds; /* struct pollfd * */ uarg[1] = p->nfds; /* u_int */ iarg[2] = p->timeout; /* int */ *n_args = 3; @@ -112,7 +112,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* munmap */ case 11: { struct munmap_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ + uarg[0] = (intptr_t)p->addr; /* void * */ iarg[1] = p->len; /* l_size_t */ *n_args = 2; break; @@ -128,8 +128,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 13: { struct linux_rt_sigaction_args *p = params; iarg[0] = p->sig; /* l_int */ - uarg[1] = (intptr_t) p->act; /* l_sigaction_t * */ - uarg[2] = (intptr_t) p->oact; /* l_sigaction_t * */ + uarg[1] = (intptr_t)p->act; /* l_sigaction_t * */ + uarg[2] = (intptr_t)p->oact; /* l_sigaction_t * */ iarg[3] = p->sigsetsize; /* l_size_t */ *n_args = 4; break; @@ -138,8 +138,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 14: { struct linux_rt_sigprocmask_args *p = params; iarg[0] = p->how; /* l_int */ - uarg[1] = (intptr_t) p->mask; /* l_sigset_t * */ - uarg[2] = (intptr_t) p->omask; /* l_sigset_t * */ + uarg[1] = (intptr_t)p->mask; /* l_sigset_t * */ + uarg[2] = (intptr_t)p->omask; /* l_sigset_t * */ iarg[3] = p->sigsetsize; /* l_size_t */ *n_args = 4; break; @@ -147,7 +147,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_rt_sigreturn */ case 15: { struct linux_rt_sigreturn_args *p = params; - uarg[0] = (intptr_t) p->ucp; /* struct l_ucontext * */ + uarg[0] = (intptr_t)p->ucp; /* struct l_ucontext * */ *n_args = 1; break; } @@ -164,7 +164,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 17: { struct linux_pread_args *p = params; iarg[0] = p->fd; /* l_uint */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->nbyte; /* l_size_t */ iarg[3] = p->offset; /* l_loff_t */ *n_args = 4; @@ -174,7 +174,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 18: { struct linux_pwrite_args *p = params; iarg[0] = p->fd; /* l_uint */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->nbyte; /* l_size_t */ iarg[3] = p->offset; /* l_loff_t */ *n_args = 4; @@ -184,7 +184,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 19: { struct readv_args *p = params; iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->iovp; /* struct iovec * */ + uarg[1] = (intptr_t)p->iovp; /* struct iovec * */ uarg[2] = p->iovcnt; /* u_int */ *n_args = 3; break; @@ -193,7 +193,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 20: { struct writev_args *p = params; iarg[0] = p->fd; /* int */ - uarg[1] = (intptr_t) p->iovp; /* struct iovec * */ + uarg[1] = (intptr_t)p->iovp; /* struct iovec * */ uarg[2] = p->iovcnt; /* u_int */ *n_args = 3; break; @@ -201,7 +201,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_access */ case 21: { struct linux_access_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->amode; /* l_int */ *n_args = 2; break; @@ -209,7 +209,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_pipe */ case 22: { struct linux_pipe_args *p = params; - uarg[0] = (intptr_t) p->pipefds; /* l_int * */ + uarg[0] = (intptr_t)p->pipefds; /* l_int * */ *n_args = 1; break; } @@ -217,10 +217,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 23: { struct linux_select_args *p = params; iarg[0] = p->nfds; /* l_int */ - uarg[1] = (intptr_t) p->readfds; /* l_fd_set * */ - uarg[2] = (intptr_t) p->writefds; /* l_fd_set * */ - uarg[3] = (intptr_t) p->exceptfds; /* l_fd_set * */ - uarg[4] = (intptr_t) p->timeout; /* struct l_timeval * */ + uarg[1] = (intptr_t)p->readfds; /* l_fd_set * */ + uarg[2] = (intptr_t)p->writefds; /* l_fd_set * */ + uarg[3] = (intptr_t)p->exceptfds; /* l_fd_set * */ + uarg[4] = (intptr_t)p->timeout; /* struct l_timeval * */ *n_args = 5; break; } @@ -254,7 +254,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_mincore_args *p = params; iarg[0] = p->start; /* l_ulong */ iarg[1] = p->len; /* l_size_t */ - uarg[2] = (intptr_t) p->vec; /* u_char * */ + uarg[2] = (intptr_t)p->vec; /* u_char * */ *n_args = 3; break; } @@ -280,7 +280,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 30: { struct linux_shmat_args *p = params; iarg[0] = p->shmid; /* l_int */ - uarg[1] = (intptr_t) p->shmaddr; /* char * */ + uarg[1] = (intptr_t)p->shmaddr; /* char * */ iarg[2] = p->shmflg; /* l_int */ *n_args = 3; break; @@ -290,7 +290,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_shmctl_args *p = params; iarg[0] = p->shmid; /* l_int */ iarg[1] = p->cmd; /* l_int */ - uarg[2] = (intptr_t) p->buf; /* struct l_shmid_ds * */ + uarg[2] = (intptr_t)p->buf; /* struct l_shmid_ds * */ *n_args = 3; break; } @@ -317,8 +317,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_nanosleep */ case 35: { struct linux_nanosleep_args *p = params; - uarg[0] = (intptr_t) p->rqtp; /* const struct l_timespec * */ - uarg[1] = (intptr_t) p->rmtp; /* struct l_timespec * */ + uarg[0] = (intptr_t)p->rqtp; /* const struct l_timespec * */ + uarg[1] = (intptr_t)p->rmtp; /* struct l_timespec * */ *n_args = 2; break; } @@ -326,7 +326,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 36: { struct linux_getitimer_args *p = params; iarg[0] = p->which; /* l_int */ - uarg[1] = (intptr_t) p->itv; /* struct l_itimerval * */ + uarg[1] = (intptr_t)p->itv; /* struct l_itimerval * */ *n_args = 2; break; } @@ -341,8 +341,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 38: { struct linux_setitimer_args *p = params; iarg[0] = p->which; /* l_int */ - uarg[1] = (intptr_t) p->itv; /* struct l_itimerval * */ - uarg[2] = (intptr_t) p->oitv; /* struct l_itimerval * */ + uarg[1] = (intptr_t)p->itv; /* struct l_itimerval * */ + uarg[2] = (intptr_t)p->oitv; /* struct l_itimerval * */ *n_args = 3; break; } @@ -356,7 +356,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_sendfile_args *p = params; iarg[0] = p->out; /* l_int */ iarg[1] = p->in; /* l_int */ - uarg[2] = (intptr_t) p->offset; /* l_off_t * */ + uarg[2] = (intptr_t)p->offset; /* l_off_t * */ iarg[3] = p->count; /* l_size_t */ *n_args = 4; break; @@ -509,10 +509,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 56: { struct linux_clone_args *p = params; iarg[0] = p->flags; /* l_ulong */ - uarg[1] = (intptr_t) p->stack; /* void * */ - uarg[2] = (intptr_t) p->parent_tidptr; /* void * */ - uarg[3] = (intptr_t) p->child_tidptr; /* void * */ - uarg[4] = (intptr_t) p->tls; /* void * */ + uarg[1] = (intptr_t)p->stack; /* void * */ + uarg[2] = (intptr_t)p->parent_tidptr; /* void * */ + uarg[3] = (intptr_t)p->child_tidptr; /* void * */ + uarg[4] = (intptr_t)p->tls; /* void * */ *n_args = 5; break; } @@ -529,9 +529,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_execve */ case 59: { struct linux_execve_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->argp; /* char ** */ - uarg[2] = (intptr_t) p->envp; /* char ** */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->argp; /* char ** */ + uarg[2] = (intptr_t)p->envp; /* char ** */ *n_args = 3; break; } @@ -546,9 +546,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 61: { struct linux_wait4_args *p = params; iarg[0] = p->pid; /* l_pid_t */ - uarg[1] = (intptr_t) p->status; /* l_int * */ + uarg[1] = (intptr_t)p->status; /* l_int * */ iarg[2] = p->options; /* l_int */ - uarg[3] = (intptr_t) p->rusage; /* struct rusage * */ + uarg[3] = (intptr_t)p->rusage; /* struct rusage * */ *n_args = 4; break; } @@ -563,7 +563,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_newuname */ case 63: { struct linux_newuname_args *p = params; - uarg[0] = (intptr_t) p->buf; /* struct l_new_utsname * */ + uarg[0] = (intptr_t)p->buf; /* struct l_new_utsname * */ *n_args = 1; break; } @@ -580,7 +580,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 65: { struct linux_semop_args *p = params; iarg[0] = p->semid; /* l_int */ - uarg[1] = (intptr_t) p->tsops; /* struct l_sembuf * */ + uarg[1] = (intptr_t)p->tsops; /* struct l_sembuf * */ iarg[2] = p->nsops; /* l_uint */ *n_args = 3; break; @@ -598,7 +598,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_shmdt */ case 67: { struct linux_shmdt_args *p = params; - uarg[0] = (intptr_t) p->shmaddr; /* char * */ + uarg[0] = (intptr_t)p->shmaddr; /* char * */ *n_args = 1; break; } @@ -614,7 +614,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 69: { struct linux_msgsnd_args *p = params; iarg[0] = p->msqid; /* l_int */ - uarg[1] = (intptr_t) p->msgp; /* struct l_msgbuf * */ + uarg[1] = (intptr_t)p->msgp; /* struct l_msgbuf * */ iarg[2] = p->msgsz; /* l_size_t */ iarg[3] = p->msgflg; /* l_int */ *n_args = 4; @@ -624,7 +624,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 70: { struct linux_msgrcv_args *p = params; iarg[0] = p->msqid; /* l_int */ - uarg[1] = (intptr_t) p->msgp; /* struct l_msgbuf * */ + uarg[1] = (intptr_t)p->msgp; /* struct l_msgbuf * */ iarg[2] = p->msgsz; /* l_size_t */ iarg[3] = p->msgtyp; /* l_long */ iarg[4] = p->msgflg; /* l_int */ @@ -636,7 +636,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_msgctl_args *p = params; iarg[0] = p->msqid; /* l_int */ iarg[1] = p->cmd; /* l_int */ - uarg[2] = (intptr_t) p->buf; /* struct l_msqid_ds * */ + uarg[2] = (intptr_t)p->buf; /* struct l_msqid_ds * */ *n_args = 3; break; } @@ -674,7 +674,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_truncate */ case 76: { struct linux_truncate_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->length; /* l_long */ *n_args = 2; break; @@ -691,7 +691,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 78: { struct linux_getdents_args *p = params; iarg[0] = p->fd; /* l_uint */ - uarg[1] = (intptr_t) p->dent; /* void * */ + uarg[1] = (intptr_t)p->dent; /* void * */ iarg[2] = p->count; /* l_uint */ *n_args = 3; break; @@ -699,7 +699,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_getcwd */ case 79: { struct linux_getcwd_args *p = params; - uarg[0] = (intptr_t) p->buf; /* char * */ + uarg[0] = (intptr_t)p->buf; /* char * */ iarg[1] = p->bufsize; /* l_ulong */ *n_args = 2; break; @@ -707,7 +707,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_chdir */ case 80: { struct linux_chdir_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ *n_args = 1; break; } @@ -721,15 +721,15 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_rename */ case 82: { struct linux_rename_args *p = params; - uarg[0] = (intptr_t) p->from; /* char * */ - uarg[1] = (intptr_t) p->to; /* char * */ + uarg[0] = (intptr_t)p->from; /* char * */ + uarg[1] = (intptr_t)p->to; /* char * */ *n_args = 2; break; } /* linux_mkdir */ case 83: { struct linux_mkdir_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->mode; /* l_mode_t */ *n_args = 2; break; @@ -737,14 +737,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_rmdir */ case 84: { struct linux_rmdir_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ *n_args = 1; break; } /* linux_creat */ case 85: { struct linux_creat_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->mode; /* l_mode_t */ *n_args = 2; break; @@ -752,31 +752,31 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_link */ case 86: { struct linux_link_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->to; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->to; /* char * */ *n_args = 2; break; } /* linux_unlink */ case 87: { struct linux_unlink_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ *n_args = 1; break; } /* linux_symlink */ case 88: { struct linux_symlink_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->to; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->to; /* char * */ *n_args = 2; break; } /* linux_readlink */ case 89: { struct linux_readlink_args *p = params; - uarg[0] = (intptr_t) p->name; /* char * */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[0] = (intptr_t)p->name; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->count; /* l_int */ *n_args = 3; break; @@ -784,7 +784,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_chmod */ case 90: { struct linux_chmod_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->mode; /* l_mode_t */ *n_args = 2; break; @@ -800,7 +800,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_chown */ case 92: { struct linux_chown_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->uid; /* l_uid_t */ iarg[2] = p->gid; /* l_gid_t */ *n_args = 3; @@ -818,7 +818,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_lchown */ case 94: { struct linux_lchown_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->uid; /* l_uid_t */ iarg[2] = p->gid; /* l_gid_t */ *n_args = 3; @@ -834,8 +834,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* gettimeofday */ case 96: { struct gettimeofday_args *p = params; - uarg[0] = (intptr_t) p->tp; /* struct l_timeval * */ - uarg[1] = (intptr_t) p->tzp; /* struct timezone * */ + uarg[0] = (intptr_t)p->tp; /* struct l_timeval * */ + uarg[1] = (intptr_t)p->tzp; /* struct timezone * */ *n_args = 2; break; } @@ -843,7 +843,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 97: { struct linux_getrlimit_args *p = params; iarg[0] = p->resource; /* l_uint */ - uarg[1] = (intptr_t) p->rlim; /* struct l_rlimit * */ + uarg[1] = (intptr_t)p->rlim; /* struct l_rlimit * */ *n_args = 2; break; } @@ -851,21 +851,21 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 98: { struct getrusage_args *p = params; iarg[0] = p->who; /* int */ - uarg[1] = (intptr_t) p->rusage; /* struct rusage * */ + uarg[1] = (intptr_t)p->rusage; /* struct rusage * */ *n_args = 2; break; } /* linux_sysinfo */ case 99: { struct linux_sysinfo_args *p = params; - uarg[0] = (intptr_t) p->info; /* struct l_sysinfo * */ + uarg[0] = (intptr_t)p->info; /* struct l_sysinfo * */ *n_args = 1; break; } /* linux_times */ case 100: { struct linux_times_args *p = params; - uarg[0] = (intptr_t) p->buf; /* struct l_times_argv * */ + uarg[0] = (intptr_t)p->buf; /* struct l_times_argv * */ *n_args = 1; break; } @@ -888,7 +888,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 103: { struct linux_syslog_args *p = params; iarg[0] = p->type; /* l_int */ - uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[1] = (intptr_t)p->buf; /* char * */ iarg[2] = p->len; /* l_int */ *n_args = 3; break; @@ -965,7 +965,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 115: { struct linux_getgroups_args *p = params; iarg[0] = p->gidsetsize; /* l_int */ - uarg[1] = (intptr_t) p->grouplist; /* l_gid_t * */ + uarg[1] = (intptr_t)p->grouplist; /* l_gid_t * */ *n_args = 2; break; } @@ -973,7 +973,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 116: { struct linux_setgroups_args *p = params; iarg[0] = p->gidsetsize; /* l_int */ - uarg[1] = (intptr_t) p->grouplist; /* l_gid_t * */ + uarg[1] = (intptr_t)p->grouplist; /* l_gid_t * */ *n_args = 2; break; } @@ -989,9 +989,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* getresuid */ case 118: { struct getresuid_args *p = params; - uarg[0] = (intptr_t) p->ruid; /* uid_t * */ - uarg[1] = (intptr_t) p->euid; /* uid_t * */ - uarg[2] = (intptr_t) p->suid; /* uid_t * */ + uarg[0] = (intptr_t)p->ruid; /* uid_t * */ + uarg[1] = (intptr_t)p->euid; /* uid_t * */ + uarg[2] = (intptr_t)p->suid; /* uid_t * */ *n_args = 3; break; } @@ -1007,9 +1007,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* getresgid */ case 120: { struct getresgid_args *p = params; - uarg[0] = (intptr_t) p->rgid; /* gid_t * */ - uarg[1] = (intptr_t) p->egid; /* gid_t * */ - uarg[2] = (intptr_t) p->sgid; /* gid_t * */ + uarg[0] = (intptr_t)p->rgid; /* gid_t * */ + uarg[1] = (intptr_t)p->egid; /* gid_t * */ + uarg[2] = (intptr_t)p->sgid; /* gid_t * */ *n_args = 3; break; } @@ -1044,23 +1044,23 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_capget */ case 125: { struct linux_capget_args *p = params; - uarg[0] = (intptr_t) p->hdrp; /* struct l_user_cap_header * */ - uarg[1] = (intptr_t) p->datap; /* struct l_user_cap_data * */ + uarg[0] = (intptr_t)p->hdrp; /* struct l_user_cap_header * */ + uarg[1] = (intptr_t)p->datap; /* struct l_user_cap_data * */ *n_args = 2; break; } /* linux_capset */ case 126: { struct linux_capset_args *p = params; - uarg[0] = (intptr_t) p->hdrp; /* struct l_user_cap_header * */ - uarg[1] = (intptr_t) p->datap; /* struct l_user_cap_data * */ + uarg[0] = (intptr_t)p->hdrp; /* struct l_user_cap_header * */ + uarg[1] = (intptr_t)p->datap; /* struct l_user_cap_data * */ *n_args = 2; break; } /* linux_rt_sigpending */ case 127: { struct linux_rt_sigpending_args *p = params; - uarg[0] = (intptr_t) p->set; /* l_sigset_t * */ + uarg[0] = (intptr_t)p->set; /* l_sigset_t * */ iarg[1] = p->sigsetsize; /* l_size_t */ *n_args = 2; break; @@ -1068,9 +1068,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_rt_sigtimedwait */ case 128: { struct linux_rt_sigtimedwait_args *p = params; - uarg[0] = (intptr_t) p->mask; /* l_sigset_t * */ - uarg[1] = (intptr_t) p->ptr; /* l_siginfo_t * */ - uarg[2] = (intptr_t) p->timeout; /* struct l_timeval * */ + uarg[0] = (intptr_t)p->mask; /* l_sigset_t * */ + uarg[1] = (intptr_t)p->ptr; /* l_siginfo_t * */ + uarg[2] = (intptr_t)p->timeout; /* struct l_timeval * */ iarg[3] = p->sigsetsize; /* l_size_t */ *n_args = 4; break; @@ -1080,14 +1080,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_rt_sigqueueinfo_args *p = params; iarg[0] = p->pid; /* l_pid_t */ iarg[1] = p->sig; /* l_int */ - uarg[2] = (intptr_t) p->info; /* l_siginfo_t * */ + uarg[2] = (intptr_t)p->info; /* l_siginfo_t * */ *n_args = 3; break; } /* linux_rt_sigsuspend */ case 130: { struct linux_rt_sigsuspend_args *p = params; - uarg[0] = (intptr_t) p->newset; /* l_sigset_t * */ + uarg[0] = (intptr_t)p->newset; /* l_sigset_t * */ iarg[1] = p->sigsetsize; /* l_size_t */ *n_args = 2; break; @@ -1095,23 +1095,23 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_sigaltstack */ case 131: { struct linux_sigaltstack_args *p = params; - uarg[0] = (intptr_t) p->uss; /* l_stack_t * */ - uarg[1] = (intptr_t) p->uoss; /* l_stack_t * */ + uarg[0] = (intptr_t)p->uss; /* l_stack_t * */ + uarg[1] = (intptr_t)p->uoss; /* l_stack_t * */ *n_args = 2; break; } /* linux_utime */ case 132: { struct linux_utime_args *p = params; - uarg[0] = (intptr_t) p->fname; /* char * */ - uarg[1] = (intptr_t) p->times; /* struct l_utimbuf * */ + uarg[0] = (intptr_t)p->fname; /* char * */ + uarg[1] = (intptr_t)p->times; /* struct l_utimbuf * */ *n_args = 2; break; } /* linux_mknod */ case 133: { struct linux_mknod_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->mode; /* l_mode_t */ iarg[2] = p->dev; /* l_uint */ *n_args = 3; @@ -1128,15 +1128,15 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 136: { struct linux_ustat_args *p = params; iarg[0] = p->dev; /* l_uint */ - uarg[1] = (intptr_t) p->ubuf; /* struct l_ustat * */ + uarg[1] = (intptr_t)p->ubuf; /* struct l_ustat * */ *n_args = 2; break; } /* linux_statfs */ case 137: { struct linux_statfs_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ - uarg[1] = (intptr_t) p->buf; /* struct l_statfs_buf * */ + uarg[0] = (intptr_t)p->path; /* char * */ + uarg[1] = (intptr_t)p->buf; /* struct l_statfs_buf * */ *n_args = 2; break; } @@ -1144,7 +1144,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 138: { struct linux_fstatfs_args *p = params; iarg[0] = p->fd; /* l_uint */ - uarg[1] = (intptr_t) p->buf; /* struct l_statfs_buf * */ + uarg[1] = (intptr_t)p->buf; /* struct l_statfs_buf * */ *n_args = 2; break; } @@ -1178,7 +1178,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 142: { struct linux_sched_setparam_args *p = params; iarg[0] = p->pid; /* l_pid_t */ - uarg[1] = (intptr_t) p->param; /* struct sched_param * */ + uarg[1] = (intptr_t)p->param; /* struct sched_param * */ *n_args = 2; break; } @@ -1186,7 +1186,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 143: { struct linux_sched_getparam_args *p = params; iarg[0] = p->pid; /* l_pid_t */ - uarg[1] = (intptr_t) p->param; /* struct sched_param * */ + uarg[1] = (intptr_t)p->param; /* struct sched_param * */ *n_args = 2; break; } @@ -1195,7 +1195,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct linux_sched_setscheduler_args *p = params; iarg[0] = p->pid; /* l_pid_t */ iarg[1] = p->policy; /* l_int */ - uarg[2] = (intptr_t) p->param; /* struct sched_param * */ + uarg[2] = (intptr_t)p->param; /* struct sched_param * */ *n_args = 3; break; } @@ -1224,14 +1224,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 148: { struct linux_sched_rr_get_interval_args *p = params; iarg[0] = p->pid; /* l_pid_t */ - uarg[1] = (intptr_t) p->interval; /* struct l_timespec * */ + uarg[1] = (intptr_t)p->interval; /* struct l_timespec * */ *n_args = 2; break; } /* mlock */ case 149: { struct mlock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ + uarg[0] = (intptr_t)p->addr; /* const void * */ uarg[1] = p->len; /* size_t */ *n_args = 2; break; @@ -1239,7 +1239,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* munlock */ case 150: { struct munlock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ + uarg[0] = (intptr_t)p->addr; /* const void * */ uarg[1] = p->len; /* size_t */ *n_args = 2; break; @@ -1274,7 +1274,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_sysctl */ case 156: { struct linux_sysctl_args *p = params; - uarg[0] = (intptr_t) p->args; /* struct l___sysctl_args * */ + uarg[0] = (intptr_t)p->args; /* struct l___sysctl_args * */ *n_args = 1; break; } @@ -1306,14 +1306,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 160: { struct linux_setrlimit_args *p = params; iarg[0] = p->resource; /* l_uint */ - uarg[1] = (intptr_t) p->rlim; /* struct l_rlimit * */ + uarg[1] = (intptr_t)p->rlim; /* struct l_rlimit * */ *n_args = 2; break; } /* chroot */ case 161: { struct chroot_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ *n_args = 1; break; } @@ -1325,33 +1325,33 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* acct */ case 163: { struct acct_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ *n_args = 1; break; } /* settimeofday */ case 164: { struct settimeofday_args *p = params; - uarg[0] = (intptr_t) p->tv; /* struct l_timeval * */ - uarg[1] = (intptr_t) p->tzp; /* struct timezone * */ + uarg[0] = (intptr_t)p->tv; /* struct l_timeval * */ + uarg[1] = (intptr_t)p->tzp; /* struct timezone * */ *n_args = 2; break; } /* linux_mount */ case 165: { struct linux_mount_args *p = params; - uarg[0] = (intptr_t) p->specialfile; /* char * */ - uarg[1] = (intptr_t) p->dir; /* char * */ - uarg[2] = (intptr_t) p->filesystemtype; /* char * */ + uarg[0] = (intptr_t)p->specialfile; /* char * */ + uarg[1] = (intptr_t)p->dir; /* char * */ + uarg[2] = (intptr_t)p->filesystemtype; /* char * */ iarg[3] = p->rwflag; /* l_ulong */ - uarg[4] = (intptr_t) p->data; /* void * */ + uarg[4] = (intptr_t)p->data; /* void * */ *n_args = 5; break; } /* linux_umount */ case 166: { struct linux_umount_args *p = params; - uarg[0] = (intptr_t) p->path; /* char * */ + uarg[0] = (intptr_t)p->path; /* char * */ iarg[1] = p->flags; /* l_int */ *n_args = 2; break; @@ -1359,7 +1359,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* swapon */ case 167: { struct swapon_args *p = params; - uarg[0] = (intptr_t) p->name; /* char * */ + uarg[0] = (intptr_t)p->name; /* char * */ *n_args = 1; break; } @@ -1374,14 +1374,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) iarg[0] = p->magic1; /* l_int */ iarg[1] = p->magic2; /* l_int */ iarg[2] = p->cmd; /* l_uint */ - uarg[3] = (intptr_t) p->arg; /* void * */ + uarg[3] = (intptr_t)p->arg; /* void * */ *n_args = 4; break; } /* linux_sethostname */ case 170: { struct linux_sethostname_args *p = params; - uarg[0] = (intptr_t) p->hostname; /* char * */ + uarg[0] = (intptr_t)p->hostname; /* char * */ iarg[1] = p->len; /* l_int */ *n_args = 2; break; @@ -1389,7 +1389,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_setdomainname */ case 171: { struct linux_setdomainname_args *p = params; - uarg[0] = (intptr_t) p->name; /* char * */ + uarg[0] = (intptr_t)p->name; /* char * */ iarg[1] = p->len; /* l_int */ *n_args = 2; break; @@ -1434,9 +1434,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_setxattr */ case 188: { struct linux_setxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* const char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* const char * */ iarg[3] = p->size; /* l_size_t */ iarg[4] = p->flags; /* l_int */ *n_args = 5; @@ -1445,9 +1445,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_lsetxattr */ case 189: { struct linux_lsetxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* const char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* const char * */ iarg[3] = p->size; /* l_size_t */ iarg[4] = p->flags; /* l_int */ *n_args = 5; @@ -1457,8 +1457,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 190: { struct linux_fsetxattr_args *p = params; iarg[0] = p->fd; /* l_int */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* const char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* const char * */ iarg[3] = p->size; /* l_size_t */ iarg[4] = p->flags; /* l_int */ *n_args = 5; @@ -1467,9 +1467,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_getxattr */ case 191: { struct linux_getxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* char * */ iarg[3] = p->size; /* l_size_t */ *n_args = 4; break; @@ -1477,9 +1477,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_lgetxattr */ case 192: { struct linux_lgetxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* char * */ iarg[3] = p->size; /* l_size_t */ *n_args = 4; break; @@ -1488,8 +1488,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 193: { struct linux_fgetxattr_args *p = params; iarg[0] = p->fd; /* l_int */ - uarg[1] = (intptr_t) p->name; /* const char * */ - uarg[2] = (intptr_t) p->value; /* char * */ + uarg[1] = (intptr_t)p->name; /* const char * */ + uarg[2] = (intptr_t)p->value; /* char * */ iarg[3] = p->size; /* l_size_t */ *n_args = 4; break; @@ -1497,8 +1497,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_listxattr */ case 194: { struct linux_listxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->list; /* const char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->list; /* const char * */ iarg[2] = p->size; /* l_size_t */ *n_args = 3; break; @@ -1506,8 +1506,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_llistxattr */ case 195: { struct linux_llistxattr_args *p = params; - uarg[0] = (intptr_t) p->path; /* const char * */ - uarg[1] = (intptr_t) p->list; /* const char * */ + uarg[0] = (intptr_t)p->path; /* const char * */ + uarg[1] = (intptr_t)p->list; /* const char * */ iarg[2] = p->size; /* l_size_t */ *n_args = 3; break; @@ -1516,7 +1516,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 196: { struct linux_flistxattr_args *p = params; iarg[0] = p->fd; /* l_int */ - uarg[1] = (intptr_t) p->list; /* const char * */ + uarg[1] = (intptr_t)p->list; /* const char * */ iarg[2] = p->size; /* l_size_t */ *n_args = 3; break; @@ -1524,16 +1524,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* linux_removexattr */ *** 33954 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Thu May 13 18:25:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ABC4262A5E8; Thu, 13 May 2021 18:25:34 +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 4Fh0TB4VvYz3l67; Thu, 13 May 2021 18:25:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8D6B423954; Thu, 13 May 2021 18:25:34 +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 14DIPYvB061158; Thu, 13 May 2021 18:25:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DIPYUw061157; Thu, 13 May 2021 18:25:34 GMT (envelope-from git) Date: Thu, 13 May 2021 18:25:34 GMT Message-Id: <202105131825.14DIPYUw061157@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 0b426a1c2cef - main - modules: Only build sdhci_fdt for arm and arm64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b426a1c2cef14ded10ded6ec737d5c116182996 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 18:25:34 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=0b426a1c2cef14ded10ded6ec737d5c116182996 commit 0b426a1c2cef14ded10ded6ec737d5c116182996 Author: Emmanuel Vadot AuthorDate: 2021-05-13 18:23:59 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 18:23:59 +0000 modules: Only build sdhci_fdt for arm and arm64 Other FDT platform (like powerpc64* or riscv64) don't have gpio built by default so just compile the module for those two arches. Fixes: 9e08f82058cb ("modules: Add sdhci_fdt module") --- sys/modules/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 6a5097e9ded0..fb2481140345 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -491,7 +491,6 @@ SUBDIR+= iscsi_initiator .if !empty(OPT_FDT) SUBDIR+= fdt -_sdhci_fdt= sdhci_fdt .endif # Linuxulator @@ -618,6 +617,10 @@ _em= em _rockchip= rockchip .endif +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" +_sdhci_fdt= sdhci_fdt +.endif + .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _agp= agp _an= an From owner-dev-commits-src-all@freebsd.org Thu May 13 18:26:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56E2B62AA06; Thu, 13 May 2021 18:26:34 +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 4Fh0VL21gnz3lCR; Thu, 13 May 2021 18:26:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 38B6323BD8; Thu, 13 May 2021 18:26:34 +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 14DIQYQZ061393; Thu, 13 May 2021 18:26:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DIQYra061392; Thu, 13 May 2021 18:26:34 GMT (envelope-from git) Date: Thu, 13 May 2021 18:26:34 GMT Message-Id: <202105131826.14DIQYra061392@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 28ce201269cd - main - UPDATING: fix spelling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28ce201269cdaf8c95b76b7cd1b08d10edce817e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 18:26:34 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=28ce201269cdaf8c95b76b7cd1b08d10edce817e commit 28ce201269cdaf8c95b76b7cd1b08d10edce817e Author: Emmanuel Vadot AuthorDate: 2021-05-13 18:26:10 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-13 18:26:10 +0000 UPDATING: fix spelling Reported by: pstef --- UPDATING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 36f9f1aea126..efccbf3b2fff 100644 --- a/UPDATING +++ b/UPDATING @@ -30,7 +30,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 14.x IS SLOW: 20210513: Commit ca179c4d74f2 changed the package in which the OpenSSL libraries and utilities are packaged. - It is recommanded for pkgbase user to do : + It is recommended for pkgbase user to do: pkg install -f FreeBSD-openssl before pkg upgrade otherwise some dependencies might not be met and pkg will stop working as libssl will not be present anymore From owner-dev-commits-src-all@freebsd.org Thu May 13 18:29:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B43B062AB9E; Thu, 13 May 2021 18:29:23 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fh0Yb05LKz3krB; Thu, 13 May 2021 18:29:22 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io1-f45.google.com with SMTP id n40so10075270ioz.4; Thu, 13 May 2021 11:29:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3lPG2G3JNnd2GYwR9ELP3g0q0AuvBWWVhlbj/hYn0lM=; b=QdmvV7677mb4X1+JPaqUcCuAVcRa0zf5luhQbuGlgfy4KTxgZuHw+JVs1KLntHcoBf a9XHQswXnj2pvu9L+b9B9ByUoxdUuD21ZToCLkTdofisyNJ5EaoIcWr3Bof4ktR06HTu TsXfw4sTCANe9mPupd2MlXCqatozkxlvvEFgbVT0LGCx338jfQuONPKdY2fQ54C9ios5 1Al8Hv7RAnp4y9h9dBv/lszoZH+AvqNUu+340+C5V3DIOsl8GW+/jEGFiJ6PUr6O6lb9 /arhTP27qo8k6p5tXNpefIq8apk/hio8HPPEe9t17pC+7tocp50DMF+o4glMvnv66WZf ZXtQ== X-Gm-Message-State: AOAM532tT7/irTJEikJ+aoawl0yd5i8ef1PI8GET30xg32JFiWrhy5Lz CwpZlG9prVmwq9L85JLQPWM1xxXwVklcI9S9QMbKY/14bSU= X-Google-Smtp-Source: ABdhPJzfTUlNIGNPeiJXGVX9myDwMN4s6TZkRznqw11oIXwgJGDjVOENjOcRAn89X4SQwkZM0TtPE0AcoDnYMPAlJk8= X-Received: by 2002:a6b:14d2:: with SMTP id 201mr31487031iou.15.1620930561326; Thu, 13 May 2021 11:29:21 -0700 (PDT) MIME-Version: 1.0 References: <202105131811.14DIBA1p045633@gitrepo.freebsd.org> In-Reply-To: <202105131811.14DIBA1p045633@gitrepo.freebsd.org> From: Ed Maste Date: Thu, 13 May 2021 14:28:51 -0400 Message-ID: Subject: Re: git: 2c9764f36b6f - main - regen syscall files after d51198d63b63 To: src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Fh0Yb05LKz3krB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of carpeddiem@gmail.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=carpeddiem@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEFALL_USER(0.00)[carpeddiem]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.166.45:from]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_ZRD(0.00)[209.85.166.45:from:127.0.2.255]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCVD_IN_DNSWL_NONE(0.00)[209.85.166.45:from]; FORGED_SENDER(0.30)[emaste@freebsd.org,carpeddiem@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.166.45:from]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[emaste@freebsd.org,carpeddiem@gmail.com]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 18:29:23 -0000 On Thu, 13 May 2021 at 14:11, Ed Maste wrote: > > The branch main has been updated by emaste: > > URL: https://cgit.FreeBSD.org/src/commit/?id=2c9764f36b6f20e9a6c71ce64a21988a394050b6 > > commit 2c9764f36b6f20e9a6c71ce64a21988a394050b6 > Author: Ed Maste > AuthorDate: 2021-05-13 17:58:04 +0000 > Commit: Ed Maste > CommitDate: 2021-05-13 18:09:58 +0000 > > regen syscall files after d51198d63b63 Oops I guess I rebased and didn't notice :( That should be "after ad385f7b46e7" From owner-dev-commits-src-all@freebsd.org Thu May 13 19:05:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52A0E62B871; Thu, 13 May 2021 19:05:05 +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 4Fh1Ln1vthz3myx; Thu, 13 May 2021 19:05:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 344572403F; Thu, 13 May 2021 19:05:05 +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 14DJ55Jf016314; Thu, 13 May 2021 19:05:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJ55w8016313; Thu, 13 May 2021 19:05:05 GMT (envelope-from git) Date: Thu, 13 May 2021 19:05:05 GMT Message-Id: <202105131905.14DJ55w8016313@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 4d8d74a4f52e - main - libpmc: remove unused PMC_MDEP_INIT_INTEL_V2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4d8d74a4f52efd078bd6298e0adbdd476ed70de9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:05:05 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4d8d74a4f52efd078bd6298e0adbdd476ed70de9 commit 4d8d74a4f52efd078bd6298e0adbdd476ed70de9 Author: Mitchell Horne AuthorDate: 2021-05-13 18:56:39 +0000 Commit: Mitchell Horne CommitDate: 2021-05-13 18:56:39 +0000 libpmc: remove unused PMC_MDEP_INIT_INTEL_V2 All uses of this macro were removed in e92a1350b50e. Remove cpu_has_iaf_counters as well. Reviewed by: ray, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30195 --- lib/libpmc/libpmc.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c index 512f3957962a..e66ec5822226 100644 --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -1367,10 +1367,6 @@ pmc_init(void) uint32_t abi_version; struct module_stat pmc_modstat; struct pmc_op_getcpuinfo op_cpu_info; -#if defined(__amd64__) || defined(__i386__) - int cpu_has_iaf_counters; - unsigned int t; -#endif if (pmc_syscall != -1) /* already inited */ return (0); @@ -1446,15 +1442,6 @@ pmc_init(void) #if defined(__amd64__) || defined(__i386__) if (cpu_info.pm_cputype != PMC_CPU_GENERIC) pmc_class_table[n++] = &tsc_class_table_descr; - - /* - * Check if this CPU has fixed function counters. - */ - cpu_has_iaf_counters = 0; - for (t = 0; t < cpu_info.pm_nclass; t++) - if (cpu_info.pm_classes[t].pm_class == PMC_CLASS_IAF && - cpu_info.pm_classes[t].pm_num > 0) - cpu_has_iaf_counters = 1; #endif #define PMC_MDEP_INIT(C) do { \ @@ -1464,15 +1451,6 @@ pmc_init(void) PMC_TABLE_SIZE(C##_pmc_classes); \ } while (0) -#define PMC_MDEP_INIT_INTEL_V2(C) do { \ - PMC_MDEP_INIT(C); \ - pmc_class_table[n++] = &iaf_class_table_descr; \ - if (!cpu_has_iaf_counters) \ - pmc_mdep_event_aliases = \ - C##_aliases_without_iaf; \ - pmc_class_table[n] = &C##_class_table_descr; \ - } while (0) - /* Configure the event name parser. */ switch (cpu_info.pm_cputype) { #if defined(__amd64__) || defined(__i386__) From owner-dev-commits-src-all@freebsd.org Thu May 13 19:05:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85B1F62BAA8; Thu, 13 May 2021 19:05:06 +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 4Fh1Lp31RHz3mm7; Thu, 13 May 2021 19:05:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 57A3C24320; Thu, 13 May 2021 19:05:06 +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 14DJ56aP016335; Thu, 13 May 2021 19:05:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJ56kv016334; Thu, 13 May 2021 19:05:06 GMT (envelope-from git) Date: Thu, 13 May 2021 19:05:06 GMT Message-Id: <202105131905.14DJ56kv016334@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: da13ef6aa056 - main - libpmc: remove PMC_MDEP_TABLE logic MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da13ef6aa0565c8d79326bba5606671062033bbf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:05:06 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=da13ef6aa0565c8d79326bba5606671062033bbf commit da13ef6aa0565c8d79326bba5606671062033bbf Author: Mitchell Horne AuthorDate: 2021-05-13 19:00:07 +0000 Commit: Mitchell Horne CommitDate: 2021-05-13 19:01:19 +0000 libpmc: remove PMC_MDEP_TABLE logic This logic was added for handling some of the complicated relationships between events and x86 CPU models. Since that logic has been mostly removed from libpmc(3) in favor of pmu-events, this no longer serves much of a purpose. Mapping CPU types to event tables is already handled by the switch statement in pmc_init(). Reviewed by: ray, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30196 --- lib/libpmc/libpmc.c | 54 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c index e66ec5822226..6636c974cb73 100644 --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -177,32 +177,6 @@ static const struct pmc_event_descr cortex_a76_event_table[] = __PMC_EV_ALIAS_ARMV8_CORTEX_A76() }; -/* - * PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...) - * - * Map a CPU to the PMC classes it supports. - */ -#define PMC_MDEP_TABLE(N,C,...) \ - static const enum pmc_class N##_pmc_classes[] = { \ - PMC_CLASS_##C, __VA_ARGS__ \ - } - -PMC_MDEP_TABLE(k8, K8, PMC_CLASS_SOFT, PMC_CLASS_TSC); -PMC_MDEP_TABLE(beri, BERI, PMC_CLASS_SOFT, PMC_CLASS_BERI); -PMC_MDEP_TABLE(cortex_a8, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7); -PMC_MDEP_TABLE(cortex_a9, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7); -PMC_MDEP_TABLE(cortex_a53, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8); -PMC_MDEP_TABLE(cortex_a57, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8); -PMC_MDEP_TABLE(cortex_a76, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8); -PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K); -PMC_MDEP_TABLE(mips74k, MIPS74K, PMC_CLASS_SOFT, PMC_CLASS_MIPS74K); -PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON); -PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_SOFT, PMC_CLASS_PPC7450, PMC_CLASS_TSC); -PMC_MDEP_TABLE(ppc970, PPC970, PMC_CLASS_SOFT, PMC_CLASS_PPC970, PMC_CLASS_TSC); -PMC_MDEP_TABLE(power8, POWER8, PMC_CLASS_SOFT, PMC_CLASS_POWER8, PMC_CLASS_TSC); -PMC_MDEP_TABLE(e500, E500, PMC_CLASS_SOFT, PMC_CLASS_E500, PMC_CLASS_TSC); -PMC_MDEP_TABLE(generic, SOFT, PMC_CLASS_SOFT); - static const struct pmc_event_descr tsc_event_table[] = { __PMC_EV_TSC() @@ -264,9 +238,6 @@ static struct pmc_class_descr soft_class_table_descr = static const struct pmc_class_descr **pmc_class_table; #define PMC_CLASS_TABLE_SIZE cpu_info.pm_nclass -static const enum pmc_class *pmc_mdep_class_list; -static size_t pmc_mdep_class_list_size; - /* * Mapping tables, mapping enumeration values to human readable * strings. @@ -985,17 +956,6 @@ pmc_match_event_class(const char *name, return (NULL); } -static int -pmc_mdep_is_compatible_class(enum pmc_class pc) -{ - size_t n; - - for (n = 0; n < pmc_mdep_class_list_size; n++) - if (pmc_mdep_class_list[n] == pc) - return (1); - return (0); -} - /* * API entry points */ @@ -1070,9 +1030,8 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode, ev = NULL; for (n = 0; n < PMC_CLASS_TABLE_SIZE; n++) { pcd = pmc_class_table[n]; - if (pcd && pmc_mdep_is_compatible_class(pcd->pm_evc_class) && - strncasecmp(ctrname, pcd->pm_evc_name, - pcd->pm_evc_name_size) == 0) { + if (pcd != NULL && strncasecmp(ctrname, pcd->pm_evc_name, + pcd->pm_evc_name_size) == 0) { if ((ev = pmc_match_event_class(ctrname + pcd->pm_evc_name_size, pcd)) == NULL) { errno = EINVAL; @@ -1088,7 +1047,7 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode, */ for (n = 0; ev == NULL && n < PMC_CLASS_TABLE_SIZE; n++) { pcd = pmc_class_table[n]; - if (pcd && pmc_mdep_is_compatible_class(pcd->pm_evc_class)) + if (pcd != NULL) ev = pmc_match_event_class(ctrname, pcd); } @@ -1444,12 +1403,7 @@ pmc_init(void) pmc_class_table[n++] = &tsc_class_table_descr; #endif -#define PMC_MDEP_INIT(C) do { \ - pmc_mdep_event_aliases = C##_aliases; \ - pmc_mdep_class_list = C##_pmc_classes; \ - pmc_mdep_class_list_size = \ - PMC_TABLE_SIZE(C##_pmc_classes); \ - } while (0) +#define PMC_MDEP_INIT(C) pmc_mdep_event_aliases = C##_aliases /* Configure the event name parser. */ switch (cpu_info.pm_cputype) { From owner-dev-commits-src-all@freebsd.org Thu May 13 19:05:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E047562BB39; Thu, 13 May 2021 19:05:07 +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 4Fh1Lq5Xspz3mmF; Thu, 13 May 2021 19:05:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 89987242FC; Thu, 13 May 2021 19:05:07 +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 14DJ57aa016358; Thu, 13 May 2021 19:05:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJ57pA016357; Thu, 13 May 2021 19:05:07 GMT (envelope-from git) Date: Thu, 13 May 2021 19:05:07 GMT Message-Id: <202105131905.14DJ57pA016357@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: dfdc57e8aa8b - main - libpmc: fall-back to kernel tables if pmu-events fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfdc57e8aa8ba4b4e4484f736e8c7645ab69b54a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:05:08 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=dfdc57e8aa8ba4b4e4484f736e8c7645ab69b54a commit dfdc57e8aa8ba4b4e4484f736e8c7645ab69b54a Author: Mitchell Horne AuthorDate: 2021-05-13 18:57:37 +0000 Commit: Mitchell Horne CommitDate: 2021-05-13 19:01:24 +0000 libpmc: fall-back to kernel tables if pmu-events fails On x86, the pmu_events table is the source of truth for finding supported events. However, events not found there may still be present in the kernel's static event tables. For example, the pmc.soft(3) events will never be available from pmu-events. Update pmc_allocate() to search the legacy event tables if pmc_pmu_pmcallocate() fails to return a result. This allows both event sources to be consulted before giving up, thus restoring pmc.soft(3) and pmc.tsc(3) on x86. Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30216 --- lib/libpmc/libpmc.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c index 6636c974cb73..e2422f167267 100644 --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -989,25 +989,25 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode, pmc_config.pm_count = count; if (PMC_IS_SAMPLING_MODE(mode)) pmc_config.pm_caps |= PMC_CAP_INTERRUPT; + /* - * Can we pull this straight from the pmu table? + * Try to pull the raw event ID directly from the pmu-events table. If + * this is unsupported on the platform, or the event is not found, + * continue with searching the regular event tables. */ r = spec_copy = strdup(ctrspec); ctrname = strsep(&r, ","); if (pmc_pmu_enabled()) { - if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) { - if (PMC_CALL(PMCALLOCATE, &pmc_config) < 0) { - goto out; - } - retval = 0; - *pmcid = pmc_config.pm_pmcid; - goto out; - } - errx(EX_USAGE, "ERROR: pmc_pmu_allocate failed, check for ctrname %s\n", ctrname); - } else { - free(spec_copy); - spec_copy = NULL; + if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) + goto found; + + /* Otherwise, reset any changes */ + pmc_config.pm_ev = 0; + pmc_config.pm_caps = 0; + pmc_config.pm_class = 0; } + free(spec_copy); + spec_copy = NULL; /* replace an event alias with the canonical event specifier */ if (pmc_mdep_event_aliases) @@ -1064,14 +1064,12 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode, goto out; } - if (PMC_CALL(PMCALLOCATE, &pmc_config) < 0) - goto out; - - *pmcid = pmc_config.pm_pmcid; - - retval = 0; - - out: +found: + if (PMC_CALL(PMCALLOCATE, &pmc_config) == 0) { + *pmcid = pmc_config.pm_pmcid; + retval = 0; + } +out: if (spec_copy) free(spec_copy); From owner-dev-commits-src-all@freebsd.org Thu May 13 19:05:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C27A662BAAA; Thu, 13 May 2021 19:05:08 +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 4Fh1Lr4yzqz3mxM; Thu, 13 May 2021 19:05:08 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9B48423C73; Thu, 13 May 2021 19:05:08 +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 14DJ58mr016388; Thu, 13 May 2021 19:05:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJ58cG016387; Thu, 13 May 2021 19:05:08 GMT (envelope-from git) Date: Thu, 13 May 2021 19:05:08 GMT Message-Id: <202105131905.14DJ58cG016387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: f59127dac5ca - main - hwpmc: fix PMC_CPU_LAST MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f59127dac5ca0be3648ecc0a031a21e472afb133 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:05:08 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=f59127dac5ca0be3648ecc0a031a21e472afb133 commit f59127dac5ca0be3648ecc0a031a21e472afb133 Author: Mitchell Horne AuthorDate: 2021-05-05 18:40:39 +0000 Commit: Mitchell Horne CommitDate: 2021-05-13 19:02:59 +0000 hwpmc: fix PMC_CPU_LAST It is unused, but incorrect. MFC after: 3 days Sponsored by: The FreeBSD Foundation --- sys/sys/pmc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/pmc.h b/sys/sys/pmc.h index 1486c7aa91c7..9328a7bdfa05 100644 --- a/sys/sys/pmc.h +++ b/sys/sys/pmc.h @@ -138,7 +138,7 @@ enum pmc_cputype { }; #define PMC_CPU_FIRST PMC_CPU_AMD_K7 -#define PMC_CPU_LAST PMC_CPU_GENERIC +#define PMC_CPU_LAST PMC_CPU_ARMV8_CORTEX_A76 /* * Classes of PMCs From owner-dev-commits-src-all@freebsd.org Thu May 13 19:18:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E7AE62C501; Thu, 13 May 2021 19:18:30 +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 4Fh1fG382Jz3nlx; Thu, 13 May 2021 19:18:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5ED3224273; Thu, 13 May 2021 19:18:30 +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 14DJIUcn030196; Thu, 13 May 2021 19:18:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJIU4i030195; Thu, 13 May 2021 19:18:30 GMT (envelope-from git) Date: Thu, 13 May 2021 19:18:30 GMT Message-Id: <202105131918.14DJIU4i030195@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 4dfe70fdbda0 - main - netgraph/ng_bridge: Avoid cache thrashing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4dfe70fdbda05453e824bc9edfc0d09eab7b2929 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:18:30 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=4dfe70fdbda05453e824bc9edfc0d09eab7b2929 commit 4dfe70fdbda05453e824bc9edfc0d09eab7b2929 Author: Lutz Donnerhacke AuthorDate: 2021-02-11 22:59:11 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-13 19:14:36 +0000 netgraph/ng_bridge: Avoid cache thrashing Hint the compiler, that this update is needed at most once per second. Only in this case the memory line needs to be written. This will reduce the amount of cache trashing during forward of most frames. Suggested by: zec Approved by: zec MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28601 --- sys/netgraph/ng_bridge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 470c0f05f18d..820c93515490 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -788,7 +788,8 @@ ng_bridge_rcvdata(hook_p hook, item_p item) * This is safe without locking, because it's * the only operation during shared access. */ - host->staleness = 0; + if (__predict_false(host->staleness > 0)) + host->staleness = 0; if ((host == NULL && ctx.incoming->learnMac) || (host != NULL && host->link != ctx.incoming)) { From owner-dev-commits-src-all@freebsd.org Thu May 13 19:51:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2654B62D087; Thu, 13 May 2021 19:51: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 4Fh2Mn0g1Zz3q34; Thu, 13 May 2021 19:51:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0A20924C43; Thu, 13 May 2021 19:51:01 +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 14DJp0c8079067; Thu, 13 May 2021 19:51:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14DJp00l079066; Thu, 13 May 2021 19:51:00 GMT (envelope-from git) Date: Thu, 13 May 2021 19:51:00 GMT Message-Id: <202105131951.14DJp00l079066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: a56e5ad69030 - main - netgraph/ng_bridge: Handle send errors during loop handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a56e5ad6903037861457da754574b4903dcb0e7e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 19:51:01 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=a56e5ad6903037861457da754574b4903dcb0e7e commit a56e5ad6903037861457da754574b4903dcb0e7e Author: Lutz Donnerhacke AuthorDate: 2021-04-27 07:49:50 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-13 19:49:20 +0000 netgraph/ng_bridge: Handle send errors during loop handling If sending out a packet fails during the loop over all links, the allocated memory is leaked and not all links receive a copy. This patch fixes those problems, clarifies a premature abort of the loop, and fixes a minory style(9) bug. PR: 255430 Submitted by: Dancho Penev Tested by: Dancho Penev MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30008 --- sys/netgraph/ng_bridge.c | 55 ++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 820c93515490..f77012d42d1c 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -663,22 +663,28 @@ ng_bridge_send_data(link_cp dst, int manycast, struct mbuf *m, item_p item) { else NG_SEND_DATA_ONLY(error, dst->hook, m); - if (error == 0) { - counter_u64_add(dst->stats.xmitPackets, 1); - counter_u64_add(dst->stats.xmitOctets, len); - switch (manycast) { - default: /* unknown unicast */ - break; - case 1: /* multicast */ - counter_u64_add(dst->stats.xmitMulticasts, 1); - break; - case 2: /* broadcast */ - counter_u64_add(dst->stats.xmitBroadcasts, 1); - break; - } + if (error) { + /* The packet is still ours */ + if (item != NULL) + NG_FREE_ITEM(item); + if (m != NULL) + NG_FREE_M(m); + return (error); } - return (error); + counter_u64_add(dst->stats.xmitPackets, 1); + counter_u64_add(dst->stats.xmitOctets, len); + switch (manycast) { + default: /* unknown unicast */ + break; + case 1: /* multicast */ + counter_u64_add(dst->stats.xmitMulticasts, 1); + break; + case 2: /* broadcast */ + counter_u64_add(dst->stats.xmitBroadcasts, 1); + break; + } + return (0); } /* @@ -716,16 +722,16 @@ ng_bridge_send_ctx(hook_p dst, void *arg) * It's usable link but not the reserved (first) one. * Copy mbuf info for sending. */ - m2 = m_dup(ctx->m, M_NOWAIT); /* XXX m_copypacket() */ + m2 = m_dup(ctx->m, M_NOWAIT); if (m2 == NULL) { counter_u64_add(ctx->incoming->stats.memoryFailures, 1); ctx->error = ENOBUFS; - return (0); /* abort loop */ + return (0); /* abort loop, do not try again and again */ } /* Send packet */ error = ng_bridge_send_data(destLink, ctx->manycast, m2, NULL); - if(error) + if (error) ctx->error = error; return (1); } @@ -859,18 +865,17 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Distribute unknown, multicast, broadcast pkts to all other links */ NG_NODE_FOREACH_HOOK(node, ng_bridge_send_ctx, &ctx, ret); - /* If we never saw a good link, leave. */ - if (ctx.foundFirst == NULL || ctx.error != 0) { + /* Finally send out on the first link found */ + if (ctx.foundFirst != NULL) { + int error = ng_bridge_send_data(ctx.foundFirst, ctx.manycast, ctx.m, item); + if (error) + ctx.error = error; + } else { /* nothing to send at all */ NG_FREE_ITEM(item); NG_FREE_M(ctx.m); - return (ctx.error); } - /* - * If we've sent all the others, send the original - * on the first link we found. - */ - return (ng_bridge_send_data(ctx.foundFirst, ctx.manycast, ctx.m, item)); + return (ctx.error); } /* From owner-dev-commits-src-all@freebsd.org Fri May 14 07:19:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 13F0363B97E; Fri, 14 May 2021 07:19:20 +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 4FhKf002DDz4nwh; Fri, 14 May 2021 07:19:20 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E39715B56; Fri, 14 May 2021 07:19:19 +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 14E7JJrO085818; Fri, 14 May 2021 07:19:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14E7JJdp085817; Fri, 14 May 2021 07:19:19 GMT (envelope-from git) Date: Fri, 14 May 2021 07:19:19 GMT Message-Id: <202105140719.14E7JJdp085817@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 2a60dec0919c - main - stress2: Added a regression test. Fixed a type on an old test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2a60dec0919c20a03c2830a9466a86f9f44fbaf0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 07:19:20 -0000 The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=2a60dec0919c20a03c2830a9466a86f9f44fbaf0 commit 2a60dec0919c20a03c2830a9466a86f9f44fbaf0 Author: Peter Holm AuthorDate: 2021-05-14 07:18:39 +0000 Commit: Peter Holm CommitDate: 2021-05-14 07:18:39 +0000 stress2: Added a regression test. Fixed a type on an old test --- tools/test/stress2/misc/open2.sh | 45 ++++++++++++++++++++++++++++++++++++++ tools/test/stress2/misc/rename2.sh | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/test/stress2/misc/open2.sh b/tools/test/stress2/misc/open2.sh new file mode 100755 index 000000000000..7c0994bfd4e4 --- /dev/null +++ b/tools/test/stress2/misc/open2.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# open(2) and openat(2) syscall fuzz test + +# umount(8) returns busy +# https://people.freebsd.org/~pho/stress/log/log0111.txt +# Fixed by: cef8a95acbae + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +snums=`grep -Ew 'SYS_open|SYS_openat' /usr/include/sys/syscall.h 2>/dev/null | + awk '{print $NF}'` + [ -z "$snums" ] && exit 0 +for i in $snums; do + ./syscall4.sh $i; s=$? + [ $s -ne 0 ] && break +done +exit $s diff --git a/tools/test/stress2/misc/rename2.sh b/tools/test/stress2/misc/rename2.sh index 2c9781602d2c..085a424a98f2 100755 --- a/tools/test/stress2/misc/rename2.sh +++ b/tools/test/stress2/misc/rename2.sh @@ -40,7 +40,7 @@ cd $here rm -rf /tmp/rename.dir.* start=`date +%s` -while [ $((`date +%s` - start -lt 300 ]; do +while [ $((`date +%s` - start)) -lt 300 ]; do for j in `jot 10`; do /tmp/rename2 & done From owner-dev-commits-src-all@freebsd.org Fri May 14 08:53:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D3F4263E618; Fri, 14 May 2021 08:53:21 +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 4FhMkT5g7mz4tCl; Fri, 14 May 2021 08:53:21 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B55CB6EF9; Fri, 14 May 2021 08:53: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 14E8rLfm017292; Fri, 14 May 2021 08:53:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14E8rLvK017291; Fri, 14 May 2021 08:53:21 GMT (envelope-from git) Date: Fri, 14 May 2021 08:53:21 GMT Message-Id: <202105140853.14E8rLvK017291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: ffd61af32cf7 - main - sdhci_fsl_fdt.c: Add support for LS1028a. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ffd61af32cf76f2e59cf11a0242d327f6c24c1f0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 08:53:21 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=ffd61af32cf76f2e59cf11a0242d327f6c24c1f0 commit ffd61af32cf76f2e59cf11a0242d327f6c24c1f0 Author: Marcin Wojtas AuthorDate: 2021-04-15 13:19:13 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-14 08:28:09 +0000 sdhci_fsl_fdt.c: Add support for LS1028a. Add data specific for SoC, including all necessary quirks. Submitted by: Lukasz Hajec Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30121 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 167c28b60ca0..695176a17218 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -111,6 +111,12 @@ struct sdhci_fsl_fdt_soc_data { int baseclk_div; }; +static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1028a_soc_data = { + .quirks = SDHCI_QUIRK_DONT_SET_HISPD_BIT | + SDHCI_QUIRK_BROKEN_AUTO_STOP | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK, + .baseclk_div = 2, +}; + static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_ls1046a_soc_data = { .quirks = SDHCI_QUIRK_DONT_SET_HISPD_BIT | SDHCI_QUIRK_BROKEN_AUTO_STOP, .baseclk_div = 2, @@ -122,6 +128,7 @@ static const struct sdhci_fsl_fdt_soc_data sdhci_fsl_fdt_gen_data = { }; static const struct ofw_compat_data sdhci_fsl_fdt_compat_data[] = { + {"fsl,ls1028a-esdhc", (uintptr_t)&sdhci_fsl_fdt_ls1028a_soc_data}, {"fsl,ls1046a-esdhc", (uintptr_t)&sdhci_fsl_fdt_ls1046a_soc_data}, {"fsl,esdhc", (uintptr_t)&sdhci_fsl_fdt_gen_data}, {NULL, 0} From owner-dev-commits-src-all@freebsd.org Fri May 14 08:53:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2774C63E817; Fri, 14 May 2021 08:53:23 +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 4FhMkW09V7z4tJM; Fri, 14 May 2021 08:53:22 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E0EAB725D; Fri, 14 May 2021 08:53:22 +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 14E8rMXr017313; Fri, 14 May 2021 08:53:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14E8rMEC017312; Fri, 14 May 2021 08:53:22 GMT (envelope-from git) Date: Fri, 14 May 2021 08:53:22 GMT Message-Id: <202105140853.14E8rMEC017312@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: f0a9d7d79956 - main - sdhci_fsl_fdt.c: Add a missing call to mmc_fdt_parse. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f0a9d7d7995641901e3132242d1d9bf22dc333f6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 08:53:23 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=f0a9d7d7995641901e3132242d1d9bf22dc333f6 commit f0a9d7d7995641901e3132242d1d9bf22dc333f6 Author: Marcin Wojtas AuthorDate: 2021-04-22 10:54:41 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-14 08:29:31 +0000 sdhci_fsl_fdt.c: Add a missing call to mmc_fdt_parse. Add a missing call to mmc_fdt_parse, without it some dts properties are not parsed. Submitted by: Lukasz Hajec Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30122 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 110 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 695176a17218..c2330a679963 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -96,11 +97,13 @@ struct sdhci_fsl_fdt_softc { struct resource *irq_res; void *irq_cookie; uint32_t baseclk_hz; + uint32_t maxclk_hz; struct sdhci_fdt_gpio *gpio; struct sdhci_slot slot; bool slot_init_done; uint32_t cmd_and_mode; uint16_t sdclk_bits; + struct mmc_fdt_helper fdt_helper; uint32_t (* read)(struct sdhci_fsl_fdt_softc *, bus_size_t); void (* write)(struct sdhci_fsl_fdt_softc *, bus_size_t, uint32_t); @@ -194,9 +197,9 @@ fsl_sdhc_fdt_set_clock(struct sdhci_fsl_fdt_softc *sc, uint16_t val) ((val >> SDHCI_DIVIDER_HI_SHIFT) & SDHCI_DIVIDER_HI_MASK) << SDHCI_DIVIDER_MASK_LEN; if (div == 0) - freq = sc->baseclk_hz; + freq = sc->maxclk_hz; else - freq = sc->baseclk_hz / (2 * div); + freq = sc->maxclk_hz / (2 * div); for (prescale = 2; freq < sc->baseclk_hz / (prescale * 16); ) prescale <<= 1; @@ -445,6 +448,86 @@ sdhci_fsl_fdt_irq(void *arg) return; } +static int +sdhci_fsl_fdt_update_ios(device_t brdev, device_t reqdev) +{ + int err; + struct sdhci_fsl_fdt_softc *sc; + struct mmc_ios *ios; + struct sdhci_slot *slot; + + err = sdhci_generic_update_ios(brdev, reqdev); + if (err != 0) + return (err); + + sc = device_get_softc(brdev); + slot = device_get_ivars(reqdev); + ios = &slot->host.ios; + + switch (ios->power_mode) { + case power_on: + break; + case power_off: + if (bootverbose) + device_printf(sc->dev, "Powering down sd/mmc\n"); + + if (sc->fdt_helper.vmmc_supply) + regulator_disable(sc->fdt_helper.vmmc_supply); + if (sc->fdt_helper.vqmmc_supply) + regulator_disable(sc->fdt_helper.vqmmc_supply); + break; + case power_up: + if (bootverbose) + device_printf(sc->dev, "Powering up sd/mmc\n"); + + if (sc->fdt_helper.vmmc_supply) + regulator_enable(sc->fdt_helper.vmmc_supply); + if (sc->fdt_helper.vqmmc_supply) + regulator_enable(sc->fdt_helper.vqmmc_supply); + break; + }; + + return (0); +} + +static int +sdhci_fsl_fdt_switch_vccq(device_t brdev, device_t reqdev) +{ + struct sdhci_fsl_fdt_softc *sc; + struct sdhci_slot *slot; + int uvolt, err; + + err = sdhci_generic_switch_vccq(brdev, reqdev); + if (err != 0) + return (err); + + sc = device_get_softc(brdev); + + if (sc->fdt_helper.vqmmc_supply == NULL) + return EOPNOTSUPP; + + slot = device_get_ivars(reqdev); + switch (slot->host.ios.vccq) { + case vccq_180: + uvolt = 1800000; + break; + case vccq_330: + uvolt = 3300000; + break; + default: + return EINVAL; + } + + err = regulator_set_voltage(sc->fdt_helper.vqmmc_supply, uvolt, uvolt); + if (err != 0) { + device_printf(sc->dev, + "Cannot set vqmmc to %d<->%d\n", uvolt, uvolt); + return (err); + } + + return (0); +} + static int sdhci_fsl_fdt_get_ro(device_t bus, device_t child) { @@ -463,10 +546,24 @@ sdhci_fsl_fdt_get_card_present(device_t dev, struct sdhci_slot *slot) return (sdhci_fdt_gpio_get_present(sc->gpio)); } +static void +sdhci_fsl_fdt_of_parse(device_t dev) +{ + struct sdhci_fsl_fdt_softc *sc; + phandle_t node; + + sc = device_get_softc(dev); + node = ofw_bus_get_node(dev); + + /* Call mmc_fdt_parse in order to get mmc related properties. */ + mmc_fdt_parse(dev, node, &sc->fdt_helper, &sc->slot.host); +} + static int sdhci_fsl_fdt_attach(device_t dev) { struct sdhci_fsl_fdt_softc *sc; + struct mmc_host *host; uint32_t val, buf_order; uintptr_t ocd_data; uint64_t clk_hz; @@ -481,6 +578,7 @@ sdhci_fsl_fdt_attach(device_t dev) sc->soc_data = (struct sdhci_fsl_fdt_soc_data *)ocd_data; sc->dev = dev; sc->slot.quirks = sc->soc_data->quirks; + host = &sc->slot.host; rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, @@ -534,6 +632,9 @@ sdhci_fsl_fdt_attach(device_t dev) buf_order = SDHCI_FSL_PROT_CTRL_BYTE_SWAP; } + sdhci_fsl_fdt_of_parse(dev); + sc->maxclk_hz = host->f_max ? host->f_max : sc->baseclk_hz; + /* * Setting this register affects byte order in SDHCI_BUFFER only. * If the eSDHC block is connected over a big-endian bus, the data @@ -555,7 +656,7 @@ sdhci_fsl_fdt_attach(device_t dev) WR4(sc, SDHCI_CLOCK_CONTROL, val & ~SDHCI_FSL_CLK_SDCLKEN); val = RD4(sc, SDHCI_FSL_ESDHC_CTRL); WR4(sc, SDHCI_FSL_ESDHC_CTRL, val | SDHCI_FSL_ESDHC_CTRL_CLK_DIV2); - sc->slot.max_clk = sc->baseclk_hz; + sc->slot.max_clk = sc->maxclk_hz; sc->gpio = sdhci_fdt_gpio_setup(dev, &sc->slot); /* @@ -656,11 +757,12 @@ static const device_method_t sdhci_fsl_fdt_methods[] = { DEVMETHOD(bus_write_ivar, sdhci_generic_write_ivar), /* MMC bridge interface. */ - DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), DEVMETHOD(mmcbr_request, sdhci_generic_request), DEVMETHOD(mmcbr_get_ro, sdhci_fsl_fdt_get_ro), DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), + DEVMETHOD(mmcbr_switch_vccq, sdhci_fsl_fdt_switch_vccq), + DEVMETHOD(mmcbr_update_ios, sdhci_fsl_fdt_update_ios), /* SDHCI accessors. */ DEVMETHOD(sdhci_read_1, sdhci_fsl_fdt_read_1), From owner-dev-commits-src-all@freebsd.org Fri May 14 08:53:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62F0F63E49C; Fri, 14 May 2021 08:53:24 +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 4FhMkX2546z4tJR; Fri, 14 May 2021 08:53:24 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0A2867522; Fri, 14 May 2021 08:53:24 +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 14E8rN7A017340; Fri, 14 May 2021 08:53:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14E8rNbI017339; Fri, 14 May 2021 08:53:23 GMT (envelope-from git) Date: Fri, 14 May 2021 08:53:23 GMT Message-Id: <202105140853.14E8rNbI017339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: 1f84b3a247bf - main - sdhci_fsl_fdt.c: Read supported voltages from dts. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1f84b3a247bf4c0e584e36576a20dc120def1214 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 08:53:24 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=1f84b3a247bf4c0e584e36576a20dc120def1214 commit 1f84b3a247bf4c0e584e36576a20dc120def1214 Author: Marcin Wojtas AuthorDate: 2021-04-22 11:01:06 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-14 08:34:37 +0000 sdhci_fsl_fdt.c: Read supported voltages from dts. We shouldn't overwrite capability register. Instead, voltages supported by the controller have to be read from dts, as the hardware doesn't report correct values. Submitted by: Lukasz Hajec Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30123 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 73 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index c2330a679963..26092f662406 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -90,6 +90,9 @@ __FBSDID("$FreeBSD$"); #define SDHCI_FSL_ESDHC_CTRL_SNOOP (1 << 6) #define SDHCI_FSL_ESDHC_CTRL_CLK_DIV2 (1 << 19) +#define SDHCI_FSL_CAN_VDD_MASK \ + (SDHCI_CAN_VDD_180 | SDHCI_CAN_VDD_300 | SDHCI_CAN_VDD_330) + struct sdhci_fsl_fdt_softc { device_t dev; const struct sdhci_fsl_fdt_soc_data *soc_data; @@ -295,18 +298,11 @@ sdhci_fsl_fdt_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) val32 = RD4(sc, off); - switch (off) { - case SDHCI_CAPABILITIES: - val32 &= ~(SDHCI_CAN_DO_SUSPEND | SDHCI_CAN_VDD_180); - break; - case SDHCI_PRESENT_STATE: + if (off == SDHCI_PRESENT_STATE) { wrk32 = val32; val32 &= SDHCI_FSL_PRES_COMPAT_MASK; val32 |= (wrk32 >> 4) & SDHCI_STATE_DAT_MASK; val32 |= (wrk32 << 1) & SDHCI_STATE_CMD; - break; - default: - break; } return (val32); @@ -546,17 +542,78 @@ sdhci_fsl_fdt_get_card_present(device_t dev, struct sdhci_slot *slot) return (sdhci_fdt_gpio_get_present(sc->gpio)); } +static uint32_t +sdhci_fsl_fdt_vddrange_to_mask(device_t dev, uint32_t *vdd_ranges, int len) +{ + uint32_t vdd_min, vdd_max; + uint32_t vdd_mask = 0; + int i; + + /* Ranges are organized as pairs of values. */ + if ((len % 2) != 0) { + device_printf(dev, "Invalid voltage range\n"); + return (0); + } + len = len / 2; + + for (i = 0; i < len; i++) { + vdd_min = vdd_ranges[2 * i]; + vdd_max = vdd_ranges[2 * i + 1]; + + if (vdd_min > vdd_max || vdd_min < 1650 || vdd_min > 3600 || + vdd_max < 1650 || vdd_max > 3600) { + device_printf(dev, "Voltage range %d - %d is out of bounds\n", + vdd_min, vdd_max); + return (0); + } + + if (vdd_min <= 1800 && vdd_max >= 1800) + vdd_mask |= SDHCI_CAN_VDD_180; + if (vdd_min <= 3000 && vdd_max >= 3000) + vdd_mask |= SDHCI_CAN_VDD_300; + if (vdd_min <= 3300 && vdd_max >= 3300) + vdd_mask |= SDHCI_CAN_VDD_330; + } + + return (vdd_mask); +} + static void sdhci_fsl_fdt_of_parse(device_t dev) { struct sdhci_fsl_fdt_softc *sc; phandle_t node; + pcell_t *voltage_ranges; + uint32_t vdd_mask = 0; + ssize_t num_ranges; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); /* Call mmc_fdt_parse in order to get mmc related properties. */ mmc_fdt_parse(dev, node, &sc->fdt_helper, &sc->slot.host); + + sc->slot.caps = sdhci_fsl_fdt_read_4(dev, &sc->slot, + SDHCI_CAPABILITIES) & ~(SDHCI_CAN_DO_SUSPEND); + sc->slot.caps2 = sdhci_fsl_fdt_read_4(dev, &sc->slot, + SDHCI_CAPABILITIES2); + + /* Parse the "voltage-ranges" dts property. */ + num_ranges = OF_getencprop_alloc(node, "voltage-ranges", + (void **) &voltage_ranges); + if (num_ranges <= 0) + return; + vdd_mask = sdhci_fsl_fdt_vddrange_to_mask(dev, voltage_ranges, + num_ranges / sizeof(uint32_t)); + OF_prop_free(voltage_ranges); + + /* Overwrite voltage caps only if we got something from dts. */ + if (vdd_mask != 0 && + (vdd_mask != (sc->slot.caps & SDHCI_FSL_CAN_VDD_MASK))) { + sc->slot.caps &= ~(SDHCI_FSL_CAN_VDD_MASK); + sc->slot.caps |= vdd_mask; + sc->slot.quirks |= SDHCI_QUIRK_MISSING_CAPS; + } } static int From owner-dev-commits-src-all@freebsd.org Fri May 14 08:53:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AAFB263E539; Fri, 14 May 2021 08:53:25 +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 4FhMkY1yn8z4tXn; Fri, 14 May 2021 08:53:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2B1697523; Fri, 14 May 2021 08:53:25 +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 14E8rPUD017362; Fri, 14 May 2021 08:53:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14E8rPvq017361; Fri, 14 May 2021 08:53:25 GMT (envelope-from git) Date: Fri, 14 May 2021 08:53:25 GMT Message-Id: <202105140853.14E8rPvq017361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: f55bd0e5798d - main - qoriq_dw_pci: disable LS1028A support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f55bd0e5798dd17251302f73904da76bdfd257b9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 08:53:25 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=f55bd0e5798dd17251302f73904da76bdfd257b9 commit f55bd0e5798dd17251302f73904da76bdfd257b9 Author: Marcin Wojtas AuthorDate: 2021-05-14 08:39:46 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-14 08:50:17 +0000 qoriq_dw_pci: disable LS1028A support Enabled driver initialization causes an abort on the NXP LS1028ARDB platform (without any external endpoints connected). Temporarily disable qoriq_dw_pci probe, so that to allow successful booting of the OS. Submitted by: Lukasz Hajec Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30229 --- sys/arm64/qoriq/qoriq_dw_pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/arm64/qoriq/qoriq_dw_pci.c b/sys/arm64/qoriq/qoriq_dw_pci.c index 424a030e094c..4d0c7928fc4c 100644 --- a/sys/arm64/qoriq/qoriq_dw_pci.c +++ b/sys/arm64/qoriq/qoriq_dw_pci.c @@ -101,7 +101,13 @@ static struct qoriq_dw_pci_cfg ls2028_cfg = { /* Compatible devices. */ static struct ofw_compat_data compat_data[] = { {"fsl,ls1012a-pcie", (uintptr_t)&ls1012_cfg}, + /* + * XXX: On LS1028ARDB attaching this driver causes external abort. + * Disable it for now. + */ +#ifdef notyet {"fsl,ls1028a-pcie", (uintptr_t)&ls2028_cfg}, +#endif {"fsl,ls1043a-pcie", (uintptr_t)&ls1043_cfg}, {"fsl,ls1046a-pcie", (uintptr_t)&ls1012_cfg}, {"fsl,ls2080a-pcie", (uintptr_t)&ls2080_cfg}, From owner-dev-commits-src-all@freebsd.org Fri May 14 12:32:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7D08645D0D; Fri, 14 May 2021 12:32:40 +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 4FhSbX5Kfjz3RKj; Fri, 14 May 2021 12:32:40 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A9DD012720; Fri, 14 May 2021 12:32:40 +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 14ECWe58010683; Fri, 14 May 2021 12:32:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ECWeGH010682; Fri, 14 May 2021 12:32:40 GMT (envelope-from git) Date: Fri, 14 May 2021 12:32:40 GMT Message-Id: <202105141232.14ECWeGH010682@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Nathan Whitehorn Subject: git: 34766aa8cb51 - main - Fix scripted installs on EFI systems using ZFS root with zfsboot. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nwhitehorn X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34766aa8cb514472c571f8b0e90e833833acef51 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 12:32:40 -0000 The branch main has been updated by nwhitehorn: URL: https://cgit.FreeBSD.org/src/commit/?id=34766aa8cb514472c571f8b0e90e833833acef51 commit 34766aa8cb514472c571f8b0e90e833833acef51 Author: Nathan Whitehorn AuthorDate: 2021-05-14 12:30:41 +0000 Commit: Nathan Whitehorn CommitDate: 2021-05-14 12:30:41 +0000 Fix scripted installs on EFI systems using ZFS root with zfsboot. Unlike attended installations, scripted installs did not mount non-ZFS partitions when ZFS root (via zfsboot) was selected. Since this included the ESP, the EFI loader was not installed. Copy logic from the attended-install path to make this work. PR: 255824, 255081 MFC after: 1 week Obtained from: Mark Huizer --- usr.sbin/bsdinstall/scripts/script | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script index 1d8e52a9d6d3..6a03e88bba39 100755 --- a/usr.sbin/bsdinstall/scripts/script +++ b/usr.sbin/bsdinstall/scripts/script @@ -111,8 +111,8 @@ if [ "$ZFSBOOT_DISKS" ]; then bsdinstall zfsboot else bsdinstall scriptedpart "$PARTITIONS" - bsdinstall mount fi +bsdinstall mount # Unpack distributions bsdinstall checksum @@ -163,9 +163,8 @@ fi bsdinstall entropy if [ "$ZFSBOOT_DISKS" ]; then zpool export $ZFSBOOT_POOL_NAME -else - bsdinstall umount fi +bsdinstall umount f_dprintf "Installation Completed at %s" "$( date )" From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A972064746C; Fri, 14 May 2021 13:06:44 +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 4FhTLr4Lzgz3l1T; Fri, 14 May 2021 13:06:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 887E712963; Fri, 14 May 2021 13:06:44 +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 14ED6iuF052348; Fri, 14 May 2021 13:06:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6iNW052347; Fri, 14 May 2021 13:06:44 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:44 GMT Message-Id: <202105141306.14ED6iNW052347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 30164294a6d3 - stable/12 - pf: Introduce DIOCCLRSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 30164294a6d39f5dc39fa23cf55dc37faa594360 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:44 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=30164294a6d39f5dc39fa23cf55dc37faa594360 commit 30164294a6d39f5dc39fa23cf55dc37faa594360 Author: Kristof Provost AuthorDate: 2021-04-29 09:07:02 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:15:32 +0000 pf: Introduce DIOCCLRSTATESNV Introduce an nvlist variant of DIOCCLRSTATES. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30052 (cherry picked from commit 7606a45dcc87cb6b222af929dad37b615cb925cf) --- sys/net/pfvar.h | 14 ++++ sys/netpfil/pf/pf_ioctl.c | 199 +++++++++++++++++++++++++++++++++++++++------- sys/netpfil/pf/pf_nv.c | 1 + sys/netpfil/pf/pf_nv.h | 5 ++ 4 files changed, 192 insertions(+), 27 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index dd69713d8574..f1eeaa458609 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1072,6 +1072,19 @@ struct pfioc_src_node_kill { u_int psnk_killed; }; +#ifdef _KERNEL +struct pf_kstate_kill { + struct pf_state_cmp psk_pfcmp; + sa_family_t psk_af; + int psk_proto; + struct pf_rule_addr psk_src; + struct pf_rule_addr psk_dst; + char psk_ifname[IFNAMSIZ]; + char psk_label[PF_RULE_LABEL_SIZE]; + u_int psk_killed; +}; +#endif + struct pfioc_state_kill { struct pf_state_cmp psk_pfcmp; sa_family_t psk_af; @@ -1239,6 +1252,7 @@ struct pfioc_iface { #define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv) /* XXX cut 8 - 17 */ #define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) +#define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv) #define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index e738300e3ae7..1d4d36ded254 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -200,7 +200,9 @@ struct cdev *pf_dev; /* * XXX - These are new and need to be checked when moveing to a new version */ -static void pf_clear_states(void); +static void pf_clear_all_states(void); +static unsigned int pf_clear_states(const struct pf_kstate_kill *); +static int pf_clearstates_nv(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2476,6 +2478,72 @@ relock_DIOCKILLSTATES: return (killed); } +static int +pf_state_kill_to_kstate_kill(const struct pfioc_state_kill *psk, + struct pf_kstate_kill *kill) +{ + bzero(kill, sizeof(*kill)); + + bcopy(&psk->psk_pfcmp, &kill->psk_pfcmp, sizeof(kill->psk_pfcmp)); + kill->psk_af = psk->psk_af; + kill->psk_proto = psk->psk_proto; + bcopy(&psk->psk_src, &kill->psk_src, sizeof(kill->psk_src)); + bcopy(&psk->psk_dst, &kill->psk_dst, sizeof(kill->psk_dst)); + strlcpy(kill->psk_ifname, psk->psk_ifname, sizeof(kill->psk_ifname)); + strlcpy(kill->psk_label, psk->psk_label, sizeof(kill->psk_label)); + + return (0); +} + +static int +pf_nvstate_cmp_to_state_cmp(const nvlist_t *nvl, struct pf_state_cmp *cmp) +{ + int error = 0; + + bzero(cmp, sizeof(*cmp)); + + PFNV_CHK(pf_nvuint64(nvl, "id", &cmp->id)); + PFNV_CHK(pf_nvuint32(nvl, "creatorid", &cmp->creatorid)); + PFNV_CHK(pf_nvuint8(nvl, "direction", &cmp->direction)); + +errout: + return (error); +} + +static int +pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, + struct pf_kstate_kill *kill) +{ + int error = 0; + + bzero(kill, sizeof(*kill)); + + if (! nvlist_exists_nvlist(nvl, "cmp")) + return (EINVAL); + + PFNV_CHK(pf_nvstate_cmp_to_state_cmp(nvlist_get_nvlist(nvl, "cmp"), + &kill->psk_pfcmp)); + PFNV_CHK(pf_nvuint8(nvl, "af", &kill->psk_af)); + PFNV_CHK(pf_nvint(nvl, "proto", &kill->psk_proto)); + + if (! nvlist_exists_nvlist(nvl, "src")) + return (EINVAL); + PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "src"), + &kill->psk_src)); + if (! nvlist_exists_nvlist(nvl, "dst")) + return (EINVAL); + PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), + &kill->psk_dst)); + + PFNV_CHK(pf_nvstring(nvl, "ifname", kill->psk_ifname, + sizeof(kill->psk_ifname))); + PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, + sizeof(kill->psk_label))); + +errout: + return (error); +} + static int pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, uint32_t pool_ticket, const char *anchor, const char *anchor_call, @@ -3317,33 +3385,19 @@ DIOCCHANGERULE_error: } case DIOCCLRSTATES: { - struct pf_state *s; struct pfioc_state_kill *psk = (struct pfioc_state_kill *)addr; - u_int i, killed = 0; + struct pf_kstate_kill kill; - for (i = 0; i <= pf_hashmask; i++) { - struct pf_idhash *ih = &V_pf_idhash[i]; + error = pf_state_kill_to_kstate_kill(psk, &kill); + if (error) + break; -relock_DIOCCLRSTATES: - PF_HASHROW_LOCK(ih); - LIST_FOREACH(s, &ih->states, entry) - if (!psk->psk_ifname[0] || - !strcmp(psk->psk_ifname, - s->kif->pfik_name)) { - /* - * Don't send out individual - * delete messages. - */ - s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); - killed++; - goto relock_DIOCCLRSTATES; - } - PF_HASHROW_UNLOCK(ih); - } - psk->psk_killed = killed; - if (V_pfsync_clear_states_ptr != NULL) - V_pfsync_clear_states_ptr(V_pf_status.hostid, psk->psk_ifname); + psk->psk_killed = pf_clear_states(&kill); + break; + } + + case DIOCCLRSTATESNV: { + error = pf_clearstates_nv((struct pfioc_nv *)addr); break; } @@ -5239,7 +5293,7 @@ pf_tbladdr_copyout(struct pf_addr_wrap *aw) * XXX - Check for version missmatch!!! */ static void -pf_clear_states(void) +pf_clear_all_states(void) { struct pf_state *s; u_int i; @@ -5390,6 +5444,97 @@ on_error: return (error); } +static unsigned int +pf_clear_states(const struct pf_kstate_kill *kill) +{ + struct pf_state *s; + unsigned int killed = 0; + + for (unsigned int i = 0; i <= pf_hashmask; i++) { + struct pf_idhash *ih = &V_pf_idhash[i]; + +relock_DIOCCLRSTATES: + PF_HASHROW_LOCK(ih); + LIST_FOREACH(s, &ih->states, entry) + if (!kill->psk_ifname[0] || + !strcmp(kill->psk_ifname, + s->kif->pfik_name)) { + /* + * Don't send out individual + * delete messages. + */ + s->state_flags |= PFSTATE_NOSYNC; + pf_unlink_state(s, PF_ENTER_LOCKED); + killed++; + goto relock_DIOCCLRSTATES; + } + PF_HASHROW_UNLOCK(ih); + } + + if (V_pfsync_clear_states_ptr != NULL) + V_pfsync_clear_states_ptr(V_pf_status.hostid, kill->psk_ifname); + + return (killed); +} + +static int +pf_clearstates_nv(struct pfioc_nv *nv) +{ + struct pf_kstate_kill kill; + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + unsigned int killed; + +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + error = pf_nvstate_kill_to_kstate_kill(nvl, &kill); + if (error) + ERROUT(error); + + killed = pf_clear_states(&kill); + + free(nvlpacked, M_TEMP); + nvlpacked = NULL; + nvlist_destroy(nvl); + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_number(nvl, "killed", killed); + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + /* * XXX - Check for version missmatch!!! */ @@ -5449,7 +5594,7 @@ shutdown_pf(void) pf_commit_altq(t[0]); #endif - pf_clear_states(); + pf_clear_all_states(); pf_clear_srcnodes(NULL); diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 8a2082d3e0bb..1fdb52e5fad0 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -104,6 +104,7 @@ pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, PF_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX); PF_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); PF_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX); +PF_NV_IMPL_UINT(uint64, uint64_t, UINT64_MAX); int pf_nvint(const nvlist_t *nvl, const char *name, int *val) diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index d50f46a1f5cd..589a1972fa43 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -48,6 +48,11 @@ int pf_nvuint32_array(const nvlist_t *, const char *, uint32_t *, size_t, size_t *); void pf_uint32_array_nv(nvlist_t *, const char *, const uint32_t *, size_t); +int pf_nvuint64(const nvlist_t *, const char *, uint64_t *); +int pf_nvuint64_array(const nvlist_t *, const char *, uint64_t *, + size_t, size_t *); +void pf_uint64_array_nv(nvlist_t *, const char *, const uint64_t *, + size_t); int pf_nvstring(const nvlist_t *, const char *, char *, size_t); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D62264727A; Fri, 14 May 2021 13:06:46 +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 4FhTLs6BVjz3kyR; Fri, 14 May 2021 13:06:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A45AE12C43; Fri, 14 May 2021 13:06:45 +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 14ED6jRs052390; Fri, 14 May 2021 13:06:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6jIl052389; Fri, 14 May 2021 13:06:45 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:45 GMT Message-Id: <202105141306.14ED6jIl052389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 1cbb276258a4 - stable/12 - pf: Introduce DIOCKILLSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1cbb276258a4e7d5133da02e318bfe4edc2f7f80 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:46 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1cbb276258a4e7d5133da02e318bfe4edc2f7f80 commit 1cbb276258a4e7d5133da02e318bfe4edc2f7f80 Author: Kristof Provost AuthorDate: 2021-04-29 15:20:36 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:18:13 +0000 pf: Introduce DIOCKILLSTATESNV Introduce an nvlist based alternative to DIOCKILLSTATES. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30054 (cherry picked from commit e989530a09b6e9f77b89c950ecf32f1b4fa709da) --- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 110 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 96 insertions(+), 15 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index f1eeaa458609..abbabd842c43 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1269,6 +1269,7 @@ struct pfioc_iface { #define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit) #define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit) #define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill) +#define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv) #define DIOCSTARTALTQ _IO ('D', 42) #define DIOCSTOPALTQ _IO ('D', 43) #define DIOCADDALTQV0 _IOWR('D', 45, struct pfioc_altq_v0) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 1d4d36ded254..f38261caa8e9 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -202,6 +202,11 @@ struct cdev *pf_dev; */ static void pf_clear_all_states(void); static unsigned int pf_clear_states(const struct pf_kstate_kill *); +static int pf_killstates(struct pf_kstate_kill *, + unsigned int *); +static int pf_killstates_row(struct pf_kstate_kill *, + struct pf_idhash *); +static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); @@ -2413,7 +2418,7 @@ pf_label_match(const struct pf_krule *rule, const char *label) } static int -pf_killstates_row(struct pfioc_state_kill *psk, struct pf_idhash *ih) +pf_killstates_row(struct pf_kstate_kill *psk, struct pf_idhash *ih) { struct pf_state *s; struct pf_state_key *sk; @@ -3402,25 +3407,20 @@ DIOCCHANGERULE_error: } case DIOCKILLSTATES: { - struct pf_state *s; struct pfioc_state_kill *psk = (struct pfioc_state_kill *)addr; - u_int i, killed = 0; + struct pf_kstate_kill kill; - if (psk->psk_pfcmp.id) { - if (psk->psk_pfcmp.creatorid == 0) - psk->psk_pfcmp.creatorid = V_pf_status.hostid; - if ((s = pf_find_state_byid(psk->psk_pfcmp.id, - psk->psk_pfcmp.creatorid))) { - pf_unlink_state(s, PF_ENTER_LOCKED); - psk->psk_killed = 1; - } + error = pf_state_kill_to_kstate_kill(psk, &kill); + if (error) break; - } - for (i = 0; i <= pf_hashmask; i++) - killed += pf_killstates_row(psk, &V_pf_idhash[i]); + psk->psk_killed = 0; + error = pf_killstates(&kill, &psk->psk_killed); + break; + } - psk->psk_killed = killed; + case DIOCKILLSTATESNV: { + error = pf_killstates_nv((struct pfioc_nv *)addr); break; } @@ -5477,6 +5477,86 @@ relock_DIOCCLRSTATES: return (killed); } +static int +pf_killstates(struct pf_kstate_kill *kill, unsigned int *killed) +{ + struct pf_state *s; + + if (kill->psk_pfcmp.id) { + if (kill->psk_pfcmp.creatorid == 0) + kill->psk_pfcmp.creatorid = V_pf_status.hostid; + if ((s = pf_find_state_byid(kill->psk_pfcmp.id, + kill->psk_pfcmp.creatorid))) { + pf_unlink_state(s, PF_ENTER_LOCKED); + *killed = 1; + } + return (0); + } + + for (unsigned int i = 0; i <= pf_hashmask; i++) + *killed += pf_killstates_row(kill, &V_pf_idhash[i]); + + return (0); +} + +static int +pf_killstates_nv(struct pfioc_nv *nv) +{ + struct pf_kstate_kill kill; + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + unsigned int killed = 0; + +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + error = pf_nvstate_kill_to_kstate_kill(nvl, &kill); + if (error) + ERROUT(error); + + error = pf_killstates(&kill, &killed); + + free(nvlpacked, M_TEMP); + nvlpacked = NULL; + nvlist_destroy(nvl); + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_number(nvl, "killed", killed); + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + static int pf_clearstates_nv(struct pfioc_nv *nv) { From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 27E876475B2; Fri, 14 May 2021 13:06:44 +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 4FhTLq6ZMVz3ksM; Fri, 14 May 2021 13:06:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CFECA12C42; Fri, 14 May 2021 13:06:43 +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 14ED6h3L052236; Fri, 14 May 2021 13:06:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6hIw052234; Fri, 14 May 2021 13:06:43 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:43 GMT Message-Id: <202105141306.14ED6hIw052234@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 41bb01e095b1 - stable/13 - pf: Introduce DIOCCLRSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 41bb01e095b198b4d27b3d860c649267ad35c1d9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:44 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=41bb01e095b198b4d27b3d860c649267ad35c1d9 commit 41bb01e095b198b4d27b3d860c649267ad35c1d9 Author: Kristof Provost AuthorDate: 2021-04-29 09:07:02 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:15:27 +0000 pf: Introduce DIOCCLRSTATESNV Introduce an nvlist variant of DIOCCLRSTATES. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30052 (cherry picked from commit 7606a45dcc87cb6b222af929dad37b615cb925cf) --- sys/net/pfvar.h | 14 ++++ sys/netpfil/pf/pf_ioctl.c | 199 +++++++++++++++++++++++++++++++++++++++------- sys/netpfil/pf/pf_nv.c | 1 + sys/netpfil/pf/pf_nv.h | 5 ++ 4 files changed, 192 insertions(+), 27 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index c6761a5d87f1..dd2f189b948a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1072,6 +1072,19 @@ struct pfioc_src_node_kill { u_int psnk_killed; }; +#ifdef _KERNEL +struct pf_kstate_kill { + struct pf_state_cmp psk_pfcmp; + sa_family_t psk_af; + int psk_proto; + struct pf_rule_addr psk_src; + struct pf_rule_addr psk_dst; + char psk_ifname[IFNAMSIZ]; + char psk_label[PF_RULE_LABEL_SIZE]; + u_int psk_killed; +}; +#endif + struct pfioc_state_kill { struct pf_state_cmp psk_pfcmp; sa_family_t psk_af; @@ -1238,6 +1251,7 @@ struct pfioc_iface { #define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv) /* XXX cut 8 - 17 */ #define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) +#define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv) #define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index d9e313f62683..79da65e0ec98 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -200,7 +200,9 @@ struct cdev *pf_dev; /* * XXX - These are new and need to be checked when moveing to a new version */ -static void pf_clear_states(void); +static void pf_clear_all_states(void); +static unsigned int pf_clear_states(const struct pf_kstate_kill *); +static int pf_clearstates_nv(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2475,6 +2477,72 @@ relock_DIOCKILLSTATES: return (killed); } +static int +pf_state_kill_to_kstate_kill(const struct pfioc_state_kill *psk, + struct pf_kstate_kill *kill) +{ + bzero(kill, sizeof(*kill)); + + bcopy(&psk->psk_pfcmp, &kill->psk_pfcmp, sizeof(kill->psk_pfcmp)); + kill->psk_af = psk->psk_af; + kill->psk_proto = psk->psk_proto; + bcopy(&psk->psk_src, &kill->psk_src, sizeof(kill->psk_src)); + bcopy(&psk->psk_dst, &kill->psk_dst, sizeof(kill->psk_dst)); + strlcpy(kill->psk_ifname, psk->psk_ifname, sizeof(kill->psk_ifname)); + strlcpy(kill->psk_label, psk->psk_label, sizeof(kill->psk_label)); + + return (0); +} + +static int +pf_nvstate_cmp_to_state_cmp(const nvlist_t *nvl, struct pf_state_cmp *cmp) +{ + int error = 0; + + bzero(cmp, sizeof(*cmp)); + + PFNV_CHK(pf_nvuint64(nvl, "id", &cmp->id)); + PFNV_CHK(pf_nvuint32(nvl, "creatorid", &cmp->creatorid)); + PFNV_CHK(pf_nvuint8(nvl, "direction", &cmp->direction)); + +errout: + return (error); +} + +static int +pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, + struct pf_kstate_kill *kill) +{ + int error = 0; + + bzero(kill, sizeof(*kill)); + + if (! nvlist_exists_nvlist(nvl, "cmp")) + return (EINVAL); + + PFNV_CHK(pf_nvstate_cmp_to_state_cmp(nvlist_get_nvlist(nvl, "cmp"), + &kill->psk_pfcmp)); + PFNV_CHK(pf_nvuint8(nvl, "af", &kill->psk_af)); + PFNV_CHK(pf_nvint(nvl, "proto", &kill->psk_proto)); + + if (! nvlist_exists_nvlist(nvl, "src")) + return (EINVAL); + PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "src"), + &kill->psk_src)); + if (! nvlist_exists_nvlist(nvl, "dst")) + return (EINVAL); + PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), + &kill->psk_dst)); + + PFNV_CHK(pf_nvstring(nvl, "ifname", kill->psk_ifname, + sizeof(kill->psk_ifname))); + PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, + sizeof(kill->psk_label))); + +errout: + return (error); +} + static int pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, uint32_t pool_ticket, const char *anchor, const char *anchor_call, @@ -3305,33 +3373,19 @@ DIOCCHANGERULE_error: } case DIOCCLRSTATES: { - struct pf_state *s; struct pfioc_state_kill *psk = (struct pfioc_state_kill *)addr; - u_int i, killed = 0; + struct pf_kstate_kill kill; - for (i = 0; i <= pf_hashmask; i++) { - struct pf_idhash *ih = &V_pf_idhash[i]; + error = pf_state_kill_to_kstate_kill(psk, &kill); + if (error) + break; -relock_DIOCCLRSTATES: - PF_HASHROW_LOCK(ih); - LIST_FOREACH(s, &ih->states, entry) - if (!psk->psk_ifname[0] || - !strcmp(psk->psk_ifname, - s->kif->pfik_name)) { - /* - * Don't send out individual - * delete messages. - */ - s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); - killed++; - goto relock_DIOCCLRSTATES; - } - PF_HASHROW_UNLOCK(ih); - } - psk->psk_killed = killed; - if (V_pfsync_clear_states_ptr != NULL) - V_pfsync_clear_states_ptr(V_pf_status.hostid, psk->psk_ifname); + psk->psk_killed = pf_clear_states(&kill); + break; + } + + case DIOCCLRSTATESNV: { + error = pf_clearstates_nv((struct pfioc_nv *)addr); break; } @@ -5224,7 +5278,7 @@ pf_tbladdr_copyout(struct pf_addr_wrap *aw) * XXX - Check for version missmatch!!! */ static void -pf_clear_states(void) +pf_clear_all_states(void) { struct pf_state *s; u_int i; @@ -5375,6 +5429,97 @@ on_error: return (error); } +static unsigned int +pf_clear_states(const struct pf_kstate_kill *kill) +{ + struct pf_state *s; + unsigned int killed = 0; + + for (unsigned int i = 0; i <= pf_hashmask; i++) { + struct pf_idhash *ih = &V_pf_idhash[i]; + +relock_DIOCCLRSTATES: + PF_HASHROW_LOCK(ih); + LIST_FOREACH(s, &ih->states, entry) + if (!kill->psk_ifname[0] || + !strcmp(kill->psk_ifname, + s->kif->pfik_name)) { + /* + * Don't send out individual + * delete messages. + */ + s->state_flags |= PFSTATE_NOSYNC; + pf_unlink_state(s, PF_ENTER_LOCKED); + killed++; + goto relock_DIOCCLRSTATES; + } + PF_HASHROW_UNLOCK(ih); + } + + if (V_pfsync_clear_states_ptr != NULL) + V_pfsync_clear_states_ptr(V_pf_status.hostid, kill->psk_ifname); + + return (killed); +} + +static int +pf_clearstates_nv(struct pfioc_nv *nv) +{ + struct pf_kstate_kill kill; + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + unsigned int killed; + +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + error = pf_nvstate_kill_to_kstate_kill(nvl, &kill); + if (error) + ERROUT(error); + + killed = pf_clear_states(&kill); + + free(nvlpacked, M_TEMP); + nvlpacked = NULL; + nvlist_destroy(nvl); + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_number(nvl, "killed", killed); + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + /* * XXX - Check for version missmatch!!! */ @@ -5434,7 +5579,7 @@ shutdown_pf(void) pf_commit_altq(t[0]); #endif - pf_clear_states(); + pf_clear_all_states(); pf_clear_srcnodes(NULL); diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index 8a2082d3e0bb..1fdb52e5fad0 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -104,6 +104,7 @@ pf_nvbinary(const nvlist_t *nvl, const char *name, void *data, PF_NV_IMPL_UINT(uint8, uint8_t, UINT8_MAX); PF_NV_IMPL_UINT(uint16, uint16_t, UINT16_MAX); PF_NV_IMPL_UINT(uint32, uint32_t, UINT32_MAX); +PF_NV_IMPL_UINT(uint64, uint64_t, UINT64_MAX); int pf_nvint(const nvlist_t *nvl, const char *name, int *val) diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index d50f46a1f5cd..589a1972fa43 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -48,6 +48,11 @@ int pf_nvuint32_array(const nvlist_t *, const char *, uint32_t *, size_t, size_t *); void pf_uint32_array_nv(nvlist_t *, const char *, const uint32_t *, size_t); +int pf_nvuint64(const nvlist_t *, const char *, uint64_t *); +int pf_nvuint64_array(const nvlist_t *, const char *, uint64_t *, + size_t, size_t *); +void pf_uint64_array_nv(nvlist_t *, const char *, const uint64_t *, + size_t); int pf_nvstring(const nvlist_t *, const char *, char *, size_t); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 172F96473E3; Fri, 14 May 2021 13:06:45 +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 4FhTLs03lLz3l1X; Fri, 14 May 2021 13:06:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E789012E41; Fri, 14 May 2021 13:06:44 +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 14ED6iNO052369; Fri, 14 May 2021 13:06:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6it4052368; Fri, 14 May 2021 13:06:44 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:44 GMT Message-Id: <202105141306.14ED6it4052368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: e25df666069d - stable/13 - pf: Introduce DIOCKILLSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e25df666069d89d7224640d526fe42cb2a3c224e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:45 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e25df666069d89d7224640d526fe42cb2a3c224e commit e25df666069d89d7224640d526fe42cb2a3c224e Author: Kristof Provost AuthorDate: 2021-04-29 15:20:36 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:17:17 +0000 pf: Introduce DIOCKILLSTATESNV Introduce an nvlist based alternative to DIOCKILLSTATES. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30054 (cherry picked from commit e989530a09b6e9f77b89c950ecf32f1b4fa709da) --- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 110 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 96 insertions(+), 15 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index dd2f189b948a..7b18ef7d3b0c 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1268,6 +1268,7 @@ struct pfioc_iface { #define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit) #define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit) #define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill) +#define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv) #define DIOCSTARTALTQ _IO ('D', 42) #define DIOCSTOPALTQ _IO ('D', 43) #define DIOCADDALTQV0 _IOWR('D', 45, struct pfioc_altq_v0) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 79da65e0ec98..897a5ff512a6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -202,6 +202,11 @@ struct cdev *pf_dev; */ static void pf_clear_all_states(void); static unsigned int pf_clear_states(const struct pf_kstate_kill *); +static int pf_killstates(struct pf_kstate_kill *, + unsigned int *); +static int pf_killstates_row(struct pf_kstate_kill *, + struct pf_idhash *); +static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); @@ -2412,7 +2417,7 @@ pf_label_match(const struct pf_krule *rule, const char *label) } static int -pf_killstates_row(struct pfioc_state_kill *psk, struct pf_idhash *ih) +pf_killstates_row(struct pf_kstate_kill *psk, struct pf_idhash *ih) { struct pf_state *s; struct pf_state_key *sk; @@ -3390,25 +3395,20 @@ DIOCCHANGERULE_error: } case DIOCKILLSTATES: { - struct pf_state *s; struct pfioc_state_kill *psk = (struct pfioc_state_kill *)addr; - u_int i, killed = 0; + struct pf_kstate_kill kill; - if (psk->psk_pfcmp.id) { - if (psk->psk_pfcmp.creatorid == 0) - psk->psk_pfcmp.creatorid = V_pf_status.hostid; - if ((s = pf_find_state_byid(psk->psk_pfcmp.id, - psk->psk_pfcmp.creatorid))) { - pf_unlink_state(s, PF_ENTER_LOCKED); - psk->psk_killed = 1; - } + error = pf_state_kill_to_kstate_kill(psk, &kill); + if (error) break; - } - for (i = 0; i <= pf_hashmask; i++) - killed += pf_killstates_row(psk, &V_pf_idhash[i]); + psk->psk_killed = 0; + error = pf_killstates(&kill, &psk->psk_killed); + break; + } - psk->psk_killed = killed; + case DIOCKILLSTATESNV: { + error = pf_killstates_nv((struct pfioc_nv *)addr); break; } @@ -5462,6 +5462,86 @@ relock_DIOCCLRSTATES: return (killed); } +static int +pf_killstates(struct pf_kstate_kill *kill, unsigned int *killed) +{ + struct pf_state *s; + + if (kill->psk_pfcmp.id) { + if (kill->psk_pfcmp.creatorid == 0) + kill->psk_pfcmp.creatorid = V_pf_status.hostid; + if ((s = pf_find_state_byid(kill->psk_pfcmp.id, + kill->psk_pfcmp.creatorid))) { + pf_unlink_state(s, PF_ENTER_LOCKED); + *killed = 1; + } + return (0); + } + + for (unsigned int i = 0; i <= pf_hashmask; i++) + *killed += pf_killstates_row(kill, &V_pf_idhash[i]); + + return (0); +} + +static int +pf_killstates_nv(struct pfioc_nv *nv) +{ + struct pf_kstate_kill kill; + nvlist_t *nvl = NULL; + void *nvlpacked = NULL; + int error = 0; + unsigned int killed = 0; + +#define ERROUT(x) ERROUT_FUNCTION(on_error, x) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + error = pf_nvstate_kill_to_kstate_kill(nvl, &kill); + if (error) + ERROUT(error); + + error = pf_killstates(&kill, &killed); + + free(nvlpacked, M_TEMP); + nvlpacked = NULL; + nvlist_destroy(nvl); + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_number(nvl, "killed", killed); + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +on_error: + nvlist_destroy(nvl); + free(nvlpacked, M_TEMP); + return (error); +} + static int pf_clearstates_nv(struct pfioc_nv *nv) { From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A89EE647621; Fri, 14 May 2021 13:06:46 +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 4FhTLt22bJz3kqc; Fri, 14 May 2021 13:06:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0E5F212D18; Fri, 14 May 2021 13:06:46 +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 14ED6jXq052411; Fri, 14 May 2021 13:06:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6j7H052410; Fri, 14 May 2021 13:06:45 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:45 GMT Message-Id: <202105141306.14ED6j7H052410@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 66cff482bec5 - stable/13 - pfctl: Start using DIOCCLRSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 66cff482bec507d80645fce9652e5486425658a3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:46 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=66cff482bec507d80645fce9652e5486425658a3 commit 66cff482bec507d80645fce9652e5486425658a3 Author: Kristof Provost AuthorDate: 2021-04-29 13:10:50 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:20:36 +0000 pfctl: Start using DIOCCLRSTATESNV MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30053 (cherry picked from commit 53714a586133fd8ae662427007f84ec663cd83ef) --- lib/libpfctl/libpfctl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 18 +++++++++++++++ sbin/pfctl/pfctl.c | 21 +++++++++--------- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index b07fcda9bd5a..8c8b21d22a46 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -608,3 +608,62 @@ pfctl_set_keepcounters(int dev, bool keep) free(nv.data); return (ret); } + +static void +pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name, + const struct pfctl_state_cmp *cmp) +{ + nvlist_t *nv; + + nv = nvlist_create(0); + + nvlist_add_number(nv, "id", cmp->id); + nvlist_add_number(nv, "creatorid", cmp->creatorid); + nvlist_add_number(nv, "direction", cmp->direction); + + nvlist_add_nvlist(nvl, name, nv); +} + +int +pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed) +{ + struct pfioc_nv nv; + nvlist_t *nvl; + int ret; + + nvl = nvlist_create(0); + + pfctl_nv_add_state_cmp(nvl, "cmp", &kill->cmp); + nvlist_add_number(nvl, "af", kill->af); + nvlist_add_number(nvl, "proto", kill->proto); + pfctl_nv_add_rule_addr(nvl, "src", &kill->src); + pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst); + nvlist_add_string(nvl, "ifname", kill->ifname); + nvlist_add_string(nvl, "label", kill->label); + + nv.data = nvlist_pack(nvl, &nv.len); + nv.size = nv.len; + nvlist_destroy(nvl); + nvl = NULL; + + ret = ioctl(dev, DIOCCLRSTATESNV, &nv); + if (ret != 0) { + free(nv.data); + return (ret); + } + + nvl = nvlist_unpack(nv.data, nv.len, 0); + if (nvl == NULL) { + free(nv.data); + return (EIO); + } + + if (killed) + *killed = nvlist_get_number(nvl, "killed"); + + nvlist_destroy(nvl); + free(nv.data); + + return (ret); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index e19187fc2526..3ec2a7fa535f 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -179,6 +179,22 @@ RB_PROTOTYPE(pfctl_anchor_global, pfctl_anchor, entry_global, RB_PROTOTYPE(pfctl_anchor_node, pfctl_anchor, entry_node, pf_anchor_compare); +struct pfctl_state_cmp { + uint64_t id; + uint32_t creatorid; + uint8_t direction; +}; + +struct pfctl_kill { + struct pfctl_state_cmp cmp; + sa_family_t af; + int proto; + struct pf_rule_addr src; + struct pf_rule_addr dst; + char ifname[IFNAMSIZ]; + char label[PF_RULE_LABEL_SIZE]; +}; + int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call); @@ -189,5 +205,7 @@ int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket); int pfctl_set_keepcounters(int dev, bool keep); +int pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed); #endif diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index af2ae6fe3bf0..2cfca24c0cfa 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -79,7 +79,7 @@ int pfctl_clear_rules(int, int, char *); int pfctl_clear_nat(int, int, char *); int pfctl_clear_altq(int, int); int pfctl_clear_src_nodes(int, int); -int pfctl_clear_states(int, const char *, int); +int pfctl_clear_iface_states(int, const char *, int); void pfctl_addrprefix(char *, struct pf_addr *); int pfctl_kill_src_nodes(int, const char *, int); int pfctl_net_kill_states(int, const char *, int); @@ -467,19 +467,20 @@ pfctl_clear_src_nodes(int dev, int opts) } int -pfctl_clear_states(int dev, const char *iface, int opts) +pfctl_clear_iface_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; - memset(&psk, 0, sizeof(psk)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + memset(&kill, 0, sizeof(kill)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - if (ioctl(dev, DIOCCLRSTATES, &psk)) + if (pfctl_clear_states(dev, &kill, &killed)) err(1, "DIOCCLRSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "%d states cleared\n", psk.psk_killed); + fprintf(stderr, "%d states cleared\n", killed); return (0); } @@ -2417,7 +2418,7 @@ main(int argc, char *argv[]) pfctl_clear_altq(dev, opts); break; case 's': - pfctl_clear_states(dev, ifaceopt, opts); + pfctl_clear_iface_states(dev, ifaceopt, opts); break; case 'S': pfctl_clear_src_nodes(dev, opts); @@ -2431,7 +2432,7 @@ main(int argc, char *argv[]) pfctl_clear_tables(anchorname, opts); if (!*anchorname) { pfctl_clear_altq(dev, opts); - pfctl_clear_states(dev, ifaceopt, opts); + pfctl_clear_iface_states(dev, ifaceopt, opts); pfctl_clear_src_nodes(dev, opts); pfctl_clear_stats(dev, opts); pfctl_clear_fingerprints(dev, opts); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:47 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6D7ED6474DF; Fri, 14 May 2021 13:06:47 +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 4FhTLt6bb0z3kl5; Fri, 14 May 2021 13:06:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D0FB112C44; Fri, 14 May 2021 13:06:46 +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 14ED6kHI052432; Fri, 14 May 2021 13:06:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6kn9052431; Fri, 14 May 2021 13:06:46 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:46 GMT Message-Id: <202105141306.14ED6kn9052431@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: f756e230f5e6 - stable/12 - pfctl: Start using DIOCCLRSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f756e230f5e68ce589d3cca81726d5c01db0d0cf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:47 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f756e230f5e68ce589d3cca81726d5c01db0d0cf commit f756e230f5e68ce589d3cca81726d5c01db0d0cf Author: Kristof Provost AuthorDate: 2021-04-29 13:10:50 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:20:32 +0000 pfctl: Start using DIOCCLRSTATESNV MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30053 (cherry picked from commit 53714a586133fd8ae662427007f84ec663cd83ef) --- lib/libpfctl/libpfctl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 18 +++++++++++++++ sbin/pfctl/pfctl.c | 21 +++++++++--------- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index b07fcda9bd5a..8c8b21d22a46 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -608,3 +608,62 @@ pfctl_set_keepcounters(int dev, bool keep) free(nv.data); return (ret); } + +static void +pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name, + const struct pfctl_state_cmp *cmp) +{ + nvlist_t *nv; + + nv = nvlist_create(0); + + nvlist_add_number(nv, "id", cmp->id); + nvlist_add_number(nv, "creatorid", cmp->creatorid); + nvlist_add_number(nv, "direction", cmp->direction); + + nvlist_add_nvlist(nvl, name, nv); +} + +int +pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed) +{ + struct pfioc_nv nv; + nvlist_t *nvl; + int ret; + + nvl = nvlist_create(0); + + pfctl_nv_add_state_cmp(nvl, "cmp", &kill->cmp); + nvlist_add_number(nvl, "af", kill->af); + nvlist_add_number(nvl, "proto", kill->proto); + pfctl_nv_add_rule_addr(nvl, "src", &kill->src); + pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst); + nvlist_add_string(nvl, "ifname", kill->ifname); + nvlist_add_string(nvl, "label", kill->label); + + nv.data = nvlist_pack(nvl, &nv.len); + nv.size = nv.len; + nvlist_destroy(nvl); + nvl = NULL; + + ret = ioctl(dev, DIOCCLRSTATESNV, &nv); + if (ret != 0) { + free(nv.data); + return (ret); + } + + nvl = nvlist_unpack(nv.data, nv.len, 0); + if (nvl == NULL) { + free(nv.data); + return (EIO); + } + + if (killed) + *killed = nvlist_get_number(nvl, "killed"); + + nvlist_destroy(nvl); + free(nv.data); + + return (ret); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index e19187fc2526..3ec2a7fa535f 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -179,6 +179,22 @@ RB_PROTOTYPE(pfctl_anchor_global, pfctl_anchor, entry_global, RB_PROTOTYPE(pfctl_anchor_node, pfctl_anchor, entry_node, pf_anchor_compare); +struct pfctl_state_cmp { + uint64_t id; + uint32_t creatorid; + uint8_t direction; +}; + +struct pfctl_kill { + struct pfctl_state_cmp cmp; + sa_family_t af; + int proto; + struct pf_rule_addr src; + struct pf_rule_addr dst; + char ifname[IFNAMSIZ]; + char label[PF_RULE_LABEL_SIZE]; +}; + int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call); @@ -189,5 +205,7 @@ int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket); int pfctl_set_keepcounters(int dev, bool keep); +int pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed); #endif diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index af2ae6fe3bf0..2cfca24c0cfa 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -79,7 +79,7 @@ int pfctl_clear_rules(int, int, char *); int pfctl_clear_nat(int, int, char *); int pfctl_clear_altq(int, int); int pfctl_clear_src_nodes(int, int); -int pfctl_clear_states(int, const char *, int); +int pfctl_clear_iface_states(int, const char *, int); void pfctl_addrprefix(char *, struct pf_addr *); int pfctl_kill_src_nodes(int, const char *, int); int pfctl_net_kill_states(int, const char *, int); @@ -467,19 +467,20 @@ pfctl_clear_src_nodes(int dev, int opts) } int -pfctl_clear_states(int dev, const char *iface, int opts) +pfctl_clear_iface_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; - memset(&psk, 0, sizeof(psk)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + memset(&kill, 0, sizeof(kill)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - if (ioctl(dev, DIOCCLRSTATES, &psk)) + if (pfctl_clear_states(dev, &kill, &killed)) err(1, "DIOCCLRSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "%d states cleared\n", psk.psk_killed); + fprintf(stderr, "%d states cleared\n", killed); return (0); } @@ -2417,7 +2418,7 @@ main(int argc, char *argv[]) pfctl_clear_altq(dev, opts); break; case 's': - pfctl_clear_states(dev, ifaceopt, opts); + pfctl_clear_iface_states(dev, ifaceopt, opts); break; case 'S': pfctl_clear_src_nodes(dev, opts); @@ -2431,7 +2432,7 @@ main(int argc, char *argv[]) pfctl_clear_tables(anchorname, opts); if (!*anchorname) { pfctl_clear_altq(dev, opts); - pfctl_clear_states(dev, ifaceopt, opts); + pfctl_clear_iface_states(dev, ifaceopt, opts); pfctl_clear_src_nodes(dev, opts); pfctl_clear_stats(dev, opts); pfctl_clear_fingerprints(dev, opts); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 142C6647555; Fri, 14 May 2021 13:06:48 +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 4FhTLv5M7Pz3kmY; Fri, 14 May 2021 13:06:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5D2E212D19; Fri, 14 May 2021 13:06:47 +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 14ED6lQ9052453; Fri, 14 May 2021 13:06:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6lsP052452; Fri, 14 May 2021 13:06:47 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:47 GMT Message-Id: <202105141306.14ED6lsP052452@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 327310fcac34 - stable/13 - pfctl: Start using DIOCKILLSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 327310fcac34fdbe7528a3655dc57aa187a653d3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:48 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=327310fcac34fdbe7528a3655dc57aa187a653d3 commit 327310fcac34fdbe7528a3655dc57aa187a653d3 Author: Kristof Provost AuthorDate: 2021-04-29 19:24:56 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:21:15 +0000 pfctl: Start using DIOCKILLSTATESNV MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30055 (cherry picked from commit 2a00c4db93b8db0c326a57363ca8a690ef6ab082) --- lib/libpfctl/libpfctl.c | 24 ++++++++++--- lib/libpfctl/libpfctl.h | 2 ++ sbin/pfctl/pfctl.c | 91 +++++++++++++++++++++++++------------------------ 3 files changed, 69 insertions(+), 48 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 8c8b21d22a46..9f504237b4ee 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -50,6 +50,9 @@ #include "libpfctl.h" +static int _pfctl_clear_states(int , const struct pfctl_kill *, + unsigned int *, uint64_t); + static void pf_nvuint_8_array(const nvlist_t *nvl, const char *name, size_t maxelems, u_int8_t *numbers, size_t *nelems) @@ -624,9 +627,9 @@ pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name, nvlist_add_nvlist(nvl, name, nv); } -int -pfctl_clear_states(int dev, const struct pfctl_kill *kill, - unsigned int *killed) +static int +_pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed, uint64_t ioctlval) { struct pfioc_nv nv; nvlist_t *nvl; @@ -647,7 +650,7 @@ pfctl_clear_states(int dev, const struct pfctl_kill *kill, nvlist_destroy(nvl); nvl = NULL; - ret = ioctl(dev, DIOCCLRSTATESNV, &nv); + ret = ioctl(dev, ioctlval, &nv); if (ret != 0) { free(nv.data); return (ret); @@ -667,3 +670,16 @@ pfctl_clear_states(int dev, const struct pfctl_kill *kill, return (ret); } + +int +pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed) +{ + return (_pfctl_clear_states(dev, kill, killed, DIOCCLRSTATESNV)); +} + +int +pfctl_kill_states(int dev, const struct pfctl_kill *kill, unsigned int *killed) +{ + return (_pfctl_clear_states(dev, kill, killed, DIOCKILLSTATESNV)); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 3ec2a7fa535f..aa7f0ffd8fad 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -207,5 +207,7 @@ int pfctl_add_rule(int dev, const struct pfctl_rule *r, int pfctl_set_keepcounters(int dev, bool keep); int pfctl_clear_states(int dev, const struct pfctl_kill *kill, unsigned int *killed); +int pfctl_kill_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed); #endif diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 2cfca24c0cfa..487dfb480cdc 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -640,24 +640,25 @@ pfctl_kill_src_nodes(int dev, const char *iface, int opts) int pfctl_net_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; struct addrinfo *res[2], *resp[2]; struct sockaddr last_src, last_dst; + unsigned int newkilled; int killed, sources, dests; int ret_ga; killed = sources = dests = 0; - memset(&psk, 0, sizeof(psk)); - memset(&psk.psk_src.addr.v.a.mask, 0xff, - sizeof(psk.psk_src.addr.v.a.mask)); + memset(&kill, 0, sizeof(kill)); + memset(&kill.src.addr.v.a.mask, 0xff, + sizeof(kill.src.addr.v.a.mask)); memset(&last_src, 0xff, sizeof(last_src)); memset(&last_dst, 0xff, sizeof(last_dst)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - pfctl_addrprefix(state_kill[0], &psk.psk_src.addr.v.a.mask); + pfctl_addrprefix(state_kill[0], &kill.src.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[0], NULL, NULL, &res[0]))) { errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); @@ -671,26 +672,26 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) continue; last_src = *(struct sockaddr *)resp[0]->ai_addr; - psk.psk_af = resp[0]->ai_family; + kill.af = resp[0]->ai_family; sources++; - if (psk.psk_af == AF_INET) - psk.psk_src.addr.v.a.addr.v4 = + if (kill.af == AF_INET) + kill.src.addr.v.a.addr.v4 = ((struct sockaddr_in *)resp[0]->ai_addr)->sin_addr; - else if (psk.psk_af == AF_INET6) - psk.psk_src.addr.v.a.addr.v6 = + else if (kill.af == AF_INET6) + kill.src.addr.v.a.addr.v6 = ((struct sockaddr_in6 *)resp[0]->ai_addr)-> sin6_addr; else - errx(1, "Unknown address family %d", psk.psk_af); + errx(1, "Unknown address family %d", kill.af); if (state_killers > 1) { dests = 0; - memset(&psk.psk_dst.addr.v.a.mask, 0xff, - sizeof(psk.psk_dst.addr.v.a.mask)); + memset(&kill.dst.addr.v.a.mask, 0xff, + sizeof(kill.dst.addr.v.a.mask)); memset(&last_dst, 0xff, sizeof(last_dst)); pfctl_addrprefix(state_kill[1], - &psk.psk_dst.addr.v.a.mask); + &kill.dst.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res[1]))) { errx(1, "getaddrinfo: %s", @@ -701,7 +702,7 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) resp[1] = resp[1]->ai_next) { if (resp[1]->ai_addr == NULL) continue; - if (psk.psk_af != resp[1]->ai_family) + if (kill.af != resp[1]->ai_family) continue; if (memcmp(&last_dst, resp[1]->ai_addr, @@ -711,27 +712,27 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) dests++; - if (psk.psk_af == AF_INET) - psk.psk_dst.addr.v.a.addr.v4 = + if (kill.af == AF_INET) + kill.dst.addr.v.a.addr.v4 = ((struct sockaddr_in *)resp[1]-> ai_addr)->sin_addr; - else if (psk.psk_af == AF_INET6) - psk.psk_dst.addr.v.a.addr.v6 = + else if (kill.af == AF_INET6) + kill.dst.addr.v.a.addr.v6 = ((struct sockaddr_in6 *)resp[1]-> ai_addr)->sin6_addr; else errx(1, "Unknown address family %d", - psk.psk_af); + kill.af); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &newkilled)) err(1, "DIOCKILLSTATES"); - killed += psk.psk_killed; + killed += newkilled; } freeaddrinfo(res[1]); } else { - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &newkilled)) err(1, "DIOCKILLSTATES"); - killed += psk.psk_killed; + killed += newkilled; } } @@ -746,26 +747,27 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) int pfctl_label_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { warnx("no label specified"); usage(); } - memset(&psk, 0, sizeof(psk)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + memset(&kill, 0, sizeof(kill)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - if (strlcpy(psk.psk_label, state_kill[1], sizeof(psk.psk_label)) >= - sizeof(psk.psk_label)) + if (strlcpy(kill.label, state_kill[1], sizeof(kill.label)) >= + sizeof(kill.label)) errx(1, "label too long: %s", state_kill[1]); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "killed %d states\n", psk.psk_killed); + fprintf(stderr, "killed %d states\n", killed); return (0); } @@ -773,34 +775,35 @@ pfctl_label_kill_states(int dev, const char *iface, int opts) int pfctl_id_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { warnx("no id specified"); usage(); } - memset(&psk, 0, sizeof(psk)); + memset(&kill, 0, sizeof(kill)); if ((sscanf(state_kill[1], "%jx/%x", - &psk.psk_pfcmp.id, &psk.psk_pfcmp.creatorid)) == 2) - HTONL(psk.psk_pfcmp.creatorid); - else if ((sscanf(state_kill[1], "%jx", &psk.psk_pfcmp.id)) == 1) { - psk.psk_pfcmp.creatorid = 0; + &kill.cmp.id, &kill.cmp.creatorid)) == 2) + HTONL(kill.cmp.creatorid); + else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { + kill.cmp.creatorid = 0; } else { warnx("wrong id format specified"); usage(); } - if (psk.psk_pfcmp.id == 0) { + if (kill.cmp.id == 0) { warnx("cannot kill id 0"); usage(); } - psk.psk_pfcmp.id = htobe64(psk.psk_pfcmp.id); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + kill.cmp.id = htobe64(kill.cmp.id); + if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "killed %d states\n", psk.psk_killed); + fprintf(stderr, "killed %d states\n", killed); return (0); } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DA776473F0; Fri, 14 May 2021 13:06:51 +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 4FhTLy2szMz3kqm; Fri, 14 May 2021 13:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3AF8712C94; Fri, 14 May 2021 13:06:50 +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 14ED6o1B052565; Fri, 14 May 2021 13:06:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6o8r052564; Fri, 14 May 2021 13:06:50 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:50 GMT Message-Id: <202105141306.14ED6o8r052564@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 32252d4ae79a - stable/12 - pf: Allow states to by killed per 'gateway' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 32252d4ae79afc9cf7e2f867a81870f19c14b04e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:51 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=32252d4ae79afc9cf7e2f867a81870f19c14b04e commit 32252d4ae79afc9cf7e2f867a81870f19c14b04e Author: Kristof Provost AuthorDate: 2021-04-30 13:15:05 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:39:16 +0000 pf: Allow states to by killed per 'gateway' This allows us to kill states created from a rule with route-to/reply-to set. This is particularly useful in multi-wan setups, where one of the WAN links goes down. Submitted by: Steven Brown Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/ MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30058 (cherry picked from commit abbcba9cf5b1c26e837f00e0fbc205652cb05e51) --- lib/libpfctl/libpfctl.c | 1 + lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pfctl.8 | 20 +++++++++++--- sbin/pfctl/pfctl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++- share/man/man4/pf.4 | 2 +- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 10 +++++++ 7 files changed, 96 insertions(+), 5 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 9f504237b4ee..f50afa7c78ef 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -642,6 +642,7 @@ _pfctl_clear_states(int dev, const struct pfctl_kill *kill, nvlist_add_number(nvl, "proto", kill->proto); pfctl_nv_add_rule_addr(nvl, "src", &kill->src); pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst); + pfctl_nv_add_rule_addr(nvl, "rt_addr", &kill->rt_addr); nvlist_add_string(nvl, "ifname", kill->ifname); nvlist_add_string(nvl, "label", kill->label); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index aa7f0ffd8fad..5c8b2108d937 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -191,6 +191,7 @@ struct pfctl_kill { int proto; struct pf_rule_addr src; struct pf_rule_addr dst; + struct pf_rule_addr rt_addr; char ifname[IFNAMSIZ]; char label[PF_RULE_LABEL_SIZE]; }; diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8 index f12489d9493a..f3905f850c5a 100644 --- a/sbin/pfctl/pfctl.8 +++ b/sbin/pfctl/pfctl.8 @@ -45,7 +45,7 @@ .Op Fl K Ar host | network .Xo .Oo Fl k -.Ar host | network | label | id +.Ar host | network | label | id | gateway .Oc Xc .Op Fl o Ar level .Op Fl p Ar device @@ -256,14 +256,15 @@ option may be specified, which will kill all the source tracking entries from the first host/network to the second. .It Xo .Fl k -.Ar host | network | label | id +.Ar host | network | label | id | gateway .Xc Kill all of the state entries matching the specified .Ar host , .Ar network , .Ar label , +.Ar id , or -.Ar id . +.Ar gateway. .Pp For example, to kill all of the state entries originating from .Dq host : @@ -317,6 +318,19 @@ To kill a state with ID 4823e84500000018 created from a backup firewall with hostid 00000002 use: .Pp .Dl # pfctl -k id -k 4823e84500000018/2 +.Pp +It is also possible to kill states created from a rule with the route-to/reply-to +parameter set to route the connection through a particular gateway. +Note that rules routing via the default routing table (not via a route-to +rule) will have their rt_addr set as 0.0.0.0 or ::. +To kill all states using a gateway of 192.168.0.1 use: +.Pp +.Dl # pfctl -k gateway -k 192.168.0.1 +.Pp +A network prefix length can also be specified. +To kill all states using a gateway in 192.168.0.0/24: +.Pp +.Dl # pfctl -k gateway -k 192.168.0.0/24 .It Fl m Merge in explicitly given options without resetting those which are omitted. diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 487dfb480cdc..96f3b4740d90 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -83,6 +83,7 @@ int pfctl_clear_iface_states(int, const char *, int); void pfctl_addrprefix(char *, struct pf_addr *); int pfctl_kill_src_nodes(int, const char *, int); int pfctl_net_kill_states(int, const char *, int); +int pfctl_gateway_kill_states(int, const char *, int); int pfctl_label_kill_states(int, const char *, int); int pfctl_id_kill_states(int, const char *, int); void pfctl_init_options(struct pfctl *); @@ -246,7 +247,7 @@ usage(void) fprintf(stderr, "usage: %s [-AdeghmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" "\t[-f file] [-i interface] [-K host | network]\n" - "\t[-k host | network | label | id] [-o level] [-p device]\n" + "\t[-k host | network | gateway | label | id] [-o level] [-p device]\n" "\t[-s modifier] [-t table -T command [address ...]] [-x level]\n", __progname); @@ -744,6 +745,67 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) return (0); } +int +pfctl_gateway_kill_states(int dev, const char *iface, int opts) +{ + struct pfctl_kill kill; + struct addrinfo *res, *resp; + struct sockaddr last_src; + unsigned int newkilled; + int killed = 0; + int ret_ga; + + if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { + warnx("no gateway specified"); + usage(); + } + + memset(&kill, 0, sizeof(kill)); + memset(&kill.rt_addr.addr.v.a.mask, 0xff, + sizeof(kill.rt_addr.addr.v.a.mask)); + memset(&last_src, 0xff, sizeof(last_src)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) + errx(1, "invalid interface: %s", iface); + + pfctl_addrprefix(state_kill[1], &kill.rt_addr.addr.v.a.mask); + + if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res))) { + errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); + /* NOTREACHED */ + } + for (resp = res; resp; resp = resp->ai_next) { + if (resp->ai_addr == NULL) + continue; + /* We get lots of duplicates. Catch the easy ones */ + if (memcmp(&last_src, resp->ai_addr, sizeof(last_src)) == 0) + continue; + last_src = *(struct sockaddr *)resp->ai_addr; + + kill.af = resp->ai_family; + + if (kill.af == AF_INET) + kill.rt_addr.addr.v.a.addr.v4 = + ((struct sockaddr_in *)resp->ai_addr)->sin_addr; + else if (kill.af == AF_INET6) + kill.rt_addr.addr.v.a.addr.v6 = + ((struct sockaddr_in6 *)resp->ai_addr)-> + sin6_addr; + else + errx(1, "Unknown address family %d", kill.af); + + if (pfctl_kill_states(dev, &kill, &newkilled)) + err(1, "DIOCKILLSTATES"); + killed += newkilled; + } + + freeaddrinfo(res); + + if ((opts & PF_OPT_QUIET) == 0) + fprintf(stderr, "killed %d states\n", killed); + return (0); +} + int pfctl_label_kill_states(int dev, const char *iface, int opts) { @@ -2455,6 +2517,8 @@ main(int argc, char *argv[]) pfctl_label_kill_states(dev, ifaceopt, opts); else if (!strcmp(state_kill[0], "id")) pfctl_id_kill_states(dev, ifaceopt, opts); + else if (!strcmp(state_kill[0], "gateway")) + pfctl_gateway_kill_states(dev, ifaceopt, opts); else pfctl_net_kill_states(dev, ifaceopt, opts); } diff --git a/share/man/man4/pf.4 b/share/man/man4/pf.4 index e71ef8f426e4..2fb132203908 100644 --- a/share/man/man4/pf.4 +++ b/share/man/man4/pf.4 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 5, 2018 +.Dd May 7, 2021 .Dt PF 4 .Os .Sh NAME diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index abbabd842c43..196a5edb874a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1079,6 +1079,7 @@ struct pf_kstate_kill { int psk_proto; struct pf_rule_addr psk_src; struct pf_rule_addr psk_dst; + struct pf_rule_addr psk_rt_addr; char psk_ifname[IFNAMSIZ]; char psk_label[PF_RULE_LABEL_SIZE]; u_int psk_killed; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index f38261caa8e9..69d32b835a43 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2456,6 +2456,12 @@ relock_DIOCKILLSTATES: &psk->psk_dst.addr.v.a.mask, dstaddr, sk->af)) continue; + if (! PF_MATCHA(psk->psk_rt_addr.neg, + &psk->psk_rt_addr.addr.v.a.addr, + &psk->psk_rt_addr.addr.v.a.mask, + &s->rt_addr, sk->af)) + continue; + if (psk->psk_src.port_op != 0 && ! pf_match_port(psk->psk_src.port_op, psk->psk_src.port[0], psk->psk_src.port[1], srcport)) @@ -2539,6 +2545,10 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, return (EINVAL); PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &kill->psk_dst)); + if (nvlist_exists_nvlist(nvl, "rt_addr")) { + PFNV_CHK(pf_nvrule_addr_to_rule_addr( + nvlist_get_nvlist(nvl, "rt_addr"), &kill->psk_rt_addr)); + } PFNV_CHK(pf_nvstring(nvl, "ifname", kill->psk_ifname, sizeof(kill->psk_ifname))); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08D5A647711; Fri, 14 May 2021 13:06: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 4FhTLz4b3Dz3l1t; Fri, 14 May 2021 13:06:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A6EBE12AE8; Fri, 14 May 2021 13:06:50 +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 14ED6o58052586; Fri, 14 May 2021 13:06:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6oR0052585; Fri, 14 May 2021 13:06:50 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:50 GMT Message-Id: <202105141306.14ED6oR0052585@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 2a00e1cde461 - stable/13 - pf tests: Test killing states by gateway MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2a00e1cde461aab7aeb400f3fc67e3d527a917a3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:52 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2a00e1cde461aab7aeb400f3fc67e3d527a917a3 commit 2a00e1cde461aab7aeb400f3fc67e3d527a917a3 Author: Kristof Provost AuthorDate: 2021-04-30 15:07:23 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:39:39 +0000 pf tests: Test killing states by gateway MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30059 (cherry picked from commit c2e11d81d295f7d55ac8b6858b09d8fa123cbfe8) --- tests/sys/netpfil/pf/killstate.sh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index dddf844e6231..4ec1adf0d051 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -318,10 +318,70 @@ multilabel_cleanup() pft_cleanup } +atf_test_case "gateway" "cleanup" +gateway_head() +{ + atf_set descr 'Test killing states by route-to/reply-to address' + atf_set require.user root + atf_set require.progs scapy +} + +gateway_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in reply-to (${epair}b 192.0.2.1) proto icmp" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing with a different gateway does not affect our state + jexec alcatraz pfctl -k gateway -k 192.0.2.2 + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing states with the relevant gateway does terminate our state + jexec alcatraz pfctl -k gateway -k 192.0.2.1 + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +gateway_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "v6" atf_add_test_case "label" atf_add_test_case "multilabel" + atf_add_test_case "gateway" } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F6526476A7; Fri, 14 May 2021 13:06:50 +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 4FhTLw49X5z3kvx; Fri, 14 May 2021 13:06:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E13C512D1A; Fri, 14 May 2021 13:06:47 +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 14ED6lQS052480; Fri, 14 May 2021 13:06:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6lw0052479; Fri, 14 May 2021 13:06:47 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:47 GMT Message-Id: <202105141306.14ED6lw0052479@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 5d5936ea20a7 - stable/12 - pfctl: Start using DIOCKILLSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5d5936ea20a70a704fd51be184797e5423bb1aab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:50 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5d5936ea20a70a704fd51be184797e5423bb1aab commit 5d5936ea20a70a704fd51be184797e5423bb1aab Author: Kristof Provost AuthorDate: 2021-04-29 19:24:56 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:21:11 +0000 pfctl: Start using DIOCKILLSTATESNV MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30055 (cherry picked from commit 2a00c4db93b8db0c326a57363ca8a690ef6ab082) --- lib/libpfctl/libpfctl.c | 24 ++++++++++--- lib/libpfctl/libpfctl.h | 2 ++ sbin/pfctl/pfctl.c | 91 +++++++++++++++++++++++++------------------------ 3 files changed, 69 insertions(+), 48 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 8c8b21d22a46..9f504237b4ee 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -50,6 +50,9 @@ #include "libpfctl.h" +static int _pfctl_clear_states(int , const struct pfctl_kill *, + unsigned int *, uint64_t); + static void pf_nvuint_8_array(const nvlist_t *nvl, const char *name, size_t maxelems, u_int8_t *numbers, size_t *nelems) @@ -624,9 +627,9 @@ pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name, nvlist_add_nvlist(nvl, name, nv); } -int -pfctl_clear_states(int dev, const struct pfctl_kill *kill, - unsigned int *killed) +static int +_pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed, uint64_t ioctlval) { struct pfioc_nv nv; nvlist_t *nvl; @@ -647,7 +650,7 @@ pfctl_clear_states(int dev, const struct pfctl_kill *kill, nvlist_destroy(nvl); nvl = NULL; - ret = ioctl(dev, DIOCCLRSTATESNV, &nv); + ret = ioctl(dev, ioctlval, &nv); if (ret != 0) { free(nv.data); return (ret); @@ -667,3 +670,16 @@ pfctl_clear_states(int dev, const struct pfctl_kill *kill, return (ret); } + +int +pfctl_clear_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed) +{ + return (_pfctl_clear_states(dev, kill, killed, DIOCCLRSTATESNV)); +} + +int +pfctl_kill_states(int dev, const struct pfctl_kill *kill, unsigned int *killed) +{ + return (_pfctl_clear_states(dev, kill, killed, DIOCKILLSTATESNV)); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 3ec2a7fa535f..aa7f0ffd8fad 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -207,5 +207,7 @@ int pfctl_add_rule(int dev, const struct pfctl_rule *r, int pfctl_set_keepcounters(int dev, bool keep); int pfctl_clear_states(int dev, const struct pfctl_kill *kill, unsigned int *killed); +int pfctl_kill_states(int dev, const struct pfctl_kill *kill, + unsigned int *killed); #endif diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 2cfca24c0cfa..487dfb480cdc 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -640,24 +640,25 @@ pfctl_kill_src_nodes(int dev, const char *iface, int opts) int pfctl_net_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; struct addrinfo *res[2], *resp[2]; struct sockaddr last_src, last_dst; + unsigned int newkilled; int killed, sources, dests; int ret_ga; killed = sources = dests = 0; - memset(&psk, 0, sizeof(psk)); - memset(&psk.psk_src.addr.v.a.mask, 0xff, - sizeof(psk.psk_src.addr.v.a.mask)); + memset(&kill, 0, sizeof(kill)); + memset(&kill.src.addr.v.a.mask, 0xff, + sizeof(kill.src.addr.v.a.mask)); memset(&last_src, 0xff, sizeof(last_src)); memset(&last_dst, 0xff, sizeof(last_dst)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - pfctl_addrprefix(state_kill[0], &psk.psk_src.addr.v.a.mask); + pfctl_addrprefix(state_kill[0], &kill.src.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[0], NULL, NULL, &res[0]))) { errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); @@ -671,26 +672,26 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) continue; last_src = *(struct sockaddr *)resp[0]->ai_addr; - psk.psk_af = resp[0]->ai_family; + kill.af = resp[0]->ai_family; sources++; - if (psk.psk_af == AF_INET) - psk.psk_src.addr.v.a.addr.v4 = + if (kill.af == AF_INET) + kill.src.addr.v.a.addr.v4 = ((struct sockaddr_in *)resp[0]->ai_addr)->sin_addr; - else if (psk.psk_af == AF_INET6) - psk.psk_src.addr.v.a.addr.v6 = + else if (kill.af == AF_INET6) + kill.src.addr.v.a.addr.v6 = ((struct sockaddr_in6 *)resp[0]->ai_addr)-> sin6_addr; else - errx(1, "Unknown address family %d", psk.psk_af); + errx(1, "Unknown address family %d", kill.af); if (state_killers > 1) { dests = 0; - memset(&psk.psk_dst.addr.v.a.mask, 0xff, - sizeof(psk.psk_dst.addr.v.a.mask)); + memset(&kill.dst.addr.v.a.mask, 0xff, + sizeof(kill.dst.addr.v.a.mask)); memset(&last_dst, 0xff, sizeof(last_dst)); pfctl_addrprefix(state_kill[1], - &psk.psk_dst.addr.v.a.mask); + &kill.dst.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res[1]))) { errx(1, "getaddrinfo: %s", @@ -701,7 +702,7 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) resp[1] = resp[1]->ai_next) { if (resp[1]->ai_addr == NULL) continue; - if (psk.psk_af != resp[1]->ai_family) + if (kill.af != resp[1]->ai_family) continue; if (memcmp(&last_dst, resp[1]->ai_addr, @@ -711,27 +712,27 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) dests++; - if (psk.psk_af == AF_INET) - psk.psk_dst.addr.v.a.addr.v4 = + if (kill.af == AF_INET) + kill.dst.addr.v.a.addr.v4 = ((struct sockaddr_in *)resp[1]-> ai_addr)->sin_addr; - else if (psk.psk_af == AF_INET6) - psk.psk_dst.addr.v.a.addr.v6 = + else if (kill.af == AF_INET6) + kill.dst.addr.v.a.addr.v6 = ((struct sockaddr_in6 *)resp[1]-> ai_addr)->sin6_addr; else errx(1, "Unknown address family %d", - psk.psk_af); + kill.af); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &newkilled)) err(1, "DIOCKILLSTATES"); - killed += psk.psk_killed; + killed += newkilled; } freeaddrinfo(res[1]); } else { - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &newkilled)) err(1, "DIOCKILLSTATES"); - killed += psk.psk_killed; + killed += newkilled; } } @@ -746,26 +747,27 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) int pfctl_label_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { warnx("no label specified"); usage(); } - memset(&psk, 0, sizeof(psk)); - if (iface != NULL && strlcpy(psk.psk_ifname, iface, - sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname)) + memset(&kill, 0, sizeof(kill)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); - if (strlcpy(psk.psk_label, state_kill[1], sizeof(psk.psk_label)) >= - sizeof(psk.psk_label)) + if (strlcpy(kill.label, state_kill[1], sizeof(kill.label)) >= + sizeof(kill.label)) errx(1, "label too long: %s", state_kill[1]); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "killed %d states\n", psk.psk_killed); + fprintf(stderr, "killed %d states\n", killed); return (0); } @@ -773,34 +775,35 @@ pfctl_label_kill_states(int dev, const char *iface, int opts) int pfctl_id_kill_states(int dev, const char *iface, int opts) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; + unsigned int killed; if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { warnx("no id specified"); usage(); } - memset(&psk, 0, sizeof(psk)); + memset(&kill, 0, sizeof(kill)); if ((sscanf(state_kill[1], "%jx/%x", - &psk.psk_pfcmp.id, &psk.psk_pfcmp.creatorid)) == 2) - HTONL(psk.psk_pfcmp.creatorid); - else if ((sscanf(state_kill[1], "%jx", &psk.psk_pfcmp.id)) == 1) { - psk.psk_pfcmp.creatorid = 0; + &kill.cmp.id, &kill.cmp.creatorid)) == 2) + HTONL(kill.cmp.creatorid); + else if ((sscanf(state_kill[1], "%jx", &kill.cmp.id)) == 1) { + kill.cmp.creatorid = 0; } else { warnx("wrong id format specified"); usage(); } - if (psk.psk_pfcmp.id == 0) { + if (kill.cmp.id == 0) { warnx("cannot kill id 0"); usage(); } - psk.psk_pfcmp.id = htobe64(psk.psk_pfcmp.id); - if (ioctl(dev, DIOCKILLSTATES, &psk)) + kill.cmp.id = htobe64(kill.cmp.id); + if (pfctl_kill_states(dev, &kill, &killed)) err(1, "DIOCKILLSTATES"); if ((opts & PF_OPT_QUIET) == 0) - fprintf(stderr, "killed %d states\n", psk.psk_killed); + fprintf(stderr, "killed %d states\n", killed); return (0); } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 04EB964763B; Fri, 14 May 2021 13:06:51 +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 4FhTLx6d7vz3khL; Fri, 14 May 2021 13:06:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8B8F712A53; Fri, 14 May 2021 13:06:49 +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 14ED6nfu052544; Fri, 14 May 2021 13:06:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6nUA052543; Fri, 14 May 2021 13:06:49 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:49 GMT Message-Id: <202105141306.14ED6nUA052543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: a9620e7c7046 - stable/13 - pf: Allow states to by killed per 'gateway' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a9620e7c70463e01e1762d1c2296248027afc9be Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:51 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a9620e7c70463e01e1762d1c2296248027afc9be commit a9620e7c70463e01e1762d1c2296248027afc9be Author: Kristof Provost AuthorDate: 2021-04-30 13:15:05 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:24:00 +0000 pf: Allow states to by killed per 'gateway' This allows us to kill states created from a rule with route-to/reply-to set. This is particularly useful in multi-wan setups, where one of the WAN links goes down. Submitted by: Steven Brown Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/ MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30058 (cherry picked from commit abbcba9cf5b1c26e837f00e0fbc205652cb05e51) --- lib/libpfctl/libpfctl.c | 1 + lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pfctl.8 | 20 +++++++++++--- sbin/pfctl/pfctl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++- share/man/man4/pf.4 | 2 +- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 10 +++++++ 7 files changed, 96 insertions(+), 5 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 9f504237b4ee..f50afa7c78ef 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -642,6 +642,7 @@ _pfctl_clear_states(int dev, const struct pfctl_kill *kill, nvlist_add_number(nvl, "proto", kill->proto); pfctl_nv_add_rule_addr(nvl, "src", &kill->src); pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst); + pfctl_nv_add_rule_addr(nvl, "rt_addr", &kill->rt_addr); nvlist_add_string(nvl, "ifname", kill->ifname); nvlist_add_string(nvl, "label", kill->label); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index aa7f0ffd8fad..5c8b2108d937 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -191,6 +191,7 @@ struct pfctl_kill { int proto; struct pf_rule_addr src; struct pf_rule_addr dst; + struct pf_rule_addr rt_addr; char ifname[IFNAMSIZ]; char label[PF_RULE_LABEL_SIZE]; }; diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8 index f12489d9493a..f3905f850c5a 100644 --- a/sbin/pfctl/pfctl.8 +++ b/sbin/pfctl/pfctl.8 @@ -45,7 +45,7 @@ .Op Fl K Ar host | network .Xo .Oo Fl k -.Ar host | network | label | id +.Ar host | network | label | id | gateway .Oc Xc .Op Fl o Ar level .Op Fl p Ar device @@ -256,14 +256,15 @@ option may be specified, which will kill all the source tracking entries from the first host/network to the second. .It Xo .Fl k -.Ar host | network | label | id +.Ar host | network | label | id | gateway .Xc Kill all of the state entries matching the specified .Ar host , .Ar network , .Ar label , +.Ar id , or -.Ar id . +.Ar gateway. .Pp For example, to kill all of the state entries originating from .Dq host : @@ -317,6 +318,19 @@ To kill a state with ID 4823e84500000018 created from a backup firewall with hostid 00000002 use: .Pp .Dl # pfctl -k id -k 4823e84500000018/2 +.Pp +It is also possible to kill states created from a rule with the route-to/reply-to +parameter set to route the connection through a particular gateway. +Note that rules routing via the default routing table (not via a route-to +rule) will have their rt_addr set as 0.0.0.0 or ::. +To kill all states using a gateway of 192.168.0.1 use: +.Pp +.Dl # pfctl -k gateway -k 192.168.0.1 +.Pp +A network prefix length can also be specified. +To kill all states using a gateway in 192.168.0.0/24: +.Pp +.Dl # pfctl -k gateway -k 192.168.0.0/24 .It Fl m Merge in explicitly given options without resetting those which are omitted. diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 487dfb480cdc..96f3b4740d90 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -83,6 +83,7 @@ int pfctl_clear_iface_states(int, const char *, int); void pfctl_addrprefix(char *, struct pf_addr *); int pfctl_kill_src_nodes(int, const char *, int); int pfctl_net_kill_states(int, const char *, int); +int pfctl_gateway_kill_states(int, const char *, int); int pfctl_label_kill_states(int, const char *, int); int pfctl_id_kill_states(int, const char *, int); void pfctl_init_options(struct pfctl *); @@ -246,7 +247,7 @@ usage(void) fprintf(stderr, "usage: %s [-AdeghmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" "\t[-f file] [-i interface] [-K host | network]\n" - "\t[-k host | network | label | id] [-o level] [-p device]\n" + "\t[-k host | network | gateway | label | id] [-o level] [-p device]\n" "\t[-s modifier] [-t table -T command [address ...]] [-x level]\n", __progname); @@ -744,6 +745,67 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) return (0); } +int +pfctl_gateway_kill_states(int dev, const char *iface, int opts) +{ + struct pfctl_kill kill; + struct addrinfo *res, *resp; + struct sockaddr last_src; + unsigned int newkilled; + int killed = 0; + int ret_ga; + + if (state_killers != 2 || (strlen(state_kill[1]) == 0)) { + warnx("no gateway specified"); + usage(); + } + + memset(&kill, 0, sizeof(kill)); + memset(&kill.rt_addr.addr.v.a.mask, 0xff, + sizeof(kill.rt_addr.addr.v.a.mask)); + memset(&last_src, 0xff, sizeof(last_src)); + if (iface != NULL && strlcpy(kill.ifname, iface, + sizeof(kill.ifname)) >= sizeof(kill.ifname)) + errx(1, "invalid interface: %s", iface); + + pfctl_addrprefix(state_kill[1], &kill.rt_addr.addr.v.a.mask); + + if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res))) { + errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); + /* NOTREACHED */ + } + for (resp = res; resp; resp = resp->ai_next) { + if (resp->ai_addr == NULL) + continue; + /* We get lots of duplicates. Catch the easy ones */ + if (memcmp(&last_src, resp->ai_addr, sizeof(last_src)) == 0) + continue; + last_src = *(struct sockaddr *)resp->ai_addr; + + kill.af = resp->ai_family; + + if (kill.af == AF_INET) + kill.rt_addr.addr.v.a.addr.v4 = + ((struct sockaddr_in *)resp->ai_addr)->sin_addr; + else if (kill.af == AF_INET6) + kill.rt_addr.addr.v.a.addr.v6 = + ((struct sockaddr_in6 *)resp->ai_addr)-> + sin6_addr; + else + errx(1, "Unknown address family %d", kill.af); + + if (pfctl_kill_states(dev, &kill, &newkilled)) + err(1, "DIOCKILLSTATES"); + killed += newkilled; + } + + freeaddrinfo(res); + + if ((opts & PF_OPT_QUIET) == 0) + fprintf(stderr, "killed %d states\n", killed); + return (0); +} + int pfctl_label_kill_states(int dev, const char *iface, int opts) { @@ -2455,6 +2517,8 @@ main(int argc, char *argv[]) pfctl_label_kill_states(dev, ifaceopt, opts); else if (!strcmp(state_kill[0], "id")) pfctl_id_kill_states(dev, ifaceopt, opts); + else if (!strcmp(state_kill[0], "gateway")) + pfctl_gateway_kill_states(dev, ifaceopt, opts); else pfctl_net_kill_states(dev, ifaceopt, opts); } diff --git a/share/man/man4/pf.4 b/share/man/man4/pf.4 index e71ef8f426e4..2fb132203908 100644 --- a/share/man/man4/pf.4 +++ b/share/man/man4/pf.4 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 5, 2018 +.Dd May 7, 2021 .Dt PF 4 .Os .Sh NAME diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 7b18ef7d3b0c..0b08b418d625 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1079,6 +1079,7 @@ struct pf_kstate_kill { int psk_proto; struct pf_rule_addr psk_src; struct pf_rule_addr psk_dst; + struct pf_rule_addr psk_rt_addr; char psk_ifname[IFNAMSIZ]; char psk_label[PF_RULE_LABEL_SIZE]; u_int psk_killed; diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 897a5ff512a6..07ee7ba77a80 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2455,6 +2455,12 @@ relock_DIOCKILLSTATES: &psk->psk_dst.addr.v.a.mask, dstaddr, sk->af)) continue; + if (! PF_MATCHA(psk->psk_rt_addr.neg, + &psk->psk_rt_addr.addr.v.a.addr, + &psk->psk_rt_addr.addr.v.a.mask, + &s->rt_addr, sk->af)) + continue; + if (psk->psk_src.port_op != 0 && ! pf_match_port(psk->psk_src.port_op, psk->psk_src.port[0], psk->psk_src.port[1], srcport)) @@ -2538,6 +2544,10 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, return (EINVAL); PFNV_CHK(pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &kill->psk_dst)); + if (nvlist_exists_nvlist(nvl, "rt_addr")) { + PFNV_CHK(pf_nvrule_addr_to_rule_addr( + nvlist_get_nvlist(nvl, "rt_addr"), &kill->psk_rt_addr)); + } PFNV_CHK(pf_nvstring(nvl, "ifname", kill->psk_ifname, sizeof(kill->psk_ifname))); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 167D66475BD; Fri, 14 May 2021 13:06:49 +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 4FhTLw5RwHz3kmg; Fri, 14 May 2021 13:06:48 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 566DC12AE7; Fri, 14 May 2021 13:06:48 +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 14ED6moT052502; Fri, 14 May 2021 13:06:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6m0J052501; Fri, 14 May 2021 13:06:48 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:48 GMT Message-Id: <202105141306.14ED6m0J052501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 714762dad401 - stable/13 - pfctl: Optionally show gateway information for states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 714762dad401e55e1bfc1215d94a4d585a03f045 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=714762dad401e55e1bfc1215d94a4d585a03f045 commit 714762dad401e55e1bfc1215d94a4d585a03f045 Author: Kristof Provost AuthorDate: 2021-04-28 16:17:40 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:21:37 +0000 pfctl: Optionally show gateway information for states When showing the states, in very verbose mode, also display the gateway (i.e. the target for route-to/reply-to). Submitted by: Steven Brown Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30051 (cherry picked from commit cc948296e632e023f9374ccee68b5710f2ad54a9) --- sbin/pfctl/pf_print_state.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index 810c773f1019..e2f9d6efe609 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -354,6 +354,8 @@ print_state(struct pfsync_state *s, int opts) bcopy(&s->id, &id, sizeof(u_int64_t)); printf(" id: %016jx creatorid: %08x", (uintmax_t )be64toh(id), ntohl(s->creatorid)); + printf(" gateway: "); + print_host(&s->rt_addr, 0, s->af, opts); printf("\n"); } } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61E6D647714; Fri, 14 May 2021 13:06:53 +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 4FhTM05vwyz3ksv; Fri, 14 May 2021 13:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D45DF12C47; Fri, 14 May 2021 13:06: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 14ED6pCa052628; Fri, 14 May 2021 13:06:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6pwc052627; Fri, 14 May 2021 13:06:51 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:51 GMT Message-Id: <202105141306.14ED6pwc052627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: c505bdcc4e88 - stable/13 - authpf: Start using libpfctl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c505bdcc4e8856975920b67f8e070f944331c921 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:56 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c505bdcc4e8856975920b67f8e070f944331c921 commit c505bdcc4e8856975920b67f8e070f944331c921 Author: Kristof Provost AuthorDate: 2021-04-30 08:26:52 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:40:12 +0000 authpf: Start using libpfctl Use pfctl_kill_states() rather than the DIOCKILLSTATES ioctl directly. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30057 (cherry picked from commit 2b2ed4a69730be72f792179d57dedf2945b3d1aa) --- contrib/pf/authpf/authpf.c | 35 ++++++++++++++++++----------------- usr.sbin/authpf/Makefile | 3 ++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/contrib/pf/authpf/authpf.c b/contrib/pf/authpf/authpf.c index ac5d85b21cbc..4032efb27895 100644 --- a/contrib/pf/authpf/authpf.c +++ b/contrib/pf/authpf/authpf.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #ifdef __FreeBSD__ #include #endif +#include #include #include #include @@ -889,37 +890,37 @@ change_table(int add, const char *ip_src) static void authpf_kill_states(void) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; struct pf_addr target; - memset(&psk, 0, sizeof(psk)); + memset(&kill, 0, sizeof(kill)); memset(&target, 0, sizeof(target)); if (inet_pton(AF_INET, ipsrc, &target.v4) == 1) - psk.psk_af = AF_INET; + kill.af = AF_INET; else if (inet_pton(AF_INET6, ipsrc, &target.v6) == 1) - psk.psk_af = AF_INET6; + kill.af = AF_INET6; else { syslog(LOG_ERR, "inet_pton(%s) failed", ipsrc); return; } /* Kill all states from ipsrc */ - memcpy(&psk.psk_src.addr.v.a.addr, &target, - sizeof(psk.psk_src.addr.v.a.addr)); - memset(&psk.psk_src.addr.v.a.mask, 0xff, - sizeof(psk.psk_src.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) - syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); + memcpy(&kill.src.addr.v.a.addr, &target, + sizeof(kill.src.addr.v.a.addr)); + memset(&kill.src.addr.v.a.mask, 0xff, + sizeof(kill.src.addr.v.a.mask)); + if (pfctl_kill_states(dev, &kill, NULL)) + syslog(LOG_ERR, "pfctl_kill_states() failed (%m)"); /* Kill all states to ipsrc */ - memset(&psk.psk_src, 0, sizeof(psk.psk_src)); - memcpy(&psk.psk_dst.addr.v.a.addr, &target, - sizeof(psk.psk_dst.addr.v.a.addr)); - memset(&psk.psk_dst.addr.v.a.mask, 0xff, - sizeof(psk.psk_dst.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) - syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); + memset(&kill.src, 0, sizeof(kill.src)); + memcpy(&kill.dst.addr.v.a.addr, &target, + sizeof(kill.dst.addr.v.a.addr)); + memset(&kill.dst.addr.v.a.mask, 0xff, + sizeof(kill.dst.addr.v.a.mask)); + if (pfctl_kill_states(dev, &kill, NULL)) + syslog(LOG_ERR, "pfctl_kill_states() failed (%m)"); } /* signal handler that makes us go away properly */ diff --git a/usr.sbin/authpf/Makefile b/usr.sbin/authpf/Makefile index 19fd66b47b3d..62fe84086c16 100644 --- a/usr.sbin/authpf/Makefile +++ b/usr.sbin/authpf/Makefile @@ -12,8 +12,9 @@ SRCS= authpf.c # XXX ALTQ: CFLAGS+= -DENABLE_ALTQ +CFLAGS+= -I${SRCTOP}/lib/libpfctl -I${OBJTOP}/lib/libpfctl -LIBADD= m util +LIBADD= m util pfctl WARNS?= 3 From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 60DFB64763C; Fri, 14 May 2021 13:06:51 +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 4FhTLx5L0vz3klH; Fri, 14 May 2021 13:06:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1939912C45; Fri, 14 May 2021 13:06:49 +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 14ED6m1N052523; Fri, 14 May 2021 13:06:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6mC9052522; Fri, 14 May 2021 13:06:48 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:48 GMT Message-Id: <202105141306.14ED6mC9052522@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 32f27553f27b - stable/12 - pfctl: Optionally show gateway information for states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 32f27553f27b0bc53f7fbe6edbc6133e57237f55 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:51 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=32f27553f27b0bc53f7fbe6edbc6133e57237f55 commit 32f27553f27b0bc53f7fbe6edbc6133e57237f55 Author: Kristof Provost AuthorDate: 2021-04-28 16:17:40 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:21:43 +0000 pfctl: Optionally show gateway information for states When showing the states, in very verbose mode, also display the gateway (i.e. the target for route-to/reply-to). Submitted by: Steven Brown Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30051 (cherry picked from commit cc948296e632e023f9374ccee68b5710f2ad54a9) --- sbin/pfctl/pf_print_state.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index 810c773f1019..e2f9d6efe609 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -354,6 +354,8 @@ print_state(struct pfsync_state *s, int opts) bcopy(&s->id, &id, sizeof(u_int64_t)); printf(" id: %016jx creatorid: %08x", (uintmax_t )be64toh(id), ntohl(s->creatorid)); + printf(" gateway: "); + print_host(&s->rt_addr, 0, s->af, opts); printf("\n"); } } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5048C6476A8; Fri, 14 May 2021 13:06:53 +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 4FhTM01B4qz3l2D; Fri, 14 May 2021 13:06:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5ABA812C46; Fri, 14 May 2021 13:06: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 14ED6pR1052607; Fri, 14 May 2021 13:06:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6pha052606; Fri, 14 May 2021 13:06:51 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:51 GMT Message-Id: <202105141306.14ED6pha052606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 9321249f7319 - stable/12 - pf tests: Test killing states by gateway MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9321249f7319c9f5460d2674ee0d86424101f842 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:53 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9321249f7319c9f5460d2674ee0d86424101f842 commit 9321249f7319c9f5460d2674ee0d86424101f842 Author: Kristof Provost AuthorDate: 2021-04-30 15:07:23 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:39:43 +0000 pf tests: Test killing states by gateway MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30059 (cherry picked from commit c2e11d81d295f7d55ac8b6858b09d8fa123cbfe8) --- tests/sys/netpfil/pf/killstate.sh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 94363ed69ecc..ae0a4b88b228 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -246,9 +246,69 @@ multilabel_cleanup() pft_cleanup } +atf_test_case "gateway" "cleanup" +gateway_head() +{ + atf_set descr 'Test killing states by route-to/reply-to address' + atf_set require.user root + atf_set require.progs scapy +} + +gateway_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in reply-to (${epair}b 192.0.2.1) proto icmp" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing with a different gateway does not affect our state + jexec alcatraz pfctl -k gateway -k 192.0.2.2 + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Killing states with the relevant gateway does terminate our state + jexec alcatraz pfctl -k gateway -k 192.0.2.1 + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +gateway_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "label" atf_add_test_case "multilabel" + atf_add_test_case "gateway" } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB84E647645; Fri, 14 May 2021 13:06:56 +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 4FhTM35M3yz3kyp; Fri, 14 May 2021 13:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C10B212AEB; Fri, 14 May 2021 13:06:54 +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 14ED6sVt052739; Fri, 14 May 2021 13:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6sdT052738; Fri, 14 May 2021 13:06:54 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:54 GMT Message-Id: <202105141306.14ED6sdT052738@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 147c64747203 - stable/12 - pf tests: Test killing matching states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 147c64747203053e55a28a4c5d7515f4d7cbce82 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:57 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=147c64747203053e55a28a4c5d7515f4d7cbce82 commit 147c64747203053e55a28a4c5d7515f4d7cbce82 Author: Kristof Provost AuthorDate: 2021-05-03 13:31:03 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:48:52 +0000 pf tests: Test killing matching states MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30093 (cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6) --- tests/sys/netpfil/pf/killstate.sh | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index ae0a4b88b228..131b6268daf7 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -305,10 +305,81 @@ gateway_cleanup() pft_cleanup } +atf_test_case "match" "cleanup" +match_head() +{ + atf_set descr 'Test killing matching states' + atf_set require.user root +} + +match_body() +{ + pft_init + + epair_one=$(vnet_mkepair) + ifconfig ${epair_one}a 192.0.2.1/24 up + + epair_two=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair_one}b ${epair_two}a + jexec alcatraz ifconfig ${epair_one}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_two}a 198.51.100.1/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + jexec alcatraz pfctl -e + + vnet_mkjail singsing ${epair_two}b + jexec singsing ifconfig ${epair_two}b 198.51.100.2/24 up + jexec singsing route add default 198.51.100.1 + jexec singsing /usr/sbin/inetd -p inetd-echo.pid \ + $(atf_get_srcdir)/echo_inetd.conf + + route add 198.51.100.0/24 192.0.2.2 + + pft_set_rules alcatraz \ + "nat on ${epair_two}a from 192.0.2.0/24 -> (${epair_two}a)" \ + "pass all" + + nc 198.51.100.2 7 & + + # Expect two states + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 2 ] ; + then + atf_fail "Expected two states, found $states" + fi + + # If we don't kill the matching NAT state one should be left + jexec alcatraz pfctl -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 1 ] ; + then + atf_fail "Expected one states, found $states" + fi + + # Flush + jexec alcatraz pfctl -F states + + nc 198.51.100.2 7 & + + # Kill matching states, expect all of them to be gone + jexec alcatraz pfctl -M -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 0 ] ; + then + atf_fail "Expected zero states, found $states" + fi +} + +match_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "label" atf_add_test_case "multilabel" atf_add_test_case "gateway" + atf_add_test_case "match" } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E46DF6476B3; Fri, 14 May 2021 13:06:53 +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 4FhTM05wH6z3kqt; Fri, 14 May 2021 13:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7DE8C12D1B; Fri, 14 May 2021 13:06:52 +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 14ED6qPP052649; Fri, 14 May 2021 13:06:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6qXV052648; Fri, 14 May 2021 13:06:52 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:52 GMT Message-Id: <202105141306.14ED6qXV052648@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 468e68a9172e - stable/12 - authpf: Start using libpfctl MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 468e68a9172e997739db9bf554a14cb04a2bde72 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:56 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=468e68a9172e997739db9bf554a14cb04a2bde72 commit 468e68a9172e997739db9bf554a14cb04a2bde72 Author: Kristof Provost AuthorDate: 2021-04-30 08:26:52 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:40:15 +0000 authpf: Start using libpfctl Use pfctl_kill_states() rather than the DIOCKILLSTATES ioctl directly. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30057 (cherry picked from commit 2b2ed4a69730be72f792179d57dedf2945b3d1aa) --- contrib/pf/authpf/authpf.c | 35 ++++++++++++++++++----------------- usr.sbin/authpf/Makefile | 3 ++- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/contrib/pf/authpf/authpf.c b/contrib/pf/authpf/authpf.c index ac5d85b21cbc..4032efb27895 100644 --- a/contrib/pf/authpf/authpf.c +++ b/contrib/pf/authpf/authpf.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #ifdef __FreeBSD__ #include #endif +#include #include #include #include @@ -889,37 +890,37 @@ change_table(int add, const char *ip_src) static void authpf_kill_states(void) { - struct pfioc_state_kill psk; + struct pfctl_kill kill; struct pf_addr target; - memset(&psk, 0, sizeof(psk)); + memset(&kill, 0, sizeof(kill)); memset(&target, 0, sizeof(target)); if (inet_pton(AF_INET, ipsrc, &target.v4) == 1) - psk.psk_af = AF_INET; + kill.af = AF_INET; else if (inet_pton(AF_INET6, ipsrc, &target.v6) == 1) - psk.psk_af = AF_INET6; + kill.af = AF_INET6; else { syslog(LOG_ERR, "inet_pton(%s) failed", ipsrc); return; } /* Kill all states from ipsrc */ - memcpy(&psk.psk_src.addr.v.a.addr, &target, - sizeof(psk.psk_src.addr.v.a.addr)); - memset(&psk.psk_src.addr.v.a.mask, 0xff, - sizeof(psk.psk_src.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) - syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); + memcpy(&kill.src.addr.v.a.addr, &target, + sizeof(kill.src.addr.v.a.addr)); + memset(&kill.src.addr.v.a.mask, 0xff, + sizeof(kill.src.addr.v.a.mask)); + if (pfctl_kill_states(dev, &kill, NULL)) + syslog(LOG_ERR, "pfctl_kill_states() failed (%m)"); /* Kill all states to ipsrc */ - memset(&psk.psk_src, 0, sizeof(psk.psk_src)); - memcpy(&psk.psk_dst.addr.v.a.addr, &target, - sizeof(psk.psk_dst.addr.v.a.addr)); - memset(&psk.psk_dst.addr.v.a.mask, 0xff, - sizeof(psk.psk_dst.addr.v.a.mask)); - if (ioctl(dev, DIOCKILLSTATES, &psk)) - syslog(LOG_ERR, "DIOCKILLSTATES failed (%m)"); + memset(&kill.src, 0, sizeof(kill.src)); + memcpy(&kill.dst.addr.v.a.addr, &target, + sizeof(kill.dst.addr.v.a.addr)); + memset(&kill.dst.addr.v.a.mask, 0xff, + sizeof(kill.dst.addr.v.a.mask)); + if (pfctl_kill_states(dev, &kill, NULL)) + syslog(LOG_ERR, "pfctl_kill_states() failed (%m)"); } /* signal handler that makes us go away properly */ diff --git a/usr.sbin/authpf/Makefile b/usr.sbin/authpf/Makefile index 19fd66b47b3d..62fe84086c16 100644 --- a/usr.sbin/authpf/Makefile +++ b/usr.sbin/authpf/Makefile @@ -12,8 +12,9 @@ SRCS= authpf.c # XXX ALTQ: CFLAGS+= -DENABLE_ALTQ +CFLAGS+= -I${SRCTOP}/lib/libpfctl -I${OBJTOP}/lib/libpfctl -LIBADD= m util +LIBADD= m util pfctl WARNS?= 3 From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D0F5C6476B5; Fri, 14 May 2021 13:06:54 +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 4FhTM16WSbz3kwG; Fri, 14 May 2021 13:06:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E43E412964; Fri, 14 May 2021 13:06:52 +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 14ED6qnL052670; Fri, 14 May 2021 13:06:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6qAS052669; Fri, 14 May 2021 13:06:52 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:52 GMT Message-Id: <202105141306.14ED6qAS052669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 8c610ccac621 - stable/13 - pf: Support killing 'matching' states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8c610ccac621208022c5637ba2e2cc89790447f6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:57 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=8c610ccac621208022c5637ba2e2cc89790447f6 commit 8c610ccac621208022c5637ba2e2cc89790447f6 Author: Kristof Provost AuthorDate: 2021-05-03 13:35:50 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:42:07 +0000 pf: Support killing 'matching' states Optionally also kill states that match (i.e. are the NATed state or opposite direction state entry for) the state we're killing. See also https://redmine.pfsense.org/issues/8555 Submitted by: Steven Brown Reviewed by: bcr (man page) Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/ MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30092 (cherry picked from commit 93abcf17e6cf3c1cd8511c8ff7a8bf20b2d76367) --- lib/libpfctl/libpfctl.c | 1 + lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pfctl.8 | 13 +++++- sbin/pfctl/pfctl.c | 23 +++++++++- sbin/pfctl/pfctl_parser.h | 1 + sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 108 ++++++++++++++++++++++++++++++++++++++++------ 7 files changed, 131 insertions(+), 17 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index f50afa7c78ef..8271d9bab3df 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -645,6 +645,7 @@ _pfctl_clear_states(int dev, const struct pfctl_kill *kill, pfctl_nv_add_rule_addr(nvl, "rt_addr", &kill->rt_addr); nvlist_add_string(nvl, "ifname", kill->ifname); nvlist_add_string(nvl, "label", kill->label); + nvlist_add_bool(nvl, "kill_match", kill->kill_match); nv.data = nvlist_pack(nvl, &nv.len); nv.size = nv.len; diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 5c8b2108d937..7a1e02f3d01b 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -194,6 +194,7 @@ struct pfctl_kill { struct pf_rule_addr rt_addr; char ifname[IFNAMSIZ]; char label[PF_RULE_LABEL_SIZE]; + bool kill_match; }; int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8 index f3905f850c5a..ad0d1ba34769 100644 --- a/sbin/pfctl/pfctl.8 +++ b/sbin/pfctl/pfctl.8 @@ -35,7 +35,7 @@ .Sh SYNOPSIS .Nm pfctl .Bk -words -.Op Fl AdeghmNnOPqRrvz +.Op Fl AdeghMmNnOPqRrvz .Op Fl a Ar anchor .Oo Fl D Ar macro Ns = .Ar value Oc @@ -331,6 +331,17 @@ A network prefix length can also be specified. To kill all states using a gateway in 192.168.0.0/24: .Pp .Dl # pfctl -k gateway -k 192.168.0.0/24 +.Pp +.It Fl M +Kill matching states in the opposite direction (on other interfaces) when +killing states. +This applies to states killed using the -k option and also will apply to the +flush command when flushing states. +This is useful when an interface is specified when flushing states. +Example: +.Pp +.Dl # pfctl -M -i interface -Fs +.Pp .It Fl m Merge in explicitly given options without resetting those which are omitted. diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 96f3b4740d90..fd937cac9f63 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -245,7 +245,7 @@ usage(void) extern char *__progname; fprintf(stderr, -"usage: %s [-AdeghmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" +"usage: %s [-AdeghMmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" "\t[-f file] [-i interface] [-K host | network]\n" "\t[-k host | network | gateway | label | id] [-o level] [-p device]\n" "\t[-s modifier] [-t table -T command [address ...]] [-x level]\n", @@ -478,6 +478,9 @@ pfctl_clear_iface_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if (pfctl_clear_states(dev, &kill, &killed)) err(1, "DIOCCLRSTATES"); if ((opts & PF_OPT_QUIET) == 0) @@ -661,6 +664,9 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) pfctl_addrprefix(state_kill[0], &kill.src.addr.v.a.mask); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if ((ret_ga = getaddrinfo(state_kill[0], NULL, NULL, &res[0]))) { errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); /* NOTREACHED */ @@ -768,6 +774,9 @@ pfctl_gateway_kill_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + pfctl_addrprefix(state_kill[1], &kill.rt_addr.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res))) { @@ -821,6 +830,9 @@ pfctl_label_kill_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if (strlcpy(kill.label, state_kill[1], sizeof(kill.label)) >= sizeof(kill.label)) errx(1, "label too long: %s", state_kill[1]); @@ -846,6 +858,10 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) } memset(&kill, 0, sizeof(kill)); + + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if ((sscanf(state_kill[1], "%jx/%x", &kill.cmp.id, &kill.cmp.creatorid)) == 2) HTONL(kill.cmp.creatorid); @@ -2199,7 +2215,7 @@ main(int argc, char *argv[]) usage(); while ((ch = getopt(argc, argv, - "a:AdD:eqf:F:ghi:k:K:mnNOo:Pp:rRs:t:T:vx:z")) != -1) { + "a:AdD:eqf:F:ghi:k:K:mMnNOo:Pp:rRs:t:T:vx:z")) != -1) { switch (ch) { case 'a': anchoropt = optarg; @@ -2252,6 +2268,9 @@ main(int argc, char *argv[]) case 'm': opts |= PF_OPT_MERGE; break; + case 'M': + opts |= PF_OPT_KILLMATCH; + break; case 'n': opts |= PF_OPT_NOACTION; break; diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 0c66d5dda97a..5353900b380a 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -55,6 +55,7 @@ #define PF_OPT_NUMERIC 0x1000 #define PF_OPT_MERGE 0x2000 #define PF_OPT_RECURSE 0x4000 +#define PF_OPT_KILLMATCH 0x8000 #define PF_TH_ALL 0xFF diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 0b08b418d625..628eae10040b 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1083,6 +1083,7 @@ struct pf_kstate_kill { char psk_ifname[IFNAMSIZ]; char psk_label[PF_RULE_LABEL_SIZE]; u_int psk_killed; + bool psk_kill_match; }; #endif diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 07ee7ba77a80..81f766a5c1ab 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2416,13 +2416,33 @@ pf_label_match(const struct pf_krule *rule, const char *label) return (false); } +static unsigned int +pf_kill_matching_state(struct pf_state_key_cmp *key, int dir) +{ + struct pf_state *match; + int more = 0; + unsigned int killed = 0; + + /* Call with unlocked hashrow */ + + match = pf_find_state_all(key, dir, &more); + if (match && !more) { + pf_unlink_state(match, 0); + killed++; + } + + return (killed); +} + static int pf_killstates_row(struct pf_kstate_kill *psk, struct pf_idhash *ih) { struct pf_state *s; struct pf_state_key *sk; struct pf_addr *srcaddr, *dstaddr; - int killed = 0; + struct pf_state_key_cmp match_key; + int idx, killed = 0; + unsigned int dir; u_int16_t srcport, dstport; relock_DIOCKILLSTATES: @@ -2479,8 +2499,36 @@ relock_DIOCKILLSTATES: s->kif->pfik_name)) continue; + if (psk->psk_kill_match) { + /* Create the key to find matching states, with lock + * held. */ + + bzero(&match_key, sizeof(match_key)); + + if (s->direction == PF_OUT) { + dir = PF_IN; + idx = PF_SK_STACK; + } else { + dir = PF_OUT; + idx = PF_SK_WIRE; + } + + match_key.af = s->key[idx]->af; + match_key.proto = s->key[idx]->proto; + PF_ACPY(&match_key.addr[0], + &s->key[idx]->addr[1], match_key.af); + match_key.port[0] = s->key[idx]->port[1]; + PF_ACPY(&match_key.addr[1], + &s->key[idx]->addr[0], match_key.af); + match_key.port[1] = s->key[idx]->port[0]; + } + pf_unlink_state(s, PF_ENTER_LOCKED); killed++; + + if (psk->psk_kill_match) + killed += pf_kill_matching_state(&match_key, dir); + goto relock_DIOCKILLSTATES; } PF_HASHROW_UNLOCK(ih); @@ -2553,6 +2601,8 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, sizeof(kill->psk_ifname))); PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, sizeof(kill->psk_label))); + if (nvlist_exists_bool(nvl, "kill_match")) + kill->psk_kill_match = nvlist_get_bool(nvl, "kill_match"); errout: return (error); @@ -5442,27 +5492,57 @@ on_error: static unsigned int pf_clear_states(const struct pf_kstate_kill *kill) { + struct pf_state_key_cmp match_key; struct pf_state *s; - unsigned int killed = 0; + int idx; + unsigned int killed = 0, dir; for (unsigned int i = 0; i <= pf_hashmask; i++) { struct pf_idhash *ih = &V_pf_idhash[i]; relock_DIOCCLRSTATES: PF_HASHROW_LOCK(ih); - LIST_FOREACH(s, &ih->states, entry) - if (!kill->psk_ifname[0] || - !strcmp(kill->psk_ifname, - s->kif->pfik_name)) { - /* - * Don't send out individual - * delete messages. - */ - s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); - killed++; - goto relock_DIOCCLRSTATES; + LIST_FOREACH(s, &ih->states, entry) { + if (kill->psk_ifname[0] && + strcmp(kill->psk_ifname, + s->kif->pfik_name)) + continue; + + if (kill->psk_kill_match) { + bzero(&match_key, sizeof(match_key)); + + if (s->direction == PF_OUT) { + dir = PF_IN; + idx = PF_SK_STACK; + } else { + dir = PF_OUT; + idx = PF_SK_WIRE; + } + + match_key.af = s->key[idx]->af; + match_key.proto = s->key[idx]->proto; + PF_ACPY(&match_key.addr[0], + &s->key[idx]->addr[1], match_key.af); + match_key.port[0] = s->key[idx]->port[1]; + PF_ACPY(&match_key.addr[1], + &s->key[idx]->addr[0], match_key.af); + match_key.port[1] = s->key[idx]->port[0]; } + + /* + * Don't send out individual + * delete messages. + */ + s->state_flags |= PFSTATE_NOSYNC; + pf_unlink_state(s, PF_ENTER_LOCKED); + killed++; + + if (kill->psk_kill_match) + killed += pf_kill_matching_state(&match_key, + dir); + + goto relock_DIOCCLRSTATES; + } PF_HASHROW_UNLOCK(ih); } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 418836473F4; Fri, 14 May 2021 13:06:56 +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 4FhTM259tMz3kwQ; Fri, 14 May 2021 13:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9D6C812AE9; Fri, 14 May 2021 13:06:53 +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 14ED6rkw052693; Fri, 14 May 2021 13:06:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6rJH052692; Fri, 14 May 2021 13:06:53 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:53 GMT Message-Id: <202105141306.14ED6rJH052692@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 21449c5c1eee - stable/12 - pf: Support killing 'matching' states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 21449c5c1eee253dc5ce5a70632edba525f803e7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:57 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=21449c5c1eee253dc5ce5a70632edba525f803e7 commit 21449c5c1eee253dc5ce5a70632edba525f803e7 Author: Kristof Provost AuthorDate: 2021-05-03 13:35:50 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:48:30 +0000 pf: Support killing 'matching' states Optionally also kill states that match (i.e. are the NATed state or opposite direction state entry for) the state we're killing. See also https://redmine.pfsense.org/issues/8555 Submitted by: Steven Brown Reviewed by: bcr (man page) Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/ MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30092 (cherry picked from commit 93abcf17e6cf3c1cd8511c8ff7a8bf20b2d76367) --- lib/libpfctl/libpfctl.c | 1 + lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pfctl.8 | 13 +++++- sbin/pfctl/pfctl.c | 23 +++++++++- sbin/pfctl/pfctl_parser.h | 1 + sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 108 ++++++++++++++++++++++++++++++++++++++++------ 7 files changed, 131 insertions(+), 17 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index f50afa7c78ef..8271d9bab3df 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -645,6 +645,7 @@ _pfctl_clear_states(int dev, const struct pfctl_kill *kill, pfctl_nv_add_rule_addr(nvl, "rt_addr", &kill->rt_addr); nvlist_add_string(nvl, "ifname", kill->ifname); nvlist_add_string(nvl, "label", kill->label); + nvlist_add_bool(nvl, "kill_match", kill->kill_match); nv.data = nvlist_pack(nvl, &nv.len); nv.size = nv.len; diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 5c8b2108d937..7a1e02f3d01b 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -194,6 +194,7 @@ struct pfctl_kill { struct pf_rule_addr rt_addr; char ifname[IFNAMSIZ]; char label[PF_RULE_LABEL_SIZE]; + bool kill_match; }; int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8 index f3905f850c5a..ad0d1ba34769 100644 --- a/sbin/pfctl/pfctl.8 +++ b/sbin/pfctl/pfctl.8 @@ -35,7 +35,7 @@ .Sh SYNOPSIS .Nm pfctl .Bk -words -.Op Fl AdeghmNnOPqRrvz +.Op Fl AdeghMmNnOPqRrvz .Op Fl a Ar anchor .Oo Fl D Ar macro Ns = .Ar value Oc @@ -331,6 +331,17 @@ A network prefix length can also be specified. To kill all states using a gateway in 192.168.0.0/24: .Pp .Dl # pfctl -k gateway -k 192.168.0.0/24 +.Pp +.It Fl M +Kill matching states in the opposite direction (on other interfaces) when +killing states. +This applies to states killed using the -k option and also will apply to the +flush command when flushing states. +This is useful when an interface is specified when flushing states. +Example: +.Pp +.Dl # pfctl -M -i interface -Fs +.Pp .It Fl m Merge in explicitly given options without resetting those which are omitted. diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 96f3b4740d90..fd937cac9f63 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -245,7 +245,7 @@ usage(void) extern char *__progname; fprintf(stderr, -"usage: %s [-AdeghmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" +"usage: %s [-AdeghMmNnOPqRrvz] [-a anchor] [-D macro=value] [-F modifier]\n" "\t[-f file] [-i interface] [-K host | network]\n" "\t[-k host | network | gateway | label | id] [-o level] [-p device]\n" "\t[-s modifier] [-t table -T command [address ...]] [-x level]\n", @@ -478,6 +478,9 @@ pfctl_clear_iface_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if (pfctl_clear_states(dev, &kill, &killed)) err(1, "DIOCCLRSTATES"); if ((opts & PF_OPT_QUIET) == 0) @@ -661,6 +664,9 @@ pfctl_net_kill_states(int dev, const char *iface, int opts) pfctl_addrprefix(state_kill[0], &kill.src.addr.v.a.mask); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if ((ret_ga = getaddrinfo(state_kill[0], NULL, NULL, &res[0]))) { errx(1, "getaddrinfo: %s", gai_strerror(ret_ga)); /* NOTREACHED */ @@ -768,6 +774,9 @@ pfctl_gateway_kill_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + pfctl_addrprefix(state_kill[1], &kill.rt_addr.addr.v.a.mask); if ((ret_ga = getaddrinfo(state_kill[1], NULL, NULL, &res))) { @@ -821,6 +830,9 @@ pfctl_label_kill_states(int dev, const char *iface, int opts) sizeof(kill.ifname)) >= sizeof(kill.ifname)) errx(1, "invalid interface: %s", iface); + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if (strlcpy(kill.label, state_kill[1], sizeof(kill.label)) >= sizeof(kill.label)) errx(1, "label too long: %s", state_kill[1]); @@ -846,6 +858,10 @@ pfctl_id_kill_states(int dev, const char *iface, int opts) } memset(&kill, 0, sizeof(kill)); + + if (opts & PF_OPT_KILLMATCH) + kill.kill_match = true; + if ((sscanf(state_kill[1], "%jx/%x", &kill.cmp.id, &kill.cmp.creatorid)) == 2) HTONL(kill.cmp.creatorid); @@ -2199,7 +2215,7 @@ main(int argc, char *argv[]) usage(); while ((ch = getopt(argc, argv, - "a:AdD:eqf:F:ghi:k:K:mnNOo:Pp:rRs:t:T:vx:z")) != -1) { + "a:AdD:eqf:F:ghi:k:K:mMnNOo:Pp:rRs:t:T:vx:z")) != -1) { switch (ch) { case 'a': anchoropt = optarg; @@ -2252,6 +2268,9 @@ main(int argc, char *argv[]) case 'm': opts |= PF_OPT_MERGE; break; + case 'M': + opts |= PF_OPT_KILLMATCH; + break; case 'n': opts |= PF_OPT_NOACTION; break; diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h index 0c66d5dda97a..5353900b380a 100644 --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -55,6 +55,7 @@ #define PF_OPT_NUMERIC 0x1000 #define PF_OPT_MERGE 0x2000 #define PF_OPT_RECURSE 0x4000 +#define PF_OPT_KILLMATCH 0x8000 #define PF_TH_ALL 0xFF diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 196a5edb874a..fda0cc57681d 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1083,6 +1083,7 @@ struct pf_kstate_kill { char psk_ifname[IFNAMSIZ]; char psk_label[PF_RULE_LABEL_SIZE]; u_int psk_killed; + bool psk_kill_match; }; #endif diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 69d32b835a43..d676bc7ec9c1 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2417,13 +2417,33 @@ pf_label_match(const struct pf_krule *rule, const char *label) return (false); } +static unsigned int +pf_kill_matching_state(struct pf_state_key_cmp *key, int dir) +{ + struct pf_state *match; + int more = 0; + unsigned int killed = 0; + + /* Call with unlocked hashrow */ + + match = pf_find_state_all(key, dir, &more); + if (match && !more) { + pf_unlink_state(match, 0); + killed++; + } + + return (killed); +} + static int pf_killstates_row(struct pf_kstate_kill *psk, struct pf_idhash *ih) { struct pf_state *s; struct pf_state_key *sk; struct pf_addr *srcaddr, *dstaddr; - int killed = 0; + struct pf_state_key_cmp match_key; + int idx, killed = 0; + unsigned int dir; u_int16_t srcport, dstport; relock_DIOCKILLSTATES: @@ -2480,8 +2500,36 @@ relock_DIOCKILLSTATES: s->kif->pfik_name)) continue; + if (psk->psk_kill_match) { + /* Create the key to find matching states, with lock + * held. */ + + bzero(&match_key, sizeof(match_key)); + + if (s->direction == PF_OUT) { + dir = PF_IN; + idx = PF_SK_STACK; + } else { + dir = PF_OUT; + idx = PF_SK_WIRE; + } + + match_key.af = s->key[idx]->af; + match_key.proto = s->key[idx]->proto; + PF_ACPY(&match_key.addr[0], + &s->key[idx]->addr[1], match_key.af); + match_key.port[0] = s->key[idx]->port[1]; + PF_ACPY(&match_key.addr[1], + &s->key[idx]->addr[0], match_key.af); + match_key.port[1] = s->key[idx]->port[0]; + } + pf_unlink_state(s, PF_ENTER_LOCKED); killed++; + + if (psk->psk_kill_match) + killed += pf_kill_matching_state(&match_key, dir); + goto relock_DIOCKILLSTATES; } PF_HASHROW_UNLOCK(ih); @@ -2554,6 +2602,8 @@ pf_nvstate_kill_to_kstate_kill(const nvlist_t *nvl, sizeof(kill->psk_ifname))); PFNV_CHK(pf_nvstring(nvl, "label", kill->psk_label, sizeof(kill->psk_label))); + if (nvlist_exists_bool(nvl, "kill_match")) + kill->psk_kill_match = nvlist_get_bool(nvl, "kill_match"); errout: return (error); @@ -5457,27 +5507,57 @@ on_error: static unsigned int pf_clear_states(const struct pf_kstate_kill *kill) { + struct pf_state_key_cmp match_key; struct pf_state *s; - unsigned int killed = 0; + int idx; + unsigned int killed = 0, dir; for (unsigned int i = 0; i <= pf_hashmask; i++) { struct pf_idhash *ih = &V_pf_idhash[i]; relock_DIOCCLRSTATES: PF_HASHROW_LOCK(ih); - LIST_FOREACH(s, &ih->states, entry) - if (!kill->psk_ifname[0] || - !strcmp(kill->psk_ifname, - s->kif->pfik_name)) { - /* - * Don't send out individual - * delete messages. - */ - s->state_flags |= PFSTATE_NOSYNC; - pf_unlink_state(s, PF_ENTER_LOCKED); - killed++; - goto relock_DIOCCLRSTATES; + LIST_FOREACH(s, &ih->states, entry) { + if (kill->psk_ifname[0] && + strcmp(kill->psk_ifname, + s->kif->pfik_name)) + continue; + + if (kill->psk_kill_match) { + bzero(&match_key, sizeof(match_key)); + + if (s->direction == PF_OUT) { + dir = PF_IN; + idx = PF_SK_STACK; + } else { + dir = PF_OUT; + idx = PF_SK_WIRE; + } + + match_key.af = s->key[idx]->af; + match_key.proto = s->key[idx]->proto; + PF_ACPY(&match_key.addr[0], + &s->key[idx]->addr[1], match_key.af); + match_key.port[0] = s->key[idx]->port[1]; + PF_ACPY(&match_key.addr[1], + &s->key[idx]->addr[0], match_key.af); + match_key.port[1] = s->key[idx]->port[0]; } + + /* + * Don't send out individual + * delete messages. + */ + s->state_flags |= PFSTATE_NOSYNC; + pf_unlink_state(s, PF_ENTER_LOCKED); + killed++; + + if (kill->psk_kill_match) + killed += pf_kill_matching_state(&match_key, + dir); + + goto relock_DIOCCLRSTATES; + } PF_HASHROW_UNLOCK(ih); } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:06:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83CAB647644; Fri, 14 May 2021 13:06:56 +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 4FhTM35L2Gz3kyn; Fri, 14 May 2021 13:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0FEFC12AEA; Fri, 14 May 2021 13:06:54 +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 14ED6rQl052718; Fri, 14 May 2021 13:06:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ED6rLd052717; Fri, 14 May 2021 13:06:53 GMT (envelope-from git) Date: Fri, 14 May 2021 13:06:53 GMT Message-Id: <202105141306.14ED6rLd052717@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 97f7dda01427 - stable/13 - pf tests: Test killing matching states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 97f7dda014276e17ca50165ce1beac3ca430f862 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:57 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=97f7dda014276e17ca50165ce1beac3ca430f862 commit 97f7dda014276e17ca50165ce1beac3ca430f862 Author: Kristof Provost AuthorDate: 2021-05-03 13:31:03 +0000 Commit: Kristof Provost CommitDate: 2021-05-14 08:48:48 +0000 pf tests: Test killing matching states MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30093 (cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6) --- tests/sys/netpfil/pf/killstate.sh | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 4ec1adf0d051..ec01910f0867 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -377,6 +377,76 @@ gateway_cleanup() pft_cleanup } +atf_test_case "match" "cleanup" +match_head() +{ + atf_set descr 'Test killing matching states' + atf_set require.user root +} + +match_body() +{ + pft_init + + epair_one=$(vnet_mkepair) + ifconfig ${epair_one}a 192.0.2.1/24 up + + epair_two=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair_one}b ${epair_two}a + jexec alcatraz ifconfig ${epair_one}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_two}a 198.51.100.1/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + jexec alcatraz pfctl -e + + vnet_mkjail singsing ${epair_two}b + jexec singsing ifconfig ${epair_two}b 198.51.100.2/24 up + jexec singsing route add default 198.51.100.1 + jexec singsing /usr/sbin/inetd -p inetd-echo.pid \ + $(atf_get_srcdir)/echo_inetd.conf + + route add 198.51.100.0/24 192.0.2.2 + + pft_set_rules alcatraz \ + "nat on ${epair_two}a from 192.0.2.0/24 -> (${epair_two}a)" \ + "pass all" + + nc 198.51.100.2 7 & + + # Expect two states + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 2 ] ; + then + atf_fail "Expected two states, found $states" + fi + + # If we don't kill the matching NAT state one should be left + jexec alcatraz pfctl -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 1 ] ; + then + atf_fail "Expected one states, found $states" + fi + + # Flush + jexec alcatraz pfctl -F states + + nc 198.51.100.2 7 & + + # Kill matching states, expect all of them to be gone + jexec alcatraz pfctl -M -k 192.0.2.1 + states=$(jexec alcatraz pfctl -s s | wc -l) + if [ $states -ne 0 ] ; + then + atf_fail "Expected zero states, found $states" + fi +} + +match_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" @@ -384,4 +454,5 @@ atf_init_test_cases() atf_add_test_case "label" atf_add_test_case "multilabel" atf_add_test_case "gateway" + atf_add_test_case "match" } From owner-dev-commits-src-all@freebsd.org Fri May 14 13:57:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47A0564918C; Fri, 14 May 2021 13:57:11 +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 4FhVT31dFfz3pJf; Fri, 14 May 2021 13:57:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2650C13453; Fri, 14 May 2021 13:57:11 +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 14EDvBTZ018420; Fri, 14 May 2021 13:57:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EDvBAl018419; Fri, 14 May 2021 13:57:11 GMT (envelope-from git) Date: Fri, 14 May 2021 13:57:11 GMT Message-Id: <202105141357.14EDvBAl018419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 55b6c85e0c25 - stable/13 - syslogd: Increase message size limits MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 55b6c85e0c25ff6cb6e6529cad53abdd6cfae835 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:57:11 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=55b6c85e0c25ff6cb6e6529cad53abdd6cfae835 commit 55b6c85e0c25ff6cb6e6529cad53abdd6cfae835 Author: Dmitry Wagin AuthorDate: 2021-03-23 16:15:28 +0000 Commit: Mark Johnston CommitDate: 2021-05-14 13:56:17 +0000 syslogd: Increase message size limits Add a -M option to control the maximum length of forwarded messages. syslogd(8) used to truncate forwarded messages to 1024 bytes, but after commit 1a874a126a54 ("Add RFC 5424 syslog message output to syslogd.") applies a more conservative limit of 480 bytes for IPv4 per RFC 5426 section 3.2. Restore the old default behaviour of truncating to 1024 bytes. RFC 5424 specifies no upper limit on the length of forwarded messages, while for RFC 3164 the limit is 1024 bytes. Increase MAXLINE to 8192 bytes to correspond to commit 672ef817a192. Replaced bootfile[] size for MAXPATHLEN used in getbootfile(3) as a returned value. Using (MAXLINE+1) as a size for bootfile[] is excessive. PR: 241937 Differential Revision: https://reviews.freebsd.org/D27206 (cherry picked from commit 2d82b47a5b4ef18550565dd55628d51f54d0af2e) --- usr.sbin/syslogd/syslogd.8 | 6 ++++++ usr.sbin/syslogd/syslogd.c | 33 +++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index 0e1169771f0a..c908e130f114 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -41,6 +41,7 @@ .Op Fl b Ar bind_address .Op Fl f Ar config_file .Op Fl l Oo Ar mode Ns \&: Oc Ns Ar path +.Op Fl M Ar fwd_length .Op Fl m Ar mark_interval .Op Fl O Ar format .Op Fl P Ar pid_file @@ -243,6 +244,11 @@ Usually the .Dq kern facility is reserved for messages read directly from .Pa /dev/klog . +.It Fl M Ar fwd_length +Set the limit on the length of forwarded messages. +The minimum is 480 octets. +The maximum for RFC 3164 output format is 1024 octets. +The default is 1024 octets. .It Fl m Ar mark_interval Select the number of minutes between .Dq mark diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index acf9e193efd9..d8a2c0a5680e 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -97,8 +97,7 @@ __FBSDID("$FreeBSD$"); * Priority comparison code by Harlan Stenn. */ -/* Maximum number of characters in time of last occurrence */ -#define MAXLINE 2048 /* maximum line length */ +#define MAXLINE 8192 /* maximum line length */ #define MAXSVLINE MAXLINE /* maximum saved line length */ #define DEFUPRI (LOG_USER|LOG_NOTICE) #define DEFSPRI (LOG_KERN|LOG_CRIT) @@ -383,6 +382,7 @@ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ static int MarkSeq; /* mark sequence number */ static int NoBind; /* don't bind() as suggested by RFC 3164 */ static int SecureMode; /* when true, receive only unix domain socks */ +static int MaxForwardLen = 1024; /* max length of forwared message */ #ifdef INET6 static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */ #else @@ -394,7 +394,7 @@ static int use_bootfile; /* log entire bootfile for every kern msg */ static int no_compress; /* don't compress messages (1=pipes, 2=all) */ static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ -static char bootfile[MAXLINE+1]; /* booted kernel file */ +static char bootfile[MAXPATHLEN]; /* booted kernel file */ static int RemoteAddDate; /* Always set the date on remote messages */ static int RemoteHostname; /* Log remote hostname from the message */ @@ -553,7 +553,7 @@ main(int argc, char *argv[]) if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:m:nNoO:p:P:sS:Tuv")) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:M:m:nNoO:p:P:sS:Tuv")) != -1) switch (ch) { #ifdef INET @@ -666,6 +666,12 @@ main(int argc, char *argv[]) }); break; } + case 'M': /* max length of forwarded message */ + MaxForwardLen = atoi(optarg); + if (MaxForwardLen < 480) + errx(1, "minimum length limit of forwarded " + "messages is 480 bytes"); + break; case 'm': /* mark interval */ MarkInterval = atoi(optarg) * 60; break; @@ -710,6 +716,9 @@ main(int argc, char *argv[]) if ((argc -= optind) != 0) usage(); + if (RFC3164OutputFormat && MaxForwardLen > 1024) + errx(1, "RFC 3164 messages may not exceed 1024 bytes"); + /* Pipe to catch a signal during select(). */ s = pipe2(sigpipe, O_CLOEXEC); if (s < 0) { @@ -948,9 +957,9 @@ usage(void) fprintf(stderr, "usage: syslogd [-468ACcdFHknosTuv] [-a allowed_peer]\n" " [-b bind_address] [-f config_file]\n" - " [-l [mode:]path] [-m mark_interval]\n" - " [-O format] [-P pid_file] [-p log_socket]\n" - " [-S logpriv_socket]\n"); + " [-l [mode:]path] [-M fwd_length]\n" + " [-m mark_interval] [-O format] [-P pid_file]\n" + " [-p log_socket] [-S logpriv_socket]\n"); exit(1); } @@ -1840,27 +1849,27 @@ fprintlog_write(struct filed *f, struct iovlist *il, int flags) switch (f->f_type) { case F_FORW: - /* Truncate messages to RFC 5426 recommended size. */ dprintf(" %s", f->fu_forw_hname); switch (f->fu_forw_addr->ai_family) { #ifdef INET case AF_INET: dprintf(":%d\n", ntohs(satosin(f->fu_forw_addr->ai_addr)->sin_port)); - iovlist_truncate(il, 480); break; #endif #ifdef INET6 case AF_INET6: dprintf(":%d\n", ntohs(satosin6(f->fu_forw_addr->ai_addr)->sin6_port)); - iovlist_truncate(il, 1180); break; #endif default: dprintf("\n"); } + /* Truncate messages to maximum forward length. */ + iovlist_truncate(il, MaxForwardLen); + lsent = 0; for (r = f->fu_forw_addr; r; r = r->ai_next) { memset(&msghdr, 0, sizeof(msghdr)); @@ -2553,7 +2562,7 @@ init(int signo) char *p; char oldLocalHostName[MAXHOSTNAMELEN]; char hostMsg[2*MAXHOSTNAMELEN+40]; - char bootfileMsg[LINE_MAX]; + char bootfileMsg[MAXLINE + 1]; dprintf("init\n"); WantInitialize = 0; @@ -2900,7 +2909,7 @@ cfline(const char *line, const char *prog, const char *host, int error, i, pri, syncfile; const char *p, *q; char *bp, *pfilter_dup; - char buf[MAXLINE], ebuf[100]; + char buf[LINE_MAX], ebuf[100]; dprintf("cfline(\"%s\", f, \"%s\", \"%s\", \"%s\")\n", line, prog, host, pfilter); From owner-dev-commits-src-all@freebsd.org Fri May 14 13:57:12 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E07C64918E; Fri, 14 May 2021 13:57:12 +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 4FhVT42C5Fz3p10; Fri, 14 May 2021 13:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3E67813454; Fri, 14 May 2021 13:57:12 +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 14EDvC8W018441; Fri, 14 May 2021 13:57:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EDvCa2018440; Fri, 14 May 2021 13:57:12 GMT (envelope-from git) Date: Fri, 14 May 2021 13:57:12 GMT Message-Id: <202105141357.14EDvCa2018440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2886c93d1bca - stable/13 - libc: Some enhancements to syslog(3) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2886c93d1bca231260ebc01d4205743ca781f3c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:57:12 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2886c93d1bca231260ebc01d4205743ca781f3c7 commit 2886c93d1bca231260ebc01d4205743ca781f3c7 Author: Dmitry Wagin AuthorDate: 2021-03-23 16:01:15 +0000 Commit: Mark Johnston CommitDate: 2021-05-14 13:56:46 +0000 libc: Some enhancements to syslog(3) - Defined MAXLINE constant (8192 octets by default instead 2048) for centralized limit setting up. It sets maximum number of characters of the syslog message. RFC5424 doesn't limit maximum size of the message. Named after MAXLINE in syslogd(8). - Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted (%m) messages. - Introduced autoexpansion of sending socket buffer up to MAXLINE. Differential Revision: https://reviews.freebsd.org/D27205 (cherry picked from commit 9bd7345212203924046009e29ce3f1515556f989) --- lib/libc/gen/syslog.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 19d44db0075a..797c7389d1a2 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -57,6 +57,9 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +/* Maximum number of characters of syslog message */ +#define MAXLINE 8192 + static int LogFile = -1; /* fd for log */ static int status; /* connection status */ static int opened; /* have done openlog() */ @@ -141,7 +144,7 @@ vsyslog1(int pri, const char *fmt, va_list ap) char ch, *p; long tz_offset; int cnt, fd, saved_errno; - char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024], + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[MAXLINE], fmt_cpy[MAXLINE], errstr[64], tz_sign; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; @@ -396,9 +399,19 @@ connectlog(void) struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ if (LogFile == -1) { + socklen_t len; + if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) return; + if (_getsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, &len, + &(socklen_t){sizeof(len)}) == 0) { + if (len < MAXLINE) { + len = MAXLINE; + (void)_setsockopt(LogFile, SOL_SOCKET, SO_SNDBUF, + &len, sizeof(len)); + } + } } if (LogFile != -1 && status == NOCONN) { SyslogAddr.sun_len = sizeof(SyslogAddr); From owner-dev-commits-src-all@freebsd.org Fri May 14 14:03:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1285064947C; Fri, 14 May 2021 14:03:07 +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 4FhVbt73N3z3ps0; Fri, 14 May 2021 14:03:06 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DA5F413A0F; Fri, 14 May 2021 14:03:06 +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 14EE361P032150; Fri, 14 May 2021 14:03:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EE36lr032149; Fri, 14 May 2021 14:03:06 GMT (envelope-from git) Date: Fri, 14 May 2021 14:03:06 GMT Message-Id: <202105141403.14EE36lr032149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: abd116de1d42 - stable/13 - cryptodev: Fix some input validation bugs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: abd116de1d42489c641adadca515fcfc76000904 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 14:03:07 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=abd116de1d42489c641adadca515fcfc76000904 commit abd116de1d42489c641adadca515fcfc76000904 Author: Mark Johnston AuthorDate: 2021-05-11 21:36:12 +0000 Commit: Mark Johnston CommitDate: 2021-05-14 13:58:54 +0000 cryptodev: Fix some input validation bugs - When we do not have a separate IV, make sure that the IV length specified by the session is not larger than the payload size. - Disallow AEAD requests without a separate IV. crp_sanity() asserts that CRYPTO_F_IV_SEPARATE is set for AEAD requests, and some (but not all) drivers require it. - Return EINVAL for AEAD requests if an IV is specified but the transform does not expect one. Reported by: syzbot+c9e8f6ff5cb7fa6a1250@syzkaller.appspotmail.com Reported by: syzbot+007341439ae295cee74f@syzkaller.appspotmail.com Reported by: syzbot+46e0cc42a428b3b0a40d@syzkaller.appspotmail.com Reported by: syzbot+2c4d670173b8bdb947df@syzkaller.appspotmail.com Reported by: syzbot+220faa5eeb4d47b23877@syzkaller.appspotmail.com Reported by: syzbot+e83434b40f05843722f7@syzkaller.appspotmail.com Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30154 (cherry picked from commit 1a04f0156c4e6abfc01d5841341a94179f317f31) --- sys/opencrypto/cryptodev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 9bb95bcb21f0..45146284642b 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -932,6 +932,11 @@ cryptodev_op(struct csession *cse, const struct crypt_op *cop) } crp->crp_flags |= CRYPTO_F_IV_SEPARATE; } else if (cse->ivsize != 0) { + if (crp->crp_payload_length < cse->ivsize) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } crp->crp_iv_start = 0; crp->crp_payload_start += cse->ivsize; crp->crp_payload_length -= cse->ivsize; @@ -1112,6 +1117,11 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) cse->ivsize == AES_XTS_IV_LEN) caead->ivlen = AES_XTS_IV_LEN; + if (cse->ivsize == 0) { + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + error = EINVAL; + goto bail; + } if (caead->ivlen != cse->ivsize) { error = EINVAL; SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); @@ -1125,10 +1135,9 @@ cryptodev_aead(struct csession *cse, struct crypt_aead *caead) } crp->crp_flags |= CRYPTO_F_IV_SEPARATE; } else { - crp->crp_iv_start = crp->crp_payload_start; - crp->crp_payload_start += cse->ivsize; - crp->crp_payload_length -= cse->ivsize; - dst += cse->ivsize; + error = EINVAL; + SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); + goto bail; } if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { From owner-dev-commits-src-all@freebsd.org Fri May 14 14:08:35 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F062C649A81; Fri, 14 May 2021 14:08:35 +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 4FhVkC6WDlz3psn; Fri, 14 May 2021 14:08:35 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CC50E13619; Fri, 14 May 2021 14:08:35 +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 14EE8ZjY032613; Fri, 14 May 2021 14:08:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EE8ZnX032612; Fri, 14 May 2021 14:08:35 GMT (envelope-from git) Date: Fri, 14 May 2021 14:08:35 GMT Message-Id: <202105141408.14EE8ZnX032612@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 2cca77ee0134 - main - kqueue timer: Remove detached knotes from the process stop queue MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2cca77ee01343bf080f1b70f0217a84c200fe7c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 14:08:36 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2cca77ee01343bf080f1b70f0217a84c200fe7c1 commit 2cca77ee01343bf080f1b70f0217a84c200fe7c1 Author: Mark Johnston AuthorDate: 2021-05-14 14:07:56 +0000 Commit: Mark Johnston CommitDate: 2021-05-14 14:08:14 +0000 kqueue timer: Remove detached knotes from the process stop queue There are some scenarios where a timer event may be detached when it is on the process' kqueue timer stop queue. If kqtimer_proc_continue() is called after that point, it will iterate over the queue and access freed timer structures. It is also possible, at least in a multithreaded program, for a stopped timer event to be scheduled without removing it from the process' stop queue. Ensure that we do not doubly enqueue the event structure in this case. Reported by: syzbot+cea0931bb4e34cd728bd@syzkaller.appspotmail.com Reported by: syzbot+9e1a2f3734652015998c@syzkaller.appspotmail.com Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30251 --- sys/kern/kern_event.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 1067e7f128b7..e7047e9a7ad9 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -680,11 +680,14 @@ struct kq_timer_cb_data { struct proc *p; struct knote *kn; int cpuid; + int flags; TAILQ_ENTRY(kq_timer_cb_data) link; sbintime_t next; /* next timer event fires at */ sbintime_t to; /* precalculated timer period, 0 for abs */ }; +#define KQ_TIMER_CB_ENQUEUED 0x01 + static void kqtimer_sched_callout(struct kq_timer_cb_data *kc) { @@ -706,6 +709,7 @@ kqtimer_proc_continue(struct proc *p) TAILQ_FOREACH_SAFE(kc, &p->p_kqtim_stop, link, kc1) { TAILQ_REMOVE(&p->p_kqtim_stop, kc, link); + kc->flags &= ~KQ_TIMER_CB_ENQUEUED; if (kc->next <= now) filt_timerexpire_l(kc->kn, true); else @@ -753,7 +757,10 @@ filt_timerexpire_l(struct knote *kn, bool proc_locked) if (!proc_locked) PROC_LOCK(p); if (P_SHOULDSTOP(p) || P_KILLED(p)) { - TAILQ_INSERT_TAIL(&p->p_kqtim_stop, kc, link); + if ((kc->flags & KQ_TIMER_CB_ENQUEUED) == 0) { + kc->flags |= KQ_TIMER_CB_ENQUEUED; + TAILQ_INSERT_TAIL(&p->p_kqtim_stop, kc, link); + } if (!proc_locked) PROC_UNLOCK(p); return; @@ -826,6 +833,7 @@ filt_timerattach(struct knote *kn) kc->kn = kn; kc->p = curproc; kc->cpuid = PCPU_GET(cpuid); + kc->flags = 0; callout_init(&kc->c, 1); filt_timerstart(kn, to); @@ -856,6 +864,11 @@ filt_timerdetach(struct knote *kn) kc = kn->kn_ptr.p_v; callout_drain(&kc->c); + if ((kc->flags & KQ_TIMER_CB_ENQUEUED) != 0) { + PROC_LOCK(kc->p); + TAILQ_REMOVE(&kc->p->p_kqtim_stop, kc, link); + PROC_UNLOCK(kc->p); + } free(kc, M_KQUEUE); old = atomic_fetchadd_int(&kq_ncallouts, -1); KASSERT(old > 0, ("Number of callouts cannot become negative")); From owner-dev-commits-src-all@freebsd.org Fri May 14 14:23:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 815AB649FE5; Fri, 14 May 2021 14:23:55 +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 4FhW3v2H16z3rjj; Fri, 14 May 2021 14:23:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 409AC13DA6; Fri, 14 May 2021 14:23:55 +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 14EENtvt058649; Fri, 14 May 2021 14:23:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EENtDX058648; Fri, 14 May 2021 14:23:55 GMT (envelope-from git) Date: Fri, 14 May 2021 14:23:55 GMT Message-Id: <202105141423.14EENtDX058648@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b5fb9ae6872c - main - vfs: lockless writecount adjustment in set/unset text MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b5fb9ae6872c499f1a02bec41f48b163a73a2aaa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 14:23:55 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b5fb9ae6872c499f1a02bec41f48b163a73a2aaa commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa Author: Mateusz Guzik AuthorDate: 2021-05-07 14:04:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-14 14:22:21 +0000 vfs: lockless writecount adjustment in set/unset text ... for cases where this is not the first/last exec. --- sys/kern/vfs_default.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index cf224981cbe7..3518bbeaa279 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1177,9 +1177,23 @@ vop_stdset_text(struct vop_set_text_args *ap) { struct vnode *vp; struct mount *mp; - int error; + int error, n; vp = ap->a_vp; + + /* + * Avoid the interlock if execs are already present. + */ + n = atomic_load_int(&vp->v_writecount); + for (;;) { + if (n > -1) { + break; + } + if (atomic_fcmpset_int(&vp->v_writecount, &n, n - 1)) { + return (0); + } + } + VI_LOCK(vp); if (vp->v_writecount > 0) { error = ETXTBSY; @@ -1207,10 +1221,24 @@ static int vop_stdunset_text(struct vop_unset_text_args *ap) { struct vnode *vp; - int error; + int error, n; bool last; vp = ap->a_vp; + + /* + * Avoid the interlock if this is not the last exec. + */ + n = atomic_load_int(&vp->v_writecount); + for (;;) { + if (n >= -1) { + break; + } + if (atomic_fcmpset_int(&vp->v_writecount, &n, n + 1)) { + return (0); + } + } + last = false; VI_LOCK(vp); if (vp->v_writecount < 0) { From owner-dev-commits-src-all@freebsd.org Fri May 14 14:23:56 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9905764A297; Fri, 14 May 2021 14:23:56 +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 4FhW3w3cTBz3rW7; Fri, 14 May 2021 14:23:56 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 617AE13F21; Fri, 14 May 2021 14:23:56 +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 14EENuPa058670; Fri, 14 May 2021 14:23:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EENuqh058669; Fri, 14 May 2021 14:23:56 GMT (envelope-from git) Date: Fri, 14 May 2021 14:23:56 GMT Message-Id: <202105141423.14EENuqh058669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: ca1ce50b2b5e - main - vfs: add more safety against concurrent forced unmount to vn_write MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ca1ce50b2b5ef11d85841f3aead98b2a9ad18819 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 14:23:56 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ca1ce50b2b5ef11d85841f3aead98b2a9ad18819 commit ca1ce50b2b5ef11d85841f3aead98b2a9ad18819 Author: Mateusz Guzik AuthorDate: 2021-05-14 11:26:56 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-14 14:22:22 +0000 vfs: add more safety against concurrent forced unmount to vn_write 1. stop re-reading ->v_mount (can become NULL) 2. stop re-reading ->v_type (can change to VBAD) --- sys/kern/vfs_vnops.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 8f583329f067..6bf798cd73c5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1107,6 +1107,7 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, off_t orig_offset; int error, ioflag, lock_flags; int advice; + bool need_finished_write; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); @@ -1121,9 +1122,11 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, ioflag |= IO_NDELAY; if (fp->f_flag & O_DIRECT) ioflag |= IO_DIRECT; - if ((fp->f_flag & O_FSYNC) || - (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS))) - ioflag |= IO_SYNC; + if (fp->f_flag & O_FSYNC) { + mp = atomic_load_ptr(&vp->v_mount); + if (mp != NULL && mp->mnt_flag & MNT_SYNCHRONOUS) + ioflag |= IO_SYNC; + } /* * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE() * implementations that don't understand IO_DATASYNC fall back to full @@ -1132,9 +1135,13 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, if (fp->f_flag & O_DSYNC) ioflag |= IO_SYNC | IO_DATASYNC; mp = NULL; - if (vp->v_type != VCHR && - (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) - goto unlock; + need_finished_write = false; + if (vp->v_type != VCHR) { + error = vn_start_write(vp, &mp, V_WAIT | PCATCH); + if (error != 0) + goto unlock; + need_finished_write = true; + } advice = get_advice(fp, uio); @@ -1165,7 +1172,7 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, error = VOP_WRITE(vp, uio, ioflag, fp->f_cred); fp->f_nextoff[UIO_WRITE] = uio->uio_offset; VOP_UNLOCK(vp); - if (vp->v_type != VCHR) + if (need_finished_write) vn_finished_write(mp); if (error == 0 && advice == POSIX_FADV_NOREUSE && orig_offset != uio->uio_offset) From owner-dev-commits-src-all@freebsd.org Fri May 14 15:18:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 91F8264B9EC; Fri, 14 May 2021 15:18:23 +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 4FhXGl3k2vz3wWS; Fri, 14 May 2021 15:18:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6C88D142F4; Fri, 14 May 2021 15:18:23 +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 14EFINFn025512; Fri, 14 May 2021 15:18:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EFINQL025511; Fri, 14 May 2021 15:18:23 GMT (envelope-from git) Date: Fri, 14 May 2021 15:18:23 GMT Message-Id: <202105141518.14EFINQL025511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: c65e2d7092d6 - main - Update ugen(4) manual page. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c65e2d7092d6cbaf03721ebe46e51cec4bd6ac0f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 15:18:23 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=c65e2d7092d6cbaf03721ebe46e51cec4bd6ac0f commit c65e2d7092d6cbaf03721ebe46e51cec4bd6ac0f Author: Hans Petter Selasky AuthorDate: 2021-05-14 14:34:15 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-14 15:14:18 +0000 Update ugen(4) manual page. Fix description of generic USB character devices. PR: 244842 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- share/man/man4/ugen.4 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/share/man/man4/ugen.4 b/share/man/man4/ugen.4 index ad3ba80e0af7..35580e8aa88b 100644 --- a/share/man/man4/ugen.4 +++ b/share/man/man4/ugen.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2018 +.Dd May 14, 2021 .Dt UGEN 4 .Os .Sh NAME @@ -304,12 +304,19 @@ debug message verbosity. Default is 0. .El .Sh FILES -.Bl -tag -width ".Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar E" -compact -.It Pa /dev/ugen Ns Ar N Ns Pa \&. Ns Ar E +.Bl -tag -width "/dev/usb/B.D.E" -compact +.It Pa /dev/usb/B.D.E Endpoint .Ar E of device -.Ar N . +.Ar D +at bus +.Ar B . +.It Pa /dev/ugenB.D +Control endpoint, 0, of device +.Ar D +at bus +.Ar B . .El .Sh SEE ALSO .Xr usb 4 @@ -319,5 +326,3 @@ The driver appeared in .Nx 1.4 . -.\" .Sh BUGS -.\" The driver is not yet finished; there is no access to isochronous endpoints. From owner-dev-commits-src-all@freebsd.org Fri May 14 15:18:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA02364B94B; Fri, 14 May 2021 15:18:24 +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 4FhXGm4qZsz3wLl; Fri, 14 May 2021 15:18:24 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 83D9C14833; Fri, 14 May 2021 15:18:24 +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 14EFIOWT025533; Fri, 14 May 2021 15:18:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EFIONt025532; Fri, 14 May 2021 15:18:24 GMT (envelope-from git) Date: Fri, 14 May 2021 15:18:24 GMT Message-Id: <202105141518.14EFIONt025532@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: c904e20cc903 - main - Implement own command line option for the frequently used -i usbusX -f Y syntax, -d ugenX.Y, similar to what usbconfig(8) does. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c904e20cc903d28c1090c531c907cdd6865455ff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 15:18:25 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=c904e20cc903d28c1090c531c907cdd6865455ff commit c904e20cc903d28c1090c531c907cdd6865455ff Author: Hans Petter Selasky AuthorDate: 2021-05-14 15:12:57 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-14 15:15:07 +0000 Implement own command line option for the frequently used -i usbusX -f Y syntax, -d ugenX.Y, similar to what usbconfig(8) does. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- usr.sbin/usbdump/usbdump.8 | 30 ++++++++++++++++++++++++- usr.sbin/usbdump/usbdump.c | 56 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/usr.sbin/usbdump/usbdump.8 b/usr.sbin/usbdump/usbdump.8 index 475e832cd03b..6b5ad1920e94 100644 --- a/usr.sbin/usbdump/usbdump.8 +++ b/usr.sbin/usbdump/usbdump.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2012 +.Dd May 14, 2021 .Dt USBDUMP 8 .Os .Sh NAME @@ -33,6 +33,9 @@ .Nd "dump traffic on USB host controller" .Sh SYNOPSIS .Nm +.Op Fl d Ar [ugen]B +.Op Fl d Ar [ugen]B.D +.Op Fl d Ar [ugen]B.D.E .Op Fl i Ar ifname .Op Fl r Ar file .Op Fl s Ar snaplen @@ -48,6 +51,31 @@ utility provides a way to dump USB packets on host controllers. .Pp The following options are accepted: .Bl -tag -width ".Fl f Ar file" +.It Fl d Ar [ugen]bus +Shortcut for +.Fl i +option. +The argument may be prefixed by "ugen". +The option may be specified multiple times, but the bus specified must +be the same. +.It Fl d Ar [ugen]bus.device +Shortcut for +.Fl i +and +.Fl f +options. +The argument may be prefixed by "ugen". +The option may be specified multiple times, but the bus specified must +be the same. +.It Fl d Ar [ugen]bus.device.endpoint +Shortcut for +.Fl i +and +.Fl f +options. +The argument may be prefixed by "ugen". +The option may be specified multiple times, but the bus specified must +be the same. .It Fl b Ar file Store data part of the USB trace in binary format to the given .Ar file . diff --git a/usr.sbin/usbdump/usbdump.c b/usr.sbin/usbdump/usbdump.c index a38d08a252af..00d3b8e8913b 100644 --- a/usr.sbin/usbdump/usbdump.c +++ b/usr.sbin/usbdump/usbdump.c @@ -108,14 +108,14 @@ struct header_32 { uint8_t align; } __packed; -static int doexit = 0; -static int pkt_captured = 0; -static int verbose = 0; +static int doexit; +static int pkt_captured; +static int verbose; static int uf_minor; -static const char *i_arg = "usbus0"; -static const char *r_arg = NULL; -static const char *w_arg = NULL; -static const char *b_arg = NULL; +static char *i_arg; +static char *r_arg; +static char *w_arg; +static char *b_arg; static struct usbcap uc; static const char *errstr_table[USB_ERR_MAX] = { [USB_ERR_NORMAL_COMPLETION] = "0", @@ -779,7 +779,10 @@ usage(void) #define FMT " %-14s %s\n" fprintf(stderr, "usage: usbdump [options]\n"); - fprintf(stderr, FMT, "-i ", "Listen on USB bus interface"); + fprintf(stderr, FMT, "-d [ugen]B", "Listen on bus, B"); + fprintf(stderr, FMT, "-d [ugen]B.D", "Listen on bus, B and device, D"); + fprintf(stderr, FMT, "-d [ugen]B.D.E", "Listen on bus, B, device, D, and endpoint E"); + fprintf(stderr, FMT, "-i ", "Listen on this bus interface"); fprintf(stderr, FMT, "-f ", "Specify a device and endpoint filter"); fprintf(stderr, FMT, "-r ", "Read the raw packets from file"); fprintf(stderr, FMT, "-s ", "Snapshot bytes from each packet"); @@ -828,9 +831,41 @@ main(int argc, char *argv[]) const char *optstring; char *pp; - optstring = "b:hi:r:s:vw:f:"; + optstring = "b:d:hi:r:s:vw:f:"; while ((o = getopt(argc, argv, optstring)) != -1) { switch (o) { + case 'd': + pp = optarg; + if (pp[0] == 'u' && pp[1] == 'g' && pp[2] == 'e' && pp[3] == 'n') + pp += 4; + ifindex = strtol(pp, &pp, 10); + /* Must be same bus when using -d option. */ + if (i_arg != NULL) { + if (atoi(i_arg + 5) != ifindex) + usage(); + } else { + asprintf(&i_arg, "usbus%d", ifindex); + } + /* Parse unit and endpoint, if any. */ + if (pp != NULL) { + if (*pp == '.') { + filt_unit = strtol(pp + 1, &pp, 10); + filt_ep = -1; + if (pp != NULL) { + if (*pp == '.') { + filt_ep = strtol(pp + 1, &pp, 10); + if (pp != NULL && *pp != 0) + usage(); + } else if (*pp != 0) { + usage(); + } + } + add_filter(filt_unit, filt_ep); + } else if (*pp != 0) { + usage(); + } + } + break; case 'i': i_arg = optarg; break; @@ -879,6 +914,9 @@ main(int argc, char *argv[]) } } + if (i_arg == NULL) + i_arg = "usbus0"; + if (b_arg != NULL) { p->bfd = open(b_arg, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); From owner-dev-commits-src-all@freebsd.org Fri May 14 15:43:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8BFB64C352; Fri, 14 May 2021 15:43:39 +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 4FhXqv4w4Cz4T69; Fri, 14 May 2021 15:43:39 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9B83314B4E; Fri, 14 May 2021 15:43:39 +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 14EFhdNu064625; Fri, 14 May 2021 15:43:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EFhdNh064624; Fri, 14 May 2021 15:43:39 GMT (envelope-from git) Date: Fri, 14 May 2021 15:43:39 GMT Message-Id: <202105141543.14EFhdNh064624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 852088f6af6c - main - vfs: add missing atomic conversion to writecount adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 852088f6af6c5cd44542dde72aa5c3f4c4f9353c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 15:43:39 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=852088f6af6c5cd44542dde72aa5c3f4c4f9353c commit 852088f6af6c5cd44542dde72aa5c3f4c4f9353c Author: Mateusz Guzik AuthorDate: 2021-05-14 15:41:39 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-14 15:42:05 +0000 vfs: add missing atomic conversion to writecount adjustment Fixes: ("vfs: lockless writecount adjustment in set/unset text") --- sys/kern/vfs_default.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 3518bbeaa279..ace9ad1d37c3 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1210,7 +1210,7 @@ vop_stdset_text(struct vop_set_text_args *ap) vrefl(vp); } - vp->v_writecount--; + atomic_subtract_int(&vp->v_writecount, 1); error = 0; } VI_UNLOCK(vp); @@ -1247,7 +1247,7 @@ vop_stdunset_text(struct vop_unset_text_args *ap) last = true; vp->v_iflag &= ~VI_TEXT_REF; } - vp->v_writecount++; + atomic_add_int(&vp->v_writecount, 1); error = 0; } else { error = EINVAL; From owner-dev-commits-src-all@freebsd.org Fri May 14 16:10:17 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0B9164CC74; Fri, 14 May 2021 16:10:17 +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 4FhYQd53lzz4X4f; Fri, 14 May 2021 16:10:17 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A0B0115418; Fri, 14 May 2021 16:10:17 +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 14EGAHeV099257; Fri, 14 May 2021 16:10:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EGAHDV099254; Fri, 14 May 2021 16:10:17 GMT (envelope-from git) Date: Fri, 14 May 2021 16:10:17 GMT Message-Id: <202105141610.14EGAHDV099254@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: 76cfc6fa0d81 - main - Fix a use after free in update_rtm_from_rc(). 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: 76cfc6fa0d819e7caca86c8299947cea1af9d6bc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 16:10:17 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=76cfc6fa0d819e7caca86c8299947cea1af9d6bc commit 76cfc6fa0d819e7caca86c8299947cea1af9d6bc Author: Alexander V. Chernikov AuthorDate: 2021-05-14 16:03:08 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-05-14 16:06:41 +0000 Fix a use after free in update_rtm_from_rc(). update_rtm_from_rc() calls update_rtm_from_info() internally. The latter one may update provided prtm pointer with a new rtm. Reassign rtm from prtm afeter calling update_rtm_from_info() to avoid touching the freed rtm. PR: 255871 Submitted by: lylgood@foxmail.com MFC after: 3 days --- sys/net/rtsock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 6930bd167ac1..3cb645f42e4c 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -976,6 +976,7 @@ update_rtm_from_rc(struct rt_addrinfo *info, struct rt_msghdr **prtm, if ((error = update_rtm_from_info(info, prtm, alloc_len)) != 0) return (error); + rtm = *prtm; rtm->rtm_flags = rc->rc_rt->rte_flags | nhop_get_rtflags(nh); if (rtm->rtm_flags & RTF_GWFLAG_COMPAT) rtm->rtm_flags = RTF_GATEWAY | From owner-dev-commits-src-all@freebsd.org Fri May 14 18:04:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E84D64F1C9; Fri, 14 May 2021 18:04:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4Fhby21x9fz4mqQ; Fri, 14 May 2021 18:04:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14EI41V2074110 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 14 May 2021 21:04:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14EI41V2074110 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14EI41oN074109; Fri, 14 May 2021 21:04:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 14 May 2021 21:04:01 +0300 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: b5fb9ae6872c - main - vfs: lockless writecount adjustment in set/unset text Message-ID: References: <202105141423.14EENtDX058648@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105141423.14EENtDX058648@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4Fhby21x9fz4mqQ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 18:04:10 -0000 On Fri, May 14, 2021 at 02:23:55PM +0000, Mateusz Guzik wrote: > The branch main has been updated by mjg: > > URL: https://cgit.FreeBSD.org/src/commit/?id=b5fb9ae6872c499f1a02bec41f48b163a73a2aaa > > commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa > Author: Mateusz Guzik > AuthorDate: 2021-05-07 14:04:27 +0000 > Commit: Mateusz Guzik > CommitDate: 2021-05-14 14:22:21 +0000 > > vfs: lockless writecount adjustment in set/unset text > > ... for cases where this is not the first/last exec. > --- > sys/kern/vfs_default.c | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > > diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c > index cf224981cbe7..3518bbeaa279 100644 > --- a/sys/kern/vfs_default.c > +++ b/sys/kern/vfs_default.c > @@ -1177,9 +1177,23 @@ vop_stdset_text(struct vop_set_text_args *ap) > { > struct vnode *vp; > struct mount *mp; > - int error; > + int error, n; > > vp = ap->a_vp; > + > + /* > + * Avoid the interlock if execs are already present. > + */ > + n = atomic_load_int(&vp->v_writecount); > + for (;;) { > + if (n > -1) { > + break; If you split the VOP for tmpfs/non-tmpfs implementations, then non-tmpfs can go with the atomics only. From owner-dev-commits-src-all@freebsd.org Fri May 14 18:25:37 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B9E8964FC2F; Fri, 14 May 2021 18:25:37 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FhcQn4ktHz4s0M; Fri, 14 May 2021 18:25:37 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lj1-x233.google.com with SMTP id 131so13505876ljj.3; Fri, 14 May 2021 11:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0rnukEjPFahhmoOV2kNSHvE/AU3FMBOCrLgsgVIVe3c=; b=MNoNNQU+CH127VgBH3mOJq/cSVOQRR5vXWtF+t6aB2xZzgaMbv0EmfH3/U+qHm+f4o jxJ0B/NIwZfGyGYOOT0lY1qNhkOU4aOjRbiy7tZKP1yStU5CQekV1IdrWS6dUkvWmB08 +2pF49vAtZS2YrrLlMrybVC2OLgSum8bB1DYp6W4qqq5bqdBBE/qNkvuJSUodUVCCs8+ b3cSiCL3meqw8eCrXndvBBHklpuZmRXmHbS39SY5vggxe7YrSEu0m/Bvi8Q34CC2/YDz UeZ53kVTlGVhRP4PRbzEdgSmwuecIqzxuO4cdqAz7vvN2N2o5M094A75MCpW8dSol93l RlzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0rnukEjPFahhmoOV2kNSHvE/AU3FMBOCrLgsgVIVe3c=; b=YHA8HdtlRRWvISLnWu3j0CyaS6q2Q57DBkMmv4qWqtF+wzqBu44hNerSsv2fiZOxfw d4/RWnCZ/CMxl52jfBGd3oJ0do9Nh5TxFY0v5nTDip3UxZGDg7DamO1xmPB2Pw7iM3XF ihZM8JfMLKNKCmahxw2lcn7Nl3FFhxgTBrkbySR1OBwnyhNkXirIVGOzI+BmGtL2l0Qz 92ciM+bbGT3g/BojdJXdZmGDgYjNdQzTo9/6vCMgmZQrmFOhj+FQZZmLGLXPxAeQ7qvL wNH+IzgR9t7XPUmDrQPVnQnYdIy0DGHWE9fEKD0jvH+RFi7c4Ay4ZUM2dDmpFh7TlJlI uXbg== X-Gm-Message-State: AOAM531iyYQNldUv9xlzplNUlQprUWfX1qPWzHM+iCoNy8Fug4aGuYhh jCxO1ntKsYb9TANgy6mKJ+kFD65FU0F9UPD9RFs= X-Google-Smtp-Source: ABdhPJz0JG4Ry5w2zjXjR052zsl8SWva7DkfwpbBPahqbWbiw2Kw20vmBUyzOpP4YO7+pRepYI+WKRRjvOcwlv7ax/4= X-Received: by 2002:a2e:b605:: with SMTP id r5mr37633937ljn.483.1621016735854; Fri, 14 May 2021 11:25:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:651c:485:0:0:0:0 with HTTP; Fri, 14 May 2021 11:25:35 -0700 (PDT) In-Reply-To: References: <202105141423.14EENtDX058648@gitrepo.freebsd.org> From: Mateusz Guzik Date: Fri, 14 May 2021 20:25:35 +0200 Message-ID: Subject: Re: git: b5fb9ae6872c - main - vfs: lockless writecount adjustment in set/unset text To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4FhcQn4ktHz4s0M X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 18:25:37 -0000 Even tmpfs can go without the interlock. The code can check if it transitioned across 0 and act accordingly and conditionally vref based on that. I did not check if said transition is safe without the interlock vs other users, so I did not go for it. Arguably both exec and write counts could be treated the same way, would have a side effect of avoiding VI_LOCK_FLAGS(vp, MTX_DUPOK);. Maybe i'll look into it today or tomorrow. On 5/14/21, Konstantin Belousov wrote: > On Fri, May 14, 2021 at 02:23:55PM +0000, Mateusz Guzik wrote: >> The branch main has been updated by mjg: >> >> URL: >> https://cgit.FreeBSD.org/src/commit/?id=b5fb9ae6872c499f1a02bec41f48b163a73a2aaa >> >> commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa >> Author: Mateusz Guzik >> AuthorDate: 2021-05-07 14:04:27 +0000 >> Commit: Mateusz Guzik >> CommitDate: 2021-05-14 14:22:21 +0000 >> >> vfs: lockless writecount adjustment in set/unset text >> >> ... for cases where this is not the first/last exec. >> --- >> sys/kern/vfs_default.c | 32 ++++++++++++++++++++++++++++++-- >> 1 file changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c >> index cf224981cbe7..3518bbeaa279 100644 >> --- a/sys/kern/vfs_default.c >> +++ b/sys/kern/vfs_default.c >> @@ -1177,9 +1177,23 @@ vop_stdset_text(struct vop_set_text_args *ap) >> { >> struct vnode *vp; >> struct mount *mp; >> - int error; >> + int error, n; >> >> vp = ap->a_vp; >> + >> + /* >> + * Avoid the interlock if execs are already present. >> + */ >> + n = atomic_load_int(&vp->v_writecount); >> + for (;;) { >> + if (n > -1) { >> + break; > If you split the VOP for tmpfs/non-tmpfs implementations, then > non-tmpfs can go with the atomics only. > -- Mateusz Guzik From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7D99E628CE5; Fri, 14 May 2021 19:21:49 +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 4Fhdgd39mGz3Ghv; Fri, 14 May 2021 19:21:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5F39317BA1; Fri, 14 May 2021 19:21:49 +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 14EJLngs058112; Fri, 14 May 2021 19:21:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLnrr058111; Fri, 14 May 2021 19:21:49 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:49 GMT Message-Id: <202105141921.14EJLnrr058111@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4b6ed0758dc6 - main - cxgbe: Make the TOE ISCSI RX stats per-queue instead of per adapter. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b6ed0758dc6fad17081d7bd791cb0edbddbddb8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:49 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4b6ed0758dc6fad17081d7bd791cb0edbddbddb8 commit 4b6ed0758dc6fad17081d7bd791cb0edbddbddb8 Author: John Baldwin AuthorDate: 2021-05-14 19:16:33 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:16:33 +0000 cxgbe: Make the TOE ISCSI RX stats per-queue instead of per adapter. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29903 --- sys/dev/cxgbe/adapter.h | 7 +++- sys/dev/cxgbe/cxgbei/cxgbei.c | 83 +++------------------------------------ sys/dev/cxgbe/cxgbei/cxgbei.h | 6 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 10 +++-- sys/dev/cxgbe/t4_main.c | 8 ++++ sys/dev/cxgbe/t4_sge.c | 29 +++++++++++++- 6 files changed, 52 insertions(+), 91 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 086918b7dff9..cce58f9729c1 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -656,11 +656,16 @@ iq_to_rxq(struct sge_iq *iq) return (__containerof(iq, struct sge_rxq, iq)); } - /* ofld_rxq: SGE ingress queue + SGE free list + miscellaneous items */ struct sge_ofld_rxq { struct sge_iq iq; /* MUST be first */ struct sge_fl fl; /* MUST follow iq */ + counter_u64_t rx_iscsi_ddp_setup_ok; + counter_u64_t rx_iscsi_ddp_setup_error; + uint64_t rx_iscsi_ddp_pdus; + uint64_t rx_iscsi_ddp_octets; + uint64_t rx_iscsi_fl_pdus; + uint64_t rx_iscsi_fl_octets; u_long rx_toe_tls_records; u_long rx_toe_tls_octets; } __aligned(CACHE_LINE_SIZE); diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c index 4acdc726e75c..07f704752305 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/cxgbei.c @@ -96,50 +96,6 @@ static int worker_thread_count; static struct cxgbei_worker_thread_softc *cwt_softc; static struct proc *cxgbei_proc; -static void -free_ci_counters(struct cxgbei_data *ci) -{ - -#define FREE_CI_COUNTER(x) do { \ - if (ci->x != NULL) { \ - counter_u64_free(ci->x); \ - ci->x = NULL; \ - } \ -} while (0) - - FREE_CI_COUNTER(ddp_setup_ok); - FREE_CI_COUNTER(ddp_setup_error); - FREE_CI_COUNTER(ddp_bytes); - FREE_CI_COUNTER(ddp_pdus); - FREE_CI_COUNTER(fl_bytes); - FREE_CI_COUNTER(fl_pdus); -#undef FREE_CI_COUNTER -} - -static int -alloc_ci_counters(struct cxgbei_data *ci) -{ - -#define ALLOC_CI_COUNTER(x) do { \ - ci->x = counter_u64_alloc(M_WAITOK); \ - if (ci->x == NULL) \ - goto fail; \ -} while (0) - - ALLOC_CI_COUNTER(ddp_setup_ok); - ALLOC_CI_COUNTER(ddp_setup_error); - ALLOC_CI_COUNTER(ddp_bytes); - ALLOC_CI_COUNTER(ddp_pdus); - ALLOC_CI_COUNTER(fl_bytes); - ALLOC_CI_COUNTER(fl_pdus); -#undef ALLOC_CI_COUNTER - - return (0); -fail: - free_ci_counters(ci); - return (ENOMEM); -} - static void read_pdu_limits(struct adapter *sc, uint32_t *max_tx_pdu_len, uint32_t *max_rx_pdu_len) @@ -182,10 +138,6 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci) MPASS(sc->vres.iscsi.size > 0); MPASS(ci != NULL); - rc = alloc_ci_counters(ci); - if (rc != 0) - return (rc); - read_pdu_limits(sc, &ci->max_tx_pdu_len, &ci->max_rx_pdu_len); pr = &ci->pr; @@ -195,7 +147,6 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci) device_printf(sc->dev, "%s: failed to initialize the iSCSI page pod region: %u.\n", __func__, rc); - free_ci_counters(ci); return (rc); } @@ -219,30 +170,9 @@ cxgbei_init(struct adapter *sc, struct cxgbei_data *ci) children = SYSCTL_CHILDREN(oid); oid = SYSCTL_ADD_NODE(&ci->ctx, children, OID_AUTO, "iscsi", - CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "iSCSI ULP statistics"); + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "iSCSI ULP settings"); children = SYSCTL_CHILDREN(oid); - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_setup_ok", - CTLFLAG_RD, &ci->ddp_setup_ok, - "# of times DDP buffer was setup successfully."); - - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_setup_error", - CTLFLAG_RD, &ci->ddp_setup_error, - "# of times DDP buffer setup failed."); - - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_bytes", - CTLFLAG_RD, &ci->ddp_bytes, "# of bytes placed directly"); - - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "ddp_pdus", - CTLFLAG_RD, &ci->ddp_pdus, "# of PDUs with data placed directly."); - - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "fl_bytes", - CTLFLAG_RD, &ci->fl_bytes, "# of data bytes delivered in freelist"); - - SYSCTL_ADD_COUNTER_U64(&ci->ctx, children, OID_AUTO, "fl_pdus", - CTLFLAG_RD, &ci->fl_pdus, - "# of PDUs with data delivered in freelist"); - ci->ddp_threshold = 2048; SYSCTL_ADD_UINT(&ci->ctx, children, OID_AUTO, "ddp_threshold", CTLFLAG_RW, &ci->ddp_threshold, 0, "Rx zero copy threshold"); @@ -291,7 +221,6 @@ static int do_rx_iscsi_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) { struct adapter *sc = iq->adapter; - struct cxgbei_data *ci = sc->iscsi_ulp_softc; struct cpl_iscsi_data *cpl = mtod(m, struct cpl_iscsi_data *); u_int tid = GET_TID(cpl); struct toepcb *toep = lookup_tid(sc, tid); @@ -311,8 +240,8 @@ do_rx_iscsi_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m icp->icp_flags |= ICPF_RX_FLBUF; icp->ip.ip_data_mbuf = m; - counter_u64_add(ci->fl_pdus, 1); - counter_u64_add(ci->fl_bytes, m->m_pkthdr.len); + toep->ofld_rxq->rx_iscsi_fl_pdus++; + toep->ofld_rxq->rx_iscsi_fl_octets += m->m_pkthdr.len; #if 0 CTR3(KTR_CXGBE, "%s: tid %u, cpl->len %u", __func__, tid, @@ -326,7 +255,6 @@ static int do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) { struct adapter *sc = iq->adapter; - struct cxgbei_data *ci = sc->iscsi_ulp_softc; const struct cpl_rx_data_ddp *cpl = (const void *)(rss + 1); u_int tid = GET_TID(cpl); struct toepcb *toep = lookup_tid(sc, tid); @@ -369,8 +297,8 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) MPASS((icp->icp_flags & ICPF_RX_FLBUF) == 0); MPASS(ip->ip_data_len > 0); icp->icp_flags |= ICPF_RX_DDP; - counter_u64_add(ci->ddp_pdus, 1); - counter_u64_add(ci->ddp_bytes, ip->ip_data_len); + toep->ofld_rxq->rx_iscsi_ddp_pdus++; + toep->ofld_rxq->rx_iscsi_ddp_octets += ip->ip_data_len; } INP_WLOCK(inp); @@ -527,7 +455,6 @@ cxgbei_deactivate(struct adapter *sc) if (ci != NULL) { sysctl_ctx_free(&ci->ctx); t4_free_ppod_region(&ci->pr); - free_ci_counters(ci); free(ci, M_CXGBE); sc->iscsi_ulp_softc = NULL; } diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.h b/sys/dev/cxgbe/cxgbei/cxgbei.h index b0369b974136..3b17a4f2b36a 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.h +++ b/sys/dev/cxgbe/cxgbei/cxgbei.h @@ -113,12 +113,6 @@ struct cxgbei_data { struct ppod_region pr; struct sysctl_ctx_list ctx; /* from uld_activate to deactivate */ - counter_u64_t ddp_setup_ok; - counter_u64_t ddp_setup_error; - counter_u64_t ddp_bytes; - counter_u64_t ddp_pdus; - counter_u64_t fl_bytes; - counter_u64_t fl_pdus; }; /* cxgbei.c */ diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 94963f13b601..961acfb31987 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -819,7 +819,8 @@ no_ddp: *ittp = htobe32(itt); MPASS(*arg == NULL); /* State is maintained for DDP only. */ if (rc != 0) - counter_u64_add(ci->ddp_setup_error, 1); + counter_u64_add( + toep->ofld_rxq->rx_iscsi_ddp_setup_error, 1); return (0); } @@ -853,7 +854,7 @@ no_ddp: *ittp = htobe32(prsv->prsv_tag); *arg = prsv; - counter_u64_add(ci->ddp_setup_ok, 1); + counter_u64_add(toep->ofld_rxq->rx_iscsi_ddp_setup_ok, 1); return (0); } @@ -922,7 +923,8 @@ no_ddp: *tttp = htobe32(ttt); MPASS(io_to_ppod_reservation(io) == NULL); if (rc != 0) - counter_u64_add(ci->ddp_setup_error, 1); + counter_u64_add( + toep->ofld_rxq->rx_iscsi_ddp_setup_error, 1); return (0); } @@ -968,7 +970,7 @@ no_ddp: *tttp = htobe32(prsv->prsv_tag); io_to_ppod_reservation(io) = prsv; *arg = ctsio; - counter_u64_add(ci->ddp_setup_ok, 1); + counter_u64_add(toep->ofld_rxq->rx_iscsi_ddp_setup_ok, 1); return (0); } diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index da9d7565f3a3..3cfab1ef04e2 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -11886,6 +11886,14 @@ clear_stats(struct adapter *sc, u_int port_id) ofld_rxq->fl.cl_allocated = 0; ofld_rxq->fl.cl_recycled = 0; ofld_rxq->fl.cl_fast_recycled = 0; + counter_u64_zero( + ofld_rxq->rx_iscsi_ddp_setup_ok); + counter_u64_zero( + ofld_rxq->rx_iscsi_ddp_setup_error); + ofld_rxq->rx_iscsi_ddp_pdus = 0; + ofld_rxq->rx_iscsi_ddp_octets = 0; + ofld_rxq->rx_iscsi_fl_pdus = 0; + ofld_rxq->rx_iscsi_fl_octets = 0; ofld_rxq->rx_toe_tls_records = 0; ofld_rxq->rx_toe_tls_octets = 0; } diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 2f6c7e2e7914..ac79d8002784 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4116,12 +4116,37 @@ add_ofld_rxq_sysctls(struct sysctl_ctx_list *ctx, struct sysctl_oid *oid, return; children = SYSCTL_CHILDREN(oid); - SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_toe_tls_records", CTLFLAG_RD, &ofld_rxq->rx_toe_tls_records, "# of TOE TLS records received"); - SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_toe_tls_octets", CTLFLAG_RD, &ofld_rxq->rx_toe_tls_octets, "# of payload octets in received TOE TLS records"); + + oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "iscsi", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TOE iSCSI statistics"); + children = SYSCTL_CHILDREN(oid); + + ofld_rxq->rx_iscsi_ddp_setup_ok = counter_u64_alloc(M_WAITOK); + ofld_rxq->rx_iscsi_ddp_setup_error = counter_u64_alloc(M_WAITOK); + SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "ddp_setup_ok", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_setup_ok, + "# of times DDP buffer was setup successfully."); + SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "ddp_setup_error", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_setup_error, + "# of times DDP buffer setup failed."); + SYSCTL_ADD_U64(ctx, children, OID_AUTO, "ddp_octets", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_octets, 0, + "# of octets placed directly"); + SYSCTL_ADD_U64(ctx, children, OID_AUTO, "ddp_pdus", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_pdus, 0, + "# of PDUs with data placed directly."); + SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fl_octets", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_fl_octets, 0, + "# of data octets delivered in freelist"); + SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fl_pdus", + CTLFLAG_RD, &ofld_rxq->rx_iscsi_fl_pdus, 0, + "# of PDUs with data delivered in freelist"); } #endif From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6A92628E34; Fri, 14 May 2021 19:21:50 +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 4Fhdgf4Cghz3Gct; Fri, 14 May 2021 19:21:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8270717CF2; Fri, 14 May 2021 19:21:50 +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 14EJLoZi058133; Fri, 14 May 2021 19:21:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLoXK058132; Fri, 14 May 2021 19:21:50 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:50 GMT Message-Id: <202105141921.14EJLoXK058132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4427ac3675f9 - main - cxgbe tom: Set the tid in the work requests to program page pods for iSCSI. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4427ac3675f91df039d54a23518132e0e0fede86 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:50 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4427ac3675f91df039d54a23518132e0e0fede86 commit 4427ac3675f91df039d54a23518132e0e0fede86 Author: John Baldwin AuthorDate: 2021-05-14 19:16:40 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:16:40 +0000 cxgbe tom: Set the tid in the work requests to program page pods for iSCSI. As a result, CPL_FW4_ACK now returns credits for these work requests. To support this, page pod work requests are now constructed in special mbufs similar to "raw" mbufs used for NIC TLS in plain TX queues. These special mbufs are stored in the ulp_pduq and dispatched in order with PDU work requests. Sponsored by: Chelsio Communications Discussed with: np Differential Revision: https://reviews.freebsd.org/D29904 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 7 +- sys/dev/cxgbe/tom/t4_cpl_io.c | 241 ++++++++++++++++++++++---------------- sys/dev/cxgbe/tom/t4_ddp.c | 48 ++++++-- sys/dev/cxgbe/tom/t4_tom.h | 18 ++- 4 files changed, 196 insertions(+), 118 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 961acfb31987..4e168a33e2ca 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -844,8 +844,8 @@ no_ddp: goto no_ddp; } - rc = t4_write_page_pods_for_buf(sc, &toep->ofld_txq->wrq, toep->tid, - prsv, (vm_offset_t)csio->data_ptr, csio->dxfer_len); + rc = t4_write_page_pods_for_buf(sc, toep, prsv, + (vm_offset_t)csio->data_ptr, csio->dxfer_len); if (rc != 0) { t4_free_page_pods(prsv); uma_zfree(prsv_zone, prsv); @@ -959,8 +959,7 @@ no_ddp: goto no_ddp; } - rc = t4_write_page_pods_for_buf(sc, &toep->ofld_txq->wrq, - toep->tid, prsv, buf, xferlen); + rc = t4_write_page_pods_for_buf(sc, toep, prsv, buf, xferlen); if (rc != 0) { t4_free_page_pods(prsv); uma_zfree(prsv_zone, prsv); diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index d8eb0e091218..b4d84d3e5c55 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -927,10 +927,10 @@ rqdrop_locked(struct mbufq *q, int plen) } } -void -t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) +static struct wrqe * +write_iscsi_mbuf_wr(struct toepcb *toep, struct mbuf *sndptr) { - struct mbuf *sndptr, *m; + struct mbuf *m; struct fw_ofld_tx_data_wr *txwr; struct wrqe *wr; u_int plen, nsegs, credits, max_imm, max_nsegs, max_nsegs_1mbuf; @@ -938,9 +938,129 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) struct inpcb *inp = toep->inp; struct tcpcb *tp = intotcpcb(inp); int tx_credits, shove; + static const u_int ulp_extra_len[] = {0, 4, 4, 8}; + + M_ASSERTPKTHDR(sndptr); + + tx_credits = min(toep->tx_credits, MAX_OFLD_TX_CREDITS); + if (mbuf_raw_wr(sndptr)) { + plen = sndptr->m_pkthdr.len; + KASSERT(plen <= SGE_MAX_WR_LEN, + ("raw WR len %u is greater than max WR len", plen)); + if (plen > tx_credits * 16) + return (NULL); + + wr = alloc_wrqe(roundup2(plen, 16), &toep->ofld_txq->wrq); + if (__predict_false(wr == NULL)) + return (NULL); + + m_copydata(sndptr, 0, plen, wrtod(wr)); + return (wr); + } + + max_imm = max_imm_payload(tx_credits); + max_nsegs = max_dsgl_nsegs(tx_credits); + + plen = 0; + nsegs = 0; + max_nsegs_1mbuf = 0; /* max # of SGL segments in any one mbuf */ + for (m = sndptr; m != NULL; m = m->m_next) { + int n = sglist_count(mtod(m, void *), m->m_len); + + nsegs += n; + plen += m->m_len; + + /* + * This mbuf would send us _over_ the nsegs limit. + * Suspend tx because the PDU can't be sent out. + */ + if (plen > max_imm && nsegs > max_nsegs) + return (NULL); + + if (max_nsegs_1mbuf < n) + max_nsegs_1mbuf = n; + } + + if (__predict_false(toep->flags & TPF_FIN_SENT)) + panic("%s: excess tx.", __func__); + + /* + * We have a PDU to send. All of it goes out in one WR so 'm' + * is NULL. A PDU's length is always a multiple of 4. + */ + MPASS(m == NULL); + MPASS((plen & 3) == 0); + MPASS(sndptr->m_pkthdr.len == plen); + + shove = !(tp->t_flags & TF_MORETOCOME); + ulp_submode = mbuf_ulp_submode(sndptr); + MPASS(ulp_submode < nitems(ulp_extra_len)); + + /* + * plen doesn't include header and data digests, which are + * generated and inserted in the right places by the TOE, but + * they do occupy TCP sequence space and need to be accounted + * for. + */ + adjusted_plen = plen + ulp_extra_len[ulp_submode]; + if (plen <= max_imm) { + + /* Immediate data tx */ + + wr = alloc_wrqe(roundup2(sizeof(*txwr) + plen, 16), + &toep->ofld_txq->wrq); + if (wr == NULL) { + /* XXX: how will we recover from this? */ + return (NULL); + } + txwr = wrtod(wr); + credits = howmany(wr->wr_len, 16); + write_tx_wr(txwr, toep, plen, adjusted_plen, credits, + shove, ulp_submode); + m_copydata(sndptr, 0, plen, (void *)(txwr + 1)); + nsegs = 0; + } else { + int wr_len; + + /* DSGL tx */ + wr_len = sizeof(*txwr) + sizeof(struct ulptx_sgl) + + ((3 * (nsegs - 1)) / 2 + ((nsegs - 1) & 1)) * 8; + wr = alloc_wrqe(roundup2(wr_len, 16), + &toep->ofld_txq->wrq); + if (wr == NULL) { + /* XXX: how will we recover from this? */ + return (NULL); + } + txwr = wrtod(wr); + credits = howmany(wr_len, 16); + write_tx_wr(txwr, toep, 0, adjusted_plen, credits, + shove, ulp_submode); + write_tx_sgl(txwr + 1, sndptr, m, nsegs, max_nsegs_1mbuf); + if (wr_len & 0xf) { + uint64_t *pad = (uint64_t *)((uintptr_t)txwr + wr_len); + *pad = 0; + } + } + + tp->snd_nxt += adjusted_plen; + tp->snd_max += adjusted_plen; + + counter_u64_add(toep->ofld_txq->tx_iscsi_pdus, 1); + counter_u64_add(toep->ofld_txq->tx_iscsi_octets, plen); + + return (wr); +} + +void +t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) +{ + struct mbuf *sndptr, *m; + struct fw_wr_hdr *wrhdr; + struct wrqe *wr; + u_int plen, credits; + struct inpcb *inp = toep->inp; struct ofld_tx_sdesc *txsd = &toep->txsd[toep->txsd_pidx]; struct mbufq *pduq = &toep->ulp_pduq; - static const u_int ulp_extra_len[] = {0, 4, 4, 8}; INP_WLOCK_ASSERT(inp); KASSERT(toep->flags & TPF_FLOWC_WR_SENT, @@ -965,99 +1085,14 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) rqdrop_locked(&toep->ulp_pdu_reclaimq, drop); while ((sndptr = mbufq_first(pduq)) != NULL) { - M_ASSERTPKTHDR(sndptr); - - tx_credits = min(toep->tx_credits, MAX_OFLD_TX_CREDITS); - max_imm = max_imm_payload(tx_credits); - max_nsegs = max_dsgl_nsegs(tx_credits); - - plen = 0; - nsegs = 0; - max_nsegs_1mbuf = 0; /* max # of SGL segments in any one mbuf */ - for (m = sndptr; m != NULL; m = m->m_next) { - int n = sglist_count(mtod(m, void *), m->m_len); - - nsegs += n; - plen += m->m_len; - - /* - * This mbuf would send us _over_ the nsegs limit. - * Suspend tx because the PDU can't be sent out. - */ - if (plen > max_imm && nsegs > max_nsegs) { - toep->flags |= TPF_TX_SUSPENDED; - return; - } - - if (max_nsegs_1mbuf < n) - max_nsegs_1mbuf = n; - } - - if (__predict_false(toep->flags & TPF_FIN_SENT)) - panic("%s: excess tx.", __func__); - - /* - * We have a PDU to send. All of it goes out in one WR so 'm' - * is NULL. A PDU's length is always a multiple of 4. - */ - MPASS(m == NULL); - MPASS((plen & 3) == 0); - MPASS(sndptr->m_pkthdr.len == plen); - - shove = !(tp->t_flags & TF_MORETOCOME); - ulp_submode = mbuf_ulp_submode(sndptr); - MPASS(ulp_submode < nitems(ulp_extra_len)); - - /* - * plen doesn't include header and data digests, which are - * generated and inserted in the right places by the TOE, but - * they do occupy TCP sequence space and need to be accounted - * for. - */ - adjusted_plen = plen + ulp_extra_len[ulp_submode]; - if (plen <= max_imm) { - - /* Immediate data tx */ - - wr = alloc_wrqe(roundup2(sizeof(*txwr) + plen, 16), - &toep->ofld_txq->wrq); - if (wr == NULL) { - /* XXX: how will we recover from this? */ - toep->flags |= TPF_TX_SUSPENDED; - return; - } - txwr = wrtod(wr); - credits = howmany(wr->wr_len, 16); - write_tx_wr(txwr, toep, plen, adjusted_plen, credits, - shove, ulp_submode); - m_copydata(sndptr, 0, plen, (void *)(txwr + 1)); - nsegs = 0; - } else { - int wr_len; - - /* DSGL tx */ - wr_len = sizeof(*txwr) + sizeof(struct ulptx_sgl) + - ((3 * (nsegs - 1)) / 2 + ((nsegs - 1) & 1)) * 8; - wr = alloc_wrqe(roundup2(wr_len, 16), - &toep->ofld_txq->wrq); - if (wr == NULL) { - /* XXX: how will we recover from this? */ - toep->flags |= TPF_TX_SUSPENDED; - return; - } - txwr = wrtod(wr); - credits = howmany(wr_len, 16); - write_tx_wr(txwr, toep, 0, adjusted_plen, credits, - shove, ulp_submode); - write_tx_sgl(txwr + 1, sndptr, m, nsegs, - max_nsegs_1mbuf); - if (wr_len & 0xf) { - uint64_t *pad = (uint64_t *) - ((uintptr_t)txwr + wr_len); - *pad = 0; - } + wr = write_iscsi_mbuf_wr(toep, sndptr); + if (wr == NULL) { + toep->flags |= TPF_TX_SUSPENDED; + return; } + plen = sndptr->m_pkthdr.len; + credits = howmany(wr->wr_len, 16); KASSERT(toep->tx_credits >= credits, ("%s: not enough credits", __func__)); @@ -1068,16 +1103,19 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) toep->tx_credits -= credits; toep->tx_nocompl += credits; toep->plen_nocompl += plen; - if (toep->tx_credits <= toep->tx_total * 3 / 8 && + + /* + * Ensure there are enough credits for a full-sized WR + * as page pod WRs can be full-sized. + */ + if (toep->tx_credits <= SGE_MAX_WR_LEN * 5 / 4 && toep->tx_nocompl >= toep->tx_total / 4) { - txwr->op_to_immdlen |= htobe32(F_FW_WR_COMPL); + wrhdr = wrtod(wr); + wrhdr->hi |= htobe32(F_FW_WR_COMPL); toep->tx_nocompl = 0; toep->plen_nocompl = 0; } - tp->snd_nxt += adjusted_plen; - tp->snd_max += adjusted_plen; - toep->flags |= TPF_TX_DATA_SENT; if (toep->tx_credits < MIN_OFLD_TX_CREDITS) toep->flags |= TPF_TX_SUSPENDED; @@ -1092,9 +1130,6 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) } toep->txsd_avail--; - counter_u64_add(toep->ofld_txq->tx_iscsi_pdus, 1); - counter_u64_add(toep->ofld_txq->tx_iscsi_octets, plen); - t4_l2t_send(sc, wr, toep->l2te); } diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index b0d53dd63997..e87d013a0453 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -1081,11 +1081,30 @@ t4_write_page_pods_for_ps(struct adapter *sc, struct sge_wrq *wrq, int tid, return (0); } +static struct mbuf * +alloc_raw_wr_mbuf(int len) +{ + struct mbuf *m; + + if (len <= MHLEN) + m = m_gethdr(M_NOWAIT, MT_DATA); + else if (len <= MCLBYTES) + m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + else + m = NULL; + if (m == NULL) + return (NULL); + m->m_pkthdr.len = len; + m->m_len = len; + set_mbuf_raw_wr(m, true); + return (m); +} + int -t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, +t4_write_page_pods_for_buf(struct adapter *sc, struct toepcb *toep, struct ppod_reservation *prsv, vm_offset_t buf, int buflen) { - struct wrqe *wr; + struct inpcb *inp = toep->inp; struct ulp_mem_io *ulpmc; struct ulptx_idata *ulpsc; struct pagepod *ppod; @@ -1094,6 +1113,8 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, uint32_t cmd; struct ppod_region *pr = prsv->prsv_pr; uintptr_t end_pva, pva, pa; + struct mbuf *m; + struct mbufq wrq; cmd = htobe32(V_ULPTX_CMD(ULP_TX_MEM_WRITE)); if (is_t4(sc)) @@ -1105,6 +1126,7 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, ppod_addr = pr->pr_start + (prsv->prsv_tag & pr->pr_tag_mask); pva = trunc_page(buf); end_pva = trunc_page(buf + buflen - 1); + mbufq_init(&wrq, INT_MAX); for (i = 0; i < prsv->prsv_nppods; ppod_addr += chunk) { /* How many page pods are we writing in this cycle */ @@ -1113,12 +1135,14 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, chunk = PPOD_SZ(n); len = roundup2(sizeof(*ulpmc) + sizeof(*ulpsc) + chunk, 16); - wr = alloc_wrqe(len, wrq); - if (wr == NULL) - return (ENOMEM); /* ok to just bail out */ - ulpmc = wrtod(wr); + m = alloc_raw_wr_mbuf(len); + if (m == NULL) { + mbufq_drain(&wrq); + return (ENOMEM); + } + ulpmc = mtod(m, struct ulp_mem_io *); - INIT_ULPTX_WR(ulpmc, len, 0, 0); + INIT_ULPTX_WR(ulpmc, len, 0, toep->tid); ulpmc->cmd = cmd; ulpmc->dlen = htobe32(V_ULP_MEMIO_DATA_LEN(chunk / 32)); ulpmc->len16 = htobe32(howmany(len - sizeof(ulpmc->wr), 16)); @@ -1131,7 +1155,7 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, ppod = (struct pagepod *)(ulpsc + 1); for (j = 0; j < n; i++, j++, ppod++) { ppod->vld_tid_pgsz_tag_color = htobe64(F_PPOD_VALID | - V_PPOD_TID(tid) | + V_PPOD_TID(toep->tid) | (prsv->prsv_tag & ~V_PPOD_PGSZ(M_PPOD_PGSZ))); ppod->len_offset = htobe64(V_PPOD_LEN(buflen) | V_PPOD_OFST(offset)); @@ -1148,7 +1172,7 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, #if 0 CTR5(KTR_CXGBE, "%s: tid %d ppod[%d]->addr[%d] = %p", - __func__, tid, i, k, + __func__, toep->tid, i, k, htobe64(ppod->addr[k])); #endif } @@ -1161,9 +1185,13 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct sge_wrq *wrq, int tid, pva -= ddp_pgsz; } - t4_wrq_tx(sc, wr); + mbufq_enqueue(&wrq, m); } + INP_WLOCK(inp); + mbufq_concat(&toep->ulp_pduq, &wrq); + INP_WUNLOCK(inp); + MPASS(pva <= end_pva); return (0); diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index 68b3d29295f8..f1129b47cbcf 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -330,6 +330,22 @@ td_adapter(struct tom_data *td) return (td->tod.tod_softc); } +static inline void +set_mbuf_raw_wr(struct mbuf *m, bool raw) +{ + + M_ASSERTPKTHDR(m); + m->m_pkthdr.PH_per.eight[6] = raw; +} + +static inline bool +mbuf_raw_wr(struct mbuf *m) +{ + + M_ASSERTPKTHDR(m); + return (m->m_pkthdr.PH_per.eight[6]); +} + static inline void set_mbuf_ulp_submode(struct mbuf *m, uint8_t ulp_submode) { @@ -423,7 +439,7 @@ int t4_alloc_page_pods_for_buf(struct ppod_region *, vm_offset_t, int, struct ppod_reservation *); int t4_write_page_pods_for_ps(struct adapter *, struct sge_wrq *, int, struct pageset *); -int t4_write_page_pods_for_buf(struct adapter *, struct sge_wrq *, int, +int t4_write_page_pods_for_buf(struct adapter *, struct toepcb *, struct ppod_reservation *, vm_offset_t, int); void t4_free_page_pods(struct ppod_reservation *); int t4_soreceive_ddp(struct socket *, struct sockaddr **, struct uio *, From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 084BB628CF2; Fri, 14 May 2021 19:21:53 +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 4Fhdgh6VD1z3Gd3; Fri, 14 May 2021 19:21:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CCED317A75; Fri, 14 May 2021 19:21:52 +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 14EJLq6E058175; Fri, 14 May 2021 19:21:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLqIH058174; Fri, 14 May 2021 19:21:52 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:52 GMT Message-Id: <202105141921.14EJLqIH058174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 91ca7b095408 - main - cxgbei: Whitespace fixes, comment typo, and rewrap a comment. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91ca7b0954088f882e55e0ece6f456ca172ebcf5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:53 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=91ca7b0954088f882e55e0ece6f456ca172ebcf5 commit 91ca7b0954088f882e55e0ece6f456ca172ebcf5 Author: John Baldwin AuthorDate: 2021-05-14 19:16:57 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:16:57 +0000 cxgbei: Whitespace fixes, comment typo, and rewrap a comment. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29906 --- sys/dev/cxgbe/cxgbei/cxgbei.c | 2 +- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 12 ++++++------ sys/dev/cxgbe/tom/t4_cpl_io.c | 9 ++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c index 7027e6428515..419293ec9cdf 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/cxgbei.c @@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$"); #include "common/common.h" #include "common/t4_msg.h" -#include "common/t4_regs.h" /* for PCIE_MEM_ACCESS */ +#include "common/t4_regs.h" /* for PCIE_MEM_ACCESS */ #include "tom/t4_tom.h" #include "cxgbei.h" diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 9ee31616b873..655cc1de1478 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -280,7 +280,7 @@ finalize_pdu(struct icl_cxgbei_conn *icc, struct icl_cxgbei_pdu *icp) last = m_last(m); /* - * Round up the data segment to a 4B boundary. Pad with 0 if + * Round up the data segment to a 4B boundary. Pad with 0 if * necessary. There will definitely be room in the mbuf. */ padding = roundup2(ip->ip_data_len, 4) - ip->ip_data_len; @@ -306,7 +306,7 @@ finalize_pdu(struct icl_cxgbei_conn *icc, struct icl_cxgbei_pdu *icp) bhs->bhs_data_segment_len[1] = ip->ip_data_len >> 8; bhs->bhs_data_segment_len[0] = ip->ip_data_len >> 16; - /* "Convert" PDU to mbuf chain. Do not use icp/ip after this. */ + /* "Convert" PDU to mbuf chain. Do not use icp/ip after this. */ m->m_pkthdr.len = sizeof(struct iscsi_bhs) + ip->ip_data_len + padding; m->m_next = ip->ip_data_mbuf; set_mbuf_ulp_submode(m, ulp_submode); @@ -347,7 +347,7 @@ icl_cxgbei_conn_pdu_append_data(struct icl_conn *ic, struct icl_pdu *ip, MPASS(ip->ip_data_len <= ic->ic_max_data_segment_length); return (0); } else { - if (flags & M_WAITOK) { + if (flags & M_WAITOK) { CXGBE_UNIMPLEMENTED("fail safe append"); } ip->ip_data_len = m_length(m, NULL); @@ -576,7 +576,7 @@ send_iscsi_flowc_wr(struct adapter *sc, struct toepcb *toep, int maxlen) toep->txsd_pidx = 0; toep->txsd_avail--; - t4_wrq_tx(sc, wr); + t4_wrq_tx(sc, wr); } static void @@ -813,7 +813,7 @@ icl_cxgbei_conn_task_setup(struct icl_conn *ic, struct icl_pdu *ip, csio->dxfer_len < ci->ddp_threshold) { no_ddp: /* - * No DDP for this I/O. Allocate an ITT (based on the one + * No DDP for this I/O. Allocate an ITT (based on the one * passed in) that cannot be a valid hardware DDP tag in the * iSCSI region. */ @@ -1049,7 +1049,7 @@ static int icl_cxgbei_limits(struct icl_drv_limits *idl) { - /* Maximum allowed by the RFC. cxgbei_limits will clip them. */ + /* Maximum allowed by the RFC. cxgbei_limits will clip them. */ idl->idl_max_recv_data_segment_length = (1 << 24) - 1; idl->idl_max_send_data_segment_length = (1 << 24) - 1; diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index b4d84d3e5c55..d1b20cfa0e1e 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1819,13 +1819,12 @@ do_fw4_ack(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) SOCKBUF_LOCK(sb); sbu = sbused(sb); if (ulp_mode(toep) == ULP_MODE_ISCSI) { - if (__predict_false(sbu > 0)) { /* - * The data trasmitted before the tid's ULP mode - * changed to ISCSI is still in so_snd. - * Incoming credits should account for so_snd - * first. + * The data transmitted before the + * tid's ULP mode changed to ISCSI is + * still in so_snd. Incoming credits + * should account for so_snd first. */ sbdrop_locked(sb, min(sbu, plen)); plen -= min(sbu, plen); From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45BCD628C66; Fri, 14 May 2021 19:21: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 4Fhdgg6cWzz3GTp; Fri, 14 May 2021 19:21:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A7D3B17ABC; Fri, 14 May 2021 19:21: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 14EJLpsc058154; Fri, 14 May 2021 19:21:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLpdC058153; Fri, 14 May 2021 19:21:51 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:51 GMT Message-Id: <202105141921.14EJLpdC058153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 87bb5ed606fc - main - cxgbei: Use hardware RX flow control for offloaded iSCSI connections. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 87bb5ed606fc02f6520bbb8f9dfe2bc834a50d4d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:52 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=87bb5ed606fc02f6520bbb8f9dfe2bc834a50d4d commit 87bb5ed606fc02f6520bbb8f9dfe2bc834a50d4d Author: John Baldwin AuthorDate: 2021-05-14 19:16:51 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:16:51 +0000 cxgbei: Use hardware RX flow control for offloaded iSCSI connections. Forthcoming T6 iSCSI DDP support requires hardware RX flow control. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29905 --- sys/dev/cxgbe/cxgbei/cxgbei.c | 8 ++++---- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c index 07f704752305..7027e6428515 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/cxgbei.c @@ -315,13 +315,13 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) tp = intotcpcb(inp); MPASS(icp->icp_seq == tp->rcv_nxt); - MPASS(tp->rcv_wnd >= pdu_len); tp->rcv_nxt += pdu_len; - tp->rcv_wnd -= pdu_len; tp->t_rcvtime = ticks; - /* update rx credits */ - t4_rcvd(&toep->td->tod, tp); /* XXX: sc->tom_softc.tod */ + /* + * Don't update the window size or return credits since RX + * flow control is disabled. + */ so = inp->inp_socket; sb = &so->so_rcv; diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 4e168a33e2ca..9ee31616b873 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -591,6 +591,9 @@ set_ulp_mode_iscsi(struct adapter *sc, struct toepcb *toep, u_int ulp_submode) t4_set_tcb_field(sc, toep->ctrlq, toep, W_TCB_ULP_TYPE, V_TCB_ULP_TYPE(M_TCB_ULP_TYPE) | V_TCB_ULP_RAW(M_TCB_ULP_RAW), val, 0, 0); + + val = V_TF_RX_FLOW_CONTROL_DISABLE(1ULL); + t4_set_tcb_field(sc, toep->ctrlq, toep, W_TCB_T_FLAGS, val, val, 0, 0); } /* From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85327628F0F; Fri, 14 May 2021 19:21:54 +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 4Fhdgk0qM9z3GjG; Fri, 14 May 2021 19:21:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EADF6178F0; Fri, 14 May 2021 19:21:53 +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 14EJLrTq058198; Fri, 14 May 2021 19:21:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLrGH058197; Fri, 14 May 2021 19:21:53 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:53 GMT Message-Id: <202105141921.14EJLrGH058197@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 23b209ee885b - main - cxgbe tom: Account for pre-iSCSI mode data on suspended connections. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 23b209ee885b7891f806ecfe1bb944e40b3b4728 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:54 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=23b209ee885b7891f806ecfe1bb944e40b3b4728 commit 23b209ee885b7891f806ecfe1bb944e40b3b4728 Author: John Baldwin AuthorDate: 2021-05-14 19:17:02 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:17:02 +0000 cxgbe tom: Account for pre-iSCSI mode data on suspended connections. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29907 --- sys/dev/cxgbe/tom/t4_cpl_io.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index d1b20cfa0e1e..732754d07f8f 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1081,8 +1081,34 @@ t4_push_pdus(struct adapter *sc, struct toepcb *toep, int drop) return; } - if (drop) + if (drop) { + struct socket *so = inp->inp_socket; + struct sockbuf *sb = &so->so_snd; + int sbu; + + /* + * An unlocked read is ok here as the data should only + * transition from a non-zero value to either another + * non-zero value or zero. Once it is zero it should + * stay zero. + */ + if (__predict_false(sbused(sb)) > 0) { + SOCKBUF_LOCK(sb); + sbu = sbused(sb); + if (sbu > 0) { + /* + * The data transmitted before the + * tid's ULP mode changed to ISCSI is + * still in so_snd. Incoming credits + * should account for so_snd first. + */ + sbdrop_locked(sb, min(sbu, drop)); + drop -= min(sbu, drop); + } + sowwakeup_locked(so); /* unlocks so_snd */ + } rqdrop_locked(&toep->ulp_pdu_reclaimq, drop); + } while ((sndptr = mbufq_first(pduq)) != NULL) { wr = write_iscsi_mbuf_wr(toep, sndptr); From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0EF33628C7A; Fri, 14 May 2021 19:21:57 +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 4Fhdgm4Pzqz3GdB; Fri, 14 May 2021 19:21:56 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 31115178FF; Fri, 14 May 2021 19:21:56 +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 14EJLujN058245; Fri, 14 May 2021 19:21:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLukW058244; Fri, 14 May 2021 19:21:56 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:56 GMT Message-Id: <202105141921.14EJLukW058244@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 31df8ff73e3a - main - cxgbei: Rework the pdu_append_data hook to support M_WAITOK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 31df8ff73e3aa809146fae9baa6a96e1adf8526b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:57 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=31df8ff73e3aa809146fae9baa6a96e1adf8526b commit 31df8ff73e3aa809146fae9baa6a96e1adf8526b Author: John Baldwin AuthorDate: 2021-05-14 19:17:14 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:17:14 +0000 cxgbei: Rework the pdu_append_data hook to support M_WAITOK. - Only allocate 16K jumbo mbufs if the region of data to be appended is sufficiently large, and use a loop. - Use m_getm2() to allocate a chain for data less than 16K, or if m_getjcl() fails. - Use ENOMEM as the return value instead of '1' if the hook fails due to a memory allocation error. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29909 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 65 ++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 5770599eeeef..f91b9ee38616 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -324,35 +324,70 @@ int icl_cxgbei_conn_pdu_append_data(struct icl_conn *ic, struct icl_pdu *ip, const void *addr, size_t len, int flags) { - struct mbuf *m; #ifdef INVARIANTS struct icl_cxgbei_pdu *icp = ip_to_icp(ip); #endif + struct mbuf *m, *m_tail; + const char *src; MPASS(icp->icp_signature == CXGBEI_PDU_SIGNATURE); MPASS(ic == ip->ip_conn); KASSERT(len > 0, ("%s: len is %jd", __func__, (intmax_t)len)); - m = ip->ip_data_mbuf; - if (m == NULL) { + m_tail = ip->ip_data_mbuf; + if (m_tail != NULL) + for (; m_tail->m_next != NULL; m_tail = m_tail->m_next) + ; + + src = (const char *)addr; + + /* Allocate as jumbo mbufs of size MJUM16BYTES. */ + while (len >= MJUM16BYTES) { m = m_getjcl(M_NOWAIT, MT_DATA, 0, MJUM16BYTES); - if (__predict_false(m == NULL)) + if (__predict_false(m == NULL)) { + if ((flags & M_WAITOK) != 0) { + /* Fall back to non-jumbo mbufs. */ + break; + } return (ENOMEM); - - ip->ip_data_mbuf = m; + } + memcpy(mtod(m, void *), src, MJUM16BYTES); + m->m_len = MJUM16BYTES; + if (ip->ip_data_mbuf == NULL) { + ip->ip_data_mbuf = m_tail = m; + ip->ip_data_len = MJUM16BYTES; + } else { + m_tail->m_next = m; + m_tail = m_tail->m_next; + ip->ip_data_len += MJUM16BYTES; + } + src += MJUM16BYTES; + len -= MJUM16BYTES; } - if (__predict_true(m_append(m, len, addr) != 0)) { - ip->ip_data_len += len; - MPASS(ip->ip_data_len <= ic->ic_max_data_segment_length); - return (0); - } else { - if (flags & M_WAITOK) { - CXGBE_UNIMPLEMENTED("fail safe append"); + /* Allocate mbuf chain for the remaining data. */ + if (len != 0) { + m = m_getm2(NULL, len, flags, MT_DATA, 0); + if (__predict_false(m == NULL)) + return (ENOMEM); + if (ip->ip_data_mbuf == NULL) { + ip->ip_data_mbuf = m; + ip->ip_data_len = len; + } else { + m_tail->m_next = m; + ip->ip_data_len += len; } - ip->ip_data_len = m_length(m, NULL); - return (1); + for (; m != NULL; m = m->m_next) { + m->m_len = min(len, M_SIZE(m)); + memcpy(mtod(m, void *), src, m->m_len); + src += m->m_len; + len -= m->m_len; + } + MPASS(len == 0); } + MPASS(ip->ip_data_len <= ic->ic_max_data_segment_length); + + return (0); } void From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:55 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 42EA6628F11; Fri, 14 May 2021 19:21:55 +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 4Fhdgl10ljz3Gd8; Fri, 14 May 2021 19:21:55 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0EC2717AC6; Fri, 14 May 2021 19:21:55 +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 14EJLsbF058224; Fri, 14 May 2021 19:21:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLsvI058223; Fri, 14 May 2021 19:21:54 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:54 GMT Message-Id: <202105141921.14EJLsvI058223@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 46bee8043ee2 - main - cxgbei: Support DDP for target I/O S/G lists with more than one entry. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46bee8043ee2bd352d420cd573e0364ca45f813e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:55 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=46bee8043ee2bd352d420cd573e0364ca45f813e commit 46bee8043ee2bd352d420cd573e0364ca45f813e Author: John Baldwin AuthorDate: 2021-05-14 19:17:06 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:17:06 +0000 cxgbei: Support DDP for target I/O S/G lists with more than one entry. A CAM target layer I/O CCB can use a S/G list of virtual address ranges to describe its data buffer. This change adds zero-copy receive support for such requests. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29908 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 50 +++++++--- sys/dev/cxgbe/tom/t4_ddp.c | 191 ++++++++++++++++++++++++++++++++++++++ sys/dev/cxgbe/tom/t4_tom.h | 5 + 3 files changed, 232 insertions(+), 14 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 655cc1de1478..5770599eeeef 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -873,6 +873,28 @@ icl_cxgbei_conn_task_done(struct icl_conn *ic, void *arg) } } +static inline bool +ddp_sgl_check(struct ctl_sg_entry *sg, int entries, int xferlen) +{ + int total_len = 0; + + MPASS(entries > 0); + if (((vm_offset_t)sg[--entries].addr & 3U) != 0) + return (false); + + total_len += sg[entries].len; + + while (--entries >= 0) { + if (((vm_offset_t)sg[entries].addr & PAGE_MASK) != 0 || + (sg[entries].len % PAGE_SIZE) != 0) + return (false); + total_len += sg[entries].len; + } + + MPASS(total_len == xferlen); + return (true); +} + /* XXXNP: PDU should be passed in as parameter, like on the initiator. */ #define io_to_request_pdu(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr) #define io_to_ppod_reservation(io) ((io)->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr) @@ -888,6 +910,8 @@ icl_cxgbei_conn_transfer_setup(struct icl_conn *ic, union ctl_io *io, struct cxgbei_data *ci = sc->iscsi_ulp_softc; struct ppod_region *pr = &ci->pr; struct ppod_reservation *prsv; + struct ctl_sg_entry *sgl, sg_entry; + int sg_entries = ctsio->kern_sg_entries; uint32_t ttt; int xferlen, rc = 0, alias; @@ -898,7 +922,6 @@ icl_cxgbei_conn_transfer_setup(struct icl_conn *ic, union ctl_io *io, if (ctsio->ext_data_filled == 0) { int first_burst; struct icl_pdu *ip = io_to_request_pdu(io); - vm_offset_t buf; #ifdef INVARIANTS struct icl_cxgbei_pdu *icp = ip_to_icp(ip); @@ -931,18 +954,16 @@ no_ddp: return (0); } - if (ctsio->kern_sg_entries == 0) - buf = (vm_offset_t)ctsio->kern_data_ptr; - else if (ctsio->kern_sg_entries == 1) { - struct ctl_sg_entry *sgl = (void *)ctsio->kern_data_ptr; + if (sg_entries == 0) { + sgl = &sg_entry; + sgl->len = xferlen; + sgl->addr = (void *)ctsio->kern_data_ptr; + sg_entries = 1; + } else + sgl = (void *)ctsio->kern_data_ptr; - MPASS(sgl->len == xferlen); - buf = (vm_offset_t)sgl->addr; - } else { - rc = EAGAIN; /* XXX implement */ + if (!ddp_sgl_check(sgl, sg_entries, xferlen)) goto no_ddp; - } - /* * Reserve resources for DDP, update the ttt that should be used @@ -956,14 +977,15 @@ no_ddp: goto no_ddp; } - rc = t4_alloc_page_pods_for_buf(pr, buf, xferlen, prsv); + rc = t4_alloc_page_pods_for_sgl(pr, sgl, sg_entries, prsv); if (rc != 0) { uma_zfree(prsv_zone, prsv); goto no_ddp; } - rc = t4_write_page_pods_for_buf(sc, toep, prsv, buf, xferlen); - if (rc != 0) { + rc = t4_write_page_pods_for_sgl(sc, toep, prsv, sgl, sg_entries, + xferlen); + if (__predict_false(rc != 0)) { t4_free_page_pods(prsv); uma_zfree(prsv_zone, prsv); goto no_ddp; diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index e87d013a0453..c266a2e39fa9 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #ifdef TCP_OFFLOAD #include "common/common.h" #include "common/t4_msg.h" @@ -981,6 +984,76 @@ have_pgsz: return (0); } +int +t4_alloc_page_pods_for_sgl(struct ppod_region *pr, struct ctl_sg_entry *sgl, + int entries, struct ppod_reservation *prsv) +{ + int hcf, seglen, idx = 0, npages, nppods, i, len; + uintptr_t start_pva, end_pva, pva, p1 ; + vm_offset_t buf; + struct ctl_sg_entry *sge; + + MPASS(entries > 0); + MPASS(sgl); + + /* + * The DDP page size is unrelated to the VM page size. We combine + * contiguous physical pages into larger segments to get the best DDP + * page size possible. This is the largest of the four sizes in + * A_ULP_RX_ISCSI_PSZ that evenly divides the HCF of the segment sizes + * in the page list. + */ + hcf = 0; + for (i = entries - 1; i >= 0; i--) { + sge = sgl + i; + buf = (vm_offset_t)sge->addr; + len = sge->len; + start_pva = trunc_page(buf); + end_pva = trunc_page(buf + len - 1); + pva = start_pva; + while (pva <= end_pva) { + seglen = PAGE_SIZE; + p1 = pmap_kextract(pva); + pva += PAGE_SIZE; + while (pva <= end_pva && p1 + seglen == + pmap_kextract(pva)) { + seglen += PAGE_SIZE; + pva += PAGE_SIZE; + } + + hcf = calculate_hcf(hcf, seglen); + if (hcf < (1 << pr->pr_page_shift[1])) { + idx = 0; + goto have_pgsz; /* give up, short circuit */ + } + } + } +#define PR_PAGE_MASK(x) ((1 << pr->pr_page_shift[(x)]) - 1) + MPASS((hcf & PR_PAGE_MASK(0)) == 0); /* PAGE_SIZE is >= 4K everywhere */ + for (idx = nitems(pr->pr_page_shift) - 1; idx > 0; idx--) { + if ((hcf & PR_PAGE_MASK(idx)) == 0) + break; + } +#undef PR_PAGE_MASK + +have_pgsz: + MPASS(idx <= M_PPOD_PGSZ); + + npages = 0; + while (entries--) { + npages++; + start_pva = trunc_page(sgl->addr); + end_pva = trunc_page((vm_offset_t)sgl->addr + sgl->len - 1); + npages += (end_pva - start_pva) >> pr->pr_page_shift[idx]; + sgl = sgl + 1; + } + nppods = howmany(npages, PPOD_PAGES); + if (alloc_page_pods(pr, nppods, idx, prsv) != 0) + return (ENOMEM); + MPASS(prsv->prsv_nppods > 0); + return (0); +} + void t4_free_page_pods(struct ppod_reservation *prsv) { @@ -1197,6 +1270,124 @@ t4_write_page_pods_for_buf(struct adapter *sc, struct toepcb *toep, return (0); } +int +t4_write_page_pods_for_sgl(struct adapter *sc, struct toepcb *toep, + struct ppod_reservation *prsv, struct ctl_sg_entry *sgl, int entries, + int xferlen) +{ + struct inpcb *inp = toep->inp; + struct ulp_mem_io *ulpmc; + struct ulptx_idata *ulpsc; + struct pagepod *ppod; + int i, j, k, n, chunk, len, ddp_pgsz; + u_int ppod_addr, offset, sg_offset = 0; + uint32_t cmd; + struct ppod_region *pr = prsv->prsv_pr; + uintptr_t pva, pa; + struct mbuf *m; + struct mbufq wrq; + + MPASS(sgl != NULL); + MPASS(entries > 0); + cmd = htobe32(V_ULPTX_CMD(ULP_TX_MEM_WRITE)); + if (is_t4(sc)) + cmd |= htobe32(F_ULP_MEMIO_ORDER); + else + cmd |= htobe32(F_T5_ULP_MEMIO_IMM); + ddp_pgsz = 1 << pr->pr_page_shift[G_PPOD_PGSZ(prsv->prsv_tag)]; + offset = (vm_offset_t)sgl->addr & PAGE_MASK; + ppod_addr = pr->pr_start + (prsv->prsv_tag & pr->pr_tag_mask); + pva = trunc_page(sgl->addr); + mbufq_init(&wrq, INT_MAX); + for (i = 0; i < prsv->prsv_nppods; ppod_addr += chunk) { + + /* How many page pods are we writing in this cycle */ + n = min(prsv->prsv_nppods - i, NUM_ULP_TX_SC_IMM_PPODS); + MPASS(n > 0); + chunk = PPOD_SZ(n); + len = roundup2(sizeof(*ulpmc) + sizeof(*ulpsc) + chunk, 16); + + m = alloc_raw_wr_mbuf(len); + if (m == NULL) { + mbufq_drain(&wrq); + return (ENOMEM); + } + ulpmc = mtod(m, struct ulp_mem_io *); + + INIT_ULPTX_WR(ulpmc, len, 0, toep->tid); + ulpmc->cmd = cmd; + ulpmc->dlen = htobe32(V_ULP_MEMIO_DATA_LEN(chunk / 32)); + ulpmc->len16 = htobe32(howmany(len - sizeof(ulpmc->wr), 16)); + ulpmc->lock_addr = htobe32(V_ULP_MEMIO_ADDR(ppod_addr >> 5)); + + ulpsc = (struct ulptx_idata *)(ulpmc + 1); + ulpsc->cmd_more = htobe32(V_ULPTX_CMD(ULP_TX_SC_IMM)); + ulpsc->len = htobe32(chunk); + + ppod = (struct pagepod *)(ulpsc + 1); + for (j = 0; j < n; i++, j++, ppod++) { + ppod->vld_tid_pgsz_tag_color = htobe64(F_PPOD_VALID | + V_PPOD_TID(toep->tid) | + (prsv->prsv_tag & ~V_PPOD_PGSZ(M_PPOD_PGSZ))); + ppod->len_offset = htobe64(V_PPOD_LEN(xferlen) | + V_PPOD_OFST(offset)); + ppod->rsvd = 0; + + for (k = 0; k < nitems(ppod->addr); k++) { + if (entries != 0) { + pa = pmap_kextract(pva + sg_offset); + ppod->addr[k] = htobe64(pa); + } else + ppod->addr[k] = 0; + +#if 0 + CTR5(KTR_CXGBE, + "%s: tid %d ppod[%d]->addr[%d] = %p", + __func__, toep->tid, i, k, + htobe64(ppod->addr[k])); +#endif + + /* + * If this is the last entry in a pod, + * reuse the same entry for first address + * in the next pod. + */ + if (k + 1 == nitems(ppod->addr)) + break; + + /* + * Don't move to the next DDP page if the + * sgl is already finished. + */ + if (entries == 0) + continue; + + sg_offset += ddp_pgsz; + if (sg_offset == sgl->len) { + /* + * This sgl entry is done. Go + * to the next. + */ + entries--; + sgl++; + sg_offset = 0; + if (entries != 0) + pva = trunc_page( + (vm_offset_t)sgl->addr); + } + } + } + + mbufq_enqueue(&wrq, m); + } + + INP_WLOCK(inp); + mbufq_concat(&toep->ulp_pduq, &wrq); + INP_WUNLOCK(inp); + + return (0); +} + /* * Prepare a pageset for DDP. This sets up page pods. */ diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index f1129b47cbcf..c7984f838735 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -88,6 +88,7 @@ enum { DDP_DEAD = (1 << 6), /* toepcb is shutting down */ }; +struct ctl_sg_entry; struct sockopt; struct offload_settings; @@ -437,10 +438,14 @@ void t4_free_ppod_region(struct ppod_region *); int t4_alloc_page_pods_for_ps(struct ppod_region *, struct pageset *); int t4_alloc_page_pods_for_buf(struct ppod_region *, vm_offset_t, int, struct ppod_reservation *); +int t4_alloc_page_pods_for_sgl(struct ppod_region *, struct ctl_sg_entry *, int, + struct ppod_reservation *); int t4_write_page_pods_for_ps(struct adapter *, struct sge_wrq *, int, struct pageset *); int t4_write_page_pods_for_buf(struct adapter *, struct toepcb *, struct ppod_reservation *, vm_offset_t, int); +int t4_write_page_pods_for_sgl(struct adapter *, struct toepcb *, + struct ppod_reservation *, struct ctl_sg_entry *, int, int); void t4_free_page_pods(struct ppod_reservation *); int t4_soreceive_ddp(struct socket *, struct sockaddr **, struct uio *, struct mbuf **, struct mbuf **, int *); From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:58 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F05A1629082; Fri, 14 May 2021 19:21:57 +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 4Fhdgn4QqHz3GVG; Fri, 14 May 2021 19:21:57 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 485E017E2E; Fri, 14 May 2021 19:21:57 +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 14EJLvuT058266; Fri, 14 May 2021 19:21:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLvUc058265; Fri, 14 May 2021 19:21:57 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:57 GMT Message-Id: <202105141921.14EJLvUc058265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a1c687347a7f - main - cxgbei: Add support for zero-copy iSCSI target transmission/read. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a1c687347a7f983dadec10949938ee4d1b321120 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:58 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a1c687347a7f983dadec10949938ee4d1b321120 commit a1c687347a7f983dadec10949938ee4d1b321120 Author: John Baldwin AuthorDate: 2021-05-14 19:17:20 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:17:20 +0000 cxgbei: Add support for zero-copy iSCSI target transmission/read. - Switch to allocating the cxgbei version of icl_pdu explicitly as a separate refcounted object allocated via malloc/free instead of storing it in the bhs mbuf prior to the bhs. - Support the icl_conn_pdu_queue_cb() method to set a callback on a PDU to be invoked when the PDU is freed. - For ICL_NOCOPY buffers, use an external mbuf to manage the storage for the buffer via m_extaddref(). Each external mbuf holds a reference on the associated PDU, so the callback is invoked once all of the external mbufs have been freed. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29910 --- sys/dev/cxgbe/cxgbei/cxgbei.h | 4 + sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 161 ++++++++++++++++++++++++++++++-------- 2 files changed, 132 insertions(+), 33 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.h b/sys/dev/cxgbe/cxgbei/cxgbei.h index 3b17a4f2b36a..9941e817b9cb 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.h +++ b/sys/dev/cxgbe/cxgbei/cxgbei.h @@ -96,6 +96,10 @@ struct icl_cxgbei_pdu { uint32_t icp_signature; uint32_t icp_seq; /* For debug only */ u_int icp_flags; + + u_int ref_cnt; + icl_pdu_cb cb; + int error; }; static inline struct icl_cxgbei_pdu * diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index f91b9ee38616..f661d0a9d7d7 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -100,6 +100,8 @@ __FBSDID("$FreeBSD$"); #include "tom/t4_tom.h" #include "cxgbei.h" +static MALLOC_DEFINE(M_CXGBEI, "cxgbei", "cxgbei(4)"); + SYSCTL_NODE(_kern_icl, OID_AUTO, cxgbei, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Chelsio iSCSI offload"); static int coalesce = 1; @@ -130,6 +132,7 @@ static icl_conn_pdu_data_segment_length_t static icl_conn_pdu_append_data_t icl_cxgbei_conn_pdu_append_data; static icl_conn_pdu_get_data_t icl_cxgbei_conn_pdu_get_data; static icl_conn_pdu_queue_t icl_cxgbei_conn_pdu_queue; +static icl_conn_pdu_queue_cb_t icl_cxgbei_conn_pdu_queue_cb; static icl_conn_handoff_t icl_cxgbei_conn_handoff; static icl_conn_free_t icl_cxgbei_conn_free; static icl_conn_close_t icl_cxgbei_conn_close; @@ -146,6 +149,7 @@ static kobj_method_t icl_cxgbei_methods[] = { KOBJMETHOD(icl_conn_pdu_append_data, icl_cxgbei_conn_pdu_append_data), KOBJMETHOD(icl_conn_pdu_get_data, icl_cxgbei_conn_pdu_get_data), KOBJMETHOD(icl_conn_pdu_queue, icl_cxgbei_conn_pdu_queue), + KOBJMETHOD(icl_conn_pdu_queue_cb, icl_cxgbei_conn_pdu_queue_cb), KOBJMETHOD(icl_conn_handoff, icl_cxgbei_conn_handoff), KOBJMETHOD(icl_conn_free, icl_cxgbei_conn_free), KOBJMETHOD(icl_conn_close, icl_cxgbei_conn_close), @@ -161,54 +165,108 @@ DEFINE_CLASS(icl_cxgbei, icl_cxgbei_methods, sizeof(struct icl_cxgbei_conn)); void icl_cxgbei_conn_pdu_free(struct icl_conn *ic, struct icl_pdu *ip) { -#ifdef INVARIANTS struct icl_cxgbei_pdu *icp = ip_to_icp(ip); -#endif + KASSERT(icp->ref_cnt != 0, ("freeing deleted PDU")); MPASS(icp->icp_signature == CXGBEI_PDU_SIGNATURE); MPASS(ic == ip->ip_conn); - MPASS(ip->ip_bhs_mbuf != NULL); m_freem(ip->ip_ahs_mbuf); m_freem(ip->ip_data_mbuf); - m_freem(ip->ip_bhs_mbuf); /* storage for icl_cxgbei_pdu itself */ + m_freem(ip->ip_bhs_mbuf); + + KASSERT(ic != NULL || icp->ref_cnt == 1, + ("orphaned PDU has oustanding references")); + if (atomic_fetchadd_int(&icp->ref_cnt, -1) != 1) + return; + + free(icp, M_CXGBEI); #ifdef DIAGNOSTIC if (__predict_true(ic != NULL)) refcount_release(&ic->ic_outstanding_pdus); #endif } +static void +icl_cxgbei_pdu_call_cb(struct icl_pdu *ip) +{ + struct icl_cxgbei_pdu *icp = ip_to_icp(ip); + + MPASS(icp->icp_signature == CXGBEI_PDU_SIGNATURE); + + if (icp->cb != NULL) + icp->cb(ip, icp->error); +#ifdef DIAGNOSTIC + if (__predict_true(ip->ip_conn != NULL)) + refcount_release(&ip->ip_conn->ic_outstanding_pdus); +#endif + free(icp, M_CXGBEI); +} + +static void +icl_cxgbei_pdu_done(struct icl_pdu *ip, int error) +{ + struct icl_cxgbei_pdu *icp = ip_to_icp(ip); + + if (error != 0) + icp->error = error; + + m_freem(ip->ip_ahs_mbuf); + ip->ip_ahs_mbuf = NULL; + m_freem(ip->ip_data_mbuf); + ip->ip_data_mbuf = NULL; + m_freem(ip->ip_bhs_mbuf); + ip->ip_bhs_mbuf = NULL; + + /* + * All other references to this PDU should have been dropped + * by the m_freem() of ip_data_mbuf. + */ + if (atomic_fetchadd_int(&icp->ref_cnt, -1) == 1) + icl_cxgbei_pdu_call_cb(ip); + else + __assert_unreachable(); +} + +static void +icl_cxgbei_mbuf_done(struct mbuf *mb) +{ + + struct icl_cxgbei_pdu *icp = (struct icl_cxgbei_pdu *)mb->m_ext.ext_arg1; + + /* + * NB: mb_free_mext() might leave ref_cnt as 1 without + * decrementing it if it hits the fast path in the ref_cnt + * check. + */ + icl_cxgbei_pdu_call_cb(&icp->ip); +} + struct icl_pdu * icl_cxgbei_new_pdu(int flags) { struct icl_cxgbei_pdu *icp; struct icl_pdu *ip; struct mbuf *m; - uintptr_t a; - m = m_gethdr(flags, MT_DATA); - if (__predict_false(m == NULL)) + icp = malloc(sizeof(*icp), M_CXGBEI, flags | M_ZERO); + if (__predict_false(icp == NULL)) return (NULL); - a = roundup2(mtod(m, uintptr_t), _Alignof(struct icl_cxgbei_pdu)); - icp = (struct icl_cxgbei_pdu *)a; - bzero(icp, sizeof(*icp)); - icp->icp_signature = CXGBEI_PDU_SIGNATURE; + icp->ref_cnt = 1; ip = &icp->ip; - ip->ip_bhs_mbuf = m; - a = roundup2((uintptr_t)(icp + 1), _Alignof(struct iscsi_bhs *)); - ip->ip_bhs = (struct iscsi_bhs *)a; -#ifdef INVARIANTS - /* Everything must fit entirely in the mbuf. */ - a = (uintptr_t)(ip->ip_bhs + 1); - MPASS(a <= (uintptr_t)m + MSIZE); -#endif - bzero(ip->ip_bhs, sizeof(*ip->ip_bhs)); + m = m_gethdr(flags, MT_DATA); + if (__predict_false(m == NULL)) { + free(icp, M_CXGBEI); + return (NULL); + } - m->m_data = (void *)ip->ip_bhs; + ip->ip_bhs_mbuf = m; + ip->ip_bhs = mtod(m, struct iscsi_bhs *); + memset(ip->ip_bhs, 0, sizeof(*ip->ip_bhs)); m->m_len = sizeof(struct iscsi_bhs); m->m_pkthdr.len = m->m_len; @@ -306,16 +364,22 @@ finalize_pdu(struct icl_cxgbei_conn *icc, struct icl_cxgbei_pdu *icp) bhs->bhs_data_segment_len[1] = ip->ip_data_len >> 8; bhs->bhs_data_segment_len[0] = ip->ip_data_len >> 16; - /* "Convert" PDU to mbuf chain. Do not use icp/ip after this. */ - m->m_pkthdr.len = sizeof(struct iscsi_bhs) + ip->ip_data_len + padding; + /* + * Extract mbuf chain from PDU. + */ + m->m_pkthdr.len += ip->ip_data_len + padding; m->m_next = ip->ip_data_mbuf; set_mbuf_ulp_submode(m, ulp_submode); -#ifdef INVARIANTS - bzero(icp, sizeof(*icp)); -#endif -#ifdef DIAGNOSTIC - refcount_release(&icc->ic.ic_outstanding_pdus); -#endif + ip->ip_bhs_mbuf = NULL; + ip->ip_data_mbuf = NULL; + ip->ip_bhs = NULL; + + /* + * Drop PDU reference on icp. Additional references might + * still be held by zero-copy PDU buffers (ICL_NOCOPY). + */ + if (atomic_fetchadd_int(&icp->ref_cnt, -1) == 1) + icl_cxgbei_pdu_call_cb(ip); return (m); } @@ -324,9 +388,7 @@ int icl_cxgbei_conn_pdu_append_data(struct icl_conn *ic, struct icl_pdu *ip, const void *addr, size_t len, int flags) { -#ifdef INVARIANTS struct icl_cxgbei_pdu *icp = ip_to_icp(ip); -#endif struct mbuf *m, *m_tail; const char *src; @@ -339,6 +401,29 @@ icl_cxgbei_conn_pdu_append_data(struct icl_conn *ic, struct icl_pdu *ip, for (; m_tail->m_next != NULL; m_tail = m_tail->m_next) ; + if (flags & ICL_NOCOPY) { + m = m_get(flags & ~ICL_NOCOPY, MT_DATA); + if (m == NULL) { + ICL_WARN("failed to allocate mbuf"); + return (ENOMEM); + } + + m->m_flags |= M_RDONLY; + m_extaddref(m, __DECONST(char *, addr), len, &icp->ref_cnt, + icl_cxgbei_mbuf_done, icp, NULL); + m->m_len = len; + if (ip->ip_data_mbuf == NULL) { + ip->ip_data_mbuf = m; + ip->ip_data_len = len; + } else { + m_tail->m_next = m; + m_tail = m_tail->m_next; + ip->ip_data_len += len; + } + + return (0); + } + src = (const char *)addr; /* Allocate as jumbo mbufs of size MJUM16BYTES. */ @@ -403,6 +488,13 @@ icl_cxgbei_conn_pdu_get_data(struct icl_conn *ic, struct icl_pdu *ip, void icl_cxgbei_conn_pdu_queue(struct icl_conn *ic, struct icl_pdu *ip) +{ + icl_cxgbei_conn_pdu_queue_cb(ic, ip, NULL); +} + +void +icl_cxgbei_conn_pdu_queue_cb(struct icl_conn *ic, struct icl_pdu *ip, + icl_pdu_cb cb) { struct epoch_tracker et; struct icl_cxgbei_conn *icc = ic_to_icc(ic); @@ -418,9 +510,12 @@ icl_cxgbei_conn_pdu_queue(struct icl_conn *ic, struct icl_pdu *ip) MPASS(ip->ip_ahs_mbuf == NULL && ip->ip_ahs_len == 0); ICL_CONN_LOCK_ASSERT(ic); + + icp->cb = cb; + /* NOTE: sowriteable without so_snd lock is a mostly harmless race. */ if (ic->ic_disconnecting || so == NULL || !sowriteable(so)) { - icl_cxgbei_conn_pdu_free(ic, ip); + icl_cxgbei_pdu_done(ip, ENOTCONN); return; } @@ -809,7 +904,7 @@ icl_cxgbei_conn_close(struct icl_conn *ic) while (!STAILQ_EMPTY(&icc->rcvd_pdus)) { ip = STAILQ_FIRST(&icc->rcvd_pdus); STAILQ_REMOVE_HEAD(&icc->rcvd_pdus, ip_next); - icl_cxgbei_conn_pdu_free(ic, ip); + icl_cxgbei_pdu_done(ip, ENOTCONN); } SOCKBUF_UNLOCK(sb); } From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4AF5628B0D; Fri, 14 May 2021 19:21:58 +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 4Fhdgp3bzsz3Ggy; Fri, 14 May 2021 19:21:58 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 587EC17E2F; Fri, 14 May 2021 19:21:58 +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 14EJLwfO058287; Fri, 14 May 2021 19:21:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLwgq058286; Fri, 14 May 2021 19:21:58 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:58 GMT Message-Id: <202105141921.14EJLwgq058286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4add8e4c8991 - main - cxgbei: Don't leak resources for an aborted target transfer. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4add8e4c89915dc0018a8480c63b6d6031d31295 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:21:59 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4add8e4c89915dc0018a8480c63b6d6031d31295 commit 4add8e4c89915dc0018a8480c63b6d6031d31295 Author: John Baldwin AuthorDate: 2021-05-14 19:17:26 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:17:26 +0000 cxgbei: Don't leak resources for an aborted target transfer. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29911 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index f661d0a9d7d7..e3dc05645732 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -1153,7 +1153,8 @@ icl_cxgbei_conn_transfer_done(struct icl_conn *ic, void *arg) { struct ctl_scsiio *ctsio = arg; - if (ctsio != NULL && ctsio->kern_data_len == ctsio->ext_data_filled) { + if (ctsio != NULL && (ctsio->kern_data_len == ctsio->ext_data_filled || + ic->ic_disconnecting)) { struct ppod_reservation *prsv; prsv = io_to_ppod_reservation(ctsio); From owner-dev-commits-src-all@freebsd.org Fri May 14 19:21:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E71B7628B27; Fri, 14 May 2021 19:21:59 +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 4Fhdgq4ddVz3GWt; Fri, 14 May 2021 19:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 7F08917E30; Fri, 14 May 2021 19:21:59 +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 14EJLxGn058308; Fri, 14 May 2021 19:21:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJLxbj058307; Fri, 14 May 2021 19:21:59 GMT (envelope-from git) Date: Fri, 14 May 2021 19:21:59 GMT Message-Id: <202105141921.14EJLxbj058307@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 1ad32ad0bed4 - main - cxgbei: Don't clamp iSCSI PDUs to 8K. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1ad32ad0bed40be5deb87a36a0564adc994ad47a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:22:00 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=1ad32ad0bed40be5deb87a36a0564adc994ad47a commit 1ad32ad0bed40be5deb87a36a0564adc994ad47a Author: John Baldwin AuthorDate: 2021-05-14 19:17:31 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:21:24 +0000 cxgbei: Don't clamp iSCSI PDUs to 8K. The firmware no longer requires this workaround. Discussed with: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29912 --- sys/dev/cxgbe/cxgbei/cxgbei.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c index 419293ec9cdf..f95c9f60163f 100644 --- a/sys/dev/cxgbe/cxgbei/cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/cxgbei.c @@ -114,9 +114,6 @@ read_pdu_limits(struct adapter *sc, uint32_t *max_tx_pdu_len, rx_len = min(rx_len, v); tx_len = min(tx_len, v); - /* Remove after FW_FLOWC_MNEM_TXDATAPLEN_MAX fix in firmware. */ - tx_len = min(tx_len, 3 * 4096); - *max_tx_pdu_len = rounddown2(tx_len, 512); *max_rx_pdu_len = rounddown2(rx_len, 512); } From owner-dev-commits-src-all@freebsd.org Fri May 14 19:22:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D4883629076; Fri, 14 May 2021 19:22:02 +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 4Fhdgt0wM4z3GhG; Fri, 14 May 2021 19:22:02 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CACEB17ACA; Fri, 14 May 2021 19:22:01 +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 14EJM1SX058369; Fri, 14 May 2021 19:22:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJM1pM058368; Fri, 14 May 2021 19:22:01 GMT (envelope-from git) Date: Fri, 14 May 2021 19:22:01 GMT Message-Id: <202105141922.14EJM1pM058368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e73e2ee0acf5 - main - cxgbei: Handle target transfers with excess unsolicited data. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:22:03 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab commit e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab Author: John Baldwin AuthorDate: 2021-05-14 19:20:57 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:21:34 +0000 cxgbei: Handle target transfers with excess unsolicited data. The CTL frontend might have provided a buffer that is smaller than the FirstBurstLength and thus smaller than the amount of unsolicited data included in the request PDU. Treat these transfers as an empty transfer. Reported by: Jithesh Arakkan @ Chelsio Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29940 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index 7f638c96483a..c4eb4a35ad31 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -1064,10 +1064,15 @@ icl_cxgbei_conn_transfer_setup(struct icl_conn *ic, union ctl_io *io, /* * Note that ICL calls conn_transfer_setup even if the first * burst had everything and there's nothing left to transfer. + * + * NB: The CTL frontend might have provided a buffer + * whose length (kern_data_len) is smaller than the + * FirstBurstLength of unsolicited data. Treat those + * as an empty transfer. */ - MPASS(ctsio->kern_data_len >= first_burst); xferlen = ctsio->kern_data_len; - if (xferlen - first_burst < ci->ddp_threshold) { + if (xferlen < first_burst || + xferlen - first_burst < ci->ddp_threshold) { no_ddp: /* * No DDP for this transfer. Allocate a TTT (based on From owner-dev-commits-src-all@freebsd.org Fri May 14 19:22:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0A14628B2B; Fri, 14 May 2021 19:22:02 +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 4Fhdgs4DQVz3Gts; Fri, 14 May 2021 19:22:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A785417AC9; Fri, 14 May 2021 19:22:00 +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 14EJM0ma058348; Fri, 14 May 2021 19:22:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EJM0YC058347; Fri, 14 May 2021 19:22:00 GMT (envelope-from git) Date: Fri, 14 May 2021 19:22:00 GMT Message-Id: <202105141922.14EJM0YC058347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e894e3adb206 - main - cxgbei: Explicitly clear the page pode reservation pointer after freeing it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e894e3adb206815c2acff17a4011becb166c2f66 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 19:22:02 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e894e3adb206815c2acff17a4011becb166c2f66 commit e894e3adb206815c2acff17a4011becb166c2f66 Author: John Baldwin AuthorDate: 2021-05-14 19:20:51 +0000 Commit: John Baldwin CommitDate: 2021-05-14 19:21:34 +0000 cxgbei: Explicitly clear the page pode reservation pointer after freeing it. A single union ctl_io can be reused across multiple transfers (in particular by the ramdisk backend). On a reuse, the reservation pointer would retain its value from the previous transfer tripping an assertion. Reported by: Jithesh Arakkan @ Chelsio Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29939 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index e3dc05645732..7f638c96483a 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -1162,6 +1162,7 @@ icl_cxgbei_conn_transfer_done(struct icl_conn *ic, void *arg) t4_free_page_pods(prsv); uma_zfree(prsv_zone, prsv); + io_to_ppod_reservation(ctsio) = NULL; } } From owner-dev-commits-src-all@freebsd.org Fri May 14 20:34:40 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E2F9B62A97F; Fri, 14 May 2021 20:34:40 +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 4FhgHh6782z3RF1; Fri, 14 May 2021 20:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C536A18C20; Fri, 14 May 2021 20:34:40 +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 14EKYeCw052140; Fri, 14 May 2021 20:34:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14EKYevJ052139; Fri, 14 May 2021 20:34:40 GMT (envelope-from git) Date: Fri, 14 May 2021 20:34:40 GMT Message-Id: <202105142034.14EKYevJ052139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: cf653b7abea3 - main - git-arc(1): fix usage formatting for stage command MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf653b7abea3852cac8dfb65415f7349baa6ceb1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 20:34:40 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=cf653b7abea3852cac8dfb65415f7349baa6ceb1 commit cf653b7abea3852cac8dfb65415f7349baa6ceb1 Author: Mitchell Horne AuthorDate: 2021-05-14 20:32:47 +0000 Commit: Mitchell Horne CommitDate: 2021-05-14 20:34:04 +0000 git-arc(1): fix usage formatting for stage command The branch argument is conditional on the -b flag. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D30262 --- tools/tools/git/git-arc.1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/tools/git/git-arc.1 b/tools/tools/git/git-arc.1 index 00019a19180d..21399aef8e0e 100644 --- a/tools/tools/git/git-arc.1 +++ b/tools/tools/git/git-arc.1 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 7, 2021 +.Dd May 14, 2021 .Dt GIT-ARC 1 .Os .Sh NAME @@ -43,8 +43,8 @@ .Cm patch Ar diff1 Ns Op Cm \&, Ns Ar diff2 .Nm .Cm stage -.Op Fl b -.Ar branch Op Ar commit Ns | Ns Ar commit-range +.Op Fl b Ar branch +.Op Ar commit Ns | Ns Ar commit-range .Nm .Cm update .Op Ar commit Ns | Ns Ar commit-range Oc From owner-dev-commits-src-all@freebsd.org Fri May 14 21:25:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED29B62C818; Fri, 14 May 2021 21:25:36 +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 4FhhQS6RCnz3rXY; Fri, 14 May 2021 21:25:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CFB6A19822; Fri, 14 May 2021 21:25:36 +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 14ELPaOd019353; Fri, 14 May 2021 21:25:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ELPabh019352; Fri, 14 May 2021 21:25:36 GMT (envelope-from git) Date: Fri, 14 May 2021 21:25:36 GMT Message-Id: <202105142125.14ELPabh019352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: 91f251b2ab3a - main - fstyp(8): define HAVE_ZFS macro when built with zfs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 91f251b2ab3ade5de703756873142bfae2573753 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 21:25:37 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=91f251b2ab3ade5de703756873142bfae2573753 commit 91f251b2ab3ade5de703756873142bfae2573753 Author: Robert Wing AuthorDate: 2021-05-12 02:57:24 +0000 Commit: Robert Wing CommitDate: 2021-05-14 21:00:24 +0000 fstyp(8): define HAVE_ZFS macro when built with zfs The HAVE_ZFS macro was dropped from the Makefile during the OpenZFS merge, bring it back. While here, drop unused WARNS setting. PR: 255616 Reported by: Michael Büker Submitted by: Michael Büker Fixes: 9e5787d2284e187abb5b654d924394a65772e004 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30221 --- usr.sbin/fstyp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/fstyp/Makefile b/usr.sbin/fstyp/Makefile index bfdc845bba4a..14b5d9dfd9c3 100644 --- a/usr.sbin/fstyp/Makefile +++ b/usr.sbin/fstyp/Makefile @@ -28,7 +28,7 @@ SUBDIR.${MK_TESTS}+= tests .if ${MK_ZFS} != "no" IGNORE_PRAGMA= YES -WARNS?= 0 +CFLAGS+= -DHAVE_ZFS CFLAGS.zfs.c+= -DIN_BASE CFLAGS.zfs.c+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS.zfs.c+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include From owner-dev-commits-src-all@freebsd.org Sat May 15 07:01:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9108363BE3E; Sat, 15 May 2021 07:01:07 +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 4FhxBW3Qk8z4qL7; Sat, 15 May 2021 07:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5E1E9211E3; Sat, 15 May 2021 07:01:07 +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 14F7171Y084360; Sat, 15 May 2021 07:01:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14F717lf084359; Sat, 15 May 2021 07:01:07 GMT (envelope-from git) Date: Sat, 15 May 2021 07:01:07 GMT Message-Id: <202105150701.14F717lf084359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: effc8e57fbf0 - main - libalias: Style cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: effc8e57fbf03d7f1423c662caf2b63f0d1d21a9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 07:01:07 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=effc8e57fbf03d7f1423c662caf2b63f0d1d21a9 commit effc8e57fbf03d7f1423c662caf2b63f0d1d21a9 Author: Lutz Donnerhacke AuthorDate: 2021-05-14 13:08:08 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-15 06:57:55 +0000 libalias: Style cleanup libalias is a convolut of various coding styles modified by a series of different editors enforcing interesting convetions on spacing and comments. This patch is a baseline to start with a perfomance rework of libalias. Upcoming patches should be focus on the code, not on the style. That's why most annoying style errors should be fixed beforehand. Reviewed by: hselasky Discussed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D30259 --- sys/netinet/libalias/alias.c | 379 ++++++++++++++++----------------- sys/netinet/libalias/alias.h | 44 ++-- sys/netinet/libalias/alias_db.c | 414 +++++++++++++++++------------------- sys/netinet/libalias/alias_dummy.c | 15 +- sys/netinet/libalias/alias_ftp.c | 68 +++--- sys/netinet/libalias/alias_irc.c | 52 +++-- sys/netinet/libalias/alias_local.h | 178 +++++++--------- sys/netinet/libalias/alias_mod.c | 2 - sys/netinet/libalias/alias_nbt.c | 253 ++++++++++------------ sys/netinet/libalias/alias_pptp.c | 84 ++++---- sys/netinet/libalias/alias_proxy.c | 271 ++++++++++++----------- sys/netinet/libalias/alias_sctp.c | 138 ++++++------ sys/netinet/libalias/alias_sctp.h | 26 +-- sys/netinet/libalias/alias_skinny.c | 30 ++- sys/netinet/libalias/alias_smedia.c | 91 ++++---- sys/netinet/libalias/alias_util.c | 30 +-- 16 files changed, 975 insertions(+), 1100 deletions(-) diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c index 900731fcbec6..cac19ab55d56 100644 --- a/sys/netinet/libalias/alias.c +++ b/sys/netinet/libalias/alias.c @@ -146,7 +146,7 @@ __FBSDID("$FreeBSD$"); #include "alias_mod.h" #endif -/* +/* * Define libalias SYSCTL Node */ #ifdef SYSCTL_NODE @@ -192,7 +192,6 @@ static void TcpMonitorOut(u_char, struct alias_link *); static void TcpMonitorIn(u_char th_flags, struct alias_link *lnk) { - switch (GetStateIn(lnk)) { case ALIAS_TCP_STATE_NOT_CONNECTED: if (th_flags & TH_RST) @@ -210,7 +209,6 @@ TcpMonitorIn(u_char th_flags, struct alias_link *lnk) static void TcpMonitorOut(u_char th_flags, struct alias_link *lnk) { - switch (GetStateOut(lnk)) { case ALIAS_TCP_STATE_NOT_CONNECTED: if (th_flags & TH_RST) @@ -285,21 +283,20 @@ static int UdpAliasOut(struct libalias *, struct ip *, int, int create); static int TcpAliasIn(struct libalias *, struct ip *); static int TcpAliasOut(struct libalias *, struct ip *, int, int create); -static int -IcmpAliasIn1(struct libalias *la, struct ip *pip) -{ - - LIBALIAS_LOCK_ASSERT(la); /* De-alias incoming echo and timestamp replies. Alias incoming echo and timestamp requests. */ +static int +IcmpAliasIn1(struct libalias *la, struct ip *pip) +{ + LIBALIAS_LOCK_ASSERT(la); struct alias_link *lnk; struct icmp *ic; ic = (struct icmp *)ip_next(pip); -/* Get source address from ICMP data field and restore original data */ + /* Get source address from ICMP data field and restore original data */ lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1); if (lnk != NULL) { u_short original_id; @@ -307,15 +304,15 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip) original_id = GetOriginalPort(lnk); -/* Adjust ICMP checksum */ + /* Adjust ICMP checksum */ accumulate = ic->icmp_id; accumulate -= original_id; ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); -/* Put original sequence number back in */ + /* Put original sequence number back in */ ic->icmp_id = original_id; -/* Put original address back into IP header */ + /* Put original address back into IP header */ { struct in_addr original_address; @@ -330,15 +327,14 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip) return (PKT_ALIAS_IGNORED); } -static int -IcmpAliasIn2(struct libalias *la, struct ip *pip) -{ - - LIBALIAS_LOCK_ASSERT(la); /* Alias incoming ICMP error messages containing IP header and first 64 bits of datagram. */ +static int +IcmpAliasIn2(struct libalias *la, struct ip *pip) +{ + LIBALIAS_LOCK_ASSERT(la); struct ip *ip; struct icmp *ic, *ic2; struct udphdr *ud; @@ -377,7 +373,7 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip) original_address = GetOriginalAddress(lnk); original_port = GetOriginalPort(lnk); -/* Adjust ICMP checksum */ + /* Adjust ICMP checksum */ accumulate = twowords(&ip->ip_src); accumulate -= twowords(&original_address); accumulate += ud->uh_sport; @@ -388,13 +384,14 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip) accumulate2 -= ip->ip_sum; ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); -/* Un-alias address in IP header */ + /* Un-alias address in IP header */ DifferentialChecksum(&pip->ip_sum, &original_address, &pip->ip_dst, 2); pip->ip_dst = original_address; -/* Un-alias address and port number of original IP packet -fragment contained in ICMP data section */ + /* Un-alias address and port number of + * original IP packet fragment contained + * in ICMP data section */ ip->ip_src = original_address; ud->uh_sport = original_port; } else if (ip->ip_p == IPPROTO_ICMP) { @@ -405,7 +402,7 @@ fragment contained in ICMP data section */ original_address = GetOriginalAddress(lnk); original_id = GetOriginalPort(lnk); -/* Adjust ICMP checksum */ + /* Adjust ICMP checksum */ accumulate = twowords(&ip->ip_src); accumulate -= twowords(&original_address); accumulate += ic2->icmp_id; @@ -416,13 +413,13 @@ fragment contained in ICMP data section */ accumulate2 -= ip->ip_sum; ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); -/* Un-alias address in IP header */ + /* Un-alias address in IP header */ DifferentialChecksum(&pip->ip_sum, &original_address, &pip->ip_dst, 2); pip->ip_dst = original_address; -/* Un-alias address of original IP packet and sequence number of - embedded ICMP datagram */ + /* Un-alias address of original IP packet and + * sequence number of embedded ICMP datagram */ ip->ip_src = original_address; ic2->icmp_id = original_id; } @@ -444,7 +441,7 @@ IcmpAliasIn(struct libalias *la, struct ip *pip) if (dlen < ICMP_MINLEN) return (PKT_ALIAS_IGNORED); -/* Return if proxy-only mode is enabled */ + /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); @@ -475,20 +472,20 @@ IcmpAliasIn(struct libalias *la, struct ip *pip) return (iresult); } -static int -IcmpAliasOut1(struct libalias *la, struct ip *pip, int create) -{ /* Alias outgoing echo and timestamp requests. De-alias outgoing echo and timestamp replies. */ +static int +IcmpAliasOut1(struct libalias *la, struct ip *pip, int create) +{ struct alias_link *lnk; struct icmp *ic; LIBALIAS_LOCK_ASSERT(la); ic = (struct icmp *)ip_next(pip); -/* Save overwritten data for when echo packet returns */ + /* Save overwritten data for when echo packet returns */ lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, create); if (lnk != NULL) { u_short alias_id; @@ -496,15 +493,15 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip, int create) alias_id = GetAliasPort(lnk); -/* Since data field is being modified, adjust ICMP checksum */ + /* Since data field is being modified, adjust ICMP checksum */ accumulate = ic->icmp_id; accumulate -= alias_id; ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); -/* Alias sequence number */ + /* Alias sequence number */ ic->icmp_id = alias_id; -/* Change source address */ + /* Change source address */ { struct in_addr alias_address; @@ -519,13 +516,13 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip, int create) return (PKT_ALIAS_IGNORED); } -static int -IcmpAliasOut2(struct libalias *la, struct ip *pip) -{ /* Alias outgoing ICMP error messages containing IP header and first 64 bits of datagram. */ +static int +IcmpAliasOut2(struct libalias *la, struct ip *pip) +{ struct ip *ip; struct icmp *ic, *ic2; struct udphdr *ud; @@ -565,24 +562,24 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip) alias_address = GetAliasAddress(lnk); alias_port = GetAliasPort(lnk); -/* Adjust ICMP checksum */ + /* Adjust ICMP checksum */ accumulate = twowords(&ip->ip_dst); accumulate -= twowords(&alias_address); accumulate += ud->uh_dport; accumulate -= alias_port; ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); -/* - * Alias address in IP header if it comes from the host - * the original TCP/UDP packet was destined for. - */ + /* + * Alias address in IP header if it comes from the host + * the original TCP/UDP packet was destined for. + */ if (pip->ip_src.s_addr == ip->ip_dst.s_addr) { DifferentialChecksum(&pip->ip_sum, &alias_address, &pip->ip_src, 2); pip->ip_src = alias_address; } -/* Alias address and port number of original IP packet -fragment contained in ICMP data section */ + /* Alias address and port number of original IP packet + * fragment contained in ICMP data section */ ip->ip_dst = alias_address; ud->uh_dport = alias_port; } else if (ip->ip_p == IPPROTO_ICMP) { @@ -593,24 +590,24 @@ fragment contained in ICMP data section */ alias_address = GetAliasAddress(lnk); alias_id = GetAliasPort(lnk); -/* Adjust ICMP checksum */ + /* Adjust ICMP checksum */ accumulate = twowords(&ip->ip_dst); accumulate -= twowords(&alias_address); accumulate += ic2->icmp_id; accumulate -= alias_id; ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); -/* - * Alias address in IP header if it comes from the host - * the original ICMP message was destined for. - */ + /* + * Alias address in IP header if it comes from the host + * the original ICMP message was destined for. + */ if (pip->ip_src.s_addr == ip->ip_dst.s_addr) { DifferentialChecksum(&pip->ip_sum, &alias_address, &pip->ip_src, 2); pip->ip_src = alias_address; } -/* Alias address of original IP packet and sequence number of - embedded ICMP datagram */ + /* Alias address of original IP packet and + * sequence number of embedded ICMP datagram */ ip->ip_dst = alias_address; ic2->icmp_id = alias_id; } @@ -628,7 +625,7 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create) LIBALIAS_LOCK_ASSERT(la); (void)create; -/* Return if proxy-only mode is enabled */ + /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); @@ -655,20 +652,20 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create) return (iresult); } -static int -ProtoAliasIn(struct libalias *la, struct in_addr ip_src, - struct ip *pip, u_char ip_p, u_short *ip_sum) -{ /* Handle incoming IP packets. The only thing which is done in this case is to alias the dest IP address of the packet to our inside machine. */ +static int +ProtoAliasIn(struct libalias *la, struct in_addr ip_src, + struct ip *pip, u_char ip_p, u_short *ip_sum) +{ struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); -/* Return if proxy-only mode is enabled */ + /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); @@ -678,7 +675,7 @@ ProtoAliasIn(struct libalias *la, struct in_addr ip_src, original_address = GetOriginalAddress(lnk); -/* Restore original IP address */ + /* Restore original IP address */ DifferentialChecksum(ip_sum, &original_address, &pip->ip_dst, 2); pip->ip_dst = original_address; @@ -688,20 +685,20 @@ ProtoAliasIn(struct libalias *la, struct in_addr ip_src, return (PKT_ALIAS_IGNORED); } -static int -ProtoAliasOut(struct libalias *la, struct ip *pip, - struct in_addr ip_dst, u_char ip_p, u_short *ip_sum, int create) -{ /* Handle outgoing IP packets. The only thing which is done in this case is to alias the source IP address of the packet. */ +static int +ProtoAliasOut(struct libalias *la, struct ip *pip, + struct in_addr ip_dst, u_char ip_p, u_short *ip_sum, int create) +{ struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); -/* Return if proxy-only mode is enabled */ + /* Return if proxy-only mode is enabled */ if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) return (PKT_ALIAS_OK); @@ -714,7 +711,7 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, alias_address = GetAliasAddress(lnk); -/* Change source address */ + /* Change source address */ DifferentialChecksum(ip_sum, &alias_address, &pip->ip_src, 2); pip->ip_src = alias_address; @@ -753,8 +750,8 @@ UdpAliasIn(struct libalias *la, struct ip *pip) int accumulate; int error; struct alias_data ad = { - .lnk = lnk, - .oaddr = &original_address, + .lnk = lnk, + .oaddr = &original_address, .aaddr = &alias_address, .aport = &alias_port, .sport = &ud->uh_sport, @@ -769,46 +766,48 @@ UdpAliasIn(struct libalias *la, struct ip *pip) ud->uh_dport = GetOriginalPort(lnk); proxy_port = GetProxyPort(lnk); - /* Walk out chain. */ + /* Walk out chain. */ error = find_handler(IN, UDP, la, pip, &ad); /* If we cannot figure out the packet, ignore it. */ if (error < 0) return (PKT_ALIAS_IGNORED); -/* If UDP checksum is not zero, then adjust since destination port */ -/* is being unaliased and destination address is being altered. */ + /* If UDP checksum is not zero, then adjust since + * destination port is being unaliased and + * destination address is being altered. */ if (ud->uh_sum != 0) { accumulate = alias_port; accumulate -= ud->uh_dport; accumulate += twowords(&alias_address); accumulate -= twowords(&original_address); -/* If this is a proxy packet, modify checksum because of source change.*/ - if (proxy_port != 0) { - accumulate += ud->uh_sport; - accumulate -= proxy_port; - } + /* If this is a proxy packet, modify checksum + * because of source change.*/ + if (proxy_port != 0) { + accumulate += ud->uh_sport; + accumulate -= proxy_port; + } - if (proxy_address.s_addr != 0) { + if (proxy_address.s_addr != 0) { accumulate += twowords(&pip->ip_src); accumulate -= twowords(&proxy_address); - } + } ADJUST_CHECKSUM(accumulate, ud->uh_sum); } -/* XXX: Could the two if's below be concatenated to one ? */ -/* Restore source port and/or address in case of proxying*/ - if (proxy_port != 0) - ud->uh_sport = proxy_port; + /* XXX: Could the two if's below be concatenated to one ? */ + /* Restore source port and/or address in case of proxying*/ + if (proxy_port != 0) + ud->uh_sport = proxy_port; - if (proxy_address.s_addr != 0) { - DifferentialChecksum(&pip->ip_sum, - &proxy_address, &pip->ip_src, 2); - pip->ip_src = proxy_address; - } + if (proxy_address.s_addr != 0) { + DifferentialChecksum(&pip->ip_sum, + &proxy_address, &pip->ip_src, 2); + pip->ip_src = proxy_address; + } -/* Restore original IP address */ + /* Restore original IP address */ DifferentialChecksum(&pip->ip_sum, &original_address, &pip->ip_dst, 2); pip->ip_dst = original_address; @@ -833,7 +832,7 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) LIBALIAS_LOCK_ASSERT(la); -/* Return if proxy-only mode is enabled and not proxyrule found.*/ + /* Return if proxy-only mode is enabled and not proxyrule found.*/ dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); if (dlen < sizeof(struct udphdr)) return (PKT_ALIAS_IGNORED); @@ -842,34 +841,33 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) if (dlen < ntohs(ud->uh_ulen)) return (PKT_ALIAS_IGNORED); - proxy_type = ProxyCheck(la, &proxy_server_address, - &proxy_server_port, pip->ip_src, pip->ip_dst, - ud->uh_dport, pip->ip_p); + proxy_type = ProxyCheck(la, &proxy_server_address, &proxy_server_port, + pip->ip_src, pip->ip_dst, ud->uh_dport, pip->ip_p); if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)) return (PKT_ALIAS_OK); -/* If this is a transparent proxy, save original destination, - * then alter the destination and adjust checksums */ + /* If this is a transparent proxy, save original destination, + * then alter the destination and adjust checksums */ dest_port = ud->uh_dport; dest_address = pip->ip_dst; if (proxy_type != 0) { - int accumulate; + int accumulate; accumulate = twowords(&pip->ip_dst); accumulate -= twowords(&proxy_server_address); - ADJUST_CHECKSUM(accumulate, pip->ip_sum); + ADJUST_CHECKSUM(accumulate, pip->ip_sum); if (ud->uh_sum != 0) { accumulate = twowords(&pip->ip_dst); accumulate -= twowords(&proxy_server_address); - accumulate += ud->uh_dport; - accumulate -= proxy_server_port; - ADJUST_CHECKSUM(accumulate, ud->uh_sum); + accumulate += ud->uh_dport; + accumulate -= proxy_server_port; + ADJUST_CHECKSUM(accumulate, ud->uh_sum); } - pip->ip_dst = proxy_server_address; - ud->uh_dport = proxy_server_port; + pip->ip_dst = proxy_server_address; + ud->uh_dport = proxy_server_port; } lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst, ud->uh_sport, ud->uh_dport, @@ -878,7 +876,7 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) u_short alias_port; struct in_addr alias_address; struct alias_data ad = { - .lnk = lnk, + .lnk = lnk, .oaddr = NULL, .aaddr = &alias_address, .aport = &alias_port, @@ -887,24 +885,24 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) .maxpktsize = 0 }; -/* Save original destination address, if this is a proxy packet. - * Also modify packet to include destination encoding. This may - * change the size of IP header. */ + /* Save original destination address, if this is a proxy packet. + * Also modify packet to include destination encoding. This may + * change the size of IP header. */ if (proxy_type != 0) { - SetProxyPort(lnk, dest_port); - SetProxyAddress(lnk, dest_address); - ProxyModify(la, lnk, pip, maxpacketsize, proxy_type); - ud = (struct udphdr *)ip_next(pip); - } + SetProxyPort(lnk, dest_port); + SetProxyAddress(lnk, dest_address); + ProxyModify(la, lnk, pip, maxpacketsize, proxy_type); + ud = (struct udphdr *)ip_next(pip); + } alias_address = GetAliasAddress(lnk); alias_port = GetAliasPort(lnk); - /* Walk out chain. */ + /* Walk out chain. */ error = find_handler(OUT, UDP, la, pip, &ad); -/* If UDP checksum is not zero, adjust since source port is */ -/* being aliased and source address is being altered */ + /* If UDP checksum is not zero, adjust since source port is */ + /* being aliased and source address is being altered */ if (ud->uh_sum != 0) { int accumulate; @@ -914,10 +912,10 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) accumulate -= twowords(&alias_address); ADJUST_CHECKSUM(accumulate, ud->uh_sum); } -/* Put alias port in UDP header */ + /* Put alias port in UDP header */ ud->uh_sport = alias_port; -/* Change source address */ + /* Change source address */ DifferentialChecksum(&pip->ip_sum, &alias_address, &pip->ip_src, 2); pip->ip_src = alias_address; @@ -953,14 +951,14 @@ TcpAliasIn(struct libalias *la, struct ip *pip) u_short proxy_port; int accumulate, error; - /* - * The init of MANY vars is a bit below, but aliashandlepptpin + /* + * The init of MANY vars is a bit below, but aliashandlepptpin * seems to need the destination port that came within the * packet and not the original one looks below [*]. */ struct alias_data ad = { - .lnk = lnk, + .lnk = lnk, .oaddr = NULL, .aaddr = NULL, .aport = NULL, @@ -969,7 +967,7 @@ TcpAliasIn(struct libalias *la, struct ip *pip) .maxpktsize = 0 }; - /* Walk out chain. */ + /* Walk out chain. */ error = find_handler(IN, TCP, la, pip, &ad); alias_address = GetAliasAddress(lnk); @@ -979,8 +977,8 @@ TcpAliasIn(struct libalias *la, struct ip *pip) tc->th_dport = GetOriginalPort(lnk); proxy_port = GetProxyPort(lnk); - /* - * Look above, if anyone is going to add find_handler AFTER + /* + * Look above, if anyone is going to add find_handler AFTER * this aliashandlepptpin/point, please redo alias_data too. * Uncommenting the piece here below should be enough. */ @@ -994,22 +992,22 @@ TcpAliasIn(struct libalias *la, struct ip *pip) .dport = &ud->uh_dport, .maxpktsize = 0 }; - + /* Walk out chain. */ error = find_handler(la, pip, &ad); if (error == EHDNOF) printf("Protocol handler not found\n"); #endif -/* Adjust TCP checksum since destination port is being unaliased */ -/* and destination port is being altered. */ + /* Adjust TCP checksum since destination port is being + * unaliased and destination port is being altered. */ accumulate = alias_port; accumulate -= tc->th_dport; accumulate += twowords(&alias_address); accumulate -= twowords(&original_address); -/* If this is a proxy, then modify the TCP source port and - checksum accumulation */ + /* If this is a proxy, then modify the TCP source port + * and checksum accumulation */ if (proxy_port != 0) { accumulate += tc->th_sport; tc->th_sport = proxy_port; @@ -1017,7 +1015,7 @@ TcpAliasIn(struct libalias *la, struct ip *pip) accumulate += twowords(&pip->ip_src); accumulate -= twowords(&proxy_address); } -/* See if ACK number needs to be modified */ + /* See if ACK number needs to be modified */ if (GetAckModified(lnk) == 1) { int delta; @@ -1031,13 +1029,13 @@ TcpAliasIn(struct libalias *la, struct ip *pip) } ADJUST_CHECKSUM(accumulate, tc->th_sum); -/* Restore original IP address */ + /* Restore original IP address */ accumulate = twowords(&pip->ip_dst); pip->ip_dst = original_address; accumulate -= twowords(&pip->ip_dst); -/* If this is a transparent proxy packet, then modify the source - address */ + /* If this is a transparent proxy packet, + * then modify the source address */ if (proxy_address.s_addr != 0) { accumulate += twowords(&pip->ip_src); pip->ip_src = proxy_address; @@ -1045,7 +1043,7 @@ TcpAliasIn(struct libalias *la, struct ip *pip) } ADJUST_CHECKSUM(accumulate, pip->ip_sum); -/* Monitor TCP connection state */ + /* Monitor TCP connection state */ tc = (struct tcphdr *)ip_next(pip); TcpMonitorIn(tc->th_flags, lnk); @@ -1074,8 +1072,8 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) tc = (struct tcphdr *)ip_next(pip); if (create) - proxy_type = ProxyCheck(la, &proxy_server_address, - &proxy_server_port, pip->ip_src, pip->ip_dst, + proxy_type = ProxyCheck(la, &proxy_server_address, + &proxy_server_port, pip->ip_src, pip->ip_dst, tc->th_dport, pip->ip_p); else proxy_type = 0; @@ -1083,8 +1081,8 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)) return (PKT_ALIAS_OK); -/* If this is a transparent proxy, save original destination, - then alter the destination and adjust checksums */ + /* If this is a transparent proxy, save original destination, + * then alter the destination and adjust checksums */ dest_port = tc->th_dport; dest_address = pip->ip_dst; if (proxy_type != 0) { @@ -1112,7 +1110,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) struct in_addr alias_address; int accumulate; struct alias_data ad = { - .lnk = lnk, + .lnk = lnk, .oaddr = NULL, .aaddr = &alias_address, .aport = &alias_port, @@ -1121,38 +1119,38 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) .maxpktsize = maxpacketsize }; -/* Save original destination address, if this is a proxy packet. - Also modify packet to include destination encoding. This may - change the size of IP header. */ + /* Save original destination address, if this is a proxy packet. + * Also modify packet to include destination + * encoding. This may change the size of IP header. */ if (proxy_type != 0) { SetProxyPort(lnk, dest_port); SetProxyAddress(lnk, dest_address); ProxyModify(la, lnk, pip, maxpacketsize, proxy_type); tc = (struct tcphdr *)ip_next(pip); } -/* Get alias address and port */ + /* Get alias address and port */ alias_port = GetAliasPort(lnk); alias_address = GetAliasAddress(lnk); -/* Monitor TCP connection state */ + /* Monitor TCP connection state */ tc = (struct tcphdr *)ip_next(pip); TcpMonitorOut(tc->th_flags, lnk); - - /* Walk out chain. */ + + /* Walk out chain. */ error = find_handler(OUT, TCP, la, pip, &ad); -/* Adjust TCP checksum since source port is being aliased */ -/* and source address is being altered */ + /* Adjust TCP checksum since source port is being aliased + * and source address is being altered */ accumulate = tc->th_sport; tc->th_sport = alias_port; accumulate -= tc->th_sport; accumulate += twowords(&pip->ip_src); accumulate -= twowords(&alias_address); -/* Modify sequence number if necessary */ + /* Modify sequence number if necessary */ if (GetAckModified(lnk) == 1) { int delta; - + tc = (struct tcphdr *)ip_next(pip); delta = GetDeltaSeqOut(tc->th_seq, lnk); if (delta != 0) { @@ -1163,7 +1161,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) } ADJUST_CHECKSUM(accumulate, tc->th_sum); -/* Change source address */ + /* Change source address */ accumulate = twowords(&pip->ip_src); pip->ip_src = alias_address; accumulate -= twowords(&pip->ip_src); @@ -1259,7 +1257,7 @@ LibAliasSaveFragment(struct libalias *la, void *ptr) return (iresult); } -void * +void * LibAliasGetFragment(struct libalias *la, void *ptr) { struct alias_link *lnk; @@ -1273,7 +1271,7 @@ LibAliasGetFragment(struct libalias *la, void *ptr) GetFragmentPtr(lnk, &fptr); SetFragmentPtr(lnk, NULL); SetExpire(lnk, 0); /* Deletes link */ - } else + } else fptr = NULL; LIBALIAS_UNLOCK(la); @@ -1281,11 +1279,9 @@ LibAliasGetFragment(struct libalias *la, void *ptr) } void -LibAliasFragmentIn(struct libalias *la, void *ptr, /* Points to correctly - * de-aliased header - * fragment */ - void *ptr_fragment /* Points to fragment which must be - * de-aliased */ +LibAliasFragmentIn(struct libalias *la, + void *ptr, /* Points to correctly de-aliased header fragment */ + void *ptr_fragment /* fragment which must be de-aliased */ ) { struct ip *pip; @@ -1305,10 +1301,10 @@ LibAliasFragmentIn(struct libalias *la, void *ptr, /* Points to correctly /* Local prototypes */ static int LibAliasOutLocked(struct libalias *la, struct ip *pip, - int maxpacketsize, int create); + int maxpacketsize, int create); static int LibAliasInLocked(struct libalias *la, struct ip *pip, - int maxpacketsize); + int maxpacketsize); int LibAliasIn(struct libalias *la, void *ptr, int maxpacketsize) @@ -1340,7 +1336,7 @@ LibAliasInLocked(struct libalias *la, struct ip *pip, int maxpacketsize) /* Defense against mangled packets */ if (ntohs(pip->ip_len) > maxpacketsize || (pip->ip_hl << 2) > maxpacketsize) { - iresult = PKT_ALIAS_IGNORED; + iresult = PKT_ALIAS_IGNORED; goto getout; } @@ -1358,30 +1354,30 @@ LibAliasInLocked(struct libalias *la, struct ip *pip, int maxpacketsize) break; #ifdef _KERNEL case IPPROTO_SCTP: - iresult = SctpAlias(la, pip, SN_TO_LOCAL); + iresult = SctpAlias(la, pip, SN_TO_LOCAL); break; #endif - case IPPROTO_GRE: { + case IPPROTO_GRE: { int error; struct alias_data ad = { - .lnk = NULL, - .oaddr = NULL, + .lnk = NULL, + .oaddr = NULL, .aaddr = NULL, .aport = NULL, .sport = NULL, .dport = NULL, - .maxpktsize = 0 + .maxpktsize = 0 }; - - /* Walk out chain. */ + + /* Walk out chain. */ error = find_handler(IN, IP, la, pip, &ad); - if (error == 0) + if (error == 0) iresult = PKT_ALIAS_OK; else iresult = ProtoAliasIn(la, pip->ip_src, pip, pip->ip_p, &pip->ip_sum); + break; } - break; default: iresult = ProtoAliasIn(la, pip->ip_src, pip, pip->ip_p, &pip->ip_sum); @@ -1449,10 +1445,10 @@ LibAliasOutTry(struct libalias *la, void *ptr, int maxpacketsize, int create) } static int -LibAliasOutLocked(struct libalias *la, struct ip *pip, /* valid IP packet */ - int maxpacketsize, /* How much the packet data may grow (FTP - * and IRC inline changes) */ - int create /* Create new entries ? */ +LibAliasOutLocked(struct libalias *la, + struct ip *pip, /* valid IP packet */ + int maxpacketsize, /* How much the packet data may grow (FTP and IRC inline changes) */ + int create /* Create new entries ? */ ) { int iresult; @@ -1512,29 +1508,29 @@ LibAliasOutLocked(struct libalias *la, struct ip *pip, /* valid IP packet */ break; #ifdef _KERNEL case IPPROTO_SCTP: - iresult = SctpAlias(la, pip, SN_TO_GLOBAL); + iresult = SctpAlias(la, pip, SN_TO_GLOBAL); break; #endif case IPPROTO_GRE: { int error; struct alias_data ad = { - .lnk = NULL, - .oaddr = NULL, + .lnk = NULL, + .oaddr = NULL, .aaddr = NULL, .aport = NULL, .sport = NULL, .dport = NULL, - .maxpktsize = 0 + .maxpktsize = 0 }; - /* Walk out chain. */ + /* Walk out chain. */ error = find_handler(OUT, IP, la, pip, &ad); if (error == 0) - iresult = PKT_ALIAS_OK; - else + iresult = PKT_ALIAS_OK; + else iresult = ProtoAliasOut(la, pip, pip->ip_dst, pip->ip_p, &pip->ip_sum, create); + break; } - break; default: iresult = ProtoAliasOut(la, pip, pip->ip_dst, pip->ip_p, &pip->ip_sum, create); @@ -1550,8 +1546,9 @@ getout: } int -LibAliasUnaliasOut(struct libalias *la, void *ptr, /* valid IP packet */ - int maxpacketsize /* for error checking */ +LibAliasUnaliasOut(struct libalias *la, + void *ptr, /* valid IP packet */ + int maxpacketsize /* for error checking */ ) { struct ip *pip; @@ -1623,7 +1620,6 @@ LibAliasUnaliasOut(struct libalias *la, void *ptr, /* valid IP packet */ tc->th_sport = original_port; iresult = PKT_ALIAS_OK; - } else if (pip->ip_p == IPPROTO_ICMP) { int accumulate; struct in_addr original_address; @@ -1653,7 +1649,6 @@ LibAliasUnaliasOut(struct libalias *la, void *ptr, /* valid IP packet */ getout: LIBALIAS_UNLOCK(la); return (iresult); - } #ifndef _KERNEL @@ -1673,8 +1668,8 @@ LibAliasRefreshModules(void) for (;;) { fgets(buf, 256, fd); - if (feof(fd)) - break; + if (feof(fd)) + break; len = strlen(buf); if (len > 1) { for (i = 0; i < len; i++) @@ -1696,20 +1691,20 @@ LibAliasLoadModule(char *path) struct dll *t; void *handle; struct proto_handler *m; - const char *error; + const char *error; moduledata_t *p; - handle = dlopen (path, RTLD_LAZY); - if (!handle) { + handle = dlopen (path, RTLD_LAZY); *** 4297 LINES SKIPPED *** From owner-dev-commits-src-all@freebsd.org Sat May 15 07:08:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A471C63C0B7; Sat, 15 May 2021 07:08:54 +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 4FhxMV4C3Nz4qwN; Sat, 15 May 2021 07:08:54 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 789372131E; Sat, 15 May 2021 07:08:54 +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 14F78sIO086292; Sat, 15 May 2021 07:08:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14F78s3J086291; Sat, 15 May 2021 07:08:54 GMT (envelope-from git) Date: Sat, 15 May 2021 07:08:54 GMT Message-Id: <202105150708.14F78s3J086291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 189f8eea138a - main - libalias: replace placeholder with static constant MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 189f8eea138a78b09c9f19114b1362b0df1cf87d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 07:08:54 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=189f8eea138a78b09c9f19114b1362b0df1cf87d commit 189f8eea138a78b09c9f19114b1362b0df1cf87d Author: Lutz Donnerhacke AuthorDate: 2021-05-13 21:47:57 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-15 07:05:30 +0000 libalias: replace placeholder with static constant The field nullAddress in struct libalias is never set and never used. It exists as a placeholder for an unused argument only. Reviewed by: hselasky MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D30253 --- sys/netinet/libalias/alias_db.c | 24 ++++++++++++++---------- sys/netinet/libalias/alias_local.h | 2 -- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index cd29c16ac945..518f221c63f9 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -224,6 +224,10 @@ static LIST_HEAD(, libalias) instancehead = LIST_HEAD_INITIALIZER(instancehead); #define NO_DEST_PORT 1 #define NO_SRC_PORT 1 +/* Dummy address used for FindLinkIn/Out() and AddLink(). + The value of this variable is never used. */ +static struct in_addr const NO_ADDR; + /* Data Structures The fundamental data structure used in this program is @@ -1111,12 +1115,12 @@ _FindLinkOut(struct libalias *la, struct in_addr src_addr, lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 0); if (lnk == NULL) - lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, + lnk = _FindLinkOut(la, src_addr, NO_ADDR, src_port, dst_port, link_type, 0); } if (lnk == NULL && (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { - lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, + lnk = _FindLinkOut(la, src_addr, NO_ADDR, src_port, 0, link_type, 0); } if (lnk != NULL) { @@ -1152,7 +1156,7 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && src_addr.s_addr == la->aliasAddress.s_addr) { - lnk = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, NO_ADDR, dst_addr, src_port, dst_port, link_type, replace_partial_links); } } @@ -1294,7 +1298,7 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && alias_addr.s_addr == la->aliasAddress.s_addr) { - lnk = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, NO_ADDR, dst_port, alias_port, link_type, replace_partial_links); } } @@ -1376,7 +1380,7 @@ FindFragmentIn1(struct libalias *la, struct in_addr dst_addr, LINK_FRAGMENT_ID, 0); if (lnk == NULL) { - lnk = AddLink(la, la->nullAddress, dst_addr, alias_addr, + lnk = AddLink(la, NO_ADDR, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID); } @@ -1399,7 +1403,7 @@ AddFragmentPtrLink(struct libalias *la, struct in_addr dst_addr, u_short ip_id) { LIBALIAS_LOCK_ASSERT(la); - return AddLink(la, la->nullAddress, dst_addr, la->nullAddress, + return AddLink(la, NO_ADDR, dst_addr, NO_ADDR, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_PTR); } @@ -1409,7 +1413,7 @@ FindFragmentPtr(struct libalias *la, struct in_addr dst_addr, u_short ip_id) { LIBALIAS_LOCK_ASSERT(la); - return FindLinkIn(la, dst_addr, la->nullAddress, + return FindLinkIn(la, dst_addr, NO_ADDR, NO_DEST_PORT, ip_id, LINK_FRAGMENT_PTR, 0); } @@ -1669,7 +1673,7 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); - lnk = FindLinkIn(la, la->nullAddress, alias_addr, + lnk = FindLinkIn(la, NO_ADDR, alias_addr, 0, 0, LINK_ADDR, 0); if (lnk == NULL) { la->newDefaultLink = 1; @@ -1701,7 +1705,7 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr) struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); - lnk = FindLinkOut(la, original_addr, la->nullAddress, + lnk = FindLinkOut(la, original_addr, NO_ADDR, 0, 0, LINK_ADDR, 0); if (lnk == NULL) { return (la->aliasAddress.s_addr != INADDR_ANY) ? @@ -2317,7 +2321,7 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, struct alias_link *lnk; LIBALIAS_LOCK(la); - lnk = AddLink(la, src_addr, la->nullAddress, alias_addr, + lnk = AddLink(la, src_addr, NO_ADDR, alias_addr, 0, 0, 0, LINK_ADDR); diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h index e6374a72ef75..63bfd857f14f 100644 --- a/sys/netinet/libalias/alias_local.h +++ b/sys/netinet/libalias/alias_local.h @@ -89,8 +89,6 @@ struct libalias { /* IP address incoming packets are sent to * if no aliasing link already exists */ struct in_addr targetAddress; - /* Used as a dummy parameter for some function calls */ - struct in_addr nullAddress; /* Lookup table of pointers to chains of link records. * Each link record is doubly indexed into input and * output lookup tables. */ From owner-dev-commits-src-all@freebsd.org Sat May 15 11:05:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E94C5642410; Sat, 15 May 2021 11:05:49 +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 4Fj2cs6Fw0z3rsW; Sat, 15 May 2021 11:05:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 BF53524652; Sat, 15 May 2021 11:05:49 +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 14FB5nec005916; Sat, 15 May 2021 11:05:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14FB5nv7005915; Sat, 15 May 2021 11:05:49 GMT (envelope-from git) Date: Sat, 15 May 2021 11:05:49 GMT Message-Id: <202105151105.14FB5nv7005915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 3394d4239b85 - main - cam: allocate CCBs from UMA for SCSI and ATA IO MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3394d4239b85b5577845d9e6de4e97b18d3dba58 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 11:05:50 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=3394d4239b85b5577845d9e6de4e97b18d3dba58 commit 3394d4239b85b5577845d9e6de4e97b18d3dba58 Author: Edward Tomasz Napierala AuthorDate: 2021-05-15 10:17:22 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-15 11:03:49 +0000 cam: allocate CCBs from UMA for SCSI and ATA IO This patch makes it possible for CAM to use small CCBs allocated from an periph-specific UMA zone instead of the usual, huge ones. The end result is that CCBs issued via da(4) take 544B (size of ccb_scsiio) instead of the usual 2kB (size of 'union ccb', ~1.5kB, rounded up by malloc(9)). For ATA it's 272B. We waste less memory, we avoid zeroing the unused 1kB, and it should be easier to allocate those CCBs in low memory conditions. It should also be possible to use uma_zone_reserve(9) to improve behaviour in low memory conditions even further. Note that this does not change the size, or the layout, of CCBs as such. CCBs get allocated in various different ways, in particular on the stack, and I don't want to redo all that. Instead, this provides an opt-in mechanism for the periph to declare "my start() callback is fine with receiving a CCB allocated from this UMA zone". In other words, most of the code works exactly as it used to; the change only happens to IOs issued by xpt_run_allockq(), which is - conveniently - pretty much all that matters for performance. The reason for doing it this way is that it's pretty small, localized change, and can be implemented gradually and iteratively: take a periph, make sure its start() callback only casts the CCBs it takes to a particular type of CCB, for example ccb_scsiio, and that it only casts CCBs returned by cam_periph_getccb() to that type, then add UMA zone for that size, and declare it safe to XPT. This is disabled by default. Set 'kern.cam.ada.enable_uma_ccbs=1' and 'kern.cam.da.enable_uma_ccbs=1' tunables to enable it. Testing is welcome; I will flip the default to enable in two weeks from now. Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D28674 --- sys/cam/ata/ata_da.c | 18 ++++++++++++++++++ sys/cam/ata/ata_xpt.c | 7 +++++++ sys/cam/cam_ccb.h | 14 +++++++++++++- sys/cam/cam_periph.h | 3 +++ sys/cam/cam_xpt.c | 32 +++++++++++++++++++++++++++++--- sys/cam/scsi/scsi_da.c | 18 ++++++++++++++++++ sys/cam/scsi/scsi_xpt.c | 7 +++++++ 7 files changed, 95 insertions(+), 4 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index c29235e64e81..a8b67b2254a6 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -297,6 +297,8 @@ struct ada_softc { char announce_buffer[ADA_ANNOUNCE_SZ]; }; +static uma_zone_t ada_ccb_zone; + struct ada_quirk_entry { struct scsi_inquiry_pattern inq_pat; ada_quirks quirks; @@ -902,6 +904,7 @@ static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND; static int ada_read_ahead = ADA_DEFAULT_READ_AHEAD; static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; static int ada_enable_biospeedup = 1; +static int ada_enable_uma_ccbs = 0; static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "CAM Direct Access Disk driver"); @@ -921,6 +924,8 @@ SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, &ada_write_cache, 0, "Enable disk write cache"); SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, &ada_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN, + &ada_enable_uma_ccbs, 0, "Use UMA for CCBs"); /* * ADA_ORDEREDTAG_INTERVAL determines how often, relative @@ -1178,6 +1183,10 @@ adainit(void) { cam_status status; + ada_ccb_zone = uma_zcreate("ada_ccb", + sizeof(struct ccb_ataio), NULL, NULL, NULL, NULL, + UMA_ALIGN_PTR, 0); + /* * Install a global async callback. This callback will * receive async callbacks like "new device found". @@ -1855,6 +1864,15 @@ adaregister(struct cam_periph *periph, void *arg) "kern.cam.ada.%d.write_cache", periph->unit_number); TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); + /* + * Let XPT know we can use UMA-allocated CCBs. + */ + if (ada_enable_uma_ccbs) { + KASSERT(ada_ccb_zone != NULL, + ("%s: NULL ada_ccb_zone", __func__)); + periph->ccb_zone = ada_ccb_zone; + } + /* * Set support flags based on the Identify data and quirks. */ diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c index 0f94e556745a..c13c7b493c78 100644 --- a/sys/cam/ata/ata_xpt.c +++ b/sys/cam/ata/ata_xpt.c @@ -1795,6 +1795,13 @@ static void ata_action(union ccb *start_ccb) { + if (start_ccb->ccb_h.func_code != XPT_ATA_IO) { + KASSERT((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) == 0, + ("%s: ccb %p, func_code %#x should not be allocated " + "from UMA zone\n", + __func__, start_ccb, start_ccb->ccb_h.func_code)); + } + switch (start_ccb->ccb_h.func_code) { case XPT_SET_TRAN_SETTINGS: { diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index 221b24a7c187..2545e40e192d 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -58,6 +58,12 @@ /* Struct definitions for CAM control blocks */ /* Common CCB header */ + +/* CCB memory allocation flags */ +typedef enum { + CAM_CCB_FROM_UMA = 0x00000001,/* CCB from a periph UMA zone */ +} ccb_alloc_flags; + /* CAM CCB flags */ typedef enum { CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */ @@ -341,7 +347,13 @@ struct ccb_hdr { camq_entry xpt_links; /* For chaining in the XPT layer */ camq_entry sim_links; /* For chaining in the SIM layer */ camq_entry periph_links; /* For chaining in the type driver */ - u_int32_t retry_count; +#if BYTE_ORDER == LITTLE_ENDIAN + u_int16_t retry_count; + u_int16_t alloc_flags; /* ccb_alloc_flags */ +#else + u_int16_t alloc_flags; /* ccb_alloc_flags */ + u_int16_t retry_count; +#endif void (*cbfcnp)(struct cam_periph *, union ccb *); /* Callback on completion function */ xpt_opcode func_code; /* XPT function code */ diff --git a/sys/cam/cam_periph.h b/sys/cam/cam_periph.h index 15a239decf0a..9c323394797c 100644 --- a/sys/cam/cam_periph.h +++ b/sys/cam/cam_periph.h @@ -42,6 +42,8 @@ #include #include +#include + #include struct devstat; @@ -147,6 +149,7 @@ struct cam_periph { ac_callback_t *deferred_callback; ac_code deferred_ac; struct task periph_run_task; + uma_zone_t ccb_zone; }; #define CAM_PERIPH_MAXMAPS 2 diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index b7bc2b74da6c..33361cfb68a5 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -4693,7 +4693,17 @@ xpt_alloc_ccb_nowait(void) void xpt_free_ccb(union ccb *free_ccb) { - free(free_ccb, M_CAMCCB); + struct cam_periph *periph; + + if (free_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) { + /* + * Looks like a CCB allocated from a periph UMA zone. + */ + periph = free_ccb->ccb_h.path->periph; + uma_zfree(periph->ccb_zone, free_ccb); + } else { + free(free_ccb, M_CAMCCB); + } } /* Private XPT functions */ @@ -4707,10 +4717,18 @@ static union ccb * xpt_get_ccb_nowait(struct cam_periph *periph) { union ccb *new_ccb; + int alloc_flags; - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT); + if (periph->ccb_zone != NULL) { + alloc_flags = CAM_CCB_FROM_UMA; + new_ccb = uma_zalloc(periph->ccb_zone, M_ZERO|M_NOWAIT); + } else { + alloc_flags = 0; + new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT); + } if (new_ccb == NULL) return (NULL); + new_ccb->ccb_h.alloc_flags = alloc_flags; periph->periph_allocated++; cam_ccbq_take_opening(&periph->path->device->ccbq); return (new_ccb); @@ -4720,9 +4738,17 @@ static union ccb * xpt_get_ccb(struct cam_periph *periph) { union ccb *new_ccb; + int alloc_flags; cam_periph_unlock(periph); - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK); + if (periph->ccb_zone != NULL) { + alloc_flags = CAM_CCB_FROM_UMA; + new_ccb = uma_zalloc(periph->ccb_zone, M_ZERO|M_WAITOK); + } else { + alloc_flags = 0; + new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK); + } + new_ccb->ccb_h.alloc_flags = alloc_flags; cam_periph_lock(periph); periph->periph_allocated++; cam_ccbq_take_opening(&periph->path->device->ccbq); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index baba5d9ed839..05dd9b6e7566 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -403,6 +403,8 @@ struct da_softc { softc->delete_available &= ~(1 << delete_method); \ } +static uma_zone_t da_ccb_zone; + struct da_quirk_entry { struct scsi_inquiry_pattern inq_pat; da_quirks quirks; @@ -1557,6 +1559,7 @@ static sbintime_t da_default_softtimeout = DA_DEFAULT_SOFTTIMEOUT; static int da_send_ordered = DA_DEFAULT_SEND_ORDERED; static int da_disable_wp_detection = 0; static int da_enable_biospeedup = 1; +static int da_enable_uma_ccbs = 0; static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "CAM Direct Access Disk driver"); @@ -1573,6 +1576,8 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, disable_wp_detection, CTLFLAG_RWTUN, "Disable detection of write-protected disks"); SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, &da_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); +SYSCTL_INT(_kern_cam_da, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN, + &da_enable_uma_ccbs, 0, "Use UMA for CCBs"); SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, @@ -2011,6 +2016,10 @@ dainit(void) NULL, SHUTDOWN_PRI_DEFAULT)) == NULL) printf("dainit: shutdown event registration failed!\n"); } + + da_ccb_zone = uma_zcreate("da_ccb", + sizeof(struct ccb_scsiio), NULL, NULL, NULL, NULL, + UMA_ALIGN_PTR, 0); } /* @@ -2848,6 +2857,15 @@ daregister(struct cam_periph *periph, void *arg) TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph); + /* + * Let XPT know we can use UMA-allocated CCBs. + */ + if (da_enable_uma_ccbs) { + KASSERT(da_ccb_zone != NULL, + ("%s: NULL da_ccb_zone", __func__)); + periph->ccb_zone = da_ccb_zone; + } + /* * Take an exclusive section lock on the periph while dastart is called * to finish the probe. The lock will be dropped in dadone at the end diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 67b94488dff0..bdc23e4b51b7 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -2625,6 +2625,13 @@ static void scsi_action(union ccb *start_ccb) { + if (start_ccb->ccb_h.func_code != XPT_SCSI_IO) { + KASSERT((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) == 0, + ("%s: ccb %p, func_code %#x should not be allocated " + "from UMA zone\n", + __func__, start_ccb, start_ccb->ccb_h.func_code)); + } + switch (start_ccb->ccb_h.func_code) { case XPT_SET_TRAN_SETTINGS: { From owner-dev-commits-src-all@freebsd.org Sat May 15 14:15:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E85CD646DDD; Sat, 15 May 2021 14:15: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 4Fj6r86Fgqz4m5c; Sat, 15 May 2021 14:15:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 BED6726870; Sat, 15 May 2021 14:15:52 +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 14FEFqxA057749; Sat, 15 May 2021 14:15:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14FEFqb8057748; Sat, 15 May 2021 14:15:52 GMT (envelope-from git) Date: Sat, 15 May 2021 14:15:52 GMT Message-Id: <202105151415.14FEFqb8057748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 7fbc0c98a8ef - main - build(7): use a more relevant example for PORTS_MODULES MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fbc0c98a8efaef86d72759372ec7746d929302e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 14:15:53 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=7fbc0c98a8efaef86d72759372ec7746d929302e commit 7fbc0c98a8efaef86d72759372ec7746d929302e Author: Mitchell Horne AuthorDate: 2021-05-15 14:14:52 +0000 Commit: Mitchell Horne CommitDate: 2021-05-15 14:15:25 +0000 build(7): use a more relevant example for PORTS_MODULES emulators/kqemu-kmod no longer exists in the ports tree. Reviewed by: imp, bcr Differential Revision: https://reviews.freebsd.org/D30261 --- share/man/man7/build.7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 index 9591b0365307..62c24eaed0dc 100644 --- a/share/man/man7/build.7 +++ b/share/man/man7/build.7 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 28, 2021 +.Dd May 15, 2021 .Dt BUILD 7 .Os .Sh NAME @@ -602,7 +602,7 @@ and .Cm installkernel process. .Bd -literal -offset indent -make PORTS_MODULES=emulators/kqemu-kmod kernel +make PORTS_MODULES=emulators/virtualbox-ose-kmod kernel .Ed .It Va SRCCONF Specify a file to override the default From owner-dev-commits-src-all@freebsd.org Sat May 15 16:03:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0251B649BF1; Sat, 15 May 2021 16:03:04 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fj9Cq6Pj2z50lC; Sat, 15 May 2021 16:03:03 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: by mail-ed1-x52b.google.com with SMTP id di13so1935170edb.2; Sat, 15 May 2021 09:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=0pYabJsDvhMWX7/rOW/ty1e+SB90zG7wjhk/p30gv58=; b=JncGC+LTZf8Q6vtIXuMyAADRPjyFs6KNuNpxQMqNXdMRYHvNrQ8kDAJlNUQaYS1CfV GhTRsLx/BYpjUMLTOEHKSsVPROShGSOol2ixQF26D08N3OBu/Tt2ZyHbaYdA3ZvATjmi I1xj17KcsTg0AoE7v5IdMQ2pXm+nlbQL4O82nd8kIFxYBM/lw9l38jpxsWjeqX7JynAR TTZjIFdeaROZdn8pTl7U4n6F4WJzT2irP32xpmZ93dCW+ime13uUulHVjleoJBneCcrL HfMo2I1AoNCyPNOa74k0gVKEJlELtzWjmk8mqNrby33nSVte90Y/K3I6gYqe+CB+IdGV A3pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=0pYabJsDvhMWX7/rOW/ty1e+SB90zG7wjhk/p30gv58=; b=gvPhWAZPqgW8B8eLOsF9sPOshgorgIjtMYGSVhqBbVdeVduGCa71f/kI6gja6FlhQO RoQkdsNYnhAXKRtPY2bm3qGupLEK/NE2juYUZ26uYw4nBp/DgP9rPYcSuqhLv5XPw8jH cN7+AxE2OXQ1eg1NneNO5aIj2MU1wIBWCoDN1z1g3bh1MLKilHe54l06f/UMRkP3L/vo NNNMR5DhcJ8WvwbI8ikvDYhM2cnIQFPsGIPvUc6dXP5sMf7I7kf8BYjsFPFTCJLb1TNV Jvjn8ZfsQ/4bO1HR49c1gMd+1/ZT/CimTSAvaWQVC4B81FIeYw+X/uw3wrfPL642PnkV eA1Q== X-Gm-Message-State: AOAM533OAVFQeLmaTprog2k3xkECpZWp72dxeKHtj5aCv6s7RqIfPIzi M5F7EOgrDXDBWxx7QrMoYndyt+H+djo= X-Google-Smtp-Source: ABdhPJyPO/S76U+6lOZEhLkQhCbf5Lni3h+hXbbVxwmh8D6vQgb7zMHw1PLPnn13osYGDDgtNwTGeQ== X-Received: by 2002:aa7:d455:: with SMTP id q21mr12628496edr.2.1621094581860; Sat, 15 May 2021 09:03:01 -0700 (PDT) Received: from ernst.home (pd9e23d76.dip0.t-ipconnect.de. [217.226.61.118]) by smtp.gmail.com with ESMTPSA id bw26sm5526253ejb.119.2021.05.15.09.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 09:03:00 -0700 (PDT) Date: Sat, 15 May 2021 18:03:00 +0200 From: Gary Jennejohn To: Edward Tomasz Napierala Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 3394d4239b85 - main - cam: allocate CCBs from UMA for SCSI and ATA IO Message-ID: <20210515160300.6d6d3916@ernst.home> In-Reply-To: <202105151105.14FB5nv7005915@gitrepo.freebsd.org> References: <202105151105.14FB5nv7005915@gitrepo.freebsd.org> Reply-To: gljennjohn@gmail.com X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Fj9Cq6Pj2z50lC X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 16:03:04 -0000 On Sat, 15 May 2021 11:05:49 GMT Edward Tomasz Napierala wrote: > The branch main has been updated by trasz: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3394d4239b85b5577845d9e6de4e97b18d3dba58 > > commit 3394d4239b85b5577845d9e6de4e97b18d3dba58 > Author: Edward Tomasz Napierala > AuthorDate: 2021-05-15 10:17:22 +0000 > Commit: Edward Tomasz Napierala > CommitDate: 2021-05-15 11:03:49 +0000 > > cam: allocate CCBs from UMA for SCSI and ATA IO > > This patch makes it possible for CAM to use small CCBs allocated > from an periph-specific UMA zone instead of the usual, huge ones. > The end result is that CCBs issued via da(4) take 544B (size of > ccb_scsiio) instead of the usual 2kB (size of 'union ccb', ~1.5kB, > rounded up by malloc(9)). For ATA it's 272B. We waste less > memory, we avoid zeroing the unused 1kB, and it should be easier > to allocate those CCBs in low memory conditions. It should also > be possible to use uma_zone_reserve(9) to improve behaviour > in low memory conditions even further. > > Note that this does not change the size, or the layout, of CCBs > as such. CCBs get allocated in various different ways, in particular > on the stack, and I don't want to redo all that. Instead, this > provides an opt-in mechanism for the periph to declare "my start() > callback is fine with receiving a CCB allocated from this UMA zone". > In other words, most of the code works exactly as it used to; the > change only happens to IOs issued by xpt_run_allockq(), which > is - conveniently - pretty much all that matters for performance. > > The reason for doing it this way is that it's pretty small, localized > change, and can be implemented gradually and iteratively: take a > periph, make sure its start() callback only casts the CCBs it takes > to a particular type of CCB, for example ccb_scsiio, and that it only > casts CCBs returned by cam_periph_getccb() to that type, then add UMA > zone for that size, and declare it safe to XPT. > > This is disabled by default. Set 'kern.cam.ada.enable_uma_ccbs=1' > and 'kern.cam.da.enable_uma_ccbs=1' tunables to enable it. Testing > is welcome; I will flip the default to enable in two weeks from now. > [snip diff] I built and installed world and kernel and enabled both tunables. System's been up for about two hours using both ada and da disks pretty intensely and hasn't trashed any yet. -- Gary Jennejohn From owner-dev-commits-src-all@freebsd.org Sat May 15 19:42:08 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C8F4564DE2F; Sat, 15 May 2021 19:42:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4FjG4c3pgpz3hF8; Sat, 15 May 2021 19:42:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14FJfrDd040099 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 15 May 2021 22:41:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14FJfrDd040099 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14FJfrd9040098; Sat, 15 May 2021 22:41:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 15 May 2021 22:41:53 +0300 From: Konstantin Belousov To: Lutz Donnerhacke Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: References: <202105150701.14F717lf084359@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105150701.14F717lf084359@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4FjG4c3pgpz3hF8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 19:42:08 -0000 On Sat, May 15, 2021 at 07:01:07AM +0000, Lutz Donnerhacke wrote: > The branch main has been updated by donner: > > URL: https://cgit.FreeBSD.org/src/commit/?id=effc8e57fbf03d7f1423c662caf2b63f0d1d21a9 > > commit effc8e57fbf03d7f1423c662caf2b63f0d1d21a9 > Author: Lutz Donnerhacke > AuthorDate: 2021-05-14 13:08:08 +0000 > Commit: Lutz Donnerhacke > CommitDate: 2021-05-15 06:57:55 +0000 > > libalias: Style cleanup > > libalias is a convolut of various coding styles modified by a series > of different editors enforcing interesting convetions on spacing and > comments. > > This patch is a baseline to start with a perfomance rework of > libalias. Upcoming patches should be focus on the code, not on the > style. That's why most annoying style errors should be fixed > beforehand. > > Reviewed by: hselasky > Discussed by: emaste > MFC after: 2 weeks > Differential Revision: https://reviews.freebsd.org/D30259 > --- > sys/netinet/libalias/alias.c | 379 ++++++++++++++++----------------- > sys/netinet/libalias/alias.h | 44 ++-- > sys/netinet/libalias/alias_db.c | 414 +++++++++++++++++------------------- > sys/netinet/libalias/alias_dummy.c | 15 +- > sys/netinet/libalias/alias_ftp.c | 68 +++--- > sys/netinet/libalias/alias_irc.c | 52 +++-- > sys/netinet/libalias/alias_local.h | 178 +++++++--------- > sys/netinet/libalias/alias_mod.c | 2 - > sys/netinet/libalias/alias_nbt.c | 253 ++++++++++------------ > sys/netinet/libalias/alias_pptp.c | 84 ++++---- > sys/netinet/libalias/alias_proxy.c | 271 ++++++++++++----------- > sys/netinet/libalias/alias_sctp.c | 138 ++++++------ > sys/netinet/libalias/alias_sctp.h | 26 +-- > sys/netinet/libalias/alias_skinny.c | 30 ++- > sys/netinet/libalias/alias_smedia.c | 91 ++++---- > sys/netinet/libalias/alias_util.c | 30 +-- > 16 files changed, 975 insertions(+), 1100 deletions(-) > > diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c > index 900731fcbec6..cac19ab55d56 100644 > --- a/sys/netinet/libalias/alias.c > +++ b/sys/netinet/libalias/alias.c > @@ -146,7 +146,7 @@ __FBSDID("$FreeBSD$"); > #include "alias_mod.h" > #endif > > -/* > +/* > * Define libalias SYSCTL Node > */ > #ifdef SYSCTL_NODE > @@ -192,7 +192,6 @@ static void TcpMonitorOut(u_char, struct alias_link *); > static void > TcpMonitorIn(u_char th_flags, struct alias_link *lnk) > { > - > switch (GetStateIn(lnk)) { This was style-compatible. > case ALIAS_TCP_STATE_NOT_CONNECTED: > if (th_flags & TH_RST) > @@ -210,7 +209,6 @@ TcpMonitorIn(u_char th_flags, struct alias_link *lnk) > static void > TcpMonitorOut(u_char th_flags, struct alias_link *lnk) > { > - > switch (GetStateOut(lnk)) { > case ALIAS_TCP_STATE_NOT_CONNECTED: > if (th_flags & TH_RST) > @@ -285,21 +283,20 @@ static int UdpAliasOut(struct libalias *, struct ip *, int, int create); > static int TcpAliasIn(struct libalias *, struct ip *); > static int TcpAliasOut(struct libalias *, struct ip *, int, int create); > > -static int > -IcmpAliasIn1(struct libalias *la, struct ip *pip) > -{ > - > - LIBALIAS_LOCK_ASSERT(la); > /* > De-alias incoming echo and timestamp replies. > Alias incoming echo and timestamp requests. > */ > +static int > +IcmpAliasIn1(struct libalias *la, struct ip *pip) > +{ > + LIBALIAS_LOCK_ASSERT(la); > struct alias_link *lnk; > struct icmp *ic; And this is not in style. Declarations must precede executable statements, even asserts. From owner-dev-commits-src-all@freebsd.org Sat May 15 19:58:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3128F64E53A; Sat, 15 May 2021 19:58:30 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjGRT6V41z3kh6; Sat, 15 May 2021 19:58:29 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 14FJwC15008462 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 15 May 2021 21:58:12 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14FJwChK018571; Sat, 15 May 2021 21:58:12 +0200 Date: Sat, 15 May 2021 21:58:12 +0200 From: Lutz Donnerhacke To: Konstantin Belousov Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: <20210515195812.GB17734@belenus.iks-jena.de> References: <202105150701.14F717lf084359@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4FjGRT6V41z3kh6 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 19:58:30 -0000 On Sat, May 15, 2021 at 10:41:53PM +0300, Konstantin Belousov wrote: > On Sat, May 15, 2021 at 07:01:07AM +0000, Lutz Donnerhacke wrote: > > @@ -285,21 +283,20 @@ static int UdpAliasOut(struct libalias *, struct ip *, int, int create); > > static int TcpAliasIn(struct libalias *, struct ip *); > > static int TcpAliasOut(struct libalias *, struct ip *, int, int create); > > > > -static int > > -IcmpAliasIn1(struct libalias *la, struct ip *pip) > > -{ > > - > > - LIBALIAS_LOCK_ASSERT(la); > > /* > > De-alias incoming echo and timestamp replies. > > Alias incoming echo and timestamp requests. > > */ > > +static int > > +IcmpAliasIn1(struct libalias *la, struct ip *pip) > > +{ > > + LIBALIAS_LOCK_ASSERT(la); > > struct alias_link *lnk; > > struct icmp *ic; > And this is not in style. Declarations must precede executable statements, > even asserts. Of course it was a style commit. + /* + De-alias incoming echo and timestamp replies. + Alias incoming echo and timestamp requests. + */ static int IcmpAliasIn1(struct libalias *la, struct ip *pip) { - LIBALIAS_LOCK_ASSERT(la); - /* - De-alias incoming echo and timestamp replies. - Alias incoming echo and timestamp requests. - */ struct alias_link *lnk; From owner-dev-commits-src-all@freebsd.org Sat May 15 20:19:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8182264EF15; Sat, 15 May 2021 20:19:50 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4FjGw55x1Tz3n3Y; Sat, 15 May 2021 20:19:49 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14FKEVwT047967 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 15 May 2021 23:14:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14FKEVwT047967 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14FKEV4O047966; Sat, 15 May 2021 23:14:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 15 May 2021 23:14:31 +0300 From: Konstantin Belousov To: Lutz Donnerhacke Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210515195812.GB17734@belenus.iks-jena.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4FjGw55x1Tz3n3Y X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:19:50 -0000 On Sat, May 15, 2021 at 09:58:12PM +0200, Lutz Donnerhacke wrote: > On Sat, May 15, 2021 at 10:41:53PM +0300, Konstantin Belousov wrote: > > On Sat, May 15, 2021 at 07:01:07AM +0000, Lutz Donnerhacke wrote: > > > @@ -285,21 +283,20 @@ static int UdpAliasOut(struct libalias *, struct ip *, int, int create); > > > static int TcpAliasIn(struct libalias *, struct ip *); > > > static int TcpAliasOut(struct libalias *, struct ip *, int, int create); > > > > > > -static int > > > -IcmpAliasIn1(struct libalias *la, struct ip *pip) > > > -{ > > > - > > > - LIBALIAS_LOCK_ASSERT(la); > > > /* > > > De-alias incoming echo and timestamp replies. > > > Alias incoming echo and timestamp requests. > > > */ > > > +static int > > > +IcmpAliasIn1(struct libalias *la, struct ip *pip) > > > +{ > > > + LIBALIAS_LOCK_ASSERT(la); > > > struct alias_link *lnk; > > > struct icmp *ic; > > And this is not in style. Declarations must precede executable statements, > > even asserts. > > Of course it was a style commit. > > + /* > + De-alias incoming echo and timestamp replies. > + Alias incoming echo and timestamp requests. > + */ > static int > IcmpAliasIn1(struct libalias *la, struct ip *pip) > { > - > LIBALIAS_LOCK_ASSERT(la); > - /* > - De-alias incoming echo and timestamp replies. > - Alias incoming echo and timestamp requests. > - */ > struct alias_link *lnk; I do not understand what are you trying to say. From owner-dev-commits-src-all@freebsd.org Sat May 15 20:51:42 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9FDD664FA57; Sat, 15 May 2021 20:51:42 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjHct2pXGz3rV3; Sat, 15 May 2021 20:51:42 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 14FKpXKe014408 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 15 May 2021 22:51:34 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14FKpXkB019890; Sat, 15 May 2021 22:51:33 +0200 Date: Sat, 15 May 2021 22:51:33 +0200 From: Lutz Donnerhacke To: Konstantin Belousov Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: <20210515205133.GA19770@belenus.iks-jena.de> References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4FjHct2pXGz3rV3 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:51:42 -0000 On Sat, May 15, 2021 at 11:14:31PM +0300, Konstantin Belousov wrote: > On Sat, May 15, 2021 at 09:58:12PM +0200, Lutz Donnerhacke wrote: > > Of course it was a style commit. > > > > + /* > > + De-alias incoming echo and timestamp replies. > > + Alias incoming echo and timestamp requests. > > + */ > > static int > > IcmpAliasIn1(struct libalias *la, struct ip *pip) > > { > > - > > LIBALIAS_LOCK_ASSERT(la); > > - /* > > - De-alias incoming echo and timestamp replies. > > - Alias incoming echo and timestamp requests. > > - */ > > struct alias_link *lnk; > > I do not understand what are you trying to say. The diff above is a reformatting of the original diff in the commit. It does show, what really happend during the edit: - The empty line at the beginnen of the function body was removed - The comment at the beginning of the function body was moved before the function definition. The LIBALIAS_LOCK_ASSERT and the variable declarations were not moved. From owner-dev-commits-src-all@freebsd.org Sat May 15 20:55:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 58D0364FC3B; Sat, 15 May 2021 20:55:27 +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 4FjHjC22vKz3rSY; Sat, 15 May 2021 20:55:27 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2EBCD4690; Sat, 15 May 2021 20:55:27 +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 14FKtRSs088260; Sat, 15 May 2021 20:55:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14FKtRRQ088259; Sat, 15 May 2021 20:55:27 GMT (envelope-from git) Date: Sat, 15 May 2021 20:55:27 GMT Message-Id: <202105152055.14FKtRRQ088259@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 128e25842ef5 - main - vm: add another pager private flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 128e25842ef510b39815d784e1d2af0d4afd584f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:55:27 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=128e25842ef510b39815d784e1d2af0d4afd584f commit 128e25842ef510b39815d784e1d2af0d4afd584f Author: Mateusz Guzik AuthorDate: 2021-05-14 07:50:10 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-15 20:47:29 +0000 vm: add another pager private flag Move OBJ_SHADOWLIST around to let pager flags be next to each other. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D30258 --- sys/fs/tmpfs/tmpfs.h | 2 +- sys/vm/vm_object.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 549339d9b6d1..bb777e29e3d0 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -45,7 +45,7 @@ MALLOC_DECLARE(M_TMPFSNAME); #endif -#define OBJ_TMPFS OBJ_PAGERPRIV /* has tmpfs vnode allocated */ +#define OBJ_TMPFS OBJ_PAGERPRIV1 /* has tmpfs vnode allocated */ /* * Internal representation of a tmpfs directory entry. diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index d159c621d2e6..1bf4cee856c7 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -201,13 +201,14 @@ struct vm_object { #define OBJ_UMTXDEAD 0x0020 /* umtx pshared was terminated */ #define OBJ_SIZEVNLOCK 0x0040 /* lock vnode to check obj size */ #define OBJ_PG_DTOR 0x0080 /* dont reset object, leave that for dtor */ +#define OBJ_SHADOWLIST 0x0100 /* Object is on the shadow list. */ #define OBJ_SWAP 0x0200 /* object swaps */ #define OBJ_SPLIT 0x0400 /* object is being split */ #define OBJ_COLLAPSING 0x0800 /* Parent of collapse. */ #define OBJ_COLORED 0x1000 /* pg_color is defined */ #define OBJ_ONEMAPPING 0x2000 /* One USE (a single, non-forked) mapping flag */ -#define OBJ_SHADOWLIST 0x4000 /* Object is on the shadow list. */ -#define OBJ_PAGERPRIV 0x8000 /* Pager private */ +#define OBJ_PAGERPRIV1 0x4000 /* Pager private */ +#define OBJ_PAGERPRIV2 0x8000 /* Pager private */ /* * Helpers to perform conversion between vm_object page indexes and offsets. From owner-dev-commits-src-all@freebsd.org Sat May 15 20:55:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FCD464FF85; Sat, 15 May 2021 20:55:28 +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 4FjHjD2gnLz3rq7; Sat, 15 May 2021 20:55:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 453CD42F5; Sat, 15 May 2021 20:55:28 +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 14FKtSPX088288; Sat, 15 May 2021 20:55:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14FKtSRD088287; Sat, 15 May 2021 20:55:28 GMT (envelope-from git) Date: Sat, 15 May 2021 20:55:28 GMT Message-Id: <202105152055.14FKtSRD088287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: eec2e4ef7f96 - main - tmpfs: reimplement the mtime scan to use the lazy list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eec2e4ef7f964d18fcec3dc2cdcd7530be490835 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:55:28 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=eec2e4ef7f964d18fcec3dc2cdcd7530be490835 commit eec2e4ef7f964d18fcec3dc2cdcd7530be490835 Author: Mateusz Guzik AuthorDate: 2021-05-07 14:43:43 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-15 20:48:45 +0000 tmpfs: reimplement the mtime scan to use the lazy list Tested by: pho Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D30065 --- sys/fs/tmpfs/tmpfs.h | 1 + sys/fs/tmpfs/tmpfs_subr.c | 107 ++++++++++++++++++++++++++++++++++++++++++++ sys/fs/tmpfs/tmpfs_vfsops.c | 67 ++++++++++++++------------- 3 files changed, 143 insertions(+), 32 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index bb777e29e3d0..99368d67aaaa 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -46,6 +46,7 @@ MALLOC_DECLARE(M_TMPFSNAME); #endif #define OBJ_TMPFS OBJ_PAGERPRIV1 /* has tmpfs vnode allocated */ +#define OBJ_TMPFS_VREF OBJ_PAGERPRIV2 /* vnode is referenced */ /* * Internal representation of a tmpfs directory entry. diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 67eb12598e24..8b75c58d69a2 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -99,6 +99,92 @@ tmpfs_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, return (object); } +/* + * Make sure tmpfs vnodes with writable mappings can be found on the lazy list. + * + * This allows for periodic mtime updates while only scanning vnodes which are + * plausibly dirty, see tmpfs_update_mtime_lazy. + */ +static void +tmpfs_pager_writecount_recalc(vm_object_t object, vm_offset_t old, + vm_offset_t new) +{ + struct vnode *vp; + + VM_OBJECT_ASSERT_WLOCKED(object); + + vp = object->un_pager.swp.swp_tmpfs; + + /* + * Forced unmount? + */ + if (vp == NULL) { + KASSERT((object->flags & OBJ_TMPFS_VREF) == 0, + ("object %p with OBJ_TMPFS_VREF but without vnode", object)); + VM_OBJECT_WUNLOCK(object); + return; + } + + if (old == 0) { + VNASSERT((object->flags & OBJ_TMPFS_VREF) == 0, vp, + ("object without writable mappings has a reference")); + VNPASS(vp->v_usecount > 0, vp); + } else { + VNASSERT((object->flags & OBJ_TMPFS_VREF) != 0, vp, + ("object with writable mappings does not have a reference")); + } + + if (old == new) { + VM_OBJECT_WUNLOCK(object); + return; + } + + if (new == 0) { + vm_object_clear_flag(object, OBJ_TMPFS_VREF); + VM_OBJECT_WUNLOCK(object); + vrele(vp); + } else { + if ((object->flags & OBJ_TMPFS_VREF) == 0) { + vref(vp); + vlazy(vp); + vm_object_set_flag(object, OBJ_TMPFS_VREF); + } + VM_OBJECT_WUNLOCK(object); + } +} + +static void +tmpfs_pager_update_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + vm_offset_t new, old; + + VM_OBJECT_WLOCK(object); + KASSERT((object->flags & OBJ_ANON) == 0, + ("%s: object %p with OBJ_ANON", __func__, object)); + old = object->un_pager.swp.writemappings; + object->un_pager.swp.writemappings += (vm_ooffset_t)end - start; + new = object->un_pager.swp.writemappings; + tmpfs_pager_writecount_recalc(object, old, new); + VM_OBJECT_ASSERT_UNLOCKED(object); +} + +static void +tmpfs_pager_release_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + vm_offset_t new, old; + + VM_OBJECT_WLOCK(object); + KASSERT((object->flags & OBJ_ANON) == 0, + ("%s: object %p with OBJ_ANON", __func__, object)); + old = object->un_pager.swp.writemappings; + object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; + new = object->un_pager.swp.writemappings; + tmpfs_pager_writecount_recalc(object, old, new); + VM_OBJECT_ASSERT_UNLOCKED(object); +} + static void tmpfs_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) { @@ -131,6 +217,8 @@ struct pagerops tmpfs_pager_ops = { .pgo_kvme_type = KVME_TYPE_VNODE, .pgo_alloc = tmpfs_pager_alloc, .pgo_set_writeable_dirty = vm_object_set_writeable_dirty_, + .pgo_update_writecount = tmpfs_pager_update_writecount, + .pgo_release_writecount = tmpfs_pager_release_writecount, .pgo_mightbedirty = vm_object_mightbedirty_, .pgo_getvp = tmpfs_pager_getvp, }; @@ -643,6 +731,7 @@ tmpfs_free_dirent(struct tmpfs_mount *tmp, struct tmpfs_dirent *de) void tmpfs_destroy_vobject(struct vnode *vp, vm_object_t obj) { + bool want_vrele; ASSERT_VOP_ELOCKED(vp, "tmpfs_destroy_vobject"); if (vp->v_type != VREG || obj == NULL) @@ -650,12 +739,24 @@ tmpfs_destroy_vobject(struct vnode *vp, vm_object_t obj) VM_OBJECT_WLOCK(obj); VI_LOCK(vp); + /* + * May be going through forced unmount. + */ + want_vrele = false; + if ((obj->flags & OBJ_TMPFS_VREF) != 0) { + vm_object_clear_flag(obj, OBJ_TMPFS_VREF); + want_vrele = true; + } + vm_object_clear_flag(obj, OBJ_TMPFS); obj->un_pager.swp.swp_tmpfs = NULL; if (vp->v_writecount < 0) vp->v_writecount = 0; VI_UNLOCK(vp); VM_OBJECT_WUNLOCK(obj); + if (want_vrele) { + vrele(vp); + } } /* @@ -792,6 +893,12 @@ loop: case VREG: object = node->tn_reg.tn_aobj; VM_OBJECT_WLOCK(object); + KASSERT((object->flags & OBJ_TMPFS_VREF) == 0, + ("%s: object %p with OBJ_TMPFS_VREF but without vnode", + __func__, object)); + KASSERT(object->un_pager.swp.writemappings == 0, + ("%s: object %p has writemappings", + __func__, object)); VI_LOCK(vp); KASSERT(vp->v_object == NULL, ("Not NULL v_object in tmpfs")); vp->v_object = object; diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 4f29b5dfc6f0..7dffb9027946 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -99,18 +99,38 @@ static const char *tmpfs_updateopts[] = { "from", "export", "nomtime", "size", NULL }; -/* - * Handle updates of time from writes to mmaped regions, if allowed. - * Use MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since - * unmap of the tmpfs-backed vnode does not call vinactive(), due to - * vm object type is basically OBJT_SWAP. If lazy, only handle - * delayed update of mtime due to the writes to mapped files. - */ +static int +tmpfs_update_mtime_lazy_filter(struct vnode *vp, void *arg) +{ + struct vm_object *obj; + + if (vp->v_type != VREG) + return (0); + + obj = atomic_load_ptr(&vp->v_object); + if (obj == NULL) + return (0); + + return (vm_object_mightbedirty_(obj)); +} + static void -tmpfs_update_mtime(struct mount *mp, bool lazy) +tmpfs_update_mtime_lazy(struct mount *mp) +{ + struct vnode *vp, *mvp; + + MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, tmpfs_update_mtime_lazy_filter, NULL) { + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK) != 0) + continue; + tmpfs_check_mtime(vp); + vput(vp); + } +} + +static void +tmpfs_update_mtime_all(struct mount *mp) { struct vnode *vp, *mvp; - struct vm_object *obj; if (VFS_TO_TMPFS(mp)->tm_nomtime) return; @@ -119,28 +139,11 @@ tmpfs_update_mtime(struct mount *mp, bool lazy) VI_UNLOCK(vp); continue; } - obj = vp->v_object; - MPASS(obj->type == tmpfs_pager_type); - MPASS((obj->flags & OBJ_TMPFS) != 0); - - /* - * In lazy case, do unlocked read, avoid taking vnode - * lock if not needed. Lost update will be handled on - * the next call. - * For non-lazy case, we must flush all pending - * metadata changes now. - */ - if (!lazy || obj->generation != obj->cleangeneration) { - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK) != 0) - continue; - tmpfs_check_mtime(vp); - if (!lazy) - tmpfs_update(vp); - vput(vp); - } else { - VI_UNLOCK(vp); + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK) != 0) continue; - } + tmpfs_check_mtime(vp); + tmpfs_update(vp); + vput(vp); } } @@ -300,7 +303,7 @@ tmpfs_rw_to_ro(struct mount *mp) MNT_IUNLOCK(mp); for (;;) { tmpfs_all_rw_maps(mp, tmpfs_revoke_rw_maps_cb, NULL); - tmpfs_update_mtime(mp, false); + tmpfs_update_mtime_all(mp); error = vflush(mp, 0, flags, curthread); if (error != 0) { VFS_TO_TMPFS(mp)->tm_ronly = 0; @@ -653,7 +656,7 @@ tmpfs_sync(struct mount *mp, int waitfor) mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED; MNT_IUNLOCK(mp); } else if (waitfor == MNT_LAZY) { - tmpfs_update_mtime(mp, true); + tmpfs_update_mtime_lazy(mp); } return (0); } From owner-dev-commits-src-all@freebsd.org Sat May 15 20:56:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C42FF64FFA3; Sat, 15 May 2021 20:56:13 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjHk46yv5z3rnR; Sat, 15 May 2021 20:56:12 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lj1-x234.google.com with SMTP id p12so2606960ljg.1; Sat, 15 May 2021 13:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=u3P4RRuFANpBOQgVDLfIeMvs7Z29Xd/tfiRTqRDcXO4=; b=aSiu+ajARc4YQ99EbbfbpIQBl/dG2u9uPpN+ub4epe9I9tdYX8t7XvHsL29L9lX3MU 3K8vCR8CikQKyf+w8NxJaxaX6x36pWIqf4x6OMbZanrZYxAcSZMLTY6/TexNdA4s3dE0 WuJWf1vidn1jxr0/Du2kRqQ3WcpogWbddDEOZ5Ackzb6yeNsVsF5EKTtTjIEjbpfUgV5 R8JM8BxuZsiqQ8W+TEKWgfv+vXX7yMVKRBZIhznHmV6shVpKX1kRvFrG/gpZqfl7L4a/ drR1g5GYM/cTF+/1ldRXuiSzWxl/hzXTrB/ZmIDcc9Omd+TT4/aJQrJNavuyVvh1Sfpq 916Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=u3P4RRuFANpBOQgVDLfIeMvs7Z29Xd/tfiRTqRDcXO4=; b=BO5h5KbV85Wt6OYOmTtdVnSX7OnhKaTdkLspEiqozw5VMzhcMCnXgFtdEkzY5mKbMh MKcsX66KuG/xxLukNvlEuCHAszMtsrqfyFjkGVAYdvj7BiXR3vWxcGVTyTVv/4lBbz4i YwNz5jeLwohL/n1jFTDM3NSGngsBGntg5/NoWY9FZHd7XY8pp5/IdRP/uFKIkFBtWqRO MNgcnTwwFHxHzhARVnUWBL5f2ygXdyzxe5cSm0qgDkeUnpfsP73O8f2+IOtblciVWDWi PZ7UL3w/hKQmBzmCueSCgc48Skd7C3bE/YqMqL+Xe2s1+mVaMFZrN7unL0wOxIoFn9Vb GmeQ== X-Gm-Message-State: AOAM531E7t1/Gaip2mS9+EMk8vprrO/FwiP0jYOIPLd3WzZj8dz80qVk WVxLfLsi5ciCtZYPyffzPU1c+mgs4xuvgMmLS5CpI5BM X-Google-Smtp-Source: ABdhPJylAPDWx2g+2sskNL8cko1FqffbbnFUfeBd6zeCnbluqrXGY46c/59ETFoY+SJAtFqSkhCYh3Gx+ABFhsoPB/8= X-Received: by 2002:a2e:9acb:: with SMTP id p11mr42549540ljj.463.1621112170523; Sat, 15 May 2021 13:56:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:651c:485:0:0:0:0 with HTTP; Sat, 15 May 2021 13:56:09 -0700 (PDT) In-Reply-To: <202105141922.14EJM1pM058368@gitrepo.freebsd.org> References: <202105141922.14EJM1pM058368@gitrepo.freebsd.org> From: Mateusz Guzik Date: Sat, 15 May 2021 22:56:09 +0200 Message-ID: Subject: Re: git: e73e2ee0acf5 - main - cxgbei: Handle target transfers with excess unsolicited data. To: John Baldwin Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4FjHk46yv5z3rnR X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=aSiu+ajA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::234 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.73 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::234:from]; TO_DN_SOME(0.00)[]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::234:from:127.0.2.255]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::234:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_LONG(-0.73)[-0.732]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:56:13 -0000 One of these commits breaks tinderbox: i386 MINIMAL kernel failed, check _.i386.MINIMAL for details i386 GENERIC kernel failed, check _.i386.GENERIC for details i386 GENERIC-NODEBUG kernel failed, check _.i386.GENERIC-NODEBUG for details i386 PAE kernel failed, check _.i386.PAE for details i386 LINT kernel failed, check _.i386.LINT for details i386 LINT-NOINET kernel failed, check _.i386.LINT-NOINET for details i386 LINT-NOINET6 kernel failed, check _.i386.LINT-NOINET6 for details i386 LINT-NOIP kernel failed, check _.i386.LINT-NOIP for details /usr/src/sys/dev/cxgbe/tom/t4_ddp.c:1045:15: error: invalid operands to binary expression ('void *' and 'int') start_pva = trunc_page(sgl->addr); ^~~~~~~~~~~~~~~~~~~~~ ./machine/param.h:150:29: note: expanded from macro 'trunc_page' #define trunc_page(x) ((x) & ~PAGE_MASK) ~~~ ^ ~~~~~~~~~~ /usr/src/sys/dev/cxgbe/tom/t4_ddp.c:1300:8: error: invalid operands to binary expression ('void *' and 'int') pva = trunc_page(sgl->addr); ^~~~~~~~~~~~~~~~~~~~~ ./machine/param.h:150:29: note: expanded from macro 'trunc_page' #define trunc_page(x) ((x) & ~PAGE_MASK) ~~~ ^ ~~~~~~~~~~ On 5/14/21, John Baldwin wrote: > The branch main has been updated by jhb: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab > > commit e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab > Author: John Baldwin > AuthorDate: 2021-05-14 19:20:57 +0000 > Commit: John Baldwin > CommitDate: 2021-05-14 19:21:34 +0000 > > cxgbei: Handle target transfers with excess unsolicited data. > > The CTL frontend might have provided a buffer that is smaller than the > FirstBurstLength and thus smaller than the amount of unsolicited data > included in the request PDU. Treat these transfers as an empty > transfer. > > Reported by: Jithesh Arakkan @ Chelsio > Sponsored by: Chelsio Communications > > Differential Revision: https://reviews.freebsd.org/D29940 > --- > sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c > b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c > index 7f638c96483a..c4eb4a35ad31 100644 > --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c > +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c > @@ -1064,10 +1064,15 @@ icl_cxgbei_conn_transfer_setup(struct icl_conn *ic, > union ctl_io *io, > /* > * Note that ICL calls conn_transfer_setup even if the first > * burst had everything and there's nothing left to transfer. > + * > + * NB: The CTL frontend might have provided a buffer > + * whose length (kern_data_len) is smaller than the > + * FirstBurstLength of unsolicited data. Treat those > + * as an empty transfer. > */ > - MPASS(ctsio->kern_data_len >= first_burst); > xferlen = ctsio->kern_data_len; > - if (xferlen - first_burst < ci->ddp_threshold) { > + if (xferlen < first_burst || > + xferlen - first_burst < ci->ddp_threshold) { > no_ddp: > /* > * No DDP for this transfer. Allocate a TTT (based on > -- Mateusz Guzik From owner-dev-commits-src-all@freebsd.org Sat May 15 21:25:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F25D962806A for ; Sat, 15 May 2021 21:25:10 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjJMV6Q34z3vpm for ; Sat, 15 May 2021 21:25:10 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f48.google.com with SMTP id k5-20020a05600c4785b0290174b7945d7eso1035673wmo.2 for ; Sat, 15 May 2021 14:25:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+NQ0JGpMrnEYkuoL4ruQ5d4fx+ZcAWcjyboX8xjX+QU=; b=uVl5wqRTo5Q1qCNnLwRhkEbF7wZxJCL1IkWkj8YmsfSdspzMhO4bFNr1boXg56OxAo qZK+p75mAeXfD0PWBI9ZCx9V2kfk5uLf7KrRJ8fsel36YzgjFEBdVca7ciXtmcu1Bobx 6NqDB+uisbmt4lpOcO0BDJB77TL7XWLiwCrKmoBJAlhEc7QfH393h+FYkpm+wpAvwR6+ vFuBhWoQHge6XRT7yGOY6tNH15tRWD04cJY29Ud8QRT89ZezY13AO/CAV8lBXREOgMSf vMxVo/qZxjSL68onu+MJAfO+1PgzuWPp70nuTt87hjR8Iado0FoSiIUXerqOGcGr1avQ L+lw== X-Gm-Message-State: AOAM530cmOYO9SaWKO+AEaIftenNB3Ebt6TN/4h324BeK1AG0Ca6ByPn zrHpYOu/Jda/yk19tpf91osHcw== X-Google-Smtp-Source: ABdhPJydoeNd5dUz4L5Pt+hW79x2P3FGPYZ0Fv+6c9CDH5Ycud3olFTC6Un/nRCJ/SgzWa9nD+vfBA== X-Received: by 2002:a1c:c911:: with SMTP id f17mr57365662wmb.45.1621113909413; Sat, 15 May 2021 14:25:09 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id z66sm16182477wmc.4.2021.05.15.14.25.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 May 2021 14:25:09 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: e73e2ee0acf5 - main - cxgbei: Handle target transfers with excess unsolicited data. From: Jessica Clarke In-Reply-To: Date: Sat, 15 May 2021 22:25:08 +0100 Cc: John Baldwin , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <2B05ED91-15B0-468B-A23A-266BD559419D@freebsd.org> References: <202105141922.14EJM1pM058368@gitrepo.freebsd.org> To: Mateusz Guzik X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FjJMV6Q34z3vpm X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 21:25:11 -0000 On 15 May 2021, at 21:56, Mateusz Guzik wrote: >=20 > One of these commits breaks tinderbox: > i386 MINIMAL kernel failed, check _.i386.MINIMAL for details > i386 GENERIC kernel failed, check _.i386.GENERIC for details > i386 GENERIC-NODEBUG kernel failed, check _.i386.GENERIC-NODEBUG for = details > i386 PAE kernel failed, check _.i386.PAE for details > i386 LINT kernel failed, check _.i386.LINT for details > i386 LINT-NOINET kernel failed, check _.i386.LINT-NOINET for details > i386 LINT-NOINET6 kernel failed, check _.i386.LINT-NOINET6 for details > i386 LINT-NOIP kernel failed, check _.i386.LINT-NOIP for details >=20 > /usr/src/sys/dev/cxgbe/tom/t4_ddp.c:1045:15: error: invalid operands > to binary expression ('void *' and 'int') > start_pva =3D trunc_page(sgl->addr); > ^~~~~~~~~~~~~~~~~~~~~ > ./machine/param.h:150:29: note: expanded from macro 'trunc_page' > #define trunc_page(x) ((x) & ~PAGE_MASK) > ~~~ ^ ~~~~~~~~~~ > /usr/src/sys/dev/cxgbe/tom/t4_ddp.c:1300:8: error: invalid operands to > binary expression ('void *' and 'int') > pva =3D trunc_page(sgl->addr); > ^~~~~~~~~~~~~~~~~~~~~ > ./machine/param.h:150:29: note: expanded from macro 'trunc_page' > #define trunc_page(x) ((x) & ~PAGE_MASK) > ~~~ ^ ~~~~~~~~~~ It seems amd64, arm64 and riscv cast to unsigned long first, but arm, = i386, mips and powerpc do not. These macros should probably just become MI in sys/sys/param.h rather than fixing the MD copies to include casts. Jess > On 5/14/21, John Baldwin wrote: >> The branch main has been updated by jhb: >>=20 >> URL: >> = https://cgit.FreeBSD.org/src/commit/?id=3De73e2ee0acf5a0e0f47b9c2bcd73c835= c4922fab >>=20 >> commit e73e2ee0acf5a0e0f47b9c2bcd73c835c4922fab >> Author: John Baldwin >> AuthorDate: 2021-05-14 19:20:57 +0000 >> Commit: John Baldwin >> CommitDate: 2021-05-14 19:21:34 +0000 >>=20 >> cxgbei: Handle target transfers with excess unsolicited data. >>=20 >> The CTL frontend might have provided a buffer that is smaller than = the >> FirstBurstLength and thus smaller than the amount of unsolicited = data >> included in the request PDU. Treat these transfers as an empty >> transfer. >>=20 >> Reported by: Jithesh Arakkan @ Chelsio >> Sponsored by: Chelsio Communications >>=20 >> Differential Revision: https://reviews.freebsd.org/D29940 >> --- >> sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >>=20 >> diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c >> b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c >> index 7f638c96483a..c4eb4a35ad31 100644 >> --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c >> +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c >> @@ -1064,10 +1064,15 @@ icl_cxgbei_conn_transfer_setup(struct = icl_conn *ic, >> union ctl_io *io, >> /* >> * Note that ICL calls conn_transfer_setup even if the = first >> * burst had everything and there's nothing left to = transfer. >> + * >> + * NB: The CTL frontend might have provided a buffer >> + * whose length (kern_data_len) is smaller than the >> + * FirstBurstLength of unsolicited data. Treat those >> + * as an empty transfer. >> */ >> - MPASS(ctsio->kern_data_len >=3D first_burst); >> xferlen =3D ctsio->kern_data_len; >> - if (xferlen - first_burst < ci->ddp_threshold) { >> + if (xferlen < first_burst || >> + xferlen - first_burst < ci->ddp_threshold) { >> no_ddp: >> /* >> * No DDP for this transfer. Allocate a TTT = (based on >>=20 >=20 >=20 > --=20 > Mateusz Guzik From owner-dev-commits-src-all@freebsd.org Sat May 15 21:31:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE443628931; Sat, 15 May 2021 21:31:05 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4FjJVK4rdjz3wGw; Sat, 15 May 2021 21:31:05 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14FLUsfc066663 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 May 2021 00:30:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14FLUsfc066663 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14FLUsFM066662; Sun, 16 May 2021 00:30:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 16 May 2021 00:30:54 +0300 From: Konstantin Belousov To: Lutz Donnerhacke Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> <20210515205133.GA19770@belenus.iks-jena.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210515205133.GA19770@belenus.iks-jena.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4FjJVK4rdjz3wGw X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 21:31:06 -0000 On Sat, May 15, 2021 at 10:51:33PM +0200, Lutz Donnerhacke wrote: > On Sat, May 15, 2021 at 11:14:31PM +0300, Konstantin Belousov wrote: > > On Sat, May 15, 2021 at 09:58:12PM +0200, Lutz Donnerhacke wrote: > > > Of course it was a style commit. > > > > > > + /* > > > + De-alias incoming echo and timestamp replies. > > > + Alias incoming echo and timestamp requests. > > > + */ > > > static int > > > IcmpAliasIn1(struct libalias *la, struct ip *pip) > > > { > > > - > > > LIBALIAS_LOCK_ASSERT(la); > > > - /* > > > - De-alias incoming echo and timestamp replies. > > > - Alias incoming echo and timestamp requests. > > > - */ > > > struct alias_link *lnk; > > > > I do not understand what are you trying to say. > > The diff above is a reformatting of the original diff in the commit. > It does show, what really happend during the edit: > - The empty line at the beginnen of the function body was removed This is optional, empty line at the beginning for the functions without local declarations was required before, and is allowed right now. > - The comment at the beginning of the function body was moved > before the function definition. > > The LIBALIAS_LOCK_ASSERT and the variable declarations were not moved. So you changed some style, but left the large violation in place. From owner-dev-commits-src-all@freebsd.org Sat May 15 22:37:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 28E9E629822; Sat, 15 May 2021 22:37:33 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjKz0693Mz4YXj; Sat, 15 May 2021 22:37:32 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 14FMbOJK023145 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 16 May 2021 00:37:25 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14FMaYgC023690; Sun, 16 May 2021 00:36:34 +0200 Date: Sun, 16 May 2021 00:36:34 +0200 From: Lutz Donnerhacke To: Konstantin Belousov Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: <20210515223634.GA21814@belenus.iks-jena.de> References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> <20210515205133.GA19770@belenus.iks-jena.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4FjKz0693Mz4YXj X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 22:37:33 -0000 On Sun, May 16, 2021 at 12:30:54AM +0300, Konstantin Belousov wrote: > > The LIBALIAS_LOCK_ASSERT and the variable declarations were not moved. > So you changed some style, but left the large violation in place. This cleanup is a preparation to fix various issues in this code. So yes, the change was intentionally limited to style issues. Mixing style and functional changes makes it very hard to track down a broken behavior to a single commit. This change is huge, it must not break anything. From owner-dev-commits-src-all@freebsd.org Sat May 15 22:42:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09ED5629DA1 for ; Sat, 15 May 2021 22:42:09 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjL4J6L8Fz4YtL for ; Sat, 15 May 2021 22:42:08 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f42.google.com with SMTP id i17so2571239wrq.11 for ; Sat, 15 May 2021 15:42:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=F7NT+d9CyIVNEdF3LuF2NMB/isI8Z051uKvErSixD3o=; b=J4I6adyE8pSF6j//50x4wQVgMri2AGXxQJpvcZOX1eupNTrBWOGGUY1pSVlvD8PfCn 5eWuf7PACtiW5ilHdkT+vEgznwKQfgCUETcTEMeB8ZnB1ER6s8jHWQOFGCn7U+ptpIIh l9wSsygJXkdtXYXWJoHwuZTg1nf9xcPs5A9wsXsariLq7YPfMOXEP8UcOtbDn8gyLtrB mmzOzv06R6jLxxYG8cmDH8HwgkX54bwfKJMAuKsPFeQeUvYZ2F8Lo+7N8OdKKAB8NpkO kj4SwE116QADITYD66B5ykpf6KNQ+UmGWGFTtIx23w4v5GsRE6Zp/PlOv0bgRy8I7tuu 9tpQ== X-Gm-Message-State: AOAM530ajIk4Ti0DWrcUjb2ZFmrqeMcY4ddfIdmZfKTm7FjB4etDG/AA KNc1FC3/HEQXcl8K7EHLB7UVQQ== X-Google-Smtp-Source: ABdhPJxMCn1m6Q6Vt+IF7pmyxy1F8CxguUj8k19zOHo7zqJAZTbbaXipbKRq3nzJLGH2APlA+3vxzQ== X-Received: by 2002:a5d:4408:: with SMTP id z8mr3869094wrq.2.1621118527506; Sat, 15 May 2021 15:42:07 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id v10sm12664092wrq.0.2021.05.15.15.42.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 May 2021 15:42:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup From: Jessica Clarke In-Reply-To: <20210515223634.GA21814@belenus.iks-jena.de> Date: Sat, 15 May 2021 23:42:06 +0100 Cc: Konstantin Belousov , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <67F972DE-A735-4537-8AFB-87E4E9832424@freebsd.org> References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> <20210515205133.GA19770@belenus.iks-jena.de> <20210515223634.GA21814@belenus.iks-jena.de> To: Lutz Donnerhacke X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FjL4J6L8Fz4YtL X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 22:42:09 -0000 On 15 May 2021, at 23:36, Lutz Donnerhacke wrote: >=20 > On Sun, May 16, 2021 at 12:30:54AM +0300, Konstantin Belousov wrote: >>> The LIBALIAS_LOCK_ASSERT and the variable declarations were not = moved. >> So you changed some style, but left the large violation in place. >=20 > This cleanup is a preparation to fix various issues in this code. > So yes, the change was intentionally limited to style issues. >=20 > Mixing style and functional changes makes it very hard to track down a > broken behavior to a single commit. This change is huge, it must not = break > anything. I think you two are talking past each other. kib@=E2=80=99s point is = that some of the changes made in this commit were style *changes* not style *fixes* (i.e. = the code was compliant before, you=E2=80=99ve just changed it from one = acceptable formatting to another), and that there were instances of significant = style violations *not* fixed (e.g. the assertion macro before variable = declarations pointed out). He is not talking about functional violations, only style = ones. However, in your defence, your original commit did not claim to fix = *all* style violations, only "most annoying style errors", though that doesn=E2=80=99t= account for unnecessary churn as seen with the blank lines at the starts of = functions. Jess From owner-dev-commits-src-all@freebsd.org Sat May 15 22:44:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70C81629F23; Sat, 15 May 2021 22:44:57 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjL7Y1N9Qz4ZPH; Sat, 15 May 2021 22:44:56 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 14FMiseA023622 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 16 May 2021 00:44:54 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14FMisfL024199; Sun, 16 May 2021 00:44:54 +0200 Date: Sun, 16 May 2021 00:44:54 +0200 From: Lutz Donnerhacke To: Jessica Clarke Cc: Konstantin Belousov , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: effc8e57fbf0 - main - libalias: Style cleanup Message-ID: <20210515224454.GB21814@belenus.iks-jena.de> References: <202105150701.14F717lf084359@gitrepo.freebsd.org> <20210515195812.GB17734@belenus.iks-jena.de> <20210515205133.GA19770@belenus.iks-jena.de> <20210515223634.GA21814@belenus.iks-jena.de> <67F972DE-A735-4537-8AFB-87E4E9832424@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <67F972DE-A735-4537-8AFB-87E4E9832424@freebsd.org> X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4FjL7Y1N9Qz4ZPH X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 22:44:57 -0000 On Sat, May 15, 2021 at 11:42:06PM +0100, Jessica Clarke wrote: > I think you two are talking past each other. kib@’s point is that some of the > changes made in this commit were style *changes* not style *fixes* (i.e. the > code was compliant before, you’ve just changed it from one acceptable > formatting to another), and that there were instances of significant style > violations *not* fixed (e.g. the assertion macro before variable declarations > pointed out). He is not talking about functional violations, only style ones. > However, in your defence, your original commit did not claim to fix *all* style > violations, only "most annoying style errors", though that doesn’t account for > unnecessary churn as seen with the blank lines at the starts of functions. You are right. Let's close this discussion. From owner-dev-commits-src-all@freebsd.org Sat May 15 23:24:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 741B862A7CA for ; Sat, 15 May 2021 23:24:41 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjM1P2VZrz4f0x for ; Sat, 15 May 2021 23:24:41 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk1-x730.google.com with SMTP id x8so2537634qkl.2 for ; Sat, 15 May 2021 16:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kR5UUuS67BzBCIwANsMwLI5sCoL9aMgF930m9lLpzG4=; b=Ca8bC712qFl2S0t9HZMjBx5GogIlTeNecu9ZmGmtcJxUfbDHgBMnK4Y6kOkdttLRUq HM7BnXTSCNU5CIP6ZNZh7f3E6rX+C/2J8GHxklhWl92Zej+QWhvOJps/4x1h6F0dylbE HUJNTdOjKhExs91KHiX4rYm3wsL6TIjh8es/wC6RxKeMPUzVFtmHYAAINZb3vONNnNmR JQPl/5FILILO5xEIAiEeeOrjeEqdgc7fUU1mtYR9FJuS2Ckr0UgGXHZ6BYPPDMOuOCmk YnJOb0jmqbIRlySzhcDKV6ercTS2MhvYcpdEoBJ8A8a4H7H/k6JlgKXXcMRBeLDtoZmE m/Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kR5UUuS67BzBCIwANsMwLI5sCoL9aMgF930m9lLpzG4=; b=YqkGGJS4HkInUrwwGsHpd0u/yj5kdl6p/rSfHeYrS6Cv8d1QgPOJ8gyn6sH3l/jaGW ehldRH5dCy1aJAusmivVmyx1PVcAuEmf+lq7fZd+9cKcisumt6hmxoAsQqIPTog7XE6x ngVQRiax7su3cMiPYjFXP7xy+8btEprPrfOmvbXwTptm39rrCukqLc0xjQS9Yz7zvFIG jyAf6L2awnKRPNCO76jJKkbHMwr1Ng17qyVbMm/NvBffld1fnFWTZ4Ef3jnBIHCBxMrV 1OliWkjoG+V3Mf0c6zRcnUwqNNqIbOtxyZLJQXzL2BAiD7c5oC1eraLOrqiGbsJgsOzB L6xg== X-Gm-Message-State: AOAM530tCp9BHwCB/U0iuD6XNd/SF3wpK5St/MnUrJJF1Xl1hflPQC+W 7GnlELtJBPPAkYiCqvfEV1FN74cMPHlvX4is X-Google-Smtp-Source: ABdhPJz6KIup3BvglK/USF/2tVBV6PNnuNOx+5Hor9gHUD0EsjMTHiW3iM2KI0oV0FxkzAYoi10HrQ== X-Received: by 2002:a37:815:: with SMTP id 21mr48899075qki.498.1621121080238; Sat, 15 May 2021 16:24:40 -0700 (PDT) Received: from mutt-hbsd (pool-100-16-224-136.bltmmd.fios.verizon.net. [100.16.224.136]) by smtp.gmail.com with ESMTPSA id i9sm7940282qtg.18.2021.05.15.16.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 16:24:39 -0700 (PDT) Date: Sat, 15 May 2021 19:24:38 -0400 From: Shawn Webb To: Edward Tomasz Napierala Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 3394d4239b85 - main - cam: allocate CCBs from UMA for SCSI and ATA IO Message-ID: <20210515232438.7siob6di7bdvaefs@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 14.0-CURRENT-HBSD FreeBSD 14.0-CURRENT-HBSD X-PGP-Key: https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/blob/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc References: <202105151105.14FB5nv7005915@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6k5h3synwn52j6at" Content-Disposition: inline In-Reply-To: <202105151105.14FB5nv7005915@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4FjM1P2VZrz4f0x X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 23:24:41 -0000 --6k5h3synwn52j6at Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 15, 2021 at 11:05:49AM +0000, Edward Tomasz Napierala wrote: > The branch main has been updated by trasz: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D3394d4239b85b5577845d9e6de= 4e97b18d3dba58 >=20 > commit 3394d4239b85b5577845d9e6de4e97b18d3dba58 > Author: Edward Tomasz Napierala > AuthorDate: 2021-05-15 10:17:22 +0000 > Commit: Edward Tomasz Napierala > CommitDate: 2021-05-15 11:03:49 +0000 >=20 > cam: allocate CCBs from UMA for SCSI and ATA IO > =20 > This patch makes it possible for CAM to use small CCBs allocated > from an periph-specific UMA zone instead of the usual, huge ones. > The end result is that CCBs issued via da(4) take 544B (size of > ccb_scsiio) instead of the usual 2kB (size of 'union ccb', ~1.5kB, > rounded up by malloc(9)). For ATA it's 272B. We waste less > memory, we avoid zeroing the unused 1kB, and it should be easier > to allocate those CCBs in low memory conditions. It should also > be possible to use uma_zone_reserve(9) to improve behaviour > in low memory conditions even further. > =20 > Note that this does not change the size, or the layout, of CCBs > as such. CCBs get allocated in various different ways, in particular > on the stack, and I don't want to redo all that. Instead, this > provides an opt-in mechanism for the periph to declare "my start() > callback is fine with receiving a CCB allocated from this UMA zone". > In other words, most of the code works exactly as it used to; the > change only happens to IOs issued by xpt_run_allockq(), which > is - conveniently - pretty much all that matters for performance. > =20 > The reason for doing it this way is that it's pretty small, localized > change, and can be implemented gradually and iteratively: take a > periph, make sure its start() callback only casts the CCBs it takes > to a particular type of CCB, for example ccb_scsiio, and that it only > casts CCBs returned by cam_periph_getccb() to that type, then add UMA > zone for that size, and declare it safe to XPT. > =20 > This is disabled by default. Set 'kern.cam.ada.enable_uma_ccbs=3D1' > and 'kern.cam.da.enable_uma_ccbs=3D1' tunables to enable it. Testing > is welcome; I will flip the default to enable in two weeks from now. > =20 > Reviewed By: imp > Sponsored by: NetApp, Inc. > Sponsored by: Klara, Inc. > Differential Revision: https://reviews.freebsd.org/D28674 > --- > sys/cam/ata/ata_da.c | 18 ++++++++++++++++++ > sys/cam/ata/ata_xpt.c | 7 +++++++ > sys/cam/cam_ccb.h | 14 +++++++++++++- > sys/cam/cam_periph.h | 3 +++ > sys/cam/cam_xpt.c | 32 +++++++++++++++++++++++++++++--- > sys/cam/scsi/scsi_da.c | 18 ++++++++++++++++++ > sys/cam/scsi/scsi_xpt.c | 7 +++++++ > 7 files changed, 95 insertions(+), 4 deletions(-) Hey Edward, I suspect this may be the cause of a kernel panic I just had when booting my Softiron Overdrive 1000 arm64 system: panic: ata_action: ccb 0xffff000040388828, func_code 0x15 should not be all= ocated from UMA zone cpuid =3D 1 time =3D 1 __HardenedBSD_version =3D 1400000 __FreeBSD_version =3D 1400013 version =3D FreeBSD 14.0-CURRENT-HBSD #1 hardened/current/master-n190374-a= 541810e5fa: Sat May 15 17:05:42 EDT 2021 shawn@arm64-02:/usr/obj/usr/src/arm64.aarch64/sys/HARDENEDBSD KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x30 vpanic() at vpanic+0x188 panic() at panic+0x44 ata_action() at ata_action+0x340 _ata_announce_periph() at _ata_announce_periph+0x74 ata_announce_periph_sbuf() at ata_announce_periph_sbuf+0x24 xpt_announce_periph_sbuf() at xpt_announce_periph_sbuf+0x1a8 adaregister() at adaregister+0x420 cam_periph_alloc() at cam_periph_alloc+0x528 adaasync() at adaasync+0xa8 xptsetasyncfunc() at xptsetasyncfunc+0x100 xptdevicetraverse() at xptdevicetraverse+0x9c xpttargettraverse() at xpttargettraverse+0x78 xptbustraverse() at xptbustraverse+0x80 xpt_register_async() at xpt_register_async+0x1fc adainit() at adainit+0x4c periphdriver_init() at periphdriver_init+0x54 xpt_finishconfig_task() at xpt_finishconfig_task+0x18 taskqueue_run_locked() at taskqueue_run_locked+0x188 taskqueue_thread_loop() at taskqueue_thread_loop+0x9c fork_exit() at fork_exit+0x74 fork_trampoline() at fork_trampoline+0x14 KDB: enter: panic [ thread pid 0 tid 100023 ] Stopped at kdb_enter+0x44: undefined f904411f Thanks, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --6k5h3synwn52j6at Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmCgWDMACgkQ/y5nonf4 4fruaQ/+PIkDG/eUlPCAdIrcETOpYDRNCaCK08kg1k6F4OE4H6PUeltr00DQhjH8 NdmIGPlne3Bs2y0qsZLGIMcD5s+NdFyj6bm2d6IX0UP3Si8zSiI8L7bum7jQlv2K Bbk7pAFKBHwYlNm5CotlwoIlDAWztr0N/YNIi4SWX+m2MStoVXZTOcO+3fRB/yFE buWVb1hZlPECmpVnhP/XQtMParxbUd1i9I00oxdYHSVux8CQq73D/Rkm4PT5pj4S iOWouMUGed6fDLS7o1M/wB9t9KOGpvnRqVaolvRfZglTI8ek5d6w9Po0fI4aSUNy LcWZKS0LsQH7zTlevpNvQNDBq1a7xm5UbhMOs3wNiBCgjsJ0anwV9j3/951x/jTS EjqDVfMsa1Vb7s+hXb4Gf9f1RF4HoUeB7P1nOjn+LjZv3kCT/b6mKEMYjrCjeOJz JChaBU2BBY8Q8hsIk4Ndx2Vn3XMLxDjsCsBPQ7f88LX+PZfUiIWtP5aHUuPbQw7l 9zDAkRV7Bb1SeIJeDPvfNbQSHq2waRvd+cZM278X7fM5GmvZG4SfUnEpGpiSA+aD /Eq74lJN35/SdVWH/oRvgpj1zKCwP62Pc112S2Tv6qog2BApWRlPdfMEk+FzMImm B92knlTQDqe1zf2/P5koVWLzLBXteQ9gqpmV30mP8Ki2FLNeoF8= =02Rf -----END PGP SIGNATURE----- --6k5h3synwn52j6at-- From owner-dev-commits-src-all@freebsd.org Sun May 16 00:29:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D425D62C716; Sun, 16 May 2021 00:29:50 +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 4FjNSZ5WLCz4mBG; Sun, 16 May 2021 00:29:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A1D3E71AE; Sun, 16 May 2021 00:29:50 +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 14G0To61066287; Sun, 16 May 2021 00:29:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G0ToTT066286; Sun, 16 May 2021 00:29:50 GMT (envelope-from git) Date: Sun, 16 May 2021 00:29:50 GMT Message-Id: <202105160029.14G0ToTT066286@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 2e6b07866f9e - main - libalias: Ensure ASSERT behind varable declarations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e6b07866f9e1520626a1523f6609cc411bdda1c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 00:29:50 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=2e6b07866f9e1520626a1523f6609cc411bdda1c commit 2e6b07866f9e1520626a1523f6609cc411bdda1c Author: Lutz Donnerhacke AuthorDate: 2021-05-15 22:49:11 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-16 00:28:36 +0000 libalias: Ensure ASSERT behind varable declarations At some places the ASSERT was inserted before variable declarations are finished. This is fixed now. Reported by: kib Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30282 --- sys/netinet/libalias/alias.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c index cac19ab55d56..0e2756affcb4 100644 --- a/sys/netinet/libalias/alias.c +++ b/sys/netinet/libalias/alias.c @@ -290,10 +290,10 @@ static int TcpAliasOut(struct libalias *, struct ip *, int, int create); static int IcmpAliasIn1(struct libalias *la, struct ip *pip) { - LIBALIAS_LOCK_ASSERT(la); struct alias_link *lnk; struct icmp *ic; + LIBALIAS_LOCK_ASSERT(la); ic = (struct icmp *)ip_next(pip); /* Get source address from ICMP data field and restore original data */ @@ -334,13 +334,13 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip) static int IcmpAliasIn2(struct libalias *la, struct ip *pip) { - LIBALIAS_LOCK_ASSERT(la); struct ip *ip; struct icmp *ic, *ic2; struct udphdr *ud; struct tcphdr *tc; struct alias_link *lnk; + LIBALIAS_LOCK_ASSERT(la); ic = (struct icmp *)ip_next(pip); ip = &ic->icmp_ip; From owner-dev-commits-src-all@freebsd.org Sun May 16 02:17:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0681F630985; Sun, 16 May 2021 02:17:45 +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 4FjQs46mzfz3Fj5; Sun, 16 May 2021 02:17:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D13D0106E0; Sun, 16 May 2021 02:17:44 +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 14G2Hicl011710; Sun, 16 May 2021 02:17:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G2HitE011709; Sun, 16 May 2021 02:17:44 GMT (envelope-from git) Date: Sun, 16 May 2021 02:17:44 GMT Message-Id: <202105160217.14G2HitE011709@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 555baef969a1 - stable/13 - Improve UMA cache reclamation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 555baef969a17a7cbcd6af3ee5bcf854ecd4de7c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 02:17:45 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=555baef969a17a7cbcd6af3ee5bcf854ecd4de7c commit 555baef969a17a7cbcd6af3ee5bcf854ecd4de7c Author: Alexander Motin AuthorDate: 2021-05-02 23:35:28 +0000 Commit: Alexander Motin CommitDate: 2021-05-16 02:10:48 +0000 Improve UMA cache reclamation. When estimating working set size, measure only allocation batches, not free batches. Allocation and free patterns can be very different. For example, ZFS on vm_lowmem event can free to UMA few gigabytes of memory in one call, but it does not mean it will request the same amount back that fast too, in fact it won't. Update working set size on every reclamation call, shrinking caches faster under pressure. Lack of this caused repeating vm_lowmem events squeezing more and more memory out of real consumers only to make it stuck in UMA caches. I saw ZFS drop ARC size in half before previous algorithm after periodic WSS update decided to reclaim UMA caches. Introduce voluntary reclamation of UMA caches not used for a long time. For each zdom track longterm minimal cache size watermark, freeing some unused items every UMA_TIMEOUT after first 15 minutes without cache misses. Freed memory can get better use by other consumers. For example, ZFS won't grow its ARC unless it see free memory, since it does not know it is not really used. And even if memory is not really needed, periodic free during inactivity periods should reduce its fragmentation. Reviewed by: markj, jeff (previous version) MFC after: 2 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29790 (cherry picked from commit 2760658b211c654bce1dbde597bc52b49fde5d7e) --- sys/vm/uma_core.c | 179 +++++++++++++++++++++++++++++++++++++----------------- sys/vm/uma_int.h | 3 + 2 files changed, 126 insertions(+), 56 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 7e86c7c67786..410d5bb6772b 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -292,8 +292,10 @@ static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int, int, int); static void cache_drain(uma_zone_t); static void bucket_drain(uma_zone_t, uma_bucket_t); static void bucket_cache_reclaim(uma_zone_t zone, bool, int); +static bool bucket_cache_reclaim_domain(uma_zone_t, bool, bool, int); static int keg_ctor(void *, int, void *, int); static void keg_dtor(void *, int, void *); +static void keg_drain(uma_keg_t keg, int domain); static int zone_ctor(void *, int, void *, int); static void zone_dtor(void *, int, void *); static inline void item_dtor(uma_zone_t zone, void *item, int size, @@ -610,24 +612,6 @@ zone_domain_highest(uma_zone_t zone, int pref) return (domain); } -/* - * Safely subtract cnt from imax. - */ -static void -zone_domain_imax_sub(uma_zone_domain_t zdom, int cnt) -{ - long new; - long old; - - old = zdom->uzd_imax; - do { - if (old <= cnt) - new = 0; - else - new = old - cnt; - } while (atomic_fcmpset_long(&zdom->uzd_imax, &old, new) == 0); -} - /* * Set the maximum imax value. */ @@ -639,8 +623,16 @@ zone_domain_imax_set(uma_zone_domain_t zdom, int nitems) old = zdom->uzd_imax; do { if (old >= nitems) - break; + return; } while (atomic_fcmpset_long(&zdom->uzd_imax, &old, nitems) == 0); + + /* + * We are at new maximum, so do the last WSS update for the old + * bimin and prepare to measure next allocation batch. + */ + if (zdom->uzd_wss < old - zdom->uzd_bimin) + zdom->uzd_wss = old - zdom->uzd_bimin; + zdom->uzd_bimin = nitems; } /* @@ -651,6 +643,7 @@ static uma_bucket_t zone_fetch_bucket(uma_zone_t zone, uma_zone_domain_t zdom, bool reclaim) { uma_bucket_t bucket; + long cnt; int i; bool dtor = false; @@ -678,15 +671,26 @@ zone_fetch_bucket(uma_zone_t zone, uma_zone_domain_t zdom, bool reclaim) ("%s: empty bucket in bucket cache", __func__)); zdom->uzd_nitems -= bucket->ub_cnt; - /* - * Shift the bounds of the current WSS interval to avoid - * perturbing the estimate. - */ if (reclaim) { + /* + * Shift the bounds of the current WSS interval to avoid + * perturbing the estimates. + */ + cnt = lmin(zdom->uzd_bimin, bucket->ub_cnt); + atomic_subtract_long(&zdom->uzd_imax, cnt); + zdom->uzd_bimin -= cnt; zdom->uzd_imin -= lmin(zdom->uzd_imin, bucket->ub_cnt); - zone_domain_imax_sub(zdom, bucket->ub_cnt); - } else if (zdom->uzd_imin > zdom->uzd_nitems) - zdom->uzd_imin = zdom->uzd_nitems; + if (zdom->uzd_limin >= bucket->ub_cnt) { + zdom->uzd_limin -= bucket->ub_cnt; + } else { + zdom->uzd_limin = 0; + zdom->uzd_timin = 0; + } + } else if (zdom->uzd_bimin > zdom->uzd_nitems) { + zdom->uzd_bimin = zdom->uzd_nitems; + if (zdom->uzd_imin > zdom->uzd_nitems) + zdom->uzd_imin = zdom->uzd_nitems; + } ZDOM_UNLOCK(zdom); if (dtor) @@ -718,8 +722,18 @@ zone_put_bucket(uma_zone_t zone, int domain, uma_bucket_t bucket, void *udata, */ zdom->uzd_nitems += bucket->ub_cnt; if (__predict_true(zdom->uzd_nitems < zone->uz_bucket_max)) { - if (ws) + if (ws) { zone_domain_imax_set(zdom, zdom->uzd_nitems); + } else { + /* + * Shift the bounds of the current WSS interval to + * avoid perturbing the estimates. + */ + atomic_add_long(&zdom->uzd_imax, bucket->ub_cnt); + zdom->uzd_imin += bucket->ub_cnt; + zdom->uzd_bimin += bucket->ub_cnt; + zdom->uzd_limin += bucket->ub_cnt; + } if (STAILQ_EMPTY(&zdom->uzd_buckets)) zdom->uzd_seq = bucket->ub_seq; @@ -951,22 +965,49 @@ uma_timeout(void *unused) } /* - * Update the working set size estimate for the zone's bucket cache. - * The constants chosen here are somewhat arbitrary. With an update period of - * 20s (UMA_TIMEOUT), this estimate is dominated by zone activity over the - * last 100s. + * Update the working set size estimates for the zone's bucket cache. + * The constants chosen here are somewhat arbitrary. */ static void zone_domain_update_wss(uma_zone_domain_t zdom) { - long wss; + long m; - ZDOM_LOCK(zdom); - MPASS(zdom->uzd_imax >= zdom->uzd_imin); - wss = zdom->uzd_imax - zdom->uzd_imin; - zdom->uzd_imax = zdom->uzd_imin = zdom->uzd_nitems; - zdom->uzd_wss = (4 * wss + zdom->uzd_wss) / 5; - ZDOM_UNLOCK(zdom); + ZDOM_LOCK_ASSERT(zdom); + MPASS(zdom->uzd_imax >= zdom->uzd_nitems); + MPASS(zdom->uzd_nitems >= zdom->uzd_bimin); + MPASS(zdom->uzd_bimin >= zdom->uzd_imin); + + /* + * Estimate WSS as modified moving average of biggest allocation + * batches for each period over few minutes (UMA_TIMEOUT of 20s). + */ + zdom->uzd_wss = lmax(zdom->uzd_wss * 3 / 4, + zdom->uzd_imax - zdom->uzd_bimin); + + /* + * Estimate longtime minimum item count as a combination of recent + * minimum item count, adjusted by WSS for safety, and the modified + * moving average over the last several hours (UMA_TIMEOUT of 20s). + * timin measures time since limin tried to go negative, that means + * we were dangerously close to or got out of cache. + */ + m = zdom->uzd_imin - zdom->uzd_wss; + if (m >= 0) { + if (zdom->uzd_limin >= m) + zdom->uzd_limin = m; + else + zdom->uzd_limin = (m + zdom->uzd_limin * 255) / 256; + zdom->uzd_timin++; + } else { + zdom->uzd_limin = 0; + zdom->uzd_timin = 0; + } + + /* To reduce period edge effects on WSS keep half of the imax. */ + atomic_subtract_long(&zdom->uzd_imax, + (zdom->uzd_imax - zdom->uzd_nitems + 1) / 2); + zdom->uzd_imin = zdom->uzd_bimin = zdom->uzd_nitems; } /* @@ -982,7 +1023,7 @@ zone_timeout(uma_zone_t zone, void *unused) u_int slabs, pages; if ((zone->uz_flags & UMA_ZFLAG_HASH) == 0) - goto update_wss; + goto trim; keg = zone->uz_keg; @@ -1023,14 +1064,18 @@ zone_timeout(uma_zone_t zone, void *unused) KEG_UNLOCK(keg, 0); hash_free(&oldhash); - goto update_wss; + goto trim; } } KEG_UNLOCK(keg, 0); -update_wss: - for (int i = 0; i < vm_ndomains; i++) - zone_domain_update_wss(ZDOM_GET(zone, i)); +trim: + /* Trim caches not used for a long time. */ + for (int i = 0; i < vm_ndomains; i++) { + if (bucket_cache_reclaim_domain(zone, false, false, i) && + (zone->uz_flags & UMA_ZFLAG_CACHE) == 0) + keg_drain(zone->uz_keg, i); + } } /* @@ -1312,12 +1357,13 @@ pcpu_cache_drain_safe(uma_zone_t zone) * requested a drain, otherwise the per-domain caches are trimmed to either * estimated working set size. */ -static void -bucket_cache_reclaim_domain(uma_zone_t zone, bool drain, int domain) +static bool +bucket_cache_reclaim_domain(uma_zone_t zone, bool drain, bool trim, int domain) { uma_zone_domain_t zdom; uma_bucket_t bucket; long target; + bool done = false; /* * The cross bucket is partially filled and not part of @@ -1335,23 +1381,35 @@ bucket_cache_reclaim_domain(uma_zone_t zone, bool drain, int domain) /* * If we were asked to drain the zone, we are done only once - * this bucket cache is empty. Otherwise, we reclaim items in - * excess of the zone's estimated working set size. If the - * difference nitems - imin is larger than the WSS estimate, - * then the estimate will grow at the end of this interval and - * we ignore the historical average. + * this bucket cache is empty. If trim, we reclaim items in + * excess of the zone's estimated working set size. Multiple + * consecutive calls will shrink the WSS and so reclaim more. + * If neither drain nor trim, then voluntarily reclaim 1/4 + * (to reduce first spike) of items not used for a long time. */ ZDOM_LOCK(zdom); - target = drain ? 0 : lmax(zdom->uzd_wss, zdom->uzd_nitems - - zdom->uzd_imin); - while (zdom->uzd_nitems > target) { + zone_domain_update_wss(zdom); + if (drain) + target = 0; + else if (trim) + target = zdom->uzd_wss; + else if (zdom->uzd_timin > 900 / UMA_TIMEOUT) + target = zdom->uzd_nitems - zdom->uzd_limin / 4; + else { + ZDOM_UNLOCK(zdom); + return (done); + } + while ((bucket = STAILQ_FIRST(&zdom->uzd_buckets)) != NULL && + zdom->uzd_nitems >= target + bucket->ub_cnt) { bucket = zone_fetch_bucket(zone, zdom, true); if (bucket == NULL) break; bucket_free(zone, bucket, NULL); + done = true; ZDOM_LOCK(zdom); } ZDOM_UNLOCK(zdom); + return (done); } static void @@ -1368,10 +1426,10 @@ bucket_cache_reclaim(uma_zone_t zone, bool drain, int domain) if (domain != UMA_ANYDOMAIN && (zone->uz_flags & UMA_ZONE_ROUNDROBIN) == 0) { - bucket_cache_reclaim_domain(zone, drain, domain); + bucket_cache_reclaim_domain(zone, drain, true, domain); } else { for (i = 0; i < vm_ndomains; i++) - bucket_cache_reclaim_domain(zone, drain, i); + bucket_cache_reclaim_domain(zone, drain, true, i); } } @@ -2515,9 +2573,18 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) SYSCTL_ADD_LONG(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "imin", CTLFLAG_RD, &zdom->uzd_imin, "minimum item count in this period"); + SYSCTL_ADD_LONG(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "bimin", CTLFLAG_RD, &zdom->uzd_bimin, + "Minimum item count in this batch"); SYSCTL_ADD_LONG(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "wss", CTLFLAG_RD, &zdom->uzd_wss, "Working set size"); + SYSCTL_ADD_LONG(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "limin", CTLFLAG_RD, &zdom->uzd_limin, + "Long time minimum item count"); + SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "timin", CTLFLAG_RD, &zdom->uzd_timin, 0, + "Time since zero long time minimum item count"); } /* @@ -3537,7 +3604,7 @@ cache_alloc(uma_zone_t zone, uma_cache_t cache, void *udata, int flags) * We lost the race, release this bucket and start over. */ critical_exit(); - zone_put_bucket(zone, domain, bucket, udata, false); + zone_put_bucket(zone, domain, bucket, udata, !new); critical_enter(); return (true); diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index 93910e78165b..d4b43a61f29e 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -445,7 +445,10 @@ struct uma_zone_domain { long uzd_nitems; /* total item count */ long uzd_imax; /* maximum item count this period */ long uzd_imin; /* minimum item count this period */ + long uzd_bimin; /* Minimum item count this batch. */ long uzd_wss; /* working set size estimate */ + long uzd_limin; /* Longtime minimum item count. */ + u_int uzd_timin; /* Time since uzd_limin == 0. */ smr_seq_t uzd_seq; /* Lowest queued seq. */ struct mtx uzd_lock; /* Lock for the domain */ } __aligned(CACHE_LINE_SIZE); From owner-dev-commits-src-all@freebsd.org Sun May 16 02:48:25 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67CBE631773; Sun, 16 May 2021 02:48:25 +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 4FjRXT2Vxhz3K0T; Sun, 16 May 2021 02:48:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3BA0E11388; Sun, 16 May 2021 02:48:25 +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 14G2mPTq051133; Sun, 16 May 2021 02:48:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G2mPC6051132; Sun, 16 May 2021 02:48:25 GMT (envelope-from git) Date: Sun, 16 May 2021 02:48:25 GMT Message-Id: <202105160248.14G2mPC6051132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: e99210ab632b - stable/13 - cxgbe(4): Break up t4_read_chip_settings. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e99210ab632b3d74b322d4f6770315a0afe5a683 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 02:48:25 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=e99210ab632b3d74b322d4f6770315a0afe5a683 commit e99210ab632b3d74b322d4f6770315a0afe5a683 Author: Navdeep Parhar AuthorDate: 2021-02-18 09:15:46 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 02:45:16 +0000 cxgbe(4): Break up t4_read_chip_settings. Read the PF-only hardware settings directly in get_params__post_init. Split the rest into two routines used by both the PF and VF drivers: one that reads the SGE rx buffer configuration and another that verifies miscellaneous hardware configuration. Sponsored by: Chelsio Communications (cherry picked from commit fae028dd97d8fc8f9ba5153408b177481dbefd70) --- sys/dev/cxgbe/adapter.h | 3 +- sys/dev/cxgbe/common/common.h | 2 +- sys/dev/cxgbe/common/t4_hw.c | 4 +-- sys/dev/cxgbe/t4_main.c | 16 +++++++--- sys/dev/cxgbe/t4_sge.c | 72 ++++++++++++++++++++++++------------------- sys/dev/cxgbe/t4_vf.c | 9 +++--- 6 files changed, 62 insertions(+), 44 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 7bf4efae09c0..12641cb2e628 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -1270,7 +1270,8 @@ void t4_sge_modload(void); void t4_sge_modunload(void); uint64_t t4_sge_extfree_refs(void); void t4_tweak_chip_settings(struct adapter *); -int t4_read_chip_settings(struct adapter *); +int t4_verify_chip_settings(struct adapter *); +void t4_init_rx_buf_info(struct adapter *); int t4_create_dma_tag(struct adapter *); void t4_sge_sysctls(struct adapter *, struct sysctl_ctx_list *, struct sysctl_oid_list *); diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 4c387d563365..9cc923eaf2f6 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -643,7 +643,7 @@ int t4_prep_adapter(struct adapter *adapter, u32 *buf); int t4_shutdown_adapter(struct adapter *adapter); int t4_init_devlog_params(struct adapter *adapter, int fw_attach); int t4_init_sge_params(struct adapter *adapter); -int t4_init_tp_params(struct adapter *adap, bool sleep_ok); +int t4_init_tp_params(struct adapter *adap); int t4_filter_field_shift(const struct adapter *adap, int filter_sel); int t4_port_init(struct adapter *adap, int mbox, int pf, int vf, int port_id); void t4_fatal_err(struct adapter *adapter, bool fw_error); diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index 734ab7f33acb..bbf58cae97f2 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -9694,7 +9694,7 @@ static void read_filter_mode_and_ingress_config(struct adapter *adap, * * Initialize various fields of the adapter's TP Parameters structure. */ -int t4_init_tp_params(struct adapter *adap, bool sleep_ok) +int t4_init_tp_params(struct adapter *adap) { int chan; u32 tx_len, rx_len, r, v; @@ -9708,7 +9708,7 @@ int t4_init_tp_params(struct adapter *adap, bool sleep_ok) for (chan = 0; chan < MAX_NCHAN; chan++) tpp->tx_modq[chan] = chan; - read_filter_mode_and_ingress_config(adap, sleep_ok); + read_filter_mode_and_ingress_config(adap, true); if (chip_id(adap) > CHELSIO_T5) { v = t4_read_reg(adap, A_TP_OUT_CONFIG); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 3fde57786d13..d25e83922d54 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -4754,13 +4754,19 @@ get_params__post_init(struct adapter *sc) sc->vres.key.size = val[1] - val[0] + 1; } - t4_init_sge_params(sc); - /* - * We've got the params we wanted to query via the firmware. Now grab - * some others directly from the chip. + * We've got the params we wanted to query directly from the firmware. + * Grab some others via other means. */ - rc = t4_read_chip_settings(sc); + t4_init_sge_params(sc); + t4_init_tp_params(sc); + t4_read_mtu_tbl(sc, sc->params.mtus, NULL); + t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd); + + rc = t4_verify_chip_settings(sc); + if (rc != 0) + return (rc); + t4_init_rx_buf_info(sc); return (rc); } diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index a8d16352268e..42bc0c6cc7a7 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -831,16 +831,15 @@ hwsz_ok(struct adapter *sc, int hwsz) } /* - * XXX: driver really should be able to deal with unexpected settings. + * Initialize the rx buffer sizes and figure out which zones the buffers will + * be allocated from. */ -int -t4_read_chip_settings(struct adapter *sc) +void +t4_init_rx_buf_info(struct adapter *sc) { struct sge *s = &sc->sge; struct sge_params *sp = &sc->params.sge; - int i, j, n, rc = 0; - uint32_t m, v, r; - uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE); + int i, j, n; static int sw_buf_sizes[] = { /* Sorted by size */ MCLBYTES, #if MJUMPAGESIZE != MCLBYTES @@ -851,23 +850,6 @@ t4_read_chip_settings(struct adapter *sc) }; struct rx_buf_info *rxb; - m = F_RXPKTCPLMODE; - v = F_RXPKTCPLMODE; - r = sc->params.sge.sge_control; - if ((r & m) != v) { - device_printf(sc->dev, "invalid SGE_CONTROL(0x%x)\n", r); - rc = EINVAL; - } - - /* - * If this changes then every single use of PAGE_SHIFT in the driver - * needs to be carefully reviewed for PAGE_SHIFT vs sp->page_shift. - */ - if (sp->page_shift != PAGE_SHIFT) { - device_printf(sc->dev, "invalid SGE_HOST_PAGE_SIZE(0x%x)\n", r); - rc = EINVAL; - } - s->safe_zidx = -1; rxb = &s->rx_buf_info[0]; for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { @@ -912,6 +894,36 @@ t4_read_chip_settings(struct adapter *sc) if (s->safe_zidx == -1 && rxb->size1 == safest_rx_cluster) s->safe_zidx = i; } +} + +/* + * Verify some basic SGE settings for the PF and VF driver, and other + * miscellaneous settings for the PF driver. + */ +int +t4_verify_chip_settings(struct adapter *sc) +{ + struct sge_params *sp = &sc->params.sge; + uint32_t m, v, r; + int rc = 0; + const uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE); + + m = F_RXPKTCPLMODE; + v = F_RXPKTCPLMODE; + r = sp->sge_control; + if ((r & m) != v) { + device_printf(sc->dev, "invalid SGE_CONTROL(0x%x)\n", r); + rc = EINVAL; + } + + /* + * If this changes then every single use of PAGE_SHIFT in the driver + * needs to be carefully reviewed for PAGE_SHIFT vs sp->page_shift. + */ + if (sp->page_shift != PAGE_SHIFT) { + device_printf(sc->dev, "invalid SGE_HOST_PAGE_SIZE(0x%x)\n", r); + rc = EINVAL; + } if (sc->flags & IS_VF) return (0); @@ -920,14 +932,16 @@ t4_read_chip_settings(struct adapter *sc) r = t4_read_reg(sc, A_ULP_RX_TDDP_PSZ); if (r != v) { device_printf(sc->dev, "invalid ULP_RX_TDDP_PSZ(0x%x)\n", r); - rc = EINVAL; + if (sc->vres.ddp.size != 0) + rc = EINVAL; } m = v = F_TDDPTAGTCB; r = t4_read_reg(sc, A_ULP_RX_CTL); if ((r & m) != v) { device_printf(sc->dev, "invalid ULP_RX_CTL(0x%x)\n", r); - rc = EINVAL; + if (sc->vres.ddp.size != 0) + rc = EINVAL; } m = V_INDICATESIZE(M_INDICATESIZE) | F_REARMDDPOFFSET | @@ -936,14 +950,10 @@ t4_read_chip_settings(struct adapter *sc) r = t4_read_reg(sc, A_TP_PARA_REG5); if ((r & m) != v) { device_printf(sc->dev, "invalid TP_PARA_REG5(0x%x)\n", r); - rc = EINVAL; + if (sc->vres.ddp.size != 0) + rc = EINVAL; } - t4_init_tp_params(sc, 1); - - t4_read_mtu_tbl(sc, sc->params.mtus, NULL); - t4_load_mtus(sc, sc->params.mtus, sc->params.a_wnd, sc->params.b_wnd); - return (rc); } diff --git a/sys/dev/cxgbe/t4_vf.c b/sys/dev/cxgbe/t4_vf.c index 6c736e37faac..4ad5e9d7839d 100644 --- a/sys/dev/cxgbe/t4_vf.c +++ b/sys/dev/cxgbe/t4_vf.c @@ -253,10 +253,6 @@ get_params__post_init(struct adapter *sc) return (EINVAL); } - rc = t4_read_chip_settings(sc); - if (rc != 0) - return (rc); - /* * Grab our Virtual Interface resource allocation, extract the * features that we're interested in and do a bit of sanity testing on @@ -290,6 +286,11 @@ get_params__post_init(struct adapter *sc) else sc->params.max_pkts_per_eth_tx_pkts_wr = 14; + rc = t4_verify_chip_settings(sc); + if (rc != 0) + return (rc); + t4_init_rx_buf_info(sc); + return (0); } From owner-dev-commits-src-all@freebsd.org Sun May 16 02:52:13 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 978BD631A97; Sun, 16 May 2021 02:52:13 +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 4FjRcs3wdHz3Klg; Sun, 16 May 2021 02:52:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6ED331148D; Sun, 16 May 2021 02:52:13 +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 14G2qD9b064685; Sun, 16 May 2021 02:52:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G2qD7G064684; Sun, 16 May 2021 02:52:13 GMT (envelope-from git) Date: Sun, 16 May 2021 02:52:13 GMT Message-Id: <202105160252.14G2qD7G064684@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 191894573beb - stable/13 - cxgbe(4): Use firmware commands to get/set filter configuration. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 191894573bebe55287fd1f809af642552ba202a8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 02:52:13 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=191894573bebe55287fd1f809af642552ba202a8 commit 191894573bebe55287fd1f809af642552ba202a8 Author: Navdeep Parhar AuthorDate: 2021-02-19 21:05:19 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 02:50:36 +0000 cxgbe(4): Use firmware commands to get/set filter configuration. 1. Query the firmware for filter mode, mask, and related ingress config instead of trying to figure them out from hardware registers. Read configuration from the registers only when the firmware does not support this query. 2. Use the firmware to set the filter mode. This is the correct way to do it and is more flexible as well. The filter mode (and associated ingress config) can now be changed any time it is safe to do so. The user can specify a subset of a valid mode and the driver will enable enough bits to make sure that the mode is maxed out -- that is, it is not possible to set another bit without exceeding the total width for optional filter fields. This is a hardware requirement that was not enforced by the driver previously. Sponsored by: Chelsio Communications (cherry picked from commit 7ac8040a99319456c3225cd5166390f5bd172fdf) --- sys/dev/cxgbe/common/common.h | 9 +- sys/dev/cxgbe/common/t4_hw.c | 190 +++++++++++++++++++++++++------ sys/dev/cxgbe/firmware/t4fw_interface.h | 5 + sys/dev/cxgbe/t4_filter.c | 196 +++++++++++++++++++------------- sys/dev/cxgbe/t4_ioctl.h | 14 +-- sys/dev/cxgbe/tom/t4_tom.c | 2 +- 6 files changed, 287 insertions(+), 129 deletions(-) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 9cc923eaf2f6..53be2fa2588a 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -256,11 +256,11 @@ struct tp_params { unsigned int la_mask; /* what events are recorded by TP LA */ unsigned short tx_modq[MAX_NCHAN]; /* channel to modulation queue map */ - uint32_t vlan_pri_map; - uint32_t ingress_config; + uint16_t filter_mode; + uint16_t filter_mask; /* Used by TOE and hashfilters */ + int vnic_mode; uint32_t max_rx_pdu; uint32_t max_tx_pdu; - uint64_t hash_filter_mask; bool rx_pkt_encap; int8_t fcoe_shift; @@ -753,8 +753,7 @@ int t4_set_sched_ipg(struct adapter *adap, int sched, unsigned int ipg); int t4_set_pace_tbl(struct adapter *adap, const unsigned int *pace_vals, unsigned int start, unsigned int n); void t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate); -int t4_set_filter_mode(struct adapter *adap, unsigned int mode_map, - bool sleep_ok); +int t4_set_filter_cfg(struct adapter *adap, int mode, int mask, int vnic_mode); void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid); void t4_wol_magic_enable(struct adapter *adap, unsigned int port, const u8 *addr); diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index bbf58cae97f2..f4197a6a0b1b 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -9650,19 +9650,74 @@ int t4_init_sge_params(struct adapter *adapter) return 0; } +/* Convert the LE's hardware hash mask to a shorter filter mask. */ +static inline uint16_t +hashmask_to_filtermask(uint64_t hashmask, uint16_t filter_mode) +{ + static const uint8_t width[] = {1, 3, 17, 17, 8, 8, 16, 9, 3, 1}; + int i; + uint16_t filter_mask; + uint64_t mask; /* field mask */ + + filter_mask = 0; + for (i = S_FCOE; i <= S_FRAGMENTATION; i++) { + if ((filter_mode & (1 << i)) == 0) + continue; + mask = (1 << width[i]) - 1; + if ((hashmask & mask) == mask) + filter_mask |= 1 << i; + hashmask >>= width[i]; + } + + return (filter_mask); +} + /* * Read and cache the adapter's compressed filter mode and ingress config. */ -static void read_filter_mode_and_ingress_config(struct adapter *adap, - bool sleep_ok) +static void +read_filter_mode_and_ingress_config(struct adapter *adap) { - uint32_t v; + int rc; + uint32_t v, param[2], val[2]; struct tp_params *tpp = &adap->params.tp; + uint64_t hash_mask; + + param[0] = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_FILTER) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_FILTER_MODE_MASK); + param[1] = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_FILTER) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_FILTER_VNIC_MODE); + rc = -t4_query_params(adap, adap->mbox, adap->pf, 0, 2, param, val); + if (rc == 0) { + tpp->filter_mode = G_FW_PARAMS_PARAM_FILTER_MODE(val[0]); + tpp->filter_mask = G_FW_PARAMS_PARAM_FILTER_MASK(val[0]); + tpp->vnic_mode = val[1]; + } else { + /* + * Old firmware. Read filter mode/mask and ingress config + * straight from the hardware. + */ + t4_tp_pio_read(adap, &v, 1, A_TP_VLAN_PRI_MAP, true); + tpp->filter_mode = v & 0xffff; + + hash_mask = 0; + if (chip_id(adap) > CHELSIO_T4) { + v = t4_read_reg(adap, LE_HASH_MASK_GEN_IPV4T5(3)); + hash_mask = v; + v = t4_read_reg(adap, LE_HASH_MASK_GEN_IPV4T5(4)); + hash_mask |= (u64)v << 32; + } + tpp->filter_mask = hashmask_to_filtermask(hash_mask, + tpp->filter_mode); - t4_tp_pio_read(adap, &tpp->vlan_pri_map, 1, A_TP_VLAN_PRI_MAP, - sleep_ok); - t4_tp_pio_read(adap, &tpp->ingress_config, 1, A_TP_INGRESS_CONFIG, - sleep_ok); + t4_tp_pio_read(adap, &v, 1, A_TP_INGRESS_CONFIG, true); + if (v & F_VNIC) + tpp->vnic_mode = FW_VNIC_MODE_PF_VF; + else + tpp->vnic_mode = FW_VNIC_MODE_OUTER_VLAN; + } /* * Now that we have TP_VLAN_PRI_MAP cached, we can calculate the field @@ -9679,13 +9734,6 @@ static void read_filter_mode_and_ingress_config(struct adapter *adap, tpp->macmatch_shift = t4_filter_field_shift(adap, F_MACMATCH); tpp->matchtype_shift = t4_filter_field_shift(adap, F_MPSHITTYPE); tpp->frag_shift = t4_filter_field_shift(adap, F_FRAGMENTATION); - - if (chip_id(adap) > CHELSIO_T4) { - v = t4_read_reg(adap, LE_HASH_MASK_GEN_IPV4T5(3)); - adap->params.tp.hash_filter_mask = v; - v = t4_read_reg(adap, LE_HASH_MASK_GEN_IPV4T5(4)); - adap->params.tp.hash_filter_mask |= (u64)v << 32; - } } /** @@ -9708,7 +9756,7 @@ int t4_init_tp_params(struct adapter *adap) for (chan = 0; chan < MAX_NCHAN; chan++) tpp->tx_modq[chan] = chan; - read_filter_mode_and_ingress_config(adap, true); + read_filter_mode_and_ingress_config(adap); if (chip_id(adap) > CHELSIO_T5) { v = t4_read_reg(adap, A_TP_OUT_CONFIG); @@ -9745,7 +9793,7 @@ int t4_init_tp_params(struct adapter *adap) */ int t4_filter_field_shift(const struct adapter *adap, int filter_sel) { - unsigned int filter_mode = adap->params.tp.vlan_pri_map; + const unsigned int filter_mode = adap->params.tp.filter_mode; unsigned int sel; int field_shift; @@ -10816,30 +10864,98 @@ out: } /** - * t4_set_filter_mode - configure the optional components of filter tuples + * t4_set_filter_cfg - set up filter mode/mask and ingress config. * @adap: the adapter - * @mode_map: a bitmap selcting which optional filter components to enable - * @sleep_ok: if true we may sleep while awaiting command completion - * - * Sets the filter mode by selecting the optional components to enable - * in filter tuples. Returns 0 on success and a negative error if the - * requested mode needs more bits than are available for optional - * components. - */ -int t4_set_filter_mode(struct adapter *adap, unsigned int mode_map, - bool sleep_ok) -{ - static u8 width[] = { 1, 3, 17, 17, 8, 8, 16, 9, 3, 1 }; + * @mode: a bitmap selecting which optional filter components to enable + * @mask: a bitmap selecting which components to enable in filter mask + * @vnic_mode: the ingress config/vnic mode setting + * + * Sets the filter mode and mask by selecting the optional components to + * enable in filter tuples. Returns 0 on success and a negative error if + * the requested mode needs more bits than are available for optional + * components. The filter mask must be a subset of the filter mode. + */ +int t4_set_filter_cfg(struct adapter *adap, int mode, int mask, int vnic_mode) +{ + static const uint8_t width[] = {1, 3, 17, 17, 8, 8, 16, 9, 3, 1}; + int i, nbits, rc; + uint32_t param, val; + uint16_t fmode, fmask; + const int maxbits = FILTER_OPT_LEN; + + if (mode != -1 || mask != -1) { + if (mode != -1) { + fmode = mode; + nbits = 0; + for (i = S_FCOE; i <= S_FRAGMENTATION; i++) { + if (fmode & (1 << i)) + nbits += width[i]; + } + if (nbits > maxbits) { + CH_ERR(adap, "optional fields in the filter " + "mode (0x%x) add up to %d bits " + "(must be <= %db). Remove some fields and " + "try again.\n", fmode, nbits, maxbits); + return -E2BIG; + } - int i, nbits = 0; + /* + * Hardware wants the bits to be maxed out. Keep + * setting them until there's no room for more. + */ + for (i = S_FCOE; i <= S_FRAGMENTATION; i++) { + if (fmode & (1 << i)) + continue; + if (nbits + width[i] <= maxbits) { + fmode |= 1 << i; + nbits += width[i]; + if (nbits == maxbits) + break; + } + } - for (i = S_FCOE; i <= S_FRAGMENTATION; i++) - if (mode_map & (1 << i)) - nbits += width[i]; - if (nbits > FILTER_OPT_LEN) - return -EINVAL; - t4_tp_pio_write(adap, &mode_map, 1, A_TP_VLAN_PRI_MAP, sleep_ok); - read_filter_mode_and_ingress_config(adap, sleep_ok); + fmask = fmode & adap->params.tp.filter_mask; + if (fmask != adap->params.tp.filter_mask) { + CH_WARN(adap, + "filter mask will be changed from 0x%x to " + "0x%x to comply with the filter mode (0x%x).\n", + adap->params.tp.filter_mask, fmask, fmode); + } + } else { + fmode = adap->params.tp.filter_mode; + fmask = mask; + if ((fmode | fmask) != fmode) { + CH_ERR(adap, + "filter mask (0x%x) must be a subset of " + "the filter mode (0x%x).\n", fmask, fmode); + return -EINVAL; + } + } + + param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_FILTER) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_FILTER_MODE_MASK); + val = V_FW_PARAMS_PARAM_FILTER_MODE(fmode) | + V_FW_PARAMS_PARAM_FILTER_MASK(fmask); + rc = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, + &val); + if (rc < 0) + return rc; + } + + if (vnic_mode != -1) { + param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_FILTER) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_FILTER_VNIC_MODE); + val = vnic_mode; + rc = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, + &val); + if (rc < 0) + return rc; + } + + /* Refresh. */ + read_filter_mode_and_ingress_config(adap); return 0; } diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index dcec2cc122f2..30a2e1760052 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -4874,6 +4874,11 @@ enum fw_params_param_dev_diag { enum fw_params_param_dev_filter{ FW_PARAM_DEV_FILTER_VNIC_MODE = 0x00, FW_PARAM_DEV_FILTER_MODE_MASK = 0x01, + + /* VNIC modes */ + FW_VNIC_MODE_PF_VF = 0, + FW_VNIC_MODE_OUTER_VLAN = 1, + FW_VNIC_MODE_ENCAP_EN = 2, }; enum fw_params_param_dev_ktls_hw { diff --git a/sys/dev/cxgbe/t4_filter.c b/sys/dev/cxgbe/t4_filter.c index 65a87f4c4163..1e0269fcd5c0 100644 --- a/sys/dev/cxgbe/t4_filter.c +++ b/sys/dev/cxgbe/t4_filter.c @@ -231,9 +231,8 @@ filter_eq(struct t4_filter_specification *fs1, return (false); /* - * We know the masks are the same because all hashfilter masks have to - * conform to the global tp->hash_filter_mask and the driver has - * verified that already. + * We know the masks are the same because all hashfilters conform to the + * global tp->filter_mask and the driver has verified that already. */ if ((fs1->mask.pfvf_vld || fs1->mask.ovlan_vld) && @@ -325,7 +324,11 @@ remove_hftid(struct adapter *sc, struct filter_entry *f) LIST_REMOVE(f, link_tid); } -static uint32_t +/* + * Input: driver's 32b filter mode. + * Returns: hardware filter mode (bits to set in vlan_pri_map) for the input. + */ +static uint16_t mode_to_fconf(uint32_t mode) { uint32_t fconf = 0; @@ -363,13 +366,22 @@ mode_to_fconf(uint32_t mode) return (fconf); } -static uint32_t +/* + * Input: driver's 32b filter mode. + * Returns: hardware vnic mode (ingress config) matching the input. + */ +static int mode_to_iconf(uint32_t mode) { + if ((mode & T4_FILTER_VNIC) == 0) + return (-1); /* ingress config doesn't matter. */ if (mode & T4_FILTER_IC_VNIC) - return (F_VNIC); - return (0); + return (FW_VNIC_MODE_PF_VF); + else if (mode & T4_FILTER_IC_ENCAP) + return (FW_VNIC_MODE_ENCAP_EN); + else + return (FW_VNIC_MODE_OUTER_VLAN); } static int @@ -401,16 +413,24 @@ check_fspec_against_fconf_iconf(struct adapter *sc, fconf |= F_VLAN; if (fs->val.ovlan_vld || fs->mask.ovlan_vld) { - fconf |= F_VNIC_ID; - if (tpp->ingress_config & F_VNIC) + if (tpp->vnic_mode != FW_VNIC_MODE_OUTER_VLAN) return (EINVAL); + fconf |= F_VNIC_ID; } if (fs->val.pfvf_vld || fs->mask.pfvf_vld) { + if (tpp->vnic_mode != FW_VNIC_MODE_PF_VF) + return (EINVAL); fconf |= F_VNIC_ID; - if ((tpp->ingress_config & F_VNIC) == 0) + } + +#ifdef notyet + if (fs->val.encap_vld || fs->mask.encap_vld) { + if (tpp->vnic_mode != FW_VNIC_MODE_ENCAP_EN); return (EINVAL); + fconf |= F_VNIC_ID; } +#endif if (fs->val.iport || fs->mask.iport) fconf |= F_PORT; @@ -418,46 +438,70 @@ check_fspec_against_fconf_iconf(struct adapter *sc, if (fs->val.fcoe || fs->mask.fcoe) fconf |= F_FCOE; - if ((tpp->vlan_pri_map | fconf) != tpp->vlan_pri_map) + if ((tpp->filter_mode | fconf) != tpp->filter_mode) return (E2BIG); return (0); } +/* + * Input: hardware filter configuration (filter mode/mask, ingress config). + * Input: driver's 32b filter mode matching the input. + */ +static uint32_t +fconf_to_mode(uint16_t hwmode, int vnic_mode) +{ + uint32_t mode = T4_FILTER_IPv4 | T4_FILTER_IPv6 | T4_FILTER_IP_SADDR | + T4_FILTER_IP_DADDR | T4_FILTER_IP_SPORT | T4_FILTER_IP_DPORT; + + if (hwmode & F_FRAGMENTATION) + mode |= T4_FILTER_IP_FRAGMENT; + if (hwmode & F_MPSHITTYPE) + mode |= T4_FILTER_MPS_HIT_TYPE; + if (hwmode & F_MACMATCH) + mode |= T4_FILTER_MAC_IDX; + if (hwmode & F_ETHERTYPE) + mode |= T4_FILTER_ETH_TYPE; + if (hwmode & F_PROTOCOL) + mode |= T4_FILTER_IP_PROTO; + if (hwmode & F_TOS) + mode |= T4_FILTER_IP_TOS; + if (hwmode & F_VLAN) + mode |= T4_FILTER_VLAN; + if (hwmode & F_VNIC_ID) + mode |= T4_FILTER_VNIC; /* real meaning depends on vnic_mode. */ + if (hwmode & F_PORT) + mode |= T4_FILTER_PORT; + if (hwmode & F_FCOE) + mode |= T4_FILTER_FCoE; + + switch (vnic_mode) { + case FW_VNIC_MODE_PF_VF: + mode |= T4_FILTER_IC_VNIC; + break; + case FW_VNIC_MODE_ENCAP_EN: + mode |= T4_FILTER_IC_ENCAP; + break; + case FW_VNIC_MODE_OUTER_VLAN: + default: + break; + } + + return (mode); +} + int get_filter_mode(struct adapter *sc, uint32_t *mode) { struct tp_params *tp = &sc->params.tp; - uint64_t mask; + uint16_t filter_mode; - /* Non-zero incoming value in mode means "hashfilter mode". */ - mask = *mode ? tp->hash_filter_mask : UINT64_MAX; + /* Filter mask must comply with the global filter mode. */ + MPASS((tp->filter_mode | tp->filter_mask) == tp->filter_mode); - /* Always */ - *mode = T4_FILTER_IPv4 | T4_FILTER_IPv6 | T4_FILTER_IP_SADDR | - T4_FILTER_IP_DADDR | T4_FILTER_IP_SPORT | T4_FILTER_IP_DPORT; - -#define CHECK_FIELD(fconf_bit, field_shift, field_mask, mode_bit) do { \ - if (tp->vlan_pri_map & (fconf_bit)) { \ - MPASS(tp->field_shift >= 0); \ - if ((mask >> tp->field_shift & field_mask) == field_mask) \ - *mode |= (mode_bit); \ - } \ -} while (0) - - CHECK_FIELD(F_FRAGMENTATION, frag_shift, M_FT_FRAGMENTATION, T4_FILTER_IP_FRAGMENT); - CHECK_FIELD(F_MPSHITTYPE, matchtype_shift, M_FT_MPSHITTYPE, T4_FILTER_MPS_HIT_TYPE); - CHECK_FIELD(F_MACMATCH, macmatch_shift, M_FT_MACMATCH, T4_FILTER_MAC_IDX); - CHECK_FIELD(F_ETHERTYPE, ethertype_shift, M_FT_ETHERTYPE, T4_FILTER_ETH_TYPE); - CHECK_FIELD(F_PROTOCOL, protocol_shift, M_FT_PROTOCOL, T4_FILTER_IP_PROTO); - CHECK_FIELD(F_TOS, tos_shift, M_FT_TOS, T4_FILTER_IP_TOS); - CHECK_FIELD(F_VLAN, vlan_shift, M_FT_VLAN, T4_FILTER_VLAN); - CHECK_FIELD(F_VNIC_ID, vnic_shift, M_FT_VNIC_ID , T4_FILTER_VNIC); - if (tp->ingress_config & F_VNIC) - *mode |= T4_FILTER_IC_VNIC; - CHECK_FIELD(F_PORT, port_shift, M_FT_PORT , T4_FILTER_PORT); - CHECK_FIELD(F_FCOE, fcoe_shift, M_FT_FCOE , T4_FILTER_FCoE); -#undef CHECK_FIELD + /* Non-zero incoming value in mode means "hashfilter mode". */ + filter_mode = *mode ? tp->filter_mask : tp->filter_mode; + *mode = fconf_to_mode(filter_mode, tp->vnic_mode); return (0); } @@ -465,33 +509,22 @@ get_filter_mode(struct adapter *sc, uint32_t *mode) int set_filter_mode(struct adapter *sc, uint32_t mode) { - struct tp_params *tpp = &sc->params.tp; - uint32_t fconf, iconf; - int rc; + struct tp_params *tp = &sc->params.tp; + int rc, iconf; + uint16_t fconf; iconf = mode_to_iconf(mode); - if ((iconf ^ tpp->ingress_config) & F_VNIC) { - /* - * For now we just complain if A_TP_INGRESS_CONFIG is not - * already set to the correct value for the requested filter - * mode. It's not clear if it's safe to write to this register - * on the fly. (And we trust the cached value of the register). - * - * check_fspec_against_fconf_iconf and other code that looks at - * tp->vlan_pri_map and tp->ingress_config needs to be reviewed - * thorougly before allowing dynamic filter mode changes. - */ - return (EBUSY); - } - fconf = mode_to_fconf(mode); + if ((iconf == -1 || iconf == tp->vnic_mode) && fconf == tp->filter_mode) + return (0); /* Nothing to do */ - rc = begin_synchronized_op(sc, NULL, HOLD_LOCK | SLEEP_OK | INTR_OK, - "t4setfm"); + rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4setfm"); if (rc) return (rc); - if (sc->tids.ftids_in_use > 0 || sc->tids.hpftids_in_use > 0) { + if (sc->tids.ftids_in_use > 0 || /* TCAM filters active */ + sc->tids.hpftids_in_use > 0 || /* hi-pri TCAM filters active */ + sc->tids.tids_in_use > 0) { /* TOE or hashfilters active */ rc = EBUSY; goto done; } @@ -503,9 +536,10 @@ set_filter_mode(struct adapter *sc, uint32_t mode) } #endif - rc = -t4_set_filter_mode(sc, fconf, true); + /* Note that filter mask will get clipped to the new filter mode. */ + rc = -t4_set_filter_cfg(sc, fconf, -1, iconf); done: - end_synchronized_op(sc, LOCK_HELD); + end_synchronized_op(sc, 0); return (rc); } @@ -718,7 +752,7 @@ hashfilter_ntuple(struct adapter *sc, const struct t4_filter_specification *fs, uint64_t *ftuple) { struct tp_params *tp = &sc->params.tp; - uint64_t fmask; + uint16_t fmask; *ftuple = fmask = 0; @@ -727,63 +761,67 @@ hashfilter_ntuple(struct adapter *sc, const struct t4_filter_specification *fs, * in the Compressed Filter Tuple. */ if (tp->vlan_shift >= 0 && fs->mask.vlan) { - *ftuple |= (F_FT_VLAN_VLD | fs->val.vlan) << tp->vlan_shift; - fmask |= M_FT_VLAN << tp->vlan_shift; + *ftuple |= (uint64_t)(F_FT_VLAN_VLD | fs->val.vlan) << + tp->vlan_shift; + fmask |= F_VLAN; } if (tp->port_shift >= 0 && fs->mask.iport) { *ftuple |= (uint64_t)fs->val.iport << tp->port_shift; - fmask |= M_FT_PORT << tp->port_shift; + fmask |= F_PORT; } if (tp->protocol_shift >= 0 && fs->mask.proto) { *ftuple |= (uint64_t)fs->val.proto << tp->protocol_shift; - fmask |= M_FT_PROTOCOL << tp->protocol_shift; + fmask |= F_PROTOCOL; } if (tp->tos_shift >= 0 && fs->mask.tos) { *ftuple |= (uint64_t)(fs->val.tos) << tp->tos_shift; - fmask |= M_FT_TOS << tp->tos_shift; + fmask |= F_TOS; } if (tp->vnic_shift >= 0 && fs->mask.vnic) { - /* F_VNIC in ingress config was already validated. */ - if (tp->ingress_config & F_VNIC) + /* vnic_mode was already validated. */ + if (tp->vnic_mode == FW_VNIC_MODE_PF_VF) MPASS(fs->mask.pfvf_vld); - else + else if (tp->vnic_mode == FW_VNIC_MODE_OUTER_VLAN) MPASS(fs->mask.ovlan_vld); - +#ifdef notyet + else if (tp->vnic_mode == FW_VNIC_MODE_ENCAP_EN) + MPASS(fs->mask.encap_vld); +#endif *ftuple |= ((1ULL << 16) | fs->val.vnic) << tp->vnic_shift; - fmask |= M_FT_VNIC_ID << tp->vnic_shift; + fmask |= F_VNIC_ID; } if (tp->macmatch_shift >= 0 && fs->mask.macidx) { *ftuple |= (uint64_t)(fs->val.macidx) << tp->macmatch_shift; - fmask |= M_FT_MACMATCH << tp->macmatch_shift; + fmask |= F_MACMATCH; } if (tp->ethertype_shift >= 0 && fs->mask.ethtype) { *ftuple |= (uint64_t)(fs->val.ethtype) << tp->ethertype_shift; - fmask |= M_FT_ETHERTYPE << tp->ethertype_shift; + fmask |= F_ETHERTYPE; } if (tp->matchtype_shift >= 0 && fs->mask.matchtype) { *ftuple |= (uint64_t)(fs->val.matchtype) << tp->matchtype_shift; - fmask |= M_FT_MPSHITTYPE << tp->matchtype_shift; + fmask |= F_MPSHITTYPE; } if (tp->frag_shift >= 0 && fs->mask.frag) { *ftuple |= (uint64_t)(fs->val.frag) << tp->frag_shift; - fmask |= M_FT_FRAGMENTATION << tp->frag_shift; + fmask |= F_FRAGMENTATION; } if (tp->fcoe_shift >= 0 && fs->mask.fcoe) { *ftuple |= (uint64_t)(fs->val.fcoe) << tp->fcoe_shift; - fmask |= M_FT_FCOE << tp->fcoe_shift; + fmask |= F_FCOE; } - /* A hashfilter must conform to the filterMask. */ - if (fmask != tp->hash_filter_mask) + /* A hashfilter must conform to the hardware filter mask. */ + if (fmask != tp->filter_mask) return (EINVAL); return (0); diff --git a/sys/dev/cxgbe/t4_ioctl.h b/sys/dev/cxgbe/t4_ioctl.h index 1daa4f5dfa27..4f0a71683ef0 100644 --- a/sys/dev/cxgbe/t4_ioctl.h +++ b/sys/dev/cxgbe/t4_ioctl.h @@ -110,7 +110,7 @@ struct t4_i2c_data { #define T4_FILTER_IP_DPORT 0x20 /* Destination IP port */ #define T4_FILTER_FCoE 0x40 /* Fibre Channel over Ethernet packet */ #define T4_FILTER_PORT 0x80 /* Physical ingress port */ -#define T4_FILTER_VNIC 0x100 /* VNIC id or outer VLAN */ +#define T4_FILTER_VNIC 0x100 /* See the IC_* bits towards the end */ #define T4_FILTER_VLAN 0x200 /* VLAN ID */ #define T4_FILTER_IP_TOS 0x400 /* IPv4 TOS/IPv6 Traffic Class */ #define T4_FILTER_IP_PROTO 0x800 /* IP protocol */ @@ -118,12 +118,12 @@ struct t4_i2c_data { #define T4_FILTER_MAC_IDX 0x2000 /* MPS MAC address match index */ #define T4_FILTER_MPS_HIT_TYPE 0x4000 /* MPS match type */ #define T4_FILTER_IP_FRAGMENT 0x8000 /* IP fragment */ - -#define T4_FILTER_IC_VNIC 0x80000000 /* TP Ingress Config's F_VNIC - bit. It indicates whether - T4_FILTER_VNIC bit means VNIC - id (PF/VF) or outer VLAN. - 0 = oVLAN, 1 = VNIC */ +/* + * T4_FILTER_VNIC's real meaning depends on the ingress config. + */ +#define T4_FILTER_IC_OVLAN 0 /* outer VLAN */ +#define T4_FILTER_IC_VNIC 0x80000000 /* VNIC id (PF/VF) */ +#define T4_FILTER_IC_ENCAP 0x40000000 /* Filter action */ enum { diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index 0f0b4d7ee5b3..df837cc50454 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -1066,7 +1066,7 @@ select_ntuple(struct vi_info *vi, struct l2t_entry *e) if (tp->protocol_shift >= 0) ntuple |= (uint64_t)IPPROTO_TCP << tp->protocol_shift; - if (tp->vnic_shift >= 0 && tp->ingress_config & F_VNIC) { + if (tp->vnic_shift >= 0 && tp->vnic_mode == FW_VNIC_MODE_PF_VF) { ntuple |= (uint64_t)(V_FT_VNID_ID_VF(vi->vin) | V_FT_VNID_ID_PF(sc->pf) | V_FT_VNID_ID_VLD(vi->vfvld)) << tp->vnic_shift; From owner-dev-commits-src-all@freebsd.org Sun May 16 02:53:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FE356317E2; Sun, 16 May 2021 02:53: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 4FjRfm2k7nz3L3f; Sun, 16 May 2021 02:53:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3B49B1149E; Sun, 16 May 2021 02:53:52 +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 14G2rqDT064904; Sun, 16 May 2021 02:53:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G2rqIU064903; Sun, 16 May 2021 02:53:52 GMT (envelope-from git) Date: Sun, 16 May 2021 02:53:52 GMT Message-Id: <202105160253.14G2rqIU064903@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: a8076e0afdf4 - stable/13 - cxgbe(4): Add a driver ioctl to set the filter mask. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a8076e0afdf4e0af676a195708b20670ef4cb61a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 02:53:52 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=a8076e0afdf4e0af676a195708b20670ef4cb61a commit a8076e0afdf4e0af676a195708b20670ef4cb61a Author: Navdeep Parhar AuthorDate: 2021-02-19 21:47:18 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 02:53:07 +0000 cxgbe(4): Add a driver ioctl to set the filter mask. Allow the filter mask (aka the hashfilter mode when hashfilters are in use) to be set any time it is safe to do so. The requested mask must be a subset of the filter mode already. The driver will not change the mode or ingress config just to support a new mask. Sponsored by: Chelsio Communications (cherry picked from commit c91dda5ad923f24ef2e538b8dc180fa98598b4db) --- sys/dev/cxgbe/adapter.h | 1 + sys/dev/cxgbe/t4_filter.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sys/dev/cxgbe/t4_ioctl.h | 2 ++ sys/dev/cxgbe/t4_main.c | 3 +++ 4 files changed, 48 insertions(+) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 12641cb2e628..0b7ceb147708 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -1345,6 +1345,7 @@ void cxgbe_ratelimit_query(struct ifnet *, struct if_ratelimit_query_results *); /* t4_filter.c */ int get_filter_mode(struct adapter *, uint32_t *); int set_filter_mode(struct adapter *, uint32_t); +int set_filter_mask(struct adapter *, uint32_t); int get_filter(struct adapter *, struct t4_filter *); int set_filter(struct adapter *, struct t4_filter *); int del_filter(struct adapter *, struct t4_filter *); diff --git a/sys/dev/cxgbe/t4_filter.c b/sys/dev/cxgbe/t4_filter.c index 1e0269fcd5c0..3afab0d1d6b9 100644 --- a/sys/dev/cxgbe/t4_filter.c +++ b/sys/dev/cxgbe/t4_filter.c @@ -543,6 +543,48 @@ done: return (rc); } +int +set_filter_mask(struct adapter *sc, uint32_t mode) +{ + struct tp_params *tp = &sc->params.tp; + int rc, iconf; + uint16_t fmask; + + iconf = mode_to_iconf(mode); + fmask = mode_to_fconf(mode); + if ((iconf == -1 || iconf == tp->vnic_mode) && fmask == tp->filter_mask) + return (0); /* Nothing to do */ + + /* + * We aren't going to change the global filter mode or VNIC mode here. + * The given filter mask must conform to them. + */ + if ((fmask | tp->filter_mode) != tp->filter_mode) + return (EINVAL); + if (iconf != -1 && iconf != tp->vnic_mode) + return (EINVAL); + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4sethfm"); + if (rc) + return (rc); + + if (sc->tids.tids_in_use > 0) { /* TOE or hashfilters active */ + rc = EBUSY; + goto done; + } + +#ifdef TCP_OFFLOAD + if (uld_active(sc, ULD_TOM)) { + rc = EBUSY; + goto done; + } +#endif + rc = -t4_set_filter_cfg(sc, -1, fmask, -1); +done: + end_synchronized_op(sc, 0); + return (rc); +} + static inline uint64_t get_filter_hits(struct adapter *sc, uint32_t tid) { diff --git a/sys/dev/cxgbe/t4_ioctl.h b/sys/dev/cxgbe/t4_ioctl.h index 4f0a71683ef0..ff2c5ef80a14 100644 --- a/sys/dev/cxgbe/t4_ioctl.h +++ b/sys/dev/cxgbe/t4_ioctl.h @@ -63,6 +63,7 @@ enum { T4_LOAD_BOOT, /* flash boot rom */ T4_LOAD_BOOTCFG, /* flash bootcfg */ T4_CUDBG_DUMP, /* debug dump of chip state */ + T4_SET_FILTER_MASK, /* set filter mask (hashfilter mode) */ }; struct t4_reg { @@ -429,4 +430,5 @@ struct t4_offload_policy { #define CHELSIO_T4_LOAD_BOOTCFG _IOW('f', T4_LOAD_BOOTCFG, struct t4_data) #define CHELSIO_T4_CUDBG_DUMP _IOWR('f', T4_CUDBG_DUMP, struct t4_cudbg_dump) #define CHELSIO_T4_SET_OFLD_POLICY _IOW('f', T4_SET_OFLD_POLICY, struct t4_offload_policy) +#define CHELSIO_T4_SET_FILTER_MASK _IOW('f', T4_SET_FILTER_MASK, uint32_t) #endif diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index d25e83922d54..68fe25a2f62e 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -10968,6 +10968,9 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag, case CHELSIO_T4_SET_FILTER_MODE: rc = set_filter_mode(sc, *(uint32_t *)data); break; + case CHELSIO_T4_SET_FILTER_MASK: + rc = set_filter_mask(sc, *(uint32_t *)data); + break; case CHELSIO_T4_GET_FILTER: rc = get_filter(sc, (struct t4_filter *)data); break; From owner-dev-commits-src-all@freebsd.org Sun May 16 02:56:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BADA7631D14; Sun, 16 May 2021 02:56:24 +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 4FjRjh4vlbz3L9q; Sun, 16 May 2021 02:56:24 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 90B9F113B3; Sun, 16 May 2021 02:56:24 +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 14G2uOjk065208; Sun, 16 May 2021 02:56:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G2uOCo065207; Sun, 16 May 2021 02:56:24 GMT (envelope-from git) Date: Sun, 16 May 2021 02:56:24 GMT Message-Id: <202105160256.14G2uOCo065207@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d314a9f27939 - stable/13 - cxgbe(4): Use the correct filter width for T5+. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d314a9f279391d0626a57fa29b798a95ceee5698 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 02:56:24 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d314a9f279391d0626a57fa29b798a95ceee5698 commit d314a9f279391d0626a57fa29b798a95ceee5698 Author: Navdeep Parhar AuthorDate: 2021-02-19 22:18:08 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 02:54:17 +0000 cxgbe(4): Use the correct filter width for T5+. T5 and above have extra bits for the optional filter fields. This is a correctness issue and not just a waste because a filter mode valid on a T4 (36b) may not be valid on a T5+ (40b). Sponsored by: Chelsio Communications (cherry picked from commit 0460a45062dfeb98b1f1f7a3a7b9268662b61545) --- sys/dev/cxgbe/common/common.h | 1 + sys/dev/cxgbe/common/t4_hw.c | 5 ++++- sys/dev/cxgbe/common/t4_hw.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index 53be2fa2588a..e04101c9adc5 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -309,6 +309,7 @@ struct chip_params { u8 cng_ch_bits_log; /* congestion channel map bits width */ u8 nsched_cls; u8 cim_num_obq; + u8 filter_opt_len; u16 mps_rplc_size; u16 vfcount; u32 sge_fl_db; diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c index f4197a6a0b1b..bb08c55c87b2 100644 --- a/sys/dev/cxgbe/common/t4_hw.c +++ b/sys/dev/cxgbe/common/t4_hw.c @@ -9258,6 +9258,7 @@ const struct chip_params *t4_get_chip_params(int chipid) .cng_ch_bits_log = 2, .nsched_cls = 15, .cim_num_obq = CIM_NUM_OBQ, + .filter_opt_len = FILTER_OPT_LEN, .mps_rplc_size = 128, .vfcount = 128, .sge_fl_db = F_DBPRIO, @@ -9271,6 +9272,7 @@ const struct chip_params *t4_get_chip_params(int chipid) .cng_ch_bits_log = 2, .nsched_cls = 16, .cim_num_obq = CIM_NUM_OBQ_T5, + .filter_opt_len = T5_FILTER_OPT_LEN, .mps_rplc_size = 128, .vfcount = 128, .sge_fl_db = F_DBPRIO | F_DBTYPE, @@ -9284,6 +9286,7 @@ const struct chip_params *t4_get_chip_params(int chipid) .cng_ch_bits_log = 3, .nsched_cls = 16, .cim_num_obq = CIM_NUM_OBQ_T5, + .filter_opt_len = T5_FILTER_OPT_LEN, .mps_rplc_size = 256, .vfcount = 256, .sge_fl_db = 0, @@ -10881,7 +10884,7 @@ int t4_set_filter_cfg(struct adapter *adap, int mode, int mask, int vnic_mode) int i, nbits, rc; uint32_t param, val; uint16_t fmode, fmask; - const int maxbits = FILTER_OPT_LEN; + const int maxbits = adap->chip_params->filter_opt_len; if (mode != -1 || mask != -1) { if (mode != -1) { diff --git a/sys/dev/cxgbe/common/t4_hw.h b/sys/dev/cxgbe/common/t4_hw.h index 36ce6271dad6..c0625b752962 100644 --- a/sys/dev/cxgbe/common/t4_hw.h +++ b/sys/dev/cxgbe/common/t4_hw.h @@ -55,6 +55,7 @@ enum { NTRACE = 4, /* # of tracing filters */ TRACE_LEN = 112, /* length of trace data and mask */ FILTER_OPT_LEN = 36, /* filter tuple width of optional components */ + T5_FILTER_OPT_LEN = 40, NWOL_PAT = 8, /* # of WoL patterns */ WOL_PAT_LEN = 128, /* length of WoL patterns */ UDBS_SEG_SIZE = 128, /* Segment size of BAR2 doorbells */ From owner-dev-commits-src-all@freebsd.org Sun May 16 03:00:49 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6971F631925; Sun, 16 May 2021 03:00:49 +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 4FjRpn2bqdz3LVh; Sun, 16 May 2021 03:00:49 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4218F11349; Sun, 16 May 2021 03:00:49 +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 14G30ngw076429; Sun, 16 May 2021 03:00:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G30n5j076428; Sun, 16 May 2021 03:00:49 GMT (envelope-from git) Date: Sun, 16 May 2021 03:00:49 GMT Message-Id: <202105160300.14G30n5j076428@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 98893d4953da - stable/13 - cxgbetool(8): Add support for setting the hashfilter mode (filter mask). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 98893d4953da2faa0ba77248ddadf676ad8cfc6b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:00:49 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=98893d4953da2faa0ba77248ddadf676ad8cfc6b commit 98893d4953da2faa0ba77248ddadf676ad8cfc6b Author: Navdeep Parhar AuthorDate: 2021-02-19 22:22:08 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 02:57:12 +0000 cxgbetool(8): Add support for setting the hashfilter mode (filter mask). Tighten up the validation of filter modes while here. Unrecognized keywords will be now be flagged as errors instead of being ignored. (cherry picked from commit 038148c108c4e7251c52364616273eec72b0c061) --- usr.sbin/cxgbetool/cxgbetool.c | 78 +++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/usr.sbin/cxgbetool/cxgbetool.c b/usr.sbin/cxgbetool/cxgbetool.c index c852b4e9940d..139a0bd8e564 100644 --- a/usr.sbin/cxgbetool/cxgbetool.c +++ b/usr.sbin/cxgbetool/cxgbetool.c @@ -100,7 +100,7 @@ usage(FILE *fp) "\thashfilter [ ] ... set a hashfilter\n" "\thashfilter delete|clear delete a hashfilter\n" "\thashfilter list list all hashfilters\n" - "\thashfilter mode get global hashfilter mode\n" + "\thashfilter mode [] ... get/set global hashfilter mode\n" "\ti2c [] read from i2c device\n" "\tloadboot [pf|offset ] install boot image\n" "\tloadboot clear [pf|offset ] remove boot image\n" @@ -1046,6 +1046,8 @@ get_filter_mode(int hashfilter) if (mode & T4_FILTER_VNIC) { if (mode & T4_FILTER_IC_VNIC) printf("vnic_id "); + else if (mode & T4_FILTER_IC_ENCAP) + printf("encap "); else printf("ovlan "); } @@ -1062,57 +1064,69 @@ get_filter_mode(int hashfilter) } static int -set_filter_mode(int argc, const char *argv[]) +set_filter_mode(int argc, const char *argv[], int hashfilter) { uint32_t mode = 0; - int vnic = 0, ovlan = 0; + int vnic = 0, ovlan = 0, invalid = 0; for (; argc; argc--, argv++) { - if (!strcmp(argv[0], "frag")) + if (!strcmp(argv[0], "ipv4") || !strcmp(argv[0], "ipv6") || + !strcmp(argv[0], "sip") || !strcmp(argv[0], "dip") || + !strcmp(argv[0], "sport") || !strcmp(argv[0], "dport")) { + /* These are always available and enabled. */ + continue; + } else if (!strcmp(argv[0], "frag")) mode |= T4_FILTER_IP_FRAGMENT; - - if (!strcmp(argv[0], "matchtype")) + else if (!strcmp(argv[0], "matchtype")) mode |= T4_FILTER_MPS_HIT_TYPE; - - if (!strcmp(argv[0], "macidx")) + else if (!strcmp(argv[0], "macidx")) mode |= T4_FILTER_MAC_IDX; - - if (!strcmp(argv[0], "ethtype")) + else if (!strcmp(argv[0], "ethtype")) mode |= T4_FILTER_ETH_TYPE; - - if (!strcmp(argv[0], "proto")) + else if (!strcmp(argv[0], "proto")) mode |= T4_FILTER_IP_PROTO; - - if (!strcmp(argv[0], "tos")) + else if (!strcmp(argv[0], "tos")) mode |= T4_FILTER_IP_TOS; - - if (!strcmp(argv[0], "vlan")) + else if (!strcmp(argv[0], "vlan")) mode |= T4_FILTER_VLAN; - - if (!strcmp(argv[0], "ovlan")) { + else if (!strcmp(argv[0], "ovlan")) { mode |= T4_FILTER_VNIC; - ovlan++; - } - - if (!strcmp(argv[0], "vnic_id")) { + ovlan = 1; + } else if (!strcmp(argv[0], "vnic_id")) { mode |= T4_FILTER_VNIC; mode |= T4_FILTER_IC_VNIC; - vnic++; + vnic = 1; } - - if (!strcmp(argv[0], "iport")) +#ifdef notyet + else if (!strcmp(argv[0], "encap")) { + mode |= T4_FILTER_VNIC; + mode |= T4_FILTER_IC_ENCAP; + encap = 1; + } +#endif + else if (!strcmp(argv[0], "iport")) mode |= T4_FILTER_PORT; - - if (!strcmp(argv[0], "fcoe")) + else if (!strcmp(argv[0], "fcoe")) mode |= T4_FILTER_FCoE; + else { + warnx("\"%s\" is not valid while setting filter mode.", + argv[0]); + invalid++; + } } - if (vnic > 0 && ovlan > 0) { + if (vnic + ovlan > 1) { warnx("\"vnic_id\" and \"ovlan\" are mutually exclusive."); - return (EINVAL); + invalid++; } - return doit(CHELSIO_T4_SET_FILTER_MODE, &mode); + if (invalid > 0) + return (EINVAL); + + if (hashfilter) + return doit(CHELSIO_T4_SET_FILTER_MASK, &mode); + else + return doit(CHELSIO_T4_SET_FILTER_MODE, &mode); } static int @@ -1420,8 +1434,8 @@ filter_cmd(int argc, const char *argv[], int hashfilter) return get_filter_mode(hashfilter); /* mode */ - if (!hashfilter && strcmp(argv[0], "mode") == 0) - return set_filter_mode(argc - 1, argv + 1); + if (strcmp(argv[0], "mode") == 0) + return set_filter_mode(argc - 1, argv + 1, hashfilter); /* ... */ s = str_to_number(argv[0], NULL, &val); From owner-dev-commits-src-all@freebsd.org Sun May 16 03:01:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34A31631E56; Sun, 16 May 2021 03:01:31 +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 4FjRqZ5Ryqz3LxH; Sun, 16 May 2021 03:01:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8B2A1113DA; Sun, 16 May 2021 03:01:30 +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 14G31UH9080054; Sun, 16 May 2021 03:01:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G31UMP080053; Sun, 16 May 2021 03:01:30 GMT (envelope-from git) Date: Sun, 16 May 2021 03:01:30 GMT Message-Id: <202105160301.14G31UMP080053@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 7f681917602b - stable/13 - cxgbe(4): Fix an assertion that is not valid during attach. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7f681917602bac0a2a806ddff49952ca719ca4e3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:01:31 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=7f681917602bac0a2a806ddff49952ca719ca4e3 commit 7f681917602bac0a2a806ddff49952ca719ca4e3 Author: Navdeep Parhar AuthorDate: 2021-03-05 19:28:18 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:01:07 +0000 cxgbe(4): Fix an assertion that is not valid during attach. Firmware access from t4_attach takes place without any synchronization. The driver should not panic (debug kernels) if something goes wrong in early communication with the firmware. It should still load so that it's possible to poke around with cxgbetool. Sponsored by: Chelsio Communications (cherry picked from commit 4a4e9c516cfc54181264c92276301a45ea4680d4) --- sys/dev/cxgbe/t4_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 68fe25a2f62e..2d383dc082ff 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2875,7 +2875,8 @@ t4_fatal_err(struct adapter *sc, bool fw_error) log(LOG_ALERT, "%s: encountered fatal error, adapter stopped.\n", device_get_nameunit(sc->dev)); if (fw_error) { - ASSERT_SYNCHRONIZED_OP(sc); + if (sc->flags & CHK_MBOX_ACCESS) + ASSERT_SYNCHRONIZED_OP(sc); sc->flags |= ADAP_ERR; } else { ADAPTER_LOCK(sc); From owner-dev-commits-src-all@freebsd.org Sun May 16 03:02:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA0BB63219F; Sun, 16 May 2021 03:02:07 +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 4FjRrH4gl9z3M1v; Sun, 16 May 2021 03:02:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 88E5B1178E; Sun, 16 May 2021 03:02:07 +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 14G327XD080199; Sun, 16 May 2021 03:02:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G327uk080198; Sun, 16 May 2021 03:02:07 GMT (envelope-from git) Date: Sun, 16 May 2021 03:02:07 GMT Message-Id: <202105160302.14G327uk080198@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 9b9bd9345060 - stable/13 - cxgbe(4): Remove extra blank line. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9b9bd93450605e467738b539e169da1b5326e4c3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:02:07 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=9b9bd93450605e467738b539e169da1b5326e4c3 commit 9b9bd93450605e467738b539e169da1b5326e4c3 Author: Navdeep Parhar AuthorDate: 2021-03-05 20:48:39 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:01:55 +0000 cxgbe(4): Remove extra blank line. No functional change. (cherry picked from commit 765d623d606c0800f2f2689c03edecac473e30a9) --- sys/dev/cxgbe/adapter.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 0b7ceb147708..1a901d376b46 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -164,7 +164,6 @@ enum { BUF_PACKING_OK = (1 << 6), IS_VF = (1 << 7), KERN_TLS_OK = (1 << 8), - CXGBE_BUSY = (1 << 9), /* port flags */ From owner-dev-commits-src-all@freebsd.org Sun May 16 03:03:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 814996323B1; Sun, 16 May 2021 03:03:51 +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 4FjRtH31lgz3MTL; Sun, 16 May 2021 03:03:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2D65D113F3; Sun, 16 May 2021 03:03: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 14G33pvn080418; Sun, 16 May 2021 03:03:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G33psu080417; Sun, 16 May 2021 03:03:51 GMT (envelope-from git) Date: Sun, 16 May 2021 03:03:51 GMT Message-Id: <202105160303.14G33psu080417@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: af1edd87f678 - stable/13 - cxgbe(4): catch up with the latest cryptocaps. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: af1edd87f67816b109b61f31d1a27fdaafdf7d5c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:03:51 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=af1edd87f67816b109b61f31d1a27fdaafdf7d5c commit af1edd87f67816b109b61f31d1a27fdaafdf7d5c Author: Navdeep Parhar AuthorDate: 2021-03-15 19:54:34 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:02:40 +0000 cxgbe(4): catch up with the latest cryptocaps. There are two crypto capabilities that the driver didn't know about. Sponsored by: Chelsio Communications (cherry picked from commit 0b373f26bea17e4b569531b94df30e1af6a0327b) --- sys/dev/cxgbe/t4_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 2d383dc082ff..370c5dcf3ebe 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -6405,7 +6405,8 @@ static char *caps_decoder[] = { "\005INITIATOR_SSNOFLD\006TARGET_SSNOFLD" "\007T10DIF" "\010INITIATOR_CMDOFLD\011TARGET_CMDOFLD", - "\20\001LOOKASIDE\002TLSKEYS", /* 7: Crypto */ + "\20\001LOOKASIDE\002TLSKEYS\003IPSEC_INLINE" /* 7: Crypto */ + "\004TLS_HW", "\20\001INITIATOR\002TARGET\003CTRL_OFLD" /* 8: FCoE */ "\004PO_INITIATOR\005PO_TARGET", }; From owner-dev-commits-src-all@freebsd.org Sun May 16 03:07:54 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08B166324AD; Sun, 16 May 2021 03:07:54 +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 4FjRyx6tnMz3MyB; Sun, 16 May 2021 03:07:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D36EB113F5; Sun, 16 May 2021 03:07:53 +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 14G37r67080787; Sun, 16 May 2021 03:07:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G37rQC080786; Sun, 16 May 2021 03:07:53 GMT (envelope-from git) Date: Sun, 16 May 2021 03:07:53 GMT Message-Id: <202105160307.14G37rQC080786@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 564d1f6aef5e - stable/13 - cxgbe(4): use standard sysctl routines to deal with 16b values. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 564d1f6aef5e72a94e53f70b727c675481086622 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:07:54 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=564d1f6aef5e72a94e53f70b727c675481086622 commit 564d1f6aef5e72a94e53f70b727c675481086622 Author: Navdeep Parhar AuthorDate: 2021-03-19 17:56:24 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:06:35 +0000 cxgbe(4): use standard sysctl routines to deal with 16b values. These routines to handle 8b and 16b types were added in r289773 5+ years ago. Sponsored by: Chelsio Communications (cherry picked from commit 473f6163e310b773dfd7e500e255d01d7328dd16) --- sys/dev/cxgbe/adapter.h | 1 - sys/dev/cxgbe/t4_netmap.c | 30 ++++++++++++----------------- sys/dev/cxgbe/t4_sge.c | 49 ++++++++++++++++------------------------------- 3 files changed, 28 insertions(+), 52 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 1a901d376b46..21c642519d83 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -1279,7 +1279,6 @@ int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *, bus_addr_t *, void **); int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, void *); -int sysctl_uint16(SYSCTL_HANDLER_ARGS); int t4_setup_adapter_queues(struct adapter *); int t4_teardown_adapter_queues(struct adapter *); int t4_setup_vi_queues(struct vi_info *); diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index 29284d76bdda..6078dd89829d 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -168,24 +168,20 @@ alloc_nm_rxq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int intr_idx, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "rx queue"); children = SYSCTL_CHILDREN(oid); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "abs_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_abs_id, - 0, sysctl_uint16, "I", "absolute id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_cntxt_id, - 0, sysctl_uint16, "I", "SGE context id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->iq_cidx, 0, - sysctl_uint16, "I", "consumer index"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "abs_id", CTLFLAG_RD, + &nm_rxq->iq_abs_id, 0, "absolute id of the queue"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, + &nm_rxq->iq_cntxt_id, 0, "SGE context id of the queue"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, + &nm_rxq->iq_cidx, 0, "consumer index"); children = SYSCTL_CHILDREN(oid); oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "fl", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "freelist"); children = SYSCTL_CHILDREN(oid); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_rxq->fl_cntxt_id, - 0, sysctl_uint16, "I", "SGE context id of the freelist"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, + &nm_rxq->fl_cntxt_id, 0, "SGE context id of the freelist"); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, &nm_rxq->fl_cidx, 0, "consumer index"); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, @@ -252,12 +248,10 @@ alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm_txq, int iqidx, int idx, SYSCTL_ADD_UINT(&vi->ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, &nm_txq->cntxt_id, 0, "SGE context id of the queue"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_txq->cidx, 0, - sysctl_uint16, "I", "consumer index"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "pidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &nm_txq->pidx, 0, - sysctl_uint16, "I", "producer index"); + SYSCTL_ADD_U16(&vi->ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, + &nm_txq->cidx, 0, "consumer index"); + SYSCTL_ADD_U16(&vi->ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, + &nm_txq->pidx, 0, "producer index"); return (rc); } diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 42bc0c6cc7a7..9eaa72468b89 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -3734,15 +3734,12 @@ add_iq_sysctls(struct sysctl_ctx_list *ctx, struct sysctl_oid *oid, "bus address of descriptor ring"); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "dmalen", CTLFLAG_RD, NULL, iq->qsize * IQ_ESIZE, "descriptor ring size in bytes"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "abs_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &iq->abs_id, 0, - sysctl_uint16, "I", "absolute id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &iq->cntxt_id, 0, - sysctl_uint16, "I", "SGE context id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &iq->cidx, 0, - sysctl_uint16, "I", "consumer index"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "abs_id", CTLFLAG_RD, + &iq->abs_id, 0, "absolute id of the queue"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, + &iq->cntxt_id, 0, "SGE context id of the queue"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, &iq->cidx, + 0, "consumer index"); } static void @@ -3760,9 +3757,8 @@ add_fl_sysctls(struct adapter *sc, struct sysctl_ctx_list *ctx, SYSCTL_ADD_INT(ctx, children, OID_AUTO, "dmalen", CTLFLAG_RD, NULL, fl->sidx * EQ_ESIZE + sc->params.sge.spg_len, "desc ring size in bytes"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cntxt_id", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &fl->cntxt_id, 0, - sysctl_uint16, "I", "SGE context id of the freelist"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, + &fl->cntxt_id, 0, "SGE context id of the freelist"); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "padding", CTLFLAG_RD, NULL, fl_pad ? 1 : 0, "padding enabled"); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "packing", CTLFLAG_RD, NULL, @@ -4279,12 +4275,10 @@ alloc_wrq(struct adapter *sc, struct vi_info *vi, struct sge_wrq *wrq, "desc ring size in bytes"); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, &wrq->eq.cntxt_id, 0, "SGE context id of the queue"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &wrq->eq.cidx, 0, - sysctl_uint16, "I", "consumer index"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "pidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &wrq->eq.pidx, 0, - sysctl_uint16, "I", "producer index"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, + &wrq->eq.cidx, 0, "consumer index"); + SYSCTL_ADD_U16(ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, + &wrq->eq.pidx, 0, "producer index"); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "sidx", CTLFLAG_RD, NULL, wrq->eq.sidx, "status page index"); SYSCTL_ADD_UQUAD(ctx, children, OID_AUTO, "tx_wrs_direct", CTLFLAG_RD, @@ -4381,12 +4375,10 @@ alloc_txq(struct vi_info *vi, struct sge_txq *txq, int idx, &eq->abs_id, 0, "absolute id of the queue"); SYSCTL_ADD_UINT(&vi->ctx, children, OID_AUTO, "cntxt_id", CTLFLAG_RD, &eq->cntxt_id, 0, "SGE context id of the queue"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "cidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &eq->cidx, 0, - sysctl_uint16, "I", "consumer index"); - SYSCTL_ADD_PROC(&vi->ctx, children, OID_AUTO, "pidx", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, &eq->pidx, 0, - sysctl_uint16, "I", "producer index"); + SYSCTL_ADD_U16(&vi->ctx, children, OID_AUTO, "cidx", CTLFLAG_RD, + &eq->cidx, 0, "consumer index"); + SYSCTL_ADD_U16(&vi->ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, + &eq->pidx, 0, "producer index"); SYSCTL_ADD_INT(&vi->ctx, children, OID_AUTO, "sidx", CTLFLAG_RD, NULL, eq->sidx, "status page index"); @@ -6098,15 +6090,6 @@ t4_handle_wrerr_rpl(struct adapter *adap, const __be64 *rpl) return (0); } -int -sysctl_uint16(SYSCTL_HANDLER_ARGS) -{ - uint16_t *id = arg1; - int i = *id; - - return sysctl_handle_int(oidp, &i, 0, req); -} - static inline bool bufidx_used(struct adapter *sc, int idx) { From owner-dev-commits-src-all@freebsd.org Sun May 16 03:10:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2E9D863278F; Sun, 16 May 2021 03:10:31 +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 4FjS1z0nvqz3N1x; Sun, 16 May 2021 03:10:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0435B1146E; Sun, 16 May 2021 03:10:31 +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 14G3AU0O089241; Sun, 16 May 2021 03:10:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3AUtt089240; Sun, 16 May 2021 03:10:30 GMT (envelope-from git) Date: Sun, 16 May 2021 03:10:30 GMT Message-Id: <202105160310.14G3AUtt089240@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d9eb1e0c9084 - stable/13 - cxgbe(4): make it safe to call setup_memwin repeatedly. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d9eb1e0c90849b9f0f65a8dc9261ae0f187d5ff8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:10:31 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d9eb1e0c90849b9f0f65a8dc9261ae0f187d5ff8 commit d9eb1e0c90849b9f0f65a8dc9261ae0f187d5ff8 Author: Navdeep Parhar AuthorDate: 2021-03-19 19:30:57 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:08:51 +0000 cxgbe(4): make it safe to call setup_memwin repeatedly. A repeat call will recreate the memory windows in the hardware and move them to their last-known positions without repeating any of the software initialization. Sponsored by: Chelsio Communications (cherry picked from commit a1d803c162067b6cd334fc8a44a89f26cc82d83b) --- sys/dev/cxgbe/t4_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 370c5dcf3ebe..7f25d0f7bcff 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3031,16 +3031,18 @@ setup_memwin(struct adapter *sc) } for (i = 0, mw = &sc->memwin[0]; i < NUM_MEMWIN; i++, mw_init++, mw++) { - rw_init(&mw->mw_lock, "memory window access"); - mw->mw_base = mw_init->base; - mw->mw_aperture = mw_init->aperture; - mw->mw_curpos = 0; + if (!rw_initialized(&mw->mw_lock)) { + rw_init(&mw->mw_lock, "memory window access"); + mw->mw_base = mw_init->base; + mw->mw_aperture = mw_init->aperture; + mw->mw_curpos = 0; + } t4_write_reg(sc, PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_BASE_WIN, i), (mw->mw_base + bar0) | V_BIR(0) | V_WINDOW(ilog2(mw->mw_aperture) - 10)); rw_wlock(&mw->mw_lock); - position_memwin(sc, i, 0); + position_memwin(sc, i, mw->mw_curpos); rw_wunlock(&mw->mw_lock); } From owner-dev-commits-src-all@freebsd.org Sun May 16 03:11:53 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDD0F632552; Sun, 16 May 2021 03:11:53 +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 4FjS3Y5Xw8z3N31; Sun, 16 May 2021 03:11:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A627411837; Sun, 16 May 2021 03:11:53 +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 14G3BrCm090313; Sun, 16 May 2021 03:11:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3BrmP090312; Sun, 16 May 2021 03:11:53 GMT (envelope-from git) Date: Sun, 16 May 2021 03:11:53 GMT Message-Id: <202105160311.14G3BrmP090312@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 139c8bd6f3da - stable/13 - cxgbe(4): create a separate helper routine to write the global RSS key. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 139c8bd6f3da4c3cd32ddf1934094436f403e5ed Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:11:53 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=139c8bd6f3da4c3cd32ddf1934094436f403e5ed commit 139c8bd6f3da4c3cd32ddf1934094436f403e5ed Author: Navdeep Parhar AuthorDate: 2021-03-19 20:28:11 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:10:57 +0000 cxgbe(4): create a separate helper routine to write the global RSS key. While here, make sure only the PF driver attempts to program the global RSS key (with options RSS). The VF driver doesn't have access to those device registers. Sponsored by: Chelsio Communications (cherry picked from commit 3cc6f777befc2e494b39a4c0dcd91aaf99267f40) --- sys/dev/cxgbe/t4_main.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 7f25d0f7bcff..67b42dc297b3 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -5810,14 +5810,28 @@ t4_setup_intr_handlers(struct adapter *sc) return (0); } -int -adapter_full_init(struct adapter *sc) +static void +write_global_rss_key(struct adapter *sc) { - int rc, i; #ifdef RSS + int i; uint32_t raw_rss_key[RSS_KEYSIZE / sizeof(uint32_t)]; uint32_t rss_key[RSS_KEYSIZE / sizeof(uint32_t)]; + + CTASSERT(RSS_KEYSIZE == 40); + + rss_getkey((void *)&raw_rss_key[0]); + for (i = 0; i < nitems(rss_key); i++) { + rss_key[i] = htobe32(raw_rss_key[nitems(rss_key) - 1 - i]); + } + t4_write_rss_key(sc, &rss_key[0], -1, 1); #endif +} + +int +adapter_full_init(struct adapter *sc) +{ + int rc, i; ASSERT_SYNCHRONIZED_OP(sc); ADAPTER_LOCK_ASSERT_NOTOWNED(sc); @@ -5843,17 +5857,11 @@ adapter_full_init(struct adapter *sc) taskqueue_start_threads(&sc->tq[i], 1, PI_NET, "%s tq%d", device_get_nameunit(sc->dev), i); } -#ifdef RSS - MPASS(RSS_KEYSIZE == 40); - rss_getkey((void *)&raw_rss_key[0]); - for (i = 0; i < nitems(rss_key); i++) { - rss_key[i] = htobe32(raw_rss_key[nitems(rss_key) - 1 - i]); - } - t4_write_rss_key(sc, &rss_key[0], -1, 1); -#endif - if (!(sc->flags & IS_VF)) + if (!(sc->flags & IS_VF)) { + write_global_rss_key(sc); t4_intr_enable(sc); + } #ifdef KERN_TLS if (sc->flags & KERN_TLS_OK) callout_reset_sbt(&sc->ktls_tick, SBT_1MS, 0, ktls_tick, sc, From owner-dev-commits-src-all@freebsd.org Sun May 16 03:14:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4BFE063285D; Sun, 16 May 2021 03:14:10 +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 4FjS6B1jbjz3NP2; Sun, 16 May 2021 03:14:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2397F117AF; Sun, 16 May 2021 03:14:10 +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 14G3EAPK093630; Sun, 16 May 2021 03:14:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3EAIp093629; Sun, 16 May 2021 03:14:10 GMT (envelope-from git) Date: Sun, 16 May 2021 03:14:10 GMT Message-Id: <202105160314.14G3EAIp093629@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 95a3005326e9 - stable/13 - cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 95a3005326e91dfdf4c3c639b60690db3bf4ddcf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:14:10 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=95a3005326e91dfdf4c3c639b60690db3bf4ddcf commit 95a3005326e91dfdf4c3c639b60690db3bf4ddcf Author: Navdeep Parhar AuthorDate: 2021-03-24 01:01:01 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:12:11 +0000 cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode. The hw.cxgbe.kern_tls tunable was used for this in the past and if it was set then all T6 adapters would be configured for NIC TLS operation and could not be reconfigured for TOE without a reload. With this change ifconfig can be used to manipulate toe and txtls caps like any other caps. hw.cxgbe.kern_tls continues to work as usual but its effects are not permanent any more. * Enable nic_ktls_ofld in the default configuration file and use the firmware instead of direct register manipulation to apply/rollback NIC TLS configuration. This allows the driver to switch the hardware between TOE and NIC TLS mode in a safe manner. Note that the configuration is adapter-wide and not per-port. * Remove the kern_tls config file as it works with 100G T6 cards only and leads to firmware crashes with 25G cards. The configurations included with the driver (with the exception of the FPGA configs) are supposed to work with all adapters. Reported by: Veeresh U.K. at Chelsio Sponsored by: Chelsio Communications Reviewed by: jhb@ Differential Revision: https://reviews.freebsd.org/D29291 (cherry picked from commit 15f33555678300953858f6ed98dfc72c399a9139) --- sys/dev/cxgbe/adapter.h | 2 +- sys/dev/cxgbe/common/common.h | 5 + sys/dev/cxgbe/firmware/t6fw_cfg.txt | 4 +- sys/dev/cxgbe/firmware/t6fw_cfg_kern_tls.txt | 278 --------------------------- sys/dev/cxgbe/t4_clip.c | 2 +- sys/dev/cxgbe/t4_main.c | 171 ++++++++++------ sys/dev/cxgbe/t4_sge.c | 2 +- sys/dev/cxgbe/tom/t4_connect.c | 2 +- sys/dev/cxgbe/tom/t4_listen.c | 2 +- 9 files changed, 129 insertions(+), 339 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 21c642519d83..a7429c3914a8 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -163,7 +163,7 @@ enum { ADAP_ERR = (1 << 5), BUF_PACKING_OK = (1 << 6), IS_VF = (1 << 7), - KERN_TLS_OK = (1 << 8), + KERN_TLS_ON = (1 << 8), /* HW is configured for KERN_TLS */ CXGBE_BUSY = (1 << 9), /* port flags */ diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h index e04101c9adc5..6264a7d6ec07 100644 --- a/sys/dev/cxgbe/common/common.h +++ b/sys/dev/cxgbe/common/common.h @@ -499,6 +499,11 @@ static inline int is_hashfilter(const struct adapter *adap) return adap->params.hash_filter; } +static inline int is_ktls(const struct adapter *adap) +{ + return adap->cryptocaps & FW_CAPS_CONFIG_TLS_HW; +} + static inline int chip_id(struct adapter *adap) { return adap->params.chipid; diff --git a/sys/dev/cxgbe/firmware/t6fw_cfg.txt b/sys/dev/cxgbe/firmware/t6fw_cfg.txt index 6e5649642b29..1ad84f63b25f 100644 --- a/sys/dev/cxgbe/firmware/t6fw_cfg.txt +++ b/sys/dev/cxgbe/firmware/t6fw_cfg.txt @@ -161,7 +161,7 @@ nserver = 512 nhpfilter = 0 nhash = 16384 - protocol = ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside + protocol = ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, nic_ktls_ofld tp_l2t = 4096 tp_ddp = 2 tp_ddp_iscsi = 2 @@ -273,7 +273,7 @@ [fini] version = 0x1 - checksum = 0xa92352a8 + checksum = 0x5fbc0a4a # # $FreeBSD$ # diff --git a/sys/dev/cxgbe/firmware/t6fw_cfg_kern_tls.txt b/sys/dev/cxgbe/firmware/t6fw_cfg_kern_tls.txt deleted file mode 100644 index 911ebd9cff65..000000000000 --- a/sys/dev/cxgbe/firmware/t6fw_cfg_kern_tls.txt +++ /dev/null @@ -1,278 +0,0 @@ -# Firmware configuration file. -# -# Global limits (some are hardware limits, others are due to the firmware). -# nvi = 128 virtual interfaces -# niqflint = 1023 ingress queues with freelists and/or interrupts -# nethctrl = 64K Ethernet or ctrl egress queues -# neq = 64K egress queues of all kinds, including freelists -# nexactf = 512 MPS TCAM entries, can oversubscribe. - -[global] - rss_glb_config_mode = basicvirtual - rss_glb_config_options = tnlmapen,hashtoeplitz,tnlalllkp - - # PL_TIMEOUT register - pl_timeout_value = 200 # the timeout value in units of us - - sge_timer_value = 1, 5, 10, 50, 100, 200 # SGE_TIMER_VALUE* in usecs - - reg[0x10c4] = 0x20000000/0x20000000 # GK_CONTROL, enable 5th thread - - reg[0x7dc0] = 0x0e2f8849 # TP_SHIFT_CNT - - #Tick granularities in kbps - tsch_ticks = 100000, 10000, 1000, 10 - - filterMode = fragmentation, mpshittype, protocol, vlan, port, fcoe - filterMask = protocol - - tp_pmrx = 10, 512 - tp_pmrx_pagesize = 64K - - # TP number of RX channels (0 = auto) - tp_nrxch = 0 - - tp_pmtx = 10, 512 - tp_pmtx_pagesize = 64K - - # TP number of TX channels (0 = auto) - tp_ntxch = 0 - - # TP OFLD MTUs - tp_mtus = 88, 256, 512, 576, 808, 1024, 1280, 1488, 1500, 2002, 2048, 4096, 4352, 8192, 9000, 9600 - - # enable TP_OUT_CONFIG.IPIDSPLITMODE and CRXPKTENC - reg[0x7d04] = 0x00010008/0x00010008 - - # TP_GLOBAL_CONFIG - reg[0x7d08] = 0x00000800/0x00000800 # set IssFromCplEnable - - # TP_PC_CONFIG - reg[0x7d48] = 0x00000000/0x00000400 # clear EnableFLMError - - # TP_PARA_REG0 - reg[0x7d60] = 0x06000000/0x07000000 # set InitCWND to 6 - - # cluster, lan, or wan. - tp_tcptuning = lan - - # LE_DB_CONFIG - reg[0x19c04] = 0x00000000/0x00440000 # LE Server SRAM disabled - # LE IPv4 compression disabled - # LE_DB_HASH_CONFIG - reg[0x19c28] = 0x00800000/0x01f00000 # LE Hash bucket size 8, - - # ULP_TX_CONFIG - reg[0x8dc0] = 0x00000104/0x00000104 # Enable ITT on PI err - # Enable more error msg for ... - # TPT error. - - # ULP_RX_MISC_FEATURE_ENABLE - #reg[0x1925c] = 0x01003400/0x01003400 # iscsi tag pi bit - # Enable offset decrement after ... - # PI extraction and before DDP - # ulp insert pi source info in DIF - # iscsi_eff_offset_en - - #Enable iscsi completion moderation feature - reg[0x1925c] = 0x000041c0/0x000031c0 # Enable offset decrement after - # PI extraction and before DDP. - # ulp insert pi source info in - # DIF. - # Enable iscsi hdr cmd mode. - # iscsi force cmd mode. - # Enable iscsi cmp mode. - # MC configuration - #mc_mode_brc[0] = 1 # mc0 - 1: enable BRC, 0: enable RBC - -# PFs 0-3. These get 8 MSI/8 MSI-X vectors each. VFs are supported by -# these 4 PFs only. -[function "0"] - wx_caps = all - r_caps = all - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x1 - -[function "1"] - wx_caps = all - r_caps = all - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x2 - -[function "2"] - wx_caps = all - r_caps = all - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x4 - -[function "3"] - wx_caps = all - r_caps = all - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x8 - -# PF4 is the resource-rich PF that the bus/nexus driver attaches to. -# It gets 32 MSI/128 MSI-X vectors. -[function "4"] - wx_caps = all - r_caps = all - nvi = 32 - rssnvi = 32 - niqflint = 512 - nethctrl = 1024 - neq = 2048 - nqpcq = 8192 - nexactf = 456 - cmask = all - pmask = all - ncrypto_lookaside = 16 - nclip = 320 - nethofld = 8192 - - # TCAM has 6K cells; each region must start at a multiple of 128 cell. - # Each entry in these categories takes 2 cells each. nhash will use the - # TCAM iff there is room left (that is, the rest don't add up to 3072). - nfilter = 48 - nserver = 64 - nhpfilter = 0 - nhash = 524288 - protocol = ofld, tlskeys, crypto_lookaside - tp_l2t = 4096 - tp_ddp = 2 - tp_ddp_iscsi = 2 - tp_tls_key = 3 - tp_tls_mxrxsize = 17408 # 16384 + 1024, governs max rx data, pm max xfer len, rx coalesce sizes - tp_stag = 2 - tp_pbl = 5 - tp_rq = 7 - tp_srq = 128 - -# PF5 is the SCSI Controller PF. It gets 32 MSI/40 MSI-X vectors. -# Not used right now. -[function "5"] - nvi = 1 - rssnvi = 0 - -# PF6 is the FCoE Controller PF. It gets 32 MSI/40 MSI-X vectors. -# Not used right now. -[function "6"] - nvi = 1 - rssnvi = 0 - -# The following function, 1023, is not an actual PCIE function but is used to -# configure and reserve firmware internal resources that come from the global -# resource pool. -# -[function "1023"] - wx_caps = all - r_caps = all - nvi = 4 - rssnvi = 0 - cmask = all - pmask = all - nexactf = 8 - nfilter = 16 - - -# For Virtual functions, we only allow NIC functionality and we only allow -# access to one port (1 << PF). Note that because of limitations in the -# Scatter Gather Engine (SGE) hardware which checks writes to VF KDOORBELL -# and GTS registers, the number of Ingress and Egress Queues must be a power -# of 2. -# -[function "0/*"] - wx_caps = 0x82 - r_caps = 0x86 - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x1 - -[function "1/*"] - wx_caps = 0x82 - r_caps = 0x86 - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x2 - -[function "2/*"] - wx_caps = 0x82 - r_caps = 0x86 - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x1 - -[function "3/*"] - wx_caps = 0x82 - r_caps = 0x86 - nvi = 1 - rssnvi = 0 - niqflint = 2 - nethctrl = 2 - neq = 4 - nexactf = 2 - cmask = all - pmask = 0x2 - -# MPS has 192K buffer space for ingress packets from the wire as well as -# loopback path of the L2 switch. -[port "0"] - dcb = none - #bg_mem = 25 - #lpbk_mem = 25 - hwm = 60 - lwm = 15 - dwm = 30 - -[port "1"] - dcb = none - #bg_mem = 25 - #lpbk_mem = 25 - hwm = 60 - lwm = 15 - dwm = 30 - -[fini] - version = 0x1 - checksum = 0xa737b06f -# -# $FreeBSD$ -# diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index 1472ae926617..a93271103998 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -276,7 +276,7 @@ update_clip_table(struct adapter *sc) inet_ntop(AF_INET6, &ce->lip, &ip[0], sizeof(ip)); - if (sc->flags & KERN_TLS_OK || + if (sc->flags & KERN_TLS_ON || sc->active_ulds != 0) { log(LOG_ERR, "%s: could not add %s (%d)\n", diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 67b42dc297b3..284f20f9e183 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -812,9 +812,12 @@ static int read_card_mem(struct adapter *, int, struct t4_mem_range *); static int read_i2c(struct adapter *, struct t4_i2c_data *); static int clear_stats(struct adapter *, u_int); #ifdef TCP_OFFLOAD -static int toe_capability(struct vi_info *, int); +static int toe_capability(struct vi_info *, bool); static void t4_async_event(void *, int); #endif +#ifdef KERN_TLS +static int ktls_capability(struct adapter *, bool); +#endif static int mod_event(module_t, int, void *); static int notify_siblings(device_t, int); @@ -1838,7 +1841,7 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) } #ifdef TCP_OFFLOAD - if (vi->nofldrxq != 0 && (sc->flags & KERN_TLS_OK) == 0) + if (vi->nofldrxq != 0) ifp->if_capabilities |= IFCAP_TOE; #endif #ifdef RATELIMIT @@ -1859,9 +1862,10 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) #endif ifp->if_hw_tsomaxsegsize = 65536; #ifdef KERN_TLS - if (sc->flags & KERN_TLS_OK) { + if (is_ktls(sc)) { ifp->if_capabilities |= IFCAP_TXTLS; - ifp->if_capenable |= IFCAP_TXTLS; + if (sc->flags & KERN_TLS_ON) + ifp->if_capenable |= IFCAP_TXTLS; } #endif @@ -2186,8 +2190,15 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data) ifp->if_capenable ^= IFCAP_MEXTPG; #ifdef KERN_TLS - if (mask & IFCAP_TXTLS) + if (mask & IFCAP_TXTLS) { + int enable = (ifp->if_capenable ^ mask) & IFCAP_TXTLS; + + rc = ktls_capability(sc, enable); + if (rc != 0) + goto fail; + ifp->if_capenable ^= (mask & IFCAP_TXTLS); + } #endif if (mask & IFCAP_VXLAN_HWCSUM) { ifp->if_capenable ^= IFCAP_VXLAN_HWCSUM; @@ -4782,47 +4793,36 @@ ktls_tick(void *arg) uint32_t tstamp; sc = arg; - - tstamp = tcp_ts_getticks(); - t4_write_reg(sc, A_TP_SYNC_TIME_HI, tstamp >> 1); - t4_write_reg(sc, A_TP_SYNC_TIME_LO, tstamp << 31); - + if (sc->flags & KERN_TLS_ON) { + tstamp = tcp_ts_getticks(); + t4_write_reg(sc, A_TP_SYNC_TIME_HI, tstamp >> 1); + t4_write_reg(sc, A_TP_SYNC_TIME_LO, tstamp << 31); + } callout_schedule_sbt(&sc->ktls_tick, SBT_1MS, 0, C_HARDCLOCK); } -static void -t4_enable_kern_tls(struct adapter *sc) +static int +t4_config_kern_tls(struct adapter *sc, bool enable) { - uint32_t m, v; - - m = F_ENABLECBYP; - v = F_ENABLECBYP; - t4_set_reg_field(sc, A_TP_PARA_REG6, m, v); - - m = F_CPL_FLAGS_UPDATE_EN | F_SEQ_UPDATE_EN; - v = F_CPL_FLAGS_UPDATE_EN | F_SEQ_UPDATE_EN; - t4_set_reg_field(sc, A_ULP_TX_CONFIG, m, v); - - m = F_NICMODE; - v = F_NICMODE; - t4_set_reg_field(sc, A_TP_IN_CONFIG, m, v); - - m = F_LOOKUPEVERYPKT; - v = 0; - t4_set_reg_field(sc, A_TP_INGRESS_CONFIG, m, v); - - m = F_TXDEFERENABLE | F_DISABLEWINDOWPSH | F_DISABLESEPPSHFLAG; - v = F_DISABLEWINDOWPSH; - t4_set_reg_field(sc, A_TP_PC_CONFIG, m, v); + int rc; + uint32_t param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_KTLS_HW) | + V_FW_PARAMS_PARAM_Y(enable ? 1 : 0) | + V_FW_PARAMS_PARAM_Z(FW_PARAMS_PARAM_DEV_KTLS_HW_USER_ENABLE); - m = V_TIMESTAMPRESOLUTION(M_TIMESTAMPRESOLUTION); - v = V_TIMESTAMPRESOLUTION(0x1f); - t4_set_reg_field(sc, A_TP_TIMER_RESOLUTION, m, v); + rc = -t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, ¶m); + if (rc != 0) { + CH_ERR(sc, "failed to %s NIC TLS: %d\n", + enable ? "enable" : "disable", rc); + return (rc); + } - sc->flags |= KERN_TLS_OK; + if (enable) + sc->flags |= KERN_TLS_ON; + else + sc->flags &= ~KERN_TLS_ON; - sc->tlst.inline_keys = t4_tls_inline_keys; - sc->tlst.combo_wrs = t4_tls_combo_wrs; + return (rc); } #endif @@ -4936,18 +4936,19 @@ set_params__post_init(struct adapter *sc) #ifdef KERN_TLS if (sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS && sc->toecaps & FW_CAPS_CONFIG_TOE) { - if (t4_kern_tls != 0) - t4_enable_kern_tls(sc); - else { - /* - * Limit TOE connections to 2 reassembly - * "islands". This is required for TOE TLS - * connections to downgrade to plain TOE - * connections if an unsupported TLS version - * or ciphersuite is used. - */ - t4_tp_wr_bits_indirect(sc, A_TP_FRAG_CONFIG, - V_PASSMODE(M_PASSMODE), V_PASSMODE(2)); + /* + * Limit TOE connections to 2 reassembly "islands". This is + * required for TOE TLS connections to downgrade to plain TOE + * connections if an unsupported TLS version or ciphersuite is + * used. + */ + t4_tp_wr_bits_indirect(sc, A_TP_FRAG_CONFIG, + V_PASSMODE(M_PASSMODE), V_PASSMODE(2)); + if (is_ktls(sc)) { + sc->tlst.inline_keys = t4_tls_inline_keys; + sc->tlst.combo_wrs = t4_tls_combo_wrs; + if (t4_kern_tls != 0) + t4_config_kern_tls(sc, true); } } #endif @@ -5863,7 +5864,7 @@ adapter_full_init(struct adapter *sc) t4_intr_enable(sc); } #ifdef KERN_TLS - if (sc->flags & KERN_TLS_OK) + if (is_ktls(sc)) callout_reset_sbt(&sc->ktls_tick, SBT_1MS, 0, ktls_tick, sc, C_HARDCLOCK); #endif @@ -6753,7 +6754,7 @@ t4_sysctls(struct adapter *sc) } #ifdef KERN_TLS - if (sc->flags & KERN_TLS_OK) { + if (is_ktls(sc)) { /* * dev.t4nex.0.tls. */ @@ -11043,7 +11044,7 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag, #ifdef TCP_OFFLOAD static int -toe_capability(struct vi_info *vi, int enable) +toe_capability(struct vi_info *vi, bool enable) { int rc; struct port_info *pi = vi->pi; @@ -11055,6 +11056,39 @@ toe_capability(struct vi_info *vi, int enable) return (ENODEV); if (enable) { +#ifdef KERN_TLS + if (sc->flags & KERN_TLS_ON) { + int i, j, n; + struct port_info *p; + struct vi_info *v; + + /* + * Reconfigure hardware for TOE if TXTLS is not enabled + * on any ifnet. + */ + n = 0; + for_each_port(sc, i) { + p = sc->port[i]; + for_each_vi(p, j, v) { + if (v->ifp->if_capenable & IFCAP_TXTLS) { + CH_WARN(sc, + "%s has NIC TLS enabled.\n", + device_get_nameunit(v->dev)); + n++; + } + } + } + if (n > 0) { + CH_WARN(sc, "Disable NIC TLS on all interfaces " + "associated with this adapter before " + "trying to enable TOE.\n"); + return (EAGAIN); + } + rc = t4_config_kern_tls(sc, false); + if (rc) + return (rc); + } +#endif if ((vi->ifp->if_capenable & IFCAP_TOE) != 0) { /* TOE is already enabled. */ return (0); @@ -11263,6 +11297,35 @@ uld_active(struct adapter *sc, int uld_id) } #endif +#ifdef KERN_TLS +static int +ktls_capability(struct adapter *sc, bool enable) +{ + ASSERT_SYNCHRONIZED_OP(sc); + + if (!is_ktls(sc)) + return (ENODEV); + + if (enable) { + if (sc->flags & KERN_TLS_ON) + return (0); /* already on */ + if (sc->offload_map != 0) { + CH_WARN(sc, + "Disable TOE on all interfaces associated with " + "this adapter before trying to enable NIC TLS.\n"); + return (EAGAIN); + } + return (t4_config_kern_tls(sc, true)); + } else { + /* + * Nothing to do for disable. If TOE is enabled sometime later + * then toe_capability will reconfigure the hardware. + */ + return (0); + } +} +#endif + /* * t = ptr to tunable. * nc = number of CPUs. diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 9eaa72468b89..2c7e8f348331 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4423,7 +4423,7 @@ alloc_txq(struct vi_info *vi, struct sge_txq *txq, int idx, "# of times hardware assisted with inner checksums (VXLAN)"); #ifdef KERN_TLS - if (sc->flags & KERN_TLS_OK) { + if (is_ktls(sc)) { SYSCTL_ADD_UQUAD(&vi->ctx, children, OID_AUTO, "kern_tls_records", CTLFLAG_RD, &txq->kern_tls_records, "# of NIC TLS records transmitted"); diff --git a/sys/dev/cxgbe/tom/t4_connect.c b/sys/dev/cxgbe/tom/t4_connect.c index c285b6fc41fa..c71b9694bd3b 100644 --- a/sys/dev/cxgbe/tom/t4_connect.c +++ b/sys/dev/cxgbe/tom/t4_connect.c @@ -256,7 +256,7 @@ t4_connect(struct toedev *tod, struct socket *so, struct nhop_object *nh, DONT_OFFLOAD_ACTIVE_OPEN(ENOSYS); /* XXX: implement lagg+TOE */ else DONT_OFFLOAD_ACTIVE_OPEN(ENOTSUP); - if (sc->flags & KERN_TLS_OK) + if (sc->flags & KERN_TLS_ON) DONT_OFFLOAD_ACTIVE_OPEN(ENOTSUP); rw_rlock(&sc->policy_lock); diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c index 126af9a1f20f..9cf527925fcc 100644 --- a/sys/dev/cxgbe/tom/t4_listen.c +++ b/sys/dev/cxgbe/tom/t4_listen.c @@ -539,7 +539,7 @@ t4_listen_start(struct toedev *tod, struct tcpcb *tp) if (!(inp->inp_vflag & INP_IPV6) && IN_LOOPBACK(ntohl(inp->inp_laddr.s_addr))) return (0); - if (sc->flags & KERN_TLS_OK) + if (sc->flags & KERN_TLS_ON) return (0); #if 0 ADAPTER_LOCK(sc); From owner-dev-commits-src-all@freebsd.org Sun May 16 03:19:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF9D96327E5; Sun, 16 May 2021 03:19:44 +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 4FjSDc6RWBz3NyQ; Sun, 16 May 2021 03:19:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C50AD11B08; Sun, 16 May 2021 03:19:44 +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 14G3Jisv094101; Sun, 16 May 2021 03:19:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3Jieb094100; Sun, 16 May 2021 03:19:44 GMT (envelope-from git) Date: Sun, 16 May 2021 03:19:44 GMT Message-Id: <202105160319.14G3Jieb094100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 248bc9784a2c - stable/13 - cxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 248bc9784a2c17814fb2e3651bf266ffb354d2aa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:19:45 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=248bc9784a2c17814fb2e3651bf266ffb354d2aa commit 248bc9784a2c17814fb2e3651bf266ffb354d2aa Author: Navdeep Parhar AuthorDate: 2021-03-30 04:35:05 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:18:42 +0000 cxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT. This fixes a panic due to stale so->so_proto if t4_tom is unloaded and one or more connections that were previously offloaded are still around in TIME_WAIT state. Reviewed by: jhb@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29503 (cherry picked from commit 539489326947f2873f21b292941f8e5551f7c17b) --- sys/dev/cxgbe/tom/t4_cpl_io.c | 2 ++ sys/dev/cxgbe/tom/t4_tom.c | 14 ++++++++++++-- sys/dev/cxgbe/tom/t4_tom.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index e12354a0b1eb..1e50bf860787 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1263,6 +1263,7 @@ do_peer_close(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) break; case TCPS_FIN_WAIT_2: + restore_so_proto(so, inp->inp_vflag & INP_IPV6); tcp_twstart(tp); INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the inp */ NET_EPOCH_EXIT(et); @@ -1323,6 +1324,7 @@ do_close_con_rpl(struct sge_iq *iq, const struct rss_header *rss, switch (tp->t_state) { case TCPS_CLOSING: /* see TCPS_FIN_WAIT_2 in do_peer_close too */ + restore_so_proto(so, inp->inp_vflag & INP_IPV6); tcp_twstart(tp); release: INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the inp */ diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index df837cc50454..6a4b5e8f261e 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -79,9 +79,11 @@ __FBSDID("$FreeBSD$"); #include "tom/t4_tom.h" #include "tom/t4_tls.h" +static struct protosw *tcp_protosw; static struct protosw toe_protosw; static struct pr_usrreqs toe_usrreqs; +static struct protosw *tcp6_protosw; static struct protosw toe6_protosw; static struct pr_usrreqs toe6_usrreqs; @@ -263,6 +265,15 @@ offload_socket(struct socket *so, struct toepcb *toep) mtx_unlock(&td->toep_list_lock); } +void +restore_so_proto(struct socket *so, bool v6) +{ + if (v6) + so->so_proto = tcp6_protosw; + else + so->so_proto = tcp_protosw; +} + /* This is _not_ the normal way to "unoffload" a socket. */ void undo_offload_socket(struct socket *so) @@ -282,6 +293,7 @@ undo_offload_socket(struct socket *so) sb = &so->so_rcv; SOCKBUF_LOCK(sb); sb->sb_flags &= ~SB_NOCOALESCE; + restore_so_proto(so, inp->inp_vflag & INP_IPV6); SOCKBUF_UNLOCK(sb); tp->tod = NULL; @@ -1837,8 +1849,6 @@ t4_ctloutput_tom(struct socket *so, struct sockopt *sopt) static int t4_tom_mod_load(void) { - struct protosw *tcp_protosw, *tcp6_protosw; - /* CPL handlers */ t4_register_cpl_handler(CPL_GET_TCB_RPL, do_get_tcb_rpl); t4_register_shared_cpl_handler(CPL_L2T_WRITE_RPL, do_l2t_write_rpl2, diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index 628857cfae17..68b3d29295f8 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -352,6 +352,7 @@ int init_toepcb(struct vi_info *, struct toepcb *); struct toepcb *hold_toepcb(struct toepcb *); void free_toepcb(struct toepcb *); void offload_socket(struct socket *, struct toepcb *); +void restore_so_proto(struct socket *, bool); void undo_offload_socket(struct socket *); void final_cpl_received(struct toepcb *); void insert_tid(struct adapter *, int, void *, int); From owner-dev-commits-src-all@freebsd.org Sun May 16 03:25:03 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6316B632DCA; Sun, 16 May 2021 03:25:03 +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 4FjSLl2P3yz3Psy; Sun, 16 May 2021 03:25:03 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 3A5EB119C4; Sun, 16 May 2021 03:25:03 +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 14G3P310006818; Sun, 16 May 2021 03:25:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3P339006817; Sun, 16 May 2021 03:25:03 GMT (envelope-from git) Date: Sun, 16 May 2021 03:25:03 GMT Message-Id: <202105160325.14G3P339006817@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: e0897d666922 - stable/13 - cxgbe(4): Always use the per-VI callout to read interface stats. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e0897d6669224612e53e140ddfac571e369bbba6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:25:03 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=e0897d6669224612e53e140ddfac571e369bbba6 commit e0897d6669224612e53e140ddfac571e369bbba6 Author: Navdeep Parhar AuthorDate: 2021-04-01 07:57:19 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:21:58 +0000 cxgbe(4): Always use the per-VI callout to read interface stats. There is no change in the source of the stats (t4_get_port_stats or t4_get_vi_stats) but the per-port callout is gone. Sponsored by: Chelsio Communications Reviewed by: jhb@ Differential Revision: https://reviews.freebsd.org/D29527 (cherry picked from commit 516fe911a6b7a2d2f245ebbc7837e5dc2e353703) --- sys/dev/cxgbe/adapter.h | 5 ++--- sys/dev/cxgbe/t4_main.c | 46 +++++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index a7429c3914a8..c46f9626b95b 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -237,8 +237,9 @@ struct vi_info { struct timeval last_refreshed; struct fw_vi_stats_vf stats; - + struct mtx tick_mtx; struct callout tick; + struct sysctl_ctx_list ctx; /* from ifconfig up to driver detach */ uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */ @@ -316,8 +317,6 @@ struct port_info { u_int tx_parse_error; int fcs_reg; uint64_t fcs_base; - - struct callout tick; }; #define IS_MAIN_VI(vi) ((vi) == &((vi)->pi->vi[0])) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 284f20f9e183..ce439b94aa6c 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1797,7 +1797,8 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) struct adapter *sc = vi->adapter; vi->xact_addr_filt = -1; - callout_init(&vi->tick, 1); + mtx_init(&vi->tick_mtx, "vi tick", NULL, MTX_DEF); + callout_init_mtx(&vi->tick, &vi->tick_mtx, 0); if (sc->flags & IS_VF || t4_tx_vm_wr != 0) vi->flags |= TX_USES_VM_WR; @@ -1921,8 +1922,6 @@ cxgbe_attach(device_t dev) struct vi_info *vi; int i, rc; - callout_init_mtx(&pi->tick, &pi->pi_lock, 0); - rc = cxgbe_vi_attach(dev, &pi->vi[0]); if (rc) return (rc); @@ -1991,7 +1990,6 @@ cxgbe_detach(device_t dev) } cxgbe_vi_detach(&pi->vi[0]); - callout_drain(&pi->tick); ifmedia_removeall(&pi->media); end_synchronized_op(sc, 0); @@ -5583,14 +5581,16 @@ cxgbe_init_synchronized(struct vi_info *vi) /* all ok */ pi->up_vis++; ifp->if_drv_flags |= IFF_DRV_RUNNING; + if (pi->link_cfg.link_ok) + t4_os_link_changed(pi); + PORT_UNLOCK(pi); + mtx_lock(&vi->tick_mtx); if (pi->nvi > 1 || sc->flags & IS_VF) callout_reset(&vi->tick, hz, vi_tick, vi); else - callout_reset(&pi->tick, hz, cxgbe_tick, pi); - if (pi->link_cfg.link_ok) - t4_os_link_changed(pi); - PORT_UNLOCK(pi); + callout_reset(&vi->tick, hz, cxgbe_tick, vi); + mtx_unlock(&vi->tick_mtx); done: if (rc != 0) cxgbe_uninit_synchronized(vi); @@ -5642,11 +5642,11 @@ cxgbe_uninit_synchronized(struct vi_info *vi) TXQ_UNLOCK(txq); } + mtx_lock(&vi->tick_mtx); + callout_stop(&vi->tick); + mtx_unlock(&vi->tick_mtx); + PORT_LOCK(pi); - if (pi->nvi > 1 || sc->flags & IS_VF) - callout_stop(&vi->tick); - else - callout_stop(&pi->tick); if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { PORT_UNLOCK(pi); return (0); @@ -6277,11 +6277,11 @@ read_vf_stat(struct adapter *sc, u_int vin, int reg) { u32 stats[2]; - mtx_assert(&sc->reg_lock, MA_OWNED); if (sc->flags & IS_VF) { stats[0] = t4_read_reg(sc, VF_MPS_REG(reg)); stats[1] = t4_read_reg(sc, VF_MPS_REG(reg + 4)); } else { + mtx_assert(&sc->reg_lock, MA_OWNED); t4_write_reg(sc, A_PL_INDIR_CMD, V_PL_AUTOINC(1) | V_PL_VFID(vin) | V_PL_ADDR(VF_MPS_REG(reg))); stats[0] = t4_read_reg(sc, A_PL_INDIR_DATA); @@ -6297,6 +6297,8 @@ t4_get_vi_stats(struct adapter *sc, u_int vin, struct fw_vi_stats_vf *stats) #define GET_STAT(name) \ read_vf_stat(sc, vin, A_MPS_VF_STAT_##name##_L) + if (!(sc->flags & IS_VF)) + mtx_lock(&sc->reg_lock); stats->tx_bcast_bytes = GET_STAT(TX_VF_BCAST_BYTES); stats->tx_bcast_frames = GET_STAT(TX_VF_BCAST_FRAMES); stats->tx_mcast_bytes = GET_STAT(TX_VF_MCAST_BYTES); @@ -6313,6 +6315,8 @@ t4_get_vi_stats(struct adapter *sc, u_int vin, struct fw_vi_stats_vf *stats) stats->rx_ucast_bytes = GET_STAT(RX_VF_UCAST_BYTES); stats->rx_ucast_frames = GET_STAT(RX_VF_UCAST_FRAMES); stats->rx_err_frames = GET_STAT(RX_VF_ERR_FRAMES); + if (!(sc->flags & IS_VF)) + mtx_unlock(&sc->reg_lock); #undef GET_STAT } @@ -6343,10 +6347,8 @@ vi_refresh_stats(struct adapter *sc, struct vi_info *vi) if (timevalcmp(&tv, &vi->last_refreshed, <)) return; - mtx_lock(&sc->reg_lock); t4_get_vi_stats(sc, vi->vin, &vi->stats); getmicrotime(&vi->last_refreshed); - mtx_unlock(&sc->reg_lock); } static void @@ -6380,13 +6382,14 @@ cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) static void cxgbe_tick(void *arg) { - struct port_info *pi = arg; - struct adapter *sc = pi->adapter; + struct vi_info *vi = arg; + struct adapter *sc = vi->adapter; - PORT_LOCK_ASSERT_OWNED(pi); - cxgbe_refresh_stats(sc, pi); + MPASS(IS_MAIN_VI(vi)); + mtx_assert(&vi->tick_mtx, MA_OWNED); - callout_schedule(&pi->tick, hz); + cxgbe_refresh_stats(sc, vi->pi); + callout_schedule(&vi->tick, hz); } void @@ -6395,8 +6398,9 @@ vi_tick(void *arg) struct vi_info *vi = arg; struct adapter *sc = vi->adapter; - vi_refresh_stats(sc, vi); + mtx_assert(&vi->tick_mtx, MA_OWNED); + vi_refresh_stats(sc, vi); callout_schedule(&vi->tick, hz); } From owner-dev-commits-src-all@freebsd.org Sun May 16 03:25:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85199632AC5; Sun, 16 May 2021 03:25:04 +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 4FjSLm39vYz3Plh; Sun, 16 May 2021 03:25:04 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 547A111D0E; Sun, 16 May 2021 03:25:04 +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 14G3P4Xi006839; Sun, 16 May 2021 03:25:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3P4ek006838; Sun, 16 May 2021 03:25:04 GMT (envelope-from git) Date: Sun, 16 May 2021 03:25:04 GMT Message-Id: <202105160325.14G3P4ek006838@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 81ec0d054652 - stable/13 - cxgbe/tom: Fix potential leak in t4_aiotx_process_job. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 81ec0d0546522af8e1870d11e162e5b479e90640 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:25:04 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=81ec0d0546522af8e1870d11e162e5b479e90640 commit 81ec0d0546522af8e1870d11e162e5b479e90640 Author: Navdeep Parhar AuthorDate: 2021-04-04 22:04:31 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:24:06 +0000 cxgbe/tom: Fix potential leak in t4_aiotx_process_job. The mbuf allocated could be a chain and must be freed with m_freem. Reviewed by: jhb@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D29579 (cherry picked from commit bf5057691bb0d1160d729772cdb4c449e366f5b4) --- sys/dev/cxgbe/tom/t4_cpl_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 1e50bf860787..ee40d0646b71 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -2204,8 +2204,7 @@ out: job->aio_error = (void *)(intptr_t)error; aiotx_free_job(job); } - if (m != NULL) - m_free(m); + m_freem(m); SOCKBUF_LOCK(sb); } From owner-dev-commits-src-all@freebsd.org Sun May 16 03:26:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 01157632AE4; Sun, 16 May 2021 03:26:38 +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 4FjSNY6clWz3Ptl; Sun, 16 May 2021 03:26:37 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CB559119C5; Sun, 16 May 2021 03:26:37 +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 14G3Qbre007049; Sun, 16 May 2021 03:26:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3Qb0m007048; Sun, 16 May 2021 03:26:37 GMT (envelope-from git) Date: Sun, 16 May 2021 03:26:37 GMT Message-Id: <202105160326.14G3Qb0m007048@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 9b107d9ef469 - stable/13 - cxgbe(4): make the logging helpers a little more robust. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9b107d9ef469b3d9e7479b9bc6f4a7b9b9f0334c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:26:38 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=9b107d9ef469b3d9e7479b9bc6f4a7b9b9f0334c commit 9b107d9ef469b3d9e7479b9bc6f4a7b9b9f0334c Author: Navdeep Parhar AuthorDate: 2021-04-22 22:28:43 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:26:22 +0000 cxgbe(4): make the logging helpers a little more robust. Sponsored by: Chelsio Communications (cherry picked from commit 8f1bc78ef79bc13d88d15cdc5b1bf2f7361ded6d) --- sys/dev/cxgbe/osdep.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/cxgbe/osdep.h b/sys/dev/cxgbe/osdep.h index 95c93d83cff8..3f41ccaf3d2c 100644 --- a/sys/dev/cxgbe/osdep.h +++ b/sys/dev/cxgbe/osdep.h @@ -43,13 +43,13 @@ #include #define CH_ERR(adap, fmt, ...) log(LOG_ERR, "%s: " fmt, \ - device_get_nameunit(adap->dev), ##__VA_ARGS__) + device_get_nameunit((adap)->dev), ##__VA_ARGS__) #define CH_WARN(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \ - device_get_nameunit(adap->dev), ##__VA_ARGS__) + device_get_nameunit((adap)->dev), ##__VA_ARGS__) #define CH_ALERT(adap, fmt, ...) log(LOG_ALERT, "%s: " fmt, \ - device_get_nameunit(adap->dev), ##__VA_ARGS__) + device_get_nameunit((adap)->dev), ##__VA_ARGS__) #define CH_WARN_RATELIMIT(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \ - device_get_nameunit(adap->dev), ##__VA_ARGS__) + device_get_nameunit((adap)->dev), ##__VA_ARGS__) #ifndef LINUX_TYPES_DEFINED typedef int8_t s8; From owner-dev-commits-src-all@freebsd.org Sun May 16 03:27:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1349B632E32; Sun, 16 May 2021 03:27:10 +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 4FjSP973Hfz3Q09; Sun, 16 May 2021 03:27:09 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 DA9A9119C6; Sun, 16 May 2021 03:27:09 +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 14G3R9NH007194; Sun, 16 May 2021 03:27:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3R9hm007193; Sun, 16 May 2021 03:27:09 GMT (envelope-from git) Date: Sun, 16 May 2021 03:27:09 GMT Message-Id: <202105160327.14G3R9hm007193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: b7259437d5d7 - stable/13 - cxgbe(4): Fix minor nit in the display of MPS TCAM entries. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7259437d5d7c194607f5ffff1a75c7258d473aa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:27:10 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=b7259437d5d7c194607f5ffff1a75c7258d473aa commit b7259437d5d7c194607f5ffff1a75c7258d473aa Author: Navdeep Parhar AuthorDate: 2021-04-22 22:36:51 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:26:58 +0000 cxgbe(4): Fix minor nit in the display of MPS TCAM entries. (cherry picked from commit dc77e7929644b87c0aa3f8f5e8d57fd10f49df54) --- sys/dev/cxgbe/t4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index ce439b94aa6c..6d4b413e3bfd 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -9141,7 +9141,7 @@ sysctl_mps_tcam_t6(SYSCTL_HANDLER_ARGS) if (lookup_type && lookup_type != M_DATALKPTYPE) { sbuf_printf(sb, "\n%3u %02x:%02x:%02x:%02x:%02x:%02x " "%012jx %06x %06x - - %3c" - " 'I' %4x %3c %#x%4u%4d", i, addr[0], + " I %4x %3c %#x%4u%4d", i, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], (uintmax_t)mask, vniy, vnix, dip_hit ? 'Y' : 'N', port_num, cls_lo & F_T6_SRAM_VLD ? 'Y' : 'N', From owner-dev-commits-src-all@freebsd.org Sun May 16 03:30:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6088163302A; Sun, 16 May 2021 03:30:33 +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 4FjST52H75z3QZv; Sun, 16 May 2021 03:30:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 36980119C8; Sun, 16 May 2021 03:30:33 +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 14G3UX8F015710; Sun, 16 May 2021 03:30:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3UXLl015709; Sun, 16 May 2021 03:30:33 GMT (envelope-from git) Date: Sun, 16 May 2021 03:30:33 GMT Message-Id: <202105160330.14G3UXLl015709@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 8b8b659f39f3 - stable/13 - cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8b8b659f39f3b94a1e111418a4b75d1ed9c332d7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:30:33 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=8b8b659f39f3b94a1e111418a4b75d1ed9c332d7 commit 8b8b659f39f3b94a1e111418a4b75d1ed9c332d7 Author: Navdeep Parhar AuthorDate: 2021-04-13 23:50:12 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:28:50 +0000 cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame. Sponsored by: Chelsio Communications (cherry picked from commit d107ee06f3e3c15fe119ea01b120d11bf87ef9f0) --- sys/dev/cxgbe/t4_sge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 2c7e8f348331..68b5ed812096 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -2072,6 +2072,8 @@ have_mbuf: rxq->rxcsum++; } else { MPASS(tnl_type == RX_PKT_TNL_TYPE_VXLAN); + + M_HASHTYPE_SETINNER(m0); if (__predict_false(cpl->ip_frag)) { /* * csum_data is for the inner frame (which is an From owner-dev-commits-src-all@freebsd.org Sun May 16 03:35:45 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D415633136; Sun, 16 May 2021 03:35:45 +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 4FjSb52Blgz3R43; Sun, 16 May 2021 03:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 32F8A11D3B; Sun, 16 May 2021 03:35:45 +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 14G3Zj5l020949; Sun, 16 May 2021 03:35:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3Zjr0020947; Sun, 16 May 2021 03:35:45 GMT (envelope-from git) Date: Sun, 16 May 2021 03:35:45 GMT Message-Id: <202105160335.14G3Zjr0020947@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 7d984fe000d8 - stable/13 - cxgbe(4): Add flag to reliably stop the driver from accessing hw stats. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7d984fe000d8132f02dc249dd110d28b456a5d22 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:35:45 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=7d984fe000d8132f02dc249dd110d28b456a5d22 commit 7d984fe000d8132f02dc249dd110d28b456a5d22 Author: Navdeep Parhar AuthorDate: 2021-04-23 00:45:52 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:34:01 +0000 cxgbe(4): Add flag to reliably stop the driver from accessing hw stats. There are two kinds of routines in the driver that read statistics from the hardware: the cxgbe_* variants read the per-port MPS/MAC registers and the vi_* variants read the per-VI registers. They can be called from the 1Hz callout or if_get_counter. All stats collection now takes place under the callout lock and there is a new flag to indicate that these routines should not access any hardware register. Sponsored by: Chelsio Communications (cherry picked from commit b47b28e5b28aeaa42e87f905fe6a0fe65dbfc184) --- sys/dev/cxgbe/adapter.h | 4 +--- sys/dev/cxgbe/t4_main.c | 59 +++++++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index c46f9626b95b..7bdad292c752 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -175,6 +175,7 @@ enum { VI_INIT_DONE = (1 << 1), VI_SYSCTL_CTX = (1 << 2), TX_USES_VM_WR = (1 << 3), + VI_SKIP_STATS = (1 << 4), /* adapter debug_flags */ DF_DUMP_MBOX = (1 << 0), /* Log all mbox cmd/rpl. */ @@ -311,7 +312,6 @@ struct port_info { struct link_config link_cfg; struct ifmedia media; - struct timeval last_refreshed; struct port_stats stats; u_int tnl_cong_drops; u_int tx_parse_error; @@ -1213,11 +1213,9 @@ void end_synchronized_op(struct adapter *, int); int update_mac_settings(struct ifnet *, int); int adapter_full_init(struct adapter *); int adapter_full_uninit(struct adapter *); -uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); int vi_full_init(struct vi_info *); int vi_full_uninit(struct vi_info *); void vi_sysctls(struct vi_info *); -void vi_tick(void *); int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); int alloc_atid(struct adapter *, void *); void *lookup_atid(struct adapter *, int); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 6d4b413e3bfd..1477a30dd0cd 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -735,9 +735,10 @@ static int t4_free_irq(struct adapter *, struct irq *); static void t4_init_atid_table(struct adapter *); static void t4_free_atid_table(struct adapter *); static void get_regs(struct adapter *, struct t4_regdump *, uint8_t *); -static void vi_refresh_stats(struct adapter *, struct vi_info *); -static void cxgbe_refresh_stats(struct adapter *, struct port_info *); +static void vi_refresh_stats(struct vi_info *); +static void cxgbe_refresh_stats(struct vi_info *); static void cxgbe_tick(void *); +static void vi_tick(void *); static void cxgbe_sysctls(struct port_info *); static int sysctl_int_array(SYSCTL_HANDLER_ARGS); static int sysctl_bitfield_8b(SYSCTL_HANDLER_ARGS); @@ -820,6 +821,8 @@ static int ktls_capability(struct adapter *, bool); #endif static int mod_event(module_t, int, void *); static int notify_siblings(device_t, int); +static uint64_t vi_get_counter(struct ifnet *, ift_counter); +static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); struct { uint16_t device; @@ -1818,7 +1821,10 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) ifp->if_ioctl = cxgbe_ioctl; ifp->if_transmit = cxgbe_transmit; ifp->if_qflush = cxgbe_qflush; - ifp->if_get_counter = cxgbe_get_counter; + if (vi->pi->nvi > 1 || sc->flags & IS_VF) + ifp->if_get_counter = vi_get_counter; + else + ifp->if_get_counter = cxgbe_get_counter; #if defined(KERN_TLS) || defined(RATELIMIT) ifp->if_snd_tag_alloc = cxgbe_snd_tag_alloc; ifp->if_snd_tag_modify = cxgbe_snd_tag_modify; @@ -2336,7 +2342,9 @@ vi_get_counter(struct ifnet *ifp, ift_counter c) struct vi_info *vi = ifp->if_softc; struct fw_vi_stats_vf *s = &vi->stats; - vi_refresh_stats(vi->adapter, vi); + mtx_lock(&vi->tick_mtx); + vi_refresh_stats(vi); + mtx_unlock(&vi->tick_mtx); switch (c) { case IFCOUNTER_IPACKETS: @@ -2380,18 +2388,16 @@ vi_get_counter(struct ifnet *ifp, ift_counter c) } } -uint64_t +static uint64_t cxgbe_get_counter(struct ifnet *ifp, ift_counter c) { struct vi_info *vi = ifp->if_softc; struct port_info *pi = vi->pi; - struct adapter *sc = pi->adapter; struct port_stats *s = &pi->stats; - if (pi->nvi > 1 || sc->flags & IS_VF) - return (vi_get_counter(ifp, c)); - - cxgbe_refresh_stats(sc, pi); + mtx_lock(&vi->tick_mtx); + cxgbe_refresh_stats(vi); + mtx_unlock(&vi->tick_mtx); switch (c) { case IFCOUNTER_IPACKETS: @@ -5586,7 +5592,7 @@ cxgbe_init_synchronized(struct vi_info *vi) PORT_UNLOCK(pi); mtx_lock(&vi->tick_mtx); - if (pi->nvi > 1 || sc->flags & IS_VF) + if (ifp->if_get_counter == vi_get_counter) callout_reset(&vi->tick, hz, vi_tick, vi); else callout_reset(&vi->tick, hz, cxgbe_tick, vi); @@ -6334,12 +6340,14 @@ t4_clr_vi_stats(struct adapter *sc, u_int vin) } static void -vi_refresh_stats(struct adapter *sc, struct vi_info *vi) +vi_refresh_stats(struct vi_info *vi) { struct timeval tv; const struct timeval interval = {0, 250000}; /* 250ms */ - if (!(vi->flags & VI_INIT_DONE)) + mtx_assert(&vi->tick_mtx, MA_OWNED); + + if (!(vi->flags & VI_INIT_DONE) || vi->flags & VI_SKIP_STATS) return; getmicrotime(&tv); @@ -6347,22 +6355,31 @@ vi_refresh_stats(struct adapter *sc, struct vi_info *vi) if (timevalcmp(&tv, &vi->last_refreshed, <)) return; - t4_get_vi_stats(sc, vi->vin, &vi->stats); + t4_get_vi_stats(vi->adapter, vi->vin, &vi->stats); getmicrotime(&vi->last_refreshed); } static void -cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) +cxgbe_refresh_stats(struct vi_info *vi) { u_int i, v, tnl_cong_drops, chan_map; struct timeval tv; const struct timeval interval = {0, 250000}; /* 250ms */ + struct port_info *pi; + struct adapter *sc; + + mtx_assert(&vi->tick_mtx, MA_OWNED); + + if (vi->flags & VI_SKIP_STATS) + return; getmicrotime(&tv); timevalsub(&tv, &interval); - if (timevalcmp(&tv, &pi->last_refreshed, <)) + if (timevalcmp(&tv, &vi->last_refreshed, <)) return; + pi = vi->pi; + sc = vi->adapter; tnl_cong_drops = 0; t4_get_port_stats(sc, pi->tx_chan, &pi->stats); chan_map = pi->rx_e_chan_map; @@ -6376,31 +6393,29 @@ cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) chan_map &= ~(1 << i); } pi->tnl_cong_drops = tnl_cong_drops; - getmicrotime(&pi->last_refreshed); + getmicrotime(&vi->last_refreshed); } static void cxgbe_tick(void *arg) { struct vi_info *vi = arg; - struct adapter *sc = vi->adapter; MPASS(IS_MAIN_VI(vi)); mtx_assert(&vi->tick_mtx, MA_OWNED); - cxgbe_refresh_stats(sc, vi->pi); + cxgbe_refresh_stats(vi); callout_schedule(&vi->tick, hz); } -void +static void vi_tick(void *arg) { struct vi_info *vi = arg; - struct adapter *sc = vi->adapter; mtx_assert(&vi->tick_mtx, MA_OWNED); - vi_refresh_stats(sc, vi); + vi_refresh_stats(vi); callout_schedule(&vi->tick, hz); } From owner-dev-commits-src-all@freebsd.org Sun May 16 03:37:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DEC046334A6; Sun, 16 May 2021 03:37:30 +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 4FjSd65yQ4z3h8x; Sun, 16 May 2021 03:37:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B49F711D3C; Sun, 16 May 2021 03:37:30 +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 14G3bUAC021175; Sun, 16 May 2021 03:37:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3bUPm021174; Sun, 16 May 2021 03:37:30 GMT (envelope-from git) Date: Sun, 16 May 2021 03:37:30 GMT Message-Id: <202105160337.14G3bUPm021174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 294591a4b7be - stable/13 - cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 294591a4b7bea721162764121727dd61da252787 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:37:30 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=294591a4b7bea721162764121727dd61da252787 commit 294591a4b7bea721162764121727dd61da252787 Author: Navdeep Parhar AuthorDate: 2021-04-23 07:26:47 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:36:13 +0000 cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function. It can be called to (re)apply the settings in the driver softc to the hardware. Sponsored by: Chelsio Communications (cherry picked from commit 5f00292fe3b76aba9115f3b2dfc887acb647eb91) --- sys/dev/cxgbe/t4_main.c | 58 ++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 1477a30dd0cd..a6ddce1c238f 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -823,6 +823,7 @@ static int mod_event(module_t, int, void *); static int notify_siblings(device_t, int); static uint64_t vi_get_counter(struct ifnet *, ift_counter); static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); +static void enable_vxlan_rx(struct adapter *); struct { uint16_t device; @@ -11665,12 +11666,38 @@ struct vxlan_evargs { }; static void -t4_vxlan_start(struct adapter *sc, void *arg) +enable_vxlan_rx(struct adapter *sc) { - struct vxlan_evargs *v = arg; + int i, rc; struct port_info *pi; uint8_t match_all_mac[ETHER_ADDR_LEN] = {0}; - int i, rc; + + ASSERT_SYNCHRONIZED_OP(sc); + + t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, V_VXLAN(sc->vxlan_port) | + F_VXLAN_EN); + for_each_port(sc, i) { + pi = sc->port[i]; + if (pi->vxlan_tcam_entry == true) + continue; + rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, match_all_mac, + match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, + true); + if (rc < 0) { + rc = -rc; + CH_ERR(&pi->vi[0], + "failed to add VXLAN TCAM entry: %d.\n", rc); + } else { + MPASS(rc == sc->rawf_base + pi->port_id); + pi->vxlan_tcam_entry = true; + } + } +} + +static void +t4_vxlan_start(struct adapter *sc, void *arg) +{ + struct vxlan_evargs *v = arg; if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) return; @@ -11680,32 +11707,13 @@ t4_vxlan_start(struct adapter *sc, void *arg) if (sc->vxlan_refcount == 0) { sc->vxlan_port = v->port; sc->vxlan_refcount = 1; - t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, - V_VXLAN(v->port) | F_VXLAN_EN); - for_each_port(sc, i) { - pi = sc->port[i]; - if (pi->vxlan_tcam_entry == true) - continue; - rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, - match_all_mac, match_all_mac, - sc->rawf_base + pi->port_id, 1, pi->port_id, true); - if (rc < 0) { - rc = -rc; - log(LOG_ERR, - "%s: failed to add VXLAN TCAM entry: %d.\n", - device_get_name(pi->vi[0].dev), rc); - } else { - MPASS(rc == sc->rawf_base + pi->port_id); - rc = 0; - pi->vxlan_tcam_entry = true; - } - } + enable_vxlan_rx(sc); } else if (sc->vxlan_port == v->port) { sc->vxlan_refcount++; } else { - log(LOG_ERR, "%s: VXLAN already configured on port %d; " + CH_ERR(sc, "VXLAN already configured on port %d; " "ignoring attempt to configure it on port %d\n", - device_get_nameunit(sc->dev), sc->vxlan_port, v->port); + sc->vxlan_port, v->port); } end_synchronized_op(sc, 0); } From owner-dev-commits-src-all@freebsd.org Sun May 16 03:38:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 732086330FF; Sun, 16 May 2021 03:38:27 +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 4FjSfC2rbGz3gys; Sun, 16 May 2021 03:38:27 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4A6A411D3D; Sun, 16 May 2021 03:38:27 +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 14G3cRWM021360; Sun, 16 May 2021 03:38:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3cR5H021359; Sun, 16 May 2021 03:38:27 GMT (envelope-from git) Date: Sun, 16 May 2021 03:38:27 GMT Message-Id: <202105160338.14G3cR5H021359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 1c0a5613ac8f - stable/13 - cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1c0a5613ac8f4f7f7ee17a80d161aaeee8b8bdd5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:38:27 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=1c0a5613ac8f4f7f7ee17a80d161aaeee8b8bdd5 commit 1c0a5613ac8f4f7f7ee17a80d161aaeee8b8bdd5 Author: Navdeep Parhar AuthorDate: 2021-04-23 19:17:54 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:37:37 +0000 cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time. Sponsored by: Chelsio Communications (cherry picked from commit 50f5d13eeb8835fe8250d65f033334d7d956d703) --- sys/dev/cxgbe/t4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index a6ddce1c238f..5f969829c2d1 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -593,7 +593,7 @@ SYSCTL_INT(_hw_cxgbe, OID_AUTO, pcie_relaxed_ordering, CTLFLAG_RDTUN, "PCIe Relaxed Ordering: 0 = disable, 1 = enable, 2 = leave alone"); static int t4_panic_on_fatal_err = 0; -SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RWTUN, &t4_panic_on_fatal_err, 0, "panic on fatal errors"); static int t4_tx_vm_wr = 0; From owner-dev-commits-src-all@freebsd.org Sun May 16 03:45:44 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D93F363380D; Sun, 16 May 2021 03:45:44 +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 4FjSpc5qSyz3hZx; Sun, 16 May 2021 03:45:44 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B0BE112097; Sun, 16 May 2021 03:45:44 +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 14G3ji97034182; Sun, 16 May 2021 03:45:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3jiQf034181; Sun, 16 May 2021 03:45:44 GMT (envelope-from git) Date: Sun, 16 May 2021 03:45:44 GMT Message-Id: <202105160345.14G3jiQf034181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 8f7d9587664a - stable/13 - cxgbe(4): Do not panic when tx is called with invalid checksum requests. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8f7d9587664af630fedc1a3b91f8ca22dd55f51b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:45:44 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=8f7d9587664af630fedc1a3b91f8ca22dd55f51b commit 8f7d9587664af630fedc1a3b91f8ca22dd55f51b Author: Navdeep Parhar AuthorDate: 2021-04-28 20:45:58 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:44:46 +0000 cxgbe(4): Do not panic when tx is called with invalid checksum requests. There is no need to panic in if_transmit if the checksums requested are inconsistent with the frame being transmitted. This typically indicates that the kernel and driver were built with different INET/INET6 options, or there is some other kernel bug. The driver should just throw away the requests that it doesn't understand and move on. Sponsored by: Chelsio Communications (cherry picked from commit b9820bca183aba6c0c03a8b717bedd24da7428da) --- sys/dev/cxgbe/t4_sge.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 68b5ed812096..c09ba29213a1 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -2712,6 +2712,9 @@ max_nsegs_allowed(struct mbuf *m, bool vm_wr) return (TX_SGL_SEGS); } +static struct timeval txerr_ratecheck = {0}; +static const struct timeval txerr_interval = {3, 0}; + /* * Analyze the mbuf to determine its tx needs. The mbuf passed in may change: * a) caller can assume it's been freed if this function returns with an error. @@ -2863,9 +2866,14 @@ restart: } #endif default: - panic("%s: ethertype 0x%04x unknown. if_cxgbe must be compiled" - " with the same INET/INET6 options as the kernel.", - __func__, eh_type); + if (ratecheck(&txerr_ratecheck, &txerr_interval)) { + log(LOG_ERR, "%s: ethertype 0x%04x unknown. " + "if_cxgbe must be compiled with the same " + "INET/INET6 options as the kernel.\n", __func__, + eh_type); + } + rc = EINVAL; + goto fail; } if (needs_vxlan_csum(m0)) { @@ -2901,10 +2909,15 @@ restart: } #endif default: - panic("%s: VXLAN hw offload requested with unknown " - "ethertype 0x%04x. if_cxgbe must be compiled" - " with the same INET/INET6 options as the kernel.", - __func__, eh_type); + if (ratecheck(&txerr_ratecheck, &txerr_interval)) { + log(LOG_ERR, "%s: VXLAN hw offload requested" + "with unknown ethertype 0x%04x. if_cxgbe " + "must be compiled with the same INET/INET6 " + "options as the kernel.\n", __func__, + eh_type); + } + rc = EINVAL; + goto fail; } #if defined(INET) || defined(INET6) if (needs_inner_tcp_csum(m0)) { From owner-dev-commits-src-all@freebsd.org Sun May 16 03:46:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DDECD633A0C; Sun, 16 May 2021 03:46:51 +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 4FjSqv5z4tz3hsr; Sun, 16 May 2021 03:46:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B54A111EB9; Sun, 16 May 2021 03:46: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 14G3kpP3034357; Sun, 16 May 2021 03:46:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G3kpvq034356; Sun, 16 May 2021 03:46:51 GMT (envelope-from git) Date: Sun, 16 May 2021 03:46:51 GMT Message-Id: <202105160346.14G3kpvq034356@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 1f9df724eb20 - stable/13 - cxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f9df724eb20203fdf14a97ab27d6a182b1e747b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 03:46:51 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=1f9df724eb20203fdf14a97ab27d6a182b1e747b commit 1f9df724eb20203fdf14a97ab27d6a182b1e747b Author: Navdeep Parhar AuthorDate: 2021-05-01 23:53:50 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-16 03:45:59 +0000 cxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management. The _ext event notification includes the address being added/removed and that gives the driver an easy way to ignore non-IPv6 addresses. Remove 'tom' from the handler's name while here, it was moved out of t4_tom a long time ago. Sponsored by: Chelsio Communications (cherry picked from commit f4ba035bca927e21f0f88ce56915523bafd573d9) --- sys/dev/cxgbe/t4_clip.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index a93271103998..f737c17eaaae 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -343,9 +343,13 @@ t4_destroy_clip_table(struct adapter *sc) } static void -t4_tom_ifaddr_event(void *arg __unused, struct ifnet *ifp) +t4_ifaddr_event(void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa, + int event) { + if (ifa->ifa_addr->sa_family != AF_INET6) + return; + atomic_add_rel_int(&in6_ifaddr_gen, 1); taskqueue_enqueue_timeout(taskqueue_thread, &clip_task, -hz / 4); } @@ -390,15 +394,15 @@ t4_clip_modload(void) { TIMEOUT_TASK_INIT(taskqueue_thread, &clip_task, 0, t4_clip_task, NULL); - ifaddr_evhandler = EVENTHANDLER_REGISTER(ifaddr_event, - t4_tom_ifaddr_event, NULL, EVENTHANDLER_PRI_ANY); + ifaddr_evhandler = EVENTHANDLER_REGISTER(ifaddr_event_ext, + t4_ifaddr_event, NULL, EVENTHANDLER_PRI_ANY); } void t4_clip_modunload(void) { - EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_evhandler); + EVENTHANDLER_DEREGISTER(ifaddr_event_ext, ifaddr_evhandler); taskqueue_cancel_timeout(taskqueue_thread, &clip_task, NULL); } #endif From owner-dev-commits-src-all@freebsd.org Sun May 16 04:40:51 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B623C634965; Sun, 16 May 2021 04:40:51 +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 4FjV2C4rXRz3pRw; Sun, 16 May 2021 04:40:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8E81E12854; Sun, 16 May 2021 04:40: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 14G4ep3V008791; Sun, 16 May 2021 04:40:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G4ep47008790; Sun, 16 May 2021 04:40:51 GMT (envelope-from git) Date: Sun, 16 May 2021 04:40:51 GMT Message-Id: <202105160440.14G4ep47008790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 34dad5e91413 - stable/13 - usr.bin/netstat: use roundup2 when rounding up to power of 2. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 34dad5e91413e7d533f7628d39c2b70cedf9c793 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 04:40:51 -0000 The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=34dad5e91413e7d533f7628d39c2b70cedf9c793 commit 34dad5e91413e7d533f7628d39c2b70cedf9c793 Author: Xin LI AuthorDate: 2021-05-02 16:30:22 +0000 Commit: Xin LI CommitDate: 2021-05-16 04:40:23 +0000 usr.bin/netstat: use roundup2 when rounding up to power of 2. (cherry picked from commit f6b6d216cafb154a85313a2d1bd34b18b9bfbba8) --- usr.bin/netstat/common.c | 4 ++-- usr.bin/netstat/nhops.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/netstat/common.c b/usr.bin/netstat/common.c index ac721b3e9ab0..9dbbaeee25ea 100644 --- a/usr.bin/netstat/common.c +++ b/usr.bin/netstat/common.c @@ -114,7 +114,7 @@ prepare_ifmap(size_t *pifmap_size) ifindex = sdl->sdl_index; if (ifindex >= ifmap_size) { - size = roundup(ifindex + 1, 32) * + size = roundup2(ifindex + 1, 32) * sizeof(struct ifmap_entry); if ((ifmap = realloc(ifmap, size)) == NULL) errx(2, "realloc(%d) failed", size); @@ -122,7 +122,7 @@ prepare_ifmap(size_t *pifmap_size) size - ifmap_size * sizeof(struct ifmap_entry)); - ifmap_size = roundup(ifindex + 1, 32); + ifmap_size = roundup2(ifindex + 1, 32); } if (*ifmap[ifindex].ifname != '\0') diff --git a/usr.bin/netstat/nhops.c b/usr.bin/netstat/nhops.c index 44006da7f1fe..51bed6e23c0f 100644 --- a/usr.bin/netstat/nhops.c +++ b/usr.bin/netstat/nhops.c @@ -213,7 +213,7 @@ nhop_map_update(struct nhop_map *map, uint32_t idx, char *gw, char *ifname) else new_size = map->size * 2; if (new_size <= idx) - new_size = roundup(idx + 1, 32); + new_size = roundup2(idx + 1, 32); sz = new_size * (sizeof(struct nhop_entry)); if ((map->ptr = realloc(map->ptr, sz)) == NULL) From owner-dev-commits-src-all@freebsd.org Sun May 16 04:40:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFD36634969; Sun, 16 May 2021 04:40: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 4FjV2D5lDNz3pQq; Sun, 16 May 2021 04:40:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A49AB12AB7; Sun, 16 May 2021 04:40:52 +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 14G4eqTb008819; Sun, 16 May 2021 04:40:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G4eq3i008818; Sun, 16 May 2021 04:40:52 GMT (envelope-from git) Date: Sun, 16 May 2021 04:40:52 GMT Message-Id: <202105160440.14G4eq3i008818@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 5a485392c4cc - stable/13 - usr.bin/patch: remove unneeded header. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5a485392c4ccc9a9501219f2f52f6a5264658beb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 04:40:53 -0000 The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=5a485392c4ccc9a9501219f2f52f6a5264658beb commit 5a485392c4ccc9a9501219f2f52f6a5264658beb Author: Xin LI AuthorDate: 2021-05-02 16:27:32 +0000 Commit: Xin LI CommitDate: 2021-05-16 04:40:41 +0000 usr.bin/patch: remove unneeded header. (cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075) --- usr.bin/patch/backupfile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index ecdca19e2a71..a35e6fd21dc8 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "backupfile.h" From owner-dev-commits-src-all@freebsd.org Sun May 16 04:42:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE878635282; Sun, 16 May 2021 04:42:11 +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 4FjV3l59jqz3pT1; Sun, 16 May 2021 04:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9A681127E0; Sun, 16 May 2021 04:42:11 +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 14G4gB6W013670; Sun, 16 May 2021 04:42:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G4gBXO013669; Sun, 16 May 2021 04:42:11 GMT (envelope-from git) Date: Sun, 16 May 2021 04:42:11 GMT Message-Id: <202105160442.14G4gBXO013669@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: cd7d1862f7b0 - stable/12 - usr.bin/patch: remove unneeded header. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: cd7d1862f7b07277577d1e684792526acfdd3bc7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 04:42:11 -0000 The branch stable/12 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=cd7d1862f7b07277577d1e684792526acfdd3bc7 commit cd7d1862f7b07277577d1e684792526acfdd3bc7 Author: Xin LI AuthorDate: 2021-05-02 16:27:32 +0000 Commit: Xin LI CommitDate: 2021-05-16 04:42:02 +0000 usr.bin/patch: remove unneeded header. (cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075) --- usr.bin/patch/backupfile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index ecdca19e2a71..a35e6fd21dc8 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "backupfile.h" From owner-dev-commits-src-all@freebsd.org Sun May 16 04:43:33 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD355634F62; Sun, 16 May 2021 04:43:33 +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 4FjV5K5vt5z3q5Y; Sun, 16 May 2021 04:43:33 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B37B8125E1; Sun, 16 May 2021 04:43:33 +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 14G4hXmg013866; Sun, 16 May 2021 04:43:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G4hXTP013865; Sun, 16 May 2021 04:43:33 GMT (envelope-from git) Date: Sun, 16 May 2021 04:43:33 GMT Message-Id: <202105160443.14G4hXTP013865@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: fb2dd85a9483 - stable/11 - usr.bin/patch: remove unneeded header. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: fb2dd85a9483b5731d75ace0f29850f1802cfeae Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 04:43:33 -0000 The branch stable/11 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=fb2dd85a9483b5731d75ace0f29850f1802cfeae commit fb2dd85a9483b5731d75ace0f29850f1802cfeae Author: Xin LI AuthorDate: 2021-05-02 16:27:32 +0000 Commit: Xin LI CommitDate: 2021-05-16 04:43:24 +0000 usr.bin/patch: remove unneeded header. (cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075) --- usr.bin/patch/backupfile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index ecdca19e2a71..a35e6fd21dc8 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "backupfile.h" From owner-dev-commits-src-all@freebsd.org Sun May 16 05:38:39 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A3BF636231; Sun, 16 May 2021 05:38:39 +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 4FjWJv2yldz3w58; Sun, 16 May 2021 05:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4FBC613856; Sun, 16 May 2021 05:38:39 +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 14G5cdIt079933; Sun, 16 May 2021 05:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G5cdtY079932; Sun, 16 May 2021 05:38:39 GMT (envelope-from git) Date: Sun, 16 May 2021 05:38:39 GMT Message-Id: <202105160538.14G5cdtY079932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Guangyuan Yang Subject: git: 80ba60f64394 - main - kerberos.8: Replace dead link MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80ba60f64394fab3cda10d5921af896ed1c57c5f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 05:38:39 -0000 The branch main has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=80ba60f64394fab3cda10d5921af896ed1c57c5f commit 80ba60f64394fab3cda10d5921af896ed1c57c5f Author: Guangyuan Yang AuthorDate: 2021-05-16 05:37:09 +0000 Commit: Guangyuan Yang CommitDate: 2021-05-16 05:37:09 +0000 kerberos.8: Replace dead link Replace it with a tutorial hosted on kerberos.org and the classic "dialogue" from Bill Bryant. The change has been reported and merged upstream (https://github.com/heimdal/heimdal/commit/7f3445f1b7). MFC after: 3 days PR: 251854 Reported by: ktullavik@gmail.com Submitted by: bjk (upstream github) Reviewed by: bcr --- crypto/heimdal/lib/krb5/kerberos.8 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crypto/heimdal/lib/krb5/kerberos.8 b/crypto/heimdal/lib/krb5/kerberos.8 index 94d49955180b..a4161eea5953 100644 --- a/crypto/heimdal/lib/krb5/kerberos.8 +++ b/crypto/heimdal/lib/krb5/kerberos.8 @@ -31,7 +31,7 @@ .\" .\" $Id$ .\" -.Dd September 1, 2000 +.Dd May 15, 2021 .Dt KERBEROS 8 .Os HEIMDAL .Sh NAME @@ -71,9 +71,12 @@ or .Ic ftp , without giving your password. .Pp -For more information on how Kerberos works, and other general Kerberos -questions see the Kerberos FAQ at -.Pa http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html . +For more information on how Kerberos works, see the tutorial at +.Lk https://kerberos.org/software/tutorial.html +or the informal +.Dq dialogue +at +.Lk https://web.mit.edu/kerberos/dialogue.html . .Pp For setup instructions see the Heimdal Texinfo manual. .Sh SEE ALSO From owner-dev-commits-src-all@freebsd.org Sun May 16 08:37:23 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D863A63A7A1; Sun, 16 May 2021 08:37:23 +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 4FjbH75hs3z4lQb; Sun, 16 May 2021 08:37:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A83FB15B16; Sun, 16 May 2021 08:37:23 +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 14G8bNAT020973; Sun, 16 May 2021 08:37:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G8bNKH020972; Sun, 16 May 2021 08:37:23 GMT (envelope-from git) Date: Sun, 16 May 2021 08:37:23 GMT Message-Id: <202105160837.14G8bNKH020972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: 3f5f4078b371 - stable/13 - find(1): Document the -f option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f5f4078b371b919f1a0d6096d91a7c103a23b7d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 08:37:23 -0000 The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3f5f4078b371b919f1a0d6096d91a7c103a23b7d commit 3f5f4078b371b919f1a0d6096d91a7c103a23b7d Author: Ceri Davies AuthorDate: 2021-05-13 08:10:22 +0000 Commit: Gordon Bergling CommitDate: 2021-05-16 08:36:53 +0000 find(1): Document the -f option PR: 223127 Reported by: Mathieu Arnold Reviewed by: bcr, gbe Differential Revision: https://reviews.freebsd.org/D30215 (cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0) --- usr.bin/find/find.1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 0c5c113479a3..8bc9f9d69604 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -31,7 +31,7 @@ .\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd March 13, 2021 +.Dd May 13, 2021 .Dt FIND 1 .Os .Sh NAME @@ -135,6 +135,19 @@ primary specified by Refer to its description under .Sx PRIMARIES for more information. +.It Fl f Ar path +Add +.Ar path +to the list of paths that will be recursed into. +This is useful when +.Ar path +begins with a character that would otherwise be interpreted as an +.Ar expression , +namely +.Dq Li "!" , +.Dq Li "(" +and +.Dq Li - . .It Fl s Cause .Nm From owner-dev-commits-src-all@freebsd.org Sun May 16 08:38:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0DD1163A6CA; Sun, 16 May 2021 08:38:05 +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 4FjbHw6zWcz4lVN; Sun, 16 May 2021 08:38:04 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D8BC0158AA; Sun, 16 May 2021 08:38:04 +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 14G8c49f021133; Sun, 16 May 2021 08:38:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G8c46K021132; Sun, 16 May 2021 08:38:04 GMT (envelope-from git) Date: Sun, 16 May 2021 08:38:04 GMT Message-Id: <202105160838.14G8c46K021132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: ed5c8820f478 - stable/12 - find(1): Document the -f option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ed5c8820f4786ddca97ef0411c133bccee2ddd85 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 08:38:05 -0000 The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=ed5c8820f4786ddca97ef0411c133bccee2ddd85 commit ed5c8820f4786ddca97ef0411c133bccee2ddd85 Author: Ceri Davies AuthorDate: 2021-05-13 08:10:22 +0000 Commit: Gordon Bergling CommitDate: 2021-05-16 08:37:47 +0000 find(1): Document the -f option PR: 223127 Reported by: Mathieu Arnold Reviewed by: bcr, gbe Differential Revision: https://reviews.freebsd.org/D30215 (cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0) --- usr.bin/find/find.1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 0c5c113479a3..8bc9f9d69604 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -31,7 +31,7 @@ .\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd March 13, 2021 +.Dd May 13, 2021 .Dt FIND 1 .Os .Sh NAME @@ -135,6 +135,19 @@ primary specified by Refer to its description under .Sx PRIMARIES for more information. +.It Fl f Ar path +Add +.Ar path +to the list of paths that will be recursed into. +This is useful when +.Ar path +begins with a character that would otherwise be interpreted as an +.Ar expression , +namely +.Dq Li "!" , +.Dq Li "(" +and +.Dq Li - . .It Fl s Cause .Nm From owner-dev-commits-src-all@freebsd.org Sun May 16 09:13:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 833C863B84E; Sun, 16 May 2021 09:13:19 +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 4Fjc4b3L99z4qJK; Sun, 16 May 2021 09:13:19 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5B159163CC; Sun, 16 May 2021 09:13:19 +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 14G9DJ7N074278; Sun, 16 May 2021 09:13:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14G9DJT1074277; Sun, 16 May 2021 09:13:19 GMT (envelope-from git) Date: Sun, 16 May 2021 09:13:19 GMT Message-Id: <202105160913.14G9DJT1074277@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 5365af662c78 - main - loader: gfx_fb_drawrect should use GfxFbBltVideoFill MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5365af662c78d7bded3bf83c7271d6bff17229a9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 09:13:19 -0000 The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=5365af662c78d7bded3bf83c7271d6bff17229a9 commit 5365af662c78d7bded3bf83c7271d6bff17229a9 Author: Toomas Soome AuthorDate: 2021-05-11 18:05:12 +0000 Commit: Toomas Soome CommitDate: 2021-05-16 08:22:37 +0000 loader: gfx_fb_drawrect should use GfxFbBltVideoFill The gfx_fb_drawrect() is drawing rectangle by pixels, this can be very slow on some systems. Use Blt() video fill primitive instead. Testing done: Tested on mac mini 2012 where the issue was revealed Reviewed by: yuripv MFC after: 1 week --- stand/common/gfx_fb.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 3eae0a3a859e..92af49913748 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -1357,16 +1357,12 @@ isqrt(int num) return (res); } -/* set pixel in framebuffer using gfx coordinates */ -void -gfx_fb_setpixel(uint32_t x, uint32_t y) +static uint32_t +gfx_fb_getcolor(void) { uint32_t c; const teken_attr_t *ap; - if (gfx_state.tg_fb_type == FB_TEXT) - return; - ap = teken_get_curattr(&gfx_state.tg_teken); if (ap->ta_format & TF_REVERSE) { c = ap->ta_bgcolor; @@ -1378,7 +1374,19 @@ gfx_fb_setpixel(uint32_t x, uint32_t y) c |= TC_LIGHT; } - c = gfx_fb_color_map(c); + return (gfx_fb_color_map(c)); +} + +/* set pixel in framebuffer using gfx coordinates */ +void +gfx_fb_setpixel(uint32_t x, uint32_t y) +{ + uint32_t c; + + if (gfx_state.tg_fb_type == FB_TEXT) + return; + + c = gfx_fb_getcolor(); if (x >= gfx_state.tg_fb.fb_width || y >= gfx_state.tg_fb.fb_height) @@ -1389,25 +1397,26 @@ gfx_fb_setpixel(uint32_t x, uint32_t y) /* * draw rectangle in framebuffer using gfx coordinates. - * The function is borrowed from vt_fb.c */ void gfx_fb_drawrect(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t fill) { - uint32_t x, y; + uint32_t c; if (gfx_state.tg_fb_type == FB_TEXT) return; - for (y = y1; y <= y2; y++) { - if (fill || (y == y1) || (y == y2)) { - for (x = x1; x <= x2; x++) - gfx_fb_setpixel(x, y); - } else { - gfx_fb_setpixel(x1, y); - gfx_fb_setpixel(x2, y); - } + c = gfx_fb_getcolor(); + + if (fill != 0) { + gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, + y2 - y1, 0); + } else { + gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, 1, 0); + gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y2, x2 - x1, 1, 0); + gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, 1, y2 - y1, 0); + gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x2, y1, 1, y2 - y1, 0); } } From owner-dev-commits-src-all@freebsd.org Sun May 16 10:45:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1700A63D917; Sun, 16 May 2021 10:45:36 +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 4Fjf7404Wrz3Gv9; Sun, 16 May 2021 10:45:36 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E051F1760E; Sun, 16 May 2021 10:45:35 +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 14GAjZ1S093218; Sun, 16 May 2021 10:45:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GAjZIL093217; Sun, 16 May 2021 10:45:35 GMT (envelope-from git) Date: Sun, 16 May 2021 10:45:35 GMT Message-Id: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0f206cc91279e630ad9e733eb6e330b7dbe6c70e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 10:45:36 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e Author: Edward Tomasz Napierala AuthorDate: 2021-05-16 09:28:04 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-16 10:38:26 +0000 cam: add missing zeroing of a stack-allocated CCB. This could cause a panic at boot. Reported By: Shawn Webb Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. --- sys/cam/ata/ata_xpt.c | 1 + sys/cam/scsi/scsi_xpt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c index c13c7b493c78..2e3f862cbf41 100644 --- a/sys/cam/ata/ata_xpt.c +++ b/sys/cam/ata/ata_xpt.c @@ -2187,6 +2187,7 @@ ata_announce_periph_sbuf(struct cam_periph *periph, struct sbuf *sb) struct ccb_trans_settings cts; u_int speed, mb; + bzero(&cts, sizeof(cts)); _ata_announce_periph(periph, &cts, &speed); if ((cts.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) return; diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index bdc23e4b51b7..5097802c4063 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -3154,6 +3154,7 @@ scsi_announce_periph(struct cam_periph *periph) struct ccb_trans_settings cts; u_int speed, freq, mb; + memset(&cts, 0, sizeof(cts)); _scsi_announce_periph(periph, &speed, &freq, &cts); if (cam_ccb_status((union ccb *)&cts) != CAM_REQ_CMP) return; From owner-dev-commits-src-all@freebsd.org Sun May 16 12:40:50 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8816D640E8B; Sun, 16 May 2021 12:40:50 +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 4Fjhh23RQ9z3lWy; Sun, 16 May 2021 12:40:50 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5F345187EB; Sun, 16 May 2021 12:40:50 +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 14GCeo57047750; Sun, 16 May 2021 12:40:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GCeoNl047749; Sun, 16 May 2021 12:40:50 GMT (envelope-from git) Date: Sun, 16 May 2021 12:40:50 GMT Message-Id: <202105161240.14GCeoNl047749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 8252fe56a0ed - main - cam: Fix race condition in dainit() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8252fe56a0edc95f55b203424a8f2f957959e7a4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 12:40:50 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=8252fe56a0edc95f55b203424a8f2f957959e7a4 commit 8252fe56a0edc95f55b203424a8f2f957959e7a4 Author: Edward Tomasz Napierala AuthorDate: 2021-05-16 09:35:31 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-16 12:36:54 +0000 cam: Fix race condition in dainit() Previously, daregister() could have been called before dainit() initialized the UMA zone. This would trip a KASSERT. Reported By: pho Tested By: pho Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. --- sys/cam/scsi/scsi_da.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 05dd9b6e7566..cf6e2e17e410 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2001,6 +2001,10 @@ dainit(void) { cam_status status; + da_ccb_zone = uma_zcreate("da_ccb", + sizeof(struct ccb_scsiio), NULL, NULL, NULL, NULL, + UMA_ALIGN_PTR, 0); + /* * Install a global async callback. This callback will * receive async callbacks like "new device found". @@ -2016,10 +2020,6 @@ dainit(void) NULL, SHUTDOWN_PRI_DEFAULT)) == NULL) printf("dainit: shutdown event registration failed!\n"); } - - da_ccb_zone = uma_zcreate("da_ccb", - sizeof(struct ccb_scsiio), NULL, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); } /* From owner-dev-commits-src-all@freebsd.org Sun May 16 16:55:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A84D9628C29; Sun, 16 May 2021 16:55:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjpKj49SVz4n53; Sun, 16 May 2021 16:55:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qk1-x734.google.com with SMTP id o27so3640219qkj.9; Sun, 16 May 2021 09:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=myAaqOW72vhosiqprMnDFN1trSIm4iOk05JdaY8VWFI=; b=bTnwqbEdRCH2CuLyhfBtDZ5C8Z/ApTAIOEax0932HUdRBrXRcHPe01xYT1TB0D6MFe UOY4g+/oCPd64eRpVBrXh+rpjSsoXVmeL5AESqd6q0lRcsVcaBJqyBf1ui2q/kVrhxUD QJXQ9vp4Zt2RhYZNBl8nHW8OGO/+NIFudGa5mbo096axxJcfGsfLjBjs/5F+HHePX0f2 VmWAFbv+eerHPg0+TQiWLFCu8wMnLF+BFwBIXUUSR6TAZIM6MSOg+Lydpqj13BwTXaBa bxynSpWIkE1Zgua/epdASCL35xtzb9dAGZwf8BSFGkKggdF+L1nXsNSLWPPzDSlW0V8V LgiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=myAaqOW72vhosiqprMnDFN1trSIm4iOk05JdaY8VWFI=; b=H71Q+/dINwShPfSXmoyqMTnrSj/lCq63wd9vMb9m1QdSKYNcHaD6Vthev8ZCbiewbx 0l1SPmzOVzoMlzsjwVja7PEX5iqllZtdmPp2/lz2JuvpgynT/0RWVWViFr5Hn4MzD8pW /VRFYHiFxSnlzzyh59eEihiGyLHp3c6YJdwKRH9MhhmfarWD+qfcJG7EubA7Go/vwDWe wdrmM5ofYQDpxkyrUEgq61ky83RdFgqJpnXVaab15Zc3Q3qdiYMGvFMQTHmLvxvBEu0g bGqNqvcBFZAUZ8yZxuQ/KDefpvWCBs+dgLTY+l0ECjibK4cbK3leUkEvvLXIRiHgRiWj JiHQ== X-Gm-Message-State: AOAM5316mLv3Ru1l7IcO+dd/T04HZRo9sDOTbBdryJyRuRRU4P1QfFFZ DW/wifxLqPzp5vq7YWgBGmvrqdg499naaA== X-Google-Smtp-Source: ABdhPJyt86hQotUc3VmNuJu9uClqlCoeE8mtQTPJOhOcWOMOZ3nhGAcnFe3mRzdXapjuKHq9l+RG2w== X-Received: by 2002:a05:620a:9d6:: with SMTP id y22mr42975860qky.432.1621184120577; Sun, 16 May 2021 09:55:20 -0700 (PDT) Received: from nuc ([142.126.163.177]) by smtp.gmail.com with ESMTPSA id y6sm8841357qkd.106.2021.05.16.09.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 09:55:20 -0700 (PDT) Sender: Mark Johnston Date: Sun, 16 May 2021 12:55:20 -0400 From: Mark Johnston To: Edward Tomasz Napierala Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. Message-ID: References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4FjpKj49SVz4n53 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 16:55:21 -0000 On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala wrote: > The branch main has been updated by trasz: > > URL: https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > Author: Edward Tomasz Napierala > AuthorDate: 2021-05-16 09:28:04 +0000 > Commit: Edward Tomasz Napierala > CommitDate: 2021-05-16 10:38:26 +0000 > > cam: add missing zeroing of a stack-allocated CCB. > > This could cause a panic at boot. There are other instances of this, for example syzbot is currently hitting an assertion, seemingly because the alloc_flags field of a stack-allocated CCB was not zeroed: https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c I think the patch below will fix it, but I did not audit other callers. It feels a bit strange to require all callers of xpt_setup_ccb() to manually zero the structure first, can we provide a single routine to initialize stack-allocated CCBs? diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c index 51d9e5f532f7..adf4fd17fc5b 100644 --- a/sys/dev/virtio/scsi/virtio_scsi.c +++ b/sys/dev/virtio/scsi/virtio_scsi.c @@ -700,6 +700,7 @@ vtscsi_register_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE | AC_FOUND_DEVICE; @@ -716,6 +717,7 @@ vtscsi_deregister_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = 0; From owner-dev-commits-src-all@freebsd.org Sun May 16 17:27:57 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4409D629DA3 for ; Sun, 16 May 2021 17:27:57 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fjq3K0y7hz4sFR for ; Sun, 16 May 2021 17:27:56 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82f.google.com with SMTP id i20so3075722qtx.4 for ; Sun, 16 May 2021 10:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vq3Su//bgkIJZX5L6/plp06s8ZYj72lwnbBMdimOgmk=; b=BkFQh9dFjSXNoe64TOHag0i+9LcvAbjV7+LB7575mowd90hjsQmmNiRXNAcTrgfsEL XP0A71kihfn3Zyt5/99sANQgDd3KZqbSeV7hFr2DXv/z4eW4WRuQi94xYVYD90gqilXL XXiZxiHV1kok4TMdAUJAAcYvvqcxTylpxo0gr34nqfLf9Wk7T0OT9Lfjr0eoh6KaJytp qQmbCS7Oy7N1s7Z6Qw/svHO75e3x0IIBGXdCU4u/l5/TXOXVgpIKTabmfY8RJWhGmsLG VXT1n5snkbm1o9xgnKKbs5qInGsd/h5k6kPfn1IREa5HNjUNnAxpL8jK2lgbpGfXVEwa 5w2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vq3Su//bgkIJZX5L6/plp06s8ZYj72lwnbBMdimOgmk=; b=e0f3oEqtDsrUwd/5vpVi5o9Fzs2fU1K688DN6f0pn2zfX0mVzzcfe43TE5oYbypGpJ Dtu56wh8HwQbQf2xxIQeavwVdZNpXUTJZP5YGhcS+WMR3pzXyz8RWQJyHcaSxV/jp7H+ 7pts7sEv9gBpx2Yazhg/LQLu4OrCEgeYr/vNQPKIwqtXawN34knqyi7FF5yKDEhhOUtB Z4NQV7xdKcFNSPBg0GwTVmOwUfUNsbK5QzpFF1Jg8SZug+/OoDQXTf76nlWZhklev5yD /TtJoJQLR5n+X/aLZvSRdg3D1brRolPMTd9f+vkw/59hONRww6fLjjT0KU0/hHTHsQwK jBFg== X-Gm-Message-State: AOAM531g0kC6vIlrsmVk2MGPX1KiSkOYs/BYQMtLDu0F7f1l/fIC6T4h okK6e+tABGhI9RrOqSH984LHiv7m6Za5KReK7o808w== X-Google-Smtp-Source: ABdhPJydZS6wTHdOJZWQYbmMK32O9TYOIk54C4VDXfuLltbd3NI+GQRTzh+zzruiWUDXpFwhglWbRclf0Px5XSaaaYU= X-Received: by 2002:a05:622a:588:: with SMTP id c8mr42429415qtb.49.1621186075894; Sun, 16 May 2021 10:27:55 -0700 (PDT) MIME-Version: 1.0 References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> In-Reply-To: From: Warner Losh Date: Sun, 16 May 2021 12:27:44 -0500 Message-ID: Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. To: Mark Johnston Cc: Edward Tomasz Napierala , src-committers , "" , dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4Fjq3K0y7hz4sFR X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 17:27:57 -0000 On Sun, May 16, 2021, 11:55 AM Mark Johnston wrote: > On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala wrote: > > The branch main has been updated by trasz: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > Author: Edward Tomasz Napierala > > AuthorDate: 2021-05-16 09:28:04 +0000 > > Commit: Edward Tomasz Napierala > > CommitDate: 2021-05-16 10:38:26 +0000 > > > > cam: add missing zeroing of a stack-allocated CCB. > > > > This could cause a panic at boot. > > There are other instances of this, for example syzbot is currently > hitting an assertion, seemingly because the alloc_flags field of a > stack-allocated CCB was not zeroed: > https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c > > I think the patch below will fix it, but I did not audit other callers. > It feels a bit strange to require all callers of xpt_setup_ccb() to > manually zero the structure first, can we provide a single routine to > initialize stack-allocated CCBs? > If we did, we could set a flag we could assert on, and/or do static analysis to find any others... Warner diff --git a/sys/dev/virtio/scsi/virtio_scsi.c > b/sys/dev/virtio/scsi/virtio_scsi.c > index 51d9e5f532f7..adf4fd17fc5b 100644 > --- a/sys/dev/virtio/scsi/virtio_scsi.c > +++ b/sys/dev/virtio/scsi/virtio_scsi.c > @@ -700,6 +700,7 @@ vtscsi_register_async(struct vtscsi_softc *sc) > { > struct ccb_setasync csa; > > + memset(&csa, 0, sizeof(csa)); > xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); > csa.ccb_h.func_code = XPT_SASYNC_CB; > csa.event_enable = AC_LOST_DEVICE | AC_FOUND_DEVICE; > @@ -716,6 +717,7 @@ vtscsi_deregister_async(struct vtscsi_softc *sc) > { > struct ccb_setasync csa; > > + memset(&csa, 0, sizeof(csa)); > xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); > csa.ccb_h.func_code = XPT_SASYNC_CB; > csa.event_enable = 0; > From owner-dev-commits-src-all@freebsd.org Sun May 16 17:41:34 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 220DA62A33D; Sun, 16 May 2021 17:41:34 +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 4FjqM20Wd2z4tCD; Sun, 16 May 2021 17:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EE1DD1D00A; Sun, 16 May 2021 17:41:33 +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 14GHfXwv049651; Sun, 16 May 2021 17:41:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GHfXXF049650; Sun, 16 May 2021 17:41:33 GMT (envelope-from git) Date: Sun, 16 May 2021 17:41:33 GMT Message-Id: <202105161741.14GHfXXF049650@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 687e510e5ce3 - main - netgraph/ng_checksum: Fix double free error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 687e510e5ce32fddf46a9dc1d517ccc8a8e25581 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 17:41:34 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=687e510e5ce32fddf46a9dc1d517ccc8a8e25581 commit 687e510e5ce32fddf46a9dc1d517ccc8a8e25581 Author: Lutz Donnerhacke AuthorDate: 2021-05-15 09:32:57 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-16 17:39:51 +0000 netgraph/ng_checksum: Fix double free error m_pullup(9) frees the mbuf(9) chain in the case of an allocation error. The mbuf chain must not be freed again in this case. PR: 255874 Submitted by: Approved by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30273 --- sys/netgraph/ng_checksum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netgraph/ng_checksum.c b/sys/netgraph/ng_checksum.c index 682375c805da..3b542bd86acc 100644 --- a/sys/netgraph/ng_checksum.c +++ b/sys/netgraph/ng_checksum.c @@ -682,9 +682,9 @@ bypass: return (error); done: + NG_FREE_M(m); drop: NG_FREE_ITEM(item); - NG_FREE_M(m); priv->stats.dropped++; From owner-dev-commits-src-all@freebsd.org Sun May 16 17:44:20 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08AE262A83E; Sun, 16 May 2021 17:44:20 +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 4FjqQC6lTjz4tj4; Sun, 16 May 2021 17:44:19 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CEB071D190; Sun, 16 May 2021 17:44:19 +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 14GHiJOM054601; Sun, 16 May 2021 17:44:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GHiJrd054600; Sun, 16 May 2021 17:44:19 GMT (envelope-from git) Date: Sun, 16 May 2021 17:44:19 GMT Message-Id: <202105161744.14GHiJrd054600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fb580451456a - main - linux: Fix SMAP-enabled futex routines MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb580451456aa769daa2f4b2f077e39692f80c62 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 17:44:20 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fb580451456aa769daa2f4b2f077e39692f80c62 commit fb580451456aa769daa2f4b2f077e39692f80c62 Author: Mark Johnston AuthorDate: 2021-05-16 17:41:41 +0000 Commit: Mark Johnston CommitDate: 2021-05-16 17:42:08 +0000 linux: Fix SMAP-enabled futex routines Some of them were dereferencing the user pointer before disabling SMAP. PR: 255591 Reviewed by: kib Tested by: pitwuu@gmail.com Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30276 --- sys/amd64/linux/linux_support.s | 12 ++++++------ sys/amd64/linux32/linux32_support.s | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/amd64/linux/linux_support.s b/sys/amd64/linux/linux_support.s index 391f76414f22..45eb565f667d 100644 --- a/sys/amd64/linux/linux_support.s +++ b/sys/amd64/linux/linux_support.s @@ -126,16 +126,16 @@ ENTRY(futex_orl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault + stac movl (%rsi),%eax 1: movl %eax,%ecx orl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) @@ -168,16 +168,16 @@ ENTRY(futex_andl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault + stac movl (%rsi),%eax 1: movl %eax,%ecx andl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) @@ -210,16 +210,16 @@ ENTRY(futex_xorl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault + stac movl (%rsi),%eax 1: movl %eax,%ecx xorl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) diff --git a/sys/amd64/linux32/linux32_support.s b/sys/amd64/linux32/linux32_support.s index 981bba9f5821..f3ec3bd8c776 100644 --- a/sys/amd64/linux32/linux32_support.s +++ b/sys/amd64/linux32/linux32_support.s @@ -126,16 +126,16 @@ ENTRY(futex_orl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault + stac movl (%rsi),%eax 1: movl %eax,%ecx orl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) @@ -169,15 +169,15 @@ ENTRY(futex_andl_smap) cmpq %rax,%rsi ja futex_fault movl (%rsi),%eax + stac 1: movl %eax,%ecx andl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) @@ -210,16 +210,16 @@ ENTRY(futex_xorl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault + stac movl (%rsi),%eax 1: movl %eax,%ecx xorl %edi,%ecx - stac #ifdef SMP lock #endif cmpxchgl %ecx,(%rsi) - clac jnz 1b + clac movl %eax,(%rdx) xorl %eax,%eax movq %rax,PCB_ONFAULT(%r8) From owner-dev-commits-src-all@freebsd.org Sun May 16 18:03:28 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D3BA162B1A7; Sun, 16 May 2021 18:03:28 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjqrJ5HWfz3CW8; Sun, 16 May 2021 18:03:28 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wr1-x431.google.com with SMTP id i17so4075659wrq.11; Sun, 16 May 2021 11:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=RJd8EkduXX1rOocBDVC1ceaIUceaXDSc4J8sp+3rY0E=; b=OnkmTGeijHITWrzexNz32ko0Yg2nlraovElXAOFNnrxCPqiQtLYEFFkAmYyuxT6Z0W fpgQQz0G0x4YpGAbEHVbLtjUNOKBmPol7Q6FyFJrQSjpnBFKiSTn2M1bGVhXjaLG9g44 HFc5tpWj6pylpec+pgHzDvxwdXcE2dqAIB2FxtyQ65XXQHrQaCL7g06NIY8GcfVeTSvA X2PfshR+7WMycR1LlX3cqe8kWh9AL/PUq+BSo/oW46rlwn/mKWHcfYAx3R47miQDz5mo 9u2gwKEiuFo8aFbTwe9RMDK1pLvSl+CO471rpq4p6n+OeSE33mYVdsJu56V284fcNUzk A0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=RJd8EkduXX1rOocBDVC1ceaIUceaXDSc4J8sp+3rY0E=; b=ryyPzp2e2JCYebJ4OFdZLvDS4QmjH5HOAKUq4RHL751g4z7NwPU8q2W4ra7YCWr5DF QeeMCR4tSO5OrJ76VnOB27H3zub0cImJ7mU95+VZfsAhc7ojK2BnruTlTLUF/CnLtaSt Pn5yxgvmWAOPInqz037CxWPM6I3RGXtc45U/uyHCeVIXtuhzH6uW2KfgvPio5m8Y4W5C Gk+DXbMU6nkgUMUVuXPrsFLYvrZSjIVueb/BvvHOLIep1rJJBILpH930heCMEsQyx1BJ Yzp6wPLpSbC3ltEx8GvmKAXUak2fAYPWHJHVwt2GCUh/SwxI0C+T43ZlrtgUKGbNAqNd S/Nw== X-Gm-Message-State: AOAM5303VnZC1OYJLdgw2lk6xIMYqjkL/J7u62OMgt6kYbC3xo8rtW1A hNHOZ4d9Adw5WFwPHdaONCAAoQPasq0= X-Google-Smtp-Source: ABdhPJxwF1GbGE36PPtBMJ95CEir7aZlYkN79Tv1m01fmVv8BhvQbQ4quJkzgJo18Foibh70BWl4TQ== X-Received: by 2002:a05:6000:1ac7:: with SMTP id i7mr71075228wry.380.1621188206578; Sun, 16 May 2021 11:03:26 -0700 (PDT) Received: from brick (cpc159423-cmbg20-2-0-cust338.5-4.cable.virginm.net. [86.7.147.83]) by smtp.gmail.com with ESMTPSA id y14sm14129240wrr.82.2021.05.16.11.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 11:03:25 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Sun, 16 May 2021 19:03:24 +0100 From: Edward Tomasz Napierala To: Warner Losh Cc: Mark Johnston , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. Message-ID: Mail-Followup-To: Warner Losh , Mark Johnston , src-committers , "" , dev-commits-src-main@freebsd.org References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4FjqrJ5HWfz3CW8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 18:03:28 -0000 On 0516T1227, Warner Losh wrote: > On Sun, May 16, 2021, 11:55 AM Mark Johnston wrote: > > > On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala wrote: > > > The branch main has been updated by trasz: > > > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > Author: Edward Tomasz Napierala > > > AuthorDate: 2021-05-16 09:28:04 +0000 > > > Commit: Edward Tomasz Napierala > > > CommitDate: 2021-05-16 10:38:26 +0000 > > > > > > cam: add missing zeroing of a stack-allocated CCB. > > > > > > This could cause a panic at boot. > > > > There are other instances of this, for example syzbot is currently > > hitting an assertion, seemingly because the alloc_flags field of a > > stack-allocated CCB was not zeroed: > > https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c > > > > I think the patch below will fix it, but I did not audit other callers. > > It feels a bit strange to require all callers of xpt_setup_ccb() to > > manually zero the structure first, can we provide a single routine to > > initialize stack-allocated CCBs? We definitely could, although in some cases it's a bit more complicated than that - a function that gets passed a CCB and then calls xpt_setup_ccb() to fill it shouldn't zero it, as that would be making assumption on how the CCB passed to it was allocated. Now that I look at the code, I can definitely see that I've missed a couple of places. Perhaps I should replace those two KASSERTs with diagnostic printfs for now, until I get that sorted out? > If we did, we could set a flag we could assert on, and/or do static > analysis to find any others... That sounds promising, except I've never done anything like that; I don't even know where to start. From owner-dev-commits-src-all@freebsd.org Sun May 16 19:19:36 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09EE762DF65; Sun, 16 May 2021 19:19:36 +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 4FjsX76rXXz3MqF; Sun, 16 May 2021 19:19:35 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D173E1E2AE; Sun, 16 May 2021 19:19:35 +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 14GJJZOi074699; Sun, 16 May 2021 19:19:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GJJZu0074697; Sun, 16 May 2021 19:19:35 GMT (envelope-from git) Date: Sun, 16 May 2021 19:19:35 GMT Message-Id: <202105161919.14GJJZu0074697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 75b5caa08ef2 - main - cam: turn KASSERTs into printfs for now MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 75b5caa08ef286b484aee6ddae61582b8b7ac407 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 19:19:36 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=75b5caa08ef286b484aee6ddae61582b8b7ac407 commit 75b5caa08ef286b484aee6ddae61582b8b7ac407 Author: Edward Tomasz Napierala AuthorDate: 2021-05-16 19:11:46 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-16 19:19:19 +0000 cam: turn KASSERTs into printfs for now It looks like I've missed a couple of places where we don't clear stack-allocated CCBs. Don't panic when that happens, just print a warning. This is a temporary measure until I get those cases fixed. Reviewed By: markj Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30296 --- sys/cam/ata/ata_xpt.c | 8 ++++++++ sys/cam/scsi/scsi_xpt.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c index 2e3f862cbf41..08ce945a0938 100644 --- a/sys/cam/ata/ata_xpt.c +++ b/sys/cam/ata/ata_xpt.c @@ -1796,10 +1796,18 @@ ata_action(union ccb *start_ccb) { if (start_ccb->ccb_h.func_code != XPT_ATA_IO) { +#ifdef notyet KASSERT((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) == 0, ("%s: ccb %p, func_code %#x should not be allocated " "from UMA zone\n", __func__, start_ccb, start_ccb->ccb_h.func_code)); +#else + if ((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) != 0) { + printf("%s: ccb %p, func_code %#x should not be allocated " + "from UMA zone\n", + __func__, start_ccb, start_ccb->ccb_h.func_code); + } +#endif } switch (start_ccb->ccb_h.func_code) { diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 5097802c4063..b88e1869b880 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -2626,10 +2626,18 @@ scsi_action(union ccb *start_ccb) { if (start_ccb->ccb_h.func_code != XPT_SCSI_IO) { +#ifdef notyet KASSERT((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) == 0, ("%s: ccb %p, func_code %#x should not be allocated " "from UMA zone\n", __func__, start_ccb, start_ccb->ccb_h.func_code)); +#else + if ((start_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) != 0) { + printf("%s: ccb %p, func_code %#x should not be allocated " + "from UMA zone\n", + __func__, start_ccb, start_ccb->ccb_h.func_code); + } +#endif } switch (start_ccb->ccb_h.func_code) { From owner-dev-commits-src-all@freebsd.org Sun May 16 23:43:02 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 379C2635EA8; Sun, 16 May 2021 23:43:02 +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 4FjzN615drz4pLl; Sun, 16 May 2021 23:43:02 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0D5FC21C73; Sun, 16 May 2021 23:43:02 +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 14GNh1mT031584; Sun, 16 May 2021 23:43:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GNh1fS031583; Sun, 16 May 2021 23:43:01 GMT (envelope-from git) Date: Sun, 16 May 2021 23:43:01 GMT Message-Id: <202105162343.14GNh1fS031583@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 46269d66ed02 - main - NFSv4 server: Re-establish the delegation recall timeout MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46269d66ed02598c86756d81a7d7b27ec0f0c5cd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 23:43:02 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=46269d66ed02598c86756d81a7d7b27ec0f0c5cd commit 46269d66ed02598c86756d81a7d7b27ec0f0c5cd Author: Rick Macklem AuthorDate: 2021-05-16 23:40:01 +0000 Commit: Rick Macklem CommitDate: 2021-05-16 23:40:01 +0000 NFSv4 server: Re-establish the delegation recall timeout Commit 7a606f280a3e allowed the server to do retries of CB_RECALL callbacks every couple of seconds. This was needed to allow the Linux client to re-establish the back channel. However this patch broke the delegation timeout check, such that it would just keep retrying CB_RECALLS. If the client has crashed or been network patitioned from the server, this continues until the client TCP reconnects to the server and re-establishes the back channel. This patch modifies the code such that it still times out the delegation recall after some minutes, so that the server will allow the conflicting client request once the delegation times out. This patch only affects the NFSv4 server when delegations are enabled and a NFSv4 client that holds a delegation has crashed or been network partitioned from the server for at least several minutes when a delegation needs to be recalled. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 3aebddad0962..c16d5b8afdc8 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -5292,8 +5292,9 @@ nfsrv_delegconflict(struct nfsstate *stp, int *haslockp, NFSPROC_T *p, * - check to see if the delegation has expired * - if so, get the v4root lock and then expire it */ - if ((stp->ls_flags & NFSLCK_DELEGRECALL) == 0 || stp->ls_lastrecall < - time_uptime) { + if ((stp->ls_flags & NFSLCK_DELEGRECALL) == 0 || (stp->ls_lastrecall < + NFSD_MONOSEC && clp->lc_expiry >= NFSD_MONOSEC && + stp->ls_delegtime >= NFSD_MONOSEC)) { /* * - do a recall callback, since not yet done * For now, never allow truncate to be set. To use From owner-dev-commits-src-all@freebsd.org Sun May 16 23:52:15 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 86223636338; Sun, 16 May 2021 23:52:15 +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 4FjzZl3HGRz4qV8; Sun, 16 May 2021 23:52:15 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4E35922056; Sun, 16 May 2021 23:52:15 +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 14GNqFLi043784; Sun, 16 May 2021 23:52:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14GNqFGa043783; Sun, 16 May 2021 23:52:15 GMT (envelope-from git) Date: Sun, 16 May 2021 23:52:15 GMT Message-Id: <202105162352.14GNqFGa043783@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: cd192185662e - stable/13 - copy_file_range(2): improve copying of a large hole to EOF MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cd192185662ef90f52614ea17cb739f5047d5e0c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 23:52:15 -0000 The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=cd192185662ef90f52614ea17cb739f5047d5e0c commit cd192185662ef90f52614ea17cb739f5047d5e0c Author: Rick Macklem AuthorDate: 2021-05-02 23:04:27 +0000 Commit: Rick Macklem CommitDate: 2021-05-16 23:48:06 +0000 copy_file_range(2): improve copying of a large hole to EOF PR#255523 reported that a file copy for a file with a large hole to EOF on ZFS ran slowly over NFSv4.2. The problem was that vn_generic_copy_file_range() would loop around reading the hole's data and then see it is all 0s. It was coded this way since UFS always allocates a data block near the end of the file, such that a hole to EOF never exists. This patch modifies vn_generic_copy_file_range() to check for a ENXIO returned from VOP_IOCTL(..FIOSEEKDATA..) and handle that case as a hole to EOF. asomers@ confirms that it works for his ZFS test case. PR: 255523 (cherry picked from commit 4f592683c356379c5bac56b52807ed4ad54ee647) --- sys/kern/vfs_vnops.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 832c717a33b7..d4396f67a67b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3099,13 +3099,13 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags, struct ucred *incred, struct ucred *outcred, struct thread *fsize_td) { - struct vattr va; + struct vattr va, inva; struct mount *mp; struct uio io; off_t startoff, endoff, xfer, xfer2; u_long blksize; int error, interrupted; - bool cantseek, readzeros, eof, lastblock; + bool cantseek, readzeros, eof, lastblock, holetoeof; ssize_t aresid; size_t copylen, len, rem, savlen; char *dat; @@ -3122,7 +3122,11 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, goto out; if (VOP_PATHCONF(invp, _PC_MIN_HOLE_SIZE, &holein) != 0) holein = 0; + if (holein > 0) + error = VOP_GETATTR(invp, &inva, incred); VOP_UNLOCK(invp); + if (error != 0) + goto out; mp = NULL; error = vn_start_write(outvp, &mp, V_WAIT); @@ -3203,7 +3207,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, * Note that some file systems such as NFSv3, NFSv4.0 and NFSv4.1 may * support holes on the server, but do not support FIOSEEKHOLE. */ - eof = false; + holetoeof = eof = false; while (len > 0 && error == 0 && !eof && interrupted == 0) { endoff = 0; /* To shut up compilers. */ cantseek = true; @@ -3212,8 +3216,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, /* * Find the next data area. If there is just a hole to EOF, - * FIOSEEKDATA should fail and then we drop down into the - * inner loop and create the hole on the outvp file. + * FIOSEEKDATA should fail with ENXIO. * (I do not know if any file system will report a hole to * EOF via FIOSEEKHOLE, but I am pretty sure FIOSEEKDATA * will fail for those file systems.) @@ -3222,10 +3225,16 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, * the code just falls through to the inner copy loop. */ error = EINVAL; - if (holein > 0) + if (holein > 0) { error = VOP_IOCTL(invp, FIOSEEKDATA, &startoff, 0, incred, curthread); - if (error == 0) { + if (error == ENXIO) { + startoff = endoff = inva.va_size; + eof = holetoeof = true; + error = 0; + } + } + if (error == 0 && !holetoeof) { endoff = startoff; error = VOP_IOCTL(invp, FIOSEEKHOLE, &endoff, 0, incred, curthread); @@ -3256,11 +3265,12 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp, } if (error == 0 && *outoffp + xfer > - va.va_size && xfer == len) - /* Grow last block. */ + va.va_size && (xfer == len || holetoeof)) { + /* Grow output file (hole at end). */ error = vn_write_outvp(outvp, dat, *outoffp, xfer, blksize, true, false, outcred); + } if (error == 0) { *inoffp += xfer; *outoffp += xfer;