From owner-dev-commits-src-branches@freebsd.org Mon May 10 00:58:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:58:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:58:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:59:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:59:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:59:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 00:59:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 01:14:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:49:28 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:49:29 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:49:32 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:49:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:49:32 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2021 13:49:33 -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-branches@freebsd.org Mon May 10 13:49:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 13:50:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:43 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 14:32:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:02:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:08:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:17:37 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:23:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:54:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 15:56:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 16:03:27 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 16:07:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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/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-branches@freebsd.org Mon May 10 19:49:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Mon May 10 19:49:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 00:27:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 00:28:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 00:28:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 01:15:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 01:17:18 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 01:23:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 01:25:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:08 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:09 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 10:31:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Tue May 11 15:06:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:06:50 -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-branches@freebsd.org Tue May 11 15:06:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 00:12:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 02:19:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 02:22:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 02:37:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 02:43:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 02:49:26 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 08:15:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 08:16:28 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 13:31:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:50:43 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:51:00 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:51:01 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:51:03 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:51:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:57:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:57:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 15:57:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Wed May 12 16:10:18 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Thu May 13 15:02:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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/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-branches@freebsd.org Fri May 14 13:06:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:47 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:55 -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-branches@freebsd.org Fri May 14 13:06:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:55 -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-branches@freebsd.org Fri May 14 13:06:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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=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-branches@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:06:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:55 -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-branches@freebsd.org Fri May 14 13:06:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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=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-branches@freebsd.org Fri May 14 13:06:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 13:06:55 -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-branches@freebsd.org Fri May 14 13:06:56 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:57:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 13:57:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Fri May 14 14:03:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 02:17:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 02:48:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 02:52:13 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 02:53:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 02:56:24 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:00:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:01:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:02:07 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:03:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:07:54 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:10:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:11:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:14:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:19:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:25:03 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:25:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:26:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:27:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:30:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:35:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:37:30 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:38:27 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:45:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 03:46:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 04:40:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 04:40:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 04:42:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 04:43:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 08:37:23 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 08:38:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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-branches@freebsd.org Sun May 16 23:52:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org 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-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD 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;