From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 08:59: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 C623E6517DE; Mon, 14 Jun 2021 08:59: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 4G3QPF4mg8z4c6H; Mon, 14 Jun 2021 08:59: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 85E9011ECF; Mon, 14 Jun 2021 08:59: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 15E8xTvE040504; Mon, 14 Jun 2021 08:59:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15E8xT7N040503; Mon, 14 Jun 2021 08:59:29 GMT (envelope-from git) Date: Mon, 14 Jun 2021 08:59:29 GMT Message-Id: <202106140859.15E8xT7N040503@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 7a2030a10686 - stable/13 - tcp: fix compilation of IPv4-only builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7a2030a10686d156270c770d96f4ba4f86d4c58e 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, 14 Jun 2021 08:59:29 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=7a2030a10686d156270c770d96f4ba4f86d4c58e commit 7a2030a10686d156270c770d96f4ba4f86d4c58e Author: Michael Tuexen AuthorDate: 2021-06-11 07:50:46 +0000 Commit: Michael Tuexen CommitDate: 2021-06-13 23:27:17 +0000 tcp: fix compilation of IPv4-only builds PR: 256538 Reported by: iron.udjin@gmail.com Sponsored by: Netflix, Inc. (cherry picked from commit 224cf7b35b9bbe8d075f6004249d850c620b7855) --- sys/netinet/tcp_stacks/rack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index f010c958951c..c4938e7b15a6 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -17673,9 +17673,11 @@ send: th = rack->r_ctl.fsb.th; udp = rack->r_ctl.fsb.udp; if (udp) { +#ifdef INET6 if (isipv6) ulen = hdrlen + len - sizeof(struct ip6_hdr); else +#endif /* INET6 */ ulen = hdrlen + len - sizeof(struct ip); udp->uh_ulen = htons(ulen); } From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 09:00:20 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 88063651DA1; Mon, 14 Jun 2021 09:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3QQD3Jq6z4cC9; Mon, 14 Jun 2021 09:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A0C412088; Mon, 14 Jun 2021 09:00:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15E90KbW049307; Mon, 14 Jun 2021 09:00:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15E90KhK049301; Mon, 14 Jun 2021 09:00:20 GMT (envelope-from git) Date: Mon, 14 Jun 2021 09:00:20 GMT Message-Id: <202106140900.15E90KhK049301@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: fce16041a86c - stable/13 - tcp: remove debug output from RACK MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fce16041a86cfc75daea3eaeefa22a30b03df0d6 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, 14 Jun 2021 09:00:20 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=fce16041a86cfc75daea3eaeefa22a30b03df0d6 commit fce16041a86cfc75daea3eaeefa22a30b03df0d6 Author: Michael Tuexen AuthorDate: 2021-06-11 13:43:38 +0000 Commit: Michael Tuexen CommitDate: 2021-06-13 23:28:19 +0000 tcp: remove debug output from RACK Reported by: iron.udjin@gmail.com, Marek Zarychta Reviewed by: rrs PR: 256538 Differential Revision: https://reviews.freebsd.org/D30723 Sponsored by: Netflix, Inc. (cherry picked from commit f1536bb53898b12e2d19938f8fe2d04b5e5d12a6) --- sys/netinet/tcp_stacks/rack.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index c4938e7b15a6..bcf3dcc0e38a 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -589,8 +589,6 @@ rack_set_cc_pacing(struct tcp_rack *rack) rack->rc_pacing_cc_set = 1; if (strcmp(tp->cc_algo->name, CCALGONAME_NEWRENO) != 0) { /* Not new-reno we can't play games with beta! */ - printf("cc_algo:%s is not NEWRENO:%s\n", - tp->cc_algo->name, CCALGONAME_NEWRENO); goto out; } ptr = ((struct newreno *)tp->ccv->cc_data); From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 09:01: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 D4481651BE3; Mon, 14 Jun 2021 09:01: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 4G3QRS5kMYz4c2B; Mon, 14 Jun 2021 09:01: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 AE17A12257; Mon, 14 Jun 2021 09:01: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 15E91OAG049884; Mon, 14 Jun 2021 09:01:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15E91OKY049883; Mon, 14 Jun 2021 09:01:24 GMT (envelope-from git) Date: Mon, 14 Jun 2021 09:01:24 GMT Message-Id: <202106140901.15E91OKY049883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 82f75079f188 - stable/13 - tcp: fix two bugs in new reno MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 82f75079f188d15c4a2ab5eb4bdbe0414b7f7f34 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, 14 Jun 2021 09:01:24 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=82f75079f188d15c4a2ab5eb4bdbe0414b7f7f34 commit 82f75079f188d15c4a2ab5eb4bdbe0414b7f7f34 Author: Michael Tuexen AuthorDate: 2021-06-11 13:37:39 +0000 Commit: Michael Tuexen CommitDate: 2021-06-13 23:29:14 +0000 tcp: fix two bugs in new reno * Completely initialise the CC module specific data * Use beta_ecn in case of an ECN event whenever ABE is enabled or it is requested by the stack. Reviewed by: rscheff, rrs Sponsored by: Netflix, Inc. (cherry picked from commit fa3746be4203fc9a3414afb21d964eec8bad74f8) --- sys/netinet/cc/cc_newreno.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/netinet/cc/cc_newreno.c b/sys/netinet/cc/cc_newreno.c index 55cab36e149a..1ebd6200befd 100644 --- a/sys/netinet/cc/cc_newreno.c +++ b/sys/netinet/cc/cc_newreno.c @@ -111,6 +111,7 @@ newreno_malloc(struct cc_var *ccv) /* NB: nreno is not zeroed, so initialise all fields. */ nreno->beta = V_newreno_beta; nreno->beta_ecn = V_newreno_beta_ecn; + nreno->newreno_flags = 0; ccv->cc_data = nreno; } @@ -254,8 +255,9 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) * has set a flag in our newreno_flags (due to pacing) telling * us to use the lower valued back-off. */ - if (V_cc_do_abe || - (nreno && (nreno->newreno_flags & CC_NEWRENO_BETA_ECN) && (type == CC_ECN))) + if ((type == CC_ECN) && + (V_cc_do_abe || + ((nreno != NULL) && (nreno->newreno_flags & CC_NEWRENO_BETA_ECN)))) factor = beta_ecn; else factor = beta; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 16:07:21 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 1FF1764B49E; Mon, 14 Jun 2021 16:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3btx0Gzqz3j4l; Mon, 14 Jun 2021 16:07:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E20D817958; Mon, 14 Jun 2021 16:07:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15EG7Kl0016524; Mon, 14 Jun 2021 16:07:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EG7KKm016523; Mon, 14 Jun 2021 16:07:20 GMT (envelope-from git) Date: Mon, 14 Jun 2021 16:07:20 GMT Message-Id: <202106141607.15EG7KKm016523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 4a3bd4277286 - stable/13 - LinuxKPI: add pr_err_once MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4a3bd4277286909a5c20c3277c9c2f2d726a1113 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, 14 Jun 2021 16:07:21 -0000 The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=4a3bd4277286909a5c20c3277c9c2f2d726a1113 commit 4a3bd4277286909a5c20c3277c9c2f2d726a1113 Author: Greg V AuthorDate: 2021-06-07 14:30:18 +0000 Commit: Ed Maste CommitDate: 2021-06-14 16:06:09 +0000 LinuxKPI: add pr_err_once Reviewed by: hselasky, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30672 (cherry picked from commit 05c2d94a081d5948560a01c26c7f432960cde606) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 6ee292940016..46b11d89652b 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -235,6 +235,8 @@ extern int linuxkpi_debug; log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__) #define pr_err(fmt, ...) \ log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err_once(fmt, ...) \ + log_once(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warn(...) \ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 16:07:58 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 5611A64B657; Mon, 14 Jun 2021 16:07:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3bvf1vykz3jLR; Mon, 14 Jun 2021 16:07: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 2A07C17A41; Mon, 14 Jun 2021 16:07: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 15EG7wn2016704; Mon, 14 Jun 2021 16:07:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EG7wsq016702; Mon, 14 Jun 2021 16:07:58 GMT (envelope-from git) Date: Mon, 14 Jun 2021 16:07:58 GMT Message-Id: <202106141607.15EG7wsq016702@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 6bed59d60bf6 - stable/12 - LinuxKPI: add pr_err_once MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6bed59d60bf680d94933df9724547c0f9af57cb1 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, 14 Jun 2021 16:07:58 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6bed59d60bf680d94933df9724547c0f9af57cb1 commit 6bed59d60bf680d94933df9724547c0f9af57cb1 Author: Greg V AuthorDate: 2021-06-07 14:30:18 +0000 Commit: Ed Maste CommitDate: 2021-06-14 16:06:56 +0000 LinuxKPI: add pr_err_once Reviewed by: hselasky, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30672 (cherry picked from commit 05c2d94a081d5948560a01c26c7f432960cde606) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 9b0a2df72322..36d89cf83557 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -235,6 +235,8 @@ extern int linuxkpi_debug; log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__) #define pr_err(fmt, ...) \ log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err_once(fmt, ...) \ + log_once(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warn(...) \ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 16:10: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 D373C64BE24; Mon, 14 Jun 2021 16:10: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 4G3byC5bbKz3jbL; Mon, 14 Jun 2021 16:10: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 A81A217A45; Mon, 14 Jun 2021 16:10: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 15EGABjs020640; Mon, 14 Jun 2021 16:10:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EGABkb020637; Mon, 14 Jun 2021 16:10:11 GMT (envelope-from git) Date: Mon, 14 Jun 2021 16:10:11 GMT Message-Id: <202106141610.15EGABkb020637@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 626ecbc91b39 - stable/11 - LinuxKPI: add pr_err_once MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 626ecbc91b3983e0a78c41164943ef0daba7d20f 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, 14 Jun 2021 16:10:11 -0000 The branch stable/11 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=626ecbc91b3983e0a78c41164943ef0daba7d20f commit 626ecbc91b3983e0a78c41164943ef0daba7d20f Author: Greg V AuthorDate: 2021-06-07 14:30:18 +0000 Commit: Ed Maste CommitDate: 2021-06-14 16:07:39 +0000 LinuxKPI: add pr_err_once Reviewed by: hselasky, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30672 (cherry picked from commit 05c2d94a081d5948560a01c26c7f432960cde606) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 4d0d417a736b..23239e42652b 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -231,6 +231,8 @@ extern int linuxkpi_debug; log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__) #define pr_err(fmt, ...) \ log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err_once(fmt, ...) \ + log_once(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__) #define pr_warn(...) \ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 16:35: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 B88526521A7; Mon, 14 Jun 2021 16:35: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 4G3cWT4qCPz3nF9; Mon, 14 Jun 2021 16:35: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 8DE55180F9; Mon, 14 Jun 2021 16:35: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 15EGZXiU056096; Mon, 14 Jun 2021 16:35:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EGZXmh056095; Mon, 14 Jun 2021 16:35:33 GMT (envelope-from git) Date: Mon, 14 Jun 2021 16:35:33 GMT Message-Id: <202106141635.15EGZXmh056095@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: 9c84b01ac069 - stable/12 - pf: Convenience function for optional (numeric) arguments 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: 9c84b01ac069ddf50dba58f2fcff965c525dc946 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, 14 Jun 2021 16:35:33 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9c84b01ac069ddf50dba58f2fcff965c525dc946 commit 9c84b01ac069ddf50dba58f2fcff965c525dc946 Author: Kristof Provost AuthorDate: 2021-05-15 11:45:55 +0000 Commit: Kristof Provost CommitDate: 2021-06-14 16:25:16 +0000 pf: Convenience function for optional (numeric) arguments Add _opt() variants for the uint* functions. These functions set the provided default value if the nvlist doesn't contain the relevant value. This is helpful for optional values (e.g. when the API is extended to add new fields). While here simplify the header by also using macros to create the prototypes for the macro-generated function implementations. Reviewed by: scottl MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30510 (cherry picked from commit 7c4342890bf17b72f0d79ada1326d9cbf34e736c) --- sys/netpfil/pf/pf_nv.c | 15 +++++++++++++++ sys/netpfil/pf/pf_nv.h | 35 ++++++++++++++--------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index dab72f04d138..31943ba69687 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -40,6 +40,21 @@ __FBSDID("$FreeBSD$"); #include #define PF_NV_IMPL_UINT(fnname, type, max) \ + int \ + pf_nv ## fnname ## _opt(const nvlist_t *nvl, const char *name, \ + type *val, type dflt) \ + { \ + uint64_t raw; \ + if (! nvlist_exists_number(nvl, name)) { \ + *val = dflt; \ + return (0); \ + } \ + raw = nvlist_get_number(nvl, name); \ + if (raw > max) \ + return (ERANGE); \ + *val = (type)raw; \ + return (0); \ + } \ int \ pf_nv ## fnname(const nvlist_t *nvl, const char *name, type *val) \ { \ diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 321c0425fe7f..e53d19018ffe 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -56,29 +56,22 @@ SDT_PROBE_DECLARE(pf, ioctl, nvchk, error); goto errout; \ } while (0) +#define PF_NV_DEF_UINT(fnname, type, max) \ + int pf_nv ## fnname ## _opt(const nvlist_t *, const char *, \ + type *, type); \ + int pf_nv ## fnname(const nvlist_t *, const char *, type *); \ + int pf_nv ## fnname ## _array(const nvlist_t *, const char *, \ + type *,size_t, size_t *); \ + void pf_ ## fnname ## _array_nv(nvlist_t *, const char *, \ + const type *, size_t); + +PF_NV_DEF_UINT(uint8, uint8_t, UINT8_MAX); +PF_NV_DEF_UINT(uint16, uint16_t, UINT16_MAX); +PF_NV_DEF_UINT(uint32, uint32_t, UINT32_MAX); +PF_NV_DEF_UINT(uint64, uint64_t, UINT64_MAX); + int pf_nvbinary(const nvlist_t *, const char *, void *, size_t); int pf_nvint(const nvlist_t *, const char *, int *); -int pf_nvuint8(const nvlist_t *, const char *, uint8_t *); -int pf_nvuint8_array(const nvlist_t *, const char *, uint8_t *, - size_t, size_t *); -void pf_uint8_array_nv(nvlist_t *, const char *, const uint8_t *, - size_t); -int pf_nvuint16(const nvlist_t *, const char *, uint16_t *); -int pf_nvuint16_array(const nvlist_t *, const char *, uint16_t *, - size_t, size_t *); -void pf_uint16_array_nv(nvlist_t *, const char *, const uint16_t *, - size_t); -int pf_nvuint32(const nvlist_t *, const char *, uint32_t *); -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); /* Translation functions */ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 16:35: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 575C065228A; Mon, 14 Jun 2021 16:35: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 4G3cWV1ygkz3nFB; Mon, 14 Jun 2021 16:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 26D1517EFC; Mon, 14 Jun 2021 16:35:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15EGZYxa056176; Mon, 14 Jun 2021 16:35:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EGZYjE056175; Mon, 14 Jun 2021 16:35:34 GMT (envelope-from git) Date: Mon, 14 Jun 2021 16:35:34 GMT Message-Id: <202106141635.15EGZYjE056175@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: 832594e4e294 - stable/13 - pf: Convenience function for optional (numeric) arguments 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: 832594e4e29485880cb6db2bacfdc26e74ea7258 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, 14 Jun 2021 16:35:34 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=832594e4e29485880cb6db2bacfdc26e74ea7258 commit 832594e4e29485880cb6db2bacfdc26e74ea7258 Author: Kristof Provost AuthorDate: 2021-05-15 11:45:55 +0000 Commit: Kristof Provost CommitDate: 2021-06-14 16:14:23 +0000 pf: Convenience function for optional (numeric) arguments Add _opt() variants for the uint* functions. These functions set the provided default value if the nvlist doesn't contain the relevant value. This is helpful for optional values (e.g. when the API is extended to add new fields). While here simplify the header by also using macros to create the prototypes for the macro-generated function implementations. Reviewed by: scottl MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30510 (cherry picked from commit 7c4342890bf17b72f0d79ada1326d9cbf34e736c) --- sys/netpfil/pf/pf_nv.c | 15 +++++++++++++++ sys/netpfil/pf/pf_nv.h | 35 ++++++++++++++--------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/sys/netpfil/pf/pf_nv.c b/sys/netpfil/pf/pf_nv.c index dab72f04d138..31943ba69687 100644 --- a/sys/netpfil/pf/pf_nv.c +++ b/sys/netpfil/pf/pf_nv.c @@ -40,6 +40,21 @@ __FBSDID("$FreeBSD$"); #include #define PF_NV_IMPL_UINT(fnname, type, max) \ + int \ + pf_nv ## fnname ## _opt(const nvlist_t *nvl, const char *name, \ + type *val, type dflt) \ + { \ + uint64_t raw; \ + if (! nvlist_exists_number(nvl, name)) { \ + *val = dflt; \ + return (0); \ + } \ + raw = nvlist_get_number(nvl, name); \ + if (raw > max) \ + return (ERANGE); \ + *val = (type)raw; \ + return (0); \ + } \ int \ pf_nv ## fnname(const nvlist_t *nvl, const char *name, type *val) \ { \ diff --git a/sys/netpfil/pf/pf_nv.h b/sys/netpfil/pf/pf_nv.h index 321c0425fe7f..e53d19018ffe 100644 --- a/sys/netpfil/pf/pf_nv.h +++ b/sys/netpfil/pf/pf_nv.h @@ -56,29 +56,22 @@ SDT_PROBE_DECLARE(pf, ioctl, nvchk, error); goto errout; \ } while (0) +#define PF_NV_DEF_UINT(fnname, type, max) \ + int pf_nv ## fnname ## _opt(const nvlist_t *, const char *, \ + type *, type); \ + int pf_nv ## fnname(const nvlist_t *, const char *, type *); \ + int pf_nv ## fnname ## _array(const nvlist_t *, const char *, \ + type *,size_t, size_t *); \ + void pf_ ## fnname ## _array_nv(nvlist_t *, const char *, \ + const type *, size_t); + +PF_NV_DEF_UINT(uint8, uint8_t, UINT8_MAX); +PF_NV_DEF_UINT(uint16, uint16_t, UINT16_MAX); +PF_NV_DEF_UINT(uint32, uint32_t, UINT32_MAX); +PF_NV_DEF_UINT(uint64, uint64_t, UINT64_MAX); + int pf_nvbinary(const nvlist_t *, const char *, void *, size_t); int pf_nvint(const nvlist_t *, const char *, int *); -int pf_nvuint8(const nvlist_t *, const char *, uint8_t *); -int pf_nvuint8_array(const nvlist_t *, const char *, uint8_t *, - size_t, size_t *); -void pf_uint8_array_nv(nvlist_t *, const char *, const uint8_t *, - size_t); -int pf_nvuint16(const nvlist_t *, const char *, uint16_t *); -int pf_nvuint16_array(const nvlist_t *, const char *, uint16_t *, - size_t, size_t *); -void pf_uint16_array_nv(nvlist_t *, const char *, const uint16_t *, - size_t); -int pf_nvuint32(const nvlist_t *, const char *, uint32_t *); -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); /* Translation functions */ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 19:05: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 342316494CA; Mon, 14 Jun 2021 19:05: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 4G3grm0rn2z4ZBF; Mon, 14 Jun 2021 19:05: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 05A6C1A244; Mon, 14 Jun 2021 19:05: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 15EJ5hWu065334; Mon, 14 Jun 2021 19:05:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EJ5hZp065333; Mon, 14 Jun 2021 19:05:43 GMT (envelope-from git) Date: Mon, 14 Jun 2021 19:05:43 GMT Message-Id: <202106141905.15EJ5hZp065333@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Neel Chauhan Subject: git: 210349325af9 - stable/13 - linuxkpi: Add list_for_each_entry_lockless() macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nc X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 210349325af9920d1535ad76fa3b92847684f6e0 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, 14 Jun 2021 19:05:44 -0000 The branch stable/13 has been updated by nc (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=210349325af9920d1535ad76fa3b92847684f6e0 commit 210349325af9920d1535ad76fa3b92847684f6e0 Author: Neel Chauhan AuthorDate: 2021-06-10 15:14:20 +0000 Commit: Neel Chauhan CommitDate: 2021-06-14 19:05:39 +0000 linuxkpi: Add list_for_each_entry_lockless() macro This is needed by the drm-kmod 5.7 update. Approved by: hselasky (src) Differential Revision: https://reviews.freebsd.org/D30708 (cherry picked from commit b47f461c8e67253fdb394968428b760e880baa08) --- sys/compat/linuxkpi/common/include/linux/list.h | 2 ++ sys/sys/param.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h index 1f3db8e43a08..977207376c45 100644 --- a/sys/compat/linuxkpi/common/include/linux/list.h +++ b/sys/compat/linuxkpi/common/include/linux/list.h @@ -197,6 +197,8 @@ list_del_init(struct list_head *entry) for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \ p = list_entry((p)->field.next, typeof(*p), field)) +#define list_for_each_entry_lockless(...) list_for_each_entry(__VA_ARGS__) + #define list_for_each_entry_safe(p, n, h, field) \ for (p = list_entry((h)->next, typeof(*p), field), \ n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\ diff --git a/sys/sys/param.h b/sys/sys/param.h index 22b93e1d17fa..9a5716635a2f 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 1300508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300509 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20: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 E472B6501B9; Mon, 14 Jun 2021 20: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 4G3jcH5sYtz4l0q; Mon, 14 Jun 2021 20: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 B18E61B581; Mon, 14 Jun 2021 20: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 15EKP3ZD072955; Mon, 14 Jun 2021 20: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 15EKP3Zm072954; Mon, 14 Jun 2021 20:25:03 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:03 GMT Message-Id: <202106142025.15EKP3Zm072954@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: 4e30dd0567da - stable/12 - ngatm: Handle errors from uni_msg_extend() 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: 4e30dd0567da0ce7e34d9a3438e978465584b161 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, 14 Jun 2021 20:25:04 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4e30dd0567da0ce7e34d9a3438e978465584b161 commit 4e30dd0567da0ce7e34d9a3438e978465584b161 Author: Mark Johnston AuthorDate: 2021-06-06 20:42:16 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:24:48 +0000 ngatm: Handle errors from uni_msg_extend() uni_msg_extend() may fail due to a memory allocation failure. In this case, though, the message is freed, so callers shouldn't touch it. PR: 255861 Reviewed by: harti Sponsored by: The FreeBSD Foundation (cherry picked from commit e755e2776ddff729ae4102f3273473aa33b00077) --- sys/contrib/ngatm/netnatm/msg/uni_ie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/contrib/ngatm/netnatm/msg/uni_ie.c b/sys/contrib/ngatm/netnatm/msg/uni_ie.c index e4b8310d88d9..3842279c63a1 100644 --- a/sys/contrib/ngatm/netnatm/msg/uni_ie.c +++ b/sys/contrib/ngatm/netnatm/msg/uni_ie.c @@ -216,7 +216,8 @@ uni_encode_msg_hdr(struct uni_msg *msg, struct uni_msghdr *h, { u_char byte; - (void)uni_msg_ensure(msg, 9); + if (uni_msg_ensure(msg, 9) != 0) + return -1; APP_BYTE(msg, cx->pnni ? PNNI_PROTO : UNI_PROTO); APP_BYTE(msg, 3); @@ -654,7 +655,8 @@ uni_encode_ie_hdr(struct uni_msg *msg, enum uni_ietype type, { u_char byte; - (void)uni_msg_ensure(msg, 4 + len); + if (uni_msg_ensure(msg, 4 + len) != 0) + return -1; *msg->b_wptr++ = type; byte = 0x80 | (h->coding << 5); From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 0D312650241; Mon, 14 Jun 2021 20:25: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 4G3jcJ6srTz4kjZ; Mon, 14 Jun 2021 20: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 D49381B3AB; Mon, 14 Jun 2021 20: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 15EKP4a6072984; Mon, 14 Jun 2021 20: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 15EKP4sr072983; Mon, 14 Jun 2021 20:25:04 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:04 GMT Message-Id: <202106142025.15EKP4sr072983@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: 71efecb7eb1a - stable/12 - iwn: adjust EEPROM read timeout for Intel 4965AGN M2 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: 71efecb7eb1ad713f2d4c58f479baaf0bd861db0 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, 14 Jun 2021 20:25:05 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71efecb7eb1ad713f2d4c58f479baaf0bd861db0 commit 71efecb7eb1ad713f2d4c58f479baaf0bd861db0 Author: Radosław Chmielarz AuthorDate: 2021-06-06 20:42:10 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:24:48 +0000 iwn: adjust EEPROM read timeout for Intel 4965AGN M2 Reading EEPROM from Intel 4965AGN M2 takes 60 us which was causing panic on system startup. PR: 255465 Reviewed by: markj (cherry picked from commit 03d4b58feee396d392668f192ecdde08ecc8036c) --- sys/dev/iwn/if_iwn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 47beef785069..1c2679b6583a 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -1688,13 +1688,13 @@ iwn_read_prom_data(struct iwn_softc *sc, uint32_t addr, void *data, int count) addr += sc->prom_base; for (; count > 0; count -= 2, addr++) { IWN_WRITE(sc, IWN_EEPROM, addr << 2); - for (ntries = 0; ntries < 10; ntries++) { + for (ntries = 0; ntries < 20; ntries++) { val = IWN_READ(sc, IWN_EEPROM); if (val & IWN_EEPROM_READ_VALID) break; DELAY(5); } - if (ntries == 10) { + if (ntries == 20) { device_printf(sc->sc_dev, "timeout reading ROM at 0x%x\n", addr); return ETIMEDOUT; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25:22 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 8131A650516; Mon, 14 Jun 2021 20:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3jcf3J0Jz4kxv; Mon, 14 Jun 2021 20:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 59C361B341; Mon, 14 Jun 2021 20:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15EKPMrf073166; Mon, 14 Jun 2021 20:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPMNd073165; Mon, 14 Jun 2021 20:25:22 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:22 GMT Message-Id: <202106142025.15EKPMNd073165@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: e58cb5c01de9 - stable/13 - arm64: Use the right PTE when downgrading perms in pmap_promote_l2() 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: e58cb5c01de989c8f88af3732a5fe404b0660a9c 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, 14 Jun 2021 20:25:22 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e58cb5c01de989c8f88af3732a5fe404b0660a9c commit e58cb5c01de989c8f88af3732a5fe404b0660a9c Author: Mark Johnston AuthorDate: 2021-06-06 20:40:29 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:14 +0000 arm64: Use the right PTE when downgrading perms in pmap_promote_l2() When promoting a run of small mappings to a superpage, we have to downgrade clean, writable mappings to read-only, to handle the possibility that the MMU will concurrently mark one of the mappings as dirty. The code which performed this operation for the first PTE in the run used the wrong PTE pointer. As a result, the comparison would always fail, aborting the promotion. This only occurs when promoting writable, clean mappings. Fixes: ca2cae0b4dd Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit a48f51b3d396664f9b0a91f016159f4e4324da85) --- sys/arm64/arm64/pmap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index efe6bdd3d034..b49ec4194e19 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -3518,7 +3518,11 @@ setl2: if ((newl2 & (ATTR_S1_AP_RW_BIT | ATTR_SW_DBM)) == (ATTR_S1_AP(ATTR_S1_AP_RO) | ATTR_SW_DBM)) { - if (!atomic_fcmpset_64(l2, &newl2, newl2 & ~ATTR_SW_DBM)) + /* + * When the mapping is clean, i.e., ATTR_S1_AP_RO is set, + * ATTR_SW_DBM can be cleared without a TLB invalidation. + */ + if (!atomic_fcmpset_64(firstl3, &newl2, newl2 & ~ATTR_SW_DBM)) goto setl2; newl2 &= ~ATTR_SW_DBM; } @@ -3529,6 +3533,11 @@ setl2: setl3: if ((oldl3 & (ATTR_S1_AP_RW_BIT | ATTR_SW_DBM)) == (ATTR_S1_AP(ATTR_S1_AP_RO) | ATTR_SW_DBM)) { + /* + * When the mapping is clean, i.e., ATTR_S1_AP_RO is + * set, ATTR_SW_DBM can be cleared without a TLB + * invalidation. + */ if (!atomic_fcmpset_64(l3, &oldl3, oldl3 & ~ATTR_SW_DBM)) goto setl3; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 DEFF16502A5; Mon, 14 Jun 2021 20:25: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 4G3jcg5N8Mz4l3V; Mon, 14 Jun 2021 20:25: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 815C81B583; Mon, 14 Jun 2021 20:25: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 15EKPNXD073190; Mon, 14 Jun 2021 20:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPNOa073189; Mon, 14 Jun 2021 20:25:23 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:23 GMT Message-Id: <202106142025.15EKPNOa073189@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: 09e47586d72f - stable/13 - ngatm: Handle errors from uni_msg_extend() 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: 09e47586d72f4940eea1e70df706dbc165ad0415 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, 14 Jun 2021 20:25:24 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=09e47586d72f4940eea1e70df706dbc165ad0415 commit 09e47586d72f4940eea1e70df706dbc165ad0415 Author: Mark Johnston AuthorDate: 2021-06-06 20:42:16 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:14 +0000 ngatm: Handle errors from uni_msg_extend() uni_msg_extend() may fail due to a memory allocation failure. In this case, though, the message is freed, so callers shouldn't touch it. PR: 255861 Reviewed by: harti Sponsored by: The FreeBSD Foundation (cherry picked from commit e755e2776ddff729ae4102f3273473aa33b00077) --- sys/contrib/ngatm/netnatm/msg/uni_ie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/contrib/ngatm/netnatm/msg/uni_ie.c b/sys/contrib/ngatm/netnatm/msg/uni_ie.c index e4b8310d88d9..3842279c63a1 100644 --- a/sys/contrib/ngatm/netnatm/msg/uni_ie.c +++ b/sys/contrib/ngatm/netnatm/msg/uni_ie.c @@ -216,7 +216,8 @@ uni_encode_msg_hdr(struct uni_msg *msg, struct uni_msghdr *h, { u_char byte; - (void)uni_msg_ensure(msg, 9); + if (uni_msg_ensure(msg, 9) != 0) + return -1; APP_BYTE(msg, cx->pnni ? PNNI_PROTO : UNI_PROTO); APP_BYTE(msg, 3); @@ -654,7 +655,8 @@ uni_encode_ie_hdr(struct uni_msg *msg, enum uni_ietype type, { u_char byte; - (void)uni_msg_ensure(msg, 4 + len); + if (uni_msg_ensure(msg, 4 + len) != 0) + return -1; *msg->b_wptr++ = type; byte = 0x80 | (h->coding << 5); From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 E64A2650521; Mon, 14 Jun 2021 20:25: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 4G3jch5tLhz4l3d; Mon, 14 Jun 2021 20:25: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 A06661B50F; Mon, 14 Jun 2021 20:25: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 15EKPOlG073214; Mon, 14 Jun 2021 20:25:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPOZg073213; Mon, 14 Jun 2021 20:25:24 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:24 GMT Message-Id: <202106142025.15EKPOZg073213@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: 67b7e2de4fc5 - stable/13 - iwn: adjust EEPROM read timeout for Intel 4965AGN M2 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: 67b7e2de4fc5dc1165feee8ca281c44444425d0f 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, 14 Jun 2021 20:25:25 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=67b7e2de4fc5dc1165feee8ca281c44444425d0f commit 67b7e2de4fc5dc1165feee8ca281c44444425d0f Author: Radosław Chmielarz AuthorDate: 2021-06-06 20:42:10 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:14 +0000 iwn: adjust EEPROM read timeout for Intel 4965AGN M2 Reading EEPROM from Intel 4965AGN M2 takes 60 us which was causing panic on system startup. PR: 255465 Reviewed by: markj (cherry picked from commit 03d4b58feee396d392668f192ecdde08ecc8036c) --- sys/dev/iwn/if_iwn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 2121a15bad6e..334ba644e04b 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -1688,13 +1688,13 @@ iwn_read_prom_data(struct iwn_softc *sc, uint32_t addr, void *data, int count) addr += sc->prom_base; for (; count > 0; count -= 2, addr++) { IWN_WRITE(sc, IWN_EEPROM, addr << 2); - for (ntries = 0; ntries < 10; ntries++) { + for (ntries = 0; ntries < 20; ntries++) { val = IWN_READ(sc, IWN_EEPROM); if (val & IWN_EEPROM_READ_VALID) break; DELAY(5); } - if (ntries == 10) { + if (ntries == 20) { device_printf(sc->sc_dev, "timeout reading ROM at 0x%x\n", addr); return ETIMEDOUT; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 0766965032A; Mon, 14 Jun 2021 20:25: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 4G3jcj68JYz4l3m; Mon, 14 Jun 2021 20:25: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 BB5E31B584; Mon, 14 Jun 2021 20:25: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 15EKPPW8073238; Mon, 14 Jun 2021 20:25:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPP4Y073237; Mon, 14 Jun 2021 20:25:25 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:25 GMT Message-Id: <202106142025.15EKPP4Y073237@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: 5346c8bc543a - stable/13 - Suppress D_NEEDGIANT warnings for some drivers 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: 5346c8bc543a09932b168f459e8a7a601af4bfdc 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, 14 Jun 2021 20:25:26 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5346c8bc543a09932b168f459e8a7a601af4bfdc commit 5346c8bc543a09932b168f459e8a7a601af4bfdc Author: Mark Johnston AuthorDate: 2021-06-06 20:40:19 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:14 +0000 Suppress D_NEEDGIANT warnings for some drivers During boot we warn that the kbd and openfirm drivers are Giant-locked and may be deleted. Generally, the warning helps signal that certain old drivers are not being maintained and are subject to removal, but this doesn't really apply to certain drivers which are harder to detangle from Giant. Add a flag, D_GIANTOK, that devices can specify to suppress the misleading warning. Use it in the kbd and openfirm drivers. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit fbeb4ccac990fdb3bc26ab925a3ca8e7d2f89721) --- sys/dev/kbd/kbd.c | 2 +- sys/dev/ofw/openfirmio.c | 2 +- sys/kern/kern_conf.c | 2 +- sys/sys/conf.h | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index fd996f7a06ad..70c0ef15a56e 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -453,7 +453,7 @@ static d_poll_t genkbdpoll; static struct cdevsw kbd_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, + .d_flags = D_NEEDGIANT | D_GIANTOK, .d_open = genkbdopen, .d_close = genkbdclose, .d_read = genkbdread, diff --git a/sys/dev/ofw/openfirmio.c b/sys/dev/ofw/openfirmio.c index 2112d45d4dd9..30afb85baf8a 100644 --- a/sys/dev/ofw/openfirmio.c +++ b/sys/dev/ofw/openfirmio.c @@ -66,7 +66,7 @@ static d_ioctl_t openfirm_ioctl; static struct cdevsw openfirm_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, + .d_flags = D_NEEDGIANT | D_GIANTOK, .d_ioctl = openfirm_ioctl, .d_name = "openfirm", }; diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 3a07c95e74d0..42435c0b8740 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -665,7 +665,7 @@ prep_cdevsw(struct cdevsw *devsw, int flags) devsw->d_kqfilter = dead_kqfilter; } - if (devsw->d_flags & D_NEEDGIANT) { + if ((devsw->d_flags & (D_NEEDGIANT | D_GIANTOK)) == D_NEEDGIANT) { printf("WARNING: Device \"%s\" is Giant locked and may be " "deleted before FreeBSD 14.0.\n", devsw->d_name == NULL ? "???" : devsw->d_name); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 2a87e5d3a9ca..123bf91cf952 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -173,6 +173,7 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh, */ #define D_TRACKCLOSE 0x00080000 /* track all closes */ #define D_MMAP_ANON 0x00100000 /* special treatment in vm_mmap.c */ +#define D_GIANTOK 0x00200000 /* suppress warning about using Giant */ #define D_NEEDGIANT 0x00400000 /* driver want Giant */ #define D_NEEDMINOR 0x00800000 /* driver uses clone_create() */ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 961E46502D9; Mon, 14 Jun 2021 20:25: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 4G3jcp3K3gz4kk2; Mon, 14 Jun 2021 20:25: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 59AE91B511; Mon, 14 Jun 2021 20:25: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 15EKPUwe073341; Mon, 14 Jun 2021 20:25:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPUDt073340; Mon, 14 Jun 2021 20:25:30 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:30 GMT Message-Id: <202106142025.15EKPUDt073340@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: 129fb0fb0282 - stable/13 - Fix handling of D_GIANTOK 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: 129fb0fb02828adf71d457bb20aab48b7d88b287 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, 14 Jun 2021 20:25:30 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=129fb0fb02828adf71d457bb20aab48b7d88b287 commit 129fb0fb02828adf71d457bb20aab48b7d88b287 Author: Mark Johnston AuthorDate: 2021-06-07 18:25:26 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:15 +0000 Fix handling of D_GIANTOK It was meant to suppress only the printf(), not the subsequent injection of Giant-protected thunks for various file operations. Fixes: fbeb4ccac9 Reported by: pho Tested by: pho Pointy hat: markj (cherry picked from commit 887c753c9f451322cae3efbf9b63f53f3d9011c8) --- sys/kern/kern_conf.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 42435c0b8740..cb575114571a 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -665,10 +665,13 @@ prep_cdevsw(struct cdevsw *devsw, int flags) devsw->d_kqfilter = dead_kqfilter; } - if ((devsw->d_flags & (D_NEEDGIANT | D_GIANTOK)) == D_NEEDGIANT) { - printf("WARNING: Device \"%s\" is Giant locked and may be " - "deleted before FreeBSD 14.0.\n", - devsw->d_name == NULL ? "???" : devsw->d_name); + if ((devsw->d_flags & D_NEEDGIANT) != 0) { + if ((devsw->d_flags & D_GIANTOK) == 0) { + printf( + "WARNING: Device \"%s\" is Giant locked and may be " + "deleted before FreeBSD 14.0.\n", + devsw->d_name == NULL ? "???" : devsw->d_name); + } if (devsw->d_gianttrick == NULL) { memcpy(dsw2, devsw, sizeof *dsw2); devsw->d_gianttrick = dsw2; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 7451F650450; Mon, 14 Jun 2021 20:25: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 4G3jcn5ZCFz4kvw; Mon, 14 Jun 2021 20:25: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 3A92A1B510; Mon, 14 Jun 2021 20:25: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 15EKPTJc073317; Mon, 14 Jun 2021 20:25:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPTve073316; Mon, 14 Jun 2021 20:25:29 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:29 GMT Message-Id: <202106142025.15EKPTve073316@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: 368b1cd57190 - stable/13 - riscv: Rename pmap_fault_fixup() to pmap_fault() 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: 368b1cd57190757c5fbadd83ce002f7943a3e7ec 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, 14 Jun 2021 20:25:30 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=368b1cd57190757c5fbadd83ce002f7943a3e7ec commit 368b1cd57190757c5fbadd83ce002f7943a3e7ec Author: Mark Johnston AuthorDate: 2021-06-06 20:42:00 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:15 +0000 riscv: Rename pmap_fault_fixup() to pmap_fault() This is consistent with other platforms, specifically arm and arm64. No functional change intended. Reviewed by: jrtc27 Sponsored by: The FreeBSD Foundation (cherry picked from commit 317113bb125166f6ba3035a29408339af38cca54) --- sys/riscv/include/pmap.h | 2 +- sys/riscv/riscv/pmap.c | 2 +- sys/riscv/riscv/trap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h index 9a1f23b20245..64b529e95887 100644 --- a/sys/riscv/include/pmap.h +++ b/sys/riscv/include/pmap.h @@ -160,7 +160,7 @@ void pmap_unmap_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t); bool pmap_get_tables(pmap_t, vm_offset_t, pd_entry_t **, pd_entry_t **, pt_entry_t **); -int pmap_fault_fixup(pmap_t, vm_offset_t, vm_prot_t); +int pmap_fault(pmap_t, vm_offset_t, vm_prot_t); static inline int pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 0f2834febd41..9761d97f449a 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -2382,7 +2382,7 @@ retryl3: } int -pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_t ftype) +pmap_fault(pmap_t pmap, vm_offset_t va, vm_prot_t ftype) { pd_entry_t *l2, l2e; pt_entry_t bits, *pte, oldpte; diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index 599fd64b56be..88c6adf5623b 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -228,7 +228,7 @@ page_fault_handler(struct trapframe *frame, int usermode) ftype = VM_PROT_READ; } - if (pmap_fault_fixup(map->pmap, va, ftype)) + if (pmap_fault(map->pmap, va, ftype)) goto done; error = vm_fault_trap(map, va, ftype, VM_FAULT_NORMAL, &sig, &ucode); From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 8F3DA6502BB; Mon, 14 Jun 2021 20:25: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 4G3jcl1JS4z4l5n; Mon, 14 Jun 2021 20:25: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 E6C7E1B585; Mon, 14 Jun 2021 20:25: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 15EKPQoq073262; Mon, 14 Jun 2021 20:25:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPQnV073261; Mon, 14 Jun 2021 20:25:26 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:26 GMT Message-Id: <202106142025.15EKPQnV073261@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: 25b73f214418 - stable/13 - riscv: Handle hardware-managed dirty bit updates in pmap_promote_l2() 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: 25b73f21441893423d00b6631ad22c7d0ad4b0d2 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, 14 Jun 2021 20:25:28 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=25b73f21441893423d00b6631ad22c7d0ad4b0d2 commit 25b73f21441893423d00b6631ad22c7d0ad4b0d2 Author: Mark Johnston AuthorDate: 2021-06-06 20:41:35 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:15 +0000 riscv: Handle hardware-managed dirty bit updates in pmap_promote_l2() pmap_promote_l2() failed to handle implementations which set the accessed and dirty flags. In particular, when comparing the attributes of a run of 512 PTEs, we must handle the possibility that the hardware will set PTE_D on a clean, writable mapping. Following the example of amd64 and arm64, change riscv's pmap_promote_l2() to downgrade clean, writable mappings to read-only, so that updates are synchronized by the pmap lock. Fixes: f6893f09d Reported by: Nathaniel Filardo Tested by: Nathaniel Filardo Reviewed by: jrtc27, alc, Nathaniel Filardo Sponsored by: The FreeBSD Foundation (cherry picked from commit c05748e028b84c216d0161e70418f8cb09e074e4) --- sys/riscv/riscv/pmap.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index f30dda17afae..0f2834febd41 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -2540,7 +2540,7 @@ static void pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, struct rwlock **lockp) { - pt_entry_t *firstl3, *l3; + pt_entry_t *firstl3, firstl3e, *l3, l3e; vm_paddr_t pa; vm_page_t ml3; @@ -2551,7 +2551,8 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, ("pmap_promote_l2: invalid l2 entry %p", l2)); firstl3 = (pt_entry_t *)PHYS_TO_DMAP(PTE_TO_PHYS(pmap_load(l2))); - pa = PTE_TO_PHYS(pmap_load(firstl3)); + firstl3e = pmap_load(firstl3); + pa = PTE_TO_PHYS(firstl3e); if ((pa & L2_OFFSET) != 0) { CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); @@ -2559,17 +2560,40 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, return; } + /* + * Downgrade a clean, writable mapping to read-only to ensure that the + * hardware does not set PTE_D while we are comparing PTEs. + * + * Upon a write access to a clean mapping, the implementation will + * either atomically check protections and set PTE_D, or raise a page + * fault. In the latter case, the pmap lock provides atomicity. Thus, + * we do not issue an sfence.vma here and instead rely on pmap_fault() + * to do so lazily. + */ + while ((firstl3e & (PTE_W | PTE_D)) == PTE_W) { + if (atomic_fcmpset_64(firstl3, &firstl3e, firstl3e & ~PTE_W)) { + firstl3e &= ~PTE_W; + break; + } + } + pa += PAGE_SIZE; for (l3 = firstl3 + 1; l3 < firstl3 + Ln_ENTRIES; l3++) { - if (PTE_TO_PHYS(pmap_load(l3)) != pa) { + l3e = pmap_load(l3); + if (PTE_TO_PHYS(l3e) != pa) { CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); atomic_add_long(&pmap_l2_p_failures, 1); return; } - if ((pmap_load(l3) & PTE_PROMOTE) != - (pmap_load(firstl3) & PTE_PROMOTE)) { + while ((l3e & (PTE_W | PTE_D)) == PTE_W) { + if (atomic_fcmpset_64(l3, &l3e, l3e & ~PTE_W)) { + l3e &= ~PTE_W; + break; + } + } + if ((l3e & PTE_PROMOTE) != (firstl3e & PTE_PROMOTE)) { CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); @@ -2589,11 +2613,10 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, return; } - if ((pmap_load(firstl3) & PTE_SW_MANAGED) != 0) - pmap_pv_promote_l2(pmap, va, PTE_TO_PHYS(pmap_load(firstl3)), - lockp); + if ((firstl3e & PTE_SW_MANAGED) != 0) + pmap_pv_promote_l2(pmap, va, PTE_TO_PHYS(firstl3e), lockp); - pmap_store(l2, pmap_load(firstl3)); + pmap_store(l2, firstl3e); atomic_add_long(&pmap_l2_promotions, 1); CTR2(KTR_PMAP, "pmap_promote_l2: success for va %#lx in pmap %p", va, From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 58CFA650445; Mon, 14 Jun 2021 20:25: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 4G3jcm1XyVz4l3s; Mon, 14 Jun 2021 20:25: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 1514C1B3AD; Mon, 14 Jun 2021 20:25: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 15EKPRpX073293; Mon, 14 Jun 2021 20:25:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPRsD073292; Mon, 14 Jun 2021 20:25:27 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:27 GMT Message-Id: <202106142025.15EKPRsD073292@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: aa8280a90204 - stable/13 - arm: Remove last_fault_code 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: aa8280a90204c25a53851f8a68c6bdf2cb0111ef 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, 14 Jun 2021 20:25:28 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=aa8280a90204c25a53851f8a68c6bdf2cb0111ef commit aa8280a90204c25a53851f8a68c6bdf2cb0111ef Author: Mark Johnston AuthorDate: 2021-06-06 20:42:13 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:15 +0000 arm: Remove last_fault_code It is unused since the removal of pmap-v4.c in commit b88b275145. Sponsored by: The FreeBSD Foundation (cherry picked from commit 62ba0def5584bc1fc84fc7df6d7a1256e4a34fb8) --- sys/arm/arm/trap-v6.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sys/arm/arm/trap-v6.c b/sys/arm/arm/trap-v6.c index 16f166e83114..cd141376d381 100644 --- a/sys/arm/arm/trap-v6.c +++ b/sys/arm/arm/trap-v6.c @@ -70,10 +70,6 @@ __FBSDID("$FreeBSD$"); extern char cachebailout[]; -#ifdef DEBUG -int last_fault_code; /* For the benefit of pmap_fault_fixup() */ -#endif - struct ksig { int sig; u_long code; @@ -495,10 +491,6 @@ abort_handler(struct trapframe *tf, int prefetch) if (prefetch) ftype |= VM_PROT_EXECUTE; -#ifdef DEBUG - last_fault_code = fsr; -#endif - #ifdef INVARIANTS onfault = pcb->pcb_onfault; pcb->pcb_onfault = NULL; From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:25: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 8A85165033C; Mon, 14 Jun 2021 20:25: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 4G3jcq6drzz4kkC; Mon, 14 Jun 2021 20:25: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 7D2211AFB3; Mon, 14 Jun 2021 20:25: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 15EKPV1q073365; Mon, 14 Jun 2021 20:25:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKPVgP073364; Mon, 14 Jun 2021 20:25:31 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:25:31 GMT Message-Id: <202106142025.15EKPVgP073364@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: fa3cfd1a845a - stable/13 - arm64: Fix pmap_copy()'s handling of 2MB mappings 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: fa3cfd1a845a33dbee88fcd80599c3ecc3268e26 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, 14 Jun 2021 20:25:32 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fa3cfd1a845a33dbee88fcd80599c3ecc3268e26 commit fa3cfd1a845a33dbee88fcd80599c3ecc3268e26 Author: Mark Johnston AuthorDate: 2021-06-06 20:40:45 +0000 Commit: Mark Johnston CommitDate: 2021-06-14 20:25:15 +0000 arm64: Fix pmap_copy()'s handling of 2MB mappings When copying mappings from parent to child, we clear the accessed and dirty bits. This is done for both 4KB and 2MB PTEs. However, pmap_demote_l2() asserts that writable superpages must be dirty. This is to avoid races with the MMU setting the dirty bit during promotion and demotion. pmap_copy() can create clean, writable superpage mappings, so it violates this assertion. Modify pmap_copy() to preserve the accessed and dirty bits when copying 2MB mappings, like we do on amd64. Fixes: ca2cae0b4dd Reported by: Jenkins via mhorne Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30643 (cherry picked from commit 4e4035ef1fb5e2f9da6b658ffae8a54862b4d018) --- sys/arm64/arm64/pmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index b49ec4194e19..e9dd27981d61 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -4751,11 +4751,8 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t len, ((srcptepaddr & ATTR_SW_MANAGED) == 0 || pmap_pv_insert_l2(dst_pmap, addr, srcptepaddr, PMAP_ENTER_NORECLAIM, &lock))) { - mask = ATTR_AF | ATTR_SW_WIRED; - nbits = 0; - if ((srcptepaddr & ATTR_SW_DBM) != 0) - nbits |= ATTR_S1_AP_RW_BIT; - pmap_store(l2, (srcptepaddr & ~mask) | nbits); + mask = ATTR_SW_WIRED; + pmap_store(l2, srcptepaddr & ~mask); pmap_resident_count_inc(dst_pmap, L2_SIZE / PAGE_SIZE); atomic_add_long(&pmap_l2_mappings, 1); From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:51: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 486DF6527D3; Mon, 14 Jun 2021 20:51: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 4G3kBT1cl1z4rGR; Mon, 14 Jun 2021 20:51: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 1FD971B7A7; Mon, 14 Jun 2021 20:51: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 15EKpD4l009945; Mon, 14 Jun 2021 20:51:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKpDp6009944; Mon, 14 Jun 2021 20:51:13 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:51:13 GMT Message-Id: <202106142051.15EKpDp6009944@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 2071c3fb0dcc - stable/13 - tcp: LRO timestamps have lost their previous precision MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2071c3fb0dcc8b458d1c7b2eba7f4bc781715288 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, 14 Jun 2021 20:51:13 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=2071c3fb0dcc8b458d1c7b2eba7f4bc781715288 commit 2071c3fb0dcc8b458d1c7b2eba7f4bc781715288 Author: Randall Stewart AuthorDate: 2021-06-09 17:58:54 +0000 Commit: Michael Tuexen CommitDate: 2021-06-14 20:49:27 +0000 tcp: LRO timestamps have lost their previous precision Recently we had a rewrite to tcp_lro.c that was tested but one subtle change was the move to a less precise timestamp. This causes all kinds of chaos in tcp's that do pacing and needs to be fixed to use the more precise time that was there before. Reviewed by: mtuexen, gallatin, hselasky Sponsored by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30695 (cherry picked from commit b45daaea95abd8bda52caaacf120f9197caab3e7) --- sys/netinet/tcp_lro.c | 23 +++++++++++++---------- sys/netinet/tcp_lro.h | 4 ++-- sys/sys/time.h | 11 +++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c index 09fc024c3d73..ea84ca191eca 100644 --- a/sys/netinet/tcp_lro.c +++ b/sys/netinet/tcp_lro.c @@ -562,16 +562,18 @@ void tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) { struct lro_entry *le, *le_tmp; - sbintime_t sbt; + uint64_t now, tov; + struct bintime bt; if (LIST_EMPTY(&lc->lro_active)) return; - /* get timeout time */ - sbt = getsbinuptime() - tvtosbt(*timeout); - + /* get timeout time and current time in ns */ + binuptime(&bt); + now = bintime2ns(&bt); + tov = ((timeout->tv_sec * 1000000000) + (timeout->tv_usec * 1000)); LIST_FOREACH_SAFE(le, &lc->lro_active, next, le_tmp) { - if (sbt >= le->alloc_time) { + if (now >= (bintime2ns(&le->alloc_time) + tov)) { tcp_lro_active_remove(le); tcp_lro_flush(lc, le); } @@ -610,7 +612,7 @@ tcp_lro_log(struct tcpcb *tp, const struct lro_ctrl *lc, { if (tp->t_logstate != TCP_LOG_STATE_OFF) { union tcp_log_stackspecific log; - struct timeval tv; + struct timeval tv, btv; uint32_t cts; cts = tcp_get_usecs(&tv); @@ -637,7 +639,8 @@ tcp_lro_log(struct tcpcb *tp, const struct lro_ctrl *lc, log.u_bbr.cwnd_gain = le->window; log.u_bbr.cur_del_rate = (uintptr_t)m; log.u_bbr.bw_inuse = (uintptr_t)le->m_head; - log.u_bbr.flex6 = sbttous(lc->lro_last_queue_time); + bintime2timeval(&lc->lro_last_queue_time, &btv); + log.u_bbr.flex6 = tcp_tv_to_usectick(&btv); log.u_bbr.flex7 = le->compressed; log.u_bbr.pacing_gain = le->uncompressed; if (in_epoch(net_epoch_preempt)) @@ -1446,7 +1449,7 @@ tcp_lro_flush_all(struct lro_ctrl *lc) CURVNET_SET(lc->ifp->if_vnet); /* get current time */ - lc->lro_last_queue_time = getsbinuptime(); + binuptime(&lc->lro_last_queue_time); /* sort all mbufs according to stream */ tcp_lro_sort(lc->lro_mbuf_data, lc->lro_mbuf_count); @@ -1739,7 +1742,7 @@ tcp_lro_rx_common(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum, bool use_h #endif /* If no hardware or arrival stamp on the packet add timestamp */ if ((m->m_flags & (M_TSTMP_LRO | M_TSTMP)) == 0) { - m->m_pkthdr.rcv_tstmp = sbttons(lc->lro_last_queue_time); + m->m_pkthdr.rcv_tstmp = bintime2ns(&lc->lro_last_queue_time); m->m_flags |= M_TSTMP_LRO; } @@ -1834,7 +1837,7 @@ tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum) int error; /* get current time */ - lc->lro_last_queue_time = getsbinuptime(); + binuptime(&lc->lro_last_queue_time); CURVNET_SET(lc->ifp->if_vnet); error = tcp_lro_rx_common(lc, m, csum, true); diff --git a/sys/netinet/tcp_lro.h b/sys/netinet/tcp_lro.h index d2220a626b81..5ff15e2dc97e 100644 --- a/sys/netinet/tcp_lro.h +++ b/sys/netinet/tcp_lro.h @@ -140,7 +140,7 @@ struct lro_entry { uint16_t uncompressed; uint16_t window; uint16_t timestamp; /* flag, not a TCP hdr field. */ - sbintime_t alloc_time; /* time when entry was allocated */ + struct bintime alloc_time; /* time when entry was allocated */ }; LIST_HEAD(lro_head, lro_entry); @@ -154,7 +154,7 @@ struct lro_mbuf_sort { struct lro_ctrl { struct ifnet *ifp; struct lro_mbuf_sort *lro_mbuf_data; - sbintime_t lro_last_queue_time; /* last time data was queued */ + struct bintime lro_last_queue_time; /* last time data was queued */ uint64_t lro_queued; uint64_t lro_flushed; uint64_t lro_bad_csum; diff --git a/sys/sys/time.h b/sys/sys/time.h index 9bffca204d56..a48aa3fe5548 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -286,6 +286,17 @@ bintime2timespec(const struct bintime *_bt, struct timespec *_ts) (uint32_t)(_bt->frac >> 32)) >> 32; } +static __inline uint64_t +bintime2ns(const struct bintime *_bt) +{ + uint64_t ret; + + ret = (uint64_t)(_bt->sec) * (uint64_t)1000000000; + ret += (((uint64_t)1000000000 * + (uint32_t)(_bt->frac >> 32)) >> 32); + return (ret); +} + static __inline void timespec2bintime(const struct timespec *_ts, struct bintime *_bt) { From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 20:59:19 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 C103365334D; Mon, 14 Jun 2021 20:59:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3kMq4pQ6z4rY0; Mon, 14 Jun 2021 20:59:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8D3CE1BA19; Mon, 14 Jun 2021 20:59:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15EKxJSc014123; Mon, 14 Jun 2021 20:59:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EKxJLb014122; Mon, 14 Jun 2021 20:59:19 GMT (envelope-from git) Date: Mon, 14 Jun 2021 20:59:19 GMT Message-Id: <202106142059.15EKxJLb014122@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 8ecbecdcfdb0 - stable/13 - tcp: Mbuf leak while holding a socket buffer lock. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8ecbecdcfdb082dc4056a9d627d5de2ed7eceda4 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, 14 Jun 2021 20:59:19 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8ecbecdcfdb082dc4056a9d627d5de2ed7eceda4 commit 8ecbecdcfdb082dc4056a9d627d5de2ed7eceda4 Author: Randall Stewart AuthorDate: 2021-06-10 12:33:57 +0000 Commit: Michael Tuexen CommitDate: 2021-06-14 20:51:42 +0000 tcp: Mbuf leak while holding a socket buffer lock. When running at NF the current Rack and BBR changes with the recent commits from Richard that cause the socket buffer lock to be held over the ip_output() call and then finally culminating in a call to tcp_handle_wakeup() we get a lot of leaked mbufs. I don't think that this leak is actually caused by holding the lock or what Richard has done, but is exposing some other bug that has probably been lying dormant for a long time. I will continue to look (using his changes) at what is going on to try to root cause out the issue. In the meantime I can't leave the leaks out for everyone else. So this commit will revert all of Richards changes and move both Rack and BBR back to just doing the old sorwakeup_locked() calls after messing with the so_rcv buffer. We may want to look at adding back in Richards changes after I have pinpointed the root cause of the mbuf leak and fixed it. Reviewed by: mtuexen,rscheff Sponsored by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30704 (cherry picked from commit 67e892819b26c198e4232c7586ead7f854f848c5) --- sys/netinet/tcp_output.c | 2 ++ sys/netinet/tcp_stacks/bbr.c | 47 +++++++++++++++++------------ sys/netinet/tcp_stacks/rack.c | 69 ++++++++++++++++++++++--------------------- sys/netinet/tcp_var.h | 18 +++++++++++ 4 files changed, 84 insertions(+), 52 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 2a91570acdad..44333d772482 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1551,6 +1551,8 @@ send: #endif /* INET */ out: + if (error == 0) + tcp_account_for_send(tp, len, (tp->snd_nxt != tp->snd_max), 0); /* * In transmit state, time the transmission and arrange for * the retransmit. In persist state, just set snd_max. diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 7d709e33f0d7..05db7180e7b2 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -486,7 +486,7 @@ static void uint32_t line, uint8_t is_start, uint16_t set); static struct bbr_sendmap * - bbr_find_lowest_rsm(struct tcp_bbr *bbr); + bbr_find_lowest_rsm(struct tcp_bbr *bbr); static __inline uint32_t bbr_get_rtt(struct tcp_bbr *bbr, int32_t rtt_type); static void @@ -1620,7 +1620,7 @@ bbr_init_sysctls(void) &bbr_drop_limit, 0, "Number of segments limit for drop (0=use min_cwnd w/flight)?"); - /* Timeout controls */ + /* Timeout controls */ bbr_timeout = SYSCTL_ADD_NODE(&bbr_sysctl_ctx, SYSCTL_CHILDREN(bbr_sysctl_root), OID_AUTO, @@ -5750,7 +5750,7 @@ tcp_bbr_tso_size_check(struct tcp_bbr *bbr, uint32_t cts) * seg = goal_tso / mss * tso = seg * mss * else - * tso = mss + * tso = mss * if (tso > per-tcb-max) * tso = per-tcb-max * else if ( bw > 512Mbps) @@ -6736,7 +6736,7 @@ bbr_update_bbr_info(struct tcp_bbr *bbr, struct bbr_sendmap *rsm, uint32_t rtt, else bbr->rc_ack_is_cumack = 0; old_rttprop = bbr_get_rtt(bbr, BBR_RTT_PROP); - /* + /* * Note the following code differs to the original * BBR spec. It calls for <= not <. However after a * long discussion in email with Neal, he acknowledged @@ -8306,12 +8306,14 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, appended = #endif sbappendstream_locked(&so->so_rcv, m, 0); - tp->t_flags |= TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && appended != mcnt) counter_fo_release(so->so_rcv.sb_shlim, mcnt - appended); #endif + } else { /* * XXX: Due to the header drop above "th" is @@ -8323,6 +8325,11 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, thflags = tcp_reass(tp, th, &temp, &tlen, m); tp->t_flags |= TF_ACKNOW; + if (tp->t_flags & TF_WAKESOR) { + tp->t_flags &= ~TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); + } } if ((tp->t_flags & TF_SACK_PERMIT) && (save_tlen > 0) && @@ -8357,7 +8364,6 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, save_start + tlen); } } - tcp_handle_wakeup(tp, so); } else { m_freem(m); thflags &= ~TH_FIN; @@ -9164,7 +9170,11 @@ bbr_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, if (tlen == 0 && (thflags & TH_FIN) == 0) { (void)tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); - tcp_handle_wakeup(tp, so); + if (tp->t_flags & TF_WAKESOR) { + tp->t_flags &= ~TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); + } } tp->snd_wl1 = th->th_seq - 1; if (bbr_process_ack(m, th, so, tp, to, tiwin, tlen, &ourfinisacked, thflags, &ret_val)) { @@ -11565,18 +11575,18 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((thflags & TH_SYN) && (thflags & TH_FIN) && V_drop_synfin) { retval = 0; m_freem(m); - goto done_with_input; - } - /* - * If a segment with the ACK-bit set arrives in the SYN-SENT state - * check SEQ.ACK first as described on page 66 of RFC 793, section 3.9. - */ - if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && - (SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { + goto done_with_input; + } + /* + * If a segment with the ACK-bit set arrives in the SYN-SENT state + * check SEQ.ACK first as described on page 66 of RFC 793, section 3.9. + */ + if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && + (SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { tcp_log_end_status(tp, TCP_EI_STATUS_RST_IN_FRONT); ctf_do_dropwithreset_conn(m, tp, th, BANDLIM_RST_OPENPORT, tlen); - return (1); - } + return (1); + } in_recovery = IN_RECOVERY(tp->t_flags); if (tiwin > bbr->r_ctl.rc_high_rwnd) bbr->r_ctl.rc_high_rwnd = tiwin; @@ -11786,8 +11796,6 @@ bbr_do_send_accounting(struct tcpcb *tp, struct tcp_bbr *bbr, struct bbr_sendmap * own bin */ #ifdef NETFLIX_STATS - tp->t_sndtlppack++; - tp->t_sndtlpbyte += len; KMOD_TCPSTAT_INC(tcps_tlpresends); KMOD_TCPSTAT_ADD(tcps_tlpresend_bytes, len); #endif @@ -13741,6 +13749,7 @@ out: * retransmit. In persist state, just set snd_max. */ if (error == 0) { + tcp_account_for_send(tp, len, (rsm != NULL), doing_tlp); if (TCPS_HAVEESTABLISHED(tp->t_state) && (tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index bcf3dcc0e38a..f9ba67088f7a 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -10219,7 +10219,8 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, sbappendstream_locked(&so->so_rcv, m, 0); rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); - tp->t_flags |= TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && appended != mcnt) counter_fo_release(so->so_rcv.sb_shlim, @@ -10236,7 +10237,11 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, thflags = tcp_reass(tp, th, &temp, &tlen, m); tp->t_flags |= TF_ACKNOW; - + if (tp->t_flags & TF_WAKESOR) { + tp->t_flags &= ~TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); + } } if ((tp->t_flags & TF_SACK_PERMIT) && (save_tlen > 0) && @@ -10276,7 +10281,6 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, save_start + tlen); } } - tcp_handle_wakeup(tp, so); } else { m_freem(m); thflags &= ~TH_FIN; @@ -10482,7 +10486,8 @@ rack_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so, ctf_calc_rwin(so, tp); } rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); - tp->t_flags |= TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && mcnt != appended) counter_fo_release(so->so_rcv.sb_shlim, mcnt - appended); @@ -10490,7 +10495,6 @@ rack_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so, rack_handle_delayed_ack(tp, rack, tlen, 0); if (tp->snd_una == tp->snd_max) sack_filter_clear(&rack->r_ctl.rack_sf, tp->snd_una); - tcp_handle_wakeup(tp, so); return (1); } @@ -11083,7 +11087,11 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, if (tlen == 0 && (thflags & TH_FIN) == 0) { (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); - tcp_handle_wakeup(tp, so); + if (tp->t_flags & TF_WAKESOR) { + tp->t_flags &= ~TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); + } } tp->snd_wl1 = th->th_seq - 1; /* For syn-recv we need to possibly update the rtt */ @@ -12331,29 +12339,23 @@ rack_fini(struct tcpcb *tp, int32_t tcb_is_purged) rack = (struct tcp_rack *)tp->t_fb_ptr; if (tp->t_in_pkt) { /* - * Since we are switching we need to process any - * inbound packets in case a compressed ack is - * in queue or the new stack does not support - * mbuf queuing. These packets in theory should - * have been handled by the old stack anyway. + * It is unsafe to process the packets since a + * reset may be lurking in them (its rare but it + * can occur). If we were to find a RST, then we + * would end up dropping the connection and the + * INP lock, so when we return the caller (tcp_usrreq) + * will blow up when it trys to unlock the inp. */ - if ((rack->rc_inp->inp_flags & (INP_DROPPED|INP_TIMEWAIT)) || - (rack->rc_inp->inp_flags2 & INP_FREED)) { - /* Kill all the packets */ - struct mbuf *save, *m; - - m = tp->t_in_pkt; - tp->t_in_pkt = NULL; - tp->t_tail_pkt = NULL; - while (m) { - save = m->m_nextpkt; - m->m_nextpkt = NULL; - m_freem(m); - m = save; - } - } else { - /* Process all the packets */ - ctf_do_queued_segments(rack->rc_inp->inp_socket, rack->rc_tp, 0); + struct mbuf *save, *m; + + m = tp->t_in_pkt; + tp->t_in_pkt = NULL; + tp->t_tail_pkt = NULL; + while (m) { + save = m->m_nextpkt; + m->m_nextpkt = NULL; + m_freem(m); + m = save; } if ((tp->t_inpcb) && (tp->t_inpcb->inp_flags2 & INP_MBUF_ACKCMP)) @@ -13995,7 +13997,6 @@ rack_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, } if (rack_do_segment_nounlock(m, th, so, tp, drop_hdrlen, tlen, iptos, 0, &tv) == 0) { - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); } } @@ -15402,6 +15403,8 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma rack->rc_tlp_in_progress = 1; rack->r_ctl.rc_tlp_cnt_out++; } + if (error == 0) + tcp_account_for_send(tp, len, 1, doing_tlp); tp->t_flags &= ~(TF_ACKNOW | TF_DELACK); rack->forced_ack = 0; /* If we send something zap the FA flag */ if (IN_FASTRECOVERY(tp->t_flags) && rsm) @@ -15880,6 +15883,9 @@ again: rack_log_progress_event(rack, tp, ticks, PROGRESS_START, __LINE__); tp->t_acktime = ticks; } + if (error == 0) + tcp_account_for_send(tp, len, 0, 0); + rack->forced_ack = 0; /* If we send something zap the FA flag */ tot_len += len; if ((tp->t_flags & TF_GPUTINPROG) == 0) @@ -16320,8 +16326,6 @@ again: tlen = rsm->r_end - rsm->r_start; if (tlen > segsiz) tlen = segsiz; - tp->t_sndtlppack++; - tp->t_sndtlpbyte += tlen; KASSERT(SEQ_LEQ(tp->snd_una, rsm->r_start), ("%s:%d: r.start:%u < SND.UNA:%u; tp:%p, rack:%p, rsm:%p", __func__, __LINE__, @@ -18107,6 +18111,7 @@ out: * retransmit. In persist state, just set snd_max. */ if (error == 0) { + tcp_account_for_send(tp, len, (rsm != NULL), doing_tlp); rack->forced_ack = 0; /* If we send something zap the FA flag */ if (rsm && (doing_tlp == 0)) { /* Set we retransmitted */ @@ -18151,8 +18156,6 @@ out: if (doing_tlp && (rsm == NULL)) { /* New send doing a TLP */ add_flag |= RACK_TLP; - tp->t_sndtlppack++; - tp->t_sndtlpbyte += len; } rack_log_output(tp, &to, len, rack_seq, (uint8_t) flags, error, rack_to_usec_ts(&tv), diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 1858d0146ce5..367dd9765534 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -261,6 +261,8 @@ struct tcpcb { uint32_t t_maxpeakrate; /* max peak rate set by user, in bytes/s */ uint32_t t_sndtlppack; /* tail loss probe packets sent */ uint64_t t_sndtlpbyte; /* total tail loss probe bytes sent */ + uint64_t t_sndbytes; /* total bytes sent */ + uint64_t t_snd_rxt_bytes; /* total bytes retransmitted */ uint8_t t_tfo_client_cookie_len; /* TCP Fast Open client cookie length */ uint32_t t_end_info_status; /* Status flag of end info */ @@ -1128,6 +1130,22 @@ tcp_fields_to_net(struct tcphdr *th) th->th_win = htons(th->th_win); th->th_urp = htons(th->th_urp); } + +static inline void +tcp_account_for_send(struct tcpcb *tp, uint32_t len, uint8_t is_rxt, uint8_t is_tlp) +{ + if (is_tlp) { + tp->t_sndtlppack++; + tp->t_sndtlpbyte += len; + } + /* To get total bytes sent you must add t_snd_rxt_bytes to t_sndbytes */ + if (is_rxt) + tp->t_snd_rxt_bytes += len; + else + tp->t_sndbytes += len; + +} + #endif /* _KERNEL */ #endif /* _NETINET_TCP_VAR_H_ */ From owner-dev-commits-src-branches@freebsd.org Mon Jun 14 21:02: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 3236C6535CD; Mon, 14 Jun 2021 21:02: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 4G3kRD0vHXz4tLh; Mon, 14 Jun 2021 21:02: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 071AB1BAB0; Mon, 14 Jun 2021 21:02: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 15EL2FMK027399; Mon, 14 Jun 2021 21:02:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15EL2Ftq027363; Mon, 14 Jun 2021 21:02:15 GMT (envelope-from git) Date: Mon, 14 Jun 2021 21:02:15 GMT Message-Id: <202106142102.15EL2Ftq027363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: d0eaf95edcaf - stable/13 - tcp: Missing mfree in rack and bbr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d0eaf95edcafcaeebfbc3ce9f361e98914830a49 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, 14 Jun 2021 21:02:16 -0000 The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d0eaf95edcafcaeebfbc3ce9f361e98914830a49 commit d0eaf95edcafcaeebfbc3ce9f361e98914830a49 Author: Randall Stewart AuthorDate: 2021-06-11 15:38:08 +0000 Commit: Michael Tuexen CommitDate: 2021-06-14 21:00:17 +0000 tcp: Missing mfree in rack and bbr Recently (Nov) we added logic that protects against a peer negotiating a timestamp, and then not including a timestamp. This involved in the input path doing a goto done_with_input label. Now I suspect the code was cribbed from one in Rack that has to do with the SYN. This had a bug, i.e. it should have a m_freem(m) before going to the label (bbr had this missing m_freem() but rack did not). This then caused the missing m_freem to show up in both BBR and Rack. Also looking at the code referencing m->m_pkthdr.lro_nsegs later (after processing) is not a good idea, even though its only for logging. Best to copy that off before any frees can take place. Reviewed by: mtuexen Sponsored by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30727 (cherry picked from commit ba1b3e48f5be320f0590bc357ea53fdc3e4edc65) --- sys/netinet/tcp_stacks/bbr.c | 1 + sys/netinet/tcp_stacks/rack.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 05db7180e7b2..06975c45cdbd 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -11441,6 +11441,7 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS) && ((thflags & TH_RST) == 0) && (V_tcp_tolerate_missing_ts == 0)) { retval = 0; + m_freem(m); goto done_with_input; } /* diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index f9ba67088f7a..dc3c8d47dc31 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -13452,6 +13452,7 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, #ifdef TCP_ACCOUNTING int ack_val_set = 0xf; #endif + int nsegs; uint32_t us_cts; /* * tv passed from common code is from either M_TSTMP_LRO or @@ -13463,6 +13464,7 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if (m->m_flags & M_ACKCMP) { panic("Impossible reach m has ackcmp? m:%p tp:%p", m, tp); } + nsegs = m->m_pkthdr.lro_nsegs; counter_u64_add(rack_proc_non_comp_ack, 1); thflags = th->th_flags; #ifdef TCP_ACCOUNTING @@ -13605,6 +13607,7 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, if ((thflags & TH_SYN) && (thflags & TH_FIN) && V_drop_synfin) { way_out = 4; retval = 0; + m_freem(m); goto done_with_input; } /* @@ -13639,6 +13642,7 @@ rack_do_segment_nounlock(struct mbuf *m, struct tcphdr *th, struct socket *so, ((thflags & TH_RST) == 0) && (V_tcp_tolerate_missing_ts == 0)) { way_out = 5; retval = 0; + m_freem(m); goto done_with_input; } @@ -13942,7 +13946,7 @@ do_output_now: way_out = 2; } done_with_input: - rack_log_doseg_done(rack, cts, nxt_pkt, did_out, way_out, max(1, m->m_pkthdr.lro_nsegs)); + rack_log_doseg_done(rack, cts, nxt_pkt, did_out, way_out, max(1, nsegs)); if (did_out) rack->r_wanted_output = 0; #ifdef INVARIANTS From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 12:40: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 218966493EE; Tue, 15 Jun 2021 12:40: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 4G47Fn0CWnz3k44; Tue, 15 Jun 2021 12:40: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 DF7621DE; Tue, 15 Jun 2021 12:40: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 15FCeStH082307; Tue, 15 Jun 2021 12:40:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FCeSO9082306; Tue, 15 Jun 2021 12:40:28 GMT (envelope-from git) Date: Tue, 15 Jun 2021 12:40:28 GMT Message-Id: <202106151240.15FCeSO9082306@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 36c7408818c5 - stable/13 - tests/netgraph: Inital framework for testing libnetgraph MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 36c7408818c53ae0c1f1aee0250c5d3fe16b06e0 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, 15 Jun 2021 12:40:29 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=36c7408818c53ae0c1f1aee0250c5d3fe16b06e0 commit 36c7408818c53ae0c1f1aee0250c5d3fe16b06e0 Author: Lutz Donnerhacke AuthorDate: 2021-06-02 22:29:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-15 12:31:32 +0000 tests/netgraph: Inital framework for testing libnetgraph Provide a framework of functions to test various netgraph modules. Tests contain: - creating, renaming, and destroying nodes - connecting and removing hooks - sending and receiving data - sending ASCII messages and receiving binary responses - errors can be passed for indiviual inspection or fail the test Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30629 Differential Revision: https://reviews.freebsd.org/D30657 Differential Revision: https://reviews.freebsd.org/D30671 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 24ea1dbf257aa6757f469bcd859f90e9ad851e59) (cherry picked from commit 09307dbfb888a98232096c751a96ecb3344aa77c) (cherry picked from commit 9021c46603bf29b9700f24b8dce8796b434d7c8f) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) Also contains some fixups: - indent all files correctly - finish factoring out - remove debugging code - check for renaming issues reported in PR241954 PR: 241954 Differential Revision: https://reviews.freebsd.org/D30692 Differential Revision: https://reviews.freebsd.org/D30714 Differential Revision: https://reviews.freebsd.org/D30713 (cherry picked from commit a664ade93972ce617f0888ff79e715dff9cf0f87) (cherry picked from commit 0afa9be03937d60cb5aeba64c81e3e2165bd3737) (cherry picked from commit 43e4821315c31db067e23564b9bfafb519e77b2b) --- tests/sys/netgraph/Makefile | 6 +- tests/sys/netgraph/basic.c | 191 ++++++++++++++++++++++++++++++ tests/sys/netgraph/util.c | 277 ++++++++++++++++++++++++++++++++++++++++++++ tests/sys/netgraph/util.h | 114 ++++++++++++++++++ 4 files changed, 587 insertions(+), 1 deletion(-) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index aef190bbe178..9f220a620bbe 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -10,6 +10,10 @@ TAP_TESTS_SH+= ng_macfilter_test TEST_METADATA.ng_macfilter_test+= required_user="root" TEST_METADATA.ng_macfilter_test+= required_programs="perl" -MAN= +ATF_TESTS_C+= basic \ + +SRCS.basic= basic.c util.c + +LIBADD+= netgraph .include diff --git a/tests/sys/netgraph/basic.c b/tests/sys/netgraph/basic.c new file mode 100644 index 000000000000..573422add694 --- /dev/null +++ b/tests/sys/netgraph/basic.c @@ -0,0 +1,191 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(send_recv); +ATF_TC_HEAD(send_recv, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(send_recv, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + ng_send_data("a", msg, sizeof(msg)); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1); +} + +ATF_TC(node); +ATF_TC_HEAD(node, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(node, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_errors(PASS); + ng_name("a", "test hub"); + ng_errors(FAIL); + if (errno == EADDRINUSE) + atf_tc_expect_fail("PR241954"); + ATF_CHECK_ERRNO(0, 1); + atf_tc_expect_pass(); + + ng_connect(".", "b", "test hub:", "b"); + ng_connect(".", "c", "test hub:", "c"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + ng_shutdown("test hub:"); +} + +ATF_TC(message); +ATF_TC_HEAD(message, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(message, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_send_msg("test hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("test hub:"); +} + +ATF_TC(same_name); +ATF_TC_HEAD(same_name, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(same_name, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test"); + + ng_errors(PASS); + ng_connect(".", "a", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_connect(".", "b", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_name(".", "test"); + ATF_CHECK_ERRNO(EADDRINUSE, 1); + + ng_errors(FAIL); + ng_shutdown("test:"); +} + +ATF_TC(queuelimit); +ATF_TC_HEAD(queuelimit, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(queuelimit, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int MAX = 1000; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + + ng_errors(PASS); + for (i = 0; i < MAX; i++) + { + ng_send_data("a", msg, sizeof(msg)); + if (errno != 0) + break; + /* no ng_handle_events -> messages stall */ + } + ng_errors(FAIL); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] > 100); + ATF_CHECK(r[0] == i); + atf_tc_expect_fail("Queue full (%d)", i); + ATF_CHECK(r[0] == MAX); + atf_tc_expect_pass(); +} + +ATF_TP_ADD_TCS(basic) +{ + ATF_TP_ADD_TC(basic, send_recv); + ATF_TP_ADD_TC(basic, node); + ATF_TP_ADD_TC(basic, message); + ATF_TP_ADD_TC(basic, same_name); + ATF_TP_ADD_TC(basic, queuelimit); + + return atf_no_error(); +} diff --git a/tests/sys/netgraph/util.c b/tests/sys/netgraph/util.c new file mode 100644 index 000000000000..b25e63dfa76d --- /dev/null +++ b/tests/sys/netgraph/util.c @@ -0,0 +1,277 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" + + +static int cs = -1, ds = -1; +static ng_error_t error_handling = FAIL; + +#define CHECK(r, x) do { \ + if (!(x)) { \ + if (error_handling == PASS) \ + return r; \ + atf_tc_fail_requirement(file, line, "%s (%s)", \ + #x " not met", strerror(errno));\ + } \ +} while(0) + +struct data_handler +{ + char const *hook; + ng_data_handler_t handler; + SLIST_ENTRY(data_handler) next; +}; +static SLIST_HEAD(, data_handler) data_head = SLIST_HEAD_INITIALIZER(data_head); +static ng_msg_handler_t msg_handler = NULL; + +static void handle_data(void *ctx); +static void handle_msg(void *ctx); + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line) +{ + struct ngm_connect c; + + strncpy(c.ourhook, hook1, sizeof(c.ourhook)); + strncpy(c.peerhook, hook2, sizeof(c.peerhook)); + strncpy(c.path, path2, sizeof(c.path)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_CONNECT, + &c, sizeof(c))); +} + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line) +{ + struct ngm_mkpeer p; + + strncpy(p.ourhook, hook1, sizeof(p.ourhook)); + strncpy(p.peerhook, hook2, sizeof(p.peerhook)); + strncpy(p.type, type, sizeof(p.type)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_MKPEER, + &p, sizeof(p))); +} + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line) +{ + struct ngm_rmhook h; + + strncpy(h.ourhook, hook, sizeof(h.ourhook)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_RMHOOK, + &h, sizeof(h))); +} + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line) +{ + struct ngm_name n; + + strncpy(n.name, name, sizeof(n.name)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_NAME, + &n, sizeof(n))); +} + +void +_ng_shutdown(char const *path, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_SHUTDOWN, + NULL, 0)); +} + +void +ng_register_data(char const *hook, ng_data_handler_t proc) +{ + struct data_handler *p; + + ATF_REQUIRE(NULL != (p = calloc(1, sizeof(struct data_handler)))); + ATF_REQUIRE(NULL != (p->hook = strdup(hook))); + ATF_REQUIRE(NULL != (p->handler = proc)); + SLIST_INSERT_HEAD(&data_head, p, next); +} + +void +_ng_send_data(char const *hook, + void const *data, size_t len, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendData(ds, hook, data, len)); +} + +void +ng_register_msg(ng_msg_handler_t proc) +{ + msg_handler = proc; +} + +static void +handle_msg(void *ctx) +{ + struct ng_mesg *m; + char path[NG_PATHSIZ]; + + ATF_REQUIRE(-1 != NgAllocRecvMsg(cs, &m, path)); + + if (msg_handler != NULL) + (*msg_handler) (path, m, ctx); + + free(m); +} + +static void +handle_data(void *ctx) +{ + char hook[NG_HOOKSIZ]; + struct data_handler *hnd; + u_char *data; + int len; + + ATF_REQUIRE(0 < (len = NgAllocRecvData(ds, &data, hook))); + SLIST_FOREACH(hnd, &data_head, next) + { + if (0 == strcmp(hnd->hook, hook)) + break; + } + + if (hnd != NULL) + (*(hnd->handler)) (data, len, ctx); + + free(data); +} + +int +ng_handle_event(unsigned int ms, void *context) +{ + fd_set fds; + int maxfd = (ds < cs) ? cs : ds; + struct timeval timeout = {0, ms * 1000lu}; + + FD_ZERO(&fds); + FD_SET(cs, &fds); + FD_SET(ds, &fds); +retry: + switch (select(maxfd + 1, &fds, NULL, NULL, &timeout)) + { + case -1: + ATF_REQUIRE_ERRNO(EINTR, 1); + goto retry; + case 0: /* timeout */ + return 0; + default: /* something to do */ + if (FD_ISSET(cs, &fds)) + handle_msg(context); + if (FD_ISSET(ds, &fds)) + handle_data(context); + return 1; + } +} + +void +ng_handle_events(unsigned int ms, void *context) +{ + while (ng_handle_event(ms, context)) + ; +} + +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line) +{ + int res; + + CHECK(-1, -1 != (res = NgSendAsciiMsg(cs, path, "%s", msg))); + return (res); +} + +ng_error_t +ng_errors(ng_error_t n) +{ + ng_error_t o = error_handling; + + error_handling = n; + return (o); +} + +void +_ng_init(char const *file, size_t line) +{ + if (cs >= 0) /* prevent reinit */ + return; + + CHECK(, 0 == NgMkSockNode(NULL, &cs, &ds)); + NgSetDebug(3); +} + +#define GD(x) void \ +get_data##x(void *data, size_t len, void *ctx) {\ + int *cnt = ctx; \ + \ + (void)data; \ + (void)len; \ + cnt[x]++; \ +} + +GD(0) +GD(1) +GD(2) +GD(3) +GD(4) +GD(5) +GD(6) +GD(7) +GD(8) +GD(9) diff --git a/tests/sys/netgraph/util.h b/tests/sys/netgraph/util.h new file mode 100644 index 000000000000..44c9f3a360a7 --- /dev/null +++ b/tests/sys/netgraph/util.h @@ -0,0 +1,114 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#include + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line); +#define ng_connect(p1,h1,p2,h2) \ + _ng_connect(p1,h1,p2,h2,__FILE__,__LINE__) + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line); +#define ng_mkpeer(p1,h1,t,h2) \ + _ng_mkpeer(p1,h1,t,h2,__FILE__,__LINE__) + +void +_ng_shutdown(char const *path, + char const *file, size_t line); +#define ng_shutdown(p) \ + _ng_shutdown(p,__FILE__,__LINE__) + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line); +#define ng_rmhook(p,h) \ + _ng_rmhook(p,h,__FILE__,__LINE__) + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line); +#define ng_name(p,n) \ + _ng_name(p,n,__FILE__,__LINE__) + + +typedef void (*ng_data_handler_t)(void *, size_t, void *ctx); +void ng_register_data(char const *hook, ng_data_handler_t proc); +void +_ng_send_data(char const *hook, void const *, size_t, + char const *file, size_t line); +#define ng_send_data(h,d,l) \ + _ng_send_data(h,d,l,__FILE__,__LINE__) + +typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *); +void ng_register_msg(ng_msg_handler_t proc); +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line); +#define ng_send_msg(p,m) \ + _ng_send_msg(p,m,__FILE__,__LINE__) + +int ng_handle_event(unsigned int ms, void *ctx); +void ng_handle_events(unsigned int ms, void *ctx); + +typedef enum +{ + FAIL, PASS +} ng_error_t; +ng_error_t ng_errors(ng_error_t); + +void _ng_init(char const *file, size_t line); +#define ng_init() \ + _ng_init(__FILE__,__LINE__) + +/* Helper function to count received data */ + +typedef int ng_counter_t[10]; +#define ng_counter_clear(x)\ + bzero((x), sizeof(x)) + +void get_data0(void *data, size_t len, void *ctx); +void get_data1(void *data, size_t len, void *ctx); +void get_data2(void *data, size_t len, void *ctx); +void get_data3(void *data, size_t len, void *ctx); +void get_data4(void *data, size_t len, void *ctx); +void get_data5(void *data, size_t len, void *ctx); +void get_data6(void *data, size_t len, void *ctx); +void get_data7(void *data, size_t len, void *ctx); +void get_data8(void *data, size_t len, void *ctx); +void get_data9(void *data, size_t len, void *ctx); From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 12:40: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 26B68649A9C; Tue, 15 Jun 2021 12:40: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 4G47Fp0Yzyz3k45; Tue, 15 Jun 2021 12:40: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 EEFB81E0; Tue, 15 Jun 2021 12:40: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 15FCeTKE082331; Tue, 15 Jun 2021 12:40:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FCeT1W082330; Tue, 15 Jun 2021 12:40:29 GMT (envelope-from git) Date: Tue, 15 Jun 2021 12:40:29 GMT Message-Id: <202106151240.15FCeT1W082330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 1b379f585876 - stable/13 - tests/netgraph: Tests for ng_bridge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1b379f5858766867932eff72db19cf435fedd512 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, 15 Jun 2021 12:40:30 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=1b379f5858766867932eff72db19cf435fedd512 commit 1b379f5858766867932eff72db19cf435fedd512 Author: Lutz Donnerhacke AuthorDate: 2021-06-04 10:59:00 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-15 12:38:49 +0000 tests/netgraph: Tests for ng_bridge Test functionality of ng_bridge(4): - replicating traffic to anything but the sending hook - persistence - detect loops - unicast to only one link of many - stretch to implementation limits on broadcast Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30647 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 61814702398ce29430b2bef75cbdd6fd2c07ad12) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/bridge.c | 632 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 634 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 9f220a620bbe..7376cb5c1227 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -11,8 +11,10 @@ TEST_METADATA.ng_macfilter_test+= required_user="root" TEST_METADATA.ng_macfilter_test+= required_programs="perl" ATF_TESTS_C+= basic \ + bridge \ SRCS.basic= basic.c util.c +SRCS.bridge= bridge.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/bridge.c b/tests/sys/netgraph/bridge.c new file mode 100644 index 000000000000..3e3c0f804278 --- /dev/null +++ b/tests/sys/netgraph/bridge.c @@ -0,0 +1,632 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include +#include +#include +#include + +#include "util.h" +#include + +static void get_tablesize(char const *source, struct ng_mesg *msg, void *ctx); +struct gettable +{ + u_int32_t tok; + int cnt; +}; + +struct frame4 +{ + struct ether_header eh; + struct ip ip; + char data[64]; +}; +struct frame6 +{ + struct ether_header eh; + struct ip6_hdr ip; + char data[64]; +}; + +static struct frame4 msg4 = { + .ip.ip_v = 4, + .ip.ip_hl = 5, + .ip.ip_ttl = 1, + .ip.ip_p = 254, + .ip.ip_src = {htonl(0x0a00dead)}, + .ip.ip_dst = {htonl(0x0a00beef)}, + .ip.ip_len = 32, + .eh.ether_type = ETHERTYPE_IP, + .eh.ether_shost = {2, 4, 6}, + .eh.ether_dhost = {2, 4, 6}, +}; + + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_connect(".", "b", "bridge:", "link1"); + ng_connect(".", "c", "bridge:", "link2"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + ng_send_data("b", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + ng_send_data("c", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 1 && r[2] == 0); + + /* send to learned unicast */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 3; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 3); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + + ng_send_msg("bridge:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("bridge:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge1"); + ng_mkpeer(".", "b", "bridge", "link1"); + ng_name("b", "bridge2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + + /*- + * Open loop + * + * /-- bridge1 + * . < | + * \-- bridge2 + */ + ng_connect("bridge1:", "link11", "bridge2:", "link11"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- bridge1 -\ + * . < | | + * \-- bridge2 -/ + */ + ng_connect("bridge1:", "link12", "bridge2:", "link12"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_errors(PASS); + ng_send_data("a", &msg4, sizeof(msg4)); + ATF_CHECK_ERRNO(ELOOP, errno != 0); /* loop might be detected */ + ng_errors(FAIL); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, &r)) + break; + ATF_CHECK(r[0] == 0 && r[1] == 1); + + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); +} + +ATF_TC(many_unicasts); +ATF_TC_HEAD(many_unicasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_unicasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use learned MAC as destination */ + msg4.eh.ether_shost[3] = 0; + msg4.eh.ether_dhost[3] = 0xff; + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data2); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] == HOOKS && r[2] == 0); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.cnt = 0; + ng_errors(PASS); + rm.tok = ng_send_msg("bridge:", "gettable"); + ng_errors(FAIL); + if (rm.tok == (u_int32_t)-1) + { + ATF_CHECK_ERRNO(ENOBUFS, 1); + atf_tc_expect_fail("response too large"); + } + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == HOOKS + 1); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(many_broadcasts); +ATF_TC_HEAD(many_broadcasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_broadcasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use broadcast MAC */ + msg4.eh.ether_shost[3] = 0; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data3); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] > 100 && r[3] > 100); + if (i < HOOKS) + atf_tc_expect_fail("netgraph queue full (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_private); +ATF_TC_HEAD(uplink_private, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_private, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "u1", "bridge", "uplink1"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("u1", "bridge"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l0", "bridge:", "link0"); + ng_register_data("l0", get_data0); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_classic); +ATF_TC_HEAD(uplink_classic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_classic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "l0", "bridge", "link0"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("l0", "bridge"); + ng_register_data("l0", get_data0); + ng_connect(".", "u1", "bridge:", "uplink1"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TP_ADD_TCS(bridge) +{ + ATF_TP_ADD_TC(bridge, basic); + ATF_TP_ADD_TC(bridge, loop); + ATF_TP_ADD_TC(bridge, persistence); + ATF_TP_ADD_TC(bridge, many_unicasts); + ATF_TP_ADD_TC(bridge, many_broadcasts); + ATF_TP_ADD_TC(bridge, uplink_private); + ATF_TP_ADD_TC(bridge, uplink_classic); + + return atf_no_error(); +} + +static void +get_tablesize(char const *source, struct ng_mesg *msg, void *ctx) +{ + struct gettable *rm = ctx; + struct ng_bridge_host_ary *gt = (void *)msg->data; + + fprintf(stderr, "Response from %s to query %d\n", source, msg->header.token); + if (rm->tok == msg->header.token) + rm->cnt = gt->numHosts; +} From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 18:18: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 9C2BE64FD5E; Tue, 15 Jun 2021 18:18: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 4G4GlR43Jhz4mZ3; Tue, 15 Jun 2021 18:18: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 68FEE4B78; Tue, 15 Jun 2021 18:18: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 15FIIBdE031753; Tue, 15 Jun 2021 18:18:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FIIBLh031752; Tue, 15 Jun 2021 18:18:11 GMT (envelope-from git) Date: Tue, 15 Jun 2021 18:18:11 GMT Message-Id: <202106151818.15FIIBLh031752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 934e10b4a388 - stable/13 - libcasper: fix descriptors numbers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 934e10b4a388b13c2bcd8fbac8cd8cc4a641b1b0 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, 15 Jun 2021 18:18:11 -0000 The branch stable/13 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=934e10b4a388b13c2bcd8fbac8cd8cc4a641b1b0 commit 934e10b4a388b13c2bcd8fbac8cd8cc4a641b1b0 Author: Mariusz Zaborski AuthorDate: 2021-06-09 21:46:51 +0000 Commit: Mariusz Zaborski CommitDate: 2021-06-15 18:14:43 +0000 libcasper: fix descriptors numbers Casper services expect that the first 3 descriptors (stdin/stdout/stderr) will point to /dev/null. Which Casper will ensure later. The Casper services are forked from the original process. If the initial process closes one of those descriptors, Casper may reuse one of them for it on purpose. If this is the case, then renumarate the descriptors used by Casper to higher numbers. This is done already after the fork, so it doesn't break the parent process. PR: 255339 Reported by: Borja Marcos Tested by: jkim@ (cherry picked from commit aa310ebfba3d49a0b6b03a103b969731a8136a73) --- lib/libcasper/libcasper/libcasper_impl.c | 27 +++++++++++++++++++++++++++ lib/libcasper/libcasper/libcasper_impl.h | 1 + lib/libcasper/libcasper/service.c | 23 +++++++++++++---------- lib/libcasper/libcasper/zygote.c | 15 +++++++++------ 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/lib/libcasper/libcasper/libcasper_impl.c b/lib/libcasper/libcasper/libcasper_impl.c index e4411630c8a1..ae28c8769a07 100644 --- a/lib/libcasper/libcasper/libcasper_impl.c +++ b/lib/libcasper/libcasper/libcasper_impl.c @@ -32,8 +32,10 @@ * $FreeBSD$ */ +#include #include #include +#include #include #include "libcasper_impl.h" @@ -44,3 +46,28 @@ fd_is_valid(int fd) return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); } + +void +fd_fix_environment(int *fdp) +{ + int nullfd, nfd; + + if (*fdp > STDERR_FILENO) + return; + + nullfd = open(_PATH_DEVNULL, O_RDWR); + if (nullfd == -1) + errx(1, "Unable to open %s", _PATH_DEVNULL); + + while (*fdp <= STDERR_FILENO) { + nfd = dup(*fdp); + if (nfd == -1) + errx(1, "Unable to secure fd"); + if (dup2(nullfd, *fdp) == -1) + errx(1, "Unable to secure fd"); + *fdp = nfd; + } + + close(nullfd); +} + diff --git a/lib/libcasper/libcasper/libcasper_impl.h b/lib/libcasper/libcasper/libcasper_impl.h index 11e43f083977..24049a0c07c8 100644 --- a/lib/libcasper/libcasper/libcasper_impl.h +++ b/lib/libcasper/libcasper/libcasper_impl.h @@ -44,6 +44,7 @@ struct service; struct service_connection; bool fd_is_valid(int fd); +void fd_fix_environment(int *fdp); /* Private service functions. */ struct service *service_alloc(const char *name, diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c index 5c1c64d9a9d7..e87d0640347c 100644 --- a/lib/libcasper/libcasper/service.c +++ b/lib/libcasper/libcasper/service.c @@ -386,24 +386,27 @@ stdnull(void) } static void -service_clean(int sock, int procfd, uint64_t flags) +service_clean(int *sockp, int *procfdp, uint64_t flags) { int fd, maxfd, minfd; - assert(sock > STDERR_FILENO); - assert(procfd > STDERR_FILENO); - assert(sock != procfd); + fd_fix_environment(sockp); + fd_fix_environment(procfdp); + + assert(*sockp > STDERR_FILENO); + assert(*procfdp > STDERR_FILENO); + assert(*sockp != *procfdp); if ((flags & CASPER_SERVICE_STDIO) == 0) stdnull(); if ((flags & CASPER_SERVICE_FD) == 0) { - if (procfd > sock) { - maxfd = procfd; - minfd = sock; + if (*procfdp > *sockp) { + maxfd = *procfdp; + minfd = *sockp; } else { - maxfd = sock; - minfd = procfd; + maxfd = *sockp; + minfd = *procfdp; } for (fd = STDERR_FILENO + 1; fd < maxfd; fd++) { @@ -424,7 +427,7 @@ service_start(struct service *service, int sock, int procfd) assert(service != NULL); assert(service->s_magic == SERVICE_MAGIC); setproctitle("%s", service->s_name); - service_clean(sock, procfd, service->s_flags); + service_clean(&sock, &procfd, service->s_flags); if (service_connection_add(service, sock, NULL) == NULL) _exit(1); diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c index 2b84bb49a695..5cdd139cc134 100644 --- a/lib/libcasper/libcasper/zygote.c +++ b/lib/libcasper/libcasper/zygote.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "libcasper_impl.h" #include "zygote.h" /* Zygote info. */ @@ -104,7 +105,7 @@ zygote_clone_service_execute(int *chanfdp, int *procfdp) * between sandbox and its owner. */ static void -zygote_main(int sock) +zygote_main(int *sockp) { int error, procfd; int chanfd[2]; @@ -113,12 +114,14 @@ zygote_main(int sock) zygote_func_t *func; pid_t pid; - assert(sock > STDERR_FILENO); + fd_fix_environment(sockp); + + assert(*sockp > STDERR_FILENO); setproctitle("zygote"); for (;;) { - nvlin = nvlist_recv(sock, 0); + nvlin = nvlist_recv(*sockp, 0); if (nvlin == NULL) { if (errno == ENOTCONN) { /* Casper exited. */ @@ -157,7 +160,7 @@ zygote_main(int sock) break; case 0: /* Child. */ - close(sock); + close(*sockp); close(chanfd[0]); func(chanfd[1]); /* NOTREACHED */ @@ -179,7 +182,7 @@ send: nvlist_move_descriptor(nvlout, "chanfd", chanfd[0]); nvlist_move_descriptor(nvlout, "procfd", procfd); } - (void)nvlist_send(sock, nvlout); + (void)nvlist_send(*sockp, nvlout); nvlist_destroy(nvlout); } /* NOTREACHED */ @@ -206,7 +209,7 @@ zygote_init(void) case 0: /* Child. */ close(sp[0]); - zygote_main(sp[1]); + zygote_main(&sp[1]); /* NOTREACHED */ abort(); default: From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 18:23:40 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 E29026503F0; Tue, 15 Jun 2021 18:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4Gsm61knz4n9t; Tue, 15 Jun 2021 18:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6BB94FBC; Tue, 15 Jun 2021 18:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15FINeXm044510; Tue, 15 Jun 2021 18:23:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FINegi044509; Tue, 15 Jun 2021 18:23:40 GMT (envelope-from git) Date: Tue, 15 Jun 2021 18:23:40 GMT Message-Id: <202106151823.15FINegi044509@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 4e2ae05c3ae8 - stable/12 - libcasper: fix descriptors numbers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 4e2ae05c3ae8c470829b4c3a78aa8c34a7f0b617 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, 15 Jun 2021 18:23:41 -0000 The branch stable/12 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=4e2ae05c3ae8c470829b4c3a78aa8c34a7f0b617 commit 4e2ae05c3ae8c470829b4c3a78aa8c34a7f0b617 Author: Mariusz Zaborski AuthorDate: 2021-06-09 21:46:51 +0000 Commit: Mariusz Zaborski CommitDate: 2021-06-15 18:23:25 +0000 libcasper: fix descriptors numbers Casper services expect that the first 3 descriptors (stdin/stdout/stderr) will point to /dev/null. Which Casper will ensure later. The Casper services are forked from the original process. If the initial process closes one of those descriptors, Casper may reuse one of them for it on purpose. If this is the case, then renumarate the descriptors used by Casper to higher numbers. This is done already after the fork, so it doesn't break the parent process. PR: 255339 Reported by: Borja Marcos Tested by: jkim@ (cherry picked from commit aa310ebfba3d49a0b6b03a103b969731a8136a73) --- lib/libcasper/libcasper/libcasper_impl.c | 27 +++++++++++++++++++++++++++ lib/libcasper/libcasper/libcasper_impl.h | 1 + lib/libcasper/libcasper/service.c | 23 +++++++++++++---------- lib/libcasper/libcasper/zygote.c | 15 +++++++++------ 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/lib/libcasper/libcasper/libcasper_impl.c b/lib/libcasper/libcasper/libcasper_impl.c index e4411630c8a1..ae28c8769a07 100644 --- a/lib/libcasper/libcasper/libcasper_impl.c +++ b/lib/libcasper/libcasper/libcasper_impl.c @@ -32,8 +32,10 @@ * $FreeBSD$ */ +#include #include #include +#include #include #include "libcasper_impl.h" @@ -44,3 +46,28 @@ fd_is_valid(int fd) return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); } + +void +fd_fix_environment(int *fdp) +{ + int nullfd, nfd; + + if (*fdp > STDERR_FILENO) + return; + + nullfd = open(_PATH_DEVNULL, O_RDWR); + if (nullfd == -1) + errx(1, "Unable to open %s", _PATH_DEVNULL); + + while (*fdp <= STDERR_FILENO) { + nfd = dup(*fdp); + if (nfd == -1) + errx(1, "Unable to secure fd"); + if (dup2(nullfd, *fdp) == -1) + errx(1, "Unable to secure fd"); + *fdp = nfd; + } + + close(nullfd); +} + diff --git a/lib/libcasper/libcasper/libcasper_impl.h b/lib/libcasper/libcasper/libcasper_impl.h index 11e43f083977..24049a0c07c8 100644 --- a/lib/libcasper/libcasper/libcasper_impl.h +++ b/lib/libcasper/libcasper/libcasper_impl.h @@ -44,6 +44,7 @@ struct service; struct service_connection; bool fd_is_valid(int fd); +void fd_fix_environment(int *fdp); /* Private service functions. */ struct service *service_alloc(const char *name, diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c index 5c1c64d9a9d7..e87d0640347c 100644 --- a/lib/libcasper/libcasper/service.c +++ b/lib/libcasper/libcasper/service.c @@ -386,24 +386,27 @@ stdnull(void) } static void -service_clean(int sock, int procfd, uint64_t flags) +service_clean(int *sockp, int *procfdp, uint64_t flags) { int fd, maxfd, minfd; - assert(sock > STDERR_FILENO); - assert(procfd > STDERR_FILENO); - assert(sock != procfd); + fd_fix_environment(sockp); + fd_fix_environment(procfdp); + + assert(*sockp > STDERR_FILENO); + assert(*procfdp > STDERR_FILENO); + assert(*sockp != *procfdp); if ((flags & CASPER_SERVICE_STDIO) == 0) stdnull(); if ((flags & CASPER_SERVICE_FD) == 0) { - if (procfd > sock) { - maxfd = procfd; - minfd = sock; + if (*procfdp > *sockp) { + maxfd = *procfdp; + minfd = *sockp; } else { - maxfd = sock; - minfd = procfd; + maxfd = *sockp; + minfd = *procfdp; } for (fd = STDERR_FILENO + 1; fd < maxfd; fd++) { @@ -424,7 +427,7 @@ service_start(struct service *service, int sock, int procfd) assert(service != NULL); assert(service->s_magic == SERVICE_MAGIC); setproctitle("%s", service->s_name); - service_clean(sock, procfd, service->s_flags); + service_clean(&sock, &procfd, service->s_flags); if (service_connection_add(service, sock, NULL) == NULL) _exit(1); diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c index 2b84bb49a695..5cdd139cc134 100644 --- a/lib/libcasper/libcasper/zygote.c +++ b/lib/libcasper/libcasper/zygote.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "libcasper_impl.h" #include "zygote.h" /* Zygote info. */ @@ -104,7 +105,7 @@ zygote_clone_service_execute(int *chanfdp, int *procfdp) * between sandbox and its owner. */ static void -zygote_main(int sock) +zygote_main(int *sockp) { int error, procfd; int chanfd[2]; @@ -113,12 +114,14 @@ zygote_main(int sock) zygote_func_t *func; pid_t pid; - assert(sock > STDERR_FILENO); + fd_fix_environment(sockp); + + assert(*sockp > STDERR_FILENO); setproctitle("zygote"); for (;;) { - nvlin = nvlist_recv(sock, 0); + nvlin = nvlist_recv(*sockp, 0); if (nvlin == NULL) { if (errno == ENOTCONN) { /* Casper exited. */ @@ -157,7 +160,7 @@ zygote_main(int sock) break; case 0: /* Child. */ - close(sock); + close(*sockp); close(chanfd[0]); func(chanfd[1]); /* NOTREACHED */ @@ -179,7 +182,7 @@ send: nvlist_move_descriptor(nvlout, "chanfd", chanfd[0]); nvlist_move_descriptor(nvlout, "procfd", procfd); } - (void)nvlist_send(sock, nvlout); + (void)nvlist_send(*sockp, nvlout); nvlist_destroy(nvlout); } /* NOTREACHED */ @@ -206,7 +209,7 @@ zygote_init(void) case 0: /* Child. */ close(sp[0]); - zygote_main(sp[1]); + zygote_main(&sp[1]); /* NOTREACHED */ abort(); default: From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 18:30:40 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 4BF246501EF; Tue, 15 Jun 2021 18:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4H1r1VJ0z4pNP; Tue, 15 Jun 2021 18:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1C8445316; Tue, 15 Jun 2021 18:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15FIUenp053379; Tue, 15 Jun 2021 18:30:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FIUeOW053378; Tue, 15 Jun 2021 18:30:40 GMT (envelope-from git) Date: Tue, 15 Jun 2021 18:30:40 GMT Message-Id: <202106151830.15FIUeOW053378@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 6c0a51837f4b - stable/11 - libcasper: fix descriptors numbers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 6c0a51837f4ba242ea723a887c3b6120d9335c8f 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, 15 Jun 2021 18:30:40 -0000 The branch stable/11 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=6c0a51837f4ba242ea723a887c3b6120d9335c8f commit 6c0a51837f4ba242ea723a887c3b6120d9335c8f Author: Mariusz Zaborski AuthorDate: 2021-06-09 21:46:51 +0000 Commit: Mariusz Zaborski CommitDate: 2021-06-15 18:30:27 +0000 libcasper: fix descriptors numbers Casper services expect that the first 3 descriptors (stdin/stdout/stderr) will point to /dev/null. Which Casper will ensure later. The Casper services are forked from the original process. If the initial process closes one of those descriptors, Casper may reuse one of them for it on purpose. If this is the case, then renumarate the descriptors used by Casper to higher numbers. This is done already after the fork, so it doesn't break the parent process. PR: 255339 Reported by: Borja Marcos Tested by: jkim@ (cherry picked from commit aa310ebfba3d49a0b6b03a103b969731a8136a73) --- lib/libcasper/libcasper/libcasper_impl.c | 27 +++++++++++++++++++++++++++ lib/libcasper/libcasper/libcasper_impl.h | 1 + lib/libcasper/libcasper/service.c | 23 +++++++++++++---------- lib/libcasper/libcasper/zygote.c | 15 +++++++++------ 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/lib/libcasper/libcasper/libcasper_impl.c b/lib/libcasper/libcasper/libcasper_impl.c index 57d489943252..f58bd44d2039 100644 --- a/lib/libcasper/libcasper/libcasper_impl.c +++ b/lib/libcasper/libcasper/libcasper_impl.c @@ -30,8 +30,10 @@ * $FreeBSD$ */ +#include #include #include +#include #include #include "libcasper_impl.h" @@ -42,3 +44,28 @@ fd_is_valid(int fd) return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); } + +void +fd_fix_environment(int *fdp) +{ + int nullfd, nfd; + + if (*fdp > STDERR_FILENO) + return; + + nullfd = open(_PATH_DEVNULL, O_RDWR); + if (nullfd == -1) + errx(1, "Unable to open %s", _PATH_DEVNULL); + + while (*fdp <= STDERR_FILENO) { + nfd = dup(*fdp); + if (nfd == -1) + errx(1, "Unable to secure fd"); + if (dup2(nullfd, *fdp) == -1) + errx(1, "Unable to secure fd"); + *fdp = nfd; + } + + close(nullfd); +} + diff --git a/lib/libcasper/libcasper/libcasper_impl.h b/lib/libcasper/libcasper/libcasper_impl.h index 89f244d0b87d..01dbd234e3ff 100644 --- a/lib/libcasper/libcasper/libcasper_impl.h +++ b/lib/libcasper/libcasper/libcasper_impl.h @@ -42,6 +42,7 @@ struct service; struct service_connection; bool fd_is_valid(int fd); +void fd_fix_environment(int *fdp); /* Private service functions. */ struct service *service_alloc(const char *name, diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c index cc53d0d630ae..b3d2d2f05ea3 100644 --- a/lib/libcasper/libcasper/service.c +++ b/lib/libcasper/libcasper/service.c @@ -365,24 +365,27 @@ stdnull(void) } static void -service_clean(int sock, int procfd, uint64_t flags) +service_clean(int *sockp, int *procfdp, uint64_t flags) { int fd, maxfd, minfd; - assert(sock > STDERR_FILENO); - assert(procfd > STDERR_FILENO); - assert(sock != procfd); + fd_fix_environment(sockp); + fd_fix_environment(procfdp); + + assert(*sockp > STDERR_FILENO); + assert(*procfdp > STDERR_FILENO); + assert(*sockp != *procfdp); if ((flags & CASPER_SERVICE_STDIO) == 0) stdnull(); if ((flags & CASPER_SERVICE_FD) == 0) { - if (procfd > sock) { - maxfd = procfd; - minfd = sock; + if (*procfdp > *sockp) { + maxfd = *procfdp; + minfd = *sockp; } else { - maxfd = sock; - minfd = procfd; + maxfd = *sockp; + minfd = *procfdp; } for (fd = STDERR_FILENO + 1; fd < maxfd; fd++) { @@ -403,7 +406,7 @@ service_start(struct service *service, int sock, int procfd) assert(service != NULL); assert(service->s_magic == SERVICE_MAGIC); setproctitle("%s", service->s_name); - service_clean(sock, procfd, service->s_flags); + service_clean(&sock, &procfd, service->s_flags); if (service_connection_add(service, sock, NULL) == NULL) exit(1); diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c index feeb1537af87..ef0032ddf58d 100644 --- a/lib/libcasper/libcasper/zygote.c +++ b/lib/libcasper/libcasper/zygote.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include "libcasper_impl.h" #include "zygote.h" /* Zygote info. */ @@ -88,7 +89,7 @@ zygote_clone(zygote_func_t *func, int *chanfdp, int *procfdp) * between sandbox and its owner. */ static void -zygote_main(int sock) +zygote_main(int *sockp) { int error, procfd; int chanfd[2]; @@ -96,12 +97,14 @@ zygote_main(int sock) zygote_func_t *func; pid_t pid; - assert(sock > STDERR_FILENO); + fd_fix_environment(sockp); + + assert(*sockp > STDERR_FILENO); setproctitle("zygote"); for (;;) { - nvlin = nvlist_recv(sock, 0); + nvlin = nvlist_recv(*sockp, 0); if (nvlin == NULL) { if (errno == ENOTCONN) { /* Casper exited. */ @@ -133,7 +136,7 @@ zygote_main(int sock) break; case 0: /* Child. */ - close(sock); + close(*sockp); close(chanfd[0]); func(chanfd[1]); /* NOTREACHED */ @@ -155,7 +158,7 @@ send: nvlist_move_descriptor(nvlout, "chanfd", chanfd[0]); nvlist_move_descriptor(nvlout, "procfd", procfd); } - (void)nvlist_send(sock, nvlout); + (void)nvlist_send(*sockp, nvlout); nvlist_destroy(nvlout); } /* NOTREACHED */ @@ -182,7 +185,7 @@ zygote_init(void) case 0: /* Child. */ close(sp[0]); - zygote_main(sp[1]); + zygote_main(&sp[1]); /* NOTREACHED */ abort(); default: From owner-dev-commits-src-branches@freebsd.org Tue Jun 15 21:27: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 35F9D653F8A; Tue, 15 Jun 2021 21:27: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 4G4LxP0pTjz3PC9; Tue, 15 Jun 2021 21:27: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 03D8375ED; Tue, 15 Jun 2021 21:27: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 15FLR4kk087526; Tue, 15 Jun 2021 21:27:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15FLR463087525; Tue, 15 Jun 2021 21:27:04 GMT (envelope-from git) Date: Tue, 15 Jun 2021 21:27:04 GMT Message-Id: <202106152127.15FLR463087525@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Pedro F. Giffuni" Subject: git: 62d555c4e828 - stable/13 - fread: improve performance for unbuffered reads MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pfg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 62d555c4e82852bf80b1d833a31ff4dc7833f4cd 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, 15 Jun 2021 21:27:05 -0000 The branch stable/13 has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=62d555c4e82852bf80b1d833a31ff4dc7833f4cd commit 62d555c4e82852bf80b1d833a31ff4dc7833f4cd Author: Pedro F. Giffuni AuthorDate: 2021-05-31 01:48:38 +0000 Commit: Pedro F. Giffuni CommitDate: 2021-06-15 21:26:31 +0000 fread: improve performance for unbuffered reads We can use the buffer passed to fread(3) directly in the FILE *. The buffer needs to be reset before each call to __srefill(). This preserves the expected behavior in all cases. The change was found originally in OpenBSD and later adopted by NetBSD. MFC after: 2 weeks Obtained from: OpenBSD (CVS 1.18) Differential Revision: https://reviews.freebsd.org/D30548 --- lib/libc/stdio/fread.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c index c12bcf1148b7..11f8d13f0caf 100644 --- a/lib/libc/stdio/fread.c +++ b/lib/libc/stdio/fread.c @@ -99,6 +99,35 @@ __fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict fp) fp->_r = 0; total = resid; p = buf; + + /* + * If we're unbuffered we know that the buffer in fp is empty so + * we can read directly into buf. This is much faster than a + * series of one byte reads into fp->_nbuf. + */ + if ((fp->_flags & __SNBF) != 0 && buf != NULL) { + while (resid > 0) { + /* set up the buffer */ + fp->_bf._base = fp->_p = p; + fp->_bf._size = resid; + + if (__srefill(fp)) { + /* no more input: return partial result */ + count = (total - resid) / size; + break; + } + p += fp->_r; + resid -= fp->_r; + } + + /* restore the old buffer (see __smakebuf) */ + fp->_bf._base = fp->_p = fp->_nbuf; + fp->_bf._size = 1; + fp->_r = 0; + + return (count); + } + while (resid > (r = fp->_r)) { (void)memcpy((void *)p, (void *)fp->_p, (size_t)r); fp->_p += r; From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 00:45: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 38EB4657D3B; Wed, 16 Jun 2021 00:45: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 4G4RLT0NR6z3vfd; Wed, 16 Jun 2021 00:45: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 E4FDA126AE; Wed, 16 Jun 2021 00:45: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 15G0jadL052638; Wed, 16 Jun 2021 00:45:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15G0jaSX052637; Wed, 16 Jun 2021 00:45:36 GMT (envelope-from git) Date: Wed, 16 Jun 2021 00:45:36 GMT Message-Id: <202106160045.15G0jaSX052637@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Martin Matuska Subject: git: d940dcb757cd - stable/13 - zfs: unbreak stable/13 clang build on non-x86 archs after b0c251b0d MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d940dcb757cd2214a218fe3445eef5d24581b556 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, 16 Jun 2021 00:45:37 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=d940dcb757cd2214a218fe3445eef5d24581b556 commit d940dcb757cd2214a218fe3445eef5d24581b556 Author: Martin Matuska AuthorDate: 2021-06-16 00:38:42 +0000 Commit: Martin Matuska CommitDate: 2021-06-16 00:44:48 +0000 zfs: unbreak stable/13 clang build on non-x86 archs after b0c251b0d (direct commit) --- cddl/lib/libspl/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cddl/lib/libspl/Makefile b/cddl/lib/libspl/Makefile index 8088ef497d46..c657dd9b2290 100644 --- a/cddl/lib/libspl/Makefile +++ b/cddl/lib/libspl/Makefile @@ -1,10 +1,12 @@ # $FreeBSD$ +.include +.include + .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/os/freebsd .PATH: ${SRCTOP}/sys/contrib/openzfs/include - LIB= spl LIBADD= PACKAGE= runtime @@ -53,6 +55,9 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h +.if ${COMPILER_TYPE} == "clang" +CFLAGS.atomic.c+= -Wno-error=atomic-alignment +.endif CFLAGS.atomic.S+= -DLOCORE .include From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 01: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 49BCC658D2B; Wed, 16 Jun 2021 01: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 4G4SzS1Mn0z4TSZ; Wed, 16 Jun 2021 01: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 13733135E2; Wed, 16 Jun 2021 01: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 15G1xFrw046130; Wed, 16 Jun 2021 01: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 15G1xFBw046129; Wed, 16 Jun 2021 01:59:15 GMT (envelope-from git) Date: Wed, 16 Jun 2021 01:59:15 GMT Message-Id: <202106160159.15G1xFBw046129@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Martin Matuska Subject: git: 014f9aa8218a - stable/13 - zfs: unbreak stable/13 build on i386 after b0c251b0d MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 014f9aa8218a66ef1e412ad37a75b8da5ab9d65e 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, 16 Jun 2021 01:59:16 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=014f9aa8218a66ef1e412ad37a75b8da5ab9d65e commit 014f9aa8218a66ef1e412ad37a75b8da5ab9d65e Author: Martin Matuska AuthorDate: 2021-06-16 01:47:02 +0000 Commit: Martin Matuska CommitDate: 2021-06-16 01:56:19 +0000 zfs: unbreak stable/13 build on i386 after b0c251b0d The build was broken because upstream merged e76373de7 (author: mav) without fef8bd41f from openzfs/zfs/master into openzfs/zfs/zfs-2.1-release. Temporary fix until upstream decides a way to solve this problem. Patch by: mav Differential Revision: https://reviews.freebsd.org/D30783 (direct commit) --- sys/contrib/openzfs/lib/libspl/asm-i386/atomic.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/contrib/openzfs/lib/libspl/asm-i386/atomic.S b/sys/contrib/openzfs/lib/libspl/asm-i386/atomic.S index 7a574b0d1729..c8a6c78b5fa8 100644 --- a/sys/contrib/openzfs/lib/libspl/asm-i386/atomic.S +++ b/sys/contrib/openzfs/lib/libspl/asm-i386/atomic.S @@ -762,6 +762,7 @@ SET_SIZE(atomic_swap_32) ENTRY(atomic_swap_64) + ALTENTRY(atomic_store_64) pushl %esi pushl %ebx movl 12(%esp), %esi @@ -776,8 +777,20 @@ popl %ebx popl %esi ret + SET_SIZE(atomic_store_64) SET_SIZE(atomic_swap_64) + ENTRY(atomic_load_64) + pushl %esi + movl 8(%esp), %esi + movl %ebx, %eax + movl %ecx, %edx + lock + cmpxchg8b (%esi) + popl %esi + ret + SET_SIZE(atomic_load_64) + ENTRY(atomic_set_long_excl) movl 4(%esp), %edx movl 8(%esp), %ecx From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 10:42: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 79A7065F4F7; Wed, 16 Jun 2021 10:42: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 4G4hb62P9rz3Mrr; Wed, 16 Jun 2021 10:42: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 371911A699; Wed, 16 Jun 2021 10:42: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 15GAgQLD054345; Wed, 16 Jun 2021 10:42:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GAgQ3T054344; Wed, 16 Jun 2021 10:42:26 GMT (envelope-from git) Date: Wed, 16 Jun 2021 10:42:26 GMT Message-Id: <202106161042.15GAgQ3T054344@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 118ff4e9b3f1 - stable/13 - rk3328_cru: fix a typo in the SCLK_I2S2 gate definition MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 118ff4e9b3f1cb22bdb2ccdb05dc4c5092d16371 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, 16 Jun 2021 10:42:26 -0000 The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=118ff4e9b3f1cb22bdb2ccdb05dc4c5092d16371 commit 118ff4e9b3f1cb22bdb2ccdb05dc4c5092d16371 Author: Andriy Gapon AuthorDate: 2021-06-09 07:44:41 +0000 Commit: Andriy Gapon CommitDate: 2021-06-16 10:42:12 +0000 rk3328_cru: fix a typo in the SCLK_I2S2 gate definition (cherry picked from commit ffc5dc788f05dec5fd11aff8f216c37cd56fcd7f) --- sys/arm64/rockchip/clk/rk3328_cru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/rockchip/clk/rk3328_cru.c b/sys/arm64/rockchip/clk/rk3328_cru.c index e110564f773d..95a87cfd0e00 100644 --- a/sys/arm64/rockchip/clk/rk3328_cru.c +++ b/sys/arm64/rockchip/clk/rk3328_cru.c @@ -114,7 +114,7 @@ static struct rk_cru_gate rk3328_gates[] = { /* CRU_CLKGATE_CON1 */ CRU_GATE(SCLK_I2S0, "clk_i2s0", "clk_i2s0_mux", 0x204, 3) CRU_GATE(SCLK_I2S1, "clk_i2s1", "clk_i2s1_mux", 0x204, 6) - CRU_GATE(SCLK_I2S1, "clk_i2s2", "clk_i2s2_mux", 0x204, 10) + CRU_GATE(SCLK_I2S2, "clk_i2s2", "clk_i2s2_mux", 0x204, 10) /* CRU_CLKGATE_CON4 */ CRU_GATE(0, "gpll_peri", "gpll", 0x210, 0) From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 10:46:42 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 EFF7565F73F; Wed, 16 Jun 2021 10:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4hh26Ng8z3N5p; Wed, 16 Jun 2021 10:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3A731A708; Wed, 16 Jun 2021 10:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15GAkgGk054760; Wed, 16 Jun 2021 10:46:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GAkgrD054759; Wed, 16 Jun 2021 10:46:42 GMT (envelope-from git) Date: Wed, 16 Jun 2021 10:46:42 GMT Message-Id: <202106161046.15GAkgrD054759@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: e7ca75cb75be - stable/13 - rc.d: liberate powerd from ACPI dependency MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e7ca75cb75be2aa6177face2b1220af09988f49f 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, 16 Jun 2021 10:46:43 -0000 The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=e7ca75cb75be2aa6177face2b1220af09988f49f commit e7ca75cb75be2aa6177face2b1220af09988f49f Author: Andriy Gapon AuthorDate: 2021-06-08 17:08:10 +0000 Commit: Andriy Gapon CommitDate: 2021-06-16 10:46:21 +0000 rc.d: liberate powerd from ACPI dependency For instance, many non-ACPI ARM systems have CPU power / frequency levels. (cherry picked from commit 20eb6bd8c598fdbf4e96ed4ca64a609be255ccba) --- libexec/rc/rc.d/Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index 1a61e89aa215..13ed6048efc0 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -80,6 +80,7 @@ CONFS= DAEMON \ pf \ pflog \ pfsync \ + powerd \ ppp \ pppoed \ pwcheck \ @@ -136,10 +137,6 @@ ACPI= power_profile ACPIPACKAGE= acpi .endif -.if ${MK_ACPI} != "no" || ${MK_APM} != "no" -CONFS+= powerd -.endif - .if ${MK_APM} != "no" CONFGROUPS+= APM APM+= apm From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 10: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 6EEC365FA09; Wed, 16 Jun 2021 10: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 4G4hlL2mWYz3NJ2; Wed, 16 Jun 2021 10:49:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 439881A4C9; Wed, 16 Jun 2021 10:49:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15GAnYk3055067; Wed, 16 Jun 2021 10:49:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GAnYdd055066; Wed, 16 Jun 2021 10:49:34 GMT (envelope-from git) Date: Wed, 16 Jun 2021 10:49:34 GMT Message-Id: <202106161049.15GAnYdd055066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 0dc7e55dcb0e - stable/12 - rc.d: liberate powerd from ACPI dependency MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 0dc7e55dcb0e7fd6415bf50ec6b8e11bf0beb2c5 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, 16 Jun 2021 10:49:34 -0000 The branch stable/12 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=0dc7e55dcb0e7fd6415bf50ec6b8e11bf0beb2c5 commit 0dc7e55dcb0e7fd6415bf50ec6b8e11bf0beb2c5 Author: Andriy Gapon AuthorDate: 2021-06-08 17:08:10 +0000 Commit: Andriy Gapon CommitDate: 2021-06-16 10:49:11 +0000 rc.d: liberate powerd from ACPI dependency For instance, many non-ACPI ARM systems have CPU power / frequency levels. (cherry picked from commit 20eb6bd8c598fdbf4e96ed4ca64a609be255ccba) --- libexec/rc/rc.d/Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index e4c426290d4e..f6e6c437fece 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -84,6 +84,7 @@ CONFS= DAEMON \ pf \ pflog \ pfsync \ + powerd \ ppp \ pppoed \ pwcheck \ @@ -141,10 +142,6 @@ ACPI= power_profile ACPIPACKAGE= acpi .endif -.if ${MK_ACPI} != "no" || ${MK_APM} != "no" -CONFS+= powerd -.endif - .if ${MK_AMD} != "no" CONFGROUPS+= AMD AMD+= amd From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:26: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 8F78D660999; Wed, 16 Jun 2021 11:26: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 4G4jYk3hWnz3QnH; Wed, 16 Jun 2021 11:26: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 6313E1A9F8; Wed, 16 Jun 2021 11:26: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 15GBQIev008237; Wed, 16 Jun 2021 11:26:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBQIi6008236; Wed, 16 Jun 2021 11:26:18 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:26:18 GMT Message-Id: <202106161126.15GBQIi6008236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 7d243608d516 - stable/13 - tests/netgraph: Tests for ng_hub MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7d243608d516ba421fe603b57fd430beba441eef 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, 16 Jun 2021 11:26:18 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=7d243608d516ba421fe603b57fd430beba441eef commit 7d243608d516ba421fe603b57fd430beba441eef Author: Lutz Donnerhacke AuthorDate: 2021-06-03 22:22:29 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:25:01 +0000 tests/netgraph: Tests for ng_hub Test functionality of ng_hub(4): - replicting traffic to anything but the sending hook - persistence - an unrestricted loop - implementation limits with many hooks. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30633 (cherry picked from commit 7863faa78ae271017c404c635b2a9d07379d4316) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/hub.c | 231 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 7376cb5c1227..2ae9882b2bc3 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -12,9 +12,11 @@ TEST_METADATA.ng_macfilter_test+= required_programs="perl" ATF_TESTS_C+= basic \ bridge \ + hub \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c +SRCS.hub= hub.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/hub.c b/tests/sys/netgraph/hub.c new file mode 100644 index 000000000000..08d083ad9605 --- /dev/null +++ b/tests/sys/netgraph/hub.c @@ -0,0 +1,231 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + ng_connect(".", "b", "hub:", "b"); + ng_connect(".", "c", "hub:", "c"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data0); + ng_register_data("c", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("b", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("c", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + ng_shutdown("hub:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_send_msg("hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("hub:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "LOOP Alert!"; + + ng_errors(PASS); + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub1"); + ng_mkpeer(".", "b", "hub", "b"); + ng_name("b", "hub2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data0); + + /*- + * Open loop + * + * /-- hub1 + * . < | + * \-- hub2 + */ + ng_connect("hub1:", "xc1", "hub2:", "xc1"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- hub1 -\ + * . < | | + * \-- hub2 -/ + */ + ng_connect("hub1:", "xc2", "hub2:", "xc2"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, r)) + break; + ATF_CHECK(r[0] > 7); + + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); +} + +ATF_TC(many_hooks); +ATF_TC_HEAD(many_hooks, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_hooks, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int HOOKS = 1000; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_register_data("a", get_data0); + ng_counter_clear(r); + for (i = 0; i < HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "hook%d", i); + ng_connect(".", hook, "hub:", hook); + ng_errors(PASS); + ng_send_data(hook, msg, sizeof(msg)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, r); + } + ATF_CHECK(r[0] > 100); + atf_tc_expect_fail("Implementation limitation (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("hub:"); +} + + +ATF_TP_ADD_TCS(hub) +{ + ATF_TP_ADD_TC(hub, basic); + ATF_TP_ADD_TC(hub, loop); + ATF_TP_ADD_TC(hub, persistence); + ATF_TP_ADD_TC(hub, many_hooks); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:26:19 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 A6EF366091D; Wed, 16 Jun 2021 11:26:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4jYl45Tmz3QqJ; Wed, 16 Jun 2021 11:26:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 72EC61A9F9; Wed, 16 Jun 2021 11:26:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15GBQJRs008261; Wed, 16 Jun 2021 11:26:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBQJur008260; Wed, 16 Jun 2021 11:26:19 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:26:19 GMT Message-Id: <202106161126.15GBQJur008260@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 053937ce6e1a - stable/13 - tests/netgraph: Tests for ng_vlan_rotate MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 053937ce6e1a72a72f8845c0dc8a10be71fea336 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, 16 Jun 2021 11:26:19 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=053937ce6e1a72a72f8845c0dc8a10be71fea336 commit 053937ce6e1a72a72f8845c0dc8a10be71fea336 Author: Lutz Donnerhacke AuthorDate: 2021-06-06 23:56:12 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:25:04 +0000 tests/netgraph: Tests for ng_vlan_rotate Test functionality of ng_vlan_rotate(4): - Rotate 1 to 9 stagged vlans in any possible direction and length - Rotate random combinations of ethertypes (8100, 88a8, 9100) - Automatic reverse rotating for backward data flow - Test too many and too few vlans Reviewed by: kp (earlier version) Differential Revision: https://reviews.freebsd.org/D30670 (cherry picked from commit 6b08e68be111d50931b0d30145f8b7e3402decaf) --- tests/sys/netgraph/Makefile | 8 +- tests/sys/netgraph/vlan_rotate.c | 335 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+), 3 deletions(-) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 2ae9882b2bc3..f397e66a22bc 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -10,13 +10,15 @@ TAP_TESTS_SH+= ng_macfilter_test TEST_METADATA.ng_macfilter_test+= required_user="root" TEST_METADATA.ng_macfilter_test+= required_programs="perl" -ATF_TESTS_C+= basic \ - bridge \ - hub \ +ATF_TESTS_C+= basic \ + bridge \ + hub \ + vlan_rotate \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c SRCS.hub= hub.c util.c +SRCS.vlan_rotate=vlan_rotate.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/vlan_rotate.c b/tests/sys/netgraph/vlan_rotate.c new file mode 100644 index 000000000000..8df3ab981a7c --- /dev/null +++ b/tests/sys/netgraph/vlan_rotate.c @@ -0,0 +1,335 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" +#include + +struct vlan +{ + uint16_t proto; + uint16_t tag; +} __packed; + +struct frame +{ + u_char dst[ETHER_ADDR_LEN]; + u_char src[ETHER_ADDR_LEN]; + struct vlan vlan[10]; +} __packed; + +static struct frame msg = { + .src = {2, 4, 6, 1, 3, 5}, + .dst = {2, 4, 6, 1, 3, 7}, + .vlan[0] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(1, 0, 0))}, + .vlan[1] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(2, 0, 0))}, + .vlan[2] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(3, 0, 0))}, + .vlan[3] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(4, 0, 0))}, + .vlan[4] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(5, 0, 0))}, + .vlan[5] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(6, 0, 0))}, + .vlan[6] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(7, 0, 0))}, + .vlan[7] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(8, 0, 0))}, + .vlan[8] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(9, 0, 0))}, + .vlan[9] = {0} +}; + +static void _basic(int); +static void get_vlan(void *data, size_t len, void *ctx); + +static void +get_vlan(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = EVL_VLANOFTAG(ntohs(f->vlan[i].tag)); +} + +static void +_basic(int direction) +{ + int r[10]; + int i, rot, len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_vlan); + + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + for (rot = -len + 1; rot < len; rot++) + { + char cmd[40]; + + /* set rotation offset */ + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len + 1; + int vlan = r[i]; + + ATF_CHECK_MSG(vlan == expect, + "len=%d rot=%d i=%d -> vlan=%d, expect=%d", + len, rot, i, r[i], expect); + } + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + _basic(1); +} + +ATF_TC(reverse); +ATF_TC_HEAD(reverse, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(reverse, dummy) +{ + _basic(-1); +} + +static void _ethertype(int); +static void get_ethertype(void *data, size_t len, void *ctx); + +static void +get_ethertype(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = ntohs(f->vlan[i].proto); +} + +static void +_ethertype(int direction) +{ + int r[10]; + int i, rounds = 20; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_ethertype); + + while (rounds-- > 0) + { + char cmd[40]; + int len = 9; + int rot = rand() % (2 * len - 1) - len + 1; + int vlan[10]; + + for (i = 0; i < len; i++) + { + switch (rand() % 3) + { + default: + msg.vlan[i].proto = htons(ETHERTYPE_VLAN); + break; + case 1: + msg.vlan[i].proto = htons(ETHERTYPE_QINQ); + break; + case 2: + msg.vlan[i].proto = htons(ETHERTYPE_8021Q9100); + break; + } + } + msg.vlan[i].proto = htons(ETHERTYPE_IP); + + for (i = 0; i < len; i++) + vlan[i] = msg.vlan[i].proto; + + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + bzero(r, sizeof(r)); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len; + + ATF_CHECK_MSG(r[i] == ntohs(vlan[expect]), + "len=%d rot=%d i=%d -> vlan=%04x, expect(%d)=%04x", + len, rot, i, ntohs(r[i]), expect, vlan[expect]); + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(ethertype); +ATF_TC_HEAD(ethertype, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(ethertype, dummy) +{ + _ethertype(1); +} + +ATF_TC(typeether); +ATF_TC_HEAD(typeether, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(typeether, dummy) +{ + _ethertype(-1); +} + +ATF_TC(minmax); +ATF_TC_HEAD(minmax, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(minmax, dummy) +{ + ng_counter_t r; + int len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", "original"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", "ordered"); + ng_connect(".", "c", "vr:", "excessive"); + ng_connect(".", "d", "vr:", "incomplete"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_register_data("d", get_data3); + + ng_send_msg("vr:", "setconf { min=3 max=7 rot=0 }"); + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + ng_counter_clear(r); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("b", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("c", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("d", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + } + + ng_shutdown("vr:"); +} + +ATF_TP_ADD_TCS(vlan_rotate) +{ + /* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */ + srand(0xb93b); + + ATF_TP_ADD_TC(vlan_rotate, basic); + ATF_TP_ADD_TC(vlan_rotate, ethertype); + ATF_TP_ADD_TC(vlan_rotate, reverse); + ATF_TP_ADD_TC(vlan_rotate, typeether); + ATF_TP_ADD_TC(vlan_rotate, minmax); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:45: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 B639E660D26; Wed, 16 Jun 2021 11:45: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 4G4k0R0cQkz3jJQ; Wed, 16 Jun 2021 11:45: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 EC9A51AD7E; Wed, 16 Jun 2021 11:45:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15GBjwSn035326; Wed, 16 Jun 2021 11:45:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBjwIs035325; Wed, 16 Jun 2021 11:45:58 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:45:58 GMT Message-Id: <202106161145.15GBjwIs035325@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 49a07e3d08a0 - stable/12 - tests/netgraph: Prebuild tests directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 49a07e3d08a0d7126fb759ea394a629a14e914f9 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, 16 Jun 2021 11:45:59 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=49a07e3d08a0d7126fb759ea394a629a14e914f9 commit 49a07e3d08a0d7126fb759ea394a629a14e914f9 Author: Lutz Donnerhacke AuthorDate: 2021-06-16 11:37:51 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:44:15 +0000 tests/netgraph: Prebuild tests directory (partially cherry picked from commit e8db04c38959c882fe17e7c2b26fbabe74f26311) --- tests/sys/Makefile | 1 + tests/sys/netgraph/Makefile | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/tests/sys/Makefile b/tests/sys/Makefile index 2d3b26f0f1aa..2bf51bcd3fd7 100644 --- a/tests/sys/Makefile +++ b/tests/sys/Makefile @@ -18,6 +18,7 @@ TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= kqueue TESTS_SUBDIRS+= mac TESTS_SUBDIRS+= mqueue +TESTS_SUBDIRS+= netgraph TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= netinet6 TESTS_SUBDIRS+= netipsec diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile new file mode 100644 index 000000000000..e6a9d6fbf338 --- /dev/null +++ b/tests/sys/netgraph/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/netgraph +BINDIR= ${TESTSDIR} + +.include From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:46: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 36E4C660E4A; Wed, 16 Jun 2021 11:46: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 4G4k0S15y1z3jD9; Wed, 16 Jun 2021 11:46: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 0E3DA1B240; Wed, 16 Jun 2021 11:46: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 15GBjx6I035352; Wed, 16 Jun 2021 11:45:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBjxq3035351; Wed, 16 Jun 2021 11:45:59 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:45:59 GMT Message-Id: <202106161145.15GBjxq3035351@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 2def89063412 - stable/12 - tests/netgraph: Inital framework for testing libnetgraph MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2def8906341231cd6b3647756c182f60d114deee 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, 16 Jun 2021 11:46:00 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=2def8906341231cd6b3647756c182f60d114deee commit 2def8906341231cd6b3647756c182f60d114deee Author: Lutz Donnerhacke AuthorDate: 2021-06-02 22:29:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:44:15 +0000 tests/netgraph: Inital framework for testing libnetgraph Provide a framework of functions to test various netgraph modules. Tests contain: - creating, renaming, and destroying nodes - connecting and removing hooks - sending and receiving data - sending ASCII messages and receiving binary responses - errors can be passed for indiviual inspection or fail the test Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30629 Differential Revision: https://reviews.freebsd.org/D30657 Differential Revision: https://reviews.freebsd.org/D30671 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 24ea1dbf257aa6757f469bcd859f90e9ad851e59) (cherry picked from commit 09307dbfb888a98232096c751a96ecb3344aa77c) (cherry picked from commit 9021c46603bf29b9700f24b8dce8796b434d7c8f) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) Also contains some fixups: - indent all files correctly - finish factoring out - remove debugging code - check for renaming issues reported in PR241954 PR: 241954 Differential Revision: https://reviews.freebsd.org/D30692 Differential Revision: https://reviews.freebsd.org/D30714 Differential Revision: https://reviews.freebsd.org/D30713 (cherry picked from commit a664ade93972ce617f0888ff79e715dff9cf0f87) (cherry picked from commit 0afa9be03937d60cb5aeba64c81e3e2165bd3737) (cherry picked from commit 43e4821315c31db067e23564b9bfafb519e77b2b) --- tests/sys/netgraph/Makefile | 6 + tests/sys/netgraph/basic.c | 191 ++++++++++++++++++++++++++++++ tests/sys/netgraph/util.c | 277 ++++++++++++++++++++++++++++++++++++++++++++ tests/sys/netgraph/util.h | 114 ++++++++++++++++++ 4 files changed, 588 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index e6a9d6fbf338..a28cae2f2432 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -5,4 +5,10 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} +ATF_TESTS_C+= basic \ + +SRCS.basic= basic.c util.c + +LIBADD+= netgraph + .include diff --git a/tests/sys/netgraph/basic.c b/tests/sys/netgraph/basic.c new file mode 100644 index 000000000000..573422add694 --- /dev/null +++ b/tests/sys/netgraph/basic.c @@ -0,0 +1,191 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(send_recv); +ATF_TC_HEAD(send_recv, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(send_recv, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + ng_send_data("a", msg, sizeof(msg)); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1); +} + +ATF_TC(node); +ATF_TC_HEAD(node, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(node, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_errors(PASS); + ng_name("a", "test hub"); + ng_errors(FAIL); + if (errno == EADDRINUSE) + atf_tc_expect_fail("PR241954"); + ATF_CHECK_ERRNO(0, 1); + atf_tc_expect_pass(); + + ng_connect(".", "b", "test hub:", "b"); + ng_connect(".", "c", "test hub:", "c"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + ng_shutdown("test hub:"); +} + +ATF_TC(message); +ATF_TC_HEAD(message, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(message, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_send_msg("test hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("test hub:"); +} + +ATF_TC(same_name); +ATF_TC_HEAD(same_name, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(same_name, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test"); + + ng_errors(PASS); + ng_connect(".", "a", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_connect(".", "b", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_name(".", "test"); + ATF_CHECK_ERRNO(EADDRINUSE, 1); + + ng_errors(FAIL); + ng_shutdown("test:"); +} + +ATF_TC(queuelimit); +ATF_TC_HEAD(queuelimit, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(queuelimit, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int MAX = 1000; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + + ng_errors(PASS); + for (i = 0; i < MAX; i++) + { + ng_send_data("a", msg, sizeof(msg)); + if (errno != 0) + break; + /* no ng_handle_events -> messages stall */ + } + ng_errors(FAIL); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] > 100); + ATF_CHECK(r[0] == i); + atf_tc_expect_fail("Queue full (%d)", i); + ATF_CHECK(r[0] == MAX); + atf_tc_expect_pass(); +} + +ATF_TP_ADD_TCS(basic) +{ + ATF_TP_ADD_TC(basic, send_recv); + ATF_TP_ADD_TC(basic, node); + ATF_TP_ADD_TC(basic, message); + ATF_TP_ADD_TC(basic, same_name); + ATF_TP_ADD_TC(basic, queuelimit); + + return atf_no_error(); +} diff --git a/tests/sys/netgraph/util.c b/tests/sys/netgraph/util.c new file mode 100644 index 000000000000..b25e63dfa76d --- /dev/null +++ b/tests/sys/netgraph/util.c @@ -0,0 +1,277 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" + + +static int cs = -1, ds = -1; +static ng_error_t error_handling = FAIL; + +#define CHECK(r, x) do { \ + if (!(x)) { \ + if (error_handling == PASS) \ + return r; \ + atf_tc_fail_requirement(file, line, "%s (%s)", \ + #x " not met", strerror(errno));\ + } \ +} while(0) + +struct data_handler +{ + char const *hook; + ng_data_handler_t handler; + SLIST_ENTRY(data_handler) next; +}; +static SLIST_HEAD(, data_handler) data_head = SLIST_HEAD_INITIALIZER(data_head); +static ng_msg_handler_t msg_handler = NULL; + +static void handle_data(void *ctx); +static void handle_msg(void *ctx); + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line) +{ + struct ngm_connect c; + + strncpy(c.ourhook, hook1, sizeof(c.ourhook)); + strncpy(c.peerhook, hook2, sizeof(c.peerhook)); + strncpy(c.path, path2, sizeof(c.path)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_CONNECT, + &c, sizeof(c))); +} + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line) +{ + struct ngm_mkpeer p; + + strncpy(p.ourhook, hook1, sizeof(p.ourhook)); + strncpy(p.peerhook, hook2, sizeof(p.peerhook)); + strncpy(p.type, type, sizeof(p.type)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_MKPEER, + &p, sizeof(p))); +} + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line) +{ + struct ngm_rmhook h; + + strncpy(h.ourhook, hook, sizeof(h.ourhook)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_RMHOOK, + &h, sizeof(h))); +} + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line) +{ + struct ngm_name n; + + strncpy(n.name, name, sizeof(n.name)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_NAME, + &n, sizeof(n))); +} + +void +_ng_shutdown(char const *path, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_SHUTDOWN, + NULL, 0)); +} + +void +ng_register_data(char const *hook, ng_data_handler_t proc) +{ + struct data_handler *p; + + ATF_REQUIRE(NULL != (p = calloc(1, sizeof(struct data_handler)))); + ATF_REQUIRE(NULL != (p->hook = strdup(hook))); + ATF_REQUIRE(NULL != (p->handler = proc)); + SLIST_INSERT_HEAD(&data_head, p, next); +} + +void +_ng_send_data(char const *hook, + void const *data, size_t len, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendData(ds, hook, data, len)); +} + +void +ng_register_msg(ng_msg_handler_t proc) +{ + msg_handler = proc; +} + +static void +handle_msg(void *ctx) +{ + struct ng_mesg *m; + char path[NG_PATHSIZ]; + + ATF_REQUIRE(-1 != NgAllocRecvMsg(cs, &m, path)); + + if (msg_handler != NULL) + (*msg_handler) (path, m, ctx); + + free(m); +} + +static void +handle_data(void *ctx) +{ + char hook[NG_HOOKSIZ]; + struct data_handler *hnd; + u_char *data; + int len; + + ATF_REQUIRE(0 < (len = NgAllocRecvData(ds, &data, hook))); + SLIST_FOREACH(hnd, &data_head, next) + { + if (0 == strcmp(hnd->hook, hook)) + break; + } + + if (hnd != NULL) + (*(hnd->handler)) (data, len, ctx); + + free(data); +} + +int +ng_handle_event(unsigned int ms, void *context) +{ + fd_set fds; + int maxfd = (ds < cs) ? cs : ds; + struct timeval timeout = {0, ms * 1000lu}; + + FD_ZERO(&fds); + FD_SET(cs, &fds); + FD_SET(ds, &fds); +retry: + switch (select(maxfd + 1, &fds, NULL, NULL, &timeout)) + { + case -1: + ATF_REQUIRE_ERRNO(EINTR, 1); + goto retry; + case 0: /* timeout */ + return 0; + default: /* something to do */ + if (FD_ISSET(cs, &fds)) + handle_msg(context); + if (FD_ISSET(ds, &fds)) + handle_data(context); + return 1; + } +} + +void +ng_handle_events(unsigned int ms, void *context) +{ + while (ng_handle_event(ms, context)) + ; +} + +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line) +{ + int res; + + CHECK(-1, -1 != (res = NgSendAsciiMsg(cs, path, "%s", msg))); + return (res); +} + +ng_error_t +ng_errors(ng_error_t n) +{ + ng_error_t o = error_handling; + + error_handling = n; + return (o); +} + +void +_ng_init(char const *file, size_t line) +{ + if (cs >= 0) /* prevent reinit */ + return; + + CHECK(, 0 == NgMkSockNode(NULL, &cs, &ds)); + NgSetDebug(3); +} + +#define GD(x) void \ +get_data##x(void *data, size_t len, void *ctx) {\ + int *cnt = ctx; \ + \ + (void)data; \ + (void)len; \ + cnt[x]++; \ +} + +GD(0) +GD(1) +GD(2) +GD(3) +GD(4) +GD(5) +GD(6) +GD(7) +GD(8) +GD(9) diff --git a/tests/sys/netgraph/util.h b/tests/sys/netgraph/util.h new file mode 100644 index 000000000000..44c9f3a360a7 --- /dev/null +++ b/tests/sys/netgraph/util.h @@ -0,0 +1,114 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#include + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line); +#define ng_connect(p1,h1,p2,h2) \ + _ng_connect(p1,h1,p2,h2,__FILE__,__LINE__) + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line); +#define ng_mkpeer(p1,h1,t,h2) \ + _ng_mkpeer(p1,h1,t,h2,__FILE__,__LINE__) + +void +_ng_shutdown(char const *path, + char const *file, size_t line); +#define ng_shutdown(p) \ + _ng_shutdown(p,__FILE__,__LINE__) + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line); +#define ng_rmhook(p,h) \ + _ng_rmhook(p,h,__FILE__,__LINE__) + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line); +#define ng_name(p,n) \ + _ng_name(p,n,__FILE__,__LINE__) + + +typedef void (*ng_data_handler_t)(void *, size_t, void *ctx); +void ng_register_data(char const *hook, ng_data_handler_t proc); +void +_ng_send_data(char const *hook, void const *, size_t, + char const *file, size_t line); +#define ng_send_data(h,d,l) \ + _ng_send_data(h,d,l,__FILE__,__LINE__) + +typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *); +void ng_register_msg(ng_msg_handler_t proc); +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line); +#define ng_send_msg(p,m) \ + _ng_send_msg(p,m,__FILE__,__LINE__) + +int ng_handle_event(unsigned int ms, void *ctx); +void ng_handle_events(unsigned int ms, void *ctx); + +typedef enum +{ + FAIL, PASS +} ng_error_t; +ng_error_t ng_errors(ng_error_t); + +void _ng_init(char const *file, size_t line); +#define ng_init() \ + _ng_init(__FILE__,__LINE__) + +/* Helper function to count received data */ + +typedef int ng_counter_t[10]; +#define ng_counter_clear(x)\ + bzero((x), sizeof(x)) + +void get_data0(void *data, size_t len, void *ctx); +void get_data1(void *data, size_t len, void *ctx); +void get_data2(void *data, size_t len, void *ctx); +void get_data3(void *data, size_t len, void *ctx); +void get_data4(void *data, size_t len, void *ctx); +void get_data5(void *data, size_t len, void *ctx); +void get_data6(void *data, size_t len, void *ctx); +void get_data7(void *data, size_t len, void *ctx); +void get_data8(void *data, size_t len, void *ctx); +void get_data9(void *data, size_t len, void *ctx); From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:46: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 6431D660E9B; Wed, 16 Jun 2021 11:46: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 4G4k0T20Dmz3jRC; Wed, 16 Jun 2021 11:46: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 280401B0EC; Wed, 16 Jun 2021 11:46: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 15GBk1o6035376; Wed, 16 Jun 2021 11:46:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBk1F2035375; Wed, 16 Jun 2021 11:46:01 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:46:01 GMT Message-Id: <202106161146.15GBk1F2035375@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: da49f6099185 - stable/12 - tests/netgraph: Tests for ng_bridge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: da49f60991854f2c0e6fac56a574fad0447ae844 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, 16 Jun 2021 11:46:01 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=da49f60991854f2c0e6fac56a574fad0447ae844 commit da49f60991854f2c0e6fac56a574fad0447ae844 Author: Lutz Donnerhacke AuthorDate: 2021-06-04 10:59:00 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:44:15 +0000 tests/netgraph: Tests for ng_bridge Test functionality of ng_bridge(4): - replicating traffic to anything but the sending hook - persistence - detect loops - unicast to only one link of many - stretch to implementation limits on broadcast Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30647 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 61814702398ce29430b2bef75cbdd6fd2c07ad12) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/bridge.c | 632 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 634 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index a28cae2f2432..7ec036139850 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -6,8 +6,10 @@ TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} ATF_TESTS_C+= basic \ + bridge \ SRCS.basic= basic.c util.c +SRCS.bridge= bridge.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/bridge.c b/tests/sys/netgraph/bridge.c new file mode 100644 index 000000000000..3e3c0f804278 --- /dev/null +++ b/tests/sys/netgraph/bridge.c @@ -0,0 +1,632 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include +#include +#include +#include + +#include "util.h" +#include + +static void get_tablesize(char const *source, struct ng_mesg *msg, void *ctx); +struct gettable +{ + u_int32_t tok; + int cnt; +}; + +struct frame4 +{ + struct ether_header eh; + struct ip ip; + char data[64]; +}; +struct frame6 +{ + struct ether_header eh; + struct ip6_hdr ip; + char data[64]; +}; + +static struct frame4 msg4 = { + .ip.ip_v = 4, + .ip.ip_hl = 5, + .ip.ip_ttl = 1, + .ip.ip_p = 254, + .ip.ip_src = {htonl(0x0a00dead)}, + .ip.ip_dst = {htonl(0x0a00beef)}, + .ip.ip_len = 32, + .eh.ether_type = ETHERTYPE_IP, + .eh.ether_shost = {2, 4, 6}, + .eh.ether_dhost = {2, 4, 6}, +}; + + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_connect(".", "b", "bridge:", "link1"); + ng_connect(".", "c", "bridge:", "link2"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + ng_send_data("b", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + ng_send_data("c", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 1 && r[2] == 0); + + /* send to learned unicast */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 3; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 3); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + + ng_send_msg("bridge:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("bridge:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge1"); + ng_mkpeer(".", "b", "bridge", "link1"); + ng_name("b", "bridge2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + + /*- + * Open loop + * + * /-- bridge1 + * . < | + * \-- bridge2 + */ + ng_connect("bridge1:", "link11", "bridge2:", "link11"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- bridge1 -\ + * . < | | + * \-- bridge2 -/ + */ + ng_connect("bridge1:", "link12", "bridge2:", "link12"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_errors(PASS); + ng_send_data("a", &msg4, sizeof(msg4)); + ATF_CHECK_ERRNO(ELOOP, errno != 0); /* loop might be detected */ + ng_errors(FAIL); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, &r)) + break; + ATF_CHECK(r[0] == 0 && r[1] == 1); + + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); +} + +ATF_TC(many_unicasts); +ATF_TC_HEAD(many_unicasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_unicasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use learned MAC as destination */ + msg4.eh.ether_shost[3] = 0; + msg4.eh.ether_dhost[3] = 0xff; + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data2); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] == HOOKS && r[2] == 0); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.cnt = 0; + ng_errors(PASS); + rm.tok = ng_send_msg("bridge:", "gettable"); + ng_errors(FAIL); + if (rm.tok == (u_int32_t)-1) + { + ATF_CHECK_ERRNO(ENOBUFS, 1); + atf_tc_expect_fail("response too large"); + } + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == HOOKS + 1); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(many_broadcasts); +ATF_TC_HEAD(many_broadcasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_broadcasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use broadcast MAC */ + msg4.eh.ether_shost[3] = 0; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data3); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] > 100 && r[3] > 100); + if (i < HOOKS) + atf_tc_expect_fail("netgraph queue full (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_private); +ATF_TC_HEAD(uplink_private, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_private, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "u1", "bridge", "uplink1"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("u1", "bridge"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l0", "bridge:", "link0"); + ng_register_data("l0", get_data0); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_classic); +ATF_TC_HEAD(uplink_classic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_classic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "l0", "bridge", "link0"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("l0", "bridge"); + ng_register_data("l0", get_data0); + ng_connect(".", "u1", "bridge:", "uplink1"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TP_ADD_TCS(bridge) +{ + ATF_TP_ADD_TC(bridge, basic); + ATF_TP_ADD_TC(bridge, loop); + ATF_TP_ADD_TC(bridge, persistence); + ATF_TP_ADD_TC(bridge, many_unicasts); + ATF_TP_ADD_TC(bridge, many_broadcasts); + ATF_TP_ADD_TC(bridge, uplink_private); + ATF_TP_ADD_TC(bridge, uplink_classic); + + return atf_no_error(); +} + +static void +get_tablesize(char const *source, struct ng_mesg *msg, void *ctx) +{ + struct gettable *rm = ctx; + struct ng_bridge_host_ary *gt = (void *)msg->data; + + fprintf(stderr, "Response from %s to query %d\n", source, msg->header.token); + if (rm->tok == msg->header.token) + rm->cnt = gt->numHosts; +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:46: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 BA6DE660A61; Wed, 16 Jun 2021 11:46: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 4G4k0W3w3tz3jLn; Wed, 16 Jun 2021 11:46: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 63B191AE73; Wed, 16 Jun 2021 11:46: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 15GBk3ep035433; Wed, 16 Jun 2021 11:46:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBk3kr035432; Wed, 16 Jun 2021 11:46:03 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:46:03 GMT Message-Id: <202106161146.15GBk3kr035432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 617e33a19aaf - stable/12 - tests/netgraph: Tests for ng_vlan_rotate MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 617e33a19aaf88956be722f286d590f5d4c4683a 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, 16 Jun 2021 11:46:03 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=617e33a19aaf88956be722f286d590f5d4c4683a commit 617e33a19aaf88956be722f286d590f5d4c4683a Author: Lutz Donnerhacke AuthorDate: 2021-06-06 23:56:12 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:44:15 +0000 tests/netgraph: Tests for ng_vlan_rotate Test functionality of ng_vlan_rotate(4): - Rotate 1 to 9 stagged vlans in any possible direction and length - Rotate random combinations of ethertypes (8100, 88a8, 9100) - Automatic reverse rotating for backward data flow - Test too many and too few vlans Reviewed by: kp (earlier version) Differential Revision: https://reviews.freebsd.org/D30670 (cherry picked from commit 6b08e68be111d50931b0d30145f8b7e3402decaf) --- tests/sys/netgraph/Makefile | 8 +- tests/sys/netgraph/vlan_rotate.c | 335 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+), 3 deletions(-) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 9c5faedbc8e1..adc5a898dc02 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -5,13 +5,15 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} -ATF_TESTS_C+= basic \ - bridge \ - hub \ +ATF_TESTS_C+= basic \ + bridge \ + hub \ + vlan_rotate \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c SRCS.hub= hub.c util.c +SRCS.vlan_rotate=vlan_rotate.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/vlan_rotate.c b/tests/sys/netgraph/vlan_rotate.c new file mode 100644 index 000000000000..8df3ab981a7c --- /dev/null +++ b/tests/sys/netgraph/vlan_rotate.c @@ -0,0 +1,335 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" +#include + +struct vlan +{ + uint16_t proto; + uint16_t tag; +} __packed; + +struct frame +{ + u_char dst[ETHER_ADDR_LEN]; + u_char src[ETHER_ADDR_LEN]; + struct vlan vlan[10]; +} __packed; + +static struct frame msg = { + .src = {2, 4, 6, 1, 3, 5}, + .dst = {2, 4, 6, 1, 3, 7}, + .vlan[0] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(1, 0, 0))}, + .vlan[1] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(2, 0, 0))}, + .vlan[2] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(3, 0, 0))}, + .vlan[3] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(4, 0, 0))}, + .vlan[4] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(5, 0, 0))}, + .vlan[5] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(6, 0, 0))}, + .vlan[6] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(7, 0, 0))}, + .vlan[7] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(8, 0, 0))}, + .vlan[8] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(9, 0, 0))}, + .vlan[9] = {0} +}; + +static void _basic(int); +static void get_vlan(void *data, size_t len, void *ctx); + +static void +get_vlan(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = EVL_VLANOFTAG(ntohs(f->vlan[i].tag)); +} + +static void +_basic(int direction) +{ + int r[10]; + int i, rot, len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_vlan); + + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + for (rot = -len + 1; rot < len; rot++) + { + char cmd[40]; + + /* set rotation offset */ + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len + 1; + int vlan = r[i]; + + ATF_CHECK_MSG(vlan == expect, + "len=%d rot=%d i=%d -> vlan=%d, expect=%d", + len, rot, i, r[i], expect); + } + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + _basic(1); +} + +ATF_TC(reverse); +ATF_TC_HEAD(reverse, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(reverse, dummy) +{ + _basic(-1); +} + +static void _ethertype(int); +static void get_ethertype(void *data, size_t len, void *ctx); + +static void +get_ethertype(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = ntohs(f->vlan[i].proto); +} + +static void +_ethertype(int direction) +{ + int r[10]; + int i, rounds = 20; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_ethertype); + + while (rounds-- > 0) + { + char cmd[40]; + int len = 9; + int rot = rand() % (2 * len - 1) - len + 1; + int vlan[10]; + + for (i = 0; i < len; i++) + { + switch (rand() % 3) + { + default: + msg.vlan[i].proto = htons(ETHERTYPE_VLAN); + break; + case 1: + msg.vlan[i].proto = htons(ETHERTYPE_QINQ); + break; + case 2: + msg.vlan[i].proto = htons(ETHERTYPE_8021Q9100); + break; + } + } + msg.vlan[i].proto = htons(ETHERTYPE_IP); + + for (i = 0; i < len; i++) + vlan[i] = msg.vlan[i].proto; + + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + bzero(r, sizeof(r)); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len; + + ATF_CHECK_MSG(r[i] == ntohs(vlan[expect]), + "len=%d rot=%d i=%d -> vlan=%04x, expect(%d)=%04x", + len, rot, i, ntohs(r[i]), expect, vlan[expect]); + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(ethertype); +ATF_TC_HEAD(ethertype, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(ethertype, dummy) +{ + _ethertype(1); +} + +ATF_TC(typeether); +ATF_TC_HEAD(typeether, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(typeether, dummy) +{ + _ethertype(-1); +} + +ATF_TC(minmax); +ATF_TC_HEAD(minmax, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(minmax, dummy) +{ + ng_counter_t r; + int len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", "original"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", "ordered"); + ng_connect(".", "c", "vr:", "excessive"); + ng_connect(".", "d", "vr:", "incomplete"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_register_data("d", get_data3); + + ng_send_msg("vr:", "setconf { min=3 max=7 rot=0 }"); + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + ng_counter_clear(r); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("b", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("c", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("d", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + } + + ng_shutdown("vr:"); +} + +ATF_TP_ADD_TCS(vlan_rotate) +{ + /* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */ + srand(0xb93b); + + ATF_TP_ADD_TC(vlan_rotate, basic); + ATF_TP_ADD_TC(vlan_rotate, ethertype); + ATF_TP_ADD_TC(vlan_rotate, reverse); + ATF_TP_ADD_TC(vlan_rotate, typeether); + ATF_TP_ADD_TC(vlan_rotate, minmax); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:46:02 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 773F6660E9C; Wed, 16 Jun 2021 11:46:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4k0V2jRLz3j7q; Wed, 16 Jun 2021 11:46: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 3AB811B29A; Wed, 16 Jun 2021 11:46: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 15GBk2io035409; Wed, 16 Jun 2021 11:46:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GBk2Vk035408; Wed, 16 Jun 2021 11:46:02 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:46:02 GMT Message-Id: <202106161146.15GBk2Vk035408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 1818c5a49a99 - stable/12 - tests/netgraph: Tests for ng_hub MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 1818c5a49a99da36ade0fe5e347c5b389dc90a00 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, 16 Jun 2021 11:46:02 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=1818c5a49a99da36ade0fe5e347c5b389dc90a00 commit 1818c5a49a99da36ade0fe5e347c5b389dc90a00 Author: Lutz Donnerhacke AuthorDate: 2021-06-03 22:22:29 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:44:15 +0000 tests/netgraph: Tests for ng_hub Test functionality of ng_hub(4): - replicting traffic to anything but the sending hook - persistence - an unrestricted loop - implementation limits with many hooks. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30633 (cherry picked from commit 7863faa78ae271017c404c635b2a9d07379d4316) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/hub.c | 231 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 7ec036139850..9c5faedbc8e1 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -7,9 +7,11 @@ BINDIR= ${TESTSDIR} ATF_TESTS_C+= basic \ bridge \ + hub \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c +SRCS.hub= hub.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/hub.c b/tests/sys/netgraph/hub.c new file mode 100644 index 000000000000..08d083ad9605 --- /dev/null +++ b/tests/sys/netgraph/hub.c @@ -0,0 +1,231 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + ng_connect(".", "b", "hub:", "b"); + ng_connect(".", "c", "hub:", "c"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data0); + ng_register_data("c", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("b", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("c", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + ng_shutdown("hub:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_send_msg("hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("hub:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "LOOP Alert!"; + + ng_errors(PASS); + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub1"); + ng_mkpeer(".", "b", "hub", "b"); + ng_name("b", "hub2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data0); + + /*- + * Open loop + * + * /-- hub1 + * . < | + * \-- hub2 + */ + ng_connect("hub1:", "xc1", "hub2:", "xc1"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- hub1 -\ + * . < | | + * \-- hub2 -/ + */ + ng_connect("hub1:", "xc2", "hub2:", "xc2"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, r)) + break; + ATF_CHECK(r[0] > 7); + + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); +} + +ATF_TC(many_hooks); +ATF_TC_HEAD(many_hooks, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_hooks, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int HOOKS = 1000; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_register_data("a", get_data0); + ng_counter_clear(r); + for (i = 0; i < HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "hook%d", i); + ng_connect(".", hook, "hub:", hook); + ng_errors(PASS); + ng_send_data(hook, msg, sizeof(msg)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, r); + } + ATF_CHECK(r[0] > 100); + atf_tc_expect_fail("Implementation limitation (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("hub:"); +} + + +ATF_TP_ADD_TCS(hub) +{ + ATF_TP_ADD_TC(hub, basic); + ATF_TP_ADD_TC(hub, loop); + ATF_TP_ADD_TC(hub, persistence); + ATF_TP_ADD_TC(hub, many_hooks); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11: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 4E176660EF1; Wed, 16 Jun 2021 11: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 4G4k4S1nQxz3kHS; Wed, 16 Jun 2021 11: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 25EBE1B38E; Wed, 16 Jun 2021 11: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 15GBnSnq035972; Wed, 16 Jun 2021 11: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 15GBnSR3035971; Wed, 16 Jun 2021 11:49:28 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:49:28 GMT Message-Id: <202106161149.15GBnSR3035971@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: abeb0d0c29ba - stable/11 - tests/netgraph: Prebuild tests directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: abeb0d0c29ba28f3f502931adfa8d98758ff116e 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, 16 Jun 2021 11:49:28 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=abeb0d0c29ba28f3f502931adfa8d98758ff116e commit abeb0d0c29ba28f3f502931adfa8d98758ff116e Author: Lutz Donnerhacke AuthorDate: 2021-06-16 11:37:51 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:48:21 +0000 tests/netgraph: Prebuild tests directory (partially cherry picked from commit e8db04c38959c882fe17e7c2b26fbabe74f26311) --- tests/sys/Makefile | 1 + tests/sys/netgraph/Makefile | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/tests/sys/Makefile b/tests/sys/Makefile index 5e0c3aba7ed3..bf0d15fa8253 100644 --- a/tests/sys/Makefile +++ b/tests/sys/Makefile @@ -15,6 +15,7 @@ TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= kqueue TESTS_SUBDIRS+= mac TESTS_SUBDIRS+= mqueue +TESTS_SUBDIRS+= netgraph TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= netmap TESTS_SUBDIRS+= opencrypto diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile new file mode 100644 index 000000000000..e6a9d6fbf338 --- /dev/null +++ b/tests/sys/netgraph/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/netgraph +BINDIR= ${TESTSDIR} + +.include From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11: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 61FA8660BDD; Wed, 16 Jun 2021 11: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 4G4k4T2G2Xz3kN9; Wed, 16 Jun 2021 11: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 358BC1B0EF; Wed, 16 Jun 2021 11: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 15GBnTnB035998; Wed, 16 Jun 2021 11: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 15GBnTKM035997; Wed, 16 Jun 2021 11:49:29 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:49:29 GMT Message-Id: <202106161149.15GBnTKM035997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 4a0c1d0543af - stable/11 - tests/netgraph: Inital framework for testing libnetgraph MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 4a0c1d0543afd83156b50b3f9b74c79e74cf526f 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, 16 Jun 2021 11:49:29 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=4a0c1d0543afd83156b50b3f9b74c79e74cf526f commit 4a0c1d0543afd83156b50b3f9b74c79e74cf526f Author: Lutz Donnerhacke AuthorDate: 2021-06-02 22:29:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:48:22 +0000 tests/netgraph: Inital framework for testing libnetgraph Provide a framework of functions to test various netgraph modules. Tests contain: - creating, renaming, and destroying nodes - connecting and removing hooks - sending and receiving data - sending ASCII messages and receiving binary responses - errors can be passed for indiviual inspection or fail the test Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30629 Differential Revision: https://reviews.freebsd.org/D30657 Differential Revision: https://reviews.freebsd.org/D30671 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 24ea1dbf257aa6757f469bcd859f90e9ad851e59) (cherry picked from commit 09307dbfb888a98232096c751a96ecb3344aa77c) (cherry picked from commit 9021c46603bf29b9700f24b8dce8796b434d7c8f) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) Also contains some fixups: - indent all files correctly - finish factoring out - remove debugging code - check for renaming issues reported in PR241954 PR: 241954 Differential Revision: https://reviews.freebsd.org/D30692 Differential Revision: https://reviews.freebsd.org/D30714 Differential Revision: https://reviews.freebsd.org/D30713 (cherry picked from commit a664ade93972ce617f0888ff79e715dff9cf0f87) (cherry picked from commit 0afa9be03937d60cb5aeba64c81e3e2165bd3737) (cherry picked from commit 43e4821315c31db067e23564b9bfafb519e77b2b) --- tests/sys/netgraph/Makefile | 6 + tests/sys/netgraph/basic.c | 191 ++++++++++++++++++++++++++++++ tests/sys/netgraph/util.c | 277 ++++++++++++++++++++++++++++++++++++++++++++ tests/sys/netgraph/util.h | 114 ++++++++++++++++++ 4 files changed, 588 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index e6a9d6fbf338..a28cae2f2432 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -5,4 +5,10 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} +ATF_TESTS_C+= basic \ + +SRCS.basic= basic.c util.c + +LIBADD+= netgraph + .include diff --git a/tests/sys/netgraph/basic.c b/tests/sys/netgraph/basic.c new file mode 100644 index 000000000000..573422add694 --- /dev/null +++ b/tests/sys/netgraph/basic.c @@ -0,0 +1,191 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(send_recv); +ATF_TC_HEAD(send_recv, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(send_recv, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + ng_send_data("a", msg, sizeof(msg)); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1); +} + +ATF_TC(node); +ATF_TC_HEAD(node, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(node, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_errors(PASS); + ng_name("a", "test hub"); + ng_errors(FAIL); + if (errno == EADDRINUSE) + atf_tc_expect_fail("PR241954"); + ATF_CHECK_ERRNO(0, 1); + atf_tc_expect_pass(); + + ng_connect(".", "b", "test hub:", "b"); + ng_connect(".", "c", "test hub:", "c"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + ng_shutdown("test hub:"); +} + +ATF_TC(message); +ATF_TC_HEAD(message, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(message, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test hub"); + + ng_send_msg("test hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("test hub:"); +} + +ATF_TC(same_name); +ATF_TC_HEAD(same_name, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(same_name, dummy) +{ + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "test"); + + ng_errors(PASS); + ng_connect(".", "a", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_connect(".", "b", ".", "b"); + ATF_CHECK_ERRNO(EEXIST, 1); + ng_name(".", "test"); + ATF_CHECK_ERRNO(EADDRINUSE, 1); + + ng_errors(FAIL); + ng_shutdown("test:"); +} + +ATF_TC(queuelimit); +ATF_TC_HEAD(queuelimit, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(queuelimit, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int MAX = 1000; + + ng_init(); + ng_connect(".", "a", ".", "b"); + ng_register_data("b", get_data0); + + ng_errors(PASS); + for (i = 0; i < MAX; i++) + { + ng_send_data("a", msg, sizeof(msg)); + if (errno != 0) + break; + /* no ng_handle_events -> messages stall */ + } + ng_errors(FAIL); + + ng_counter_clear(r); + ng_handle_events(50, &r); + ATF_CHECK(r[0] > 100); + ATF_CHECK(r[0] == i); + atf_tc_expect_fail("Queue full (%d)", i); + ATF_CHECK(r[0] == MAX); + atf_tc_expect_pass(); +} + +ATF_TP_ADD_TCS(basic) +{ + ATF_TP_ADD_TC(basic, send_recv); + ATF_TP_ADD_TC(basic, node); + ATF_TP_ADD_TC(basic, message); + ATF_TP_ADD_TC(basic, same_name); + ATF_TP_ADD_TC(basic, queuelimit); + + return atf_no_error(); +} diff --git a/tests/sys/netgraph/util.c b/tests/sys/netgraph/util.c new file mode 100644 index 000000000000..b25e63dfa76d --- /dev/null +++ b/tests/sys/netgraph/util.c @@ -0,0 +1,277 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" + + +static int cs = -1, ds = -1; +static ng_error_t error_handling = FAIL; + +#define CHECK(r, x) do { \ + if (!(x)) { \ + if (error_handling == PASS) \ + return r; \ + atf_tc_fail_requirement(file, line, "%s (%s)", \ + #x " not met", strerror(errno));\ + } \ +} while(0) + +struct data_handler +{ + char const *hook; + ng_data_handler_t handler; + SLIST_ENTRY(data_handler) next; +}; +static SLIST_HEAD(, data_handler) data_head = SLIST_HEAD_INITIALIZER(data_head); +static ng_msg_handler_t msg_handler = NULL; + +static void handle_data(void *ctx); +static void handle_msg(void *ctx); + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line) +{ + struct ngm_connect c; + + strncpy(c.ourhook, hook1, sizeof(c.ourhook)); + strncpy(c.peerhook, hook2, sizeof(c.peerhook)); + strncpy(c.path, path2, sizeof(c.path)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_CONNECT, + &c, sizeof(c))); +} + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line) +{ + struct ngm_mkpeer p; + + strncpy(p.ourhook, hook1, sizeof(p.ourhook)); + strncpy(p.peerhook, hook2, sizeof(p.peerhook)); + strncpy(p.type, type, sizeof(p.type)); + + CHECK(, -1 != NgSendMsg(cs, path1, + NGM_GENERIC_COOKIE, NGM_MKPEER, + &p, sizeof(p))); +} + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line) +{ + struct ngm_rmhook h; + + strncpy(h.ourhook, hook, sizeof(h.ourhook)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_RMHOOK, + &h, sizeof(h))); +} + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line) +{ + struct ngm_name n; + + strncpy(n.name, name, sizeof(n.name)); + + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_NAME, + &n, sizeof(n))); +} + +void +_ng_shutdown(char const *path, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendMsg(cs, path, + NGM_GENERIC_COOKIE, NGM_SHUTDOWN, + NULL, 0)); +} + +void +ng_register_data(char const *hook, ng_data_handler_t proc) +{ + struct data_handler *p; + + ATF_REQUIRE(NULL != (p = calloc(1, sizeof(struct data_handler)))); + ATF_REQUIRE(NULL != (p->hook = strdup(hook))); + ATF_REQUIRE(NULL != (p->handler = proc)); + SLIST_INSERT_HEAD(&data_head, p, next); +} + +void +_ng_send_data(char const *hook, + void const *data, size_t len, + char const *file, size_t line) +{ + CHECK(, -1 != NgSendData(ds, hook, data, len)); +} + +void +ng_register_msg(ng_msg_handler_t proc) +{ + msg_handler = proc; +} + +static void +handle_msg(void *ctx) +{ + struct ng_mesg *m; + char path[NG_PATHSIZ]; + + ATF_REQUIRE(-1 != NgAllocRecvMsg(cs, &m, path)); + + if (msg_handler != NULL) + (*msg_handler) (path, m, ctx); + + free(m); +} + +static void +handle_data(void *ctx) +{ + char hook[NG_HOOKSIZ]; + struct data_handler *hnd; + u_char *data; + int len; + + ATF_REQUIRE(0 < (len = NgAllocRecvData(ds, &data, hook))); + SLIST_FOREACH(hnd, &data_head, next) + { + if (0 == strcmp(hnd->hook, hook)) + break; + } + + if (hnd != NULL) + (*(hnd->handler)) (data, len, ctx); + + free(data); +} + +int +ng_handle_event(unsigned int ms, void *context) +{ + fd_set fds; + int maxfd = (ds < cs) ? cs : ds; + struct timeval timeout = {0, ms * 1000lu}; + + FD_ZERO(&fds); + FD_SET(cs, &fds); + FD_SET(ds, &fds); +retry: + switch (select(maxfd + 1, &fds, NULL, NULL, &timeout)) + { + case -1: + ATF_REQUIRE_ERRNO(EINTR, 1); + goto retry; + case 0: /* timeout */ + return 0; + default: /* something to do */ + if (FD_ISSET(cs, &fds)) + handle_msg(context); + if (FD_ISSET(ds, &fds)) + handle_data(context); + return 1; + } +} + +void +ng_handle_events(unsigned int ms, void *context) +{ + while (ng_handle_event(ms, context)) + ; +} + +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line) +{ + int res; + + CHECK(-1, -1 != (res = NgSendAsciiMsg(cs, path, "%s", msg))); + return (res); +} + +ng_error_t +ng_errors(ng_error_t n) +{ + ng_error_t o = error_handling; + + error_handling = n; + return (o); +} + +void +_ng_init(char const *file, size_t line) +{ + if (cs >= 0) /* prevent reinit */ + return; + + CHECK(, 0 == NgMkSockNode(NULL, &cs, &ds)); + NgSetDebug(3); +} + +#define GD(x) void \ +get_data##x(void *data, size_t len, void *ctx) {\ + int *cnt = ctx; \ + \ + (void)data; \ + (void)len; \ + cnt[x]++; \ +} + +GD(0) +GD(1) +GD(2) +GD(3) +GD(4) +GD(5) +GD(6) +GD(7) +GD(8) +GD(9) diff --git a/tests/sys/netgraph/util.h b/tests/sys/netgraph/util.h new file mode 100644 index 000000000000..44c9f3a360a7 --- /dev/null +++ b/tests/sys/netgraph/util.h @@ -0,0 +1,114 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#include + +void +_ng_connect(char const *path1, char const *hook1, + char const *path2, char const *hook2, + char const *file, size_t line); +#define ng_connect(p1,h1,p2,h2) \ + _ng_connect(p1,h1,p2,h2,__FILE__,__LINE__) + +void +_ng_mkpeer(char const *path1, char const *hook1, + char const *type, char const *hook2, + char const *file, size_t line); +#define ng_mkpeer(p1,h1,t,h2) \ + _ng_mkpeer(p1,h1,t,h2,__FILE__,__LINE__) + +void +_ng_shutdown(char const *path, + char const *file, size_t line); +#define ng_shutdown(p) \ + _ng_shutdown(p,__FILE__,__LINE__) + +void +_ng_rmhook(char const *path, char const *hook, + char const *file, size_t line); +#define ng_rmhook(p,h) \ + _ng_rmhook(p,h,__FILE__,__LINE__) + +void +_ng_name(char const *path, char const *name, + char const *file, size_t line); +#define ng_name(p,n) \ + _ng_name(p,n,__FILE__,__LINE__) + + +typedef void (*ng_data_handler_t)(void *, size_t, void *ctx); +void ng_register_data(char const *hook, ng_data_handler_t proc); +void +_ng_send_data(char const *hook, void const *, size_t, + char const *file, size_t line); +#define ng_send_data(h,d,l) \ + _ng_send_data(h,d,l,__FILE__,__LINE__) + +typedef void (*ng_msg_handler_t)(char const *, struct ng_mesg *, void *); +void ng_register_msg(ng_msg_handler_t proc); +int +_ng_send_msg(char const *path, char const *msg, + char const *file, size_t line); +#define ng_send_msg(p,m) \ + _ng_send_msg(p,m,__FILE__,__LINE__) + +int ng_handle_event(unsigned int ms, void *ctx); +void ng_handle_events(unsigned int ms, void *ctx); + +typedef enum +{ + FAIL, PASS +} ng_error_t; +ng_error_t ng_errors(ng_error_t); + +void _ng_init(char const *file, size_t line); +#define ng_init() \ + _ng_init(__FILE__,__LINE__) + +/* Helper function to count received data */ + +typedef int ng_counter_t[10]; +#define ng_counter_clear(x)\ + bzero((x), sizeof(x)) + +void get_data0(void *data, size_t len, void *ctx); +void get_data1(void *data, size_t len, void *ctx); +void get_data2(void *data, size_t len, void *ctx); +void get_data3(void *data, size_t len, void *ctx); +void get_data4(void *data, size_t len, void *ctx); +void get_data5(void *data, size_t len, void *ctx); +void get_data6(void *data, size_t len, void *ctx); +void get_data7(void *data, size_t len, void *ctx); +void get_data8(void *data, size_t len, void *ctx); +void get_data9(void *data, size_t len, void *ctx); From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:49: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 239A0661138; Wed, 16 Jun 2021 11: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 4G4k4V3zH3z3kF0; Wed, 16 Jun 2021 11: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 5FFD21B242; Wed, 16 Jun 2021 11: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 15GBnUFY036024; Wed, 16 Jun 2021 11: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 15GBnUbn036023; Wed, 16 Jun 2021 11:49:30 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:49:30 GMT Message-Id: <202106161149.15GBnUbn036023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 49736a31a5c2 - stable/11 - tests/netgraph: Tests for ng_bridge MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 49736a31a5c29319c6dc8f9080b3a85da2305b47 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, 16 Jun 2021 11:49:31 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=49736a31a5c29319c6dc8f9080b3a85da2305b47 commit 49736a31a5c29319c6dc8f9080b3a85da2305b47 Author: Lutz Donnerhacke AuthorDate: 2021-06-04 10:59:00 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:48:24 +0000 tests/netgraph: Tests for ng_bridge Test functionality of ng_bridge(4): - replicating traffic to anything but the sending hook - persistence - detect loops - unicast to only one link of many - stretch to implementation limits on broadcast Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30647 Differential Revision: https://reviews.freebsd.org/D30699 (cherry picked from commit 61814702398ce29430b2bef75cbdd6fd2c07ad12) (cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/bridge.c | 632 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 634 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index a28cae2f2432..7ec036139850 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -6,8 +6,10 @@ TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} ATF_TESTS_C+= basic \ + bridge \ SRCS.basic= basic.c util.c +SRCS.bridge= bridge.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/bridge.c b/tests/sys/netgraph/bridge.c new file mode 100644 index 000000000000..3e3c0f804278 --- /dev/null +++ b/tests/sys/netgraph/bridge.c @@ -0,0 +1,632 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include +#include +#include +#include + +#include "util.h" +#include + +static void get_tablesize(char const *source, struct ng_mesg *msg, void *ctx); +struct gettable +{ + u_int32_t tok; + int cnt; +}; + +struct frame4 +{ + struct ether_header eh; + struct ip ip; + char data[64]; +}; +struct frame6 +{ + struct ether_header eh; + struct ip6_hdr ip; + char data[64]; +}; + +static struct frame4 msg4 = { + .ip.ip_v = 4, + .ip.ip_hl = 5, + .ip.ip_ttl = 1, + .ip.ip_p = 254, + .ip.ip_src = {htonl(0x0a00dead)}, + .ip.ip_dst = {htonl(0x0a00beef)}, + .ip.ip_len = 32, + .eh.ether_type = ETHERTYPE_IP, + .eh.ether_shost = {2, 4, 6}, + .eh.ether_dhost = {2, 4, 6}, +}; + + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_connect(".", "b", "bridge:", "link1"); + ng_connect(".", "c", "bridge:", "link2"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + ng_send_data("b", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + ng_send_data("c", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 1 && r[2] == 0); + + /* send to learned unicast */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 3; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 3); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + + ng_send_msg("bridge:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("bridge:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge1"); + ng_mkpeer(".", "b", "bridge", "link1"); + ng_name("b", "bridge2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + + /*- + * Open loop + * + * /-- bridge1 + * . < | + * \-- bridge2 + */ + ng_connect("bridge1:", "link11", "bridge2:", "link11"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- bridge1 -\ + * . < | | + * \-- bridge2 -/ + */ + ng_connect("bridge1:", "link12", "bridge2:", "link12"); + + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_errors(PASS); + ng_send_data("a", &msg4, sizeof(msg4)); + ATF_CHECK_ERRNO(ELOOP, errno != 0); /* loop might be detected */ + ng_errors(FAIL); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, &r)) + break; + ATF_CHECK(r[0] == 0 && r[1] == 1); + + ng_shutdown("bridge1:"); + ng_shutdown("bridge2:"); +} + +ATF_TC(many_unicasts); +ATF_TC_HEAD(many_unicasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_unicasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use learned MAC as destination */ + msg4.eh.ether_shost[3] = 0; + msg4.eh.ether_dhost[3] = 0xff; + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data2); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] == HOOKS && r[2] == 0); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.cnt = 0; + ng_errors(PASS); + rm.tok = ng_send_msg("bridge:", "gettable"); + ng_errors(FAIL); + if (rm.tok == (u_int32_t)-1) + { + ATF_CHECK_ERRNO(ENOBUFS, 1); + atf_tc_expect_fail("response too large"); + } + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == HOOKS + 1); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(many_broadcasts); +ATF_TC_HEAD(many_broadcasts, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_broadcasts, dummy) +{ + ng_counter_t r; + int i; + const int HOOKS = 1000; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "bridge", "link0"); + ng_name("a", "bridge"); + ng_register_data("a", get_data0); + + /* learn MAC */ + ng_counter_clear(r); + msg4.eh.ether_shost[3] = 0xff; + ng_send_data("a", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0); + + /* use broadcast MAC */ + msg4.eh.ether_shost[3] = 0; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + + /* now send */ + ng_counter_clear(r); + for (i = 1; i <= HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "link%d", i); + ng_connect(".", hook, "bridge:", hook); + ng_register_data(hook, get_data3); + + msg4.eh.ether_shost[4] = i >> 8; + msg4.eh.ether_shost[5] = i & 0xff; + ng_errors(PASS); + ng_send_data(hook, &msg4, sizeof(msg4)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, &r); + } + ATF_CHECK(r[0] > 100 && r[3] > 100); + if (i < HOOKS) + atf_tc_expect_fail("netgraph queue full (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_private); +ATF_TC_HEAD(uplink_private, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_private, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "u1", "bridge", "uplink1"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("u1", "bridge"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l0", "bridge:", "link0"); + ng_register_data("l0", get_data0); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 0); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TC(uplink_classic); +ATF_TC_HEAD(uplink_classic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(uplink_classic, dummy) +{ + ng_counter_t r; + struct gettable rm; + + ng_init(); + ng_errors(PASS); + ng_shutdown("bridge:"); + + ng_mkpeer(".", "l0", "bridge", "link0"); + if (errno > 0) + atf_tc_skip("uplinks are not supported."); + ng_errors(FAIL); + ng_name("l0", "bridge"); + ng_register_data("l0", get_data0); + ng_connect(".", "u1", "bridge:", "uplink1"); + ng_register_data("u1", get_data1); + ng_connect(".", "u2", "bridge:", "uplink2"); + ng_register_data("u2", get_data2); + ng_connect(".", "l3", "bridge:", "link3"); + ng_register_data("l3", get_data3); + + /* unknown unicast 0 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* known unicast 0 from uplink2 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 2; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("u2", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* known unicast 0 from link3 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 3; + msg4.eh.ether_dhost[5] = 0; + ng_send_data("l3", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + /* (un)known unicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[5] = 2; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* (un)known unicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + msg4.eh.ether_dhost[0] = 0xff; + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* unknown multicast 2 from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* broadcast from uplink1 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 1; + memset(msg4.eh.ether_dhost, 0xff, sizeof(msg4.eh.ether_dhost)); + ng_send_data("u1", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 1 && r[3] == 1); + + /* broadcast from link0 */ + ng_counter_clear(r); + msg4.eh.ether_shost[5] = 0; + ng_send_data("l0", &msg4, sizeof(msg4)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 1 && r[3] == 1); + + /* inspect mac table */ + ng_register_msg(get_tablesize); + rm.tok = ng_send_msg("bridge:", "gettable"); + rm.cnt = 0; + ng_handle_events(50, &rm); + ATF_CHECK(rm.cnt == 2); + + ng_shutdown("bridge:"); +} + +ATF_TP_ADD_TCS(bridge) +{ + ATF_TP_ADD_TC(bridge, basic); + ATF_TP_ADD_TC(bridge, loop); + ATF_TP_ADD_TC(bridge, persistence); + ATF_TP_ADD_TC(bridge, many_unicasts); + ATF_TP_ADD_TC(bridge, many_broadcasts); + ATF_TP_ADD_TC(bridge, uplink_private); + ATF_TP_ADD_TC(bridge, uplink_classic); + + return atf_no_error(); +} + +static void +get_tablesize(char const *source, struct ng_mesg *msg, void *ctx) +{ + struct gettable *rm = ctx; + struct ng_bridge_host_ary *gt = (void *)msg->data; + + fprintf(stderr, "Response from %s to query %d\n", source, msg->header.token); + if (rm->tok == msg->header.token) + rm->cnt = gt->numHosts; +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 11:49: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 B1660660F39; Wed, 16 Jun 2021 11: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 4G4k4W4922z3k6c; Wed, 16 Jun 2021 11: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 748731AE77; Wed, 16 Jun 2021 11: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 15GBnVXn036054; Wed, 16 Jun 2021 11: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 15GBnV5D036053; Wed, 16 Jun 2021 11:49:31 GMT (envelope-from git) Date: Wed, 16 Jun 2021 11:49:31 GMT Message-Id: <202106161149.15GBnV5D036053@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: d68f32b4ac35 - stable/11 - tests/netgraph: Tests for ng_hub MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: d68f32b4ac357ebd54dd1c640bb87ba92d7eb76d 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, 16 Jun 2021 11:49:31 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d68f32b4ac357ebd54dd1c640bb87ba92d7eb76d commit d68f32b4ac357ebd54dd1c640bb87ba92d7eb76d Author: Lutz Donnerhacke AuthorDate: 2021-06-03 22:22:29 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 11:48:25 +0000 tests/netgraph: Tests for ng_hub Test functionality of ng_hub(4): - replicting traffic to anything but the sending hook - persistence - an unrestricted loop - implementation limits with many hooks. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D30633 (cherry picked from commit 7863faa78ae271017c404c635b2a9d07379d4316) --- tests/sys/netgraph/Makefile | 2 + tests/sys/netgraph/hub.c | 231 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 7ec036139850..9c5faedbc8e1 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -7,9 +7,11 @@ BINDIR= ${TESTSDIR} ATF_TESTS_C+= basic \ bridge \ + hub \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c +SRCS.hub= hub.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/hub.c b/tests/sys/netgraph/hub.c new file mode 100644 index 000000000000..08d083ad9605 --- /dev/null +++ b/tests/sys/netgraph/hub.c @@ -0,0 +1,231 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include + +#include "util.h" + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + char msg[] = "test"; + ng_counter_t r; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + ng_connect(".", "b", "hub:", "b"); + ng_connect(".", "c", "hub:", "c"); + + /* do not bounce back */ + ng_register_data("a", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 0); + + /* send to others */ + ng_register_data("b", get_data0); + ng_register_data("c", get_data0); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("b", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + ng_counter_clear(r); + ng_send_data("c", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 2); + + /* remove a link */ + ng_rmhook(".", "b"); + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + ng_shutdown("hub:"); +} + +ATF_TC(persistence); +ATF_TC_HEAD(persistence, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(persistence, dummy) +{ + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_send_msg("hub:", "setpersistent"); + ng_rmhook(".", "a"); + + ng_shutdown("hub:"); +} + +ATF_TC(loop); +ATF_TC_HEAD(loop, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(loop, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "LOOP Alert!"; + + ng_errors(PASS); + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub1"); + ng_mkpeer(".", "b", "hub", "b"); + ng_name("b", "hub2"); + + ng_register_data("a", get_data0); + ng_register_data("b", get_data0); + + /*- + * Open loop + * + * /-- hub1 + * . < | + * \-- hub2 + */ + ng_connect("hub1:", "xc1", "hub2:", "xc1"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + ng_handle_events(50, r); + ATF_CHECK(r[0] == 1); + + /*- + * Closed loop, DANGEROUS! + * + * /-- hub1 -\ + * . < | | + * \-- hub2 -/ + */ + ng_connect("hub1:", "xc2", "hub2:", "xc2"); + + ng_counter_clear(r); + ng_send_data("a", msg, sizeof(msg)); + for (i = 0; i < 10; i++) /* don't run forever */ + if (!ng_handle_event(50, r)) + break; + ATF_CHECK(r[0] > 7); + + ng_shutdown("hub1:"); + ng_shutdown("hub2:"); +} + +ATF_TC(many_hooks); +ATF_TC_HEAD(many_hooks, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(many_hooks, dummy) +{ + ng_counter_t r; + int i; + char msg[] = "test"; + const int HOOKS = 1000; + + ng_errors(PASS); + ng_shutdown("hub:"); + ng_errors(FAIL); + + ng_init(); + ng_mkpeer(".", "a", "hub", "a"); + ng_name("a", "hub"); + + ng_register_data("a", get_data0); + ng_counter_clear(r); + for (i = 0; i < HOOKS; i++) + { + char hook[20]; + + snprintf(hook, sizeof(hook), "hook%d", i); + ng_connect(".", hook, "hub:", hook); + ng_errors(PASS); + ng_send_data(hook, msg, sizeof(msg)); + ng_errors(FAIL); + if (errno != 0) + break; + ng_handle_events(50, r); + } + ATF_CHECK(r[0] > 100); + atf_tc_expect_fail("Implementation limitation (%d)", i); + ATF_CHECK(r[0] == HOOKS); + atf_tc_expect_pass(); + + ng_shutdown("hub:"); +} + + +ATF_TP_ADD_TCS(hub) +{ + ATF_TP_ADD_TC(hub, basic); + ATF_TP_ADD_TC(hub, loop); + ATF_TP_ADD_TC(hub, persistence); + ATF_TP_ADD_TC(hub, many_hooks); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 12:04: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 2B83C6613CA; Wed, 16 Jun 2021 12:04: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 4G4kPk0kNvz3m5p; Wed, 16 Jun 2021 12:04: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 F0A771B171; Wed, 16 Jun 2021 12:04: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 15GC4PtF062870; Wed, 16 Jun 2021 12:04:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GC4PhM062869; Wed, 16 Jun 2021 12:04:25 GMT (envelope-from git) Date: Wed, 16 Jun 2021 12:04:25 GMT Message-Id: <202106161204.15GC4PhM062869@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 7438333663b4 - stable/11 - tests/netgraph: Tests for ng_vlan_rotate MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 7438333663b4d22f6863aeffba55d6a04149e3a2 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, 16 Jun 2021 12:04:26 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=7438333663b4d22f6863aeffba55d6a04149e3a2 commit 7438333663b4d22f6863aeffba55d6a04149e3a2 Author: Lutz Donnerhacke AuthorDate: 2021-06-06 23:56:12 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 12:04:06 +0000 tests/netgraph: Tests for ng_vlan_rotate Test functionality of ng_vlan_rotate(4): - Rotate 1 to 9 stagged vlans in any possible direction and length - Rotate random combinations of ethertypes (8100, 88a8, 9100) - Automatic reverse rotating for backward data flow - Test too many and too few vlans Reviewed by: kp (earlier version) Differential Revision: https://reviews.freebsd.org/D30670 (cherry picked from commit 6b08e68be111d50931b0d30145f8b7e3402decaf) --- tests/sys/netgraph/Makefile | 8 +- tests/sys/netgraph/vlan_rotate.c | 335 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+), 3 deletions(-) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 9c5faedbc8e1..adc5a898dc02 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -5,13 +5,15 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netgraph BINDIR= ${TESTSDIR} -ATF_TESTS_C+= basic \ - bridge \ - hub \ +ATF_TESTS_C+= basic \ + bridge \ + hub \ + vlan_rotate \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c SRCS.hub= hub.c util.c +SRCS.vlan_rotate=vlan_rotate.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/vlan_rotate.c b/tests/sys/netgraph/vlan_rotate.c new file mode 100644 index 000000000000..8df3ab981a7c --- /dev/null +++ b/tests/sys/netgraph/vlan_rotate.c @@ -0,0 +1,335 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 Lutz Donnerhacke + * + * 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. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ +#include +#include +#include +#include + +#include +#include + +#include "util.h" +#include + +struct vlan +{ + uint16_t proto; + uint16_t tag; +} __packed; + +struct frame +{ + u_char dst[ETHER_ADDR_LEN]; + u_char src[ETHER_ADDR_LEN]; + struct vlan vlan[10]; +} __packed; + +static struct frame msg = { + .src = {2, 4, 6, 1, 3, 5}, + .dst = {2, 4, 6, 1, 3, 7}, + .vlan[0] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(1, 0, 0))}, + .vlan[1] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(2, 0, 0))}, + .vlan[2] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(3, 0, 0))}, + .vlan[3] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(4, 0, 0))}, + .vlan[4] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(5, 0, 0))}, + .vlan[5] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(6, 0, 0))}, + .vlan[6] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(7, 0, 0))}, + .vlan[7] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(8, 0, 0))}, + .vlan[8] = {htons(ETHERTYPE_VLAN), htons(EVL_MAKETAG(9, 0, 0))}, + .vlan[9] = {0} +}; + +static void _basic(int); +static void get_vlan(void *data, size_t len, void *ctx); + +static void +get_vlan(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = EVL_VLANOFTAG(ntohs(f->vlan[i].tag)); +} + +static void +_basic(int direction) +{ + int r[10]; + int i, rot, len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_vlan); + + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + for (rot = -len + 1; rot < len; rot++) + { + char cmd[40]; + + /* set rotation offset */ + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len + 1; + int vlan = r[i]; + + ATF_CHECK_MSG(vlan == expect, + "len=%d rot=%d i=%d -> vlan=%d, expect=%d", + len, rot, i, r[i], expect); + } + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(basic); +ATF_TC_HEAD(basic, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(basic, dummy) +{ + _basic(1); +} + +ATF_TC(reverse); +ATF_TC_HEAD(reverse, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(reverse, dummy) +{ + _basic(-1); +} + +static void _ethertype(int); +static void get_ethertype(void *data, size_t len, void *ctx); + +static void +get_ethertype(void *data, size_t len, void *ctx) +{ + int *v = ctx, i; + struct frame *f = data; + + (void)len; + for (i = 0; i < 10; i++) + v[i] = ntohs(f->vlan[i].proto); +} + +static void +_ethertype(int direction) +{ + int r[10]; + int i, rounds = 20; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", direction > 0 ? "original" : "ordered"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", direction > 0 ? "ordered" : "original"); + ng_register_data("b", get_ethertype); + + while (rounds-- > 0) + { + char cmd[40]; + int len = 9; + int rot = rand() % (2 * len - 1) - len + 1; + int vlan[10]; + + for (i = 0; i < len; i++) + { + switch (rand() % 3) + { + default: + msg.vlan[i].proto = htons(ETHERTYPE_VLAN); + break; + case 1: + msg.vlan[i].proto = htons(ETHERTYPE_QINQ); + break; + case 2: + msg.vlan[i].proto = htons(ETHERTYPE_8021Q9100); + break; + } + } + msg.vlan[i].proto = htons(ETHERTYPE_IP); + + for (i = 0; i < len; i++) + vlan[i] = msg.vlan[i].proto; + + snprintf(cmd, sizeof(cmd), "setconf { min=0 max=9 rot=%d }", rot); + ng_send_msg("vr:", cmd); + + bzero(r, sizeof(r)); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + + /* check rotation */ + for (i = 0; i < len; i++) + { + int expect = (2 * len + i - direction * rot) % len; + + ATF_CHECK_MSG(r[i] == ntohs(vlan[expect]), + "len=%d rot=%d i=%d -> vlan=%04x, expect(%d)=%04x", + len, rot, i, ntohs(r[i]), expect, vlan[expect]); + } + } + + ng_shutdown("vr:"); +} + +ATF_TC(ethertype); +ATF_TC_HEAD(ethertype, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(ethertype, dummy) +{ + _ethertype(1); +} + +ATF_TC(typeether); +ATF_TC_HEAD(typeether, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(typeether, dummy) +{ + _ethertype(-1); +} + +ATF_TC(minmax); +ATF_TC_HEAD(minmax, conf) +{ + atf_tc_set_md_var(conf, "require.user", "root"); +} + +ATF_TC_BODY(minmax, dummy) +{ + ng_counter_t r; + int len; + + ng_init(); + ng_errors(PASS); + ng_shutdown("vr:"); + ng_errors(FAIL); + + ng_mkpeer(".", "a", "vlan_rotate", "original"); + ng_name("a", "vr"); + ng_connect(".", "b", "vr:", "ordered"); + ng_connect(".", "c", "vr:", "excessive"); + ng_connect(".", "d", "vr:", "incomplete"); + ng_register_data("a", get_data0); + ng_register_data("b", get_data1); + ng_register_data("c", get_data2); + ng_register_data("d", get_data3); + + ng_send_msg("vr:", "setconf { min=3 max=7 rot=0 }"); + for (len = 9; len > 0; len--) + { + /* reduce the number of vlans */ + msg.vlan[len].proto = htons(ETHERTYPE_IP); + + ng_counter_clear(r); + ng_send_data("a", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 0 && r[1] == 1 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("b", &msg, sizeof(msg)); + ng_handle_events(50, &r); + if (len < 3) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 1); + else if (len > 7) + ATF_CHECK(r[0] == 0 && r[1] == 0 && r[2] == 1 && r[3] == 0); + else + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("c", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + + ng_counter_clear(r); + ng_send_data("d", &msg, sizeof(msg)); + ng_handle_events(50, &r); + ATF_CHECK(r[0] == 1 && r[1] == 0 && r[2] == 0 && r[3] == 0); + } + + ng_shutdown("vr:"); +} + +ATF_TP_ADD_TCS(vlan_rotate) +{ + /* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */ + srand(0xb93b); + + ATF_TP_ADD_TC(vlan_rotate, basic); + ATF_TP_ADD_TC(vlan_rotate, ethertype); + ATF_TP_ADD_TC(vlan_rotate, reverse); + ATF_TP_ADD_TC(vlan_rotate, typeether); + ATF_TP_ADD_TC(vlan_rotate, minmax); + + return atf_no_error(); +} From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 14:04: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 A4AA26634D3; Wed, 16 Jun 2021 14:04: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 4G4n4910r3z3w92; Wed, 16 Jun 2021 14:04: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 DFC021CDBC; Wed, 16 Jun 2021 14:04: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 15GE4OI6022057; Wed, 16 Jun 2021 14:04:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GE4Oa2022056; Wed, 16 Jun 2021 14:04:24 GMT (envelope-from git) Date: Wed, 16 Jun 2021 14:04:24 GMT Message-Id: <202106161404.15GE4Oa2022056@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: 85a55e0c5eb0 - stable/13 - vmm: Let guests enable SMEP/SMAP if the host supports it 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: 85a55e0c5eb0c3ad6b3ce27c3f4b5e47bf446320 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, 16 Jun 2021 14:04:25 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=85a55e0c5eb0c3ad6b3ce27c3f4b5e47bf446320 commit 85a55e0c5eb0c3ad6b3ce27c3f4b5e47bf446320 Author: Mark Johnston AuthorDate: 2021-05-26 13:34:52 +0000 Commit: Mark Johnston CommitDate: 2021-06-16 14:03:12 +0000 vmm: Let guests enable SMEP/SMAP if the host supports it Reviewed by: kib, grehan, jhb Tested by: grehan (AMD) Sponsored by: The FreeBSD Foundation (cherry picked from commit 4c599db71af56c28bb0388e73bd0570a3873c0ec) --- sys/amd64/vmm/x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c index a4a9c8203fc5..c43a3c870211 100644 --- a/sys/amd64/vmm/x86.c +++ b/sys/amd64/vmm/x86.c @@ -441,10 +441,12 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id, uint64_t *rax, uint64_t *rbx, */ regs[1] &= (CPUID_STDEXT_FSGSBASE | CPUID_STDEXT_BMI1 | CPUID_STDEXT_HLE | - CPUID_STDEXT_AVX2 | CPUID_STDEXT_BMI2 | + CPUID_STDEXT_AVX2 | CPUID_STDEXT_SMEP | + CPUID_STDEXT_BMI2 | CPUID_STDEXT_ERMS | CPUID_STDEXT_RTM | CPUID_STDEXT_AVX512F | CPUID_STDEXT_RDSEED | + CPUID_STDEXT_SMAP | CPUID_STDEXT_AVX512PF | CPUID_STDEXT_AVX512ER | CPUID_STDEXT_AVX512CD | CPUID_STDEXT_SHA); From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 16:49:22 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 611BD6657DE; Wed, 16 Jun 2021 16:49:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4rkV2Lssz4nZQ; Wed, 16 Jun 2021 16:49:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38F041F05E; Wed, 16 Jun 2021 16:49:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15GGnM85035922; Wed, 16 Jun 2021 16:49:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GGnMce035921; Wed, 16 Jun 2021 16:49:22 GMT (envelope-from git) Date: Wed, 16 Jun 2021 16:49:22 GMT Message-Id: <202106161649.15GGnMce035921@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 07ef7a034965 - stable/13 - LinuxKPI: add fault_flag_allow_retry_first MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 07ef7a03496563fddd51e891dbc9e7e5d0b1dccf 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, 16 Jun 2021 16:49:22 -0000 The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=07ef7a03496563fddd51e891dbc9e7e5d0b1dccf commit 07ef7a03496563fddd51e891dbc9e7e5d0b1dccf Author: Greg V AuthorDate: 2021-06-09 23:09:16 +0000 Commit: Ed Maste CommitDate: 2021-06-16 16:48:02 +0000 LinuxKPI: add fault_flag_allow_retry_first Used by drm 5.7. Reviewed by: bz, hselasky, nc MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30673 (cherry picked from commit 597cc550e7b98294617cdd41800e9f132b6bcad9) --- sys/compat/linuxkpi/common/include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 68a0f34acaf3..74709299ba1a 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -92,6 +92,9 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0); #define FAULT_FLAG_REMOTE (1 << 7) #define FAULT_FLAG_INSTRUCTION (1 << 8) +#define fault_flag_allow_retry_first(flags) \ + (((flags) & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_TRIED)) == FAULT_FLAG_ALLOW_RETRY) + typedef int (*pte_fn_t)(linux_pte_t *, pgtable_t, unsigned long addr, void *data); struct vm_area_struct { From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 16:50: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 66ACD665ACC; Wed, 16 Jun 2021 16:50: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 4G4rlj2Wbpz4nvG; Wed, 16 Jun 2021 16:50: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 3EBCF1F0E6; Wed, 16 Jun 2021 16:50: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 15GGoP7I044283; Wed, 16 Jun 2021 16:50:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GGoPH6044282; Wed, 16 Jun 2021 16:50:25 GMT (envelope-from git) Date: Wed, 16 Jun 2021 16:50:25 GMT Message-Id: <202106161650.15GGoPH6044282@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 97f3e018fa2f - stable/12 - LinuxKPI: add fault_flag_allow_retry_first MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 97f3e018fa2f4af8fec23a4ac391d55b29da3978 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, 16 Jun 2021 16:50:25 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=97f3e018fa2f4af8fec23a4ac391d55b29da3978 commit 97f3e018fa2f4af8fec23a4ac391d55b29da3978 Author: Greg V AuthorDate: 2021-06-09 23:09:16 +0000 Commit: Ed Maste CommitDate: 2021-06-16 16:48:49 +0000 LinuxKPI: add fault_flag_allow_retry_first Used by drm 5.7. Reviewed by: bz, hselasky, nc MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30673 (cherry picked from commit 597cc550e7b98294617cdd41800e9f132b6bcad9) --- sys/compat/linuxkpi/common/include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 7710b9d61812..ecc63b85d5b9 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -91,6 +91,9 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0); #define FAULT_FLAG_REMOTE (1 << 7) #define FAULT_FLAG_INSTRUCTION (1 << 8) +#define fault_flag_allow_retry_first(flags) \ + (((flags) & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_TRIED)) == FAULT_FLAG_ALLOW_RETRY) + typedef int (*pte_fn_t)(linux_pte_t *, pgtable_t, unsigned long addr, void *data); struct vm_area_struct { From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 21:57: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 8C33E644995; Wed, 16 Jun 2021 21:57: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 4G4zYX3Rmnz3w3r; Wed, 16 Jun 2021 21:57: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 5EAE4233D8; Wed, 16 Jun 2021 21:57: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 15GLv4Bf048998; Wed, 16 Jun 2021 21:57:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GLv4Fu048997; Wed, 16 Jun 2021 21:57:04 GMT (envelope-from git) Date: Wed, 16 Jun 2021 21:57:04 GMT Message-Id: <202106162157.15GLv4Fu048997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: ad2c95130b4b - stable/13 - netgraph/bridge: malloc without flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ad2c95130b4baceca8f314e4f1d966fcac8b96b9 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, 16 Jun 2021 21:57:04 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=ad2c95130b4baceca8f314e4f1d966fcac8b96b9 commit ad2c95130b4baceca8f314e4f1d966fcac8b96b9 Author: Lutz Donnerhacke AuthorDate: 2021-06-13 22:00:35 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 21:55:35 +0000 netgraph/bridge: malloc without flags During tests an assert was triggered and pointed to missing flags in the newlink function of ng_bridge(4). Reported by: markj Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D30759 (cherry picked from commit 4c3280e58727e900d4c217054fe655e3512380f1) --- sys/netgraph/ng_bridge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index baedeb911e6d..3f3d8b3c406e 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -395,9 +395,7 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if(NG_PEER_NODE(hook) == node) return (ELOOP); - link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); - if (link == NULL) - return (ENOMEM); + link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO); link->stats.recvOctets = counter_u64_alloc(M_WAITOK); link->stats.recvPackets = counter_u64_alloc(M_WAITOK); From owner-dev-commits-src-branches@freebsd.org Wed Jun 16 21:59: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 6656E644367; Wed, 16 Jun 2021 21:59: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 4G4zcP2RPpz3w7Y; Wed, 16 Jun 2021 21:59: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 38947234EA; Wed, 16 Jun 2021 21:59: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 15GLxXFg049267; Wed, 16 Jun 2021 21:59:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15GLxXUl049266; Wed, 16 Jun 2021 21:59:33 GMT (envelope-from git) Date: Wed, 16 Jun 2021 21:59:33 GMT Message-Id: <202106162159.15GLxXUl049266@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 63312dd6d129 - stable/12 - netgraph/bridge: malloc without flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 63312dd6d12992d7e8c10bcd41389d5a25192f8f 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, 16 Jun 2021 21:59:33 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=63312dd6d12992d7e8c10bcd41389d5a25192f8f commit 63312dd6d12992d7e8c10bcd41389d5a25192f8f Author: Lutz Donnerhacke AuthorDate: 2021-06-13 22:00:35 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-16 21:58:59 +0000 netgraph/bridge: malloc without flags During tests an assert was triggered and pointed to missing flags in the newlink function of ng_bridge(4). Reported by: markj Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D30759 (cherry picked from commit 4c3280e58727e900d4c217054fe655e3512380f1) --- sys/netgraph/ng_bridge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 5a8c1731aa3f..1a0840341020 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -395,9 +395,7 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if(NG_PEER_NODE(hook) == node) return (ELOOP); - link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); - if (link == NULL) - return (ENOMEM); + link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_WAITOK | M_ZERO); link->stats.recvOctets = counter_u64_alloc(M_WAITOK); link->stats.recvPackets = counter_u64_alloc(M_WAITOK); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 08:16:20 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 D452E64EFE5; Thu, 17 Jun 2021 08:16:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G5FJ45RSMz3n8Y; Thu, 17 Jun 2021 08:16:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A263A3D4B; Thu, 17 Jun 2021 08:16:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15H8GKr1073312; Thu, 17 Jun 2021 08:16:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15H8GKCZ073311; Thu, 17 Jun 2021 08:16:20 GMT (envelope-from git) Date: Thu, 17 Jun 2021 08:16:20 GMT Message-Id: <202106170816.15H8GKCZ073311@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 7da8312f7bf0 - stable/13 - Do not forward datagrams originated by link-local addresses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7da8312f7bf050be4fe436ea66ac46414312ae26 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, 17 Jun 2021 08:16:20 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=7da8312f7bf050be4fe436ea66ac46414312ae26 commit 7da8312f7bf050be4fe436ea66ac46414312ae26 Author: Zhenlei Huang AuthorDate: 2021-05-18 20:51:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-17 08:08:59 +0000 Do not forward datagrams originated by link-local addresses The current implement of ip_input() reject packets destined for 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local addresses. Fix to fully respect RFC 3927 section 2.7. PR: 255388 Reviewed by: donner, rgrimes, karels Differential Revision: https://reviews.freebsd.org/D29968 Reviewed by: rgrimes, donner, karels, marcus, emaste Differential Revision: https://reviews.freebsd.org/D30374 (cherry picked from commit 3d846e48227e2e78c1e7b35145f57353ffda56ba) (cherry picked from commit 03b0505b8fe848f33f2f38fe89dd5538908c847e) --- sys/netinet/ip_input.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index a85f8ac7b567..57c77f29b3eb 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -736,14 +736,12 @@ passin: } ia = NULL; } - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { - IPSTAT_INC(ips_cantforward); - m_freem(m); - return; - } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { - if (V_ip_mrouter) { + /* + * RFC 3927 2.7: Do not forward multicast packets from + * IN_LINKLOCAL. + */ + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all * incoming multicast packets are passed to the @@ -778,6 +776,13 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; + /* RFC 3927 2.7: Do not forward packets to or from IN_LINKLOCAL. */ + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { + IPSTAT_INC(ips_cantforward); + m_freem(m); + return; + } /* * Not for us; forward if possible and desirable. From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 08:19: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 B2C0E64F006; Thu, 17 Jun 2021 08:19: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 4G5FMQ4kSTz3nlf; Thu, 17 Jun 2021 08:19: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 8A9F33D4E; Thu, 17 Jun 2021 08:19: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 15H8JEnY073631; Thu, 17 Jun 2021 08:19:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15H8JE14073630; Thu, 17 Jun 2021 08:19:14 GMT (envelope-from git) Date: Thu, 17 Jun 2021 08:19:14 GMT Message-Id: <202106170819.15H8JE14073630@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: c0a91473f5be - stable/12 - Do not forward datagrams originated by link-local addresses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c0a91473f5be9f0660d1e043b1f08f7d50e815ad 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, 17 Jun 2021 08:19:14 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=c0a91473f5be9f0660d1e043b1f08f7d50e815ad commit c0a91473f5be9f0660d1e043b1f08f7d50e815ad Author: Zhenlei Huang AuthorDate: 2021-05-18 20:51:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-17 08:18:46 +0000 Do not forward datagrams originated by link-local addresses The current implement of ip_input() reject packets destined for 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local addresses. Fix to fully respect RFC 3927 section 2.7. PR: 255388 Reviewed by: donner, rgrimes, karels Differential Revision: https://reviews.freebsd.org/D29968 Reviewed by: rgrimes, donner, karels, marcus, emaste Differential Revision: https://reviews.freebsd.org/D30374 (cherry picked from commit 3d846e48227e2e78c1e7b35145f57353ffda56ba) (cherry picked from commit 03b0505b8fe848f33f2f38fe89dd5538908c847e) --- sys/netinet/ip_input.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index e329b65b4e21..6e692083c121 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -738,14 +738,12 @@ passin: IF_ADDR_RUNLOCK(ifp); ia = NULL; } - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { - IPSTAT_INC(ips_cantforward); - m_freem(m); - return; - } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { - if (V_ip_mrouter) { + /* + * RFC 3927 2.7: Do not forward multicast packets from + * IN_LINKLOCAL. + */ + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all * incoming multicast packets are passed to the @@ -780,6 +778,13 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; + /* RFC 3927 2.7: Do not forward packets to or from IN_LINKLOCAL. */ + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { + IPSTAT_INC(ips_cantforward); + m_freem(m); + return; + } /* * Not for us; forward if possible and desirable. From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 08:21: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 AD50F64F108; Thu, 17 Jun 2021 08:21: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 4G5FQJ4ZpQz3qBS; Thu, 17 Jun 2021 08:21: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 859E64007; Thu, 17 Jun 2021 08:21: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 15H8Lirp082845; Thu, 17 Jun 2021 08:21:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15H8Lid0082844; Thu, 17 Jun 2021 08:21:44 GMT (envelope-from git) Date: Thu, 17 Jun 2021 08:21:44 GMT Message-Id: <202106170821.15H8Lid0082844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 9d30353cb494 - stable/11 - Do not forward datagrams originated by link-local addresses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 9d30353cb49467ba2b672673a5765588c4e857ec 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, 17 Jun 2021 08:21:44 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=9d30353cb49467ba2b672673a5765588c4e857ec commit 9d30353cb49467ba2b672673a5765588c4e857ec Author: Zhenlei Huang AuthorDate: 2021-05-18 20:51:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-17 08:21:00 +0000 Do not forward datagrams originated by link-local addresses The current implement of ip_input() reject packets destined for 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local addresses. Fix to fully respect RFC 3927 section 2.7. PR: 255388 Reviewed by: donner, rgrimes, karels Differential Revision: https://reviews.freebsd.org/D29968 Reviewed by: rgrimes, donner, karels, marcus, emaste Differential Revision: https://reviews.freebsd.org/D30374 (cherry picked from commit 3d846e48227e2e78c1e7b35145f57353ffda56ba) (cherry picked from commit 03b0505b8fe848f33f2f38fe89dd5538908c847e) --- sys/netinet/ip_input.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 0f14889f355d..53978fd0fe6c 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -733,14 +733,12 @@ passin: IF_ADDR_RUNLOCK(ifp); ia = NULL; } - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { - IPSTAT_INC(ips_cantforward); - m_freem(m); - return; - } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { - if (V_ip_mrouter) { + /* + * RFC 3927 2.7: Do not forward multicast packets from + * IN_LINKLOCAL. + */ + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all * incoming multicast packets are passed to the @@ -775,6 +773,13 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; + /* RFC 3927 2.7: Do not forward packets to or from IN_LINKLOCAL. */ + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { + IPSTAT_INC(ips_cantforward); + m_freem(m); + return; + } /* * Not for us; forward if possible and desirable. From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 10:35: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 E3EBC650AE3; Thu, 17 Jun 2021 10:35: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 4G5JNy5tXvz4WZ7; Thu, 17 Jun 2021 10:35: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 AE7BC5A42; Thu, 17 Jun 2021 10:35: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 15HAZkP7063304; Thu, 17 Jun 2021 10:35:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HAZkQK063303; Thu, 17 Jun 2021 10:35:46 GMT (envelope-from git) Date: Thu, 17 Jun 2021 10:35:46 GMT Message-Id: <202106171035.15HAZkQK063303@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 4715d948c593 - stable/13 - Introduce DXR as an IPv4 longest prefix matching / FIB module MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4715d948c593b5bb3d2e2129ed299becec566373 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, 17 Jun 2021 10:35:47 -0000 The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=4715d948c593b5bb3d2e2129ed299becec566373 commit 4715d948c593b5bb3d2e2129ed299becec566373 Author: Marko Zec AuthorDate: 2021-05-05 11:45:52 +0000 Commit: Marko Zec CommitDate: 2021-06-17 10:07:05 +0000 Introduce DXR as an IPv4 longest prefix matching / FIB module DXR maintains compressed lookup structures with a trivial search procedure. A two-stage trie is indexed by the more significant bits of the search key (IPv4 address), while the remaining bits are used for finding the next hop in a sorted array. The tradeoff between memory footprint and search speed depends on the split between the trie and the remaining binary search. The default of 20 bits of the key being used for trie indexing yields good performance (see below) with footprints of around 2.5 Bytes per prefix with current BGP snapshots. Rebuilding lookup structures takes some time, which is compensated for by batching several RIB change requests into a single FIB update, i.e. FIB synchronization with the RIB may be delayed for a fraction of a second. RIB to FIB synchronization, next-hop table housekeeping, and lockless lookup capability is provided by the FIB_ALGO infrastructure. DXR works well on modern CPUs with several MBytes of caches, especially in VMs, where is outperforms other currently available IPv4 FIB algorithms by a large margin. Reviewed by: melifaro MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29821 (cherry picked from commit 2aca58e16f507bfcad127a0865a9d5c75c5eedc3) --- sys/modules/Makefile | 2 + sys/modules/fib_dxr/Makefile | 11 + sys/netinet/in_fib_dxr.c | 1253 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1266 insertions(+) diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 7574c612f49c..ec5dd9a047c2 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -120,6 +120,7 @@ SUBDIR= \ fdc \ fdescfs \ ${_ffec} \ + ${_fib_dxr} \ filemon \ firewire \ firmware \ @@ -476,6 +477,7 @@ _ipfilter= ipfilter .if ${MK_INET_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO} _dpdk_lpm4= dpdk_lpm4 +_fib_dxr= fib_dxr .endif .if ${MK_INET6_SUPPORT} != "no" && ${KERN_OPTS:MFIB_ALGO} diff --git a/sys/modules/fib_dxr/Makefile b/sys/modules/fib_dxr/Makefile new file mode 100644 index 000000000000..c1a704beb535 --- /dev/null +++ b/sys/modules/fib_dxr/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +SYSDIR?=${SRCTOP}/sys +.include "${SYSDIR}/conf/kern.opts.mk" + +.PATH: ${SYSDIR}/netinet + +KMOD= fib_dxr +SRCS= in_fib_dxr.c opt_inet.h + +.include diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c new file mode 100644 index 000000000000..ec32819a5a6d --- /dev/null +++ b/sys/netinet/in_fib_dxr.c @@ -0,0 +1,1253 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2012-2021 Marko Zec + * Copyright (c) 2005, 2018 University of Zagreb + * Copyright (c) 2005 International Computer Science Institute + * + * 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. + */ + +/* + * An implementation of DXR, a simple IPv4 LPM scheme with compact lookup + * structures and a trivial search procedure. More significant bits of + * the search key are used to directly index a two-stage trie, while the + * remaining bits are used for finding the next hop in a sorted array. + * More details in: + * + * M. Zec, L. Rizzo, M. Mikuc, DXR: towards a billion routing lookups per + * second in software, ACM SIGCOMM Computer Communication Review, September + * 2012 + * + * M. Zec, M. Mikuc, Pushing the envelope: beyond two billion IP routing + * lookups per second on commodity CPUs, IEEE SoftCOM, September 2017, Split + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#define DXR_TRIE_BITS 20 + +CTASSERT(DXR_TRIE_BITS >= 16 && DXR_TRIE_BITS <= 24); + +/* DXR2: two-stage primary trie, instead of a single direct lookup table */ +#define DXR2 + +#if DXR_TRIE_BITS > 16 +#define DXR_D 16 +#else +#define DXR_D (DXR_TRIE_BITS - 1) +#endif +#define DXR_X (DXR_TRIE_BITS - DXR_D) + +#define D_TBL_SIZE (1 << DXR_D) +#define DIRECT_TBL_SIZE (1 << DXR_TRIE_BITS) +#define DXR_RANGE_MASK (0xffffffffU >> DXR_TRIE_BITS) +#define DXR_RANGE_SHIFT (32 - DXR_TRIE_BITS) + +#define DESC_BASE_BITS 22 +#define DESC_FRAGMENTS_BITS (32 - DESC_BASE_BITS) +#define BASE_MAX ((1 << DESC_BASE_BITS) - 1) +#define RTBL_SIZE_INCR (BASE_MAX / 64) + +#if DXR_TRIE_BITS < 24 +#define FRAGS_MASK_SHORT ((1 << (23 - DXR_TRIE_BITS)) - 1) +#else +#define FRAGS_MASK_SHORT 0 +#endif +#define FRAGS_PREF_SHORT (((1 << DESC_FRAGMENTS_BITS) - 1) & \ + ~FRAGS_MASK_SHORT) +#define FRAGS_MARK_XL (FRAGS_PREF_SHORT - 1) +#define FRAGS_MARK_HIT (FRAGS_PREF_SHORT - 2) + +#define IS_SHORT_FORMAT(x) ((x & FRAGS_PREF_SHORT) == FRAGS_PREF_SHORT) +#define IS_LONG_FORMAT(x) ((x & FRAGS_PREF_SHORT) != FRAGS_PREF_SHORT) +#define IS_XL_FORMAT(x) (x == FRAGS_MARK_XL) + +#define RE_SHORT_MAX_NH ((1 << (DXR_TRIE_BITS - 8)) - 1) + +#define CHUNK_HASH_BITS 16 +#define CHUNK_HASH_SIZE (1 << CHUNK_HASH_BITS) +#define CHUNK_HASH_MASK (CHUNK_HASH_SIZE - 1) + +#define TRIE_HASH_BITS 16 +#define TRIE_HASH_SIZE (1 << TRIE_HASH_BITS) +#define TRIE_HASH_MASK (TRIE_HASH_SIZE - 1) + +#define XTBL_SIZE_INCR (DIRECT_TBL_SIZE / 16) + +/* Lookup structure elements */ + +struct direct_entry { + uint32_t fragments: DESC_FRAGMENTS_BITS, + base: DESC_BASE_BITS; +}; + +struct range_entry_long { + uint32_t start: DXR_RANGE_SHIFT, + nexthop: DXR_TRIE_BITS; +}; + +#if DXR_TRIE_BITS < 24 +struct range_entry_short { + uint16_t start: DXR_RANGE_SHIFT - 8, + nexthop: DXR_TRIE_BITS - 8; +}; +#endif + +/* Auxiliary structures */ + +struct heap_entry { + uint32_t start; + uint32_t end; + uint32_t preflen; + uint32_t nexthop; +}; + +struct chunk_desc { + LIST_ENTRY(chunk_desc) cd_all_le; + LIST_ENTRY(chunk_desc) cd_hash_le; + uint32_t cd_hash; + uint32_t cd_refcnt; + uint32_t cd_base; + uint32_t cd_cur_size; + uint32_t cd_max_size; +}; + +struct trie_desc { + LIST_ENTRY(trie_desc) td_all_le; + LIST_ENTRY(trie_desc) td_hash_le; + uint32_t td_hash; + uint32_t td_index; + uint32_t td_refcnt; +}; + +struct dxr_aux { + /* Glue to external state */ + struct fib_data *fd; + uint32_t fibnum; + int refcnt; + + /* Auxiliary build-time tables */ + struct direct_entry direct_tbl[DIRECT_TBL_SIZE]; + uint16_t d_tbl[D_TBL_SIZE]; + struct direct_entry *x_tbl; + union { + struct range_entry_long re; + uint32_t fragments; + } *range_tbl; + + /* Auxiliary internal state */ + uint32_t updates_mask[DIRECT_TBL_SIZE / 32]; + struct trie_desc *trietbl[D_TBL_SIZE]; + LIST_HEAD(, chunk_desc) chunk_hashtbl[CHUNK_HASH_SIZE]; + LIST_HEAD(, chunk_desc) all_chunks; + LIST_HEAD(, chunk_desc) unused_chunks; /* abuses hash link entry */ + LIST_HEAD(, trie_desc) trie_hashtbl[TRIE_HASH_SIZE]; + LIST_HEAD(, trie_desc) all_trie; + LIST_HEAD(, trie_desc) unused_trie; /* abuses hash link entry */ + struct sockaddr_in dst; + struct sockaddr_in mask; + struct heap_entry heap[33]; + uint32_t prefixes; + uint32_t updates_low; + uint32_t updates_high; + uint32_t all_chunks_cnt; + uint32_t unused_chunks_cnt; + uint32_t xtbl_size; + uint32_t all_trie_cnt; + uint32_t unused_trie_cnt; + uint32_t trie_rebuilt_prefixes; + uint32_t heap_index; + uint32_t d_bits; + uint32_t rtbl_size; + uint32_t rtbl_top; + uint32_t rtbl_work_frags; + uint32_t work_chunk; +}; + +/* Main lookup structure container */ + +struct dxr { + /* Lookup tables */ + uint16_t d_shift; + uint16_t x_shift; + uint32_t x_mask; + void *d; + void *x; + void *r; + struct nhop_object **nh_tbl; + + /* Glue to external state */ + struct dxr_aux *aux; + struct fib_data *fd; + struct epoch_context epoch_ctx; + uint32_t fibnum; +}; + +static MALLOC_DEFINE(M_DXRLPM, "dxr", "DXR LPM"); +static MALLOC_DEFINE(M_DXRAUX, "dxr aux", "DXR auxiliary"); + +uma_zone_t chunk_zone; +uma_zone_t trie_zone; + +SYSCTL_DECL(_net_route_algo); +SYSCTL_NODE(_net_route_algo, OID_AUTO, dxr, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "DXR tunables"); + +VNET_DEFINE_STATIC(int, max_trie_holes) = 8; +#define V_max_trie_holes VNET(max_trie_holes) +SYSCTL_INT(_net_route_algo_dxr, OID_AUTO, max_trie_holes, + CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(max_trie_holes), 0, + "Trie fragmentation threshold before triggering a full rebuild"); + +VNET_DEFINE_STATIC(int, max_range_holes) = 16; +#define V_max_range_holes VNET(max_range_holes) +SYSCTL_INT(_net_route_algo_dxr, OID_AUTO, max_range_holes, + CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(max_range_holes), 0, + "Range table fragmentation threshold before triggering a full rebuild"); + +/* Binary search for a matching address range */ +#define DXR_LOOKUP_STAGE \ + if (masked_dst < range[middle].start) { \ + upperbound = middle; \ + middle = (middle + lowerbound) / 2; \ + } else if (masked_dst < range[middle + 1].start) \ + return (range[middle].nexthop); \ + else { \ + lowerbound = middle + 1; \ + middle = (upperbound + middle + 1) / 2; \ + } \ + if (upperbound == lowerbound) \ + return (range[lowerbound].nexthop); + +static int +dxr_lookup(struct dxr *dxr, uint32_t dst) +{ +#ifdef DXR2 + uint16_t *dt = dxr->d; + struct direct_entry *xt = dxr->x; + int xi; +#else + struct direct_entry *dt = dxr->d; +#endif + struct direct_entry de; + struct range_entry_long *rt; + uint32_t base; + uint32_t upperbound; + uint32_t middle; + uint32_t lowerbound; + uint32_t masked_dst; + +#ifdef DXR2 + xi = (dt[dst >> dxr->d_shift] << dxr->x_shift) + + ((dst >> DXR_RANGE_SHIFT) & dxr->x_mask); + de = xt[xi]; +#else + de = dt[dst >> DXR_RANGE_SHIFT]; +#endif + + if (__predict_true(de.fragments == FRAGS_MARK_HIT)) + return (de.base); + + rt = dxr->r; + base = de.base; + lowerbound = 0; + masked_dst = dst & DXR_RANGE_MASK; + +#if DXR_TRIE_BITS < 24 + if (__predict_true(IS_SHORT_FORMAT(de.fragments))) { + upperbound = de.fragments & FRAGS_MASK_SHORT; + struct range_entry_short *range = + (struct range_entry_short *) &rt[base]; + + masked_dst >>= 8; + middle = upperbound; + upperbound = upperbound * 2 + 1; + + for (;;) { + DXR_LOOKUP_STAGE + DXR_LOOKUP_STAGE + } + } +#endif + + upperbound = de.fragments; + middle = upperbound / 2; + struct range_entry_long *range = &rt[base]; + if (__predict_false(IS_XL_FORMAT(de.fragments))) { + upperbound = *((uint32_t *) range); + range++; + middle = upperbound / 2; + } + + for (;;) { + DXR_LOOKUP_STAGE + DXR_LOOKUP_STAGE + } +} + +static void +initheap(struct dxr_aux *da, uint32_t dst_u32, uint32_t chunk) +{ + struct heap_entry *fhp = &da->heap[0]; + struct rtentry *rt; + struct route_nhop_data rnd; + + da->heap_index = 0; + da->dst.sin_addr.s_addr = htonl(dst_u32); + rt = fib4_lookup_rt(da->fibnum, da->dst.sin_addr, 0, NHR_UNLOCKED, + &rnd); + if (rt != NULL) { + struct in_addr addr; + uint32_t scopeid; + + rt_get_inet_prefix_plen(rt, &addr, &fhp->preflen, &scopeid); + fhp->start = ntohl(addr.s_addr); + fhp->end = fhp->start; + if (fhp->preflen < 32) + fhp->end |= (0xffffffffU >> fhp->preflen); + fhp->nexthop = fib_get_nhop_idx(da->fd, rnd.rnd_nhop); + } else { + fhp->preflen = fhp->nexthop = fhp->start = 0; + fhp->end = 0xffffffffU; + } +} + +static uint32_t +chunk_size(struct dxr_aux *da, struct direct_entry *fdesc) +{ + + if (IS_SHORT_FORMAT(fdesc->fragments)) + return ((fdesc->fragments & FRAGS_MASK_SHORT) + 1); + else if (IS_XL_FORMAT(fdesc->fragments)) + return (da->range_tbl[fdesc->base].fragments + 2); + else /* if (IS_LONG_FORMAT(fdesc->fragments)) */ + return (fdesc->fragments + 1); +} + +static uint32_t +chunk_hash(struct dxr_aux *da, struct direct_entry *fdesc) +{ + uint32_t size = chunk_size(da, fdesc); + uint32_t *p = (uint32_t *) &da->range_tbl[fdesc->base]; + uint32_t *l = (uint32_t *) &da->range_tbl[fdesc->base + size]; + uint32_t hash = fdesc->fragments; + + for (; p < l; p++) + hash = (hash << 7) + (hash >> 13) + *p; + + return (hash + (hash >> 16)); +} + +static int +chunk_ref(struct dxr_aux *da, uint32_t chunk) +{ + struct direct_entry *fdesc = &da->direct_tbl[chunk]; + struct chunk_desc *cdp, *empty_cdp; + uint32_t base = fdesc->base; + uint32_t size = chunk_size(da, fdesc); + uint32_t hash = chunk_hash(da, fdesc); + + /* Find an existing descriptor */ + LIST_FOREACH(cdp, &da->chunk_hashtbl[hash & CHUNK_HASH_MASK], + cd_hash_le) { + if (cdp->cd_hash != hash || cdp->cd_cur_size != size || + memcmp(&da->range_tbl[base], &da->range_tbl[cdp->cd_base], + sizeof(struct range_entry_long) * size)) + continue; + da->rtbl_top = fdesc->base; + fdesc->base = cdp->cd_base; + cdp->cd_refcnt++; + return (0); + } + + /* No matching chunks found. Recycle an empty or allocate a new one */ + cdp = NULL; + LIST_FOREACH(empty_cdp, &da->unused_chunks, cd_hash_le) + if (empty_cdp->cd_max_size >= size && (cdp == NULL || + empty_cdp->cd_max_size < cdp->cd_max_size)) { + cdp = empty_cdp; + if (empty_cdp->cd_max_size == size) + break; + } + + if (cdp != NULL) { + /* Copy from heap into the recycled chunk */ + bcopy(&da->range_tbl[fdesc->base], &da->range_tbl[cdp->cd_base], + size * sizeof(struct range_entry_long)); + fdesc->base = cdp->cd_base; + da->rtbl_top -= size; + da->unused_chunks_cnt--; + if (cdp->cd_max_size > size + 1) { + /* Split the range in two, need a new descriptor */ + empty_cdp = uma_zalloc(chunk_zone, M_NOWAIT); + if (empty_cdp == NULL) + return (1); + empty_cdp->cd_max_size = cdp->cd_max_size - size; + empty_cdp->cd_base = cdp->cd_base + size; + LIST_INSERT_AFTER(cdp, empty_cdp, cd_all_le); + LIST_INSERT_AFTER(cdp, empty_cdp, cd_hash_le); + da->all_chunks_cnt++; + da->unused_chunks_cnt++; + cdp->cd_max_size = size; + } + LIST_REMOVE(cdp, cd_hash_le); + } else { + /* Alloc a new descriptor */ + cdp = uma_zalloc(chunk_zone, M_NOWAIT); + if (cdp == NULL) + return (1); + cdp->cd_max_size = size; + cdp->cd_base = fdesc->base; + LIST_INSERT_HEAD(&da->all_chunks, cdp, cd_all_le); + da->all_chunks_cnt++; + } + + cdp->cd_hash = hash; + cdp->cd_refcnt = 1; + cdp->cd_cur_size = size; + LIST_INSERT_HEAD(&da->chunk_hashtbl[hash & CHUNK_HASH_MASK], cdp, + cd_hash_le); + if (da->rtbl_top >= da->rtbl_size) { + if (da->rtbl_top >= BASE_MAX) { + FIB_PRINTF(LOG_ERR, da->fd, + "structural limit exceeded at %d " + "range table elements", da->rtbl_top); + return (1); + } + da->rtbl_size += RTBL_SIZE_INCR; + if (da->rtbl_top >= BASE_MAX / 4) + FIB_PRINTF(LOG_WARNING, da->fd, "range table at %d%%", + da->rtbl_top * 100 / BASE_MAX); + da->range_tbl = realloc(da->range_tbl, + sizeof(*da->range_tbl) * da->rtbl_size + FRAGS_PREF_SHORT, + M_DXRAUX, M_NOWAIT); + if (da->range_tbl == NULL) + return (1); + } + + return (0); +} + +static void +chunk_unref(struct dxr_aux *da, uint32_t chunk) +{ + struct direct_entry *fdesc = &da->direct_tbl[chunk]; + struct chunk_desc *cdp; + uint32_t base = fdesc->base; + uint32_t size = chunk_size(da, fdesc); + uint32_t hash = chunk_hash(da, fdesc); + + /* Find an existing descriptor */ + LIST_FOREACH(cdp, &da->chunk_hashtbl[hash & CHUNK_HASH_MASK], + cd_hash_le) + if (cdp->cd_hash == hash && cdp->cd_cur_size == size && + memcmp(&da->range_tbl[base], &da->range_tbl[cdp->cd_base], + sizeof(struct range_entry_long) * size) == 0) + break; + + KASSERT(cdp != NULL, ("dxr: dangling chunk")); + if (--cdp->cd_refcnt > 0) + return; + + LIST_REMOVE(cdp, cd_hash_le); + da->unused_chunks_cnt++; + if (cdp->cd_base + cdp->cd_max_size != da->rtbl_top) { + LIST_INSERT_HEAD(&da->unused_chunks, cdp, cd_hash_le); + return; + } + + do { + da->all_chunks_cnt--; + da->unused_chunks_cnt--; + da->rtbl_top -= cdp->cd_max_size; + LIST_REMOVE(cdp, cd_all_le); + uma_zfree(chunk_zone, cdp); + LIST_FOREACH(cdp, &da->unused_chunks, cd_hash_le) + if (cdp->cd_base + cdp->cd_max_size == da->rtbl_top) { + LIST_REMOVE(cdp, cd_hash_le); + break; + } + } while (cdp != NULL); +} + +#ifdef DXR2 +static uint32_t +trie_hash(struct dxr_aux *da, uint32_t dxr_x, uint32_t index) +{ + uint32_t i, *val; + uint32_t hash = 0; + + for (i = 0; i < (1 << dxr_x); i++) { + hash = (hash << 3) ^ (hash >> 3); + val = (uint32_t *) + (void *) &da->direct_tbl[(index << dxr_x) + i]; + hash += (*val << 5); + hash += (*val >> 5); + } + + return (hash + (hash >> 16)); +} + +static int +trie_ref(struct dxr_aux *da, uint32_t index) +{ + struct trie_desc *tp; + uint32_t dxr_d = da->d_bits; + uint32_t dxr_x = DXR_TRIE_BITS - dxr_d; + uint32_t hash = trie_hash(da, dxr_x, index); + + /* Find an existing descriptor */ + LIST_FOREACH(tp, &da->trie_hashtbl[hash & TRIE_HASH_MASK], td_hash_le) + if (tp->td_hash == hash && + memcmp(&da->direct_tbl[index << dxr_x], + &da->x_tbl[tp->td_index << dxr_x], + sizeof(*da->x_tbl) << dxr_x) == 0) { + tp->td_refcnt++; + da->trietbl[index] = tp; + return(tp->td_index); + } + + tp = LIST_FIRST(&da->unused_trie); + if (tp != NULL) { + LIST_REMOVE(tp, td_hash_le); + da->unused_trie_cnt--; + } else { + tp = uma_zalloc(trie_zone, M_NOWAIT); + if (tp == NULL) + return (-1); + LIST_INSERT_HEAD(&da->all_trie, tp, td_all_le); + tp->td_index = da->all_trie_cnt++; + } + + tp->td_hash = hash; + tp->td_refcnt = 1; + LIST_INSERT_HEAD(&da->trie_hashtbl[hash & TRIE_HASH_MASK], tp, + td_hash_le); + memcpy(&da->x_tbl[tp->td_index << dxr_x], + &da->direct_tbl[index << dxr_x], sizeof(*da->x_tbl) << dxr_x); + da->trietbl[index] = tp; + if (da->all_trie_cnt >= da->xtbl_size >> dxr_x) { + da->xtbl_size += XTBL_SIZE_INCR; + da->x_tbl = realloc(da->x_tbl, + sizeof(*da->x_tbl) * da->xtbl_size, M_DXRAUX, M_NOWAIT); + if (da->x_tbl == NULL) + return (-1); + } + return(tp->td_index); +} + +static void +trie_unref(struct dxr_aux *da, uint32_t index) +{ + struct trie_desc *tp = da->trietbl[index]; + + if (tp == NULL) + return; + da->trietbl[index] = NULL; + if (--tp->td_refcnt > 0) + return; + + LIST_REMOVE(tp, td_hash_le); + da->unused_trie_cnt++; + if (tp->td_index != da->all_trie_cnt - 1) { + LIST_INSERT_HEAD(&da->unused_trie, tp, td_hash_le); + return; + } + + do { + da->all_trie_cnt--; + da->unused_trie_cnt--; + LIST_REMOVE(tp, td_all_le); + uma_zfree(trie_zone, tp); + LIST_FOREACH(tp, &da->unused_trie, td_hash_le) + if (tp->td_index == da->all_trie_cnt - 1) { + LIST_REMOVE(tp, td_hash_le); + break; + } + } while (tp != NULL); +} +#endif + +static void +heap_inject(struct dxr_aux *da, uint32_t start, uint32_t end, uint32_t preflen, + uint32_t nh) +{ + struct heap_entry *fhp; + int i; + + for (i = da->heap_index; i >= 0; i--) { + if (preflen > da->heap[i].preflen) + break; + else if (preflen < da->heap[i].preflen) + da->heap[i + 1] = da->heap[i]; + else + return; + } + + fhp = &da->heap[i + 1]; + fhp->preflen = preflen; + fhp->start = start; + fhp->end = end; + fhp->nexthop = nh; + da->heap_index++; +} + +static int +dxr_walk(struct rtentry *rt, void *arg) +{ + struct dxr_aux *da = arg; + uint32_t chunk = da->work_chunk; + uint32_t first = chunk << DXR_RANGE_SHIFT; + uint32_t last = first | DXR_RANGE_MASK; + struct range_entry_long *fp = + &da->range_tbl[da->rtbl_top + da->rtbl_work_frags].re; + struct heap_entry *fhp = &da->heap[da->heap_index]; + uint32_t preflen, nh, start, end, scopeid; + struct in_addr addr; + + rt_get_inet_prefix_plen(rt, &addr, &preflen, &scopeid); + start = ntohl(addr.s_addr); + if (start > last) + return (-1); /* Beyond chunk boundaries, we are done */ + if (start < first) + return (0); /* Skip this route */ + + end = start; + if (preflen < 32) + end |= (0xffffffffU >> preflen); + nh = fib_get_nhop_idx(da->fd, rt_get_raw_nhop(rt)); + + if (start == fhp->start) + heap_inject(da, start, end, preflen, nh); + else { + /* start > fhp->start */ + while (start > fhp->end) { + uint32_t oend = fhp->end; + + if (da->heap_index > 0) { + fhp--; + da->heap_index--; + } else + initheap(da, fhp->end + 1, chunk); + if (fhp->end > oend && fhp->nexthop != fp->nexthop) { + fp++; + da->rtbl_work_frags++; + fp->start = (oend + 1) & DXR_RANGE_MASK; + fp->nexthop = fhp->nexthop; + } + } + if (start > ((chunk << DXR_RANGE_SHIFT) | fp->start) && + nh != fp->nexthop) { + fp++; + da->rtbl_work_frags++; + fp->start = start & DXR_RANGE_MASK; + } else if (da->rtbl_work_frags) { + if ((--fp)->nexthop == nh) + da->rtbl_work_frags--; + else + fp++; + } + fp->nexthop = nh; + heap_inject(da, start, end, preflen, nh); + } + + return (0); +} + +static int +update_chunk(struct dxr_aux *da, uint32_t chunk) +{ + struct range_entry_long *fp; +#if DXR_TRIE_BITS < 24 + struct range_entry_short *fps; + uint32_t start, nh, i; +#endif + struct heap_entry *fhp; + uint32_t first = chunk << DXR_RANGE_SHIFT; + uint32_t last = first | DXR_RANGE_MASK; + + if (da->direct_tbl[chunk].fragments != FRAGS_MARK_HIT) + chunk_unref(da, chunk); + + initheap(da, first, chunk); + + fp = &da->range_tbl[da->rtbl_top].re; + da->rtbl_work_frags = 0; + fp->start = first & DXR_RANGE_MASK; + fp->nexthop = da->heap[0].nexthop; + + da->dst.sin_addr.s_addr = htonl(first); + da->mask.sin_addr.s_addr = htonl(~DXR_RANGE_MASK); + + da->work_chunk = chunk; + rib_walk_from(da->fibnum, AF_INET, RIB_FLAG_LOCKED, + (struct sockaddr *) &da->dst, (struct sockaddr *) &da->mask, + dxr_walk, da); + + /* Flush any remaining objects on the heap */ + fp = &da->range_tbl[da->rtbl_top + da->rtbl_work_frags].re; + fhp = &da->heap[da->heap_index]; + while (fhp->preflen > DXR_TRIE_BITS) { + uint32_t oend = fhp->end; + + if (da->heap_index > 0) { + fhp--; + da->heap_index--; + } else + initheap(da, fhp->end + 1, chunk); + if (fhp->end > oend && fhp->nexthop != fp->nexthop) { + /* Have we crossed the upper chunk boundary? */ + if (oend >= last) + break; + fp++; + da->rtbl_work_frags++; + fp->start = (oend + 1) & DXR_RANGE_MASK; + fp->nexthop = fhp->nexthop; + } + } + + /* Direct hit if the chunk contains only a single fragment */ + if (da->rtbl_work_frags == 0) { + da->direct_tbl[chunk].base = fp->nexthop; + da->direct_tbl[chunk].fragments = FRAGS_MARK_HIT; + return (0); + } + + da->direct_tbl[chunk].base = da->rtbl_top; + da->direct_tbl[chunk].fragments = da->rtbl_work_frags; + +#if DXR_TRIE_BITS < 24 + /* Check whether the chunk can be more compactly encoded */ + fp = &da->range_tbl[da->rtbl_top].re; + for (i = 0; i <= da->rtbl_work_frags; i++, fp++) + if ((fp->start & 0xff) != 0 || fp->nexthop > RE_SHORT_MAX_NH) + break; + if (i == da->rtbl_work_frags + 1) { + fp = &da->range_tbl[da->rtbl_top].re; + fps = (void *) fp; + for (i = 0; i <= da->rtbl_work_frags; i++, fp++, fps++) { + start = fp->start; + nh = fp->nexthop; + fps->start = start >> 8; + fps->nexthop = nh; + } + fps->start = start >> 8; + fps->nexthop = nh; + da->rtbl_work_frags >>= 1; + da->direct_tbl[chunk].fragments = + da->rtbl_work_frags | FRAGS_PREF_SHORT; + } else +#endif + if (da->rtbl_work_frags >= FRAGS_MARK_HIT) { + da->direct_tbl[chunk].fragments = FRAGS_MARK_XL; + memmove(&da->range_tbl[da->rtbl_top + 1], + &da->range_tbl[da->rtbl_top], + (da->rtbl_work_frags + 1) * sizeof(*da->range_tbl)); + da->range_tbl[da->rtbl_top].fragments = da->rtbl_work_frags; + da->rtbl_work_frags++; + } + da->rtbl_top += (da->rtbl_work_frags + 1); + return (chunk_ref(da, chunk)); +} + +static void +dxr_build(struct dxr *dxr) +{ + struct dxr_aux *da = dxr->aux; + struct chunk_desc *cdp; + struct rib_rtable_info rinfo; + struct timeval t0, t1, t2, t3; + uint32_t r_size, dxr_tot_size; + uint32_t i, m, range_rebuild = 0; +#ifdef DXR2 + struct trie_desc *tp; + uint32_t d_tbl_size, dxr_x, d_size, x_size; + uint32_t ti, trie_rebuild = 0, prev_size = 0; +#endif + + KASSERT(dxr->d == NULL, ("dxr: d not free")); + + if (da == NULL) { + da = malloc(sizeof(*dxr->aux), M_DXRAUX, M_NOWAIT); + if (da == NULL) + return; + dxr->aux = da; + da->fibnum = dxr->fibnum; + da->refcnt = 1; + LIST_INIT(&da->all_chunks); + LIST_INIT(&da->all_trie); + da->rtbl_size = RTBL_SIZE_INCR; + da->range_tbl = NULL; + da->xtbl_size = XTBL_SIZE_INCR; + da->x_tbl = NULL; + bzero(&da->dst, sizeof(da->dst)); + bzero(&da->mask, sizeof(da->mask)); + da->dst.sin_len = sizeof(da->dst); + da->mask.sin_len = sizeof(da->mask); + da->dst.sin_family = AF_INET; + da->mask.sin_family = AF_INET; + } + if (da->range_tbl == NULL) { + da->range_tbl = malloc(sizeof(*da->range_tbl) * da->rtbl_size + + FRAGS_PREF_SHORT, M_DXRAUX, M_NOWAIT); + if (da->range_tbl == NULL) + return; + range_rebuild = 1; + } +#ifdef DXR2 + if (da->x_tbl == NULL) { + da->x_tbl = malloc(sizeof(*da->x_tbl) * da->xtbl_size, + M_DXRAUX, M_NOWAIT); + if (da->x_tbl == NULL) + return; + trie_rebuild = 1; + } +#endif + da->fd = dxr->fd; + + microuptime(&t0); + + dxr->nh_tbl = fib_get_nhop_array(da->fd); + fib_get_rtable_info(fib_get_rh(da->fd), &rinfo); + + if (da->updates_low > da->updates_high || + da->unused_chunks_cnt > V_max_range_holes) + range_rebuild = 1; + if (range_rebuild) { + /* Bulk cleanup */ + bzero(da->chunk_hashtbl, sizeof(da->chunk_hashtbl)); + while ((cdp = LIST_FIRST(&da->all_chunks)) != NULL) { + LIST_REMOVE(cdp, cd_all_le); + uma_zfree(chunk_zone, cdp); + } + LIST_INIT(&da->unused_chunks); + da->all_chunks_cnt = da->unused_chunks_cnt = 0; + da->rtbl_top = 0; + da->updates_low = 0; + da->updates_high = DIRECT_TBL_SIZE - 1; + memset(da->updates_mask, 0xff, sizeof(da->updates_mask)); + for (i = 0; i < DIRECT_TBL_SIZE; i++) { + da->direct_tbl[i].fragments = FRAGS_MARK_HIT; + da->direct_tbl[i].base = 0; + } + } + da->prefixes = rinfo.num_prefixes; + + /* DXR: construct direct & range table */ + for (i = da->updates_low; i <= da->updates_high; i++) { + m = da->updates_mask[i >> 5] >> (i & 0x1f); + if (m == 0) + i |= 0x1f; + else if (m & 1 && update_chunk(da, i) != 0) + return; + } + r_size = sizeof(*da->range_tbl) * da->rtbl_top; + microuptime(&t1); + +#ifdef DXR2 + if (range_rebuild || da->unused_trie_cnt > V_max_trie_holes || + abs(fls(da->prefixes) - fls(da->trie_rebuilt_prefixes)) > 1) + trie_rebuild = 1; + if (trie_rebuild) { + da->trie_rebuilt_prefixes = da->prefixes; + da->d_bits = DXR_D; + da->updates_low = 0; + da->updates_high = DIRECT_TBL_SIZE - 1; + } + +dxr2_try_squeeze: + if (trie_rebuild) { + /* Bulk cleanup */ + bzero(da->trietbl, sizeof(da->trietbl)); *** 351 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 E55B76547F0; Thu, 17 Jun 2021 14:54: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 4G5Q7l5y8cz4vNg; Thu, 17 Jun 2021 14:54: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 B08BE11787; Thu, 17 Jun 2021 14:54: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 15HEshKi010608; Thu, 17 Jun 2021 14:54:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEshLd010607; Thu, 17 Jun 2021 14:54:43 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:43 GMT Message-Id: <202106171454.15HEshLd010607@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: 14cde6b5b12d - stable/12 - VNETify dummynet 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: 14cde6b5b12d32d7d5374f3766c0e06ae0ca3303 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, 17 Jun 2021 14:54:44 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=14cde6b5b12d32d7d5374f3766c0e06ae0ca3303 commit 14cde6b5b12d32d7d5374f3766c0e06ae0ca3303 Author: Tom Jones AuthorDate: 2021-05-15 12:36:45 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 08:52:13 +0000 VNETify dummynet This moves dn_cfg and other parameters into per VNET variables. The taskqueue and control state remains global. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D29274 (cherry picked from commit fe3bcfbda30e763a3ec56083b3a19cebbeaf8952) --- sys/netpfil/ipfw/dn_aqm.h | 6 +- sys/netpfil/ipfw/dn_aqm_codel.c | 2 +- sys/netpfil/ipfw/dn_aqm_pie.c | 2 +- sys/netpfil/ipfw/dn_sched.h | 2 +- sys/netpfil/ipfw/dn_sched_fq_codel.c | 2 +- sys/netpfil/ipfw/dn_sched_fq_codel.h | 7 +- sys/netpfil/ipfw/dn_sched_fq_pie.c | 9 +- sys/netpfil/ipfw/ip_dn_glue.c | 8 +- sys/netpfil/ipfw/ip_dn_io.c | 181 ++++++++++++----------- sys/netpfil/ipfw/ip_dn_private.h | 41 +++--- sys/netpfil/ipfw/ip_dummynet.c | 271 +++++++++++++++++++---------------- 11 files changed, 281 insertions(+), 250 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index a8f6c39c0a8c..cffdbae11c2f 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -38,9 +38,9 @@ /* NOW is the current time in millisecond*/ -#define NOW ((dn_cfg.curr_time * tick) / 1000) +#define NOW ((V_dn_cfg.curr_time * tick) / 1000) -#define AQM_UNOW (dn_cfg.curr_time * tick) +#define AQM_UNOW (V_dn_cfg.curr_time * tick) #define AQM_TIME_1US ((aqm_time_t)(1)) #define AQM_TIME_1MS ((aqm_time_t)(1000)) #define AQM_TIME_1S ((aqm_time_t)(AQM_TIME_1MS * 1000)) @@ -135,7 +135,7 @@ update_stats(struct dn_queue *q, int len, int drop) if (drop) { qni->drops++; sni->drops++; - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; } else { /*update queue stats */ qni->length += inc; diff --git a/sys/netpfil/ipfw/dn_aqm_codel.c b/sys/netpfil/ipfw/dn_aqm_codel.c index 8e90dcdb1e5b..47ed971c6ba5 100644 --- a/sys/netpfil/ipfw/dn_aqm_codel.c +++ b/sys/netpfil/ipfw/dn_aqm_codel.c @@ -199,7 +199,7 @@ codel_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts) update_stats(q, -m->m_pkthdr.len, 0); if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; /* extract packet TS*/ mtag = m_tag_locate(m, MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, NULL); diff --git a/sys/netpfil/ipfw/dn_aqm_pie.c b/sys/netpfil/ipfw/dn_aqm_pie.c index e106fd0121f3..3b2fd8b96f0d 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.c +++ b/sys/netpfil/ipfw/dn_aqm_pie.c @@ -338,7 +338,7 @@ pie_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts, int getts) update_stats(q, -m->m_pkthdr.len, 0); if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; if (getts) { /* extract packet TS*/ diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h index 9bbd9019d623..1aa885ce3ccf 100644 --- a/sys/netpfil/ipfw/dn_sched.h +++ b/sys/netpfil/ipfw/dn_sched.h @@ -187,7 +187,7 @@ dn_dequeue(struct dn_queue *q) q->_si->ni.len_bytes -= m->m_pkthdr.len; } if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; return m; } diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.c b/sys/netpfil/ipfw/dn_sched_fq_codel.c index d2fe6a76f1cc..2f203bd60118 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.c +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.c @@ -163,7 +163,7 @@ codel_drop_head(struct fq_codel_flow *q, struct fq_codel_si *si) fq_update_stats(q, si, -m->m_pkthdr.len, 1); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; FREE_PKT(m); } diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index e8685caca8d3..608a288c6770 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -36,6 +36,9 @@ #ifndef _IP_DN_SCHED_FQ_CODEL_H #define _IP_DN_SCHED_FQ_CODEL_H +VNET_DECLARE(unsigned long, io_pkt_drop); +#define V_io_pkt_drop VNET(io_pkt_drop) + /* list of queues */ STAILQ_HEAD(fq_codel_list, fq_codel_flow) ; @@ -104,7 +107,7 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - dn_cfg.io_pkt_drop ++; + V_dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { @@ -147,7 +150,7 @@ fq_codel_extract_head(struct fq_codel_flow *q, aqm_time_t *pkt_ts, struct fq_cod fq_update_stats(q, si, -m->m_pkthdr.len, 0); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; /* extract packet timestamp*/ struct m_tag *mtag; diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index c791ee333bc6..07da51793a52 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -83,6 +83,9 @@ #define DN_SCHED_FQ_PIE 7 +VNET_DECLARE(unsigned long, io_pkt_drop); +#define V_io_pkt_drop VNET(io_pkt_drop) + /* list of queues */ STAILQ_HEAD(fq_pie_list, fq_pie_flow) ; @@ -299,7 +302,7 @@ fq_update_stats(struct fq_pie_flow *q, struct fq_pie_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - dn_cfg.io_pkt_drop ++; + V_dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { @@ -347,7 +350,7 @@ fq_pie_extract_head(struct fq_pie_flow *q, aqm_time_t *pkt_ts, fq_update_stats(q, si, -m->m_pkthdr.len, 0); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; if (getts) { /* extract packet timestamp*/ @@ -770,7 +773,7 @@ pie_drop_head(struct fq_pie_flow *q, struct fq_pie_si *si) fq_update_stats(q, si, -m->m_pkthdr.len, 1); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; /* reset accu_prob after packet drop */ q->pst.accu_prob = 0; diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index 7beb8525e30a..05552468599b 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -569,10 +569,10 @@ dn_compat_calc_size(void) * - all flowset queues: queue_count * - all pipe queue: si_count */ - need += dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2; - need += dn_cfg.fsk_count * sizeof(struct dn_flow_set); - need += dn_cfg.si_count * sizeof(struct dn_flow_queue8); - need += dn_cfg.queue_count * sizeof(struct dn_flow_queue8); + need += V_dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2; + need += V_dn_cfg.fsk_count * sizeof(struct dn_flow_set); + need += V_dn_cfg.si_count * sizeof(struct dn_flow_queue8); + need += V_dn_cfg.queue_count * sizeof(struct dn_flow_queue8); return need; } diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 56a7aa5c4c0c..d276f85311d1 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include #include #include @@ -73,11 +74,10 @@ __FBSDID("$FreeBSD$"); /* * We keep a private variable for the simulation time, but we could * probably use an existing one ("softticks" in sys/kern/kern_timeout.c) - * instead of dn_cfg.curr_time + * instead of V_dn_cfg.curr_time */ - -struct dn_parms dn_cfg; -//VNET_DEFINE(struct dn_parms, _base_dn_cfg); +VNET_DEFINE(struct dn_parms, dn_cfg); +#define V_dn_cfg VNET(dn_cfg) /* * We use a heap to store entities for which we have pending timer events. @@ -101,13 +101,13 @@ sysctl_hash_size(SYSCTL_HANDLER_ARGS) { int error, value; - value = dn_cfg.hash_size; + value = V_dn_cfg.hash_size; error = sysctl_handle_int(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) return (error); if (value < 16 || value > 65536) return (EINVAL); - dn_cfg.hash_size = value; + V_dn_cfg.hash_size = value; return (0); } @@ -118,9 +118,9 @@ sysctl_limits(SYSCTL_HANDLER_ARGS) long value; if (arg2 != 0) - value = dn_cfg.slot_limit; + value = V_dn_cfg.slot_limit; else - value = dn_cfg.byte_limit; + value = V_dn_cfg.byte_limit; error = sysctl_handle_long(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) @@ -128,11 +128,11 @@ sysctl_limits(SYSCTL_HANDLER_ARGS) if (arg2 != 0) { if (value < 1) return (EINVAL); - dn_cfg.slot_limit = value; + V_dn_cfg.slot_limit = value; } else { if (value < 1500) return (EINVAL); - dn_cfg.byte_limit = value; + V_dn_cfg.byte_limit = value; } return (0); } @@ -147,9 +147,9 @@ SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, CTLFLAG_RW, 0, "Dummynet"); static SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, CTLFLAG_RW, 0, "Dummynet"); #endif -/* wrapper to pass dn_cfg fields to SYSCTL_* */ -//#define DC(x) (&(VNET_NAME(_base_dn_cfg).x)) -#define DC(x) (&(dn_cfg.x)) +/* wrapper to pass V_dn_cfg fields to SYSCTL_* */ +#define DC(x) (&(VNET_NAME(dn_cfg).x)) + /* parameters */ @@ -344,7 +344,7 @@ red_drops (struct dn_queue *q, int len) * XXX check wraps... */ if (q->avg) { - u_int t = div64((dn_cfg.curr_time - q->q_time), fs->lookup_step); + u_int t = div64((V_dn_cfg.curr_time - q->q_time), fs->lookup_step); q->avg = (t < fs->lookup_depth) ? SCALE_MUL(q->avg, fs->w_q_lookup[t]) : 0; @@ -519,7 +519,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) return (0); drop: - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; q->ni.drops++; ni->drops++; FREE_PKT(m); @@ -548,7 +548,7 @@ transmit_event(struct mq *q, struct delay_line *dline, uint64_t now) } if (m != NULL) { dline->oid.subtype = 1; /* in heap */ - heap_insert(&dn_cfg.evheap, pkt->output_time, dline); + heap_insert(&V_dn_cfg.evheap, pkt->output_time, dline); } } @@ -611,7 +611,7 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) (m->m_pkthdr.len * 8 + extra_bits(m, s)); si->credit -= len_scaled; /* Move packet in the delay line */ - dn_tag_get(m)->output_time = dn_cfg.curr_time + s->link.delay ; + dn_tag_get(m)->output_time = V_dn_cfg.curr_time + s->link.delay ; mq_append(&si->dline.mq, m); } @@ -629,7 +629,7 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) if (m) dn_tag_get(m)->output_time += t; si->kflags |= DN_ACTIVE; - heap_insert(&dn_cfg.evheap, now + t, si); + heap_insert(&V_dn_cfg.evheap, now + t, si); } if (delay_line_idle && done) transmit_event(q, &si->dline, now); @@ -646,74 +646,85 @@ dummynet_task(void *context, int pending) { struct timeval t; struct mq q = { NULL, NULL }; /* queue to accumulate results */ + struct epoch_tracker et; - CURVNET_SET((struct vnet *)context); + VNET_ITERATOR_DECL(vnet_iter); + VNET_LIST_RLOCK(); + NET_EPOCH_ENTER_ET(et); - DN_BH_WLOCK(); + VNET_FOREACH(vnet_iter) { + memset(&q, 0, sizeof(struct mq)); + CURVNET_SET(vnet_iter); - /* Update number of lost(coalesced) ticks. */ - dn_cfg.tick_lost += pending - 1; + DN_BH_WLOCK(); - getmicrouptime(&t); - /* Last tick duration (usec). */ - dn_cfg.tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + - (t.tv_usec - dn_cfg.prev_t.tv_usec); - /* Last tick vs standard tick difference (usec). */ - dn_cfg.tick_delta = (dn_cfg.tick_last * hz - 1000000) / hz; - /* Accumulated tick difference (usec). */ - dn_cfg.tick_delta_sum += dn_cfg.tick_delta; + /* Update number of lost(coalesced) ticks. */ + V_dn_cfg.tick_lost += pending - 1; - dn_cfg.prev_t = t; + getmicrouptime(&t); + /* Last tick duration (usec). */ + V_dn_cfg.tick_last = (t.tv_sec - V_dn_cfg.prev_t.tv_sec) * 1000000 + + (t.tv_usec - V_dn_cfg.prev_t.tv_usec); + /* Last tick vs standard tick difference (usec). */ + V_dn_cfg.tick_delta = (V_dn_cfg.tick_last * hz - 1000000) / hz; + /* Accumulated tick difference (usec). */ + V_dn_cfg.tick_delta_sum += V_dn_cfg.tick_delta; - /* - * Adjust curr_time if the accumulated tick difference is - * greater than the 'standard' tick. Since curr_time should - * be monotonically increasing, we do positive adjustments - * as required, and throttle curr_time in case of negative - * adjustment. - */ - dn_cfg.curr_time++; - if (dn_cfg.tick_delta_sum - tick >= 0) { - int diff = dn_cfg.tick_delta_sum / tick; - - dn_cfg.curr_time += diff; - dn_cfg.tick_diff += diff; - dn_cfg.tick_delta_sum %= tick; - dn_cfg.tick_adjustment++; - } else if (dn_cfg.tick_delta_sum + tick <= 0) { - dn_cfg.curr_time--; - dn_cfg.tick_diff--; - dn_cfg.tick_delta_sum += tick; - dn_cfg.tick_adjustment++; - } + V_dn_cfg.prev_t = t; - /* serve pending events, accumulate in q */ - for (;;) { - struct dn_id *p; /* generic parameter to handler */ + /* + * Adjust curr_time if the accumulated tick difference is + * greater than the 'standard' tick. Since curr_time should + * be monotonically increasing, we do positive adjustments + * as required, and throttle curr_time in case of negative + * adjustment. + */ + V_dn_cfg.curr_time++; + if (V_dn_cfg.tick_delta_sum - tick >= 0) { + int diff = V_dn_cfg.tick_delta_sum / tick; + + V_dn_cfg.curr_time += diff; + V_dn_cfg.tick_diff += diff; + V_dn_cfg.tick_delta_sum %= tick; + V_dn_cfg.tick_adjustment++; + } else if (V_dn_cfg.tick_delta_sum + tick <= 0) { + V_dn_cfg.curr_time--; + V_dn_cfg.tick_diff--; + V_dn_cfg.tick_delta_sum += tick; + V_dn_cfg.tick_adjustment++; + } - if (dn_cfg.evheap.elements == 0 || - DN_KEY_LT(dn_cfg.curr_time, HEAP_TOP(&dn_cfg.evheap)->key)) - break; - p = HEAP_TOP(&dn_cfg.evheap)->object; - heap_extract(&dn_cfg.evheap, NULL); + /* serve pending events, accumulate in q */ + for (;;) { + struct dn_id *p; /* generic parameter to handler */ - if (p->type == DN_SCH_I) { - serve_sched(&q, (struct dn_sch_inst *)p, dn_cfg.curr_time); - } else { /* extracted a delay line */ - transmit_event(&q, (struct delay_line *)p, dn_cfg.curr_time); + if (V_dn_cfg.evheap.elements == 0 || + DN_KEY_LT(V_dn_cfg.curr_time, HEAP_TOP(&V_dn_cfg.evheap)->key)) + break; + p = HEAP_TOP(&V_dn_cfg.evheap)->object; + heap_extract(&V_dn_cfg.evheap, NULL); + if (p->type == DN_SCH_I) { + serve_sched(&q, (struct dn_sch_inst *)p, V_dn_cfg.curr_time); + } else { /* extracted a delay line */ + transmit_event(&q, (struct delay_line *)p, V_dn_cfg.curr_time); + } } + if (V_dn_cfg.expire && ++V_dn_cfg.expire_cycle >= V_dn_cfg.expire) { + V_dn_cfg.expire_cycle = 0; + dn_drain_scheduler(); + dn_drain_queue(); + } + DN_BH_WUNLOCK(); + if (q.head != NULL) + dummynet_send(q.head); + + CURVNET_RESTORE(); } - if (dn_cfg.expire && ++dn_cfg.expire_cycle >= dn_cfg.expire) { - dn_cfg.expire_cycle = 0; - dn_drain_scheduler(); - dn_drain_queue(); - } + NET_EPOCH_EXIT_ET(et); + VNET_LIST_RUNLOCK(); + /* Schedule our next run. */ dn_reschedule(); - DN_BH_WUNLOCK(); - if (q.head != NULL) - dummynet_send(q.head); - CURVNET_RESTORE(); } /* @@ -827,7 +838,7 @@ tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa) dt->dn_dir = dir; dt->ifp = fwa->oif; /* dt->output tame is updated as we move through */ - dt->output_time = dn_cfg.curr_time; + dt->output_time = V_dn_cfg.curr_time; dt->iphdr_off = (dir & PROTO_LAYER2) ? ETHER_HDR_LEN : 0; return 0; } @@ -855,12 +866,12 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) int fs_id = (fwa->rule.info & IPFW_INFO_MASK) + ((fwa->rule.info & IPFW_IS_PIPE) ? 2*DN_MAX_ID : 0); DN_BH_WLOCK(); - dn_cfg.io_pkt++; + V_dn_cfg.io_pkt++; /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; /* XXX locate_flowset could be optimised with a direct ref. */ - fs = dn_ht_find(dn_cfg.fshash, fs_id, 0, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, fs_id, 0, NULL); if (fs == NULL) goto dropit; /* This queue/pipe does not exist! */ if (fs->sched == NULL) /* should not happen */ @@ -883,7 +894,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) m = *m0 = NULL; /* dn_enqueue already increases io_pkt_drop */ - dn_cfg.io_pkt_drop--; + V_dn_cfg.io_pkt_drop--; goto dropit; } @@ -894,34 +905,34 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) } /* compute the initial allowance */ - if (si->idle_time < dn_cfg.curr_time) { + if (si->idle_time < V_dn_cfg.curr_time) { /* Do this only on the first packet on an idle pipe */ struct dn_link *p = &fs->sched->link; - si->sched_time = dn_cfg.curr_time; - si->credit = dn_cfg.io_fast ? p->bandwidth : 0; + si->sched_time = V_dn_cfg.curr_time; + si->credit = V_dn_cfg.io_fast ? p->bandwidth : 0; if (p->burst) { - uint64_t burst = (dn_cfg.curr_time - si->idle_time) * p->bandwidth; + uint64_t burst = (V_dn_cfg.curr_time - si->idle_time) * p->bandwidth; if (burst > p->burst) burst = p->burst; si->credit += burst; } } /* pass through scheduler and delay line */ - m = serve_sched(NULL, si, dn_cfg.curr_time); + m = serve_sched(NULL, si, V_dn_cfg.curr_time); /* optimization -- pass it back to ipfw for immediate send */ /* XXX Don't call dummynet_send() if scheduler return the packet * just enqueued. This avoid a lock order reversal. * */ - if (/*dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { + if (/*V_dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { /* fast io, rename the tag * to carry reinject info. */ struct m_tag *tag = m_tag_first(m); tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; - dn_cfg.io_pkt_fast++; + V_dn_cfg.io_pkt_fast++; if (m->m_nextpkt != NULL) { printf("dummynet: fast io: pkt chain detected!\n"); m->m_nextpkt = NULL; @@ -937,7 +948,7 @@ done: return 0; dropit: - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; DN_BH_WUNLOCK(); if (m) FREE_PKT(m); diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 86dd5a8a0cbb..8f8fca5fbd58 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -46,7 +46,7 @@ #define D(fmt, ...) printf("%-10s " fmt "\n", \ __FUNCTION__, ## __VA_ARGS__) #define DX(lev, fmt, ...) do { \ - if (dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) + if (V_dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) #endif MALLOC_DECLARE(M_DUMMYNET); @@ -56,26 +56,26 @@ MALLOC_DECLARE(M_DUMMYNET); #endif #define DN_LOCK_INIT() do { \ - mtx_init(&dn_cfg.uh_mtx, "dn_uh", NULL, MTX_DEF); \ - mtx_init(&dn_cfg.bh_mtx, "dn_bh", NULL, MTX_DEF); \ + mtx_init(&V_dn_cfg.uh_mtx, "dn_uh", NULL, MTX_DEF); \ + mtx_init(&V_dn_cfg.bh_mtx, "dn_bh", NULL, MTX_DEF); \ } while (0) #define DN_LOCK_DESTROY() do { \ - mtx_destroy(&dn_cfg.uh_mtx); \ - mtx_destroy(&dn_cfg.bh_mtx); \ + mtx_destroy(&V_dn_cfg.uh_mtx); \ + mtx_destroy(&V_dn_cfg.bh_mtx); \ } while (0) #if 0 /* not used yet */ -#define DN_UH_RLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_UH_RUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_UH_WLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_UH_WUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_UH_LOCK_ASSERT() mtx_assert(&dn_cfg.uh_mtx, MA_OWNED) +#define DN_UH_RLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_UH_RUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_UH_WLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_UH_WUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_UH_LOCK_ASSERT() mtx_assert(&V_dn_cfg.uh_mtx, MA_OWNED) #endif -#define DN_BH_RLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_BH_RUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_BH_WLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_BH_WUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_BH_LOCK_ASSERT() mtx_assert(&dn_cfg.uh_mtx, MA_OWNED) +#define DN_BH_RLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_BH_RUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_BH_WLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_BH_WUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_BH_LOCK_ASSERT() mtx_assert(&V_dn_cfg.uh_mtx, MA_OWNED) SLIST_HEAD(dn_schk_head, dn_schk); SLIST_HEAD(dn_sch_inst_head, dn_sch_inst); @@ -101,7 +101,7 @@ set_oid(struct dn_id *o, int type, int len) } /* - * configuration and global data for a dummynet instance + * configuration and data for a dummynet instance * * When a configuration is modified from userland, 'id' is incremented * so we can use the value to check for stale pointers. @@ -154,10 +154,6 @@ struct dn_parms { struct dn_ht *schedhash; /* list of flowsets without a scheduler -- use sch_chain */ struct dn_fsk_head fsu; /* list of unlinked flowsets */ - struct dn_alg_head schedlist; /* list of algorithms */ -#ifdef NEW_AQM - struct dn_aqm_head aqmlist; /* list of AQMs */ -#endif /* Store the fs/sch to scan when draining. The value is the * bucket number of the hash table. Expire can be disabled @@ -393,9 +389,8 @@ struct dn_pkt_tag { uint16_t iphdr_off; /* IP header offset for mtodo() */ }; -extern struct dn_parms dn_cfg; -//VNET_DECLARE(struct dn_parms, _base_dn_cfg); -//#define dn_cfg VNET(_base_dn_cfg) +VNET_DECLARE(struct dn_parms, dn_cfg); +#define V_dn_cfg VNET(dn_cfg) int dummynet_io(struct mbuf **, int , struct ip_fw_args *); void dummynet_task(void *context, int pending); diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index ab2c0cdfcd05..7eee314ea705 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include /* ip_output(), IP_FORWARDING */ #include #include +#include #include #include @@ -87,10 +88,17 @@ struct schk_new_arg { /*---- callout hooks. ----*/ static struct callout dn_timeout; +static int dn_tasks_started = 0; static int dn_gone; static struct task dn_task; static struct taskqueue *dn_tq = NULL; +/* global scheduler list */ +struct dn_alg_head schedlist; +#ifdef NEW_AQM +struct dn_aqm_head aqmlist; /* list of AQMs */ +#endif + static void dummynet(void *arg) { @@ -117,7 +125,7 @@ find_aqm_type(int type, char *name) { struct dn_aqm *d; - SLIST_FOREACH(d, &dn_cfg.aqmlist, next) { + SLIST_FOREACH(d, &aqmlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -131,7 +139,7 @@ find_sched_type(int type, char *name) { struct dn_alg *d; - SLIST_FOREACH(d, &dn_cfg.schedlist, next) { + SLIST_FOREACH(d, &schedlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -354,7 +362,7 @@ q_new(uintptr_t key, int flags, void *arg) if(fs->aqmfp->init(q)) D("unable to init AQM for fs %d", fs->fs.fs_nr); #endif - dn_cfg.queue_count++; + V_dn_cfg.queue_count++; return q; } @@ -387,7 +395,7 @@ dn_delete_queue(struct dn_queue *q, int flags) dn_free_pkts(q->mq.head); bzero(q, sizeof(*q)); // safety free(q, M_DUMMYNET); - dn_cfg.queue_count--; + V_dn_cfg.queue_count--; } } @@ -527,7 +535,7 @@ si_new(uintptr_t key, int flags, void *arg) } #endif - dn_cfg.si_count++; + V_dn_cfg.si_count++; return si; error: @@ -552,10 +560,10 @@ si_destroy(void *_si, void *arg) struct delay_line *dl = &si->dline; if (dl->oid.subtype) /* remove delay line from event heap */ - heap_extract(&dn_cfg.evheap, dl); + heap_extract(&V_dn_cfg.evheap, dl); dn_free_pkts(dl->mq.head); /* drain delay line */ if (si->kflags & DN_ACTIVE) /* remove si from event heap */ - heap_extract(&dn_cfg.evheap, si); + heap_extract(&V_dn_cfg.evheap, si); #ifdef NEW_AQM /* clean up AQM status for !DN_MULTIQUEUE sched @@ -574,7 +582,7 @@ si_destroy(void *_si, void *arg) s->fp->free_sched(si); bzero(si, sizeof(*si)); /* safety */ free(si, M_DUMMYNET); - dn_cfg.si_count--; + V_dn_cfg.si_count--; return DNHT_SCAN_DEL; } @@ -605,7 +613,7 @@ si_reset_credit(void *_si, void *arg) struct dn_sch_inst *si = _si; struct dn_link *p = &si->sched->link; - si->credit = p->burst + (dn_cfg.io_fast ? p->bandwidth : 0); + si->credit = p->burst + (V_dn_cfg.io_fast ? p->bandwidth : 0); return 0; } @@ -651,9 +659,9 @@ fsk_new(uintptr_t key, int flags, void *arg) fs = malloc(sizeof(*fs), M_DUMMYNET, M_NOWAIT | M_ZERO); if (fs) { set_oid(&fs->fs.oid, DN_FS, sizeof(fs->fs)); - dn_cfg.fsk_count++; + V_dn_cfg.fsk_count++; fs->drain_bucket = 0; - SLIST_INSERT_HEAD(&dn_cfg.fsu, fs, sch_chain); + SLIST_INSERT_HEAD(&V_dn_cfg.fsu, fs, sch_chain); } return fs; } @@ -737,7 +745,7 @@ fsk_detach(struct dn_fsk *fs, int flags) (flags & DN_DETACH) ? "DET":""); if (flags & DN_DETACH) { /* detach from the list */ struct dn_fsk_head *h; - h = fs->sched ? &fs->sched->fsk_list : &dn_cfg.fsu; + h = fs->sched ? &fs->sched->fsk_list : &V_dn_cfg.fsu; SLIST_REMOVE(h, fs, dn_fsk, sch_chain); } /* Free the RED parameters, they will be recomputed on @@ -757,9 +765,9 @@ fsk_detach(struct dn_fsk *fs, int flags) if (flags & DN_DELETE_FS) { bzero(fs, sizeof(*fs)); /* safety */ free(fs, M_DUMMYNET); - dn_cfg.fsk_count--; + V_dn_cfg.fsk_count--; } else { - SLIST_INSERT_HEAD(&dn_cfg.fsu, fs, sch_chain); + SLIST_INSERT_HEAD(&V_dn_cfg.fsu, fs, sch_chain); } } @@ -797,7 +805,7 @@ delete_fs(int i, int locked) if (!locked) DN_BH_WLOCK(); - fs = dn_ht_find(dn_cfg.fshash, i, DNHT_REMOVE, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, i, DNHT_REMOVE, NULL); ND("fs %d found %p", i, fs); if (fs) { fsk_detach(fs, DN_DETACH | DN_DELETE_FS); @@ -866,7 +874,7 @@ schk_new(uintptr_t key, int flags, void *arg) } } s->fp = NULL; /* mark as a new scheduler */ - dn_cfg.schk_count++; + V_dn_cfg.schk_count++; return s; } @@ -905,7 +913,7 @@ schk_delete_cb(void *obj, void *arg) s->fp->destroy(s); bzero(s, sizeof(*s)); // safety free(obj, M_DUMMYNET); - dn_cfg.schk_count--; + V_dn_cfg.schk_count--; return DNHT_SCAN_DEL; } @@ -919,7 +927,7 @@ delete_schk(int i) { struct dn_schk *s; - s = dn_ht_find(dn_cfg.schedhash, i, DNHT_REMOVE, NULL); + s = dn_ht_find(V_dn_cfg.schedhash, i, DNHT_REMOVE, NULL); ND("%d %p", i, s); if (!s) return EINVAL; @@ -1176,7 +1184,7 @@ copy_data_helper(void *_o, void *_arg) static inline struct dn_schk * locate_scheduler(int i) { - return dn_ht_find(dn_cfg.schedhash, i, 0, NULL); + return dn_ht_find(V_dn_cfg.schedhash, i, 0, NULL); } /* @@ -1194,10 +1202,10 @@ config_red(struct dn_fsk *fs) /* Doing stuff that was in userland */ i = fs->sched->link.bandwidth; s = (i <= 0) ? 0 : - hz * dn_cfg.red_avg_pkt_size * 8 * SCALE(1) / i; + hz * V_dn_cfg.red_avg_pkt_size * 8 * SCALE(1) / i; idle = div64((s * 3) , fs->w_q); /* s, fs->w_q scaled; idle not scaled */ - fs->lookup_step = div64(idle , dn_cfg.red_lookup_depth); + fs->lookup_step = div64(idle , V_dn_cfg.red_lookup_depth); /* fs->lookup_step not scaled, */ if (!fs->lookup_step) fs->lookup_step = 1; @@ -1227,14 +1235,14 @@ config_red(struct dn_fsk *fs) free(fs->w_q_lookup, M_DUMMYNET); fs->w_q_lookup = NULL; } - if (dn_cfg.red_lookup_depth == 0) { + if (V_dn_cfg.red_lookup_depth == 0) { printf("\ndummynet: net.inet.ip.dummynet.red_lookup_depth" "must be > 0\n"); fs->fs.flags &= ~DN_IS_RED; fs->fs.flags &= ~DN_IS_GENTLE_RED; return (EINVAL); } - fs->lookup_depth = dn_cfg.red_lookup_depth; + fs->lookup_depth = V_dn_cfg.red_lookup_depth; fs->w_q_lookup = (u_int *)malloc(fs->lookup_depth * sizeof(int), M_DUMMYNET, M_NOWAIT); if (fs->w_q_lookup == NULL) { @@ -1251,12 +1259,12 @@ config_red(struct dn_fsk *fs) fs->w_q_lookup[i] = SCALE_MUL(fs->w_q_lookup[i - 1], fs->lookup_weight); - if (dn_cfg.red_avg_pkt_size < 1) - dn_cfg.red_avg_pkt_size = 512; - fs->avg_pkt_size = dn_cfg.red_avg_pkt_size; - if (dn_cfg.red_max_pkt_size < 1) - dn_cfg.red_max_pkt_size = 1500; - fs->max_pkt_size = dn_cfg.red_max_pkt_size; + if (V_dn_cfg.red_avg_pkt_size < 1) + V_dn_cfg.red_avg_pkt_size = 512; + fs->avg_pkt_size = V_dn_cfg.red_avg_pkt_size; + if (V_dn_cfg.red_max_pkt_size < 1) + V_dn_cfg.red_max_pkt_size = 1500; + fs->max_pkt_size = V_dn_cfg.red_max_pkt_size; ND("exit"); return 0; } @@ -1278,7 +1286,7 @@ fsk_attach(struct dn_fsk *fs, struct dn_schk *s) { ND("remove fs %d from fsunlinked, link to sched %d", fs->fs.fs_nr, s->sch.sched_nr); - SLIST_REMOVE(&dn_cfg.fsu, fs, dn_fsk, sch_chain); + SLIST_REMOVE(&V_dn_cfg.fsu, fs, dn_fsk, sch_chain); fs->sched = s; SLIST_INSERT_HEAD(&s->fsk_list, fs, sch_chain); if (s->fp->new_fsk) @@ -1317,7 +1325,7 @@ update_fs(struct dn_schk *s) { struct dn_fsk *fs, *tmp; - SLIST_FOREACH_SAFE(fs, &dn_cfg.fsu, sch_chain, tmp) { + SLIST_FOREACH_SAFE(fs, &V_dn_cfg.fsu, sch_chain, tmp) { if (s->sch.sched_nr != fs->fs.sched_nr) { D("fs %d for sch %d not %d still unlinked", fs->fs.fs_nr, fs->fs.sched_nr, @@ -1362,7 +1370,7 @@ get_aqm_parms(struct sockopt *sopt) break; } - fs = dn_ht_find(dn_cfg.fshash, ep->nr, 0, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, ep->nr, 0, NULL); if (!fs) { D("fs %d not found", ep->nr); err = EINVAL; @@ -1579,7 +1587,7 @@ config_link(struct dn_link *p, struct dn_id *arg) s->link.burst = p->burst; schk_reset_credit(s); } - dn_cfg.id++; + V_dn_cfg.id++; DN_BH_WUNLOCK(); return 0; } @@ -1616,15 +1624,15 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) /* XXX other sanity checks */ if (nfs->flags & DN_QSIZE_BYTES) { ipdn_bound_var(&nfs->qsize, 16384, - 1500, dn_cfg.byte_limit, NULL); // "queue byte size"); + 1500, V_dn_cfg.byte_limit, NULL); // "queue byte size"); } else { ipdn_bound_var(&nfs->qsize, 50, - 1, dn_cfg.slot_limit, NULL); // "queue slot size"); + 1, V_dn_cfg.slot_limit, NULL); // "queue slot size"); } if (nfs->flags & DN_HAVE_MASK) { /* make sure we have some buckets */ - ipdn_bound_var((int *)&nfs->buckets, dn_cfg.hash_size, - 1, dn_cfg.max_hash_size, "flowset buckets"); + ipdn_bound_var((int *)&nfs->buckets, V_dn_cfg.hash_size, + 1, V_dn_cfg.max_hash_size, "flowset buckets"); } else { nfs->buckets = 1; /* we only need 1 */ } @@ -1634,8 +1642,8 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) struct dn_schk *s; int flags = nfs->sched_nr ? DNHT_INSERT : 0; int j; - int oldc = dn_cfg.fsk_count; - fs = dn_ht_find(dn_cfg.fshash, i, flags, NULL); + int oldc = V_dn_cfg.fsk_count; + fs = dn_ht_find(V_dn_cfg.fshash, i, flags, NULL); if (fs == NULL) { D("missing sched for flowset %d", i); break; @@ -1662,8 +1670,8 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) #endif break; /* no change, nothing to do */ } - if (oldc != dn_cfg.fsk_count) /* new item */ - dn_cfg.id++; + if (oldc != V_dn_cfg.fsk_count) /* new item */ + V_dn_cfg.id++; s = locate_scheduler(nfs->sched_nr); /* detach from old scheduler if needed, preserving * queues if we need to reattach. Then update the @@ -1729,8 +1737,8 @@ config_sched(struct dn_sch *_nsch, struct dn_id *arg) return EINVAL; /* make sure we have some buckets */ if (a.sch->flags & DN_HAVE_MASK) - ipdn_bound_var((int *)&a.sch->buckets, dn_cfg.hash_size, - 1, dn_cfg.max_hash_size, "sched buckets"); + ipdn_bound_var((int *)&a.sch->buckets, V_dn_cfg.hash_size, + 1, V_dn_cfg.max_hash_size, "sched buckets"); /* XXX other sanity checks */ bzero(&p, sizeof(p)); @@ -1748,14 +1756,14 @@ again: /* run twice, for wfq and fifo */ * lookup the type. If not supplied, use the previous one * or default to WF2Q+. Otherwise, return an error. */ - dn_cfg.id++; + V_dn_cfg.id++; a.fp = find_sched_type(a.sch->oid.subtype, a.sch->name); if (a.fp != NULL) { /* found. Lookup or create entry */ - s = dn_ht_find(dn_cfg.schedhash, i, DNHT_INSERT, &a); + s = dn_ht_find(V_dn_cfg.schedhash, i, DNHT_INSERT, &a); } else if (a.sch->oid.subtype == 0 && !a.sch->name[0]) { /* No type. search existing s* or retry with WF2Q+ */ - s = dn_ht_find(dn_cfg.schedhash, i, 0, &a); + s = dn_ht_find(V_dn_cfg.schedhash, i, 0, &a); if (s != NULL) { a.fp = s->fp; /* Scheduler exists, skip to FIFO scheduler @@ -1827,7 +1835,7 @@ again: /* run twice, for wfq and fifo */ memcpy(pf, s->profile, sizeof(*pf)); } /* remove from the hash */ - dn_ht_find(dn_cfg.schedhash, i, DNHT_REMOVE, NULL); + dn_ht_find(V_dn_cfg.schedhash, i, DNHT_REMOVE, NULL); *** 390 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 0FCE26543A4; Thu, 17 Jun 2021 14:54: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 4G5Q7m6fpCz4vTS; Thu, 17 Jun 2021 14:54: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 CAE1B11567; Thu, 17 Jun 2021 14:54: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 15HEsirZ010632; Thu, 17 Jun 2021 14:54:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsiNU010631; Thu, 17 Jun 2021 14:54:44 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:44 GMT Message-Id: <202106171454.15HEsiNU010631@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: bc90a9cb0a74 - stable/12 - dummynet: Fix schedlist and aqmlist locking 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: bc90a9cb0a741315ed6a43807b781acd2bd0957c 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, 17 Jun 2021 14:54:45 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bc90a9cb0a741315ed6a43807b781acd2bd0957c commit bc90a9cb0a741315ed6a43807b781acd2bd0957c Author: Kristof Provost AuthorDate: 2021-05-21 12:26:49 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 14:53:36 +0000 dummynet: Fix schedlist and aqmlist locking These are global (i.e. shared across vnets) structures, so we need global lock to protect them. However, we look up entries in these lists (find_aqm_type(), find_sched_type()) and return them. We must ensure that the returned structures cannot go away while we are using them. Resolve this by using NET_EPOCH(). The structures can be safely accessed under it, and we postpone their cleanup until we're sure they're no longer used. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30381 (cherry picked from commit 51d73df18e4d120f6f062062c18efae3ed5193a6) --- sys/netpfil/ipfw/dn_aqm.h | 3 +- sys/netpfil/ipfw/dn_sched.h | 4 +- sys/netpfil/ipfw/ip_dn_glue.c | 6 +- sys/netpfil/ipfw/ip_dummynet.c | 123 +++++++++++++++++++++++++++++------------ 4 files changed, 98 insertions(+), 38 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index cffdbae11c2f..143d82154f9e 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -36,6 +36,7 @@ #ifndef _IP_DN_AQM_H #define _IP_DN_AQM_H +#include /* NOW is the current time in millisecond*/ #define NOW ((V_dn_cfg.curr_time * tick) / 1000) @@ -108,7 +109,7 @@ typedef int32_t aqm_stime_t; int ref_count; /*Number of queues instances in the system */ int cfg_ref_count; /*Number of AQM instances in the system */ - SLIST_ENTRY (dn_aqm) next; /* Next AQM in the list */ + CK_LIST_ENTRY(dn_aqm) next; /* Next AQM in the list */ }; /* Helper function to update queue and scheduler statistics. diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h index 1aa885ce3ccf..5c506c1d30ac 100644 --- a/sys/netpfil/ipfw/dn_sched.h +++ b/sys/netpfil/ipfw/dn_sched.h @@ -35,6 +35,8 @@ #ifndef _DN_SCHED_H #define _DN_SCHED_H +#include + #define DN_MULTIQUEUE 0x01 /* * Descriptor for a scheduling algorithm. @@ -141,7 +143,7 @@ struct dn_alg { /* run-time fields */ int ref_count; /* XXX number of instances in the system */ - SLIST_ENTRY(dn_alg) next; /* Next scheduler in the list */ + CK_LIST_ENTRY(dn_alg) next; /* Next scheduler in the list */ }; /* MSVC does not support initializers so we need this ugly macro */ diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index 05552468599b..cfea43110c9e 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -817,7 +817,11 @@ ip_dummynet_compat(struct sockopt *sopt) break; case IP_DUMMYNET_CONFIGURE: - v = malloc(len, M_TEMP, M_WAITOK); + v = malloc(len, M_TEMP, M_NOWAIT); + if (v == NULL) { + error = ENOMEM; + break; + } error = sooptcopyin(sopt, v, len, len); if (error) break; diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index 7eee314ea705..c412a45f7296 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include +#include #include #include #include @@ -59,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ +#include #include #include /* ip_output(), IP_FORWARDING */ #include @@ -94,9 +96,10 @@ static struct task dn_task; static struct taskqueue *dn_tq = NULL; /* global scheduler list */ -struct dn_alg_head schedlist; +struct mtx sched_mtx; +CK_LIST_HEAD(, dn_alg) schedlist; #ifdef NEW_AQM -struct dn_aqm_head aqmlist; /* list of AQMs */ +CK_LIST_HEAD(, dn_aqm) aqmlist; /* list of AQMs */ #endif static void @@ -125,7 +128,9 @@ find_aqm_type(int type, char *name) { struct dn_aqm *d; - SLIST_FOREACH(d, &aqmlist, next) { + MPASS(in_epoch(net_epoch_preempt)); + + CK_LIST_FOREACH(d, &aqmlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -139,7 +144,9 @@ find_sched_type(int type, char *name) { struct dn_alg *d; - SLIST_FOREACH(d, &schedlist, next) { + MPASS(in_epoch(net_epoch_preempt)); + + CK_LIST_FOREACH(d, &schedlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -1355,7 +1362,7 @@ get_aqm_parms(struct sockopt *sopt) err = EINVAL; return err; } - ep = malloc(l, M_DUMMYNET, M_WAITOK); + ep = malloc(l, M_DUMMYNET, M_NOWAIT); if(!ep) { err = ENOMEM ; return err; @@ -1410,7 +1417,7 @@ get_sched_parms(struct sockopt *sopt) err = EINVAL; return err; } - ep = malloc(l, M_DUMMYNET, M_WAITOK); + ep = malloc(l, M_DUMMYNET, M_NOWAIT); if(!ep) { err = ENOMEM ; return err; @@ -1455,6 +1462,8 @@ config_aqm(struct dn_fsk *fs, struct dn_extra_parms *ep, int busy) { int err = 0; + MPASS(in_epoch(net_epoch_preempt)); + do { /* no configurations */ if (!ep) { @@ -1614,7 +1623,7 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) #ifdef NEW_AQM ep = NULL; if (arg != NULL) { - ep = malloc(sizeof(*ep), M_TEMP, locked ? M_NOWAIT : M_WAITOK); + ep = malloc(sizeof(*ep), M_TEMP, M_NOWAIT); if (ep == NULL) return (NULL); memcpy(ep, arg, sizeof(*ep)); @@ -1727,6 +1736,8 @@ config_sched(struct dn_sch *_nsch, struct dn_id *arg) int pipe_cmd; int err = ENOMEM; + MPASS(in_epoch(net_epoch_preempt)); + a.sch = _nsch; if (a.sch->oid.len != sizeof(*a.sch)) { D("bad sched len %d", a.sch->oid.len); @@ -2070,34 +2081,53 @@ do_config(void *p, int l) DN_BH_WUNLOCK(); break; case DN_TEXT: /* store argument of next block */ - if (arg != NULL) - free(arg, M_TEMP); - arg = malloc(o.len, M_TEMP, M_WAITOK); + free(arg, M_TEMP); + arg = malloc(o.len, M_TEMP, M_NOWAIT); + if (arg == NULL) { + err = ENOMEM; + break; + } memcpy(arg, (char *)p + off, o.len); break; case DN_LINK: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->link, (char *)p + off, sizeof(dn->link)); err = config_link(&dn->link, arg); break; case DN_PROFILE: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->profile, (char *)p + off, sizeof(dn->profile)); err = config_profile(&dn->profile, arg); break; case DN_SCH: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->sched, (char *)p + off, sizeof(dn->sched)); err = config_sched(&dn->sched, arg); break; case DN_FS: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->fs, (char *)p + off, sizeof(dn->fs)); err = (NULL == config_fs(&dn->fs, arg, 0)); break; @@ -2230,7 +2260,11 @@ dummynet_get(struct sockopt *sopt, void **compat) #endif if (l > sizeof(r)) { /* request larger than default, allocate buffer */ - cmd = malloc(l, M_DUMMYNET, M_WAITOK); + cmd = malloc(l, M_DUMMYNET, M_NOWAIT); + if (cmd == NULL) { + error = ENOMEM; + goto done; + } error = sooptcopyin(sopt, cmd, l, l); sopt->sopt_valsize = sopt_valsize; if (error) @@ -2298,7 +2332,7 @@ dummynet_get(struct sockopt *sopt, void **compat) break; have = need; - start = malloc(have, M_DUMMYNET, M_WAITOK | M_ZERO); + start = malloc(have, M_DUMMYNET, M_NOWAIT | M_ZERO); } if (start == NULL) { @@ -2461,6 +2495,7 @@ dn_drain_queue(void) static int ip_dn_ctl(struct sockopt *sopt) { + struct epoch_tracker et; void *p = NULL; int error, l; @@ -2475,6 +2510,8 @@ ip_dn_ctl(struct sockopt *sopt) return (error); } + NET_EPOCH_ENTER_ET(et); + switch (sopt->sopt_name) { default : D("dummynet: unknown option %d", sopt->sopt_name); @@ -2499,7 +2536,11 @@ ip_dn_ctl(struct sockopt *sopt) D("argument len %d invalid", l); break; } - p = malloc(l, M_TEMP, M_WAITOK); // XXX can it fail ? + p = malloc(l, M_TEMP, M_NOWAIT); + if (p == NULL) { + error = ENOMEM; + break; + } error = sooptcopyin(sopt, p, l, l); if (error) break ; @@ -2510,6 +2551,8 @@ ip_dn_ctl(struct sockopt *sopt) if (p != NULL) free(p, M_TEMP); + NET_EPOCH_EXIT_ET(et); + return error ; } @@ -2579,13 +2622,16 @@ ip_dn_init(void) { if (dn_tasks_started) return; + + mtx_init(&sched_mtx, "dn_sched", NULL, MTX_DEF); + dn_tasks_started = 1; TASK_INIT(&dn_task, 0, dummynet_task, NULL); dn_tq = taskqueue_create_fast("dummynet", M_WAITOK, taskqueue_thread_enqueue, &dn_tq); taskqueue_start_threads(&dn_tq, 1, PI_NET, "dummynet"); - SLIST_INIT(&schedlist); + CK_LIST_INIT(&schedlist); callout_init(&dn_timeout, 1); dn_reschedule(); } @@ -2645,16 +2691,16 @@ load_dn_sched(struct dn_alg *d) } /* Search if scheduler already exists */ - DN_BH_WLOCK(); - SLIST_FOREACH(s, &schedlist, next) { + mtx_lock(&sched_mtx); + CK_LIST_FOREACH(s, &schedlist, next) { if (strcmp(s->name, d->name) == 0) { D("%s already loaded", d->name); break; /* scheduler already exists */ } } if (s == NULL) - SLIST_INSERT_HEAD(&schedlist, d, next); - DN_BH_WUNLOCK(); + CK_LIST_INSERT_HEAD(&schedlist, d, next); + mtx_unlock(&sched_mtx); D("dn_sched %s %sloaded", d->name, s ? "not ":""); return s ? 1 : 0; } @@ -2667,17 +2713,18 @@ unload_dn_sched(struct dn_alg *s) ND("called for %s", s->name); - DN_BH_WLOCK(); - SLIST_FOREACH_SAFE(r, &schedlist, next, tmp) { + mtx_lock(&sched_mtx); + CK_LIST_FOREACH_SAFE(r, &schedlist, next, tmp) { if (strcmp(s->name, r->name) != 0) continue; ND("ref_count = %d", r->ref_count); err = (r->ref_count != 0) ? EBUSY : 0; if (err == 0) - SLIST_REMOVE(&schedlist, r, dn_alg, next); + CK_LIST_REMOVE(r, next); break; } - DN_BH_WUNLOCK(); + mtx_unlock(&sched_mtx); + NET_EPOCH_WAIT(); D("dn_sched %s %sunloaded", s->name, err ? "not ":""); return err; } @@ -2737,17 +2784,20 @@ load_dn_aqm(struct dn_aqm *d) return 1; } + mtx_lock(&sched_mtx); + /* Search if AQM already exists */ - DN_BH_WLOCK(); /* XXX Global lock? */ - SLIST_FOREACH(aqm, &aqmlist, next) { + CK_LIST_FOREACH(aqm, &aqmlist, next) { if (strcmp(aqm->name, d->name) == 0) { D("%s already loaded", d->name); break; /* AQM already exists */ } } if (aqm == NULL) - SLIST_INSERT_HEAD(&aqmlist, d, next); - DN_BH_WUNLOCK(); + CK_LIST_INSERT_HEAD(&aqmlist, d, next); + + mtx_unlock(&sched_mtx); + D("dn_aqm %s %sloaded", d->name, aqm ? "not ":""); return aqm ? 1 : 0; } @@ -2777,21 +2827,24 @@ unload_dn_aqm(struct dn_aqm *aqm) err = 0; ND("called for %s", aqm->name); - DN_BH_WLOCK(); - /* clean up AQM status and deconfig flowset */ dn_ht_scan(V_dn_cfg.fshash, fs_cleanup, &aqm->type); - SLIST_FOREACH_SAFE(r, &aqmlist, next, tmp) { + mtx_lock(&sched_mtx); + + CK_LIST_FOREACH_SAFE(r, &aqmlist, next, tmp) { if (strcmp(aqm->name, r->name) != 0) continue; ND("ref_count = %d", r->ref_count); err = (r->ref_count != 0 || r->cfg_ref_count != 0) ? EBUSY : 0; if (err == 0) - SLIST_REMOVE(&aqmlist, r, dn_aqm, next); + CK_LIST_REMOVE(r, next); break; } - DN_BH_WUNLOCK(); + + mtx_unlock(&sched_mtx); + NET_EPOCH_WAIT(); + D("%s %sunloaded", aqm->name, err ? "not ":""); if (err) D("ref_count=%d, cfg_ref_count=%d", r->ref_count, r->cfg_ref_count); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 627A56540F3; Thu, 17 Jun 2021 14:54: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 4G5Q7q26RFz4vkD; Thu, 17 Jun 2021 14:54: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 2C7FF11737; Thu, 17 Jun 2021 14:54: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 15HEslCj010689; Thu, 17 Jun 2021 14:54:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEslk2010688; Thu, 17 Jun 2021 14:54:47 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:47 GMT Message-Id: <202106171454.15HEslk2010688@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: dddbe8523208 - stable/12 - pf: don't hold a lock during copyout() 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: dddbe852320818451f004177d4ff887618adaa85 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, 17 Jun 2021 14:54:47 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dddbe852320818451f004177d4ff887618adaa85 commit dddbe852320818451f004177d4ff887618adaa85 Author: Kristof Provost AuthorDate: 2021-06-14 12:04:02 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 14:53:36 +0000 pf: don't hold a lock during copyout() copyout() can trigger page faults, so it may potentially sleep. Reported by: avg MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 8b5f4e692b1d1585ecfc6690552650114e3e704e) --- sys/netpfil/pf/pf_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 3a5a7601b51e..3d5ae03b5a11 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2532,8 +2532,6 @@ DIOCADDRULENV_error: ERROUT(ENOSPC); } - error = copyout(nvlpacked, nv->data, nv->len); - if (clear_counter) { counter_u64_zero(rule->evaluations); for (int i = 0; i < 2; i++) { @@ -2544,6 +2542,8 @@ DIOCADDRULENV_error: } PF_RULES_WUNLOCK(); + error = copyout(nvlpacked, nv->data, nv->len); + #undef ERROUT DIOCGETRULENV_error: free(nvlpacked, M_NVLIST); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 57A4365463A; Thu, 17 Jun 2021 14:54: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 4G5Q7p1Hfgz4vZC; Thu, 17 Jun 2021 14:54: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 EEED211806; Thu, 17 Jun 2021 14:54: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 15HEsjVP010665; Thu, 17 Jun 2021 14:54:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsjVb010664; Thu, 17 Jun 2021 14:54:45 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:45 GMT Message-Id: <202106171454.15HEsjVb010664@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: 719f6456fbde - stable/12 - dummynet: free(NULL, M_DUMMYNET); is safe 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: 719f6456fbdee54f94109f945d7d945b2abf9589 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, 17 Jun 2021 14:54:46 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=719f6456fbdee54f94109f945d7d945b2abf9589 commit 719f6456fbdee54f94109f945d7d945b2abf9589 Author: Kristof Provost AuthorDate: 2021-05-21 14:55:07 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 14:53:36 +0000 dummynet: free(NULL, M_DUMMYNET); is safe There's no need to check pointers for NULL before free()ing them. No functional change. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30382 (cherry picked from commit 1b2dbe37fa32d7255faf7d1feec7bb31414a8102) --- sys/netpfil/ipfw/ip_dummynet.c | 46 ++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index c412a45f7296..57565e0d7d23 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -758,8 +758,7 @@ fsk_detach(struct dn_fsk *fs, int flags) /* Free the RED parameters, they will be recomputed on * subsequent attach if needed. */ - if (fs->w_q_lookup) - free(fs->w_q_lookup, M_DUMMYNET); + free(fs->w_q_lookup, M_DUMMYNET); fs->w_q_lookup = NULL; qht_delete(fs, flags); #ifdef NEW_AQM @@ -911,10 +910,9 @@ schk_delete_cb(void *obj, void *arg) dn_ht_free(s->siht, 0); } else if (s->siht) si_destroy(s->siht, NULL); - if (s->profile) { - free(s->profile, M_DUMMYNET); - s->profile = NULL; - } + + free(s->profile, M_DUMMYNET); + s->profile = NULL; s->siht = NULL; if (s->fp->destroy) s->fp->destroy(s); @@ -1238,10 +1236,8 @@ config_red(struct dn_fsk *fs) } /* If the lookup table already exist, free and create it again. */ - if (fs->w_q_lookup) { - free(fs->w_q_lookup, M_DUMMYNET); - fs->w_q_lookup = NULL; - } + free(fs->w_q_lookup, M_DUMMYNET); + fs->w_q_lookup = NULL; if (V_dn_cfg.red_lookup_depth == 0) { printf("\ndummynet: net.inet.ip.dummynet.red_lookup_depth" "must be > 0\n"); @@ -1580,10 +1576,9 @@ config_link(struct dn_link *p, struct dn_id *arg) return EINVAL; } /* remove profile if exists */ - if (s->profile) { - free(s->profile, M_DUMMYNET); - s->profile = NULL; - } + free(s->profile, M_DUMMYNET); + s->profile = NULL; + /* copy all parameters */ s->link.oid = p->oid; s->link.link_nr = i; @@ -1707,8 +1702,7 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) if (!locked) DN_BH_WUNLOCK(); #ifdef NEW_AQM - if (ep != NULL) - free(ep, M_TEMP); + free(ep, M_TEMP); #endif return fs; } @@ -1907,8 +1901,7 @@ next: err = 0; error: DN_BH_WUNLOCK(); - if (pf) - free(pf, M_DUMMYNET); + free(pf, M_DUMMYNET); return err; } @@ -2136,10 +2129,8 @@ do_config(void *p, int l) break; off += o.len; } - if (arg != NULL) - free(arg, M_TEMP); - if (dn != NULL) - free(dn, M_TEMP); + free(arg, M_TEMP); + free(dn, M_TEMP); return err; } @@ -2325,8 +2316,7 @@ dummynet_get(struct sockopt *sopt, void **compat) break; DN_BH_WUNLOCK(); - if (start) - free(start, M_DUMMYNET); + free(start, M_DUMMYNET); start = NULL; if (need > sopt_valsize) break; @@ -2384,10 +2374,9 @@ dummynet_get(struct sockopt *sopt, void **compat) error = sooptcopyout(sopt, start, buf - start); } done: - if (cmd && cmd != &r.o) + if (cmd != &r.o) free(cmd, M_DUMMYNET); - if (start) - free(start, M_DUMMYNET); + free(start, M_DUMMYNET); return error; } @@ -2548,8 +2537,7 @@ ip_dn_ctl(struct sockopt *sopt) break; } - if (p != NULL) - free(p, M_TEMP); + free(p, M_TEMP); NET_EPOCH_EXIT_ET(et); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 243BC6543A8; Thu, 17 Jun 2021 14:54: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 4G5Q7s06NPz4vZQ; Thu, 17 Jun 2021 14:54: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 D0C9111613; Thu, 17 Jun 2021 14:54:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15HEsm23010831; Thu, 17 Jun 2021 14:54:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsmGX010830; Thu, 17 Jun 2021 14:54:48 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:48 GMT Message-Id: <202106171454.15HEsmGX010830@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: c011422b2d77 - stable/13 - VNETify dummynet 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: c011422b2d77cc29001e35383dfc060921d6e85a 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, 17 Jun 2021 14:54:49 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=c011422b2d77cc29001e35383dfc060921d6e85a commit c011422b2d77cc29001e35383dfc060921d6e85a Author: Tom Jones AuthorDate: 2021-05-15 12:36:45 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 12:38:07 +0000 VNETify dummynet This moves dn_cfg and other parameters into per VNET variables. The taskqueue and control state remains global. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D29274 (cherry picked from commit fe3bcfbda30e763a3ec56083b3a19cebbeaf8952) --- sys/netpfil/ipfw/dn_aqm.h | 6 +- sys/netpfil/ipfw/dn_aqm_codel.c | 2 +- sys/netpfil/ipfw/dn_aqm_pie.c | 2 +- sys/netpfil/ipfw/dn_sched.h | 2 +- sys/netpfil/ipfw/dn_sched_fq_codel.c | 2 +- sys/netpfil/ipfw/dn_sched_fq_codel.h | 7 +- sys/netpfil/ipfw/dn_sched_fq_pie.c | 9 +- sys/netpfil/ipfw/ip_dn_glue.c | 8 +- sys/netpfil/ipfw/ip_dn_io.c | 180 ++++++++++++----------- sys/netpfil/ipfw/ip_dn_private.h | 42 +++--- sys/netpfil/ipfw/ip_dummynet.c | 271 +++++++++++++++++++---------------- 11 files changed, 281 insertions(+), 250 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index 8bbe9fe69e86..b0eaf2ecfc8a 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -37,9 +37,9 @@ #define _IP_DN_AQM_H /* NOW is the current time in millisecond*/ -#define NOW ((dn_cfg.curr_time * tick) / 1000) +#define NOW ((V_dn_cfg.curr_time * tick) / 1000) -#define AQM_UNOW (dn_cfg.curr_time * tick) +#define AQM_UNOW (V_dn_cfg.curr_time * tick) #define AQM_TIME_1US ((aqm_time_t)(1)) #define AQM_TIME_1MS ((aqm_time_t)(1000)) #define AQM_TIME_1S ((aqm_time_t)(AQM_TIME_1MS * 1000)) @@ -134,7 +134,7 @@ update_stats(struct dn_queue *q, int len, int drop) if (drop) { qni->drops++; sni->drops++; - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; } else { /*update queue stats */ qni->length += inc; diff --git a/sys/netpfil/ipfw/dn_aqm_codel.c b/sys/netpfil/ipfw/dn_aqm_codel.c index a1f90461ecab..79c6afd8b635 100644 --- a/sys/netpfil/ipfw/dn_aqm_codel.c +++ b/sys/netpfil/ipfw/dn_aqm_codel.c @@ -202,7 +202,7 @@ codel_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts) update_stats(q, -m->m_pkthdr.len, 0); if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; /* extract packet TS*/ mtag = m_tag_locate(m, MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, NULL); diff --git a/sys/netpfil/ipfw/dn_aqm_pie.c b/sys/netpfil/ipfw/dn_aqm_pie.c index 2d5d500e275c..4a55aed662f7 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.c +++ b/sys/netpfil/ipfw/dn_aqm_pie.c @@ -338,7 +338,7 @@ pie_extract_head(struct dn_queue *q, aqm_time_t *pkt_ts, int getts) update_stats(q, -m->m_pkthdr.len, 0); if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; if (getts) { /* extract packet TS*/ diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h index 9bbd9019d623..1aa885ce3ccf 100644 --- a/sys/netpfil/ipfw/dn_sched.h +++ b/sys/netpfil/ipfw/dn_sched.h @@ -187,7 +187,7 @@ dn_dequeue(struct dn_queue *q) q->_si->ni.len_bytes -= m->m_pkthdr.len; } if (q->ni.length == 0) /* queue is now idle */ - q->q_time = dn_cfg.curr_time; + q->q_time = V_dn_cfg.curr_time; return m; } diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.c b/sys/netpfil/ipfw/dn_sched_fq_codel.c index bc61be867d36..97341f5a9a60 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.c +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.c @@ -165,7 +165,7 @@ codel_drop_head(struct fq_codel_flow *q, struct fq_codel_si *si) fq_update_stats(q, si, -m->m_pkthdr.len, 1); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; FREE_PKT(m); } diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index a8369ac83129..dcdbc6f32e7a 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -36,6 +36,9 @@ #ifndef _IP_DN_SCHED_FQ_CODEL_H #define _IP_DN_SCHED_FQ_CODEL_H +VNET_DECLARE(unsigned long, io_pkt_drop); +#define V_io_pkt_drop VNET(io_pkt_drop) + /* list of queues */ STAILQ_HEAD(fq_codel_list, fq_codel_flow) ; @@ -104,7 +107,7 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - dn_cfg.io_pkt_drop ++; + V_dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { @@ -147,7 +150,7 @@ fq_codel_extract_head(struct fq_codel_flow *q, aqm_time_t *pkt_ts, struct fq_cod fq_update_stats(q, si, -m->m_pkthdr.len, 0); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; /* extract packet timestamp*/ struct m_tag *mtag; diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 809ca2b5f4e8..76215aed610a 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -82,6 +82,9 @@ #define DN_SCHED_FQ_PIE 7 +VNET_DECLARE(unsigned long, io_pkt_drop); +#define V_io_pkt_drop VNET(io_pkt_drop) + /* list of queues */ STAILQ_HEAD(fq_pie_list, fq_pie_flow) ; @@ -299,7 +302,7 @@ fq_update_stats(struct fq_pie_flow *q, struct fq_pie_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - dn_cfg.io_pkt_drop ++; + V_dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { @@ -347,7 +350,7 @@ fq_pie_extract_head(struct fq_pie_flow *q, aqm_time_t *pkt_ts, fq_update_stats(q, si, -m->m_pkthdr.len, 0); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; if (getts) { /* extract packet timestamp*/ @@ -768,7 +771,7 @@ pie_drop_head(struct fq_pie_flow *q, struct fq_pie_si *si) fq_update_stats(q, si, -m->m_pkthdr.len, 1); if (si->main_q.ni.length == 0) /* queue is now idle */ - si->main_q.q_time = dn_cfg.curr_time; + si->main_q.q_time = V_dn_cfg.curr_time; /* reset accu_prob after packet drop */ q->pst.accu_prob = 0; diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index 5a39a1a47282..83f26cb23680 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -567,10 +567,10 @@ dn_compat_calc_size(void) * - all flowset queues: queue_count * - all pipe queue: si_count */ - need += dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2; - need += dn_cfg.fsk_count * sizeof(struct dn_flow_set); - need += dn_cfg.si_count * sizeof(struct dn_flow_queue8); - need += dn_cfg.queue_count * sizeof(struct dn_flow_queue8); + need += V_dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2; + need += V_dn_cfg.fsk_count * sizeof(struct dn_flow_set); + need += V_dn_cfg.si_count * sizeof(struct dn_flow_queue8); + need += V_dn_cfg.queue_count * sizeof(struct dn_flow_queue8); return need; } diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 4a65bd0ef798..39bea3eb99dd 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -74,11 +74,10 @@ __FBSDID("$FreeBSD$"); /* * We keep a private variable for the simulation time, but we could * probably use an existing one ("softticks" in sys/kern/kern_timeout.c) - * instead of dn_cfg.curr_time + * instead of V_dn_cfg.curr_time */ - -struct dn_parms dn_cfg; -//VNET_DEFINE(struct dn_parms, _base_dn_cfg); +VNET_DEFINE(struct dn_parms, dn_cfg); +#define V_dn_cfg VNET(dn_cfg) /* * We use a heap to store entities for which we have pending timer events. @@ -102,13 +101,13 @@ sysctl_hash_size(SYSCTL_HANDLER_ARGS) { int error, value; - value = dn_cfg.hash_size; + value = V_dn_cfg.hash_size; error = sysctl_handle_int(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) return (error); if (value < 16 || value > 65536) return (EINVAL); - dn_cfg.hash_size = value; + V_dn_cfg.hash_size = value; return (0); } @@ -119,9 +118,9 @@ sysctl_limits(SYSCTL_HANDLER_ARGS) long value; if (arg2 != 0) - value = dn_cfg.slot_limit; + value = V_dn_cfg.slot_limit; else - value = dn_cfg.byte_limit; + value = V_dn_cfg.byte_limit; error = sysctl_handle_long(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) @@ -129,11 +128,11 @@ sysctl_limits(SYSCTL_HANDLER_ARGS) if (arg2 != 0) { if (value < 1) return (EINVAL); - dn_cfg.slot_limit = value; + V_dn_cfg.slot_limit = value; } else { if (value < 1500) return (EINVAL); - dn_cfg.byte_limit = value; + V_dn_cfg.byte_limit = value; } return (0); } @@ -151,9 +150,9 @@ static SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, "Dummynet"); #endif -/* wrapper to pass dn_cfg fields to SYSCTL_* */ -//#define DC(x) (&(VNET_NAME(_base_dn_cfg).x)) -#define DC(x) (&(dn_cfg.x)) +/* wrapper to pass V_dn_cfg fields to SYSCTL_* */ +#define DC(x) (&(VNET_NAME(dn_cfg).x)) + /* parameters */ SYSCTL_PROC(_net_inet_ip_dummynet, OID_AUTO, hash_size, @@ -349,7 +348,7 @@ red_drops (struct dn_queue *q, int len) * XXX check wraps... */ if (q->avg) { - u_int t = div64((dn_cfg.curr_time - q->q_time), fs->lookup_step); + u_int t = div64((V_dn_cfg.curr_time - q->q_time), fs->lookup_step); q->avg = (t < fs->lookup_depth) ? SCALE_MUL(q->avg, fs->w_q_lookup[t]) : 0; @@ -524,7 +523,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) return (0); drop: - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; q->ni.drops++; ni->drops++; FREE_PKT(m); @@ -553,7 +552,7 @@ transmit_event(struct mq *q, struct delay_line *dline, uint64_t now) } if (m != NULL) { dline->oid.subtype = 1; /* in heap */ - heap_insert(&dn_cfg.evheap, pkt->output_time, dline); + heap_insert(&V_dn_cfg.evheap, pkt->output_time, dline); } } @@ -616,7 +615,7 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) (m->m_pkthdr.len * 8 + extra_bits(m, s)); si->credit -= len_scaled; /* Move packet in the delay line */ - dn_tag_get(m)->output_time = dn_cfg.curr_time + s->link.delay ; + dn_tag_get(m)->output_time = V_dn_cfg.curr_time + s->link.delay ; mq_append(&si->dline.mq, m); } @@ -634,7 +633,7 @@ serve_sched(struct mq *q, struct dn_sch_inst *si, uint64_t now) if (m) dn_tag_get(m)->output_time += t; si->kflags |= DN_ACTIVE; - heap_insert(&dn_cfg.evheap, now + t, si); + heap_insert(&V_dn_cfg.evheap, now + t, si); } if (delay_line_idle && done) transmit_event(q, &si->dline, now); @@ -651,74 +650,85 @@ dummynet_task(void *context, int pending) { struct timeval t; struct mq q = { NULL, NULL }; /* queue to accumulate results */ + struct epoch_tracker et; - CURVNET_SET((struct vnet *)context); + VNET_ITERATOR_DECL(vnet_iter); + VNET_LIST_RLOCK(); + NET_EPOCH_ENTER(et); - DN_BH_WLOCK(); + VNET_FOREACH(vnet_iter) { + memset(&q, 0, sizeof(struct mq)); + CURVNET_SET(vnet_iter); - /* Update number of lost(coalesced) ticks. */ - dn_cfg.tick_lost += pending - 1; + DN_BH_WLOCK(); - getmicrouptime(&t); - /* Last tick duration (usec). */ - dn_cfg.tick_last = (t.tv_sec - dn_cfg.prev_t.tv_sec) * 1000000 + - (t.tv_usec - dn_cfg.prev_t.tv_usec); - /* Last tick vs standard tick difference (usec). */ - dn_cfg.tick_delta = (dn_cfg.tick_last * hz - 1000000) / hz; - /* Accumulated tick difference (usec). */ - dn_cfg.tick_delta_sum += dn_cfg.tick_delta; + /* Update number of lost(coalesced) ticks. */ + V_dn_cfg.tick_lost += pending - 1; - dn_cfg.prev_t = t; + getmicrouptime(&t); + /* Last tick duration (usec). */ + V_dn_cfg.tick_last = (t.tv_sec - V_dn_cfg.prev_t.tv_sec) * 1000000 + + (t.tv_usec - V_dn_cfg.prev_t.tv_usec); + /* Last tick vs standard tick difference (usec). */ + V_dn_cfg.tick_delta = (V_dn_cfg.tick_last * hz - 1000000) / hz; + /* Accumulated tick difference (usec). */ + V_dn_cfg.tick_delta_sum += V_dn_cfg.tick_delta; - /* - * Adjust curr_time if the accumulated tick difference is - * greater than the 'standard' tick. Since curr_time should - * be monotonically increasing, we do positive adjustments - * as required, and throttle curr_time in case of negative - * adjustment. - */ - dn_cfg.curr_time++; - if (dn_cfg.tick_delta_sum - tick >= 0) { - int diff = dn_cfg.tick_delta_sum / tick; - - dn_cfg.curr_time += diff; - dn_cfg.tick_diff += diff; - dn_cfg.tick_delta_sum %= tick; - dn_cfg.tick_adjustment++; - } else if (dn_cfg.tick_delta_sum + tick <= 0) { - dn_cfg.curr_time--; - dn_cfg.tick_diff--; - dn_cfg.tick_delta_sum += tick; - dn_cfg.tick_adjustment++; - } + V_dn_cfg.prev_t = t; - /* serve pending events, accumulate in q */ - for (;;) { - struct dn_id *p; /* generic parameter to handler */ + /* + * Adjust curr_time if the accumulated tick difference is + * greater than the 'standard' tick. Since curr_time should + * be monotonically increasing, we do positive adjustments + * as required, and throttle curr_time in case of negative + * adjustment. + */ + V_dn_cfg.curr_time++; + if (V_dn_cfg.tick_delta_sum - tick >= 0) { + int diff = V_dn_cfg.tick_delta_sum / tick; + + V_dn_cfg.curr_time += diff; + V_dn_cfg.tick_diff += diff; + V_dn_cfg.tick_delta_sum %= tick; + V_dn_cfg.tick_adjustment++; + } else if (V_dn_cfg.tick_delta_sum + tick <= 0) { + V_dn_cfg.curr_time--; + V_dn_cfg.tick_diff--; + V_dn_cfg.tick_delta_sum += tick; + V_dn_cfg.tick_adjustment++; + } - if (dn_cfg.evheap.elements == 0 || - DN_KEY_LT(dn_cfg.curr_time, HEAP_TOP(&dn_cfg.evheap)->key)) - break; - p = HEAP_TOP(&dn_cfg.evheap)->object; - heap_extract(&dn_cfg.evheap, NULL); + /* serve pending events, accumulate in q */ + for (;;) { + struct dn_id *p; /* generic parameter to handler */ - if (p->type == DN_SCH_I) { - serve_sched(&q, (struct dn_sch_inst *)p, dn_cfg.curr_time); - } else { /* extracted a delay line */ - transmit_event(&q, (struct delay_line *)p, dn_cfg.curr_time); + if (V_dn_cfg.evheap.elements == 0 || + DN_KEY_LT(V_dn_cfg.curr_time, HEAP_TOP(&V_dn_cfg.evheap)->key)) + break; + p = HEAP_TOP(&V_dn_cfg.evheap)->object; + heap_extract(&V_dn_cfg.evheap, NULL); + if (p->type == DN_SCH_I) { + serve_sched(&q, (struct dn_sch_inst *)p, V_dn_cfg.curr_time); + } else { /* extracted a delay line */ + transmit_event(&q, (struct delay_line *)p, V_dn_cfg.curr_time); + } } + if (V_dn_cfg.expire && ++V_dn_cfg.expire_cycle >= V_dn_cfg.expire) { + V_dn_cfg.expire_cycle = 0; + dn_drain_scheduler(); + dn_drain_queue(); + } + DN_BH_WUNLOCK(); + if (q.head != NULL) + dummynet_send(q.head); + + CURVNET_RESTORE(); } - if (dn_cfg.expire && ++dn_cfg.expire_cycle >= dn_cfg.expire) { - dn_cfg.expire_cycle = 0; - dn_drain_scheduler(); - dn_drain_queue(); - } + NET_EPOCH_EXIT(et); + VNET_LIST_RUNLOCK(); + /* Schedule our next run. */ dn_reschedule(); - DN_BH_WUNLOCK(); - if (q.head != NULL) - dummynet_send(q.head); - CURVNET_RESTORE(); } /* @@ -834,7 +844,7 @@ tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa) dt->dn_dir = dir; dt->ifp = fwa->flags & IPFW_ARGS_OUT ? fwa->ifp : NULL; /* dt->output tame is updated as we move through */ - dt->output_time = dn_cfg.curr_time; + dt->output_time = V_dn_cfg.curr_time; dt->iphdr_off = (dir & PROTO_LAYER2) ? ETHER_HDR_LEN : 0; return 0; } @@ -866,12 +876,12 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) else if (fwa->flags & IPFW_ARGS_IP6) dir |= PROTO_IPV6; DN_BH_WLOCK(); - dn_cfg.io_pkt++; + V_dn_cfg.io_pkt++; /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; /* XXX locate_flowset could be optimised with a direct ref. */ - fs = dn_ht_find(dn_cfg.fshash, fs_id, 0, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, fs_id, 0, NULL); if (fs == NULL) goto dropit; /* This queue/pipe does not exist! */ if (fs->sched == NULL) /* should not happen */ @@ -894,7 +904,7 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) m = *m0 = NULL; /* dn_enqueue already increases io_pkt_drop */ - dn_cfg.io_pkt_drop--; + V_dn_cfg.io_pkt_drop--; goto dropit; } @@ -905,34 +915,34 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) } /* compute the initial allowance */ - if (si->idle_time < dn_cfg.curr_time) { + if (si->idle_time < V_dn_cfg.curr_time) { /* Do this only on the first packet on an idle pipe */ struct dn_link *p = &fs->sched->link; - si->sched_time = dn_cfg.curr_time; - si->credit = dn_cfg.io_fast ? p->bandwidth : 0; + si->sched_time = V_dn_cfg.curr_time; + si->credit = V_dn_cfg.io_fast ? p->bandwidth : 0; if (p->burst) { - uint64_t burst = (dn_cfg.curr_time - si->idle_time) * p->bandwidth; + uint64_t burst = (V_dn_cfg.curr_time - si->idle_time) * p->bandwidth; if (burst > p->burst) burst = p->burst; si->credit += burst; } } /* pass through scheduler and delay line */ - m = serve_sched(NULL, si, dn_cfg.curr_time); + m = serve_sched(NULL, si, V_dn_cfg.curr_time); /* optimization -- pass it back to ipfw for immediate send */ /* XXX Don't call dummynet_send() if scheduler return the packet * just enqueued. This avoid a lock order reversal. * */ - if (/*dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { + if (/*V_dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { /* fast io, rename the tag * to carry reinject info. */ struct m_tag *tag = m_tag_first(m); tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; - dn_cfg.io_pkt_fast++; + V_dn_cfg.io_pkt_fast++; if (m->m_nextpkt != NULL) { printf("dummynet: fast io: pkt chain detected!\n"); m->m_nextpkt = NULL; @@ -948,7 +958,7 @@ done: return 0; dropit: - dn_cfg.io_pkt_drop++; + V_dn_cfg.io_pkt_drop++; DN_BH_WUNLOCK(); if (m) FREE_PKT(m); diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index e6e699bf35b2..8dedd071bd81 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -46,7 +46,7 @@ #define D(fmt, ...) printf("%-10s " fmt "\n", \ __FUNCTION__, ## __VA_ARGS__) #define DX(lev, fmt, ...) do { \ - if (dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) + if (V_dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) #endif MALLOC_DECLARE(M_DUMMYNET); @@ -56,26 +56,26 @@ MALLOC_DECLARE(M_DUMMYNET); #endif #define DN_LOCK_INIT() do { \ - mtx_init(&dn_cfg.uh_mtx, "dn_uh", NULL, MTX_DEF); \ - mtx_init(&dn_cfg.bh_mtx, "dn_bh", NULL, MTX_DEF); \ + mtx_init(&V_dn_cfg.uh_mtx, "dn_uh", NULL, MTX_DEF); \ + mtx_init(&V_dn_cfg.bh_mtx, "dn_bh", NULL, MTX_DEF); \ } while (0) #define DN_LOCK_DESTROY() do { \ - mtx_destroy(&dn_cfg.uh_mtx); \ - mtx_destroy(&dn_cfg.bh_mtx); \ + mtx_destroy(&V_dn_cfg.uh_mtx); \ + mtx_destroy(&V_dn_cfg.bh_mtx); \ } while (0) #if 0 /* not used yet */ -#define DN_UH_RLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_UH_RUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_UH_WLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_UH_WUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_UH_LOCK_ASSERT() mtx_assert(&dn_cfg.uh_mtx, MA_OWNED) +#define DN_UH_RLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_UH_RUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_UH_WLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_UH_WUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_UH_LOCK_ASSERT() mtx_assert(&V_dn_cfg.uh_mtx, MA_OWNED) #endif -#define DN_BH_RLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_BH_RUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_BH_WLOCK() mtx_lock(&dn_cfg.uh_mtx) -#define DN_BH_WUNLOCK() mtx_unlock(&dn_cfg.uh_mtx) -#define DN_BH_LOCK_ASSERT() mtx_assert(&dn_cfg.uh_mtx, MA_OWNED) +#define DN_BH_RLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_BH_RUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_BH_WLOCK() mtx_lock(&V_dn_cfg.uh_mtx) +#define DN_BH_WUNLOCK() mtx_unlock(&V_dn_cfg.uh_mtx) +#define DN_BH_LOCK_ASSERT() mtx_assert(&V_dn_cfg.uh_mtx, MA_OWNED) SLIST_HEAD(dn_schk_head, dn_schk); SLIST_HEAD(dn_sch_inst_head, dn_sch_inst); @@ -101,7 +101,7 @@ set_oid(struct dn_id *o, int type, int len) } /* - * configuration and global data for a dummynet instance + * configuration and data for a dummynet instance * * When a configuration is modified from userland, 'id' is incremented * so we can use the value to check for stale pointers. @@ -154,10 +154,6 @@ struct dn_parms { struct dn_ht *schedhash; /* list of flowsets without a scheduler -- use sch_chain */ struct dn_fsk_head fsu; /* list of unlinked flowsets */ - struct dn_alg_head schedlist; /* list of algorithms */ -#ifdef NEW_AQM - struct dn_aqm_head aqmlist; /* list of AQMs */ -#endif /* Store the fs/sch to scan when draining. The value is the * bucket number of the hash table. Expire can be disabled @@ -406,9 +402,9 @@ enum { PROTO_IFB = 0x0c, /* layer2 + ifbridge */ }; -extern struct dn_parms dn_cfg; -//VNET_DECLARE(struct dn_parms, _base_dn_cfg); -//#define dn_cfg VNET(_base_dn_cfg) +//extern struct dn_parms V_dn_cfg; +VNET_DECLARE(struct dn_parms, dn_cfg); +#define V_dn_cfg VNET(dn_cfg) int dummynet_io(struct mbuf **, struct ip_fw_args *); void dummynet_task(void *context, int pending); diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index 17f3e364756e..3abc78fc1410 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include /* ip_output(), IP_FORWARDING */ #include #include +#include #include #include @@ -87,10 +88,17 @@ struct schk_new_arg { /*---- callout hooks. ----*/ static struct callout dn_timeout; +static int dn_tasks_started = 0; static int dn_gone; static struct task dn_task; static struct taskqueue *dn_tq = NULL; +/* global scheduler list */ +struct dn_alg_head schedlist; +#ifdef NEW_AQM +struct dn_aqm_head aqmlist; /* list of AQMs */ +#endif + static void dummynet(void *arg) { @@ -117,7 +125,7 @@ find_aqm_type(int type, char *name) { struct dn_aqm *d; - SLIST_FOREACH(d, &dn_cfg.aqmlist, next) { + SLIST_FOREACH(d, &aqmlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -131,7 +139,7 @@ find_sched_type(int type, char *name) { struct dn_alg *d; - SLIST_FOREACH(d, &dn_cfg.schedlist, next) { + SLIST_FOREACH(d, &schedlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -354,7 +362,7 @@ q_new(uintptr_t key, int flags, void *arg) if(fs->aqmfp->init(q)) D("unable to init AQM for fs %d", fs->fs.fs_nr); #endif - dn_cfg.queue_count++; + V_dn_cfg.queue_count++; return q; } @@ -387,7 +395,7 @@ dn_delete_queue(struct dn_queue *q, int flags) dn_free_pkts(q->mq.head); bzero(q, sizeof(*q)); // safety free(q, M_DUMMYNET); - dn_cfg.queue_count--; + V_dn_cfg.queue_count--; } } @@ -527,7 +535,7 @@ si_new(uintptr_t key, int flags, void *arg) } #endif - dn_cfg.si_count++; + V_dn_cfg.si_count++; return si; error: @@ -552,10 +560,10 @@ si_destroy(void *_si, void *arg) struct delay_line *dl = &si->dline; if (dl->oid.subtype) /* remove delay line from event heap */ - heap_extract(&dn_cfg.evheap, dl); + heap_extract(&V_dn_cfg.evheap, dl); dn_free_pkts(dl->mq.head); /* drain delay line */ if (si->kflags & DN_ACTIVE) /* remove si from event heap */ - heap_extract(&dn_cfg.evheap, si); + heap_extract(&V_dn_cfg.evheap, si); #ifdef NEW_AQM /* clean up AQM status for !DN_MULTIQUEUE sched @@ -574,7 +582,7 @@ si_destroy(void *_si, void *arg) s->fp->free_sched(si); bzero(si, sizeof(*si)); /* safety */ free(si, M_DUMMYNET); - dn_cfg.si_count--; + V_dn_cfg.si_count--; return DNHT_SCAN_DEL; } @@ -605,7 +613,7 @@ si_reset_credit(void *_si, void *arg) struct dn_sch_inst *si = _si; struct dn_link *p = &si->sched->link; - si->credit = p->burst + (dn_cfg.io_fast ? p->bandwidth : 0); + si->credit = p->burst + (V_dn_cfg.io_fast ? p->bandwidth : 0); return 0; } @@ -651,9 +659,9 @@ fsk_new(uintptr_t key, int flags, void *arg) fs = malloc(sizeof(*fs), M_DUMMYNET, M_NOWAIT | M_ZERO); if (fs) { set_oid(&fs->fs.oid, DN_FS, sizeof(fs->fs)); - dn_cfg.fsk_count++; + V_dn_cfg.fsk_count++; fs->drain_bucket = 0; - SLIST_INSERT_HEAD(&dn_cfg.fsu, fs, sch_chain); + SLIST_INSERT_HEAD(&V_dn_cfg.fsu, fs, sch_chain); } return fs; } @@ -737,7 +745,7 @@ fsk_detach(struct dn_fsk *fs, int flags) (flags & DN_DETACH) ? "DET":""); if (flags & DN_DETACH) { /* detach from the list */ struct dn_fsk_head *h; - h = fs->sched ? &fs->sched->fsk_list : &dn_cfg.fsu; + h = fs->sched ? &fs->sched->fsk_list : &V_dn_cfg.fsu; SLIST_REMOVE(h, fs, dn_fsk, sch_chain); } /* Free the RED parameters, they will be recomputed on @@ -757,9 +765,9 @@ fsk_detach(struct dn_fsk *fs, int flags) if (flags & DN_DELETE_FS) { bzero(fs, sizeof(*fs)); /* safety */ free(fs, M_DUMMYNET); - dn_cfg.fsk_count--; + V_dn_cfg.fsk_count--; } else { - SLIST_INSERT_HEAD(&dn_cfg.fsu, fs, sch_chain); + SLIST_INSERT_HEAD(&V_dn_cfg.fsu, fs, sch_chain); } } @@ -797,7 +805,7 @@ delete_fs(int i, int locked) if (!locked) DN_BH_WLOCK(); - fs = dn_ht_find(dn_cfg.fshash, i, DNHT_REMOVE, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, i, DNHT_REMOVE, NULL); ND("fs %d found %p", i, fs); if (fs) { fsk_detach(fs, DN_DETACH | DN_DELETE_FS); @@ -866,7 +874,7 @@ schk_new(uintptr_t key, int flags, void *arg) } } s->fp = NULL; /* mark as a new scheduler */ - dn_cfg.schk_count++; + V_dn_cfg.schk_count++; return s; } @@ -905,7 +913,7 @@ schk_delete_cb(void *obj, void *arg) s->fp->destroy(s); bzero(s, sizeof(*s)); // safety free(obj, M_DUMMYNET); - dn_cfg.schk_count--; + V_dn_cfg.schk_count--; return DNHT_SCAN_DEL; } @@ -919,7 +927,7 @@ delete_schk(int i) { struct dn_schk *s; - s = dn_ht_find(dn_cfg.schedhash, i, DNHT_REMOVE, NULL); + s = dn_ht_find(V_dn_cfg.schedhash, i, DNHT_REMOVE, NULL); ND("%d %p", i, s); if (!s) return EINVAL; @@ -1176,7 +1184,7 @@ copy_data_helper(void *_o, void *_arg) static inline struct dn_schk * locate_scheduler(int i) { - return dn_ht_find(dn_cfg.schedhash, i, 0, NULL); + return dn_ht_find(V_dn_cfg.schedhash, i, 0, NULL); } /* @@ -1194,10 +1202,10 @@ config_red(struct dn_fsk *fs) /* Doing stuff that was in userland */ i = fs->sched->link.bandwidth; s = (i <= 0) ? 0 : - hz * dn_cfg.red_avg_pkt_size * 8 * SCALE(1) / i; + hz * V_dn_cfg.red_avg_pkt_size * 8 * SCALE(1) / i; idle = div64((s * 3) , fs->w_q); /* s, fs->w_q scaled; idle not scaled */ - fs->lookup_step = div64(idle , dn_cfg.red_lookup_depth); + fs->lookup_step = div64(idle , V_dn_cfg.red_lookup_depth); /* fs->lookup_step not scaled, */ if (!fs->lookup_step) fs->lookup_step = 1; @@ -1227,14 +1235,14 @@ config_red(struct dn_fsk *fs) free(fs->w_q_lookup, M_DUMMYNET); fs->w_q_lookup = NULL; } - if (dn_cfg.red_lookup_depth == 0) { + if (V_dn_cfg.red_lookup_depth == 0) { printf("\ndummynet: net.inet.ip.dummynet.red_lookup_depth" "must be > 0\n"); fs->fs.flags &= ~DN_IS_RED; fs->fs.flags &= ~DN_IS_GENTLE_RED; return (EINVAL); } - fs->lookup_depth = dn_cfg.red_lookup_depth; + fs->lookup_depth = V_dn_cfg.red_lookup_depth; fs->w_q_lookup = (u_int *)malloc(fs->lookup_depth * sizeof(int), M_DUMMYNET, M_NOWAIT); if (fs->w_q_lookup == NULL) { @@ -1251,12 +1259,12 @@ config_red(struct dn_fsk *fs) fs->w_q_lookup[i] = SCALE_MUL(fs->w_q_lookup[i - 1], fs->lookup_weight); - if (dn_cfg.red_avg_pkt_size < 1) - dn_cfg.red_avg_pkt_size = 512; - fs->avg_pkt_size = dn_cfg.red_avg_pkt_size; - if (dn_cfg.red_max_pkt_size < 1) - dn_cfg.red_max_pkt_size = 1500; - fs->max_pkt_size = dn_cfg.red_max_pkt_size; + if (V_dn_cfg.red_avg_pkt_size < 1) + V_dn_cfg.red_avg_pkt_size = 512; + fs->avg_pkt_size = V_dn_cfg.red_avg_pkt_size; + if (V_dn_cfg.red_max_pkt_size < 1) + V_dn_cfg.red_max_pkt_size = 1500; + fs->max_pkt_size = V_dn_cfg.red_max_pkt_size; ND("exit"); return 0; } @@ -1278,7 +1286,7 @@ fsk_attach(struct dn_fsk *fs, struct dn_schk *s) { ND("remove fs %d from fsunlinked, link to sched %d", fs->fs.fs_nr, s->sch.sched_nr); - SLIST_REMOVE(&dn_cfg.fsu, fs, dn_fsk, sch_chain); + SLIST_REMOVE(&V_dn_cfg.fsu, fs, dn_fsk, sch_chain); fs->sched = s; SLIST_INSERT_HEAD(&s->fsk_list, fs, sch_chain); if (s->fp->new_fsk) @@ -1317,7 +1325,7 @@ update_fs(struct dn_schk *s) { struct dn_fsk *fs, *tmp; - SLIST_FOREACH_SAFE(fs, &dn_cfg.fsu, sch_chain, tmp) { + SLIST_FOREACH_SAFE(fs, &V_dn_cfg.fsu, sch_chain, tmp) { if (s->sch.sched_nr != fs->fs.sched_nr) { D("fs %d for sch %d not %d still unlinked", fs->fs.fs_nr, fs->fs.sched_nr, @@ -1362,7 +1370,7 @@ get_aqm_parms(struct sockopt *sopt) break; } - fs = dn_ht_find(dn_cfg.fshash, ep->nr, 0, NULL); + fs = dn_ht_find(V_dn_cfg.fshash, ep->nr, 0, NULL); if (!fs) { D("fs %d not found", ep->nr); err = EINVAL; @@ -1579,7 +1587,7 @@ config_link(struct dn_link *p, struct dn_id *arg) s->link.burst = p->burst; schk_reset_credit(s); } - dn_cfg.id++; + V_dn_cfg.id++; DN_BH_WUNLOCK(); return 0; } @@ -1616,15 +1624,15 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) /* XXX other sanity checks */ if (nfs->flags & DN_QSIZE_BYTES) { ipdn_bound_var(&nfs->qsize, 16384, - 1500, dn_cfg.byte_limit, NULL); // "queue byte size"); + 1500, V_dn_cfg.byte_limit, NULL); // "queue byte size"); } else { ipdn_bound_var(&nfs->qsize, 50, - 1, dn_cfg.slot_limit, NULL); // "queue slot size"); + 1, V_dn_cfg.slot_limit, NULL); // "queue slot size"); } if (nfs->flags & DN_HAVE_MASK) { /* make sure we have some buckets */ - ipdn_bound_var((int *)&nfs->buckets, dn_cfg.hash_size, - 1, dn_cfg.max_hash_size, "flowset buckets"); + ipdn_bound_var((int *)&nfs->buckets, V_dn_cfg.hash_size, + 1, V_dn_cfg.max_hash_size, "flowset buckets"); } else { nfs->buckets = 1; /* we only need 1 */ } @@ -1634,8 +1642,8 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) struct dn_schk *s; int flags = nfs->sched_nr ? DNHT_INSERT : 0; int j; - int oldc = dn_cfg.fsk_count; - fs = dn_ht_find(dn_cfg.fshash, i, flags, NULL); + int oldc = V_dn_cfg.fsk_count; + fs = dn_ht_find(V_dn_cfg.fshash, i, flags, NULL); if (fs == NULL) { D("missing sched for flowset %d", i); break; @@ -1662,8 +1670,8 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) #endif break; /* no change, nothing to do */ } - if (oldc != dn_cfg.fsk_count) /* new item */ - dn_cfg.id++; + if (oldc != V_dn_cfg.fsk_count) /* new item */ + V_dn_cfg.id++; s = locate_scheduler(nfs->sched_nr); /* detach from old scheduler if needed, preserving * queues if we need to reattach. Then update the @@ -1729,8 +1737,8 @@ config_sched(struct dn_sch *_nsch, struct dn_id *arg) return EINVAL; /* make sure we have some buckets */ if (a.sch->flags & DN_HAVE_MASK) - ipdn_bound_var((int *)&a.sch->buckets, dn_cfg.hash_size, - 1, dn_cfg.max_hash_size, "sched buckets"); + ipdn_bound_var((int *)&a.sch->buckets, V_dn_cfg.hash_size, + 1, V_dn_cfg.max_hash_size, "sched buckets"); /* XXX other sanity checks */ bzero(&p, sizeof(p)); @@ -1748,14 +1756,14 @@ again: /* run twice, for wfq and fifo */ * lookup the type. If not supplied, use the previous one * or default to WF2Q+. Otherwise, return an error. */ - dn_cfg.id++; + V_dn_cfg.id++; a.fp = find_sched_type(a.sch->oid.subtype, a.sch->name); if (a.fp != NULL) { /* found. Lookup or create entry */ - s = dn_ht_find(dn_cfg.schedhash, i, DNHT_INSERT, &a); + s = dn_ht_find(V_dn_cfg.schedhash, i, DNHT_INSERT, &a); } else if (a.sch->oid.subtype == 0 && !a.sch->name[0]) { /* No type. search existing s* or retry with WF2Q+ */ - s = dn_ht_find(dn_cfg.schedhash, i, 0, &a); + s = dn_ht_find(V_dn_cfg.schedhash, i, 0, &a); if (s != NULL) { a.fp = s->fp; /* Scheduler exists, skip to FIFO scheduler @@ -1827,7 +1835,7 @@ again: /* run twice, for wfq and fifo */ memcpy(pf, s->profile, sizeof(*pf)); } /* remove from the hash */ - dn_ht_find(dn_cfg.schedhash, i, DNHT_REMOVE, NULL); + dn_ht_find(V_dn_cfg.schedhash, i, DNHT_REMOVE, NULL); /* Detach flowsets, preserve queues. */ // schk_delete_cb(s, NULL); // XXX temporarily, kill queues @@ -1845,7 +1853,7 @@ again: /* run twice, for wfq and fifo */ * trying to reuse existing ones if available */ if (!(s->fp->flags & DN_MULTIQUEUE) && !s->fs) { *** 383 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 4F5BA654648; Thu, 17 Jun 2021 14:54: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 4G5Q7t0wlxz4vch; Thu, 17 Jun 2021 14:54: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 EC48711738; Thu, 17 Jun 2021 14:54: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 15HEsn0f010855; Thu, 17 Jun 2021 14:54:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsnB5010854; Thu, 17 Jun 2021 14:54:49 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:49 GMT Message-Id: <202106171454.15HEsnB5010854@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: f63211f546b9 - stable/13 - dummynet: Fix schedlist and aqmlist locking 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: f63211f546b96a1585a8d41b1396c36ff696b3f6 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, 17 Jun 2021 14:54:50 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f63211f546b96a1585a8d41b1396c36ff696b3f6 commit f63211f546b96a1585a8d41b1396c36ff696b3f6 Author: Kristof Provost AuthorDate: 2021-05-21 12:26:49 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 12:38:07 +0000 dummynet: Fix schedlist and aqmlist locking These are global (i.e. shared across vnets) structures, so we need global lock to protect them. However, we look up entries in these lists (find_aqm_type(), find_sched_type()) and return them. We must ensure that the returned structures cannot go away while we are using them. Resolve this by using NET_EPOCH(). The structures can be safely accessed under it, and we postpone their cleanup until we're sure they're no longer used. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30381 (cherry picked from commit 51d73df18e4d120f6f062062c18efae3ed5193a6) --- sys/netpfil/ipfw/dn_aqm.h | 4 +- sys/netpfil/ipfw/dn_sched.h | 4 +- sys/netpfil/ipfw/ip_dn_glue.c | 6 +- sys/netpfil/ipfw/ip_dummynet.c | 122 +++++++++++++++++++++++++++++------------ 4 files changed, 98 insertions(+), 38 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index b0eaf2ecfc8a..cfa1c266c7c8 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -36,6 +36,8 @@ #ifndef _IP_DN_AQM_H #define _IP_DN_AQM_H +#include + /* NOW is the current time in millisecond*/ #define NOW ((V_dn_cfg.curr_time * tick) / 1000) @@ -107,7 +109,7 @@ typedef int32_t aqm_stime_t; int ref_count; /*Number of queues instances in the system */ int cfg_ref_count; /*Number of AQM instances in the system */ - SLIST_ENTRY (dn_aqm) next; /* Next AQM in the list */ + CK_LIST_ENTRY(dn_aqm) next; /* Next AQM in the list */ }; /* Helper function to update queue and scheduler statistics. diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h index 1aa885ce3ccf..5c506c1d30ac 100644 --- a/sys/netpfil/ipfw/dn_sched.h +++ b/sys/netpfil/ipfw/dn_sched.h @@ -35,6 +35,8 @@ #ifndef _DN_SCHED_H #define _DN_SCHED_H +#include + #define DN_MULTIQUEUE 0x01 /* * Descriptor for a scheduling algorithm. @@ -141,7 +143,7 @@ struct dn_alg { /* run-time fields */ int ref_count; /* XXX number of instances in the system */ - SLIST_ENTRY(dn_alg) next; /* Next scheduler in the list */ + CK_LIST_ENTRY(dn_alg) next; /* Next scheduler in the list */ }; /* MSVC does not support initializers so we need this ugly macro */ diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c index 83f26cb23680..e035fedaaf91 100644 --- a/sys/netpfil/ipfw/ip_dn_glue.c +++ b/sys/netpfil/ipfw/ip_dn_glue.c @@ -814,7 +814,11 @@ ip_dummynet_compat(struct sockopt *sopt) break; case IP_DUMMYNET_CONFIGURE: - v = malloc(len, M_TEMP, M_WAITOK); + v = malloc(len, M_TEMP, M_NOWAIT); + if (v == NULL) { + error = ENOMEM; + break; + } error = sooptcopyin(sopt, v, len, len); if (error) break; diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index 3abc78fc1410..b03ad93041bd 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include +#include #include #include #include @@ -94,9 +95,10 @@ static struct task dn_task; static struct taskqueue *dn_tq = NULL; /* global scheduler list */ -struct dn_alg_head schedlist; +struct mtx sched_mtx; +CK_LIST_HEAD(, dn_alg) schedlist; #ifdef NEW_AQM -struct dn_aqm_head aqmlist; /* list of AQMs */ +CK_LIST_HEAD(, dn_aqm) aqmlist; /* list of AQMs */ #endif static void @@ -125,7 +127,9 @@ find_aqm_type(int type, char *name) { struct dn_aqm *d; - SLIST_FOREACH(d, &aqmlist, next) { + NET_EPOCH_ASSERT(); + + CK_LIST_FOREACH(d, &aqmlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -139,7 +143,9 @@ find_sched_type(int type, char *name) { struct dn_alg *d; - SLIST_FOREACH(d, &schedlist, next) { + NET_EPOCH_ASSERT(); + + CK_LIST_FOREACH(d, &schedlist, next) { if (d->type == type || (name && !strcasecmp(d->name, name))) return d; } @@ -1355,7 +1361,7 @@ get_aqm_parms(struct sockopt *sopt) err = EINVAL; return err; } - ep = malloc(l, M_DUMMYNET, M_WAITOK); + ep = malloc(l, M_DUMMYNET, M_NOWAIT); if(!ep) { err = ENOMEM ; return err; @@ -1410,7 +1416,7 @@ get_sched_parms(struct sockopt *sopt) err = EINVAL; return err; } - ep = malloc(l, M_DUMMYNET, M_WAITOK); + ep = malloc(l, M_DUMMYNET, M_NOWAIT); if(!ep) { err = ENOMEM ; return err; @@ -1455,6 +1461,8 @@ config_aqm(struct dn_fsk *fs, struct dn_extra_parms *ep, int busy) { int err = 0; + NET_EPOCH_ASSERT(); + do { /* no configurations */ if (!ep) { @@ -1614,7 +1622,7 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) #ifdef NEW_AQM ep = NULL; if (arg != NULL) { - ep = malloc(sizeof(*ep), M_TEMP, locked ? M_NOWAIT : M_WAITOK); + ep = malloc(sizeof(*ep), M_TEMP, M_NOWAIT); if (ep == NULL) return (NULL); memcpy(ep, arg, sizeof(*ep)); @@ -1727,6 +1735,8 @@ config_sched(struct dn_sch *_nsch, struct dn_id *arg) int pipe_cmd; int err = ENOMEM; + NET_EPOCH_ASSERT(); + a.sch = _nsch; if (a.sch->oid.len != sizeof(*a.sch)) { D("bad sched len %d", a.sch->oid.len); @@ -2070,34 +2080,53 @@ do_config(void *p, int l) DN_BH_WUNLOCK(); break; case DN_TEXT: /* store argument of next block */ - if (arg != NULL) - free(arg, M_TEMP); - arg = malloc(o.len, M_TEMP, M_WAITOK); + free(arg, M_TEMP); + arg = malloc(o.len, M_TEMP, M_NOWAIT); + if (arg == NULL) { + err = ENOMEM; + break; + } memcpy(arg, (char *)p + off, o.len); break; case DN_LINK: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->link, (char *)p + off, sizeof(dn->link)); err = config_link(&dn->link, arg); break; case DN_PROFILE: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->profile, (char *)p + off, sizeof(dn->profile)); err = config_profile(&dn->profile, arg); break; case DN_SCH: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->sched, (char *)p + off, sizeof(dn->sched)); err = config_sched(&dn->sched, arg); break; case DN_FS: if (dn == NULL) - dn = malloc(sizeof(*dn), M_TEMP, M_WAITOK); + dn = malloc(sizeof(*dn), M_TEMP, M_NOWAIT); + if (dn == NULL) { + err = ENOMEM; + break; + } memcpy(&dn->fs, (char *)p + off, sizeof(dn->fs)); err = (NULL == config_fs(&dn->fs, arg, 0)); break; @@ -2230,7 +2259,11 @@ dummynet_get(struct sockopt *sopt, void **compat) #endif if (l > sizeof(r)) { /* request larger than default, allocate buffer */ - cmd = malloc(l, M_DUMMYNET, M_WAITOK); + cmd = malloc(l, M_DUMMYNET, M_NOWAIT); + if (cmd == NULL) { + error = ENOMEM; + goto done; + } error = sooptcopyin(sopt, cmd, l, l); sopt->sopt_valsize = sopt_valsize; if (error) @@ -2298,7 +2331,7 @@ dummynet_get(struct sockopt *sopt, void **compat) break; have = need; - start = malloc(have, M_DUMMYNET, M_WAITOK | M_ZERO); + start = malloc(have, M_DUMMYNET, M_NOWAIT | M_ZERO); } if (start == NULL) { @@ -2461,6 +2494,7 @@ dn_drain_queue(void) static int ip_dn_ctl(struct sockopt *sopt) { + struct epoch_tracker et; void *p = NULL; int error, l; @@ -2475,6 +2509,8 @@ ip_dn_ctl(struct sockopt *sopt) return (error); } + NET_EPOCH_ENTER(et); + switch (sopt->sopt_name) { default : D("dummynet: unknown option %d", sopt->sopt_name); @@ -2499,7 +2535,11 @@ ip_dn_ctl(struct sockopt *sopt) D("argument len %d invalid", l); break; } - p = malloc(l, M_TEMP, M_WAITOK); // XXX can it fail ? + p = malloc(l, M_TEMP, M_NOWAIT); + if (p == NULL) { + error = ENOMEM; + break; + } error = sooptcopyin(sopt, p, l, l); if (error) break ; @@ -2510,6 +2550,8 @@ ip_dn_ctl(struct sockopt *sopt) if (p != NULL) free(p, M_TEMP); + NET_EPOCH_EXIT(et); + return error ; } @@ -2578,13 +2620,16 @@ ip_dn_init(void) { if (dn_tasks_started) return; + + mtx_init(&sched_mtx, "dn_sched", NULL, MTX_DEF); + dn_tasks_started = 1; TASK_INIT(&dn_task, 0, dummynet_task, NULL); dn_tq = taskqueue_create_fast("dummynet", M_WAITOK, taskqueue_thread_enqueue, &dn_tq); taskqueue_start_threads(&dn_tq, 1, PI_NET, "dummynet"); - SLIST_INIT(&schedlist); + CK_LIST_INIT(&schedlist); callout_init(&dn_timeout, 1); dn_reschedule(); } @@ -2644,16 +2689,16 @@ load_dn_sched(struct dn_alg *d) } /* Search if scheduler already exists */ - DN_BH_WLOCK(); - SLIST_FOREACH(s, &schedlist, next) { + mtx_lock(&sched_mtx); + CK_LIST_FOREACH(s, &schedlist, next) { if (strcmp(s->name, d->name) == 0) { D("%s already loaded", d->name); break; /* scheduler already exists */ } } if (s == NULL) - SLIST_INSERT_HEAD(&schedlist, d, next); - DN_BH_WUNLOCK(); + CK_LIST_INSERT_HEAD(&schedlist, d, next); + mtx_unlock(&sched_mtx); D("dn_sched %s %sloaded", d->name, s ? "not ":""); return s ? 1 : 0; } @@ -2666,17 +2711,18 @@ unload_dn_sched(struct dn_alg *s) ND("called for %s", s->name); - DN_BH_WLOCK(); - SLIST_FOREACH_SAFE(r, &schedlist, next, tmp) { + mtx_lock(&sched_mtx); + CK_LIST_FOREACH_SAFE(r, &schedlist, next, tmp) { if (strcmp(s->name, r->name) != 0) continue; ND("ref_count = %d", r->ref_count); err = (r->ref_count != 0) ? EBUSY : 0; if (err == 0) - SLIST_REMOVE(&schedlist, r, dn_alg, next); + CK_LIST_REMOVE(r, next); break; } - DN_BH_WUNLOCK(); + mtx_unlock(&sched_mtx); + NET_EPOCH_WAIT(); D("dn_sched %s %sunloaded", s->name, err ? "not ":""); return err; } @@ -2736,17 +2782,20 @@ load_dn_aqm(struct dn_aqm *d) return 1; } + mtx_lock(&sched_mtx); + /* Search if AQM already exists */ - DN_BH_WLOCK(); /* XXX Global lock? */ - SLIST_FOREACH(aqm, &aqmlist, next) { + CK_LIST_FOREACH(aqm, &aqmlist, next) { if (strcmp(aqm->name, d->name) == 0) { D("%s already loaded", d->name); break; /* AQM already exists */ } } if (aqm == NULL) - SLIST_INSERT_HEAD(&aqmlist, d, next); - DN_BH_WUNLOCK(); + CK_LIST_INSERT_HEAD(&aqmlist, d, next); + + mtx_unlock(&sched_mtx); + D("dn_aqm %s %sloaded", d->name, aqm ? "not ":""); return aqm ? 1 : 0; } @@ -2775,21 +2824,24 @@ unload_dn_aqm(struct dn_aqm *aqm) err = 0; ND("called for %s", aqm->name); - DN_BH_WLOCK(); - /* clean up AQM status and deconfig flowset */ dn_ht_scan(V_dn_cfg.fshash, fs_cleanup, &aqm->type); - SLIST_FOREACH_SAFE(r, &aqmlist, next, tmp) { + mtx_lock(&sched_mtx); + + CK_LIST_FOREACH_SAFE(r, &aqmlist, next, tmp) { if (strcmp(aqm->name, r->name) != 0) continue; ND("ref_count = %d", r->ref_count); err = (r->ref_count != 0 || r->cfg_ref_count != 0) ? EBUSY : 0; if (err == 0) - SLIST_REMOVE(&aqmlist, r, dn_aqm, next); + CK_LIST_REMOVE(r, next); break; } - DN_BH_WUNLOCK(); + + mtx_unlock(&sched_mtx); + NET_EPOCH_WAIT(); + D("%s %sunloaded", aqm->name, err ? "not ":""); if (err) D("ref_count=%d, cfg_ref_count=%d", r->ref_count, r->cfg_ref_count); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 722166543B2; Thu, 17 Jun 2021 14:54: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 4G5Q7v2CdGz4vcm; Thu, 17 Jun 2021 14:54: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 23E8B11807; Thu, 17 Jun 2021 14:54: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 15HEspr6010879; Thu, 17 Jun 2021 14:54:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEspYR010878; Thu, 17 Jun 2021 14:54:51 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:51 GMT Message-Id: <202106171454.15HEspYR010878@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: 932531232a9d - stable/13 - dummynet: free(NULL, M_DUMMYNET); is safe 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: 932531232a9d97aad2e3302a365b85bee59a8db5 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, 17 Jun 2021 14:54:51 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=932531232a9d97aad2e3302a365b85bee59a8db5 commit 932531232a9d97aad2e3302a365b85bee59a8db5 Author: Kristof Provost AuthorDate: 2021-05-21 14:55:07 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 12:38:08 +0000 dummynet: free(NULL, M_DUMMYNET); is safe There's no need to check pointers for NULL before free()ing them. No functional change. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30382 (cherry picked from commit 1b2dbe37fa32d7255faf7d1feec7bb31414a8102) --- sys/netpfil/ipfw/ip_dummynet.c | 46 ++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index b03ad93041bd..56fa56138d96 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -757,8 +757,7 @@ fsk_detach(struct dn_fsk *fs, int flags) /* Free the RED parameters, they will be recomputed on * subsequent attach if needed. */ - if (fs->w_q_lookup) - free(fs->w_q_lookup, M_DUMMYNET); + free(fs->w_q_lookup, M_DUMMYNET); fs->w_q_lookup = NULL; qht_delete(fs, flags); #ifdef NEW_AQM @@ -910,10 +909,9 @@ schk_delete_cb(void *obj, void *arg) dn_ht_free(s->siht, 0); } else if (s->siht) si_destroy(s->siht, NULL); - if (s->profile) { - free(s->profile, M_DUMMYNET); - s->profile = NULL; - } + + free(s->profile, M_DUMMYNET); + s->profile = NULL; s->siht = NULL; if (s->fp->destroy) s->fp->destroy(s); @@ -1237,10 +1235,8 @@ config_red(struct dn_fsk *fs) } /* If the lookup table already exist, free and create it again. */ - if (fs->w_q_lookup) { - free(fs->w_q_lookup, M_DUMMYNET); - fs->w_q_lookup = NULL; - } + free(fs->w_q_lookup, M_DUMMYNET); + fs->w_q_lookup = NULL; if (V_dn_cfg.red_lookup_depth == 0) { printf("\ndummynet: net.inet.ip.dummynet.red_lookup_depth" "must be > 0\n"); @@ -1579,10 +1575,9 @@ config_link(struct dn_link *p, struct dn_id *arg) return EINVAL; } /* remove profile if exists */ - if (s->profile) { - free(s->profile, M_DUMMYNET); - s->profile = NULL; - } + free(s->profile, M_DUMMYNET); + s->profile = NULL; + /* copy all parameters */ s->link.oid = p->oid; s->link.link_nr = i; @@ -1706,8 +1701,7 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked) if (!locked) DN_BH_WUNLOCK(); #ifdef NEW_AQM - if (ep != NULL) - free(ep, M_TEMP); + free(ep, M_TEMP); #endif return fs; } @@ -1906,8 +1900,7 @@ next: err = 0; error: DN_BH_WUNLOCK(); - if (pf) - free(pf, M_DUMMYNET); + free(pf, M_DUMMYNET); return err; } @@ -2135,10 +2128,8 @@ do_config(void *p, int l) break; off += o.len; } - if (arg != NULL) - free(arg, M_TEMP); - if (dn != NULL) - free(dn, M_TEMP); + free(arg, M_TEMP); + free(dn, M_TEMP); return err; } @@ -2324,8 +2315,7 @@ dummynet_get(struct sockopt *sopt, void **compat) break; DN_BH_WUNLOCK(); - if (start) - free(start, M_DUMMYNET); + free(start, M_DUMMYNET); start = NULL; if (need > sopt_valsize) break; @@ -2383,10 +2373,9 @@ dummynet_get(struct sockopt *sopt, void **compat) error = sooptcopyout(sopt, start, buf - start); } done: - if (cmd && cmd != &r.o) + if (cmd != &r.o) free(cmd, M_DUMMYNET); - if (start) - free(start, M_DUMMYNET); + free(start, M_DUMMYNET); return error; } @@ -2547,8 +2536,7 @@ ip_dn_ctl(struct sockopt *sopt) break; } - if (p != NULL) - free(p, M_TEMP); + free(p, M_TEMP); NET_EPOCH_EXIT(et); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 D39F9654814; Thu, 17 Jun 2021 14:54: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 4G5Q7w3YR7z4vRf; Thu, 17 Jun 2021 14:54: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 44D2511459; Thu, 17 Jun 2021 14:54: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 15HEsqBL010910; Thu, 17 Jun 2021 14:54:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsq8A010909; Thu, 17 Jun 2021 14:54:52 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:52 GMT Message-Id: <202106171454.15HEsq8A010909@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: 3a57bb60f4ad - stable/13 - pf: use M_WAITOK where possible 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: 3a57bb60f4ad6afdfc0bbf833e7b6cf62a2038e8 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, 17 Jun 2021 14:54:53 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=3a57bb60f4ad6afdfc0bbf833e7b6cf62a2038e8 commit 3a57bb60f4ad6afdfc0bbf833e7b6cf62a2038e8 Author: Kristof Provost AuthorDate: 2021-06-09 12:00:07 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 12:38:08 +0000 pf: use M_WAITOK where possible In the ioctl path use M_WAITOK allocations whereever possible. These are less sensitive to memory pressure, and ioctl requests have no hard deadlines. Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30702 (cherry picked from commit ea21980a3facfed4c2c6fd10d0f16276564fb540) --- sys/netpfil/pf/pf_ioctl.c | 78 ++++++++--------------------------------------- 1 file changed, 13 insertions(+), 65 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index be7b8be23a31..30f12da782e6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -3773,11 +3773,7 @@ DIOCCHANGEADDR_error: totlen = io->pfrio_size * sizeof(struct pfr_table); pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_NOWAIT); - if (pfrts == NULL) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -3862,11 +3858,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -3900,11 +3892,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -3942,11 +3930,7 @@ DIOCCHANGEADDR_error: } totlen = count * sizeof(struct pfr_addr); pfras = mallocarray(count, sizeof(struct pfr_addr), M_TEMP, - M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -3981,11 +3965,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); PF_RULES_RLOCK(); error = pfr_get_addrs(&io->pfrio_table, pfras, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -4013,11 +3993,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_astats); pfrastats = mallocarray(io->pfrio_size, - sizeof(struct pfr_astats), M_TEMP, M_NOWAIT); - if (! pfrastats) { - error = ENOMEM; - break; - } + sizeof(struct pfr_astats), M_TEMP, M_WAITOK); PF_RULES_RLOCK(); error = pfr_get_astats(&io->pfrio_table, pfrastats, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -4045,11 +4021,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -4083,11 +4055,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -4121,11 +4089,7 @@ DIOCCHANGEADDR_error: } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_NOWAIT); - if (! pfras) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -4174,11 +4138,7 @@ DIOCCHANGEADDR_error: } totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_NOWAIT); - if (! ioes) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -4251,11 +4211,7 @@ DIOCCHANGEADDR_error: } totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_NOWAIT); - if (! ioes) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -4330,11 +4286,7 @@ DIOCCHANGEADDR_error: totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_NOWAIT); - if (ioes == NULL) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -4537,11 +4489,7 @@ DIOCCHANGEADDR_error: bufsiz = io->pfiio_size * sizeof(struct pfi_kif); ifstore = mallocarray(io->pfiio_size, sizeof(struct pfi_kif), - M_TEMP, M_NOWAIT); - if (ifstore == NULL) { - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); PF_RULES_RLOCK(); pfi_get_ifaces(io->pfiio_name, ifstore, &io->pfiio_size); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 14:54: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 C12526543E1; Thu, 17 Jun 2021 14:54: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 4G5Q7x4F3dz4vZh; Thu, 17 Jun 2021 14:54: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 6884A11614; Thu, 17 Jun 2021 14:54: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 15HEsrTl010934; Thu, 17 Jun 2021 14:54:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HEsrZg010933; Thu, 17 Jun 2021 14:54:53 GMT (envelope-from git) Date: Thu, 17 Jun 2021 14:54:53 GMT Message-Id: <202106171454.15HEsrZg010933@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: ea01d2bc1c5c - stable/13 - pf: don't hold a lock during copyout() 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: ea01d2bc1c5cfa2aed195e99dec08d36582121d2 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, 17 Jun 2021 14:54:54 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ea01d2bc1c5cfa2aed195e99dec08d36582121d2 commit ea01d2bc1c5cfa2aed195e99dec08d36582121d2 Author: Kristof Provost AuthorDate: 2021-06-14 12:04:02 +0000 Commit: Kristof Provost CommitDate: 2021-06-17 12:38:08 +0000 pf: don't hold a lock during copyout() copyout() can trigger page faults, so it may potentially sleep. Reported by: avg MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 8b5f4e692b1d1585ecfc6690552650114e3e704e) --- sys/netpfil/pf/pf_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 30f12da782e6..657c0e1945d3 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2521,8 +2521,6 @@ DIOCADDRULENV_error: ERROUT(ENOSPC); } - error = copyout(nvlpacked, nv->data, nv->len); - if (clear_counter) { counter_u64_zero(rule->evaluations); for (int i = 0; i < 2; i++) { @@ -2533,6 +2531,8 @@ DIOCADDRULENV_error: } PF_RULES_WUNLOCK(); + error = copyout(nvlpacked, nv->data, nv->len); + #undef ERROUT DIOCGETRULENV_error: free(nvlpacked, M_NVLIST); From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 18:39: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 42050657939; Thu, 17 Jun 2021 18:39: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 4G5W7B1Q9Zz3Qp5; Thu, 17 Jun 2021 18:39:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D5C71483E; Thu, 17 Jun 2021 18:39:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15HIdXdv003481; Thu, 17 Jun 2021 18:39:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HIdXUk003480; Thu, 17 Jun 2021 18:39:33 GMT (envelope-from git) Date: Thu, 17 Jun 2021 18:39:33 GMT Message-Id: <202106171839.15HIdXUk003480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: ee3a7246c65c - stable/13 - gmultipath: make physpath distinct from the underlying providers' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ee3a7246c65ceb2fdcfcf8d337dbdeaa315a332d 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, 17 Jun 2021 18:39:34 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=ee3a7246c65ceb2fdcfcf8d337dbdeaa315a332d commit ee3a7246c65ceb2fdcfcf8d337dbdeaa315a332d Author: Alan Somers AuthorDate: 2021-04-22 21:09:03 +0000 Commit: Alan Somers CommitDate: 2021-06-17 18:39:14 +0000 gmultipath: make physpath distinct from the underlying providers' zfsd uses a device's physical path attribute to automatically replace a missing ZFS disk when a blank disk is inserted into the same physical slot. Currently gmultipath passes through its underlying providers' physical path attribute. That may cause zfsd to replace a missing gmultipath provider with a newly arrived, single-path disk. That would be bad. This commit fixes that problem by simply appending "/mp" to the underlying providers' physical path, in a manner similar to what geli already does. Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D29941 (cherry picked from commit 420dbe763f15b076751443edfeeb4f676deb3c44) --- sys/geom/multipath/g_multipath.c | 6 ++++++ tests/sys/geom/class/multipath/misc.sh | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/geom/multipath/g_multipath.c b/sys/geom/multipath/g_multipath.c index 5972b63e680a..120fced0a8f1 100644 --- a/sys/geom/multipath/g_multipath.c +++ b/sys/geom/multipath/g_multipath.c @@ -394,6 +394,12 @@ g_multipath_done(struct bio *bp) mtx_unlock(&sc->sc_mtx); } else mtx_unlock(&sc->sc_mtx); + if (bp->bio_error == 0 && + bp->bio_cmd == BIO_GETATTR && + !strcmp(bp->bio_attribute, "GEOM::physpath")) + { + strlcat(bp->bio_data, "/mp", bp->bio_length); + } g_std_done(bp); } } diff --git a/tests/sys/geom/class/multipath/misc.sh b/tests/sys/geom/class/multipath/misc.sh index 583434e1cfa5..4da8462588ca 100755 --- a/tests/sys/geom/class/multipath/misc.sh +++ b/tests/sys/geom/class/multipath/misc.sh @@ -198,7 +198,7 @@ fail_on_error_cleanup() atf_test_case physpath cleanup physpath_head() { - atf_set "descr" "gmultipath should pass through the underlying providers' physical path" + atf_set "descr" "gmultipath should append /mp to the underlying providers' physical path" atf_set "require.user" "root" } physpath_body() @@ -217,7 +217,7 @@ physpath_body() atf_check gnop create -z $physpath /dev/${md1} atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop gmultipath_physpath=$(diskinfo -p multipath/"$name") - atf_check_equal "$physpath" "$gmultipath_physpath" + atf_check_equal "$physpath/mp" "$gmultipath_physpath" } physpath_cleanup() { From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 19:26: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 3117565AFDF; Thu, 17 Jun 2021 19:26: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 4G5X9n70Bgz3kL4; Thu, 17 Jun 2021 19:26: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 D502E15223; Thu, 17 Jun 2021 19:26: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 15HJQrIe069292; Thu, 17 Jun 2021 19:26:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HJQrg6069291; Thu, 17 Jun 2021 19:26:53 GMT (envelope-from git) Date: Thu, 17 Jun 2021 19:26:53 GMT Message-Id: <202106171926.15HJQrg6069291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: c0e72b2bc081 - stable/13 - Delete obsolete Solaris compat files MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c0e72b2bc0816fe923100ceb7bf639764b8c317c 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, 17 Jun 2021 19:26:54 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=c0e72b2bc0816fe923100ceb7bf639764b8c317c commit c0e72b2bc0816fe923100ceb7bf639764b8c317c Author: Alan Somers AuthorDate: 2021-05-24 14:47:44 +0000 Commit: Alan Somers CommitDate: 2021-06-17 18:40:00 +0000 Delete obsolete Solaris compat files These files have been unused ever since the OpenSolaris import Sponsored by: Axcient Reviewed By: freqlabs Differential Revision: https://reviews.freebsd.org/D30371 (cherry picked from commit fc3ba3e9fac03897d17c318b79b52d91cfb87b9e) --- cddl/compat/opensolaris/misc/deviceid.c | 115 ------- cddl/compat/opensolaris/misc/fsshare.c | 262 --------------- cddl/compat/opensolaris/misc/mkdirp.c | 215 ------------ cddl/compat/opensolaris/misc/mnttab.c | 216 ------------ cddl/compat/opensolaris/misc/thread_pool.c | 428 ------------------------ cddl/compat/opensolaris/misc/thread_pool_impl.h | 99 ------ cddl/compat/opensolaris/misc/zmount.c | 106 ------ cddl/compat/opensolaris/misc/zone.c | 46 --- 8 files changed, 1487 deletions(-) diff --git a/cddl/compat/opensolaris/misc/deviceid.c b/cddl/compat/opensolaris/misc/deviceid.c deleted file mode 100644 index 9f3ea8458b3b..000000000000 --- a/cddl/compat/opensolaris/misc/deviceid.c +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * Copyright (c) 2007 Pawel Jakub Dawidek - * All rights reserved. - * - * 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 AUTHORS 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 AUTHORS 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -int -devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) -{ - - if (strlcpy(retdevid->devid, devidstr, sizeof(retdevid->devid)) >= - sizeof(retdevid->devid)) { - return (EINVAL); - } - *retminor_name = strdup(""); - if (*retminor_name == NULL) - return (ENOMEM); - return (0); -} - -int -devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, - devid_nmlist_t **retlist) -{ - char path[MAXPATHLEN]; - char *dst; - - if (g_get_name(devid.devid, path, sizeof(path)) == -1) - return (errno); - *retlist = malloc(sizeof(**retlist)); - if (*retlist == NULL) - return (ENOMEM); - if (strlcpy((*retlist)[0].devname, path, - sizeof((*retlist)[0].devname)) >= sizeof((*retlist)[0].devname)) { - free(*retlist); - return (ENAMETOOLONG); - } - return (0); -} - -void -devid_str_free(char *str) -{ - - free(str); -} - -void -devid_free(ddi_devid_t devid) -{ - /* Do nothing. */ -} - -void -devid_free_nmlist(devid_nmlist_t *list) -{ - - free(list); -} - -int -devid_get(int fd, ddi_devid_t *retdevid) -{ - - return (ENOENT); -} - -int -devid_get_minor_name(int fd, char **retminor_name) -{ - - *retminor_name = strdup(""); - if (*retminor_name == NULL) - return (ENOMEM); - return (0); -} - -char * -devid_str_encode(ddi_devid_t devid, char *minor_name) -{ - - return (strdup(devid.devid)); -} diff --git a/cddl/compat/opensolaris/misc/fsshare.c b/cddl/compat/opensolaris/misc/fsshare.c deleted file mode 100644 index 97f5e20f42f6..000000000000 --- a/cddl/compat/opensolaris/misc/fsshare.c +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * Copyright (c) 2007 Pawel Jakub Dawidek - * All rights reserved. - * - * 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 AUTHORS 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 AUTHORS 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include -#include -#include -#include /* _PATH_MOUNTDPID */ -#include -#include -#include -#include - -#define FILE_HEADER "# !!! DO NOT EDIT THIS FILE MANUALLY !!!\n\n" -#define OPTSSIZE 1024 -#define MAXLINESIZE (PATH_MAX + OPTSSIZE) - -static void -restart_mountd(void) -{ - struct pidfh *pfh; - pid_t mountdpid; - - pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid); - if (pfh != NULL) { - /* Mountd is not running. */ - pidfile_remove(pfh); - return; - } - if (errno != EEXIST) { - /* Cannot open pidfile for some reason. */ - return; - } - /* We have mountd(8) PID in mountdpid varible. */ - kill(mountdpid, SIGHUP); -} - -/* - * Read one line from a file. Skip comments, empty lines and a line with a - * mountpoint specified in the 'skip' argument. - */ -static char * -zgetline(FILE *fd, const char *skip) -{ - static char line[MAXLINESIZE]; - size_t len, skiplen; - char *s, last; - - if (skip != NULL) - skiplen = strlen(skip); - for (;;) { - s = fgets(line, sizeof(line), fd); - if (s == NULL) - return (NULL); - /* Skip empty lines and comments. */ - if (line[0] == '\n' || line[0] == '#') - continue; - len = strlen(line); - if (line[len - 1] == '\n') - line[len - 1] = '\0'; - last = line[skiplen]; - /* Skip the given mountpoint. */ - if (skip != NULL && strncmp(skip, line, skiplen) == 0 && - (last == '\t' || last == ' ' || last == '\0')) { - continue; - } - break; - } - return (line); -} - -/* - * Function translate options to a format acceptable by exports(5), eg. - * - * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0 freefall.freebsd.org 69.147.83.54 - * - * Accepted input formats: - * - * ro,network=192.168.0.0,mask=255.255.255.0,maproot=0,freefall.freebsd.org - * ro network=192.168.0.0 mask=255.255.255.0 maproot=0 freefall.freebsd.org - * -ro,-network=192.168.0.0,-mask=255.255.255.0,-maproot=0,freefall.freebsd.org - * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0 freefall.freebsd.org - * - * Recognized keywords: - * - * ro, maproot, mapall, mask, network, sec, alldirs, public, webnfs, index, quiet - * - */ -static const char *known_opts[] = { "ro", "maproot", "mapall", "mask", - "network", "sec", "alldirs", "public", "webnfs", "index", "quiet", NULL }; -static char * -translate_opts(const char *shareopts) -{ - static char newopts[OPTSSIZE]; - char oldopts[OPTSSIZE]; - char *o, *s = NULL; - unsigned int i; - size_t len; - - strlcpy(oldopts, shareopts, sizeof(oldopts)); - newopts[0] = '\0'; - s = oldopts; - while ((o = strsep(&s, "-, ")) != NULL) { - if (o[0] == '\0') - continue; - for (i = 0; known_opts[i] != NULL; i++) { - len = strlen(known_opts[i]); - if (strncmp(known_opts[i], o, len) == 0 && - (o[len] == '\0' || o[len] == '=')) { - strlcat(newopts, "-", sizeof(newopts)); - break; - } - } - strlcat(newopts, o, sizeof(newopts)); - strlcat(newopts, " ", sizeof(newopts)); - } - return (newopts); -} - -static int -fsshare_main(const char *file, const char *mountpoint, const char *shareopts, - int share) -{ - char tmpfile[PATH_MAX]; - char *line; - FILE *newfd, *oldfd; - int fd, error; - - newfd = oldfd = NULL; - error = 0; - - /* - * Create temporary file in the same directory, so we can atomically - * rename it. - */ - if (strlcpy(tmpfile, file, sizeof(tmpfile)) >= sizeof(tmpfile)) - return (ENAMETOOLONG); - if (strlcat(tmpfile, ".XXXXXXXX", sizeof(tmpfile)) >= sizeof(tmpfile)) - return (ENAMETOOLONG); - fd = mkstemp(tmpfile); - if (fd == -1) - return (errno); - /* - * File name is random, so we don't really need file lock now, but it - * will be needed after rename(2). - */ - error = flock(fd, LOCK_EX); - assert(error == 0 || (error == -1 && errno == EOPNOTSUPP)); - newfd = fdopen(fd, "r+"); - assert(newfd != NULL); - /* Open old exports file. */ - oldfd = fopen(file, "r"); - if (oldfd == NULL) { - if (share) { - if (errno != ENOENT) { - error = errno; - goto out; - } - } else { - /* If there is no exports file, ignore the error. */ - if (errno == ENOENT) - errno = 0; - error = errno; - goto out; - } - } else { - error = flock(fileno(oldfd), LOCK_EX); - assert(error == 0 || (error == -1 && errno == EOPNOTSUPP)); - error = 0; - } - - /* Place big, fat warning at the begining of the file. */ - fprintf(newfd, "%s", FILE_HEADER); - while (oldfd != NULL && (line = zgetline(oldfd, mountpoint)) != NULL) - fprintf(newfd, "%s\n", line); - if (oldfd != NULL && ferror(oldfd) != 0) { - error = ferror(oldfd); - goto out; - } - if (ferror(newfd) != 0) { - error = ferror(newfd); - goto out; - } - if (share) { - fprintf(newfd, "%s\t%s\n", mountpoint, - translate_opts(shareopts)); - } - -out: - if (error != 0) - unlink(tmpfile); - else { - if (rename(tmpfile, file) == -1) { - error = errno; - unlink(tmpfile); - } else { - fflush(newfd); - /* - * Send SIGHUP to mountd, but unlock exports file later. - */ - restart_mountd(); - } - } - if (oldfd != NULL) { - flock(fileno(oldfd), LOCK_UN); - fclose(oldfd); - } - if (newfd != NULL) { - flock(fileno(newfd), LOCK_UN); - fclose(newfd); - } - return (error); -} - -/* - * Add the given mountpoint to the given exports file. - */ -int -fsshare(const char *file, const char *mountpoint, const char *shareopts) -{ - - return (fsshare_main(file, mountpoint, shareopts, 1)); -} - -/* - * Remove the given mountpoint from the given exports file. - */ -int -fsunshare(const char *file, const char *mountpoint) -{ - - return (fsshare_main(file, mountpoint, NULL, 0)); -} diff --git a/cddl/compat/opensolaris/misc/mkdirp.c b/cddl/compat/opensolaris/misc/mkdirp.c deleted file mode 100644 index 76a90ad0ec30..000000000000 --- a/cddl/compat/opensolaris/misc/mkdirp.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * $FreeBSD$ - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mkdirp.c 1.15 06/01/04 SMI" - -/* - * Creates directory and it's parents if the parents do not - * exist yet. - * - * Returns -1 if fails for reasons other than non-existing - * parents. - * Does NOT simplify pathnames with . or .. in them. - */ - -#include -#include -#include -#include -#include -#include -#include - -static char *simplify(const char *str); - -int -mkdirp(const char *d, mode_t mode) -{ - char *endptr, *ptr, *slash, *str; - - str = simplify(d); - - /* If space couldn't be allocated for the simplified names, return. */ - - if (str == NULL) - return (-1); - - /* Try to make the directory */ - - if (mkdir(str, mode) == 0) { - free(str); - return (0); - } - if (errno != ENOENT) { - free(str); - return (-1); - } - endptr = strrchr(str, '\0'); - slash = strrchr(str, '/'); - - /* Search upward for the non-existing parent */ - - while (slash != NULL) { - - ptr = slash; - *ptr = '\0'; - - /* If reached an existing parent, break */ - - if (access(str, F_OK) == 0) - break; - - /* If non-existing parent */ - - else { - slash = strrchr(str, '/'); - - /* If under / or current directory, make it. */ - - if (slash == NULL || slash == str) { - if (mkdir(str, mode) != 0 && errno != EEXIST) { - free(str); - return (-1); - } - break; - } - } - } - - /* Create directories starting from upmost non-existing parent */ - - while ((ptr = strchr(str, '\0')) != endptr) { - *ptr = '/'; - if (mkdir(str, mode) != 0 && errno != EEXIST) { - /* - * If the mkdir fails because str already - * exists (EEXIST), then str has the form - * "existing-dir/..", and this is really - * ok. (Remember, this loop is creating the - * portion of the path that didn't exist) - */ - free(str); - return (-1); - } - } - free(str); - return (0); -} - -/* - * simplify - given a pathname, simplify that path by removing - * duplicate contiguous slashes. - * - * A simplified copy of the argument is returned to the - * caller, or NULL is returned on error. - * - * The caller should handle error reporting based upon the - * returned vlaue, and should free the returned value, - * when appropriate. - */ - -static char * -simplify(const char *str) -{ - int i; - size_t mbPathlen; /* length of multi-byte path */ - size_t wcPathlen; /* length of wide-character path */ - wchar_t *wptr; /* scratch pointer */ - wchar_t *wcPath; /* wide-character version of the path */ - char *mbPath; /* The copy fo the path to be returned */ - - /* - * bail out if there is nothing there. - */ - - if (!str) - return (NULL); - - /* - * Get a copy of the argument. - */ - - if ((mbPath = strdup(str)) == NULL) { - return (NULL); - } - - /* - * convert the multi-byte version of the path to a - * wide-character rendering, for doing our figuring. - */ - - mbPathlen = strlen(mbPath); - - if ((wcPath = calloc(sizeof (wchar_t), mbPathlen+1)) == NULL) { - free(mbPath); - return (NULL); - } - - if ((wcPathlen = mbstowcs(wcPath, mbPath, mbPathlen)) == (size_t)-1) { - free(mbPath); - free(wcPath); - return (NULL); - } - - /* - * remove duplicate slashes first ("//../" -> "/") - */ - - for (wptr = wcPath, i = 0; i < wcPathlen; i++) { - *wptr++ = wcPath[i]; - - if (wcPath[i] == '/') { - i++; - - while (wcPath[i] == '/') { - i++; - } - - i--; - } - } - - *wptr = '\0'; - - /* - * now convert back to the multi-byte format. - */ - - if (wcstombs(mbPath, wcPath, mbPathlen) == (size_t)-1) { - free(mbPath); - free(wcPath); - return (NULL); - } - - free(wcPath); - return (mbPath); -} diff --git a/cddl/compat/opensolaris/misc/mnttab.c b/cddl/compat/opensolaris/misc/mnttab.c deleted file mode 100644 index 8f56d90f6232..000000000000 --- a/cddl/compat/opensolaris/misc/mnttab.c +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * Copyright (c) 2006 Pawel Jakub Dawidek - * All rights reserved. - * - * 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 AUTHORS 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 AUTHORS 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. - */ - -/* - * This file implements Solaris compatible getmntany() and hasmntopt() - * functions. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static char * -mntopt(char **p) -{ - char *cp = *p; - char *retstr; - - while (*cp && isspace(*cp)) - cp++; - - retstr = cp; - while (*cp && *cp != ',') - cp++; - - if (*cp) { - *cp = '\0'; - cp++; - } - - *p = cp; - return (retstr); -} - -char * -hasmntopt(struct mnttab *mnt, char *opt) -{ - char tmpopts[MNT_LINE_MAX]; - char *f, *opts = tmpopts; - - if (mnt->mnt_mntopts == NULL) - return (NULL); - (void) strcpy(opts, mnt->mnt_mntopts); - f = mntopt(&opts); - for (; *f; f = mntopt(&opts)) { - if (strncmp(opt, f, strlen(opt)) == 0) - return (f - tmpopts + mnt->mnt_mntopts); - } - return (NULL); -} - -static void -optadd(char *mntopts, size_t size, const char *opt) -{ - - if (mntopts[0] != '\0') - strlcat(mntopts, ",", size); - strlcat(mntopts, opt, size); -} - -void -statfs2mnttab(struct statfs *sfs, struct mnttab *mp) -{ - static char mntopts[MNTMAXSTR]; - long flags; - - mntopts[0] = '\0'; - - flags = sfs->f_flags; -#define OPTADD(opt) optadd(mntopts, sizeof(mntopts), (opt)) - if (flags & MNT_RDONLY) - OPTADD(MNTOPT_RO); - else - OPTADD(MNTOPT_RW); - if (flags & MNT_NOSUID) - OPTADD(MNTOPT_NOSUID); - else - OPTADD(MNTOPT_SETUID); - if (flags & MNT_UPDATE) - OPTADD(MNTOPT_REMOUNT); - if (flags & MNT_NOATIME) - OPTADD(MNTOPT_NOATIME); - else - OPTADD(MNTOPT_ATIME); - OPTADD(MNTOPT_NOXATTR); - if (flags & MNT_NOEXEC) - OPTADD(MNTOPT_NOEXEC); - else - OPTADD(MNTOPT_EXEC); -#undef OPTADD - mp->mnt_special = sfs->f_mntfromname; - mp->mnt_mountp = sfs->f_mntonname; - mp->mnt_fstype = sfs->f_fstypename; - mp->mnt_mntopts = mntopts; -} - -static struct statfs *gsfs = NULL; -static int allfs = 0; - -static int -statfs_init(void) -{ - struct statfs *sfs; - int error; - - if (gsfs != NULL) { - free(gsfs); - gsfs = NULL; - } - allfs = getfsstat(NULL, 0, MNT_WAIT); - if (allfs == -1) - goto fail; - gsfs = malloc(sizeof(gsfs[0]) * allfs * 2); - if (gsfs == NULL) - goto fail; - allfs = getfsstat(gsfs, (long)(sizeof(gsfs[0]) * allfs * 2), - MNT_WAIT); - if (allfs == -1) - goto fail; - sfs = realloc(gsfs, allfs * sizeof(gsfs[0])); - if (sfs != NULL) - gsfs = sfs; - return (0); -fail: - error = errno; - if (gsfs != NULL) - free(gsfs); - gsfs = NULL; - allfs = 0; - return (error); -} - -int -getmntany(FILE *fd __unused, struct mnttab *mgetp, struct mnttab *mrefp) -{ - struct statfs *sfs; - int i, error; - - error = statfs_init(); - if (error != 0) - return (error); - - for (i = 0; i < allfs; i++) { - if (mrefp->mnt_special != NULL && - strcmp(mrefp->mnt_special, gsfs[i].f_mntfromname) != 0) { - continue; - } - if (mrefp->mnt_mountp != NULL && - strcmp(mrefp->mnt_mountp, gsfs[i].f_mntonname) != 0) { - continue; - } - if (mrefp->mnt_fstype != NULL && - strcmp(mrefp->mnt_fstype, gsfs[i].f_fstypename) != 0) { - continue; - } - statfs2mnttab(&gsfs[i], mgetp); - return (0); - } - return (-1); -} - -int -getmntent(FILE *fp, struct mnttab *mp) -{ - struct statfs *sfs; - int error, nfs; - - nfs = (int)lseek(fileno(fp), 0, SEEK_CUR); - if (nfs == -1) - return (errno); - /* If nfs is 0, we want to refresh out cache. */ - if (nfs == 0 || gsfs == NULL) { - error = statfs_init(); - if (error != 0) - return (error); - } - if (nfs >= allfs) - return (-1); - statfs2mnttab(&gsfs[nfs], mp); - if (lseek(fileno(fp), 1, SEEK_CUR) == -1) - return (errno); - return (0); -} diff --git a/cddl/compat/opensolaris/misc/thread_pool.c b/cddl/compat/opensolaris/misc/thread_pool.c deleted file mode 100644 index 6ae0055afceb..000000000000 --- a/cddl/compat/opensolaris/misc/thread_pool.c +++ /dev/null @@ -1,428 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -__FBSDID("$FreeBSD$"); - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include "thread_pool_impl.h" - -typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */ - -static void -delete_pool(tpool_t *tpool) -{ - tpool_job_t *job; - - /* - * There should be no pending jobs, but just in case... - */ - for (job = tpool->tp_head; job != NULL; job = tpool->tp_head) { - tpool->tp_head = job->tpj_next; - free(job); - } - (void) pthread_attr_destroy(&tpool->tp_attr); - free(tpool); -} - -/* - * Worker thread is terminating. - */ -static void -worker_cleanup(void *arg) -{ - tpool_t *tpool = arg; - - if (--tpool->tp_current == 0 && - (tpool->tp_flags & (TP_DESTROY | TP_ABANDON))) { - if (tpool->tp_flags & TP_ABANDON) { - pthread_mutex_unlock(&tpool->tp_mutex); - delete_pool(tpool); - return; - } - if (tpool->tp_flags & TP_DESTROY) - (void) pthread_cond_broadcast(&tpool->tp_busycv); - } - pthread_mutex_unlock(&tpool->tp_mutex); -} - -static void -notify_waiters(tpool_t *tpool) -{ - if (tpool->tp_head == NULL && tpool->tp_active == NULL) { - tpool->tp_flags &= ~TP_WAIT; - (void) pthread_cond_broadcast(&tpool->tp_waitcv); - } -} - -/* - * Called by a worker thread on return from a tpool_dispatch()d job. - */ -static void -job_cleanup(void *arg) -{ - tpool_t *tpool = arg; - pthread_t my_tid = pthread_self(); - tpool_active_t *activep; - tpool_active_t **activepp; - - pthread_mutex_lock(&tpool->tp_mutex); - /* CSTYLED */ - for (activepp = &tpool->tp_active;; activepp = &activep->tpa_next) { - activep = *activepp; - if (activep->tpa_tid == my_tid) { - *activepp = activep->tpa_next; - break; - } - } - if (tpool->tp_flags & TP_WAIT) - notify_waiters(tpool); -} - -static void * -tpool_worker(void *arg) -{ - tpool_t *tpool = (tpool_t *)arg; - int elapsed; - tpool_job_t *job; - void (*func)(void *); - tpool_active_t active; - sigset_t maskset; - - pthread_mutex_lock(&tpool->tp_mutex); *** 578 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Thu Jun 17 20:09: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 D84E865D8AE; Thu, 17 Jun 2021 20:09: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 4G5Y6z5bBBz3pKP; Thu, 17 Jun 2021 20:09: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 A430E1557B; Thu, 17 Jun 2021 20:09: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 15HK9VPt023128; Thu, 17 Jun 2021 20:09:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15HK9VgO023127; Thu, 17 Jun 2021 20:09:31 GMT (envelope-from git) Date: Thu, 17 Jun 2021 20:09:31 GMT Message-Id: <202106172009.15HK9VgO023127@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: b6de677b705d - stable/13 - fusefs: reenable the WriteCluster.cluster_write_err test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b6de677b705d6f10f605f9a011c18406e9b0cb9a 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, 17 Jun 2021 20:09:31 -0000 The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=b6de677b705d6f10f605f9a011c18406e9b0cb9a commit b6de677b705d6f10f605f9a011c18406e9b0cb9a Author: Alan Somers AuthorDate: 2021-05-30 22:51:56 +0000 Commit: Alan Somers CommitDate: 2021-06-17 20:09:15 +0000 fusefs: reenable the WriteCluster.cluster_write_err test The underlying panic was just fixed by revision 27006229f7a40a18a61a0e8fd270bc583326b690 PR: 238565 MFC with: 27006229f7a40a18a61a0e8fd270bc583326b690 (cherry picked from commit 425bbe9e64f7af6bdb30a099bd90a32885de1ab8) --- tests/sys/fs/fusefs/write.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc index f0f9685000fb..fadf4648d31c 100644 --- a/tests/sys/fs/fusefs/write.cc +++ b/tests/sys/fs/fusefs/write.cc @@ -806,10 +806,10 @@ TEST_F(WriteCluster, clustering) * not panic the system on unmount */ /* - * Disabled because it panics. + * Regression test for bug 238585 * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238565 */ -TEST_F(WriteCluster, DISABLED_cluster_write_err) +TEST_F(WriteCluster, cluster_write_err) { const char FULLPATH[] = "mountpoint/some_file.txt"; const char RELPATH[] = "some_file.txt"; From owner-dev-commits-src-branches@freebsd.org Fri Jun 18 09:43: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 9B1CF641137; Fri, 18 Jun 2021 09:43: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 4G5vB93jtXz3Pd7; Fri, 18 Jun 2021 09:43: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 625C8203EA; Fri, 18 Jun 2021 09:43: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 15I9hTMj010425; Fri, 18 Jun 2021 09:43:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15I9hTd4010424; Fri, 18 Jun 2021 09:43:29 GMT (envelope-from git) Date: Fri, 18 Jun 2021 09:43:29 GMT Message-Id: <202106180943.15I9hTd4010424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: b4fe6fbab236 - stable/11 - libcasper: add missing unistd.h MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: b4fe6fbab236a0fd37ebafb4d3bb15856f99596c 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, 18 Jun 2021 09:43:29 -0000 The branch stable/11 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=b4fe6fbab236a0fd37ebafb4d3bb15856f99596c commit b4fe6fbab236a0fd37ebafb4d3bb15856f99596c Author: Mariusz Zaborski AuthorDate: 2021-06-18 09:41:40 +0000 Commit: Mariusz Zaborski CommitDate: 2021-06-18 09:43:19 +0000 libcasper: add missing unistd.h Reported by: Arrigo Marchiori --- lib/libcasper/libcasper/libcasper_impl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libcasper/libcasper/libcasper_impl.c b/lib/libcasper/libcasper/libcasper_impl.c index f58bd44d2039..8d1ebd8dd074 100644 --- a/lib/libcasper/libcasper/libcasper_impl.c +++ b/lib/libcasper/libcasper/libcasper_impl.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "libcasper_impl.h" From owner-dev-commits-src-branches@freebsd.org Fri Jun 18 09:54: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 D09E26416E9; Fri, 18 Jun 2021 09:54: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 4G5vQS5MxPz3hms; Fri, 18 Jun 2021 09:54: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 A068320B07; Fri, 18 Jun 2021 09:54:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15I9s81J023591; Fri, 18 Jun 2021 09:54:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15I9s8DD023590; Fri, 18 Jun 2021 09:54:08 GMT (envelope-from git) Date: Fri, 18 Jun 2021 09:54:08 GMT Message-Id: <202106180954.15I9s8DD023590@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: ef84d16e68b2 - stable/13 - ipfw.8: synopsis misses nat show form MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ef84d16e68b2a3f86eeb1b758dc560ec2a4ffcbe 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, 18 Jun 2021 09:54:08 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=ef84d16e68b2a3f86eeb1b758dc560ec2a4ffcbe commit ef84d16e68b2a3f86eeb1b758dc560ec2a4ffcbe Author: Lutz Donnerhacke AuthorDate: 2021-05-10 16:30:42 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-18 09:53:26 +0000 ipfw.8: synopsis misses nat show form Document the existing behavior, which is currently only available by reading third party documentation or the source code itself. PR: 254617 Submitted by: Oliver Kiddle Differential Revision: https://reviews.freebsd.org/D30189 (cherry picked from commit c8250c5ada85fec8936e8eb8695d7cb80a3ce8ab) --- sbin/ipfw/ipfw.8 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index ef718c247896..be3f92f3bd6b 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2021 +.Dd June 4, 2021 .Dt IPFW 8 .Os .Sh NAME @@ -105,6 +105,11 @@ in-kernel NAT. .Ar number .Cm config .Ar config-options +.Nm +.Cm nat +.Ar number +.Cm show +.Brq Cm config | log .Ss STATEFUL IPv6/IPv4 NETWORK ADDRESS AND PROTOCOL TRANSLATION .Nm .Oo Cm set Ar N Oc Cm nat64lsn Ar name Cm create Ar create-options @@ -922,7 +927,7 @@ This makes the .Xr netstat 1 entry look rather weird but is intended for use with transparent proxy servers. -.It Cm nat Ar nat_nr | tablearg +.It Cm nat Ar nat_nr | global | tablearg Pass packet to a nat instance (for network address translation, address redirect, etc.): @@ -3276,8 +3281,9 @@ Set the aliasing ports between the ranges given. Upper port has to be greater than lower. .El .Pp -Some specials value can be supplied instead of -.Va nat_number : +Some special values can be supplied instead of +.Va nat_number +in nat rule actions: .Bl -tag -width indent .It Cm global Looks up translation state in all configured nat instances. @@ -3303,7 +3309,7 @@ For more information about aliasing modes, refer to .Xr libalias 3 . See Section .Sx EXAMPLES -for some examples about nat usage. +for some examples of nat usage. .Ss REDIRECT AND LSNAT SUPPORT IN IPFW Redirect and LSNAT support follow closely the syntax used in .Xr natd 8 . From owner-dev-commits-src-branches@freebsd.org Fri Jun 18 10:01: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 BC1846417FB; Fri, 18 Jun 2021 10:01: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 4G5vZs4kt8z3jdL; Fri, 18 Jun 2021 10:01: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 8183D20855; Fri, 18 Jun 2021 10:01: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 15IA1Pf2033923; Fri, 18 Jun 2021 10:01:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15IA1P49033922; Fri, 18 Jun 2021 10:01:25 GMT (envelope-from git) Date: Fri, 18 Jun 2021 10:01:25 GMT Message-Id: <202106181001.15IA1P49033922@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 116fc1b5a07f - stable/12 - ipfw.8: synopsis misses nat show form MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 116fc1b5a07f55c43ac39f04bf9dff5a503d99ba 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, 18 Jun 2021 10:01:25 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=116fc1b5a07f55c43ac39f04bf9dff5a503d99ba commit 116fc1b5a07f55c43ac39f04bf9dff5a503d99ba Author: Lutz Donnerhacke AuthorDate: 2021-05-10 16:30:42 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-18 10:00:29 +0000 ipfw.8: synopsis misses nat show form Document the existing behavior, which is currently only available by reading third party documentation or the source code itself. PR: 254617 Submitted by: Oliver Kiddle Differential Revision: https://reviews.freebsd.org/D30189 (cherry picked from commit c8250c5ada85fec8936e8eb8695d7cb80a3ce8ab) --- sbin/ipfw/ipfw.8 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index ef718c247896..be3f92f3bd6b 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2021 +.Dd June 4, 2021 .Dt IPFW 8 .Os .Sh NAME @@ -105,6 +105,11 @@ in-kernel NAT. .Ar number .Cm config .Ar config-options +.Nm +.Cm nat +.Ar number +.Cm show +.Brq Cm config | log .Ss STATEFUL IPv6/IPv4 NETWORK ADDRESS AND PROTOCOL TRANSLATION .Nm .Oo Cm set Ar N Oc Cm nat64lsn Ar name Cm create Ar create-options @@ -922,7 +927,7 @@ This makes the .Xr netstat 1 entry look rather weird but is intended for use with transparent proxy servers. -.It Cm nat Ar nat_nr | tablearg +.It Cm nat Ar nat_nr | global | tablearg Pass packet to a nat instance (for network address translation, address redirect, etc.): @@ -3276,8 +3281,9 @@ Set the aliasing ports between the ranges given. Upper port has to be greater than lower. .El .Pp -Some specials value can be supplied instead of -.Va nat_number : +Some special values can be supplied instead of +.Va nat_number +in nat rule actions: .Bl -tag -width indent .It Cm global Looks up translation state in all configured nat instances. @@ -3303,7 +3309,7 @@ For more information about aliasing modes, refer to .Xr libalias 3 . See Section .Sx EXAMPLES -for some examples about nat usage. +for some examples of nat usage. .Ss REDIRECT AND LSNAT SUPPORT IN IPFW Redirect and LSNAT support follow closely the syntax used in .Xr natd 8 . From owner-dev-commits-src-branches@freebsd.org Fri Jun 18 10:07: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 4CA93641A42; Fri, 18 Jun 2021 10:07: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 4G5vjq1jv2z3kMX; Fri, 18 Jun 2021 10:07: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 23E34209BD; Fri, 18 Jun 2021 10:07: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 15IA7ROl037829; Fri, 18 Jun 2021 10:07:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15IA7REH037828; Fri, 18 Jun 2021 10:07:27 GMT (envelope-from git) Date: Fri, 18 Jun 2021 10:07:27 GMT Message-Id: <202106181007.15IA7REH037828@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 95f8bb6d06d9 - stable/11 - ipfw.8: synopsis misses nat show form MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 95f8bb6d06d9fb65dc382423485f2f636ec20375 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, 18 Jun 2021 10:07:27 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=95f8bb6d06d9fb65dc382423485f2f636ec20375 commit 95f8bb6d06d9fb65dc382423485f2f636ec20375 Author: Lutz Donnerhacke AuthorDate: 2021-05-10 16:30:42 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-18 10:06:42 +0000 ipfw.8: synopsis misses nat show form Document the existing behavior, which is currently only available by reading third party documentation or the source code itself. PR: 254617 Submitted by: Oliver Kiddle Differential Revision: https://reviews.freebsd.org/D30189 (cherry picked from commit c8250c5ada85fec8936e8eb8695d7cb80a3ce8ab) --- sbin/ipfw/ipfw.8 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index 4cdd7b63849f..93c265512ce1 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2021 +.Dd June 4, 2021 .Dt IPFW 8 .Os .Sh NAME @@ -105,6 +105,11 @@ in-kernel NAT. .Ar number .Cm config .Ar config-options +.Nm +.Cm nat +.Ar number +.Cm show +.Brq Cm config | log .Ss STATEFUL IPv6/IPv4 NETWORK ADDRESS AND PROTOCOL TRANSLATION .Nm .Oo Cm set Ar N Oc Cm nat64lsn Ar name Cm create Ar create-options @@ -922,7 +927,7 @@ This makes the .Xr netstat 1 entry look rather weird but is intended for use with transparent proxy servers. -.It Cm nat Ar nat_nr | tablearg +.It Cm nat Ar nat_nr | global | tablearg Pass packet to a nat instance (for network address translation, address redirect, etc.): @@ -3243,8 +3248,9 @@ Obey transparent proxy rules only, packet aliasing is not performed. Skip instance in case of global state lookup (see below). .El .Pp -Some specials value can be supplied instead of -.Va nat_number: +Some special values can be supplied instead of +.Va nat_number +in nat rule actions: .Bl -tag -width indent .It Cm global Looks up translation state in all configured nat instances. @@ -3270,7 +3276,7 @@ For more information about aliasing modes, refer to .Xr libalias 3 . See Section .Sx EXAMPLES -for some examples about nat usage. +for some examples of nat usage. .Ss REDIRECT AND LSNAT SUPPORT IN IPFW Redirect and LSNAT support follow closely the syntax used in .Xr natd 8 . From owner-dev-commits-src-branches@freebsd.org Sat Jun 19 14:09: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 6C47065A60B; Sat, 19 Jun 2021 14:09: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 4G6d2C1FSsz3lrw; Sat, 19 Jun 2021 14:09: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 1400F17BEF; Sat, 19 Jun 2021 14:09: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 15JE96Od073937; Sat, 19 Jun 2021 14:09:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15JE96aE073936; Sat, 19 Jun 2021 14:09:06 GMT (envelope-from git) Date: Sat, 19 Jun 2021 14:09:06 GMT Message-Id: <202106191409.15JE96aE073936@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: ed1acef3fe30 - stable/13 - ipfw: Update the pfil mbuf pointer in ipfw_check_frame() 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: ed1acef3fe3053b418ce3e41036ccf24957253a4 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: Sat, 19 Jun 2021 14:09:07 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ed1acef3fe3053b418ce3e41036ccf24957253a4 commit ed1acef3fe3053b418ce3e41036ccf24957253a4 Author: Mark Johnston AuthorDate: 2021-06-16 13:46:56 +0000 Commit: Mark Johnston CommitDate: 2021-06-19 14:08:49 +0000 ipfw: Update the pfil mbuf pointer in ipfw_check_frame() ipfw_chk() might call m_pullup() and thus can change the mbuf chain head. In this case, the new chain head has to be returned to the pfil hook caller, otherwise the pfil hook caller is left with a dangling pointer. Note that this affects only the link-layer hooks installed when the net.link.ether.ipfw sysctl is set to 1. PR: 256439, 254015, 255069, 255104 Fixes: f355cb3e6 Reviewed by: ae Sponsored by: The FreeBSD Foundation (cherry picked from commit bc6a2267fffeafd3946637607a74cfd639398f9d) --- sys/netpfil/ipfw/ip_fw_pfil.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/netpfil/ipfw/ip_fw_pfil.c b/sys/netpfil/ipfw/ip_fw_pfil.c index e21831c80ec6..01a44df47180 100644 --- a/sys/netpfil/ipfw/ip_fw_pfil.c +++ b/sys/netpfil/ipfw/ip_fw_pfil.c @@ -371,6 +371,8 @@ again: } ipfw = ipfw_chk(&args); + if (!mem) + *p.m = args.m; ret = PFIL_PASS; switch (ipfw) { From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 03:23:20 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 6A6DE6470AD; Sun, 20 Jun 2021 03:23:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G6yfc2PKKz3pff; Sun, 20 Jun 2021 03:23:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3AEFC22929; Sun, 20 Jun 2021 03:23:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15K3NKdP038471; Sun, 20 Jun 2021 03:23:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15K3NKTe038470; Sun, 20 Jun 2021 03:23:20 GMT (envelope-from git) Date: Sun, 20 Jun 2021 03:23:20 GMT Message-Id: <202106200323.15K3NKTe038470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: f36e15feb09b - stable/13 - bsdinstall: add a new mirror in Bulgaria MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f36e15feb09b90d298af33da64ecd07a43b62a9c 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, 20 Jun 2021 03:23:20 -0000 The branch stable/13 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=f36e15feb09b90d298af33da64ecd07a43b62a9c commit f36e15feb09b90d298af33da64ecd07a43b62a9c Author: Philip Paeps AuthorDate: 2021-06-17 13:07:37 +0000 Commit: Philip Paeps CommitDate: 2021-06-20 03:21:39 +0000 bsdinstall: add a new mirror in Bulgaria Provided by Telepoint Mirror Service. Reported by: Valentin Nikolov (cherry picked from commit 7daa45becfd32cb38933bfdc87e8a10fc982d188) --- usr.sbin/bsdinstall/scripts/mirrorselect | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/bsdinstall/scripts/mirrorselect b/usr.sbin/bsdinstall/scripts/mirrorselect index 987a524218af..77fc785b94ae 100755 --- a/usr.sbin/bsdinstall/scripts/mirrorselect +++ b/usr.sbin/bsdinstall/scripts/mirrorselect @@ -63,6 +63,7 @@ MIRROR=`dialog --backtitle "FreeBSD Installer" \ ftp://ftp2.br.freebsd.org "Brazil #2"\ ftp://ftp3.br.freebsd.org "Brazil #3"\ ftp://ftp4.br.freebsd.org "Brazil #4"\ + ftp://ftp.bg.freebsd.org "Bulgaria"\ ftp://ftp.cn.freebsd.org "China"\ ftp://ftp.cz.freebsd.org "Czech Republic"\ ftp://ftp.dk.freebsd.org "Denmark"\ From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 03:23: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 5BE9B646FCB; Sun, 20 Jun 2021 03:23:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G6ygJ2Bhzz3pfv; Sun, 20 Jun 2021 03:23:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33ED3224BC; Sun, 20 Jun 2021 03:23:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15K3NutZ038642; Sun, 20 Jun 2021 03:23:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15K3Nu6O038641; Sun, 20 Jun 2021 03:23:56 GMT (envelope-from git) Date: Sun, 20 Jun 2021 03:23:56 GMT Message-Id: <202106200323.15K3Nu6O038641@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: e5d8c43e170b - stable/13 - bsdconfig: add a new mirror in Bulgaria MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e5d8c43e170b1c45f13c030aff99ac25dba1593e 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, 20 Jun 2021 03:23:56 -0000 The branch stable/13 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=e5d8c43e170b1c45f13c030aff99ac25dba1593e commit e5d8c43e170b1c45f13c030aff99ac25dba1593e Author: Philip Paeps AuthorDate: 2021-06-17 13:07:37 +0000 Commit: Philip Paeps CommitDate: 2021-06-20 03:23:44 +0000 bsdconfig: add a new mirror in Bulgaria Provided by Telepoint Mirror Service. Reported by: Valentin Nikolov (cherry picked from commit 1c9605fe1e190197b3846e01dce1e491bef0ec34) --- usr.sbin/bsdconfig/include/messages.subr | 1 + usr.sbin/bsdconfig/share/media/ftp.subr | 1 + 2 files changed, 2 insertions(+) diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr index 4fd05db08d7d..9d910032616d 100644 --- a/usr.sbin/bsdconfig/include/messages.subr +++ b/usr.sbin/bsdconfig/include/messages.subr @@ -61,6 +61,7 @@ msg_bootstrapping_pkg="Bootstrapping pkg(8)..." msg_brazil="Brazil" msg_building_package_menus="Building package menu(s)..." msg_building_package_main_menu="Building package main menu..." +msg_bulgaria="Bulgaria" msg_cad_desc="Computer Aided Design utilities." msg_canada="Canada" msg_cancel="Cancel" diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr index a6d0e1ca1ad0..fb2579f59f89 100644 --- a/usr.sbin/bsdconfig/share/media/ftp.subr +++ b/usr.sbin/bsdconfig/share/media/ftp.subr @@ -101,6 +101,7 @@ f_dialog_menu_media_ftp() '$msg_brazil' 'ftp2.br.freebsd.org' ' $msg_brazil #3' 'ftp3.br.freebsd.org' ' $msg_brazil #4' 'ftp4.br.freebsd.org' + '$msg_bulgaria' 'ftp.bg.freebsd.org' '$msg_china' 'ftp.cn.freebsd.org' '$msg_czech_republic' 'ftp.cz.freebsd.org' '$msg_denmark' 'ftp.dk.freebsd.org' From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 03:25:22 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 75B42647453; Sun, 20 Jun 2021 03:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G6yhy2rjyz3pRn; Sun, 20 Jun 2021 03:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A504226AE; Sun, 20 Jun 2021 03:25:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15K3PMkB038882; Sun, 20 Jun 2021 03:25:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15K3PMZo038881; Sun, 20 Jun 2021 03:25:22 GMT (envelope-from git) Date: Sun, 20 Jun 2021 03:25:22 GMT Message-Id: <202106200325.15K3PMZo038881@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: bd1c7f1f05a5 - stable/12 - bsdinstall: add a new mirror in Bulgaria MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bd1c7f1f05a55402d4728f732e1336044cdde701 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, 20 Jun 2021 03:25:22 -0000 The branch stable/12 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=bd1c7f1f05a55402d4728f732e1336044cdde701 commit bd1c7f1f05a55402d4728f732e1336044cdde701 Author: Philip Paeps AuthorDate: 2021-06-17 13:07:37 +0000 Commit: Philip Paeps CommitDate: 2021-06-20 03:22:21 +0000 bsdinstall: add a new mirror in Bulgaria Provided by Telepoint Mirror Service. Reported by: Valentin Nikolov (cherry picked from commit 7daa45becfd32cb38933bfdc87e8a10fc982d188) --- usr.sbin/bsdinstall/scripts/mirrorselect | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/bsdinstall/scripts/mirrorselect b/usr.sbin/bsdinstall/scripts/mirrorselect index 987a524218af..77fc785b94ae 100755 --- a/usr.sbin/bsdinstall/scripts/mirrorselect +++ b/usr.sbin/bsdinstall/scripts/mirrorselect @@ -63,6 +63,7 @@ MIRROR=`dialog --backtitle "FreeBSD Installer" \ ftp://ftp2.br.freebsd.org "Brazil #2"\ ftp://ftp3.br.freebsd.org "Brazil #3"\ ftp://ftp4.br.freebsd.org "Brazil #4"\ + ftp://ftp.bg.freebsd.org "Bulgaria"\ ftp://ftp.cn.freebsd.org "China"\ ftp://ftp.cz.freebsd.org "Czech Republic"\ ftp://ftp.dk.freebsd.org "Denmark"\ From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 03:25: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 E0771647458; Sun, 20 Jun 2021 03:25: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 4G6yhz3gSBz3prV; Sun, 20 Jun 2021 03:25: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 6702722715; Sun, 20 Jun 2021 03:25: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 15K3PNeM038912; Sun, 20 Jun 2021 03:25:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15K3PNMa038911; Sun, 20 Jun 2021 03:25:23 GMT (envelope-from git) Date: Sun, 20 Jun 2021 03:25:23 GMT Message-Id: <202106200325.15K3PNMa038911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Philip Paeps Subject: git: 7e7e2b9f9c85 - stable/12 - bsdconfig: add a new mirror in Bulgaria MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: philip X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7e7e2b9f9c8507d6e8c3a65aea28b53ba49d612b 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, 20 Jun 2021 03:25:24 -0000 The branch stable/12 has been updated by philip: URL: https://cgit.FreeBSD.org/src/commit/?id=7e7e2b9f9c8507d6e8c3a65aea28b53ba49d612b commit 7e7e2b9f9c8507d6e8c3a65aea28b53ba49d612b Author: Philip Paeps AuthorDate: 2021-06-17 13:07:37 +0000 Commit: Philip Paeps CommitDate: 2021-06-20 03:24:20 +0000 bsdconfig: add a new mirror in Bulgaria Provided by Telepoint Mirror Service. Reported by: Valentin Nikolov (cherry picked from commit 1c9605fe1e190197b3846e01dce1e491bef0ec34) --- usr.sbin/bsdconfig/include/messages.subr | 1 + usr.sbin/bsdconfig/share/media/ftp.subr | 1 + 2 files changed, 2 insertions(+) diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr index 4932f08364d7..c1bc62749ad7 100644 --- a/usr.sbin/bsdconfig/include/messages.subr +++ b/usr.sbin/bsdconfig/include/messages.subr @@ -61,6 +61,7 @@ msg_bootstrapping_pkg="Bootstrapping pkg(8)..." msg_brazil="Brazil" msg_building_package_menus="Building package menu(s)..." msg_building_package_main_menu="Building package main menu..." +msg_bulgaria="Bulgaria" msg_cad_desc="Computer Aided Design utilities." msg_canada="Canada" msg_cancel="Cancel" diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr index a6d0e1ca1ad0..fb2579f59f89 100644 --- a/usr.sbin/bsdconfig/share/media/ftp.subr +++ b/usr.sbin/bsdconfig/share/media/ftp.subr @@ -101,6 +101,7 @@ f_dialog_menu_media_ftp() '$msg_brazil' 'ftp2.br.freebsd.org' ' $msg_brazil #3' 'ftp3.br.freebsd.org' ' $msg_brazil #4' 'ftp4.br.freebsd.org' + '$msg_bulgaria' 'ftp.bg.freebsd.org' '$msg_china' 'ftp.cn.freebsd.org' '$msg_czech_republic' 'ftp.cz.freebsd.org' '$msg_denmark' 'ftp.dk.freebsd.org' From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 11: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 5E6F764D6C9; Sun, 20 Jun 2021 11: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 4G79TX27jfz4r7S; Sun, 20 Jun 2021 11: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 32A3DDC8; Sun, 20 Jun 2021 11: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 15KBVCPI099097; Sun, 20 Jun 2021 11: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 15KBVCLY099096; Sun, 20 Jun 2021 11:31:12 GMT (envelope-from git) Date: Sun, 20 Jun 2021 11:31:12 GMT Message-Id: <202106201131.15KBVCLY099096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 402ddb85eed2 - stable/13 - Add IPv4 fib lookup performance tests with uniform keys. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 402ddb85eed2332c6e876e68e0d319e07bb8223d 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, 20 Jun 2021 11:31:12 -0000 The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=402ddb85eed2332c6e876e68e0d319e07bb8223d commit 402ddb85eed2332c6e876e68e0d319e07bb8223d Author: Alexander V. Chernikov AuthorDate: 2021-03-30 12:43:55 +0000 Commit: Marko Zec CommitDate: 2021-06-20 11:25:58 +0000 Add IPv4 fib lookup performance tests with uniform keys. Submitted by: zec MFC after: 1 week (cherry picked from commit b8598e2ff65ab82da0cf6861ee12f078b40bc252) --- sys/tests/fib_lookup/fib_lookup.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sys/tests/fib_lookup/fib_lookup.c b/sys/tests/fib_lookup/fib_lookup.c index 3dd1bb8d5a50..ea07e3d697c6 100644 --- a/sys/tests/fib_lookup/fib_lookup.c +++ b/sys/tests/fib_lookup/fib_lookup.c @@ -505,6 +505,58 @@ SYSCTL_PROC(_net_route_test, OID_AUTO, run_inet_scan, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, run_test_inet_scan, "I", "Execute fib4_lookup scan tests"); +static int +rnd_lps(SYSCTL_HANDLER_ARGS) +{ + struct epoch_tracker et; + struct in_addr *keys; + struct nhop_object **nhops; + + struct timespec ts_pre, ts_post; + uint64_t total_diff, lps; + int error; + int count = 0; + + error = sysctl_handle_int(oidp, &count, 0, req); + if (error != 0) + return (error); + if (count <= 0) + return (0); + + keys = malloc(sizeof(*keys) * count, M_TEMP, M_NOWAIT); + nhops = malloc(sizeof(*nhops) * count, M_TEMP, M_NOWAIT); + if (keys == NULL || nhops == NULL) { + free(keys, M_TEMP); + free(nhops, M_TEMP); + return (ENOMEM); + } + + printf("Preparing %d random keys...\n", count); + arc4random_buf(keys, sizeof(*keys) * count); + printf("Starting LPS test...\n"); + + NET_EPOCH_ENTER(et); + nanouptime(&ts_pre); + for (int i = 0; i < count; i++) + nhops[i] = fib4_lookup(RT_DEFAULT_FIB, keys[i], 0, NHR_NONE, 0); + nanouptime(&ts_post); + NET_EPOCH_EXIT(et); + + free(keys, M_TEMP); + free(nhops, M_TEMP); + + total_diff = (ts_post.tv_sec - ts_pre.tv_sec) * 1000000000 + + (ts_post.tv_nsec - ts_pre.tv_nsec); + lps = 1000000000ULL * count / total_diff; + printf("%d lookups in %zu nanoseconds, %lu.%06lu MLPS\n", + count, total_diff, lps / 1000000, lps % 1000000); + + return (0); +} +SYSCTL_PROC(_net_route_test, OID_AUTO, rnd_lps, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, 0, rnd_lps, "I", + "Measure lookups per second using uniformly random keys"); static int test_fib_lookup_modevent(module_t mod, int type, void *unused) From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 11: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 849C864D869; Sun, 20 Jun 2021 11: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 4G79TY3FfLz4rFl; Sun, 20 Jun 2021 11: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 55E2EE35; Sun, 20 Jun 2021 11: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 15KBVD0g099122; Sun, 20 Jun 2021 11: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 15KBVDfH099120; Sun, 20 Jun 2021 11:31:13 GMT (envelope-from git) Date: Sun, 20 Jun 2021 11:31:13 GMT Message-Id: <202106201131.15KBVDfH099120@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 2b6b8ea60cb5 - stable/13 - Revise FIB lookups per second benchmarking routines. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b6b8ea60cb59158e7fb080476251bd1369d6bd2 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, 20 Jun 2021 11:31:13 -0000 The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=2b6b8ea60cb59158e7fb080476251bd1369d6bd2 commit 2b6b8ea60cb59158e7fb080476251bd1369d6bd2 Author: Marko Zec AuthorDate: 2021-05-05 10:28:17 +0000 Commit: Marko Zec CommitDate: 2021-06-20 11:26:52 +0000 Revise FIB lookups per second benchmarking routines. Add a LPS benchmark variant which introduces artificial dependencies between successive lookups. While here, instead of writing the results from the lookups to a huge array, add them to an accumulator, in a more lightweight attempt at preventing the CPU's OOO machinery from discarding the lookup results if they would be completely unused. net.route.test.run_lps_rnd measures LPS throughput with independent uniformly random keys net.route.test.run_lps_seq measures LPS throughput with uniformly random keys with artificial interdependencies Reviewed by: melifaro MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D30096 (cherry picked from commit a43104ebe7630111d7e7debc56aacf49787dcf43) --- sys/tests/fib_lookup/fib_lookup.c | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/sys/tests/fib_lookup/fib_lookup.c b/sys/tests/fib_lookup/fib_lookup.c index ea07e3d697c6..4093ff9dd487 100644 --- a/sys/tests/fib_lookup/fib_lookup.c +++ b/sys/tests/fib_lookup/fib_lookup.c @@ -509,13 +509,13 @@ static int rnd_lps(SYSCTL_HANDLER_ARGS) { struct epoch_tracker et; - struct in_addr *keys; - struct nhop_object **nhops; - + struct in_addr key; struct timespec ts_pre, ts_post; uint64_t total_diff, lps; - int error; + uint32_t *keys; + uintptr_t acc = 0; int count = 0; + int error; error = sysctl_handle_int(oidp, &count, 0, req); if (error != 0) @@ -524,12 +524,8 @@ rnd_lps(SYSCTL_HANDLER_ARGS) return (0); keys = malloc(sizeof(*keys) * count, M_TEMP, M_NOWAIT); - nhops = malloc(sizeof(*nhops) * count, M_TEMP, M_NOWAIT); - if (keys == NULL || nhops == NULL) { - free(keys, M_TEMP); - free(nhops, M_TEMP); + if (keys == NULL) return (ENOMEM); - } printf("Preparing %d random keys...\n", count); arc4random_buf(keys, sizeof(*keys) * count); @@ -537,26 +533,42 @@ rnd_lps(SYSCTL_HANDLER_ARGS) NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - for (int i = 0; i < count; i++) - nhops[i] = fib4_lookup(RT_DEFAULT_FIB, keys[i], 0, NHR_NONE, 0); + switch (arg2) { + case 0: + for (int i = 0; i < count; i++) { + key.s_addr = keys[i] + acc; + acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, + NHR_NONE, 0); + } + case 1: + for (int i = 0; i < count; i++) { + key.s_addr = keys[i]; + acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, + NHR_NONE, 0); + } + } nanouptime(&ts_post); NET_EPOCH_EXIT(et); free(keys, M_TEMP); - free(nhops, M_TEMP); total_diff = (ts_post.tv_sec - ts_pre.tv_sec) * 1000000000 + - (ts_post.tv_nsec - ts_pre.tv_nsec); + (ts_post.tv_nsec - ts_pre.tv_nsec) + (acc & 1); lps = 1000000000ULL * count / total_diff; printf("%d lookups in %zu nanoseconds, %lu.%06lu MLPS\n", count, total_diff, lps / 1000000, lps % 1000000); return (0); } -SYSCTL_PROC(_net_route_test, OID_AUTO, rnd_lps, +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, rnd_lps, "I", - "Measure lookups per second using uniformly random keys"); + "Measure lookups per second, uniformly random keys, " + "artificial dependencies between lookups"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, 1, rnd_lps, "I", + "Measure lookups per second, uniformly random keys, independent lookups"); static int test_fib_lookup_modevent(module_t mod, int type, void *unused) From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 11: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 02B0F64D4F6; Sun, 20 Jun 2021 11: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 4G79TZ6Rcgz4rGg; Sun, 20 Jun 2021 11: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 8EC7DDCC; Sun, 20 Jun 2021 11: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 15KBVEQA099152; Sun, 20 Jun 2021 11: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 15KBVECL099151; Sun, 20 Jun 2021 11:31:14 GMT (envelope-from git) Date: Sun, 20 Jun 2021 11:31:14 GMT Message-Id: <202106201131.15KBVECL099151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 09274116f4d9 - stable/13 - tests: Revise FIB lookups per second benchmarking routines MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 09274116f4d90f5c25cfad3bd7d13b48b2d494da 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, 20 Jun 2021 11:31:15 -0000 The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=09274116f4d90f5c25cfad3bd7d13b48b2d494da commit 09274116f4d90f5c25cfad3bd7d13b48b2d494da Author: Marko Zec AuthorDate: 2021-06-17 06:49:09 +0000 Commit: Marko Zec CommitDate: 2021-06-20 11:27:17 +0000 tests: Revise FIB lookups per second benchmarking routines Fix a bug in the LPM SEQ benchmark (missing break inside a switch block) by restructuring the test loop, while introducing additional two synthetic test options: ANN: scan only the address space announced in current RIB REP: repeat lookups over several keys in a sliding window scheme The total of eight combinations of test options are now available through dedicated sysctl hooks. Differential Revision: Reviewed by: melifaro MFC after: 3 days (cherry picked from commit b6f8436b094daf7b1c429ce74997a4daf6994fcb) --- sys/tests/fib_lookup/fib_lookup.c | 140 ++++++++++++++++++++++++++++++++------ 1 file changed, 119 insertions(+), 21 deletions(-) diff --git a/sys/tests/fib_lookup/fib_lookup.c b/sys/tests/fib_lookup/fib_lookup.c index 4093ff9dd487..927664166fdd 100644 --- a/sys/tests/fib_lookup/fib_lookup.c +++ b/sys/tests/fib_lookup/fib_lookup.c @@ -505,16 +505,46 @@ SYSCTL_PROC(_net_route_test, OID_AUTO, run_inet_scan, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, run_test_inet_scan, "I", "Execute fib4_lookup scan tests"); +#define LPS_SEQ 0x1 +#define LPS_ANN 0x2 +#define LPS_REP 0x4 + +struct lps_walk_state { + uint32_t *keys; + int pos; + int lim; +}; + +static int +reduce_keys(struct rtentry *rt, void *_data) +{ + struct lps_walk_state *wa = (struct lps_walk_state *) _data; + struct in_addr addr; + uint32_t scopeid; + int plen; + + rt_get_inet_prefix_plen(rt, &addr, &plen, &scopeid); + wa->keys[wa->pos] = ntohl(addr.s_addr) | + (wa->keys[wa->pos] & ~(0xffffffffU << (32 - plen))); + + wa->pos++; + return (wa->pos == wa->lim); +} + static int rnd_lps(SYSCTL_HANDLER_ARGS) { struct epoch_tracker et; struct in_addr key; + struct lps_walk_state wa; struct timespec ts_pre, ts_post; + struct nhop_object *nh_fib; uint64_t total_diff, lps; uint32_t *keys; + uint32_t t, p; uintptr_t acc = 0; - int count = 0; + int i, pos, count = 0; + int seq = 0, rep = 0; int error; error = sysctl_handle_int(oidp, &count, 0, req); @@ -526,25 +556,62 @@ rnd_lps(SYSCTL_HANDLER_ARGS) keys = malloc(sizeof(*keys) * count, M_TEMP, M_NOWAIT); if (keys == NULL) return (ENOMEM); - printf("Preparing %d random keys...\n", count); arc4random_buf(keys, sizeof(*keys) * count); - printf("Starting LPS test...\n"); + if (arg2 & LPS_ANN) { + wa.keys = keys; + wa.pos = 0; + wa.lim = count; + printf("Reducing keys to announced address space...\n"); + do { + rib_walk(RT_DEFAULT_FIB, AF_INET, false, reduce_keys, + &wa); + } while (wa.pos < wa.lim); + printf("Reshuffling keys...\n"); + for (int i = 0; i < count; i++) { + p = random() % count; + t = keys[p]; + keys[p] = keys[i]; + keys[i] = t; + } + } + + if (arg2 & LPS_REP) { + rep = 1; + printf("REP "); + } + if (arg2 & LPS_SEQ) { + seq = 1; + printf("SEQ"); + } else if (arg2 & LPS_ANN) + printf("ANN"); + else + printf("RND"); + printf(" LPS test starting...\n"); NET_EPOCH_ENTER(et); nanouptime(&ts_pre); - switch (arg2) { - case 0: - for (int i = 0; i < count; i++) { - key.s_addr = keys[i] + acc; - acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, - NHR_NONE, 0); + for (i = 0, pos = 0; i < count; i++) { + key.s_addr = keys[pos++] ^ ((acc >> 10) & 0xff); + nh_fib = fib4_lookup(RT_DEFAULT_FIB, key, 0, NHR_NONE, 0); + if (seq) { + if (nh_fib != NULL) { + acc += (uintptr_t) nh_fib + 123; + if (acc & 0x1000) + acc += (uintptr_t) nh_fib->nh_ifp; + else + acc -= (uintptr_t) nh_fib->nh_ifp; + } else + acc ^= (acc >> 3) + (acc << 2) + i; + if (acc & 0x800) + pos++; + if (pos >= count) + pos = 0; } - case 1: - for (int i = 0; i < count; i++) { - key.s_addr = keys[i]; - acc += (uintptr_t) fib4_lookup(RT_DEFAULT_FIB, key, 0, - NHR_NONE, 0); + if (rep && ((i & 0xf) == 0xf)) { + pos -= 0xf; + if (pos < 0) + pos += 0xf; } } nanouptime(&ts_post); @@ -553,22 +620,53 @@ rnd_lps(SYSCTL_HANDLER_ARGS) free(keys, M_TEMP); total_diff = (ts_post.tv_sec - ts_pre.tv_sec) * 1000000000 + - (ts_post.tv_nsec - ts_pre.tv_nsec) + (acc & 1); + (ts_post.tv_nsec - ts_pre.tv_nsec); lps = 1000000000ULL * count / total_diff; - printf("%d lookups in %zu nanoseconds, %lu.%06lu MLPS\n", - count, total_diff, lps / 1000000, lps % 1000000); + printf("%d lookups in %zu.%06zu milliseconds, %lu.%06lu MLPS\n", + count, total_diff / 1000000, total_diff % 1000000, + lps / 1000000, lps % 1000000); return (0); } -SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq, +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, rnd_lps, "I", + "Measure lookups per second, uniformly random keys, independent lookups"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd_ann, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_ANN, rnd_lps, "I", + "Measure lookups per second, random keys from announced address space, " + "independent lookups"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_SEQ, rnd_lps, "I", "Measure lookups per second, uniformly random keys, " "artificial dependencies between lookups"); -SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd, +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq_ann, CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, - 0, 1, rnd_lps, "I", - "Measure lookups per second, uniformly random keys, independent lookups"); + 0, LPS_SEQ | LPS_ANN, rnd_lps, "I", + "Measure lookups per second, random keys from announced address space, " + "artificial dependencies between lookups"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd_rep, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_REP, rnd_lps, "I", + "Measure lookups per second, uniformly random keys, independent lookups, " + "repeated keys"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_rnd_ann_rep, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_ANN | LPS_REP, rnd_lps, "I", + "Measure lookups per second, random keys from announced address space, " + "independent lookups, repeated keys"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq_rep, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_SEQ | LPS_REP, rnd_lps, "I", + "Measure lookups per second, uniformly random keys, " + "artificial dependencies between lookups, repeated keys"); +SYSCTL_PROC(_net_route_test, OID_AUTO, run_lps_seq_ann_rep, + CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, + 0, LPS_SEQ | LPS_ANN | LPS_REP, rnd_lps, "I", + "Measure lookups per second, random keys from announced address space, " + "artificial dependencies between lookups, repeated keys"); static int test_fib_lookup_modevent(module_t mod, int type, void *unused) From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 13:18:19 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 C36AE651D81; Sun, 20 Jun 2021 13:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G7Cs758Dvz3H1c; Sun, 20 Jun 2021 13:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98BE520ED; Sun, 20 Jun 2021 13:18:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15KDIJ1T039507; Sun, 20 Jun 2021 13:18:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KDIJF4039506; Sun, 20 Jun 2021 13:18:19 GMT (envelope-from git) Date: Sun, 20 Jun 2021 13:18:19 GMT Message-Id: <202106201318.15KDIJF4039506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Martin Matuska Subject: git: d4b496996750 - stable/13 - zfs: merge openzfs/zfs@3de7aeb68 (zfs-2.1-release) into stable/13 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d4b4969967504aa53e67d431e6458ff9a4d10293 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, 20 Jun 2021 13:18:19 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=d4b4969967504aa53e67d431e6458ff9a4d10293 commit d4b4969967504aa53e67d431e6458ff9a4d10293 Merge: 09274116f4d9 3de7aeb68ac1 Author: Martin Matuska AuthorDate: 2021-06-20 13:16:16 +0000 Commit: Martin Matuska CommitDate: 2021-06-20 13:16:16 +0000 zfs: merge openzfs/zfs@3de7aeb68 (zfs-2.1-release) into stable/13 Notable upstream pull request merges: #12054 Avoid deadlock when removing L2ARC devices under I/O #12221 vdev_draid_min_asize() ignores reserved space Obtained from: OpenZFS OpenZFS commit: 3de7aeb68ac1cc1fedd99506671d9028ad1a3c20 .../etc/systemd/system/zfs-import-cache.service.in | 2 +- .../etc/systemd/system/zfs-import-scan.service.in | 2 +- sys/contrib/openzfs/module/os/linux/zfs/zfs_znode.c | 15 +++++++++++---- sys/contrib/openzfs/module/zfs/arc.c | 17 ++++++----------- sys/contrib/openzfs/module/zfs/vdev_draid.c | 3 ++- sys/contrib/openzfs/module/zfs/zio.c | 3 --- sys/contrib/openzfs/rpm/generic/zfs-dkms.spec.in | 7 +++++++ sys/contrib/openzfs/rpm/generic/zfs-kmod.spec.in | 7 +++++++ sys/contrib/openzfs/rpm/generic/zfs.spec.in | 5 +++++ .../tests/functional/cli_root/zfs_destroy/Makefile.am | 1 + sys/modules/zfs/zfs_config.h | 4 ++-- 11 files changed, 43 insertions(+), 23 deletions(-) diff --cc sys/modules/zfs/zfs_config.h index aaf35705dbc0,000000000000..344196bbede9 mode 100644,000000..100644 --- a/sys/modules/zfs/zfs_config.h +++ b/sys/modules/zfs/zfs_config.h @@@ -1,774 -1,0 +1,774 @@@ +/* + * $FreeBSD$ + */ + +/* zfs_config.h. Generated from zfs_config.h.in by configure. */ +/* zfs_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* bio_end_io_t wants 1 arg */ +/* #undef HAVE_1ARG_BIO_END_IO_T */ + +/* lookup_bdev() wants 1 arg */ +/* #undef HAVE_1ARG_LOOKUP_BDEV */ + +/* submit_bio() wants 1 arg */ +/* #undef HAVE_1ARG_SUBMIT_BIO */ + +/* bdi_setup_and_register() wants 2 args */ +/* #undef HAVE_2ARGS_BDI_SETUP_AND_REGISTER */ + +/* vfs_getattr wants 2 args */ +/* #undef HAVE_2ARGS_VFS_GETATTR */ + +/* zlib_deflate_workspacesize() wants 2 args */ +/* #undef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE */ + +/* bdi_setup_and_register() wants 3 args */ +/* #undef HAVE_3ARGS_BDI_SETUP_AND_REGISTER */ + +/* vfs_getattr wants 3 args */ +/* #undef HAVE_3ARGS_VFS_GETATTR */ + +/* vfs_getattr wants 4 args */ +/* #undef HAVE_4ARGS_VFS_GETATTR */ + +/* kernel has access_ok with 'type' parameter */ +/* #undef HAVE_ACCESS_OK_TYPE */ + +/* posix_acl has refcount_t */ +/* #undef HAVE_ACL_REFCOUNT */ + +/* Define if host toolchain supports AES */ +#define HAVE_AES 1 + +#ifdef __amd64__ +#ifndef RESCUE +/* Define if host toolchain supports AVX */ +#define HAVE_AVX 1 +#endif + +/* Define if host toolchain supports AVX2 */ +#define HAVE_AVX2 1 + +/* Define if host toolchain supports AVX512BW */ +#define HAVE_AVX512BW 1 + +/* Define if host toolchain supports AVX512CD */ +#define HAVE_AVX512CD 1 + +/* Define if host toolchain supports AVX512DQ */ +#define HAVE_AVX512DQ 1 + +/* Define if host toolchain supports AVX512ER */ +#define HAVE_AVX512ER 1 + +/* Define if host toolchain supports AVX512F */ +#define HAVE_AVX512F 1 + +/* Define if host toolchain supports AVX512IFMA */ +#define HAVE_AVX512IFMA 1 + +/* Define if host toolchain supports AVX512PF */ +#define HAVE_AVX512PF 1 + +/* Define if host toolchain supports AVX512VBMI */ +#define HAVE_AVX512VBMI 1 + +/* Define if host toolchain supports AVX512VL */ +#define HAVE_AVX512VL 1 +#endif + +/* bdev_check_media_change() exists */ +/* #undef HAVE_BDEV_CHECK_MEDIA_CHANGE */ + +/* bdev_whole() is available */ +/* #undef HAVE_BDEV_WHOLE */ + +/* bio->bi_opf is defined */ +/* #undef HAVE_BIO_BI_OPF */ + +/* bio->bi_status exists */ +/* #undef HAVE_BIO_BI_STATUS */ + +/* bio has bi_iter */ +/* #undef HAVE_BIO_BVEC_ITER */ + +/* bio_*_io_acct() available */ +/* #undef HAVE_BIO_IO_ACCT */ + +/* bio_set_dev() is available */ +/* #undef HAVE_BIO_SET_DEV */ + +/* bio_set_dev() GPL-only */ +/* #undef HAVE_BIO_SET_DEV_GPL_ONLY */ + +/* bio_set_op_attrs is available */ +/* #undef HAVE_BIO_SET_OP_ATTRS */ + +/* blkdev_reread_part() exists */ +/* #undef HAVE_BLKDEV_REREAD_PART */ + +/* blkg_tryget() is available */ +/* #undef HAVE_BLKG_TRYGET */ + +/* blkg_tryget() GPL-only */ +/* #undef HAVE_BLKG_TRYGET_GPL_ONLY */ + +/* blk_alloc_queue() expects request function */ +/* #undef HAVE_BLK_ALLOC_QUEUE_REQUEST_FN */ + +/* blk_alloc_queue_rh() expects request function */ +/* #undef HAVE_BLK_ALLOC_QUEUE_REQUEST_FN_RH */ + +/* blk queue backing_dev_info is dynamic */ +/* #undef HAVE_BLK_QUEUE_BDI_DYNAMIC */ + +/* blk_queue_flag_clear() exists */ +/* #undef HAVE_BLK_QUEUE_FLAG_CLEAR */ + +/* blk_queue_flag_set() exists */ +/* #undef HAVE_BLK_QUEUE_FLAG_SET */ + +/* blk_queue_flush() is available */ +/* #undef HAVE_BLK_QUEUE_FLUSH */ + +/* blk_queue_flush() is GPL-only */ +/* #undef HAVE_BLK_QUEUE_FLUSH_GPL_ONLY */ + +/* blk_queue_secdiscard() is available */ +/* #undef HAVE_BLK_QUEUE_SECDISCARD */ + +/* blk_queue_secure_erase() is available */ +/* #undef HAVE_BLK_QUEUE_SECURE_ERASE */ + +/* blk_queue_write_cache() exists */ +/* #undef HAVE_BLK_QUEUE_WRITE_CACHE */ + +/* blk_queue_write_cache() is GPL-only */ +/* #undef HAVE_BLK_QUEUE_WRITE_CACHE_GPL_ONLY */ + +/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +/* #undef HAVE_CFLOCALECOPYCURRENT */ + +/* Define to 1 if you have the Mac OS X function + CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */ +/* #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES */ + +/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ + +/* check_disk_change() exists */ +/* #undef HAVE_CHECK_DISK_CHANGE */ + +/* clear_inode() is available */ +/* #undef HAVE_CLEAR_INODE */ + +/* dentry uses const struct dentry_operations */ +/* #undef HAVE_CONST_DENTRY_OPERATIONS */ + +/* copy_from_iter() is available */ +/* #undef HAVE_COPY_FROM_ITER */ + +/* copy_to_iter() is available */ +/* #undef HAVE_COPY_TO_ITER */ + +/* yes */ +/* #undef HAVE_CPU_HOTPLUG */ + +/* current_time() exists */ +/* #undef HAVE_CURRENT_TIME */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +/* #undef HAVE_DCGETTEXT */ + +/* DECLARE_EVENT_CLASS() is available */ +/* #undef HAVE_DECLARE_EVENT_CLASS */ + +/* lookup_bdev() wants dev_t arg */ +/* #undef HAVE_DEVT_LOOKUP_BDEV */ + +/* sops->dirty_inode() wants flags */ +/* #undef HAVE_DIRTY_INODE_WITH_FLAGS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* d_make_root() is available */ +/* #undef HAVE_D_MAKE_ROOT */ + +/* d_prune_aliases() is available */ +/* #undef HAVE_D_PRUNE_ALIASES */ + +/* dops->d_revalidate() operation takes nameidata */ +/* #undef HAVE_D_REVALIDATE_NAMEIDATA */ + +/* eops->encode_fh() wants child and parent inodes */ +/* #undef HAVE_ENCODE_FH_WITH_INODE */ + +/* sops->evict_inode() exists */ +/* #undef HAVE_EVICT_INODE */ + +/* fops->aio_fsync() exists */ +/* #undef HAVE_FILE_AIO_FSYNC */ + +/* file_dentry() is available */ +/* #undef HAVE_FILE_DENTRY */ + +/* file_inode() is available */ +/* #undef HAVE_FILE_INODE */ + +/* iops->follow_link() cookie */ +/* #undef HAVE_FOLLOW_LINK_COOKIE */ + +/* iops->follow_link() nameidata */ +/* #undef HAVE_FOLLOW_LINK_NAMEIDATA */ + +/* fops->fsync() with range */ +/* #undef HAVE_FSYNC_RANGE */ + +/* fops->fsync() without dentry */ +/* #undef HAVE_FSYNC_WITHOUT_DENTRY */ + +/* generic_*_io_acct() 3 arg available */ +/* #undef HAVE_GENERIC_IO_ACCT_3ARG */ + +/* generic_*_io_acct() 4 arg available */ +/* #undef HAVE_GENERIC_IO_ACCT_4ARG */ + +/* generic_readlink is global */ +/* #undef HAVE_GENERIC_READLINK */ + +/* generic_setxattr() exists */ +/* #undef HAVE_GENERIC_SETXATTR */ + +/* generic_write_checks() takes kiocb */ +/* #undef HAVE_GENERIC_WRITE_CHECKS_KIOCB */ + +/* Define if the GNU gettext() function is already present or preinstalled. */ +/* #undef HAVE_GETTEXT */ + +/* iops->get_link() cookie */ +/* #undef HAVE_GET_LINK_COOKIE */ + +/* iops->get_link() delayed */ +/* #undef HAVE_GET_LINK_DELAYED */ + +/* group_info->gid exists */ +/* #undef HAVE_GROUP_INFO_GID */ + +/* has_capability() is available */ +/* #undef HAVE_HAS_CAPABILITY */ + +/* Define if you have the iconv() function and it works. */ +#define HAVE_ICONV 1 + +/* yes */ +/* #undef HAVE_INODE_LOCK_SHARED */ + +/* inode_set_flags() exists */ +/* #undef HAVE_INODE_SET_FLAGS */ + +/* inode_set_iversion() exists */ +/* #undef HAVE_INODE_SET_IVERSION */ + +/* inode->i_*time's are timespec64 */ +/* #undef HAVE_INODE_TIMESPEC64_TIMES */ + +/* timestamp_truncate() exists */ +/* #undef HAVE_INODE_TIMESTAMP_TRUNCATE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* in_compat_syscall() is available */ +/* #undef HAVE_IN_COMPAT_SYSCALL */ + +/* iov_iter_advance() is available */ +/* #undef HAVE_IOV_ITER_ADVANCE */ + +/* iov_iter_count() is available */ +/* #undef HAVE_IOV_ITER_COUNT */ + +/* iov_iter_fault_in_readable() is available */ +/* #undef HAVE_IOV_ITER_FAULT_IN_READABLE */ + +/* iov_iter_init() is available */ +/* #undef HAVE_IOV_ITER_INIT */ + +/* iov_iter_init() is available */ +/* #undef HAVE_IOV_ITER_INIT_LEGACY */ + +/* iov_iter_revert() is available */ +/* #undef HAVE_IOV_ITER_REVERT */ + +/* iov_iter types are available */ +/* #undef HAVE_IOV_ITER_TYPES */ + +/* yes */ +/* #undef HAVE_IO_SCHEDULE_TIMEOUT */ + +/* Define to 1 if you have the `issetugid' function. */ +#define HAVE_ISSETUGID 1 + +/* kernel has kernel_fpu_* functions */ +/* #undef HAVE_KERNEL_FPU */ + +/* kernel has asm/fpu/api.h */ +/* #undef HAVE_KERNEL_FPU_API_HEADER */ + +/* kernel fpu internal */ +/* #undef HAVE_KERNEL_FPU_INTERNAL */ + +/* uncached_acl_sentinel() exists */ +/* #undef HAVE_KERNEL_GET_ACL_HANDLE_CACHE */ + +/* kernel does stack verification */ +/* #undef HAVE_KERNEL_OBJTOOL */ + +/* kernel has linux/objtool.h */ +/* #undef HAVE_KERNEL_OBJTOOL_HEADER */ + +/* kernel_read() take loff_t pointer */ +/* #undef HAVE_KERNEL_READ_PPOS */ + +/* timer_list.function gets a timer_list */ +/* #undef HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST */ + +/* struct timer_list has a flags member */ +/* #undef HAVE_KERNEL_TIMER_LIST_FLAGS */ + +/* timer_setup() is available */ +/* #undef HAVE_KERNEL_TIMER_SETUP */ + +/* kernel_write() take loff_t pointer */ +/* #undef HAVE_KERNEL_WRITE_PPOS */ + +/* kmem_cache_create_usercopy() exists */ +/* #undef HAVE_KMEM_CACHE_CREATE_USERCOPY */ + +/* kstrtoul() exists */ +/* #undef HAVE_KSTRTOUL */ + +/* ktime_get_coarse_real_ts64() exists */ +/* #undef HAVE_KTIME_GET_COARSE_REAL_TS64 */ + +/* ktime_get_raw_ts64() exists */ +/* #undef HAVE_KTIME_GET_RAW_TS64 */ + +/* kvmalloc exists */ +/* #undef HAVE_KVMALLOC */ + +/* kernel has large stacks */ +/* #undef HAVE_LARGE_STACKS */ + +/* Define if you have [aio] */ +/* #undef HAVE_LIBAIO */ + +/* Define if you have [blkid] */ +/* #undef HAVE_LIBBLKID */ + +/* Define if you have [crypto] */ +#define HAVE_LIBCRYPTO 1 + +/* Define if you have [tirpc] */ +/* #undef HAVE_LIBTIRPC */ + +/* Define if you have [udev] */ +/* #undef HAVE_LIBUDEV */ + +/* Define if you have [uuid] */ +/* #undef HAVE_LIBUUID */ + +/* lseek_execute() is available */ +/* #undef HAVE_LSEEK_EXECUTE */ + +/* makedev() is declared in sys/mkdev.h */ +/* #undef HAVE_MAKEDEV_IN_MKDEV */ + +/* makedev() is declared in sys/sysmacros.h */ +/* #undef HAVE_MAKEDEV_IN_SYSMACROS */ + +/* Noting that make_request_fn() returns blk_qc_t */ +/* #undef HAVE_MAKE_REQUEST_FN_RET_QC */ + +/* Noting that make_request_fn() returns void */ +/* #undef HAVE_MAKE_REQUEST_FN_RET_VOID */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* iops->create()/mkdir()/mknod() take umode_t */ +/* #undef HAVE_MKDIR_UMODE_T */ + +/* Define to 1 if you have the `mlockall' function. */ +#define HAVE_MLOCKALL 1 + +/* lookup_bdev() wants mode arg */ +/* #undef HAVE_MODE_LOOKUP_BDEV */ + +/* Define if host toolchain supports MOVBE */ +#define HAVE_MOVBE 1 + +/* new_sync_read()/new_sync_write() are available */ +/* #undef HAVE_NEW_SYNC_READ */ + +/* iops->getattr() takes a path */ +/* #undef HAVE_PATH_IOPS_GETATTR */ + +/* Define if host toolchain supports PCLMULQDQ */ +#define HAVE_PCLMULQDQ 1 + +/* percpu_counter_init() wants gfp_t */ +/* #undef HAVE_PERCPU_COUNTER_INIT_WITH_GFP */ + +/* posix_acl_chmod() exists */ +/* #undef HAVE_POSIX_ACL_CHMOD */ + +/* posix_acl_from_xattr() needs user_ns */ +/* #undef HAVE_POSIX_ACL_FROM_XATTR_USERNS */ + +/* posix_acl_release() is available */ +/* #undef HAVE_POSIX_ACL_RELEASE */ + +/* posix_acl_release() is GPL-only */ +/* #undef HAVE_POSIX_ACL_RELEASE_GPL_ONLY */ + +/* posix_acl_valid() wants user namespace */ +/* #undef HAVE_POSIX_ACL_VALID_WITH_NS */ + +/* proc_ops structure exists */ +/* #undef HAVE_PROC_OPS_STRUCT */ + +/* iops->put_link() cookie */ +/* #undef HAVE_PUT_LINK_COOKIE */ + +/* iops->put_link() delayed */ +/* #undef HAVE_PUT_LINK_DELAYED */ + +/* iops->put_link() nameidata */ +/* #undef HAVE_PUT_LINK_NAMEIDATA */ + +/* If available, contains the Python version number currently in use. */ +#define HAVE_PYTHON "3.7" + +/* qat is enabled and existed */ +/* #undef HAVE_QAT */ + +/* iops->rename() wants flags */ +/* #undef HAVE_RENAME_WANTS_FLAGS */ + +/* REQ_DISCARD is defined */ +/* #undef HAVE_REQ_DISCARD */ + +/* REQ_FLUSH is defined */ +/* #undef HAVE_REQ_FLUSH */ + +/* REQ_OP_DISCARD is defined */ +/* #undef HAVE_REQ_OP_DISCARD */ + +/* REQ_OP_FLUSH is defined */ +/* #undef HAVE_REQ_OP_FLUSH */ + +/* REQ_OP_SECURE_ERASE is defined */ +/* #undef HAVE_REQ_OP_SECURE_ERASE */ + +/* REQ_PREFLUSH is defined */ +/* #undef HAVE_REQ_PREFLUSH */ + +/* revalidate_disk() is available */ +/* #undef HAVE_REVALIDATE_DISK */ + +/* revalidate_disk_size() is available */ +/* #undef HAVE_REVALIDATE_DISK_SIZE */ + +/* struct rw_semaphore has member activity */ +/* #undef HAVE_RWSEM_ACTIVITY */ + +/* struct rw_semaphore has atomic_long_t member count */ +/* #undef HAVE_RWSEM_ATOMIC_LONG_COUNT */ + +/* linux/sched/signal.h exists */ +/* #undef HAVE_SCHED_SIGNAL_HEADER */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SECURITY_PAM_MODULES_H 1 + +/* setattr_prepare() is available */ +/* #undef HAVE_SETATTR_PREPARE */ + +/* iops->set_acl() exists */ +/* #undef HAVE_SET_ACL */ + +/* set_cached_acl() is usable */ +/* #undef HAVE_SET_CACHED_ACL_USABLE */ + +/* struct shrink_control exists */ +/* #undef HAVE_SHRINK_CONTROL_STRUCT */ + +/* new shrinker callback wants 2 args */ +/* #undef HAVE_SINGLE_SHRINKER_CALLBACK */ + +/* ->count_objects exists */ +/* #undef HAVE_SPLIT_SHRINKER_CALLBACK */ + +#if defined(__amd64__) || defined(__i386__) +/* Define if host toolchain supports SSE */ +#define HAVE_SSE 1 + +/* Define if host toolchain supports SSE2 */ +#define HAVE_SSE2 1 + +/* Define if host toolchain supports SSE3 */ +#define HAVE_SSE3 1 + +/* Define if host toolchain supports SSE4.1 */ +#define HAVE_SSE4_1 1 + +/* Define if host toolchain supports SSE4.2 */ +#define HAVE_SSE4_2 1 + +/* Define if host toolchain supports SSSE3 */ +#define HAVE_SSSE3 1 +#endif + +/* STACK_FRAME_NON_STANDARD is defined */ +/* #undef HAVE_STACK_FRAME_NON_STANDARD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +#define HAVE_STRLCAT 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* submit_bio is member of struct block_device_operations */ +/* #undef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS */ + +/* super_setup_bdi_name() exits */ +/* #undef HAVE_SUPER_SETUP_BDI_NAME */ + +/* super_block->s_user_ns exists */ +/* #undef HAVE_SUPER_USER_NS */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* i_op->tmpfile() exists */ +/* #undef HAVE_TMPFILE */ + +/* totalhigh_pages() exists */ +/* #undef HAVE_TOTALHIGH_PAGES */ + +/* kernel has totalram_pages() */ +/* #undef HAVE_TOTALRAM_PAGES_FUNC */ + +/* Define to 1 if you have the `udev_device_get_is_initialized' function. */ +/* #undef HAVE_UDEV_DEVICE_GET_IS_INITIALIZED */ + +/* kernel has __kernel_fpu_* functions */ +/* #undef HAVE_UNDERSCORE_KERNEL_FPU */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* iops->getattr() takes a vfsmount */ +/* #undef HAVE_VFSMOUNT_IOPS_GETATTR */ + +/* aops->direct_IO() uses iovec */ +/* #undef HAVE_VFS_DIRECT_IO_IOVEC */ + +/* aops->direct_IO() uses iov_iter without rw */ +/* #undef HAVE_VFS_DIRECT_IO_ITER */ + +/* aops->direct_IO() uses iov_iter with offset */ +/* #undef HAVE_VFS_DIRECT_IO_ITER_OFFSET */ + +/* aops->direct_IO() uses iov_iter with rw and offset */ +/* #undef HAVE_VFS_DIRECT_IO_ITER_RW_OFFSET */ + +/* All required iov_iter interfaces are available */ +/* #undef HAVE_VFS_IOV_ITER */ + +/* fops->iterate() is available */ +/* #undef HAVE_VFS_ITERATE */ + +/* fops->iterate_shared() is available */ +/* #undef HAVE_VFS_ITERATE_SHARED */ + +/* fops->readdir() is available */ +/* #undef HAVE_VFS_READDIR */ + +/* fops->read/write_iter() are available */ +/* #undef HAVE_VFS_RW_ITERATE */ + +/* __vmalloc page flags exists */ +/* #undef HAVE_VMALLOC_PAGE_KERNEL */ + +/* yes */ +/* #undef HAVE_WAIT_ON_BIT_ACTION */ + +/* wait_queue_entry_t exists */ +/* #undef HAVE_WAIT_QUEUE_ENTRY_T */ + +/* wq_head->head and wq_entry->entry exist */ +/* #undef HAVE_WAIT_QUEUE_HEAD_ENTRY */ + +/* xattr_handler->get() wants dentry */ +/* #undef HAVE_XATTR_GET_DENTRY */ + +/* xattr_handler->get() wants both dentry and inode */ +/* #undef HAVE_XATTR_GET_DENTRY_INODE */ + +/* xattr_handler->get() wants xattr_handler */ +/* #undef HAVE_XATTR_GET_HANDLER */ + +/* xattr_handler has name */ +/* #undef HAVE_XATTR_HANDLER_NAME */ + +/* xattr_handler->list() wants dentry */ +/* #undef HAVE_XATTR_LIST_DENTRY */ + +/* xattr_handler->list() wants xattr_handler */ +/* #undef HAVE_XATTR_LIST_HANDLER */ + +/* xattr_handler->list() wants simple */ +/* #undef HAVE_XATTR_LIST_SIMPLE */ + +/* xattr_handler->set() wants dentry */ +/* #undef HAVE_XATTR_SET_DENTRY */ + +/* xattr_handler->set() wants both dentry and inode */ +/* #undef HAVE_XATTR_SET_DENTRY_INODE */ + +/* xattr_handler->set() wants xattr_handler */ +/* #undef HAVE_XATTR_SET_HANDLER */ + +/* Define if you have [z] */ +#define HAVE_ZLIB 1 + +/* __posix_acl_chmod() exists */ +/* #undef HAVE___POSIX_ACL_CHMOD */ + +/* kernel exports FPU functions */ +/* #undef KERNEL_EXPORTS_X86_FPU */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* make_request_fn() return type */ +/* #undef MAKE_REQUEST_FN_RET */ + +/* hardened module_param_call */ +/* #undef MODULE_PARAM_CALL_CONST */ + +/* struct shrink_control has nid */ +/* #undef SHRINK_CONTROL_HAS_NID */ + +/* Defined for legacy compatibility. */ +#define SPL_META_ALIAS ZFS_META_ALIAS + +/* Defined for legacy compatibility. */ +#define SPL_META_RELEASE ZFS_META_RELEASE + +/* Defined for legacy compatibility. */ +#define SPL_META_VERSION ZFS_META_VERSION + +/* True if ZFS is to be compiled for a FreeBSD system */ +#define SYSTEM_FREEBSD 1 + +/* True if ZFS is to be compiled for a Linux system */ +/* #undef SYSTEM_LINUX */ + +/* zfs debugging enabled */ +/* #undef ZFS_DEBUG */ + +/* /dev/zfs minor */ +/* #undef ZFS_DEVICE_MINOR */ + +/* enum node_stat_item contains NR_FILE_PAGES */ +/* #undef ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES */ + +/* enum node_stat_item contains NR_INACTIVE_ANON */ +/* #undef ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_ANON */ + +/* enum node_stat_item contains NR_INACTIVE_FILE */ +/* #undef ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_FILE */ + +/* enum zone_stat_item contains NR_FILE_PAGES */ +/* #undef ZFS_ENUM_ZONE_STAT_ITEM_NR_FILE_PAGES */ + +/* enum zone_stat_item contains NR_INACTIVE_ANON */ +/* #undef ZFS_ENUM_ZONE_STAT_ITEM_NR_INACTIVE_ANON */ + +/* enum zone_stat_item contains NR_INACTIVE_FILE */ +/* #undef ZFS_ENUM_ZONE_STAT_ITEM_NR_INACTIVE_FILE */ + +/* global_node_page_state() exists */ +/* #undef ZFS_GLOBAL_NODE_PAGE_STATE */ + +/* global_zone_page_state() exists */ +/* #undef ZFS_GLOBAL_ZONE_PAGE_STATE */ + +/* Define to 1 if GPL-only symbols can be used */ +/* #undef ZFS_IS_GPL_COMPATIBLE */ + +/* Define the project alias string. */ - #define ZFS_META_ALIAS "zfs-2.1.0-FreeBSD_gc3b60eded" ++#define ZFS_META_ALIAS "zfs-2.1.0-FreeBSD_g3de7aeb68" + +/* Define the project author. */ +#define ZFS_META_AUTHOR "OpenZFS" + +/* Define the project release date. */ +/* #undef ZFS_META_DATA */ + +/* Define the maximum compatible kernel version. */ +#define ZFS_META_KVER_MAX "5.12" + +/* Define the minimum compatible kernel version. */ +#define ZFS_META_KVER_MIN "3.10" + +/* Define the project license. */ +#define ZFS_META_LICENSE "CDDL" + +/* Define the libtool library 'age' version information. */ +/* #undef ZFS_META_LT_AGE */ + +/* Define the libtool library 'current' version information. */ +/* #undef ZFS_META_LT_CURRENT */ + +/* Define the libtool library 'revision' version information. */ +/* #undef ZFS_META_LT_REVISION */ + +/* Define the project name. */ +#define ZFS_META_NAME "zfs" + +/* Define the project release. */ - #define ZFS_META_RELEASE "FreeBSD_gc3b60eded" ++#define ZFS_META_RELEASE "FreeBSD_g3de7aeb68" + +/* Define the project version. */ +#define ZFS_META_VERSION "2.1.0" + +/* count is located in percpu_ref.data */ +/* #undef ZFS_PERCPU_REF_COUNT_IN_DATA */ + From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 19:03: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 DD7A365765E; Sun, 20 Jun 2021 19:03: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 4G7MVr5jhsz4cmN; Sun, 20 Jun 2021 19:03: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 AC3D26EFE; Sun, 20 Jun 2021 19:03: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 15KJ30vd007936; Sun, 20 Jun 2021 19:03:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KJ30fm007935; Sun, 20 Jun 2021 19:03:00 GMT (envelope-from git) Date: Sun, 20 Jun 2021 19:03:00 GMT Message-Id: <202106201903.15KJ30fm007935@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: 7242b5c6d216 - stable/12 - stand: Fix __elfN(loadimage) return value 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: 7242b5c6d2165f7c6141e5edc878f36f3ab43e40 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, 20 Jun 2021 19:03:00 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7242b5c6d2165f7c6141e5edc878f36f3ab43e40 commit 7242b5c6d2165f7c6141e5edc878f36f3ab43e40 Author: Mark Johnston AuthorDate: 2021-06-06 20:40:25 +0000 Commit: Mark Johnston CommitDate: 2021-06-20 19:02:47 +0000 stand: Fix __elfN(loadimage) return value Caller functions expect __elfN(loadimage) to return a value of zero on failure and the file size on success. PR: 256390 Reviewed by: markj (cherry picked from commit 1ea87e2a70c31454a8696ab2979d13d21c5575d2) --- stand/common/load_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 7139dc8b7c32..e81bb49a93b5 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -875,7 +875,7 @@ nosyms: p_start = sym.st_value + ef->off; if (__elfN(lookup_symbol)(fp, ef, "__stop_set_modmetadata_set", &sym) != 0) - return ENOENT; + return 0; p_end = sym.st_value + ef->off; if (__elfN(parse_modmetadata)(fp, ef, p_start, p_end) == 0) From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 19:03: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 4A21C657B56; Sun, 20 Jun 2021 19:03: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 4G7MVx0DWgz4d3Q; Sun, 20 Jun 2021 19:03: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 E465A6D72; Sun, 20 Jun 2021 19:03: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 15KJ34tX008061; Sun, 20 Jun 2021 19:03:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KJ34cA008060; Sun, 20 Jun 2021 19:03:04 GMT (envelope-from git) Date: Sun, 20 Jun 2021 19:03:04 GMT Message-Id: <202106201903.15KJ34cA008060@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: 765c6eb3953c - stable/13 - stand: Fix __elfN(loadimage) return value 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: 765c6eb3953c0e9e95543bfb9e7352772ace030c 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, 20 Jun 2021 19:03:05 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=765c6eb3953c0e9e95543bfb9e7352772ace030c commit 765c6eb3953c0e9e95543bfb9e7352772ace030c Author: Mark Johnston AuthorDate: 2021-06-06 20:40:25 +0000 Commit: Mark Johnston CommitDate: 2021-06-20 19:00:54 +0000 stand: Fix __elfN(loadimage) return value Caller functions expect __elfN(loadimage) to return a value of zero on failure and the file size on success. PR: 256390 Reviewed by: markj (cherry picked from commit 1ea87e2a70c31454a8696ab2979d13d21c5575d2) --- stand/common/load_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 8bb780ef34df..f1a9ff8e0c22 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -893,7 +893,7 @@ nosyms: p_start = sym.st_value + ef->off; if (__elfN(lookup_symbol)(ef, "__stop_set_modmetadata_set", &sym, STT_NOTYPE) != 0) - return ENOENT; + return 0; p_end = sym.st_value + ef->off; if (__elfN(parse_modmetadata)(fp, ef, p_start, p_end) == 0) From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 19:11:20 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 62599657E91; Sun, 20 Jun 2021 19:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G7MhS2Fskz4dHf; Sun, 20 Jun 2021 19:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 361F07396; Sun, 20 Jun 2021 19:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15KJBKeR017665; Sun, 20 Jun 2021 19:11:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KJBKXY017664; Sun, 20 Jun 2021 19:11:20 GMT (envelope-from git) Date: Sun, 20 Jun 2021 19:11:20 GMT Message-Id: <202106201911.15KJBKXY017664@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: 5fb914cdc18a - stable/11 - cpucontrol: fix extended signature matching code to avoid fallthough 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/11 X-Git-Reftype: branch X-Git-Commit: 5fb914cdc18acf9070002af69832973a6472f7ac 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, 20 Jun 2021 19:11:20 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5fb914cdc18acf9070002af69832973a6472f7ac commit 5fb914cdc18acf9070002af69832973a6472f7ac Author: Dan Nelson AuthorDate: 2021-06-14 19:28:16 +0000 Commit: Mark Johnston CommitDate: 2021-06-20 19:11:18 +0000 cpucontrol: fix extended signature matching code to avoid fallthough PR: 256502 (cherry picked from commit 87799c5f85dc0aed7e53ca841504e3b2ffc88498) --- usr.sbin/cpucontrol/intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/cpucontrol/intel.c b/usr.sbin/cpucontrol/intel.c index 8ad1908bd386..e9c9c6ab6f12 100644 --- a/usr.sbin/cpucontrol/intel.c +++ b/usr.sbin/cpucontrol/intel.c @@ -262,8 +262,8 @@ no_table: (flags & ext_table[i].cpu_flags) != 0) goto matched; } - } else - goto fail; + } + goto fail; matched: if (revision >= fw_header->revision) { From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 19:11: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 2907F657AB8; Sun, 20 Jun 2021 19:11: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 4G7MhX0XsBz4d75; Sun, 20 Jun 2021 19:11: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 EA89C71BF; Sun, 20 Jun 2021 19:11: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 15KJBN40017786; Sun, 20 Jun 2021 19:11:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KJBNrL017785; Sun, 20 Jun 2021 19:11:23 GMT (envelope-from git) Date: Sun, 20 Jun 2021 19:11:23 GMT Message-Id: <202106201911.15KJBNrL017785@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: d8d0df35b353 - stable/12 - cpucontrol: fix extended signature matching code to avoid fallthough 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: d8d0df35b353f9f0ae507d40b699a689a06ac252 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, 20 Jun 2021 19:11:24 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d8d0df35b353f9f0ae507d40b699a689a06ac252 commit d8d0df35b353f9f0ae507d40b699a689a06ac252 Author: Dan Nelson AuthorDate: 2021-06-14 19:28:16 +0000 Commit: Mark Johnston CommitDate: 2021-06-20 19:10:28 +0000 cpucontrol: fix extended signature matching code to avoid fallthough PR: 256502 (cherry picked from commit 87799c5f85dc0aed7e53ca841504e3b2ffc88498) --- usr.sbin/cpucontrol/intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/cpucontrol/intel.c b/usr.sbin/cpucontrol/intel.c index dfe86f7185c6..f4700898d5eb 100644 --- a/usr.sbin/cpucontrol/intel.c +++ b/usr.sbin/cpucontrol/intel.c @@ -242,8 +242,8 @@ no_table: (flags & ext_table[i].cpu_flags) != 0) goto matched; } - } else - goto fail; + } + goto fail; matched: if (revision >= fw_header->revision) { From owner-dev-commits-src-branches@freebsd.org Sun Jun 20 19:11: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 8AEE9657EB0; Sun, 20 Jun 2021 19:11: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 4G7Mhk3V7mz4dJ3; Sun, 20 Jun 2021 19:11:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FD837231; Sun, 20 Jun 2021 19:11:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15KJBYiF017919; Sun, 20 Jun 2021 19:11:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15KJBYAj017918; Sun, 20 Jun 2021 19:11:34 GMT (envelope-from git) Date: Sun, 20 Jun 2021 19:11:34 GMT Message-Id: <202106201911.15KJBYAj017918@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: 659f77766031 - stable/13 - cpucontrol: fix extended signature matching code to avoid fallthough 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: 659f77766031145ff2af2fc56da210cfbb6d249f 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, 20 Jun 2021 19:11:34 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=659f77766031145ff2af2fc56da210cfbb6d249f commit 659f77766031145ff2af2fc56da210cfbb6d249f Author: Dan Nelson AuthorDate: 2021-06-14 19:28:16 +0000 Commit: Mark Johnston CommitDate: 2021-06-20 19:10:21 +0000 cpucontrol: fix extended signature matching code to avoid fallthough PR: 256502 (cherry picked from commit 87799c5f85dc0aed7e53ca841504e3b2ffc88498) --- usr.sbin/cpucontrol/intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/cpucontrol/intel.c b/usr.sbin/cpucontrol/intel.c index dfe86f7185c6..f4700898d5eb 100644 --- a/usr.sbin/cpucontrol/intel.c +++ b/usr.sbin/cpucontrol/intel.c @@ -242,8 +242,8 @@ no_table: (flags & ext_table[i].cpu_flags) != 0) goto matched; } - } else - goto fail; + } + goto fail; matched: if (revision >= fw_header->revision) {