From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 01:13: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 4628454225A; Mon, 22 Feb 2021 01:13: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 4DkPMb1Wqyz3wBS; Mon, 22 Feb 2021 01:13: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 1C9281CAE8; Mon, 22 Feb 2021 01:13: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 11M1Dl1l010884; Mon, 22 Feb 2021 01:13:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M1DlYp010883; Mon, 22 Feb 2021 01:13:47 GMT (envelope-from git) Date: Mon, 22 Feb 2021 01:13:47 GMT Message-Id: <202102220113.11M1DlYp010883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: c05f4077ecc4 - stable/13 - pxeboot(8): remove antiquated information MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c05f4077ecc45406d52dc64bddb95a15c633d1e8 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, 22 Feb 2021 01:13:47 -0000 The branch stable/13 has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c05f4077ecc45406d52dc64bddb95a15c633d1e8 commit c05f4077ecc45406d52dc64bddb95a15c633d1e8 Author: Guangyuan Yang AuthorDate: 2021-02-15 22:03:37 +0000 Commit: Guangyuan Yang CommitDate: 2021-02-22 01:13:24 +0000 pxeboot(8): remove antiquated information While I was there: - Fix some typos - Fix an excessive argument "indent" reported by mandoc -Tlint - Replace a dead link with the one suggested by https://www.uefi.org/uefi Submitted by: linimon (in part) Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D27774 (cherry picked from commit c90fb7acf099f1dc982f8d6087aa92809ae43727) --- stand/i386/pxeldr/pxeboot.8 | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/stand/i386/pxeldr/pxeboot.8 b/stand/i386/pxeldr/pxeboot.8 index c9fa434b3028..58b1f06bcd0f 100644 --- a/stand/i386/pxeldr/pxeboot.8 +++ b/stand/i386/pxeldr/pxeboot.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 25, 2018 +.Dd February 15, 2021 .Dt PXEBOOT 8 .Os .Sh NAME @@ -97,19 +97,19 @@ from the specified server before loading any other files. .Pp Valid .Va option root-path -Syntax is the following -.Bl -tag -width ://ip/path indent +syntax is the following +.Bl -tag -width ://ip/path .It /path path to the root filesystem on the NFS server -.It ip:/path +.It ip://path path to the root filesystem on the NFS server .Ar ip -.It nfs:/path +.It nfs://path path to the root filesystem on the NFS server .It nfs://ip/path path to the root filesystem on the NFS server .Ar ip -.It tftp:/path +.It tftp://path path to the root filesystem on the TFTP server .It tftp://ip/path path to the root filesystem on the TFTP server @@ -129,18 +129,9 @@ In all other respects, acts just like .Xr loader 8 . .Pp -As PXE is still in its infancy, some firmware versions may not work -properly. -The -.Nm -bootloader has been extensively tested on version 0.99 of Intel firmware; -pre-release versions of the newer 2.0 firmware are known to have -problems. -Check with the device's manufacturer for their latest stable release. -.Pp For further information on Intel's PXE specifications and Wired for Management (WfM) systems, see -.Li http://www.intel.com/design/archives/wfm/ . +.Li http://www.pix.net/software/pxeboot/archive/pxespec.pdf . .Sh SEE ALSO .Xr loader 8 .Sh HISTORY From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 05:24: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 CC13654820C; Mon, 22 Feb 2021 05:24: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 4DkVwK5QQwz4c0F; Mon, 22 Feb 2021 05:24: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 ACB5F20079; Mon, 22 Feb 2021 05:24: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 11M5O1Bt043558; Mon, 22 Feb 2021 05:24:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M5O1lU043557; Mon, 22 Feb 2021 05:24:01 GMT (envelope-from git) Date: Mon, 22 Feb 2021 05:24:01 GMT Message-Id: <202102220524.11M5O1lU043557@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: 9c59d7533731 - stable/12 - libpmc: fix linking with C programs 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/12 X-Git-Reftype: branch X-Git-Commit: 9c59d753373189f83b4447fe6a5456573451e014 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, 22 Feb 2021 05:24:01 -0000 The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=9c59d753373189f83b4447fe6a5456573451e014 commit 9c59d753373189f83b4447fe6a5456573451e014 Author: Alan Somers AuthorDate: 2021-02-21 20:56:57 +0000 Commit: Alan Somers CommitDate: 2021-02-22 05:23:12 +0000 libpmc: fix linking with C programs Revision r334749 Added some C++ code to libpmc. It didn't change the ABI, but it did introduce a dependency on libc++. Nobody noticed because every program that in the base system that uses libpmc is also C++. Reported-by: Dom Dwyer Reviewed By: vangyzen Differential Revision: https://reviews.freebsd.org/D28550 (cherry picked from commit 04e34c0202ea50cea67d5779f54bc612c74e6532) --- lib/libpmc/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile index 35bacb26bd11..1e204e13fdb2 100644 --- a/lib/libpmc/Makefile +++ b/lib/libpmc/Makefile @@ -8,6 +8,12 @@ INCS= pmc.h pmclog.h pmcformat.h CFLAGS+= -I${.CURDIR} CWARNFLAGS.gcc+= -Wno-shadow -Wno-cast-align +.include +.if ${COMPILER_TYPE} == "gcc" +LDADD+= -lstdc++ +.else +LDADD+= -lc++ +.endif .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 05:50: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 4BECE548A34; Mon, 22 Feb 2021 05:50: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 4DkWWG1jpRz4dRq; Mon, 22 Feb 2021 05:50: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 2DD1B20337; Mon, 22 Feb 2021 05:50:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11M5ooYm077662; Mon, 22 Feb 2021 05:50:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M5oone077661; Mon, 22 Feb 2021 05:50:50 GMT (envelope-from git) Date: Mon, 22 Feb 2021 05:50:50 GMT Message-Id: <202102220550.11M5oone077661@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: 5dbb407145c8 - stable/13 - MFC jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5dbb407145c8128753fa30b695bc266dc671e433 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, 22 Feb 2021 05:50:50 -0000 The branch stable/13 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=5dbb407145c8128753fa30b695bc266dc671e433 commit 5dbb407145c8128753fa30b695bc266dc671e433 Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Jamie Gritton CommitDate: 2021-02-22 05:49:40 +0000 MFC jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Reported by: mjg Approved by: markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 059e5123c7b5..31c7d3bf2188 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3795,9 +3795,8 @@ pwd_drop(struct pwd *pwd) } /* -* Common routine for kern_chroot() and jail_attach(). The caller is -* responsible for invoking priv_check() and mac_vnode_check_chroot() to -* authorize this operation. +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. */ int pwd_chroot(struct thread *td, struct vnode *vp) @@ -3859,6 +3858,46 @@ pwd_chdir(struct thread *td, struct vnode *vp) pwd_drop(oldpwd); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct pwddesc *pdp; + struct filedesc *fdp; + struct pwd *newpwd, *oldpwd; + int error; + + fdp = td->td_proc->p_fd; + pdp = td->td_proc->p_pd; + newpwd = pwd_alloc(); + FILEDESC_SLOCK(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); + error = chroot_refuse_vdir_fds(fdp); + FILEDESC_SUNLOCK(fdp); + if (error != 0) { + PWDDESC_XUNLOCK(pdp); + pwd_drop(newpwd); + return (error); + } + + vrefact(vp); + newpwd->pwd_rdir = vp; + vrefact(vp); + newpwd->pwd_cdir = vp; + if (oldpwd->pwd_jdir == NULL) { + vrefact(vp); + newpwd->pwd_jdir = vp; + } + pwd_fill(oldpwd, newpwd); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); + pwd_drop(oldpwd); + return (0); +} + void pwd_ensure_dirs(void) { diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b56c889eeb7e..90ab69a372d2 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2495,7 +2495,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 890232b7f160..8c5aa258ed28 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -333,6 +333,7 @@ void pdunshare(struct thread *td); void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); void pwd_set_rootvnode(void); From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:37: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 31D4654D5C4; Mon, 22 Feb 2021 08:37: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 4DkbCz0gtMz4p5R; Mon, 22 Feb 2021 08:37: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 05FEA22A0A; Mon, 22 Feb 2021 08:37: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 11M8boQT094960; Mon, 22 Feb 2021 08:37:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8boEe094959; Mon, 22 Feb 2021 08:37:50 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:50 GMT Message-Id: <202102220837.11M8boEe094959@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: 882cbdeb21dc - stable/13 - netgraph/ng_bridge: Introduce "uplink" ports without MAC learning 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: 882cbdeb21dc745354781fbae1d4634ebb81fce3 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, 22 Feb 2021 08:37:51 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=882cbdeb21dc745354781fbae1d4634ebb81fce3 commit 882cbdeb21dc745354781fbae1d4634ebb81fce3 Author: Lutz Donnerhacke AuthorDate: 2021-02-06 10:08:24 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:20:37 +0000 netgraph/ng_bridge: Introduce "uplink" ports without MAC learning The ng_bridge(4) node is designed to work in moderately small environments. Connecting such a node to a larger network rapidly fills the MAC table for no reason. It even become complicated to obtain data from the gettable message, because the result is too large to transmit. This patch introduces, two new functionality bits on the hooks: - Allow or disallow MAC address learning for incoming patckets. - Allow or disallow sending unknown MACs through this hook. Uplinks are characterized by denied learing while sending out unknowns. Normal links are charaterized by allowed learning and sending out unknowns. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D23963 (cherry picked from commit f961caf2184c94d6f59c8d522207156b3533d977) --- share/man/man4/ng_bridge.4 | 30 +++++++++++++-- sys/netgraph/ng_bridge.c | 95 +++++++++++++++++++++++++++++----------------- sys/netgraph/ng_bridge.h | 2 + 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index 85c2d8871c7c..b5937375e87a 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2019 +.Dd February 6, 2021 .Dt NG_BRIDGE 4 .Os .Sh NAME @@ -92,6 +92,23 @@ To connect the host machine to a bridged network, simply connect the hook of an .Xr ng_ether 4 node to the bridge node. +.Pp +Instead of naming a hook +.Dv linkX +the hook might be also named +.Dv uplinkX . +The node does not learn MAC addresses on uplink hooks, which keeps +the internal address table small. +This way it is desirable to connect the +.Dv lower +hook of an +.Xr ng_ether 4 +node to an +.Dv uplink +hook of the bridge, and ignore the complexity of the outside world. +Frames with unknown MACs are always sent out to +.Dv uplink +hooks, so no functionality is lost. .Sh CONTROL MESSAGES This node type supports the generic control messages, plus the following: @@ -141,8 +158,9 @@ The node configuration is not changed. This command takes a four byte link number as an argument and returns a .Dv "struct ng_bridge_link_stats" -containing statistics for the corresponding link, which must be -currently connected: +containing statistics for the corresponding +.Dv link , +which must be currently connected: .Bd -literal -offset 0n /* Statistics structure (one for each link) */ struct ng_bridge_link_stats { @@ -162,6 +180,12 @@ struct ng_bridge_link_stats { uint64_t memoryFailures; /* times couldn't get mem or mbuf */ }; .Ed +.Pp +Negative numbers refer to the +.Dv uplink +hooks. +So querying for -7 will get the statistics for hook +.Dv uplink7 . .It Dv NGM_BRIDGE_CLR_STATS Pq Ic clrstats This command takes a four byte link number as an argument and clears the statistics for that link. diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 1521b1cee901..a21da545e210 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -91,6 +91,8 @@ static MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", struct ng_bridge_link { hook_p hook; /* netgraph hook */ u_int16_t loopCount; /* loop ignore timer */ + unsigned int learnMac : 1, /* autolearn macs */ + sendUnknown : 1;/* send unknown macs out */ struct ng_bridge_link_stats stats; /* link stats */ }; @@ -334,38 +336,49 @@ static int ng_bridge_newhook(node_p node, hook_p hook, const char *name) { const priv_p priv = NG_NODE_PRIVATE(node); + char linkName[NG_HOOKSIZ]; + u_int32_t linkNum; + link_p link; + const char *prefix = NG_BRIDGE_HOOK_LINK_PREFIX; + bool isUplink; /* Check for a link hook */ - if (strlen(name) > strlen(NG_BRIDGE_HOOK_LINK_PREFIX)) { - char linkName[NG_HOOKSIZ]; - u_int32_t linkNum; - link_p link; - - /* primitive parsing */ - linkNum = strtoul(name + strlen(NG_BRIDGE_HOOK_LINK_PREFIX), - NULL, 10); - /* validation by comparing against the reconstucted name */ - snprintf(linkName, sizeof(linkName), - "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, - linkNum); - if (strcmp(linkName, name) != 0) - return (EINVAL); - - if(NG_PEER_NODE(hook) == node) - return (ELOOP); - - link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, - M_WAITOK|M_ZERO); - if (link == NULL) - return (ENOMEM); - link->hook = hook; - NG_HOOK_SET_PRIVATE(hook, link); - priv->numLinks++; - return (0); + if (strlen(name) <= strlen(prefix)) + return (EINVAL); /* Unknown hook name */ + + isUplink = (name[0] == 'u'); + if (isUplink) + prefix = NG_BRIDGE_HOOK_UPLINK_PREFIX; + + /* primitive parsing */ + linkNum = strtoul(name + strlen(prefix), NULL, 10); + /* validation by comparing against the reconstucted name */ + snprintf(linkName, sizeof(linkName), "%s%u", prefix, linkNum); + if (strcmp(linkName, name) != 0) + return (EINVAL); + + if (linkNum == 0 && isUplink) + return (EINVAL); + + if(NG_PEER_NODE(hook) == node) + return (ELOOP); + + link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); + if (link == NULL) + return (ENOMEM); + + link->hook = hook; + if (isUplink) { + link->learnMac = 0; + link->sendUnknown = 1; + } else { + link->learnMac = 1; + link->sendUnknown = 1; } - /* Unknown hook name */ - return (EINVAL); + NG_HOOK_SET_PRIVATE(hook, link); + priv->numLinks++; + return (0); } /* @@ -438,6 +451,11 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) i = 0; for (bucket = 0; bucket < priv->numBuckets; bucket++) { SLIST_FOREACH(hent, &priv->tab[bucket], next) { + const char *name = NG_HOOK_NAME(hent->host.link->hook); + const char *prefix = name[0] == 'u' ? + NG_BRIDGE_HOOK_UPLINK_PREFIX : + NG_BRIDGE_HOOK_LINK_PREFIX; + memcpy(ary->hosts[i].addr, hent->host.addr, sizeof(ary->hosts[i].addr)); @@ -445,9 +463,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) ary->hosts[i].staleness = hent->host.staleness; ary->hosts[i].linkNum = strtol( - NG_HOOK_NAME(hent->host.link->hook) + - strlen(NG_BRIDGE_HOOK_LINK_PREFIX), - NULL, 10); + name + strlen(prefix), NULL, 10); i++; } } @@ -506,15 +522,20 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) hook_p hook; link_p link; char linkName[NG_HOOKSIZ]; + int linkNum; /* Get link number */ if (msg->header.arglen != sizeof(u_int32_t)) { error = EINVAL; break; } - snprintf(linkName, sizeof(linkName), - "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, - *((u_int32_t *)msg->data)); + linkNum = *((int32_t *)msg->data); + if (linkNum < 0) + snprintf(linkName, sizeof(linkName), + "%s%u", NG_BRIDGE_HOOK_UPLINK_PREFIX, -linkNum); + else + snprintf(linkName, sizeof(linkName), + "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, linkNum); if ((hook = ng_findhook(node, linkName)) == NULL) { error = ENOTCONN; @@ -609,6 +630,10 @@ ng_bridge_send_ctx(hook_p dst, void *arg) return (1); } + /* Skip sending unknowns to undesired links */ + if (!ctx->manycast && !destLink->sendUnknown) + return (1); + if (ctx->foundFirst == NULL) { /* * This is the first usable link we have found. @@ -750,7 +775,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) host->link = ctx.incoming; host->age = 0; } - } else { + } else if (ctx.incoming->learnMac) { if (!ng_bridge_put(priv, eh->ether_shost, ctx.incoming)) { ctx.incoming->stats.memoryFailures++; NG_FREE_ITEM(item); diff --git a/sys/netgraph/ng_bridge.h b/sys/netgraph/ng_bridge.h index 765d279bfdb1..ec237eb19cac 100644 --- a/sys/netgraph/ng_bridge.h +++ b/sys/netgraph/ng_bridge.h @@ -64,6 +64,8 @@ /* Hook names */ #define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */ #define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */ +#define NG_BRIDGE_HOOK_UPLINK_PREFIX "uplink" /* append decimal integer */ +#define NG_BRIDGE_HOOK_UPLINK_FMT "uplink%d" /* for use with printf(3) */ /* Node configuration structure */ struct ng_bridge_config { From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:37: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 5697654D272; Mon, 22 Feb 2021 08:37: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 4DkbD01C4Pz4nkB; Mon, 22 Feb 2021 08:37: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 1C2F222A0B; Mon, 22 Feb 2021 08:37: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 11M8bqij094980; Mon, 22 Feb 2021 08:37:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8bqrf094979; Mon, 22 Feb 2021 08:37:52 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:52 GMT Message-Id: <202102220837.11M8bqrf094979@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: 8135f3f2fcd1 - stable/13 - netgraph/ng_bridge: Derive forwarding mode from first attached hook 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: 8135f3f2fcd13feeba0362e59549ce3cb51d8c6e 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, 22 Feb 2021 08:37:52 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=8135f3f2fcd13feeba0362e59549ce3cb51d8c6e commit 8135f3f2fcd13feeba0362e59549ce3cb51d8c6e Author: Lutz Donnerhacke AuthorDate: 2021-02-06 10:25:04 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:21:04 +0000 netgraph/ng_bridge: Derive forwarding mode from first attached hook Handling of unknown MACs on an bridge with incomplete learning capabilites (aka uplink ports) can be defined in different ways. The classical approach is to broadcast unicast frames send to an unknown MAC, because the unknown devices can be everywhere. This mode is default for ng_bridge(4). In the case of dedicated uplink ports, which prohibit learning of MAC addresses in order to save memory and CPU cycles, the broadcast approach is dangerous. All traffic to the uplink port is broadcasted to every downlink port, too. In this case, it's better to restrict the distribution of frames to unknown MAC to the uplink ports only. In order to keep the chance small and the handling as natural as possible, the first attached link is used to determine the behaviour of the bridge: If it is an "uplink" port, then the bridge switch from classical mode to restricted mode. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D28487 (cherry picked from commit c869d905baa4e329dfd6793e7487b5985248ddb6) --- share/man/man4/ng_bridge.4 | 16 ++++++++++++++++ sys/netgraph/ng_bridge.c | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index b5937375e87a..1451773711e9 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -109,6 +109,22 @@ hook of the bridge, and ignore the complexity of the outside world. Frames with unknown MACs are always sent out to .Dv uplink hooks, so no functionality is lost. +.Pp +Frames with unknown destination MAC addresses are replicated to any +available hook, unless the first connected hook is an +.Ar uplink +hook. +In this case the node assumes, that all unknown MAC addresses are +located soley on the +.Ar uplink +hooks and only those hooks will be used to send out frames with +unknown destination MACs. +If the first connected hook is an +.Ar link +hook, the node will replicate such frames to all types of hooks, +even if +.Ar uplink +hooks are connected later. .Sh CONTROL MESSAGES This node type supports the generic control messages, plus the following: diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index a21da545e210..ed08020ead70 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -105,7 +105,8 @@ struct ng_bridge_private { u_int numBuckets; /* num buckets in table */ u_int hashMask; /* numBuckets - 1 */ int numLinks; /* num connected links */ - int persistent; /* can exist w/o hooks */ + unsigned int persistent : 1, /* can exist w/o hooks */ + sendUnknown : 1;/* links receive unknowns by default */ struct callout timer; /* one second periodic timer */ }; typedef struct ng_bridge_private *priv_p; @@ -309,6 +310,7 @@ ng_bridge_constructor(node_p node) priv->conf.loopTimeout = DEFAULT_LOOP_TIMEOUT; priv->conf.maxStaleness = DEFAULT_MAX_STALENESS; priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE; + priv->sendUnknown = 1; /* classic bridge */ /* * This node has all kinds of stuff that could be screwed by SMP. @@ -371,9 +373,11 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if (isUplink) { link->learnMac = 0; link->sendUnknown = 1; + if (priv->numLinks == 0) /* if the first link is an uplink */ + priv->sendUnknown = 0; /* switch to restrictive mode */ } else { link->learnMac = 1; - link->sendUnknown = 1; + link->sendUnknown = priv->sendUnknown; } NG_HOOK_SET_PRIVATE(hook, link); From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:37: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 3798354D65C; Mon, 22 Feb 2021 08:37: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 4DkbD13pPGz4nsd; Mon, 22 Feb 2021 08:37: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 5872322A0C; Mon, 22 Feb 2021 08:37: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 11M8brGr095002; Mon, 22 Feb 2021 08:37:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8brPD095001; Mon, 22 Feb 2021 08:37:53 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:53 GMT Message-Id: <202102220837.11M8brPD095001@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: d7187b4b1c70 - stable/13 - netgraph/ng_bridge: switch stats to counter framework 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: d7187b4b1c70dd4e4065f564b6e35555c5b0e574 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, 22 Feb 2021 08:37:54 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d7187b4b1c70dd4e4065f564b6e35555c5b0e574 commit d7187b4b1c70dd4e4065f564b6e35555c5b0e574 Author: Lutz Donnerhacke AuthorDate: 2021-01-13 06:16:34 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:21:13 +0000 netgraph/ng_bridge: switch stats to counter framework This is the first patch of a series of necessary steps to make ng_bridge(4) multithreaded. Reviewed by: melifaro (network), afedorov Differential Revision: https://reviews.freebsd.org/D28125 (cherry picked from commit 66c72859f66dc6c852234589f3508ce5d36d0336) --- sys/netgraph/ng_bridge.c | 133 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 25 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index ed08020ead70..49d8aae87ccf 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -65,6 +65,8 @@ #include #include #include +#include +#include #include #include @@ -87,13 +89,31 @@ static MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", #define M_NETGRAPH_BRIDGE M_NETGRAPH #endif +/* Counter based stats */ +struct ng_bridge_link_kernel_stats { + counter_u64_t recvOctets; /* total octets rec'd on link */ + counter_u64_t recvPackets; /* total pkts rec'd on link */ + counter_u64_t recvMulticasts; /* multicast pkts rec'd on link */ + counter_u64_t recvBroadcasts; /* broadcast pkts rec'd on link */ + counter_u64_t recvUnknown; /* pkts rec'd with unknown dest addr */ + counter_u64_t recvRunts; /* pkts rec'd less than 14 bytes */ + counter_u64_t recvInvalid; /* pkts rec'd with bogus source addr */ + counter_u64_t xmitOctets; /* total octets xmit'd on link */ + counter_u64_t xmitPackets; /* total pkts xmit'd on link */ + counter_u64_t xmitMulticasts; /* multicast pkts xmit'd on link */ + counter_u64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */ + counter_u64_t loopDrops; /* pkts dropped due to loopback */ + counter_u64_t loopDetects; /* number of loop detections */ + counter_u64_t memoryFailures; /* times couldn't get mem or mbuf */ +}; + /* Per-link private data */ struct ng_bridge_link { hook_p hook; /* netgraph hook */ u_int16_t loopCount; /* loop ignore timer */ unsigned int learnMac : 1, /* autolearn macs */ sendUnknown : 1;/* send unknown macs out */ - struct ng_bridge_link_stats stats; /* link stats */ + struct ng_bridge_link_kernel_stats stats; /* link stats */ }; /* Per-node private data */ @@ -369,6 +389,21 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if (link == NULL) return (ENOMEM); + link->stats.recvOctets = counter_u64_alloc(M_WAITOK); + link->stats.recvPackets = counter_u64_alloc(M_WAITOK); + link->stats.recvMulticasts = counter_u64_alloc(M_WAITOK); + link->stats.recvBroadcasts = counter_u64_alloc(M_WAITOK); + link->stats.recvUnknown = counter_u64_alloc(M_WAITOK); + link->stats.recvRunts = counter_u64_alloc(M_WAITOK); + link->stats.recvInvalid = counter_u64_alloc(M_WAITOK); + link->stats.xmitOctets = counter_u64_alloc(M_WAITOK); + link->stats.xmitPackets = counter_u64_alloc(M_WAITOK); + link->stats.xmitMulticasts = counter_u64_alloc(M_WAITOK); + link->stats.xmitBroadcasts = counter_u64_alloc(M_WAITOK); + link->stats.loopDrops = counter_u64_alloc(M_WAITOK); + link->stats.loopDetects = counter_u64_alloc(M_WAITOK); + link->stats.memoryFailures = counter_u64_alloc(M_WAITOK); + link->hook = hook; if (isUplink) { link->learnMac = 0; @@ -388,14 +423,31 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) /* * Receive a control message */ +static void ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats * p) +{ + counter_u64_zero(p->recvOctets); + counter_u64_zero(p->recvPackets); + counter_u64_zero(p->recvMulticasts); + counter_u64_zero(p->recvBroadcasts); + counter_u64_zero(p->recvUnknown); + counter_u64_zero(p->recvRunts); + counter_u64_zero(p->recvInvalid); + counter_u64_zero(p->xmitOctets); + counter_u64_zero(p->xmitPackets); + counter_u64_zero(p->xmitMulticasts); + counter_u64_zero(p->xmitBroadcasts); + counter_u64_zero(p->loopDrops); + counter_u64_zero(p->loopDetects); + counter_u64_zero(p->memoryFailures); +}; + static int ng_bridge_reset_link(hook_p hook, void *arg __unused) { link_p priv = NG_HOOK_PRIVATE(hook); priv->loopCount = 0; - bzero(&priv->stats, sizeof(priv->stats)); - + ng_bridge_clear_link_stats(&priv->stats); return (1); } @@ -549,17 +601,34 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) /* Get/clear stats */ if (msg->header.cmd != NGM_BRIDGE_CLR_STATS) { + struct ng_bridge_link_stats *rs; + NG_MKRESPONSE(resp, msg, sizeof(link->stats), M_NOWAIT); if (resp == NULL) { error = ENOMEM; break; } - bcopy(&link->stats, - resp->data, sizeof(link->stats)); + rs = (struct ng_bridge_link_stats *)resp->data; +#define FETCH(x) rs->x = counter_u64_fetch(link->stats.x) + FETCH(recvOctets); + FETCH(recvPackets); + FETCH(recvMulticasts); + FETCH(recvBroadcasts); + FETCH(recvUnknown); + FETCH(recvRunts); + FETCH(recvInvalid); + FETCH(xmitOctets); + FETCH(xmitPackets); + FETCH(xmitMulticasts); + FETCH(xmitBroadcasts); + FETCH(loopDrops); + FETCH(loopDetects); + FETCH(memoryFailures); +#undef FETCH } if (msg->header.cmd != NGM_BRIDGE_GET_STATS) - bzero(&link->stats, sizeof(link->stats)); + ng_bridge_clear_link_stats(&link->stats); break; } case NGM_BRIDGE_GET_TABLE: @@ -654,22 +723,22 @@ ng_bridge_send_ctx(hook_p dst, void *arg) */ m2 = m_dup(ctx->m, M_NOWAIT); /* XXX m_copypacket() */ if (m2 == NULL) { - ctx->incoming->stats.memoryFailures++; + counter_u64_add(ctx->incoming->stats.memoryFailures, 1); ctx->error = ENOBUFS; return (0); /* abort loop */ } /* Update stats */ - destLink->stats.xmitPackets++; - destLink->stats.xmitOctets += m2->m_pkthdr.len; + counter_u64_add(destLink->stats.xmitPackets, 1); + counter_u64_add(destLink->stats.xmitOctets, m2->m_pkthdr.len); switch (ctx->manycast) { default: /* unknown unicast */ break; case 1: /* multicast */ - destLink->stats.xmitMulticasts++; + counter_u64_add(destLink->stats.xmitMulticasts, 1); break; case 2: /* broadcast */ - destLink->stats.xmitBroadcasts++; + counter_u64_add(destLink->stats.xmitBroadcasts, 1); break; } @@ -695,19 +764,19 @@ ng_bridge_rcvdata(hook_p hook, item_p item) ctx.incoming = NG_HOOK_PRIVATE(hook); /* Sanity check packet and pull up header */ if (ctx.m->m_pkthdr.len < ETHER_HDR_LEN) { - ctx.incoming->stats.recvRunts++; + counter_u64_add(ctx.incoming->stats.recvRunts, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (EINVAL); } if (ctx.m->m_len < ETHER_HDR_LEN && !(ctx.m = m_pullup(ctx.m, ETHER_HDR_LEN))) { - ctx.incoming->stats.memoryFailures++; + counter_u64_add(ctx.incoming->stats.memoryFailures, 1); NG_FREE_ITEM(item); return (ENOBUFS); } eh = mtod(ctx.m, struct ether_header *); if ((eh->ether_shost[0] & 1) != 0) { - ctx.incoming->stats.recvInvalid++; + counter_u64_add(ctx.incoming->stats.recvInvalid, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (EINVAL); @@ -715,21 +784,21 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Is link disabled due to a loopback condition? */ if (ctx.incoming->loopCount != 0) { - ctx.incoming->stats.loopDrops++; + counter_u64_add(ctx.incoming->stats.loopDrops, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ELOOP); /* XXX is this an appropriate error? */ } /* Update stats */ - ctx.incoming->stats.recvPackets++; - ctx.incoming->stats.recvOctets += ctx.m->m_pkthdr.len; + counter_u64_add(ctx.incoming->stats.recvPackets, 1); + counter_u64_add(ctx.incoming->stats.recvOctets, ctx.m->m_pkthdr.len); if ((ctx.manycast = (eh->ether_dhost[0] & 1)) != 0) { if (ETHER_EQUAL(eh->ether_dhost, ng_bridge_bcast_addr)) { - ctx.incoming->stats.recvBroadcasts++; + counter_u64_add(ctx.incoming->stats.recvBroadcasts, 1); ctx.manycast = 2; } else - ctx.incoming->stats.recvMulticasts++; + counter_u64_add(ctx.incoming->stats.recvMulticasts, 1); } /* Look up packet's source Ethernet address in hashtable */ @@ -763,13 +832,13 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Mark link as linka non grata */ ctx.incoming->loopCount = priv->conf.loopTimeout; - ctx.incoming->stats.loopDetects++; + counter_u64_add(ctx.incoming->stats.loopDetects, 1); /* Forget all hosts on this link */ ng_bridge_remove_hosts(priv, ctx.incoming); /* Drop packet */ - ctx.incoming->stats.loopDrops++; + counter_u64_add(ctx.incoming->stats.loopDrops, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ELOOP); /* XXX appropriate? */ @@ -781,7 +850,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } } else if (ctx.incoming->learnMac) { if (!ng_bridge_put(priv, eh->ether_shost, ctx.incoming)) { - ctx.incoming->stats.memoryFailures++; + counter_u64_add(ctx.incoming->stats.memoryFailures, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ENOMEM); @@ -812,14 +881,14 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } /* Deliver packet out the destination link */ - destLink->stats.xmitPackets++; - destLink->stats.xmitOctets += ctx.m->m_pkthdr.len; + counter_u64_add(destLink->stats.xmitPackets, 1); + counter_u64_add(destLink->stats.xmitOctets, ctx.m->m_pkthdr.len); NG_FWD_NEW_DATA(ctx.error, item, destLink->hook, ctx.m); return (ctx.error); } /* Destination host is not known */ - ctx.incoming->stats.recvUnknown++; + counter_u64_add(ctx.incoming->stats.recvUnknown, 1); } /* Distribute unknown, multicast, broadcast pkts to all other links */ @@ -879,6 +948,20 @@ ng_bridge_disconnect(hook_p hook) ng_bridge_remove_hosts(priv, link); /* Free associated link information */ + counter_u64_free(link->stats.recvOctets); + counter_u64_free(link->stats.recvPackets); + counter_u64_free(link->stats.recvMulticasts); + counter_u64_free(link->stats.recvBroadcasts); + counter_u64_free(link->stats.recvUnknown); + counter_u64_free(link->stats.recvRunts); + counter_u64_free(link->stats.recvInvalid); + counter_u64_free(link->stats.xmitOctets); + counter_u64_free(link->stats.xmitPackets); + counter_u64_free(link->stats.xmitMulticasts); + counter_u64_free(link->stats.xmitBroadcasts); + counter_u64_free(link->stats.loopDrops); + counter_u64_free(link->stats.loopDetects); + counter_u64_free(link->stats.memoryFailures); free(link, M_NETGRAPH_BRIDGE); priv->numLinks--; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:37:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B841054D980; Mon, 22 Feb 2021 08:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DkbD24vjHz4p8c; Mon, 22 Feb 2021 08:37:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5DD7622726; Mon, 22 Feb 2021 08:37:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11M8bsn6095020; Mon, 22 Feb 2021 08:37:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8bsLC095019; Mon, 22 Feb 2021 08:37:54 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:54 GMT Message-Id: <202102220837.11M8bsLC095019@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: 1e2c1b762275 - stable/13 - netgraph/ng_bridge: Make simple internal functions read-only 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: 1e2c1b762275513160f7305cfb72d1c35475c693 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, 22 Feb 2021 08:37:55 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=1e2c1b762275513160f7305cfb72d1c35475c693 commit 1e2c1b762275513160f7305cfb72d1c35475c693 Author: Lutz Donnerhacke AuthorDate: 2021-01-13 22:18:55 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:21:23 +0000 netgraph/ng_bridge: Make simple internal functions read-only The data path in netgraph is designed to work on an read only state of the whole netgraph network. Currently this is achived by convention, there is no technical enforcment. In the case of NETGRAPH_DEBUG all nodes can be annotated for debugging purposes, so the strict enforcment needs to be lifted for this purpose. This patch is part of a series to make ng_bridge multithreaded, which is done by rewrite the data path to operate on const. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D28141 (cherry picked from commit 6117aa58fa4f5891badf58b13c759976983f4f04) --- sys/netgraph/netgraph.h | 9 ++++++++- sys/netgraph/ng_base.c | 2 +- sys/netgraph/ng_bridge.c | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 7535472dc631..9cc298b38236 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -87,6 +87,13 @@ struct ng_item ; typedef struct ng_item *item_p; typedef struct ng_node *node_p; typedef struct ng_hook *hook_p; +typedef struct ng_item const *item_cp; +typedef struct ng_hook const *hook_cp; +#ifdef NETGRAPH_DEBUG +typedef struct ng_node *node_cp; /* annotated during debug */ +#else /* NETGRAPH_DEBUG */ +typedef struct ng_node const *node_cp; +#endif /* NETGRAPH_DEBUG */ /* node method definitions */ typedef int ng_constructor_t(node_p node); @@ -1139,7 +1146,7 @@ int ng_make_node_common(struct ng_type *typep, node_p *nodep); int ng_name_node(node_p node, const char *name); node_p ng_name2noderef(node_p node, const char *name); int ng_newtype(struct ng_type *tp); -ng_ID_t ng_node2ID(node_p node); +ng_ID_t ng_node2ID(node_cp node); item_p ng_package_data(struct mbuf *m, int flags); item_p ng_package_msg(struct ng_mesg *msg, int flags); item_p ng_package_msg_self(node_p here, hook_p hook, struct ng_mesg *msg); diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index dadf86eb8dde..6ab39421b255 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -836,7 +836,7 @@ ng_ID2noderef(ng_ID_t ID) } ng_ID_t -ng_node2ID(node_p node) +ng_node2ID(node_cp node) { return (node ? NG_NODE_ID(node) : 0); } diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 49d8aae87ccf..f177b9da340a 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -115,6 +115,7 @@ struct ng_bridge_link { sendUnknown : 1;/* send unknown macs out */ struct ng_bridge_link_kernel_stats stats; /* link stats */ }; +typedef struct ng_bridge_link const *link_cp; /* read only access */ /* Per-node private data */ struct ng_bridge_private { @@ -130,6 +131,7 @@ struct ng_bridge_private { struct callout timer; /* one second periodic timer */ }; typedef struct ng_bridge_private *priv_p; +typedef struct ng_bridge_private const *priv_cp; /* read only access */ /* Information about a host, stored in a hash table entry */ struct ng_bridge_hent { @@ -149,12 +151,12 @@ static ng_rcvdata_t ng_bridge_rcvdata; static ng_disconnect_t ng_bridge_disconnect; /* Other internal functions */ -static struct ng_bridge_host *ng_bridge_get(priv_p priv, const u_char *addr); +static struct ng_bridge_host *ng_bridge_get(priv_cp priv, const u_char *addr); static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link); static void ng_bridge_rehash(priv_p priv); static void ng_bridge_remove_hosts(priv_p priv, link_p link); static void ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2); -static const char *ng_bridge_nodename(node_p node); +static const char *ng_bridge_nodename(node_cp node); /* Ethernet broadcast */ static const u_char ng_bridge_bcast_addr[ETHER_ADDR_LEN] = @@ -989,7 +991,7 @@ ng_bridge_disconnect(hook_p hook) * Find a host entry in the table. */ static struct ng_bridge_host * -ng_bridge_get(priv_p priv, const u_char *addr) +ng_bridge_get(priv_cp priv, const u_char *addr) { const int bucket = HASH(addr, priv->hashMask); struct ng_bridge_hent *hent; @@ -1200,7 +1202,7 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2) * Return node's "name", even if it doesn't have one. */ static const char * -ng_bridge_nodename(node_p node) +ng_bridge_nodename(node_cp node) { static char name[NG_NODESIZ]; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:38: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 456C754DA01; Mon, 22 Feb 2021 08:38: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 4DkbD56Vcsz4p8m; Mon, 22 Feb 2021 08:37:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A453222821; Mon, 22 Feb 2021 08:37: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 11M8buKU095064; Mon, 22 Feb 2021 08:37:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8buO6095063; Mon, 22 Feb 2021 08:37:56 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:56 GMT Message-Id: <202102220837.11M8buO6095063@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: 88e916bff035 - stable/13 - netgraph/ng_bridge: Document staleness in multithreaded operation 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: 88e916bff0357ffd0a4b8844cc03c79fcaa2022c 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, 22 Feb 2021 08:38:01 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=88e916bff0357ffd0a4b8844cc03c79fcaa2022c commit 88e916bff0357ffd0a4b8844cc03c79fcaa2022c Author: Lutz Donnerhacke AuthorDate: 2021-02-09 11:32:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:21:55 +0000 netgraph/ng_bridge: Document staleness in multithreaded operation In the data path of ng_bridge(4), the only value of the host struct, which needs to be modified, is the staleness, which is reset every time a frame is received. It's save to leave the code as it is. This patch is part of a series to make ng_bridge(4) multithreaded. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28546 (cherry picked from commit 011b7317dbb5038a95b9b4fca050325a62f3991e) --- sys/netgraph/ng_bridge.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 316f9d4fab8c..b6f763dcb631 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -808,7 +808,10 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Look up packet's source Ethernet address in hashtable */ if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) { - /* Update time since last heard from this host */ + /* Update time since last heard from this host. + * This is safe without locking, because it's + * the only operation during shared access. + */ host->staleness = 0; /* Did host jump to a different link? */ From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:38: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 C231254D6CF; Mon, 22 Feb 2021 08:38: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 4DkbD65WkLz4p8x; Mon, 22 Feb 2021 08:37: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 BC89822822; Mon, 22 Feb 2021 08:37:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11M8bvVj095084; Mon, 22 Feb 2021 08:37:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8bvYt095083; Mon, 22 Feb 2021 08:37:57 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:57 GMT Message-Id: <202102220837.11M8bvYt095083@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: dcb4190179bd - stable/13 - netgraph/ng_bridge: Add counters for the first link, too 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: dcb4190179bd5588b28286828d65d50b9ba182cc 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, 22 Feb 2021 08:38:02 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=dcb4190179bd5588b28286828d65d50b9ba182cc commit dcb4190179bd5588b28286828d65d50b9ba182cc Author: Lutz Donnerhacke AuthorDate: 2021-02-10 10:47:38 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:22:03 +0000 netgraph/ng_bridge: Add counters for the first link, too For broadcast, multicast and unknown unicast, the replication loop sends a copy of the packet to each link, beside the first one. This special path is handled later, but the counters are not updated. Factor out the common send and count actions as a function. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28537 (cherry picked from commit 3c958f5fdfc01b7579ea0fbfc3f15f8a85bebee9) --- sys/netgraph/ng_bridge.c | 59 +++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index b6f763dcb631..3b00e4c03124 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -695,6 +695,41 @@ struct ng_bridge_send_ctx { int manycast, error; }; +/* + * Update stats and send out + */ +static inline int +ng_bridge_send_data(link_cp dst, int manycast, struct mbuf *m, item_p item) { + int error = 0; + size_t len = m->m_pkthdr.len; + + if(item != NULL) + NG_FWD_NEW_DATA(error, item, dst->hook, m); + else + NG_SEND_DATA_ONLY(error, dst->hook, m); + + if (error == 0) { + counter_u64_add(dst->stats.xmitPackets, 1); + counter_u64_add(dst->stats.xmitOctets, len); + switch (manycast) { + default: /* unknown unicast */ + break; + case 1: /* multicast */ + counter_u64_add(dst->stats.xmitMulticasts, 1); + break; + case 2: /* broadcast */ + counter_u64_add(dst->stats.xmitBroadcasts, 1); + break; + } + } + + return (error); +} + +/* + * Loop body for sending to multiple destinations + * return 0 to stop looping + */ static int ng_bridge_send_ctx(hook_p dst, void *arg) { @@ -733,22 +768,8 @@ ng_bridge_send_ctx(hook_p dst, void *arg) return (0); /* abort loop */ } - /* Update stats */ - counter_u64_add(destLink->stats.xmitPackets, 1); - counter_u64_add(destLink->stats.xmitOctets, m2->m_pkthdr.len); - switch (ctx->manycast) { - default: /* unknown unicast */ - break; - case 1: /* multicast */ - counter_u64_add(destLink->stats.xmitMulticasts, 1); - break; - case 2: /* broadcast */ - counter_u64_add(destLink->stats.xmitBroadcasts, 1); - break; - } - /* Send packet */ - NG_SEND_DATA_ONLY(error, destLink->hook, m2); + error = ng_bridge_send_data(destLink, ctx->manycast, m2, NULL); if(error) ctx->error = error; return (1); @@ -889,10 +910,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } /* Deliver packet out the destination link */ - counter_u64_add(destLink->stats.xmitPackets, 1); - counter_u64_add(destLink->stats.xmitOctets, ctx.m->m_pkthdr.len); - NG_FWD_NEW_DATA(ctx.error, item, destLink->hook, ctx.m); - return (ctx.error); + return (ng_bridge_send_data(destLink, ctx.manycast, ctx.m, item)); } /* Destination host is not known */ @@ -913,8 +931,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) * If we've sent all the others, send the original * on the first link we found. */ - NG_FWD_NEW_DATA(ctx.error, item, ctx.foundFirst->hook, ctx.m); - return (ctx.error); + return (ng_bridge_send_data(ctx.foundFirst, ctx.manycast, ctx.m, item)); } /* From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:37: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 0376B54D909; Mon, 22 Feb 2021 08:37: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 4DkbD40m2Sz4nyK; Mon, 22 Feb 2021 08:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8921322727; Mon, 22 Feb 2021 08:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11M8btOD095042; Mon, 22 Feb 2021 08:37:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8btBY095041; Mon, 22 Feb 2021 08:37:55 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:37:55 GMT Message-Id: <202102220837.11M8btBY095041@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: 0952f69003e8 - stable/13 - netgraph/ng_bridge: Merge internal structures 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: 0952f69003e8a264989f032413055370289fa685 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, 22 Feb 2021 08:37:58 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=0952f69003e8a264989f032413055370289fa685 commit 0952f69003e8a264989f032413055370289fa685 Author: Lutz Donnerhacke AuthorDate: 2021-02-08 21:36:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:21:49 +0000 netgraph/ng_bridge: Merge internal structures In a earlier version of ng_bridge(4) the exernal visible host entry structure was a strict subset of the internal one. So internal view was a direct annotation of the external structure. This strict inheritance was lost many versions ago. There is no need to encapsulate a part of the internal represntation as a separate structure. This patch is a preparation to make the internal structure read only in the data path in order to make ng_bridge(4) multithreaded. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28545 (cherry picked from commit ccf4cd2e7830394467d5f6cf546ab453f9657b69) --- sys/netgraph/ng_bridge.c | 85 +++++++++++++++++++++++++----------------------- sys/netgraph/ng_bridge.h | 7 ---- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index f177b9da340a..316f9d4fab8c 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -134,13 +134,16 @@ typedef struct ng_bridge_private *priv_p; typedef struct ng_bridge_private const *priv_cp; /* read only access */ /* Information about a host, stored in a hash table entry */ -struct ng_bridge_hent { - struct ng_bridge_host host; /* actual host info */ - SLIST_ENTRY(ng_bridge_hent) next; /* next entry in bucket */ +struct ng_bridge_host { + u_char addr[6]; /* ethernet address */ + link_p link; /* link where addr can be found */ + u_int16_t age; /* seconds ago entry was created */ + u_int16_t staleness; /* seconds ago host last heard from */ + SLIST_ENTRY(ng_bridge_host) next; /* next entry in bucket */ }; /* Hash table bucket declaration */ -SLIST_HEAD(ng_bridge_bucket, ng_bridge_hent); +SLIST_HEAD(ng_bridge_bucket, ng_bridge_host); /* Netgraph node methods */ static ng_constructor_t ng_bridge_constructor; @@ -636,7 +639,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) case NGM_BRIDGE_GET_TABLE: { struct ng_bridge_host_ary *ary; - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; int i = 0, bucket; NG_MKRESPONSE(resp, msg, sizeof(*ary) @@ -648,14 +651,14 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) ary = (struct ng_bridge_host_ary *)resp->data; ary->numHosts = priv->numHosts; for (bucket = 0; bucket < priv->numBuckets; bucket++) { - SLIST_FOREACH(hent, &priv->tab[bucket], next) { + SLIST_FOREACH(host, &priv->tab[bucket], next) { memcpy(ary->hosts[i].addr, - hent->host.addr, + host->addr, sizeof(ary->hosts[i].addr)); - ary->hosts[i].age = hent->host.age; - ary->hosts[i].staleness = hent->host.staleness; + ary->hosts[i].age = host->age; + ary->hosts[i].staleness = host->staleness; strncpy(ary->hosts[i].hook, - NG_HOOK_NAME(hent->host.link->hook), + NG_HOOK_NAME(host->link->hook), sizeof(ary->hosts[i].hook)); i++; } @@ -994,11 +997,11 @@ static struct ng_bridge_host * ng_bridge_get(priv_cp priv, const u_char *addr) { const int bucket = HASH(addr, priv->hashMask); - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; - SLIST_FOREACH(hent, &priv->tab[bucket], next) { - if (ETHER_EQUAL(hent->host.addr, addr)) - return (&hent->host); + SLIST_FOREACH(host, &priv->tab[bucket], next) { + if (ETHER_EQUAL(host->addr, addr)) + return (host); } return (NULL); } @@ -1012,27 +1015,27 @@ static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link) { const int bucket = HASH(addr, priv->hashMask); - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; #ifdef INVARIANTS /* Assert that entry does not already exist in hashtable */ - SLIST_FOREACH(hent, &priv->tab[bucket], next) { - KASSERT(!ETHER_EQUAL(hent->host.addr, addr), + SLIST_FOREACH(host, &priv->tab[bucket], next) { + KASSERT(!ETHER_EQUAL(host->addr, addr), ("%s: entry %6D exists in table", __func__, addr, ":")); } #endif /* Allocate and initialize new hashtable entry */ - hent = malloc(sizeof(*hent), M_NETGRAPH_BRIDGE, M_NOWAIT); - if (hent == NULL) + host = malloc(sizeof(*host), M_NETGRAPH_BRIDGE, M_NOWAIT); + if (host == NULL) return (0); - bcopy(addr, hent->host.addr, ETHER_ADDR_LEN); - hent->host.link = link; - hent->host.staleness = 0; - hent->host.age = 0; + bcopy(addr, host->addr, ETHER_ADDR_LEN); + host->link = link; + host->staleness = 0; + host->age = 0; /* Add new element to hash bucket */ - SLIST_INSERT_HEAD(&priv->tab[bucket], hent, next); + SLIST_INSERT_HEAD(&priv->tab[bucket], host, next); priv->numHosts++; /* Resize table if necessary */ @@ -1077,12 +1080,12 @@ ng_bridge_rehash(priv_p priv) struct ng_bridge_bucket *const oldList = &priv->tab[oldBucket]; while (!SLIST_EMPTY(oldList)) { - struct ng_bridge_hent *const hent + struct ng_bridge_host *const host = SLIST_FIRST(oldList); SLIST_REMOVE_HEAD(oldList, next); - newBucket = HASH(hent->host.addr, newMask); - SLIST_INSERT_HEAD(&newTab[newBucket], hent, next); + newBucket = HASH(host->addr, newMask); + SLIST_INSERT_HEAD(&newTab[newBucket], host, next); } } @@ -1113,17 +1116,17 @@ ng_bridge_remove_hosts(priv_p priv, link_p link) int bucket; for (bucket = 0; bucket < priv->numBuckets; bucket++) { - struct ng_bridge_hent **hptr = &SLIST_FIRST(&priv->tab[bucket]); + struct ng_bridge_host **hptr = &SLIST_FIRST(&priv->tab[bucket]); while (*hptr != NULL) { - struct ng_bridge_hent *const hent = *hptr; + struct ng_bridge_host *const host = *hptr; - if (link == NULL || hent->host.link == link) { - *hptr = SLIST_NEXT(hent, next); - free(hent, M_NETGRAPH_BRIDGE); + if (link == NULL || host->link == link) { + *hptr = SLIST_NEXT(host, next); + free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else - hptr = &SLIST_NEXT(hent, next); + hptr = &SLIST_NEXT(host, next); } } } @@ -1164,20 +1167,20 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2) /* Update host time counters and remove stale entries */ for (bucket = 0; bucket < priv->numBuckets; bucket++) { - struct ng_bridge_hent **hptr = &SLIST_FIRST(&priv->tab[bucket]); + struct ng_bridge_host **hptr = &SLIST_FIRST(&priv->tab[bucket]); while (*hptr != NULL) { - struct ng_bridge_hent *const hent = *hptr; + struct ng_bridge_host *const host = *hptr; /* Remove hosts we haven't heard from in a while */ - if (++hent->host.staleness >= priv->conf.maxStaleness) { - *hptr = SLIST_NEXT(hent, next); - free(hent, M_NETGRAPH_BRIDGE); + if (++host->staleness >= priv->conf.maxStaleness) { + *hptr = SLIST_NEXT(host, next); + free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else { - if (hent->host.age < 0xffff) - hent->host.age++; - hptr = &SLIST_NEXT(hent, next); + if (host->age < 0xffff) + host->age++; + hptr = &SLIST_NEXT(host, next); counter++; } } diff --git a/sys/netgraph/ng_bridge.h b/sys/netgraph/ng_bridge.h index ec237eb19cac..f8eb0ca8a7da 100644 --- a/sys/netgraph/ng_bridge.h +++ b/sys/netgraph/ng_bridge.h @@ -130,13 +130,6 @@ struct ng_bridge_link_stats { struct ng_bridge_link; typedef struct ng_bridge_link *link_p; -/* Structure describing a single host */ -struct ng_bridge_host { - u_char addr[6]; /* ethernet address */ - link_p link; /* link where addr can be found */ - u_int16_t age; /* seconds ago entry was created */ - u_int16_t staleness; /* seconds ago host last heard from */ -}; #ifdef NGM_BRIDGE_TABLE_ABI struct ng_bridge_host_tbl { From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 08:41:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E0D3854DBCF; Mon, 22 Feb 2021 08:41:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DkbJX64fzz4q11; Mon, 22 Feb 2021 08:41:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3734228AE; Mon, 22 Feb 2021 08:41: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 11M8fmuK007169; Mon, 22 Feb 2021 08:41:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11M8fmlP007168; Mon, 22 Feb 2021 08:41:48 GMT (envelope-from git) Date: Mon, 22 Feb 2021 08:41:48 GMT Message-Id: <202102220841.11M8fmlP007168@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: 511690b108f8 - stable/13 - ng_bridge.4: Use more suitable mandoc macros 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: 511690b108f8f4ac65ee297786e20a0f134b0185 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, 22 Feb 2021 08:41:48 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=511690b108f8f4ac65ee297786e20a0f134b0185 commit 511690b108f8f4ac65ee297786e20a0f134b0185 Author: Lutz Donnerhacke AuthorDate: 2021-02-05 21:24:06 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-22 08:40:40 +0000 ng_bridge.4: Use more suitable mandoc macros yuripv@ suggested to replace inappropriate macros by better ones. Reviewed by: philip Differential Revision: https://reviews.freebsd.org/D28510 (cherry picked from commit 689561d4032233bc171cff30d6756c3cf3b22720) --- share/man/man4/ng_bridge.4 | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index 1451773711e9..be128d62c938 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -79,35 +79,35 @@ mechanism on a per-link basis is not yet implemented. This node type supports an unlimited number of hooks. Each connected hook represents a bridged link. The hooks are named -.Dv link0 , -.Dv link1 , +.Ar link0 , +.Ar link1 , etc. Typically these hooks are connected to the -.Dv lower +.Ar lower hooks of one or more .Xr ng_ether 4 nodes. To connect the host machine to a bridged network, simply connect the -.Dv upper +.Ar upper hook of an .Xr ng_ether 4 node to the bridge node. .Pp Instead of naming a hook -.Dv linkX +.Ar linkX the hook might be also named -.Dv uplinkX . +.Ar uplinkX . The node does not learn MAC addresses on uplink hooks, which keeps the internal address table small. This way it is desirable to connect the -.Dv lower +.Ar lower hook of an .Xr ng_ether 4 node to an -.Dv uplink +.Ar uplink hook of the bridge, and ignore the complexity of the outside world. Frames with unknown MACs are always sent out to -.Dv uplink +.Ar uplink hooks, so no functionality is lost. .Pp Frames with unknown destination MAC addresses are replicated to any @@ -129,10 +129,10 @@ hooks are connected later. This node type supports the generic control messages, plus the following: .Bl -tag -width foo -.It Dv NGM_BRIDGE_SET_CONFIG Pq Ic setconfig +.It Dv NGM_BRIDGE_SET_CONFIG Pq Ar setconfig Set the node configuration. This command takes a -.Dv "struct ng_bridge_config" +.Vt "struct ng_bridge_config" as an argument: .Bd -literal -offset 0n /* Node configuration structure */ @@ -145,37 +145,37 @@ struct ng_bridge_config { .Ed .Pp The -.Dv debugLevel +.Va debugLevel field sets the debug level on the node. At level of 2 or greater, detected loops are logged. The default level is 1. .Pp The -.Dv loopTimeout +.Va loopTimeout determines how long (in seconds) a looped link is muted. The default is 60 seconds. The -.Dv maxStaleness +.Va maxStaleness parameter determines how long a period of inactivity before a host's entry is forgotten. The default is 15 minutes. The -.Dv minStableAge +.Va minStableAge determines how quickly a host must jump from one link to another before we declare a loopback condition. The default is one second. -.It Dv NGM_BRIDGE_GET_CONFIG Pq Ic getconfig +.It Dv NGM_BRIDGE_GET_CONFIG Pq Ar getconfig Returns the current configuration as a -.Dv "struct ng_bridge_config" . -.It Dv NGM_BRIDGE_RESET Pq Ic reset +.Vt "struct ng_bridge_config" . +.It Dv NGM_BRIDGE_RESET Pq Ar reset Causes the node to forget all hosts and unmute all links. The node configuration is not changed. -.It Dv NGM_BRIDGE_GET_STATS Pq Ic getstats +.It Dv NGM_BRIDGE_GET_STATS Pq Ar getstats This command takes a four byte link number as an argument and returns a -.Dv "struct ng_bridge_link_stats" +.Vt "struct ng_bridge_link_stats" containing statistics for the corresponding -.Dv link , +.Ar link , which must be currently connected: .Bd -literal -offset 0n /* Statistics structure (one for each link) */ @@ -198,21 +198,21 @@ struct ng_bridge_link_stats { .Ed .Pp Negative numbers refer to the -.Dv uplink +.Ar uplink hooks. So querying for -7 will get the statistics for hook -.Dv uplink7 . -.It Dv NGM_BRIDGE_CLR_STATS Pq Ic clrstats +.Ar uplink7 . +.It Dv NGM_BRIDGE_CLR_STATS Pq Ar clrstats This command takes a four byte link number as an argument and clears the statistics for that link. -.It Dv NGM_BRIDGE_GETCLR_STATS Pq Ic getclrstats +.It Dv NGM_BRIDGE_GETCLR_STATS Pq Ar getclrstats Same as .Dv NGM_BRIDGE_GET_STATS , but also atomically clears the statistics as well. -.It Dv NGM_BRIDGE_GET_TABLE Pq Ic gettable +.It Dv NGM_BRIDGE_GET_TABLE Pq Ar gettable Returns the current host mapping table used to direct packets, in a -.Dv "struct ng_bridge_host_ary" . -.It Dv NGM_BRIDGE_SET_PERSISTENT Pq Ic setpersistent +.Vt "struct ng_bridge_host_ary" . +.It Dv NGM_BRIDGE_SET_PERSISTENT Pq Ar setpersistent This command sets the persistent flag on the node, and takes no arguments. .El .Sh SHUTDOWN From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 11:51: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 AA50A551F82; Mon, 22 Feb 2021 11:51: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 4DkgWH49Kcz3GxM; Mon, 22 Feb 2021 11:51: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 81F1024D72; Mon, 22 Feb 2021 11:51: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 11MBpN2j054666; Mon, 22 Feb 2021 11:51:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MBpNqU054665; Mon, 22 Feb 2021 11:51:23 GMT (envelope-from git) Date: Mon, 22 Feb 2021 11:51:23 GMT Message-Id: <202102221151.11MBpNqU054665@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Stefan Eßer Subject: git: 4aa71da8dc00 - stable/13 - bc: Upgrade to version 3.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4aa71da8dc004aa5027836259433e5bff3cd9104 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, 22 Feb 2021 11:51:23 -0000 The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=4aa71da8dc004aa5027836259433e5bff3cd9104 commit 4aa71da8dc004aa5027836259433e5bff3cd9104 Author: Stefan Eßer AuthorDate: 2021-02-17 21:56:16 +0000 Commit: Stefan Eßer CommitDate: 2021-02-22 11:50:32 +0000 bc: Upgrade to version 3.3.0 This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS: Use of these options on the command line makes bc exit after executing the given commands. These options will not cause bc to exit when passed via the environment (but EOF in STDIN or -e or -f on the command line will make bc exit as before). The same applies to DC_ENV_ARGS with regard to the dc program. (cherry picked from commit 9a995fe186257315e7b3d01e24c55d86bb18fd32) --- contrib/bc/Makefile.in | 2 +- contrib/bc/NEWS.md | 20 ++++++++++++++++++++ contrib/bc/README.md | 2 +- contrib/bc/configure.sh | 7 +------ contrib/bc/include/args.h | 2 +- contrib/bc/include/status.h | 10 +++++++--- contrib/bc/include/vm.h | 1 + contrib/bc/manuals/bc.1.md.in | 23 ++++++++++++++++------- contrib/bc/manuals/bc/A.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/A.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/E.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/E.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EH.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EH.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EHN.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EHN.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EHNP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EHNP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EHP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EHP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EN.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EN.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/ENP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/ENP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/EP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/EP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/H.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/H.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/HN.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/HN.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/HNP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/HNP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/HP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/HP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/N.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/N.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/NP.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/NP.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bc/P.1 | 25 +++++++++++++++++++------ contrib/bc/manuals/bc/P.1.md | 23 ++++++++++++++++------- contrib/bc/manuals/bcl.3 | 2 +- contrib/bc/manuals/build.md | 16 ++++++++++++++++ contrib/bc/manuals/dc.1.md.in | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/A.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/A.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/E.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/E.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EH.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EH.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EHN.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EHN.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EHNP.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EHNP.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EHP.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EHP.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EN.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EN.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/ENP.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/ENP.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/EP.1 | 27 ++++++++++++++++++++------- contrib/bc/manuals/dc/EP.1.md | 25 +++++++++++++++++-------- contrib/bc/manuals/dc/H.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/H.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/HN.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/HN.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/HNP.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/HNP.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/HP.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/HP.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/N.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/N.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/NP.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/NP.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/dc/P.1 | 29 +++++++++++++++++++++-------- contrib/bc/manuals/dc/P.1.md | 27 ++++++++++++++++++--------- contrib/bc/manuals/header_bc.txt | 2 +- contrib/bc/manuals/header_bcl.txt | 2 +- contrib/bc/manuals/header_dc.txt | 2 +- contrib/bc/release.sh | 2 +- contrib/bc/src/args.c | 4 +++- contrib/bc/src/vm.c | 6 +++--- contrib/bc/tests/script.sh | 2 +- 82 files changed, 1262 insertions(+), 502 deletions(-) diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index 8ae982bd99fe..dbb5debd44cc 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -29,7 +29,7 @@ # .POSIX: -VERSION = 3.2.6 +VERSION = 3.3.0 SRC = %%SRC%% OBJ = %%OBJ%% diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index 5982defb754c..6a8899200f4a 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,25 @@ # News +## 3.3.0 + +This is a production release that changes one behavior and fixes documentation +bugs. + +The changed behavior is the treatment of `-e` and `-f` when given through +`BC_ENV_ARGS` or `DC_ENV_ARGS`. Now `bc` and `dc` do not exit when those options +(or their equivalents) are given through those environment variables. However, +`bc` and `dc` still exit when they or their equivalents are given on the +command-line. + +## 3.2.7 + +This is a production release that removes a small non-portable shell operation +in `configure.sh`. This problem was only noticed on OpenBSD, not FreeBSD or +Linux. + +Non-OpenBSD users do ***NOT*** need to upgrade, although NetBSD users may also +need to upgrade. + ## 3.2.6 This is a production release that fixes the build on FreeBSD. diff --git a/contrib/bc/README.md b/contrib/bc/README.md index beda88d23f90..2f95e16ed246 100644 --- a/contrib/bc/README.md +++ b/contrib/bc/README.md @@ -342,7 +342,7 @@ Folders: [20]: https://git.yzena.com/gavin/bc [21]: https://gavinhoward.com/2020/04/i-am-moving-away-from-github/ [22]: https://www.deepl.com/translator -[23]: https://svnweb.freebsd.org/base/head/contrib/bc/ +[23]: https://cgit.freebsd.org/src/tree/contrib/bc [24]: https://bugs.freebsd.org/ [25]: https://reviews.freebsd.org/ [26]: ./manuals/bcl.3.md diff --git a/contrib/bc/configure.sh b/contrib/bc/configure.sh index ae1675cde97d..310c26882906 100755 --- a/contrib/bc/configure.sh +++ b/contrib/bc/configure.sh @@ -253,7 +253,7 @@ replace_ext() { _replace_ext_ext1="$2" _replace_ext_ext2="$3" - _replace_ext_result=${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2 + _replace_ext_result="${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2" printf '%s\n' "$_replace_ext_result" } @@ -1199,17 +1199,12 @@ SRC_TARGETS="" src_files=$(find_src_files $unneeded) -temp_ifs="$IFS" -IFS=$'\n' - for f in $src_files; do o=$(replace_ext "$f" "c" "o") SRC_TARGETS=$(printf '%s\n\n%s: %s %s\n\t$(CC) $(CFLAGS) -o %s -c %s\n' \ "$SRC_TARGETS" "$o" "$headers" "$f" "$o" "$f") done -IFS="$temp_ifs" - contents=$(replace "$contents" "HEADERS" "$headers") contents=$(replace "$contents" "BC_ENABLED" "$bc") diff --git a/contrib/bc/include/args.h b/contrib/bc/include/args.h index 6b68ed300440..d53785067237 100644 --- a/contrib/bc/include/args.h +++ b/contrib/bc/include/args.h @@ -39,7 +39,7 @@ #include #include -void bc_args(int argc, char *argv[]); +void bc_args(int argc, char *argv[], bool exit_exprs); extern const char* const bc_args_env_name; diff --git a/contrib/bc/include/status.h b/contrib/bc/include/status.h index 3fa844485690..cf41a3ce4670 100644 --- a/contrib/bc/include/status.h +++ b/contrib/bc/include/status.h @@ -176,11 +176,15 @@ typedef enum BcErr { #endif // __STDC_VERSION__ #if defined(__clang__) || defined(__GNUC__) -#if defined(__has_attribute) && __has_attribute(fallthrough) +#if defined(__has_attribute) +#if __has_attribute(fallthrough) #define BC_FALLTHROUGH __attribute__((fallthrough)); -#else // defined(__has_attribute) && __has_attribute(fallthrough) +#else // __has_attribute(fallthrough) #define BC_FALLTHROUGH -#endif // defined(__has_attribute) && __has_attribute(fallthrough) +#endif // __has_attribute(fallthrough) +#else // defined(__has_attribute) +#define BC_FALLTHROUGH +#endif // defined(__has_attribute) #else // defined(__clang__) || defined(__GNUC__) #define BC_FALLTHROUGH #endif // defined(__clang__) || defined(__GNUC__) diff --git a/contrib/bc/include/vm.h b/contrib/bc/include/vm.h index 8b0babff4d81..80a060edd42f 100644 --- a/contrib/bc/include/vm.h +++ b/contrib/bc/include/vm.h @@ -356,6 +356,7 @@ typedef struct BcVm { uint16_t line_len; bool no_exit_exprs; + bool exit_exprs; bool eof; #endif // !BC_ENABLE_LIBRARY diff --git a/contrib/bc/manuals/bc.1.md.in b/contrib/bc/manuals/bc.1.md.in index 624ea3fb54ab..1ce83b8237cd 100644 --- a/contrib/bc/manuals/bc.1.md.in +++ b/contrib/bc/manuals/bc.1.md.in @@ -229,10 +229,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -242,8 +245,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -251,7 +258,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/A.1 b/contrib/bc/manuals/bc/A.1 index da35e8c7eaee..d1e80769c855 100644 --- a/contrib/bc/manuals/bc/A.1 +++ b/contrib/bc/manuals/bc/A.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -230,12 +230,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -247,9 +251,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -258,6 +268,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/A.1.md b/contrib/bc/manuals/bc/A.1.md index 293a21ad0259..0cf7a4a0d70e 100644 --- a/contrib/bc/manuals/bc/A.1.md +++ b/contrib/bc/manuals/bc/A.1.md @@ -187,10 +187,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -200,8 +203,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -209,7 +216,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/E.1 b/contrib/bc/manuals/bc/E.1 index 02a56e6c653c..597cde782788 100644 --- a/contrib/bc/manuals/bc/E.1 +++ b/contrib/bc/manuals/bc/E.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -192,12 +192,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -209,9 +213,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -220,6 +230,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/E.1.md b/contrib/bc/manuals/bc/E.1.md index 7cbc1a56548a..864cf32068bf 100644 --- a/contrib/bc/manuals/bc/E.1.md +++ b/contrib/bc/manuals/bc/E.1.md @@ -171,10 +171,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -184,8 +187,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -193,7 +200,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/EH.1 b/contrib/bc/manuals/bc/EH.1 index 8cb2a3bc8335..dca77a99162e 100644 --- a/contrib/bc/manuals/bc/EH.1 +++ b/contrib/bc/manuals/bc/EH.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -189,12 +189,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -206,9 +210,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -217,6 +227,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/EH.1.md b/contrib/bc/manuals/bc/EH.1.md index 351882878cd3..c1e324ab6ebc 100644 --- a/contrib/bc/manuals/bc/EH.1.md +++ b/contrib/bc/manuals/bc/EH.1.md @@ -168,10 +168,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -181,8 +184,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -190,7 +197,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/EHN.1 b/contrib/bc/manuals/bc/EHN.1 index f751f9d31beb..6b208ade85fd 100644 --- a/contrib/bc/manuals/bc/EHN.1 +++ b/contrib/bc/manuals/bc/EHN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -189,12 +189,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -206,9 +210,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -217,6 +227,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/EHN.1.md b/contrib/bc/manuals/bc/EHN.1.md index dfe1c401970f..4ee01a4bbcc8 100644 --- a/contrib/bc/manuals/bc/EHN.1.md +++ b/contrib/bc/manuals/bc/EHN.1.md @@ -168,10 +168,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -181,8 +184,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -190,7 +197,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/EHNP.1 b/contrib/bc/manuals/bc/EHNP.1 index e25cd1a7da42..7bd46f38e104 100644 --- a/contrib/bc/manuals/bc/EHNP.1 +++ b/contrib/bc/manuals/bc/EHNP.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -184,12 +184,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -201,9 +205,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -212,6 +222,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/EHNP.1.md b/contrib/bc/manuals/bc/EHNP.1.md index e55673769736..8aca89e6f7b0 100644 --- a/contrib/bc/manuals/bc/EHNP.1.md +++ b/contrib/bc/manuals/bc/EHNP.1.md @@ -164,10 +164,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -177,8 +180,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -186,7 +193,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/EHP.1 b/contrib/bc/manuals/bc/EHP.1 index 7f35d1a1be7f..31c02f1b9591 100644 --- a/contrib/bc/manuals/bc/EHP.1 +++ b/contrib/bc/manuals/bc/EHP.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -184,12 +184,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -201,9 +205,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to \f[B]-f\f[R] or \f[B]\[en]file\f[R]. +However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -212,6 +222,9 @@ All long options are \f[B]non-portable extensions\f[R]. .SH STDOUT .PP Any non-error output is written to \f[B]stdout\f[R]. +In addition, if history (see the \f[B]HISTORY\f[R] section) and the +prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output +to \f[B]stdout\f[R]. .PP \f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot diff --git a/contrib/bc/manuals/bc/EHP.1.md b/contrib/bc/manuals/bc/EHP.1.md index 11050003420f..2c9ab3909dd6 100644 --- a/contrib/bc/manuals/bc/EHP.1.md +++ b/contrib/bc/manuals/bc/EHP.1.md @@ -164,10 +164,13 @@ The following are the options that bc(1) accepts. evaluated in the order given. This means that if a file is given before an expression, the file is read in and evaluated first. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. - However, if any other **-e**, **--expression**, **-f**, or **--file** - arguments are given after that, bc(1) will give a fatal error and exit. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**, whether on the + command-line or in **BC_ENV_ARGS**. However, if any other **-e**, + **--expression**, **-f**, or **--file** arguments are given after **-f-** or + equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -177,8 +180,12 @@ The following are the options that bc(1) accepts. through **stdin**. If expressions are also given (see above), the expressions are evaluated in the order given. - After processing all expressions and files, bc(1) will exit, unless **-** - (**stdin**) was given as an argument at least once to **-f** or **--file**. + If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**, + see the **ENVIRONMENT VARIABLES** section), then after processing all + expressions and files, bc(1) will exit, unless **-** (**stdin**) was given + as an argument at least once to **-f** or **--file**. However, if any other + **-e**, **--expression**, **-f**, or **--file** arguments are given after + **-f-** or equivalent is given, bc(1) will give a fatal error and exit. This is a **non-portable extension**. @@ -186,7 +193,9 @@ All long options are **non-portable extensions**. # STDOUT -Any non-error output is written to **stdout**. +Any non-error output is written to **stdout**. In addition, if history (see the +**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled, +both are output to **stdout**. **Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if diff --git a/contrib/bc/manuals/bc/EN.1 b/contrib/bc/manuals/bc/EN.1 index c8e3a327b2f8..faa6bf488e28 100644 --- a/contrib/bc/manuals/bc/EN.1 +++ b/contrib/bc/manuals/bc/EN.1 @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual" +.TH "BC" "1" "February 2021" "Gavin D. Howard" "General Commands Manual" .SH NAME .PP bc - arbitrary-precision decimal arithmetic language and calculator @@ -192,12 +192,16 @@ This means that if a file is given before an expression, the file is read in and evaluated first. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to -\f[B]-f\f[R] or \f[B]\[en]file\f[R]. +\f[B]-f\f[R] or \f[B]\[en]file\f[R], whether on the command-line or in +\f[B]BC_ENV_ARGS\f[R]. However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R], -\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that, -bc(1) will give a fatal error and exit. +\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after +\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and +exit. .PP This is a \f[B]non-portable extension\f[R]. .RE @@ -209,9 +213,15 @@ If expressions are also given (see above), the expressions are evaluated in the order given. .RS .PP -After processing all expressions and files, bc(1) will exit, unless +If this option is given on the command-line (i.e., not in +\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section), +then after processing all expressions and files, bc(1) will exit, unless \f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to *** 3436 LINES SKIPPED *** From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 16:28: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 ECB9E54431D; Mon, 22 Feb 2021 16:28: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 4Dknfh6RbMz3sNs; Mon, 22 Feb 2021 16:28: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 CFFB98BD; Mon, 22 Feb 2021 16:28: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 11MGSCiR015836; Mon, 22 Feb 2021 16:28:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MGSC0t015835; Mon, 22 Feb 2021 16:28:12 GMT (envelope-from git) Date: Mon, 22 Feb 2021 16:28:12 GMT Message-Id: <202102221628.11MGSC0t015835@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: e540e45097e5 - stable/13 - MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e540e45097e54aaae553ea12468801ceab473d47 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, 22 Feb 2021 16:28:13 -0000 The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=e540e45097e54aaae553ea12468801ceab473d47 commit e540e45097e54aaae553ea12468801ceab473d47 Author: Michal Krawczyk AuthorDate: 2021-02-18 09:00:58 +0000 Commit: Marcin Wojtas CommitDate: 2021-02-22 15:59:42 +0000 MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table In the new ENA-based instances like c6gn, the vector table moved to a new PCIe bar - BAR1. Previously it was always located on the BAR0, so the resources were already allocated together with the registers. As the FreeBSD isn't doing any resource allocation behind the scenes, the driver is responsible to allocate them explicitly, before other parts of the OS (like the PCI code allocating MSIx) will be able to access them. To determine dynamically BAR on which the MSIx vector table is present the pci_msix_table_bar() is being used and the new BAR is allocated if needed. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc (cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1) --- sys/dev/ena/ena.c | 21 +++++++++++++++++++++ sys/dev/ena/ena.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index b0e05f23b563..680eb0e9d049 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -299,6 +299,11 @@ ena_free_pci_resources(struct ena_adapter *adapter) bus_release_resource(pdev, SYS_RES_MEMORY, PCIR_BAR(ENA_REG_BAR), adapter->registers); } + + if (adapter->msix != NULL) { + bus_release_resource(pdev, SYS_RES_MEMORY, + adapter->msix_rid, adapter->msix); + } } static int @@ -3532,6 +3537,7 @@ ena_attach(device_t pdev) struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; + int msix_rid; int rid, rc; adapter = device_get_softc(pdev); @@ -3570,6 +3576,20 @@ ena_attach(device_t pdev) goto err_dev_free; } + /* MSIx vector table may reside on BAR0 with registers or on BAR1. */ + msix_rid = pci_msix_table_bar(pdev); + if (msix_rid != rid) { + adapter->msix = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, + &msix_rid, RF_ACTIVE); + if (unlikely(adapter->msix == NULL)) { + device_printf(pdev, + "unable to allocate bus resource: msix!\n"); + rc = ENOMEM; + goto err_pci_free; + } + adapter->msix_rid = msix_rid; + } + ena_dev->bus = malloc(sizeof(struct ena_bus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -3735,6 +3755,7 @@ err_com_free: ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: free(ena_dev->bus, M_DEVBUF); +err_pci_free: ena_free_pci_resources(adapter); err_dev_free: free(ena_dev, M_DEVBUF); diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index 28da047e2e1b..f3e92f31341a 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -41,7 +41,7 @@ #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 3 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -398,6 +398,8 @@ struct ena_adapter { /* OS resources */ struct resource *memory; struct resource *registers; + struct resource *msix; + int msix_rid; struct sx global_lock; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 16:30: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 091BA5445AC; Mon, 22 Feb 2021 16:30: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 4Dknhz6sgyz3sgV; Mon, 22 Feb 2021 16:30: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 DE7A5953; Mon, 22 Feb 2021 16:30: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 11MGUBcl019533; Mon, 22 Feb 2021 16:30:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MGUBqS019527; Mon, 22 Feb 2021 16:30:11 GMT (envelope-from git) Date: Mon, 22 Feb 2021 16:30:11 GMT Message-Id: <202102221630.11MGUBqS019527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 5de955fe436a - releng/13.0 - MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 5de955fe436a208f93359e84a059b74bb0169ce6 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, 22 Feb 2021 16:30:12 -0000 The branch releng/13.0 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=5de955fe436a208f93359e84a059b74bb0169ce6 commit 5de955fe436a208f93359e84a059b74bb0169ce6 Author: Michal Krawczyk AuthorDate: 2021-02-18 09:00:58 +0000 Commit: Marcin Wojtas CommitDate: 2021-02-22 16:29:40 +0000 MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table In the new ENA-based instances like c6gn, the vector table moved to a new PCIe bar - BAR1. Previously it was always located on the BAR0, so the resources were already allocated together with the registers. As the FreeBSD isn't doing any resource allocation behind the scenes, the driver is responsible to allocate them explicitly, before other parts of the OS (like the PCI code allocating MSIx) will be able to access them. To determine dynamically BAR on which the MSIx vector table is present the pci_msix_table_bar() is being used and the new BAR is allocated if needed. Approved by: re (gjb) Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc (cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1) (cherry picked from commit e540e45097e54aaae553ea12468801ceab473d47) --- sys/dev/ena/ena.c | 21 +++++++++++++++++++++ sys/dev/ena/ena.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index b0e05f23b563..680eb0e9d049 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -299,6 +299,11 @@ ena_free_pci_resources(struct ena_adapter *adapter) bus_release_resource(pdev, SYS_RES_MEMORY, PCIR_BAR(ENA_REG_BAR), adapter->registers); } + + if (adapter->msix != NULL) { + bus_release_resource(pdev, SYS_RES_MEMORY, + adapter->msix_rid, adapter->msix); + } } static int @@ -3532,6 +3537,7 @@ ena_attach(device_t pdev) struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; + int msix_rid; int rid, rc; adapter = device_get_softc(pdev); @@ -3570,6 +3576,20 @@ ena_attach(device_t pdev) goto err_dev_free; } + /* MSIx vector table may reside on BAR0 with registers or on BAR1. */ + msix_rid = pci_msix_table_bar(pdev); + if (msix_rid != rid) { + adapter->msix = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, + &msix_rid, RF_ACTIVE); + if (unlikely(adapter->msix == NULL)) { + device_printf(pdev, + "unable to allocate bus resource: msix!\n"); + rc = ENOMEM; + goto err_pci_free; + } + adapter->msix_rid = msix_rid; + } + ena_dev->bus = malloc(sizeof(struct ena_bus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -3735,6 +3755,7 @@ err_com_free: ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: free(ena_dev->bus, M_DEVBUF); +err_pci_free: ena_free_pci_resources(adapter); err_dev_free: free(ena_dev, M_DEVBUF); diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index 28da047e2e1b..f3e92f31341a 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -41,7 +41,7 @@ #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 3 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -398,6 +398,8 @@ struct ena_adapter { /* OS resources */ struct resource *memory; struct resource *registers; + struct resource *msix; + int msix_rid; struct sx global_lock; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 16:30:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 68840544531; Mon, 22 Feb 2021 16:30:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DknjS2HwPz3spy; Mon, 22 Feb 2021 16:30:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41924D21; Mon, 22 Feb 2021 16:30: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 11MGUarp023750; Mon, 22 Feb 2021 16:30:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MGUaKw023749; Mon, 22 Feb 2021 16:30:36 GMT (envelope-from git) Date: Mon, 22 Feb 2021 16:30:36 GMT Message-Id: <202102221630.11MGUaKw023749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 5d07525b81af - releng/13.0 - pkg(7): address minor nits (mostly clang-analyze complaints) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 5d07525b81af284c2be4ae438bcf000785122cf2 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, 22 Feb 2021 16:30:36 -0000 The branch releng/13.0 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=5d07525b81af284c2be4ae438bcf000785122cf2 commit 5d07525b81af284c2be4ae438bcf000785122cf2 Author: Kyle Evans AuthorDate: 2021-02-12 00:58:27 +0000 Commit: Kyle Evans CommitDate: 2021-02-22 16:30:26 +0000 pkg(7): address minor nits (mostly clang-analyze complaints) - One (1) spurious whitespace. - One (1) occurrence of "random(3) bad, arc4random(3)" good. - Three (3) writes that will never be seen. The latter two points are complaints from clang-analyze. Switching to arc4random(3) is decidedly a good idea because we weren't doing any kind of PRNG seeding anyways. The discarded assignments are arguably good for future-proofing, but it's better to improve the S/N ratio from clang-analyze. Approved by: re (gjb) (cherry picked from commit b2c4ca8d2872bc4410626f2b1ceafa49de5828ce) (cherry picked from commit 9ec09b04df17b3601e6f5ae8664c6ab81e1e4783) --- usr.sbin/pkg/dns_utils.c | 5 +++-- usr.sbin/pkg/pkg.c | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c index 78ebdd426f8b..f3bde529daca 100644 --- a/usr.sbin/pkg/dns_utils.c +++ b/usr.sbin/pkg/dns_utils.c @@ -87,7 +87,7 @@ compute_weight(struct dns_srvinfo **d, int first, int last) int *chosen; totalweight = 0; - + for (i = 0; i <= last; i++) totalweight += d[i]->weight; @@ -98,7 +98,8 @@ compute_weight(struct dns_srvinfo **d, int first, int last) for (i = 0; i <= last; i++) { for (;;) { - chosen[i] = random() % (d[i]->weight * 100 / totalweight); + chosen[i] = arc4random_uniform(d[i]->weight * 100 / + totalweight); for (j = 0; j < i; j++) { if (chosen[i] == chosen[j]) break; diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 788fdb39ebb9..20f6396eb73b 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -434,9 +434,7 @@ sha256_fd(int fd, char out[SHA256_DIGEST_LENGTH * 2 + 1]) int ret; SHA256_CTX sha256; - my_fd = -1; fp = NULL; - r = 0; ret = 1; out[0] = '\0'; @@ -627,7 +625,6 @@ parse_cert(int fd) { ssize_t linelen; buf = NULL; - my_fd = -1; sc = NULL; line = NULL; linecap = 0; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 17:27: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 4B48A545F56; Mon, 22 Feb 2021 17:27: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 4Dkpyp1SWRz4RwS; Mon, 22 Feb 2021 17:27: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 24CA11821; Mon, 22 Feb 2021 17:27: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 11MHRExS094489; Mon, 22 Feb 2021 17:27:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MHRE2Y094488; Mon, 22 Feb 2021 17:27:14 GMT (envelope-from git) Date: Mon, 22 Feb 2021 17:27:14 GMT Message-Id: <202102221727.11MHRE2Y094488@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: 64649f028542 - stable/13 - zfs: fix panic if scrubbing after removing a slog device 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: 64649f0285424435634c2dfd39f49536fc2b50dd 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, 22 Feb 2021 17:27:14 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=64649f0285424435634c2dfd39f49536fc2b50dd commit 64649f0285424435634c2dfd39f49536fc2b50dd Author: Martin Matuska AuthorDate: 2021-02-22 17:05:07 +0000 Commit: Martin Matuska CommitDate: 2021-02-22 17:26:12 +0000 zfs: fix panic if scrubbing after removing a slog device From openzfs-master 11f2e9a4 commit message: vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL This prevents a panic after a SLOG add/removal on the root pool followed by a zpool scrub. When a SLOG is removed, a hole takes its place - the vdev_ops for a hole is vdev_hole_ops, which defines the handler functions of vdev_op_hold and vdev_op_rele as NULL. Patch Author: Patrick Mooney Obtained from: openzfs/zfs@11f2e9a491baa2ae3fc00f6b8b892fa91a852ca1 PR: 252396 MFS after: 3 days (direct commit) --- sys/contrib/openzfs/module/zfs/vdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c index 7ffe924212da..5b83f8c22fed 100644 --- a/sys/contrib/openzfs/module/zfs/vdev.c +++ b/sys/contrib/openzfs/module/zfs/vdev.c @@ -2393,7 +2393,7 @@ vdev_hold(vdev_t *vd) for (int c = 0; c < vd->vdev_children; c++) vdev_hold(vd->vdev_child[c]); - if (vd->vdev_ops->vdev_op_leaf) + if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_hold != NULL) vd->vdev_ops->vdev_op_hold(vd); } @@ -2404,7 +2404,7 @@ vdev_rele(vdev_t *vd) for (int c = 0; c < vd->vdev_children; c++) vdev_rele(vd->vdev_child[c]); - if (vd->vdev_ops->vdev_op_leaf) + if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_rele != NULL) vd->vdev_ops->vdev_op_rele(vd); } From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 17:44: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 09E9754677D; Mon, 22 Feb 2021 17:44: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 4DkqL86xnmz4TB0; Mon, 22 Feb 2021 17:44: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 E13021D1B; Mon, 22 Feb 2021 17:44: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 11MHi0tB020691; Mon, 22 Feb 2021 17:44:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MHi0LO020690; Mon, 22 Feb 2021 17:44:00 GMT (envelope-from git) Date: Mon, 22 Feb 2021 17:44:00 GMT Message-Id: <202102221744.11MHi0LO020690@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: 940415f20a78 - stable/13 - zfs: disable use of hardware crypto offload drivers 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: 940415f20a784156ec0e247989796385896f32a8 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, 22 Feb 2021 17:44:01 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=940415f20a784156ec0e247989796385896f32a8 commit 940415f20a784156ec0e247989796385896f32a8 Author: Martin Matuska AuthorDate: 2021-02-22 17:37:47 +0000 Commit: Martin Matuska CommitDate: 2021-02-22 17:42:33 +0000 zfs: disable use of hardware crypto offload drivers From openzfs-master e7adccf7f commit message: First, the crypto request completion handler contains a bug in that it fails to reset fs_done correctly after the request is completed. This is only a problem for asynchronous drivers. Second, some hardware drivers have input constraints which ZFS does not satisfy. For instance, ccp(4) apparently requires the AAD length for AES-GCM to be a multiple of the cipher block size, and with qat(4) the AES-GCM AAD length may not be longer than 240 bytes. FreeBSD's generic crypto framework doesn't have a mechanism to automatically fall back to a software implementation if a hardware driver cannot process a request, and ZFS does not tolerate such errors. Patch Author: Mark Johnston Obtained from: openzfs/zfs@e7adccf7f537a4d07281a2b74b360154bae367bc PR: 252981, 253595 MFS after: 3 days (direct commit) --- sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c index b86ffc59a21d..0a7241699842 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c @@ -293,8 +293,19 @@ freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, error = ENOTSUP; goto bad; } - error = crypto_newsession(&sessp->fs_sid, &csp, - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE); + + /* + * Disable the use of hardware drivers on FreeBSD 13 and later since + * common crypto offload drivers impose constraints on AES-GCM AAD + * lengths that make them unusable for ZFS, and we currently do not have + * a mechanism to fall back to a software driver for requests not + * handled by a hardware driver. + * + * On 12 we continue to permit the use of hardware drivers since + * CPU-accelerated drivers such as aesni(4) register themselves as + * hardware drivers. + */ + error = crypto_newsession(&sessp->fs_sid, &csp, CRYPTOCAP_F_SOFTWARE); mtx_init(&sessp->fs_lock, "FreeBSD Cryptographic Session Lock", NULL, MTX_DEF); crypt_sessions++; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 18:25: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 20184549451; Mon, 22 Feb 2021 18:25: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 4DkrGV0NYYz4XcV; Mon, 22 Feb 2021 18:25:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0003F2891; Mon, 22 Feb 2021 18:25: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 11MIPrH1074057; Mon, 22 Feb 2021 18:25:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MIPrac074056; Mon, 22 Feb 2021 18:25:53 GMT (envelope-from git) Date: Mon, 22 Feb 2021 18:25:53 GMT Message-Id: <202102221825.11MIPrac074056@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: f3f042d850ba - releng/13.0 - MFS jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f3f042d850baaeda1bed19e00c2b3b578644b7e9 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, 22 Feb 2021 18:25:54 -0000 The branch releng/13.0 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=f3f042d850baaeda1bed19e00c2b3b578644b7e9 commit f3f042d850baaeda1bed19e00c2b3b578644b7e9 Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Jamie Gritton CommitDate: 2021-02-22 18:25:23 +0000 MFS jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Reported by: mjg Approved by: re (gjb), markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) (cherry picked from commit 5dbb407145c8128753fa30b695bc266dc671e433) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 059e5123c7b5..31c7d3bf2188 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3795,9 +3795,8 @@ pwd_drop(struct pwd *pwd) } /* -* Common routine for kern_chroot() and jail_attach(). The caller is -* responsible for invoking priv_check() and mac_vnode_check_chroot() to -* authorize this operation. +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. */ int pwd_chroot(struct thread *td, struct vnode *vp) @@ -3859,6 +3858,46 @@ pwd_chdir(struct thread *td, struct vnode *vp) pwd_drop(oldpwd); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct pwddesc *pdp; + struct filedesc *fdp; + struct pwd *newpwd, *oldpwd; + int error; + + fdp = td->td_proc->p_fd; + pdp = td->td_proc->p_pd; + newpwd = pwd_alloc(); + FILEDESC_SLOCK(fdp); + PWDDESC_XLOCK(pdp); + oldpwd = PWDDESC_XLOCKED_LOAD_PWD(pdp); + error = chroot_refuse_vdir_fds(fdp); + FILEDESC_SUNLOCK(fdp); + if (error != 0) { + PWDDESC_XUNLOCK(pdp); + pwd_drop(newpwd); + return (error); + } + + vrefact(vp); + newpwd->pwd_rdir = vp; + vrefact(vp); + newpwd->pwd_cdir = vp; + if (oldpwd->pwd_jdir == NULL) { + vrefact(vp); + newpwd->pwd_jdir = vp; + } + pwd_fill(oldpwd, newpwd); + pwd_set(pdp, newpwd); + PWDDESC_XUNLOCK(pdp); + pwd_drop(oldpwd); + return (0); +} + void pwd_ensure_dirs(void) { diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b56c889eeb7e..90ab69a372d2 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2495,7 +2495,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 890232b7f160..8c5aa258ed28 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -333,6 +333,7 @@ void pdunshare(struct thread *td); void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); void pwd_set_rootvnode(void); From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 19:02:39 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 35DB354B43B; Mon, 22 Feb 2021 19:02:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dks4v15fPz4bRj; Mon, 22 Feb 2021 19:02:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 185302ED2; Mon, 22 Feb 2021 19:02:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11MJ2cLv026577; Mon, 22 Feb 2021 19:02:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MJ2ctQ026576; Mon, 22 Feb 2021 19:02:38 GMT (envelope-from git) Date: Mon, 22 Feb 2021 19:02:38 GMT Message-Id: <202102221902.11MJ2ctQ026576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: ca9ab8ea1774 - stable/12 - MFC jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ca9ab8ea17748a1758701fde262cb272fb757989 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, 22 Feb 2021 19:02:39 -0000 The branch stable/12 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=ca9ab8ea17748a1758701fde262cb272fb757989 commit ca9ab8ea17748a1758701fde262cb272fb757989 Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Jamie Gritton CommitDate: 2021-02-22 19:02:21 +0000 MFC jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Reported by: mjg Approved by: markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 40 ++++++++++++++++++++++++++++++++++++---- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index bfa67c64f265..8614656990c0 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3242,10 +3242,9 @@ chroot_refuse_vdir_fds(struct filedesc *fdp) } /* - * Common routine for kern_chroot() and jail_attach(). The caller is - * responsible for invoking priv_check() and mac_vnode_check_chroot() to - * authorize this operation. - */ +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. +*/ int pwd_chroot(struct thread *td, struct vnode *vp) { @@ -3291,6 +3290,39 @@ pwd_chdir(struct thread *td, struct vnode *vp) vrele(oldvp); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct filedesc *fdp; + struct vnode *oldvrp, *oldvcp; + int error; + + fdp = td->td_proc->p_fd; + FILEDESC_XLOCK(fdp); + error = chroot_refuse_vdir_fds(fdp); + if (error != 0) { + FILEDESC_XUNLOCK(fdp); + return (error); + } + oldvrp = fdp->fd_rdir; + vrefact(vp); + fdp->fd_rdir = vp; + oldvcp = fdp->fd_cdir; + vrefact(vp); + fdp->fd_cdir = vp; + if (fdp->fd_jdir == NULL) { + vrefact(vp); + fdp->fd_jdir = vp; + } + FILEDESC_XUNLOCK(fdp); + vrele(oldvrp); + vrele(oldvcp); + return (0); +} + /* * Scan all active processes and prisons to see if any of them have a current * or root directory of `olddp'. If so, replace them with the new mount point. diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b4a20b4d29e9..46b43fa7bbc2 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2437,7 +2437,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root, 0); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index db5debcfe7c8..ca85f49d7997 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -243,6 +243,7 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq) /* cdir/rdir/jdir manipulation functions. */ void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); #endif /* _KERNEL */ From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 19:07: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 894F554BA37; Mon, 22 Feb 2021 19:07: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 4DksC02x27z4cJ7; Mon, 22 Feb 2021 19:07: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 5792F310D; Mon, 22 Feb 2021 19:07: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 11MJ7u8U027620; Mon, 22 Feb 2021 19:07:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MJ7urE027619; Mon, 22 Feb 2021 19:07:56 GMT (envelope-from git) Date: Mon, 22 Feb 2021 19:07:56 GMT Message-Id: <202102221907.11MJ7urE027619@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: 570121808a76 - stable/11 - MFC jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 570121808a76b85b2709502fb15618dd1e5296f1 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, 22 Feb 2021 19:07:56 -0000 The branch stable/11 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=570121808a76b85b2709502fb15618dd1e5296f1 commit 570121808a76b85b2709502fb15618dd1e5296f1 Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Jamie Gritton CommitDate: 2021-02-22 19:07:44 +0000 MFC jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Reported by: mjg Approved by: markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 40 ++++++++++++++++++++++++++++++++++++---- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 26b059c0a4b6..17f773d2b7de 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3052,10 +3052,9 @@ chroot_refuse_vdir_fds(struct filedesc *fdp) } /* - * Common routine for kern_chroot() and jail_attach(). The caller is - * responsible for invoking priv_check() and mac_vnode_check_chroot() to - * authorize this operation. - */ +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. +*/ int pwd_chroot(struct thread *td, struct vnode *vp) { @@ -3101,6 +3100,39 @@ pwd_chdir(struct thread *td, struct vnode *vp) vrele(oldvp); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct filedesc *fdp; + struct vnode *oldvrp, *oldvcp; + int error; + + fdp = td->td_proc->p_fd; + FILEDESC_XLOCK(fdp); + error = chroot_refuse_vdir_fds(fdp); + if (error != 0) { + FILEDESC_XUNLOCK(fdp); + return (error); + } + oldvrp = fdp->fd_rdir; + vrefact(vp); + fdp->fd_rdir = vp; + oldvcp = fdp->fd_cdir; + vrefact(vp); + fdp->fd_cdir = vp; + if (fdp->fd_jdir == NULL) { + vrefact(vp); + fdp->fd_jdir = vp; + } + FILEDESC_XUNLOCK(fdp); + vrele(oldvrp); + vrele(oldvcp); + return (0); +} + /* * Scan all active processes and prisons to see if any of them have a current * or root directory of `olddp'. If so, replace them with the new mount point. diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 0bb9c76a25c9..836bc4e4f8b7 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2418,7 +2418,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root, 0); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index b9ad9fe363e9..5bbc5a3e6fa8 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -239,6 +239,7 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq) /* cdir/rdir/jdir manipulation functions. */ void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); #endif /* _KERNEL */ From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 19:22: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 404D154BD88; Mon, 22 Feb 2021 19:22: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 4DksWZ1Nzlz4dF3; Mon, 22 Feb 2021 19:22: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 22B182FDB; Mon, 22 Feb 2021 19:22: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 11MJMIZL052345; Mon, 22 Feb 2021 19:22:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MJMIw3052344; Mon, 22 Feb 2021 19:22:18 GMT (envelope-from git) Date: Mon, 22 Feb 2021 19:22:18 GMT Message-Id: <202102221922.11MJMIw3052344@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: dd250d3def37 - releng/13.0 - ktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: dd250d3def37eb6f053c9239a0ef7a1f4200abd5 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, 22 Feb 2021 19:22:18 -0000 The branch releng/13.0 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=dd250d3def37eb6f053c9239a0ef7a1f4200abd5 commit dd250d3def37eb6f053c9239a0ef7a1f4200abd5 Author: Gordon Bergling AuthorDate: 2021-02-08 20:21:26 +0000 Commit: Gordon Bergling CommitDate: 2021-02-22 19:21:46 +0000 ktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page Since we ship a ktls(4) enabled OpenSSL version, mention the src.conf(5) option WITH_OPENSSL_KTLS in the manual page. Approved by: re (gjb) Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D28435 (cherry picked from commit 6c34d8ce11cb73e718fc23d85b6fbfab07ee15b4) --- share/man/man4/ktls.4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/share/man/man4/ktls.4 b/share/man/man4/ktls.4 index 9a8dccfb8afe..21e1a1bdb6ca 100644 --- a/share/man/man4/ktls.4 +++ b/share/man/man4/ktls.4 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 1, 2020 +.Dd February 8, 2021 .Dt KTLS 4 .Os .Sh NAME @@ -237,7 +237,9 @@ port may also be built with support for .Nm by enabling the .Dv KTLS -option . +option. +OpenSSL in the base system includes KTLS support when built with +.Dv WITH_OPENSSL_KTLS . .Pp Applications using a supported library should generally work with .Nm @@ -256,6 +258,7 @@ As a result, it is only supported on architectures with a direct map. .Xr cxgbe 4 , .Xr mlx5en 4 , .Xr tcp 4 , +.Xr src.conf 5 , .Xr ifconfig 8 , .Xr sysctl 8 , .Xr crypto 9 From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 20:31: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 25A3754D9B7; Mon, 22 Feb 2021 20:31: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 4Dkv3r0c40z4jnL; Mon, 22 Feb 2021 20:31: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 069D243F2; Mon, 22 Feb 2021 20:31: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 11MKVpwu044178; Mon, 22 Feb 2021 20:31:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MKVpiK044164; Mon, 22 Feb 2021 20:31:51 GMT (envelope-from git) Date: Mon, 22 Feb 2021 20:31:51 GMT Message-Id: <202102222031.11MKVpiK044164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: bc1df392499d - stable/12 - MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: bc1df392499ddf3ca5f089b850b898078267bd40 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, 22 Feb 2021 20:31:52 -0000 The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=bc1df392499ddf3ca5f089b850b898078267bd40 commit bc1df392499ddf3ca5f089b850b898078267bd40 Author: Michal Krawczyk AuthorDate: 2021-02-18 09:00:58 +0000 Commit: Marcin Wojtas CommitDate: 2021-02-22 20:31:16 +0000 MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table In the new ENA-based instances like c6gn, the vector table moved to a new PCIe bar - BAR1. Previously it was always located on the BAR0, so the resources were already allocated together with the registers. As the FreeBSD isn't doing any resource allocation behind the scenes, the driver is responsible to allocate them explicitly, before other parts of the OS (like the PCI code allocating MSIx) will be able to access them. To determine dynamically BAR on which the MSIx vector table is present the pci_msix_table_bar() is being used and the new BAR is allocated if needed. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc (cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1) --- sys/dev/ena/ena.c | 21 +++++++++++++++++++++ sys/dev/ena/ena.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 306d5dc1fd1c..0079f5354c33 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -299,6 +299,11 @@ ena_free_pci_resources(struct ena_adapter *adapter) bus_release_resource(pdev, SYS_RES_MEMORY, PCIR_BAR(ENA_REG_BAR), adapter->registers); } + + if (adapter->msix != NULL) { + bus_release_resource(pdev, SYS_RES_MEMORY, + adapter->msix_rid, adapter->msix); + } } static int @@ -3536,6 +3541,7 @@ ena_attach(device_t pdev) struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; + int msix_rid; int rid, rc; adapter = device_get_softc(pdev); @@ -3574,6 +3580,20 @@ ena_attach(device_t pdev) goto err_dev_free; } + /* MSIx vector table may reside on BAR0 with registers or on BAR1. */ + msix_rid = pci_msix_table_bar(pdev); + if (msix_rid != rid) { + adapter->msix = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, + &msix_rid, RF_ACTIVE); + if (unlikely(adapter->msix == NULL)) { + device_printf(pdev, + "unable to allocate bus resource: msix!\n"); + rc = ENOMEM; + goto err_pci_free; + } + adapter->msix_rid = msix_rid; + } + ena_dev->bus = malloc(sizeof(struct ena_bus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -3739,6 +3759,7 @@ err_com_free: ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: free(ena_dev->bus, M_DEVBUF); +err_pci_free: ena_free_pci_resources(adapter); err_dev_free: free(ena_dev, M_DEVBUF); diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index b3036eb16b2e..c8607a6d558d 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -41,7 +41,7 @@ #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 3 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -397,6 +397,8 @@ struct ena_adapter { /* OS resources */ struct resource *memory; struct resource *registers; + struct resource *msix; + int msix_rid; struct sx global_lock; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 20:46: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 44B7B54DDE0; Mon, 22 Feb 2021 20:46: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 4DkvNP1WyZz4kvw; Mon, 22 Feb 2021 20:46: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 22E094A06; Mon, 22 Feb 2021 20:46: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 11MKkCQt059353; Mon, 22 Feb 2021 20:46:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MKkCDF059352; Mon, 22 Feb 2021 20:46:12 GMT (envelope-from git) Date: Mon, 22 Feb 2021 20:46:12 GMT Message-Id: <202102222046.11MKkCDF059352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 79474cbd9bc4 - stable/11 - MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 79474cbd9bc4c72dd8d75028aedc104af562623c 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, 22 Feb 2021 20:46:13 -0000 The branch stable/11 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=79474cbd9bc4c72dd8d75028aedc104af562623c commit 79474cbd9bc4c72dd8d75028aedc104af562623c Author: Michal Krawczyk AuthorDate: 2021-02-18 09:00:58 +0000 Commit: Marcin Wojtas CommitDate: 2021-02-22 20:44:45 +0000 MFC 1c808fcd859f: Allocate BAR for ENA MSIx vector table In the new ENA-based instances like c6gn, the vector table moved to a new PCIe bar - BAR1. Previously it was always located on the BAR0, so the resources were already allocated together with the registers. As the FreeBSD isn't doing any resource allocation behind the scenes, the driver is responsible to allocate them explicitly, before other parts of the OS (like the PCI code allocating MSIx) will be able to access them. To determine dynamically BAR on which the MSIx vector table is present the pci_msix_table_bar() is being used and the new BAR is allocated if needed. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc (cherry picked from commit 1c808fcd859f5ce24132a903a4c7c9996e0513b1) --- sys/dev/ena/ena.c | 21 +++++++++++++++++++++ sys/dev/ena/ena.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 70989b7a36b9..3c6b500f9fd9 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -294,6 +294,11 @@ ena_free_pci_resources(struct ena_adapter *adapter) bus_release_resource(pdev, SYS_RES_MEMORY, PCIR_BAR(ENA_REG_BAR), adapter->registers); } + + if (adapter->msix != NULL) { + bus_release_resource(pdev, SYS_RES_MEMORY, + adapter->msix_rid, adapter->msix); + } } static int @@ -3516,6 +3521,7 @@ ena_attach(device_t pdev) struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; + int msix_rid; int rid, rc; adapter = device_get_softc(pdev); @@ -3554,6 +3560,20 @@ ena_attach(device_t pdev) goto err_dev_free; } + /* MSIx vector table may reside on BAR0 with registers or on BAR1. */ + msix_rid = pci_msix_table_bar(pdev); + if (msix_rid != rid) { + adapter->msix = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, + &msix_rid, RF_ACTIVE); + if (unlikely(adapter->msix == NULL)) { + device_printf(pdev, + "unable to allocate bus resource: msix!\n"); + rc = ENOMEM; + goto err_pci_free; + } + adapter->msix_rid = msix_rid; + } + ena_dev->bus = malloc(sizeof(struct ena_bus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -3727,6 +3747,7 @@ err_com_free: ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: free(ena_dev->bus, M_DEVBUF); +err_pci_free: ena_free_pci_resources(adapter); err_dev_free: free(ena_dev, M_DEVBUF); diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index 28da047e2e1b..f3e92f31341a 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -41,7 +41,7 @@ #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 3 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -398,6 +398,8 @@ struct ena_adapter { /* OS resources */ struct resource *memory; struct resource *registers; + struct resource *msix; + int msix_rid; struct sx global_lock; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 21:15: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 25BD154E462; Mon, 22 Feb 2021 21:15: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 4Dkw1w0HvQz4mJd; Mon, 22 Feb 2021 21:15: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 F12984CC1; Mon, 22 Feb 2021 21:15:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11MLFFai099291; Mon, 22 Feb 2021 21:15:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MLFFoJ099289; Mon, 22 Feb 2021 21:15:15 GMT (envelope-from git) Date: Mon, 22 Feb 2021 21:15:15 GMT Message-Id: <202102222115.11MLFFoJ099289@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jung-uk Kim Subject: git: 80cb372e2ad8 - stable/13 - lex: Do not let input() return 0 when end-of-file is reached MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jkim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 80cb372e2ad847c4093f9cf7ddfe4b6355520c1b 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, 22 Feb 2021 21:15:16 -0000 The branch stable/13 has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=80cb372e2ad847c4093f9cf7ddfe4b6355520c1b commit 80cb372e2ad847c4093f9cf7ddfe4b6355520c1b Author: Jung-uk Kim AuthorDate: 2021-02-17 07:22:47 +0000 Commit: Jung-uk Kim CommitDate: 2021-02-22 21:13:50 +0000 lex: Do not let input() return 0 when end-of-file is reached Importing flex 2.6.4 has introduced a regression: input() now returns 0 instead of EOF to indicate that the end of input was reached, just like traditional AT&T and POSIX lex. Note the behavior contradicts flex(1). See "INCOMPATIBILITIES WITH LEX AND POSIX" section for information. This incompatibility traces back to the original version and documented in its manual page by the Vern Paxson. Apparently, it has been reported in a few places, e.g., https://github.com/westes/flex/issues/448 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415 Unfortunately, this also breaks the scanner used by libdtrace and dtrace is unable to resolve some probe argument types as a result. See PR253440 for more information. Note the regression was introduced by the following upstream commit without any explanation or documentation change: https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff Now we restore the traditional flex behavior unless lex-compatibility mode is set with "-l" option because I believe the author originally wanted to make it more lex and POSIX compatible. PR: 253440 Reported by: markj (cherry picked from commit 6b7e592c215fb76ea027f25030ddc9a697184fbe) --- contrib/flex/src/flex.skl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/flex/src/flex.skl b/contrib/flex/src/flex.skl index 242645f53245..c23b944ea473 100644 --- a/contrib/flex/src/flex.skl +++ b/contrib/flex/src/flex.skl @@ -1863,7 +1863,11 @@ m4_ifdef( [[M4_YY_USE_LINENO]], case EOB_ACT_END_OF_FILE: { if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) +#ifdef YY_FLEX_LEX_COMPAT return 0; +#else + return EOF; +#endif if ( ! YY_G(yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 21:21: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 C16A154F49E; Mon, 22 Feb 2021 21:21: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 4Dkw8q2gYLz4nRC; Mon, 22 Feb 2021 21:21:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4BC284C71; Mon, 22 Feb 2021 21:21:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11MLLFoO008649; Mon, 22 Feb 2021 21:21:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MLLFxf008648; Mon, 22 Feb 2021 21:21:15 GMT (envelope-from git) Date: Mon, 22 Feb 2021 21:21:15 GMT Message-Id: <202102222121.11MLLFxf008648@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: 21269625733f - stable/13 - zfs: restore FreeBSD resource usage accounting 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: 21269625733f591c998f7d26790179e922ffbde0 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, 22 Feb 2021 21:21:15 -0000 The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=21269625733f591c998f7d26790179e922ffbde0 commit 21269625733f591c998f7d26790179e922ffbde0 Author: Martin Matuska AuthorDate: 2021-02-22 20:57:22 +0000 Commit: Martin Matuska CommitDate: 2021-02-22 21:20:28 +0000 zfs: restore FreeBSD resource usage accounting With the switch to OpenZFS 2.0 the platform-dependent resource usage accounting code got missing. Patch author: Ryan Moeller Obtained from: openzfs/zfs@64e0fe14fff465604952d576051ca80c2f1be898 MFS after: 3 days (direct commit) --- cddl/lib/libzpool/Makefile | 1 + sys/conf/files | 1 + sys/contrib/openzfs/include/sys/Makefile.am | 1 + sys/contrib/openzfs/include/sys/zfs_racct.h | 37 +++++++++++++++ sys/contrib/openzfs/lib/libzpool/Makefile.am | 1 + sys/contrib/openzfs/module/Makefile.bsd | 1 + .../openzfs/module/os/freebsd/zfs/zfs_racct.c | 55 ++++++++++++++++++++++ .../openzfs/module/os/linux/zfs/Makefile.in | 1 + .../openzfs/module/os/linux/zfs/zfs_racct.c | 36 ++++++++++++++ sys/contrib/openzfs/module/zfs/arc.c | 2 + sys/contrib/openzfs/module/zfs/dmu.c | 5 ++ sys/modules/zfs/Makefile | 1 + 12 files changed, 142 insertions(+) diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index 0e2cc9456faa..2cb1b0446ade 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -161,6 +161,7 @@ KERNEL_C = \ zfs_debug.c \ zfs_fm.c \ zfs_fuid.c \ + zfs_racct.c \ zfs_sa.c \ zfs_znode.c \ zfs_ratelimit.c \ diff --git a/sys/conf/files b/sys/conf/files index f0bf574b3236..1c52f16ff2e1 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -217,6 +217,7 @@ contrib/openzfs/module/os/freebsd/zfs/zfs_dir.c optional zfs compile-with "${ZF contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_ioctl_compat.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_ioctl_os.c optional zfs compile-with "${ZFS_C}" +contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c optional zfs compile-with "${ZFS_C}" diff --git a/sys/contrib/openzfs/include/sys/Makefile.am b/sys/contrib/openzfs/include/sys/Makefile.am index c3ebf17b5288..385c82c926ae 100644 --- a/sys/contrib/openzfs/include/sys/Makefile.am +++ b/sys/contrib/openzfs/include/sys/Makefile.am @@ -111,6 +111,7 @@ COMMON_H = \ zfs_fuid.h \ zfs_project.h \ zfs_quota.h \ + zfs_racct.h \ zfs_ratelimit.h \ zfs_refcount.h \ zfs_rlock.h \ diff --git a/sys/contrib/openzfs/include/sys/zfs_racct.h b/sys/contrib/openzfs/include/sys/zfs_racct.h new file mode 100644 index 000000000000..cfcdd336ea42 --- /dev/null +++ b/sys/contrib/openzfs/include/sys/zfs_racct.h @@ -0,0 +1,37 @@ +/* + * 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 + */ + +/* + * Portions Copyright 2021 iXsystems, Inc. + */ + +#ifndef _SYS_ZFS_RACCT_H +#define _SYS_ZFS_RACCT_H + +#include + +/* + * Platform-dependent resource accounting hooks + */ +void zfs_racct_read(uint64_t size, uint64_t iops); +void zfs_racct_write(uint64_t size, uint64_t iops); + +#endif /* _SYS_ZFS_RACCT_H */ diff --git a/sys/contrib/openzfs/lib/libzpool/Makefile.am b/sys/contrib/openzfs/lib/libzpool/Makefile.am index 7aa7e80985aa..b66e933657ab 100644 --- a/sys/contrib/openzfs/lib/libzpool/Makefile.am +++ b/sys/contrib/openzfs/lib/libzpool/Makefile.am @@ -163,6 +163,7 @@ KERNEL_C = \ zfs_debug.c \ zfs_fm.c \ zfs_fuid.c \ + zfs_racct.c \ zfs_sa.c \ zfs_znode.c \ zfs_ratelimit.c \ diff --git a/sys/contrib/openzfs/module/Makefile.bsd b/sys/contrib/openzfs/module/Makefile.bsd index e7cddcc5bb5e..8aa4ed22275e 100644 --- a/sys/contrib/openzfs/module/Makefile.bsd +++ b/sys/contrib/openzfs/module/Makefile.bsd @@ -153,6 +153,7 @@ SRCS+= abd_os.c \ zfs_dir.c \ zfs_ioctl_compat.c \ zfs_ioctl_os.c \ + zfs_racct.c \ zfs_vfsops.c \ zfs_vnops_os.c \ zfs_znode.c \ diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c new file mode 100644 index 000000000000..b46cc046268e --- /dev/null +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 iXsystems, Inc. + * + * 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 +#include + +void +zfs_racct_read(uint64_t size, uint64_t iops) +{ + curthread->td_ru.ru_inblock += iops; +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_force(curproc, RACCT_READBPS, size); + racct_add_force(curproc, RACCT_READIOPS, iops); + PROC_UNLOCK(curproc); + } +#endif /* RACCT */ +} + +void +zfs_racct_write(uint64_t size, uint64_t iops) +{ + curthread->td_ru.ru_oublock += iops; +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_force(curproc, RACCT_WRITEBPS, size); + racct_add_force(curproc, RACCT_WRITEIOPS, iops); + PROC_UNLOCK(curproc); + } +#endif /* RACCT */ +} diff --git a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in b/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in index 75bec52c94e2..fa990776db83 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in +++ b/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in @@ -22,6 +22,7 @@ $(MODULE)-objs += ../os/linux/zfs/zfs_debug.o $(MODULE)-objs += ../os/linux/zfs/zfs_dir.o $(MODULE)-objs += ../os/linux/zfs/zfs_file_os.o $(MODULE)-objs += ../os/linux/zfs/zfs_ioctl_os.o +$(MODULE)-objs += ../os/linux/zfs/zfs_racct.o $(MODULE)-objs += ../os/linux/zfs/zfs_sysfs.o $(MODULE)-objs += ../os/linux/zfs/zfs_uio.o $(MODULE)-objs += ../os/linux/zfs/zfs_vfsops.o diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c new file mode 100644 index 000000000000..7897e0f9edc1 --- /dev/null +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 iXsystems, Inc. + * + * 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 + +void +zfs_racct_read(uint64_t size, uint64_t iops) +{ +} + +void +zfs_racct_write(uint64_t size, uint64_t iops) +{ +} diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index fecc752e16ff..b01ccd13a0db 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -308,6 +308,7 @@ #include #include #include +#include #include #ifndef _KERNEL @@ -6296,6 +6297,7 @@ top: ARCSTAT_CONDSTAT(!HDR_PREFETCH(hdr), demand, prefetch, !HDR_ISTYPE_METADATA(hdr), data, metadata, misses); + zfs_racct_read(size, 1); } /* Check if the spa even has l2 configured */ diff --git a/sys/contrib/openzfs/module/zfs/dmu.c b/sys/contrib/openzfs/module/zfs/dmu.c index a02f43df13fd..5d6e98d245da 100644 --- a/sys/contrib/openzfs/module/zfs/dmu.c +++ b/sys/contrib/openzfs/module/zfs/dmu.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #ifdef _KERNEL #include @@ -551,6 +552,9 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, dbp[i] = &db->db; } + if (!read) + zfs_racct_write(length, nblks); + if ((flags & DMU_READ_NO_PREFETCH) == 0 && DNODE_META_IS_CACHEABLE(dn) && length <= zfetch_array_rd_sz) { dmu_zfetch(&dn->dn_zfetch, blkid, nblks, @@ -1448,6 +1452,7 @@ dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, arc_buf_t *buf, * same size as the dbuf. */ if (offset == db->db.db_offset && blksz == db->db.db_size) { + zfs_racct_write(blksz, 1); dbuf_assign_arcbuf(db, buf, tx); dbuf_rele(db, FTAG); } else { diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile index 49256609b549..0fab9f552314 100644 --- a/sys/modules/zfs/Makefile +++ b/sys/modules/zfs/Makefile @@ -126,6 +126,7 @@ SRCS+= abd_os.c \ zfs_ioctl_compat.c \ zfs_ioctl_os.c \ zfs_log.c \ + zfs_racct.c \ zfs_replay.c \ zfs_vfsops.c \ zfs_vnops_os.c \ From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 21:34: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 1906E54FEE1; Mon, 22 Feb 2021 21:34: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 4DkwRr0BDlz4prR; Mon, 22 Feb 2021 21:34: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 ED4BE5487; Mon, 22 Feb 2021 21:34:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11MLYFDP025786; Mon, 22 Feb 2021 21:34:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MLYFK0025785; Mon, 22 Feb 2021 21:34:15 GMT (envelope-from git) Date: Mon, 22 Feb 2021 21:34:15 GMT Message-Id: <202102222134.11MLYFK0025785@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jung-uk Kim Subject: git: 4e3fa977a14f - releng/13.0 - lex: Do not let input() return 0 when end-of-file is reached MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jkim X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 4e3fa977a14f7c69a39aacd8788a437527767dac 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, 22 Feb 2021 21:34:16 -0000 The branch releng/13.0 has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=4e3fa977a14f7c69a39aacd8788a437527767dac commit 4e3fa977a14f7c69a39aacd8788a437527767dac Author: Jung-uk Kim AuthorDate: 2021-02-17 07:22:47 +0000 Commit: Jung-uk Kim CommitDate: 2021-02-22 21:28:53 +0000 lex: Do not let input() return 0 when end-of-file is reached Importing flex 2.6.4 has introduced a regression: input() now returns 0 instead of EOF to indicate that the end of input was reached, just like traditional AT&T and POSIX lex. Note the behavior contradicts flex(1). See "INCOMPATIBILITIES WITH LEX AND POSIX" section for information. This incompatibility traces back to the original version and documented in its manual page by the Vern Paxson. Apparently, it has been reported in a few places, e.g., https://github.com/westes/flex/issues/448 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415 Unfortunately, this also breaks the scanner used by libdtrace and dtrace is unable to resolve some probe argument types as a result. See PR253440 for more information. Note the regression was introduced by the following upstream commit without any explanation or documentation change: https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff Now we restore the traditional flex behavior unless lex-compatibility mode is set with "-l" option because I believe the author originally wanted to make it more lex and POSIX compatible. PR: 253440 Reported by: markj Approved by: re (gjb) (cherry picked from commit 6b7e592c215fb76ea027f25030ddc9a697184fbe) --- contrib/flex/src/flex.skl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/flex/src/flex.skl b/contrib/flex/src/flex.skl index 242645f53245..c23b944ea473 100644 --- a/contrib/flex/src/flex.skl +++ b/contrib/flex/src/flex.skl @@ -1863,7 +1863,11 @@ m4_ifdef( [[M4_YY_USE_LINENO]], case EOB_ACT_END_OF_FILE: { if ( yywrap( M4_YY_CALL_ONLY_ARG ) ) +#ifdef YY_FLEX_LEX_COMPAT return 0; +#else + return EOF; +#endif if ( ! YY_G(yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 21:59: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 42C5E550BCF; Mon, 22 Feb 2021 21:59: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 4Dkx1K15Fwz4rj2; Mon, 22 Feb 2021 21:59: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 1800D54EB; Mon, 22 Feb 2021 21:59: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 11MLxmU5052645; Mon, 22 Feb 2021 21:59:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MLxmto052644; Mon, 22 Feb 2021 21:59:48 GMT (envelope-from git) Date: Mon, 22 Feb 2021 21:59:48 GMT Message-Id: <202102222159.11MLxmto052644@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: ae093a0614f3 - releng/13.0 - libdtrace: Stop relying on lex compatibility 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ae093a0614f30d4cdffb853e4eba93322e8ed8f4 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, 22 Feb 2021 21:59:49 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ae093a0614f30d4cdffb853e4eba93322e8ed8f4 commit ae093a0614f30d4cdffb853e4eba93322e8ed8f4 Author: Mark Johnston AuthorDate: 2021-02-17 15:49:38 +0000 Commit: Mark Johnston CommitDate: 2021-02-22 21:59:36 +0000 libdtrace: Stop relying on lex compatibility It does not appear to be required, and as of commit 6b7e592c215f ("lex: Do not let input() return 0 when end-of-file is reached") it causes input to return 0 instead of EOF when end-of-input is reached. Approved by: re (gjb) PR: 253440 Sponsored by: The FreeBSD Foundation (cherry picked from commit 8ba333e02eaa59337a4e1d5534d4e894344c8226) (cherry picked from commit af80731179386cf019463e392370b6478a714aea) --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h | 2 +- cddl/lib/libdtrace/Makefile | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index f2c60a2b07d4..b3f69bb6329d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -717,7 +717,7 @@ extern dt_pcb_t *yypcb; /* pointer to current parser control block */ extern char yyintprefix; /* int token prefix for macros (+/-) */ extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */ extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */ -extern char yytext[]; /* lex input buffer */ +extern char *yytext; /* lex input buffer */ extern int yylineno; /* lex line number */ extern int yydebug; /* lex debugging */ extern dt_node_t *yypragma; /* lex token list for control lines */ diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile index efd73751e2c0..45ca1692cf48 100644 --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -129,8 +129,6 @@ SRCS+= dis_tables.c DSRCS+= regs_x86.d .endif -LFLAGS+=-l - YFLAGS+=-d LIBADD= ctf elf proc pthread rtld_db From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 22:03:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6286C5508FF; Mon, 22 Feb 2021 22:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dkx5k2GDFz4s8k; Mon, 22 Feb 2021 22:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 409175361; Mon, 22 Feb 2021 22:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11MM3cNW065406; Mon, 22 Feb 2021 22:03:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MM3cSs065405; Mon, 22 Feb 2021 22:03:38 GMT (envelope-from git) Date: Mon, 22 Feb 2021 22:03:38 GMT Message-Id: <202102222203.11MM3cSs065405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 57d6e82d1f69 - stable/13 - loader_lua: consider userboot console as serial MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 57d6e82d1f69f40bda1d744b90e1fdcf761a3d29 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, 22 Feb 2021 22:03:38 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=57d6e82d1f69f40bda1d744b90e1fdcf761a3d29 commit 57d6e82d1f69f40bda1d744b90e1fdcf761a3d29 Author: Toomas Soome AuthorDate: 2021-02-14 08:28:29 +0000 Commit: Toomas Soome CommitDate: 2021-02-21 11:07:12 +0000 loader_lua: consider userboot console as serial We use ascii box chars with serial console because we do not know if terminal can draw unixode box chars. Same problem is about userboot console. (cherry picked from commit 5d8c062fe3ee7b2d6aed0b46d22f62c7771c0af8) --- stand/lua/core.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stand/lua/core.lua b/stand/lua/core.lua index a119c3c258f8..55c26e0d6d39 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -403,7 +403,10 @@ end function core.isSerialConsole() local c = loader.getenv("console") if c ~= nil then - if c:find("comconsole") ~= nil then + -- serial console is comconsole, but also userboot. + -- userboot is there, because we have no way to know + -- if the user terminal can draw unicode box chars or not. + if c:find("comconsole") ~= nil or c:find("userboot") ~= nil then return true end end From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 23:54: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 C29F155362C; Mon, 22 Feb 2021 23:54: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 4DkzY958dqz3Fwj; Mon, 22 Feb 2021 23:54: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 9929B6C72; Mon, 22 Feb 2021 23:54: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 11MNs5CN009976; Mon, 22 Feb 2021 23:54:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MNs5eC009975; Mon, 22 Feb 2021 23:54:05 GMT (envelope-from git) Date: Mon, 22 Feb 2021 23:54:05 GMT Message-Id: <202102222354.11MNs5eC009975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: c930816b7671 - stable/13 - cxgbe(4): Save proper zone index on low memory in refill_fl(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c930816b76713623ccdef09d682e41266c1d724f 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, 22 Feb 2021 23:54:05 -0000 The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=c930816b76713623ccdef09d682e41266c1d724f commit c930816b76713623ccdef09d682e41266c1d724f Author: Alexander Motin AuthorDate: 2021-02-17 02:15:28 +0000 Commit: Navdeep Parhar CommitDate: 2021-02-22 23:51:58 +0000 cxgbe(4): Save proper zone index on low memory in refill_fl(). When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it falls back to safe (4KB) ones. But it still saved into sd->zidx the original fl->zidx instead of fl->safe_zidx. It caused problems with the later use of that cluster, including memory and/or data corruption. While there, make refill_fl() to use the safe zone for all following clusters for the call, since it is unlikely that large succeed. MFC after: 3 days Sponsored by: iXsystems, Inc. Reviewed by: np, jhb Differential Revision: https://reviews.freebsd.org/D28716 (cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8) --- sys/dev/cxgbe/t4_sge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 45f07358f0db..d16f17c45614 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4524,7 +4524,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) caddr_t cl; struct rx_buf_info *rxb; struct cluster_metadata *clm; - uint16_t max_pidx; + uint16_t max_pidx, zidx = fl->zidx; uint16_t hw_cidx = fl->hw_cidx; /* stable snapshot */ FL_LOCK_ASSERT_OWNED(fl); @@ -4540,6 +4540,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) d = &fl->desc[fl->pidx]; sd = &fl->sdesc[fl->pidx]; + rxb = &sc->sge.rx_buf_info[zidx]; while (n > 0) { @@ -4573,11 +4574,11 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) sd->cl = NULL; /* gave up my reference */ } MPASS(sd->cl == NULL); - rxb = &sc->sge.rx_buf_info[fl->zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); if (__predict_false(cl == NULL)) { - if (fl->zidx != fl->safe_zidx) { - rxb = &sc->sge.rx_buf_info[fl->safe_zidx]; + if (zidx != fl->safe_zidx) { + zidx = fl->safe_zidx; + rxb = &sc->sge.rx_buf_info[zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); } if (cl == NULL) @@ -4588,7 +4589,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) pa = pmap_kextract((vm_offset_t)cl); sd->cl = cl; - sd->zidx = fl->zidx; + sd->zidx = zidx; if (fl->flags & FL_BUF_PACKING) { *d = htobe64(pa | rxb->hwidx2); From owner-dev-commits-src-branches@freebsd.org Mon Feb 22 23:56:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 41CA05538A2; Mon, 22 Feb 2021 23:56:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DkzcJ1Nvvz3GS3; Mon, 22 Feb 2021 23:56:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 22AF56C75; Mon, 22 Feb 2021 23:56: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 11MNum6v010600; Mon, 22 Feb 2021 23:56:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11MNum8a010599; Mon, 22 Feb 2021 23:56:48 GMT (envelope-from git) Date: Mon, 22 Feb 2021 23:56:48 GMT Message-Id: <202102222356.11MNum8a010599@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: ab88a1ff14ef - stable/12 - cxgbe(4): Save proper zone index on low memory in refill_fl(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: ab88a1ff14ef1db0296af1d2be648b784ba4e614 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, 22 Feb 2021 23:56:48 -0000 The branch stable/12 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=ab88a1ff14ef1db0296af1d2be648b784ba4e614 commit ab88a1ff14ef1db0296af1d2be648b784ba4e614 Author: Alexander Motin AuthorDate: 2021-02-17 02:15:28 +0000 Commit: Navdeep Parhar CommitDate: 2021-02-22 23:55:19 +0000 cxgbe(4): Save proper zone index on low memory in refill_fl(). When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it falls back to safe (4KB) ones. But it still saved into sd->zidx the original fl->zidx instead of fl->safe_zidx. It caused problems with the later use of that cluster, including memory and/or data corruption. While there, make refill_fl() to use the safe zone for all following clusters for the call, since it is unlikely that large succeed. MFC after: 3 days Sponsored by: iXsystems, Inc. Reviewed by: np, jhb Differential Revision: https://reviews.freebsd.org/D28716 (cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8) --- sys/dev/cxgbe/t4_sge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 335fd28644d2..4489d40e9fe4 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4530,7 +4530,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) caddr_t cl; struct rx_buf_info *rxb; struct cluster_metadata *clm; - uint16_t max_pidx; + uint16_t max_pidx, zidx = fl->zidx; uint16_t hw_cidx = fl->hw_cidx; /* stable snapshot */ FL_LOCK_ASSERT_OWNED(fl); @@ -4546,6 +4546,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) d = &fl->desc[fl->pidx]; sd = &fl->sdesc[fl->pidx]; + rxb = &sc->sge.rx_buf_info[zidx]; while (n > 0) { @@ -4579,11 +4580,11 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) sd->cl = NULL; /* gave up my reference */ } MPASS(sd->cl == NULL); - rxb = &sc->sge.rx_buf_info[fl->zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); if (__predict_false(cl == NULL)) { - if (fl->zidx != fl->safe_zidx) { - rxb = &sc->sge.rx_buf_info[fl->safe_zidx]; + if (zidx != fl->safe_zidx) { + zidx = fl->safe_zidx; + rxb = &sc->sge.rx_buf_info[zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); } if (cl == NULL) @@ -4594,7 +4595,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) pa = pmap_kextract((vm_offset_t)cl); sd->cl = cl; - sd->zidx = fl->zidx; + sd->zidx = zidx; if (fl->flags & FL_BUF_PACKING) { *d = htobe64(pa | rxb->hwidx2); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:32: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 E3A8E554C30; Tue, 23 Feb 2021 00:32: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 4Dl0P867J3z3JCP; Tue, 23 Feb 2021 00:32: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 C52F7788E; Tue, 23 Feb 2021 00:32: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 11N0WC67062491; Tue, 23 Feb 2021 00:32:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0WCYo062490; Tue, 23 Feb 2021 00:32:12 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:32:12 GMT Message-Id: <202102230032.11N0WCYo062490@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: c8169618a730 - stable/13 - Exclude reserved iSCSI Target Transfer Tag. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c8169618a7300bf41dad37b0ce107a4be5d9f8b0 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, 23 Feb 2021 00:32:13 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c8169618a7300bf41dad37b0ce107a4be5d9f8b0 commit c8169618a7300bf41dad37b0ce107a4be5d9f8b0 Author: Alexander Motin AuthorDate: 2021-01-24 18:58:29 +0000 Commit: Alexander Motin CommitDate: 2021-02-23 00:31:52 +0000 Exclude reserved iSCSI Target Transfer Tag. RFC 7143 (11.7.4): The Target Transfer Tag values are not specified by this protocol, except that the value 0xffffffff is reserved and means that the Target Transfer Tag is not supplied. MFC after: 1 month --- sys/cam/ctl/ctl_frontend_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 996ab4e44fc0..8b0effcaf393 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -2693,6 +2693,10 @@ cfiscsi_datamove_out(union ctl_io *io) target_transfer_tag = atomic_fetchadd_32(&cs->cs_target_transfer_tag, 1); + if (target_transfer_tag == 0xffffffff) { + target_transfer_tag = + atomic_fetchadd_32(&cs->cs_target_transfer_tag, 1); + } cdw = cfiscsi_data_wait_new(cs, io, bhssc->bhssc_initiator_task_tag, &target_transfer_tag); if (cdw == NULL) { From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:32: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 16C98554C31; Tue, 23 Feb 2021 00:32: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 4Dl0P970x8z3J6Y; Tue, 23 Feb 2021 00:32: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 DDBAF72FA; Tue, 23 Feb 2021 00:32: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 11N0WDsR062514; Tue, 23 Feb 2021 00:32:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0WDdc062513; Tue, 23 Feb 2021 00:32:13 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:32:13 GMT Message-Id: <202102230032.11N0WDdc062513@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 49f4b33f9e16 - stable/13 - Exclude reserved iSCSI Initiator Task Tag. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 49f4b33f9e1667f51a2d55e39785ce50c2cda950 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, 23 Feb 2021 00:32:14 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=49f4b33f9e1667f51a2d55e39785ce50c2cda950 commit 49f4b33f9e1667f51a2d55e39785ce50c2cda950 Author: Alexander Motin AuthorDate: 2021-01-24 19:23:04 +0000 Commit: Alexander Motin CommitDate: 2021-02-23 00:31:52 +0000 Exclude reserved iSCSI Initiator Task Tag. RFC 7143 (11.2.1.8): An ITT value of 0xffffffff is reserved and MUST NOT be assigned for a task by the initiator. The only instance in which it may be seen on the wire is in a target-initiated NOP-In PDU (Section 11.19) and in the initiator response to that PDU, if necessary. MFC after: 1 month --- sys/dev/iscsi/iscsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index eaaf84de9594..5e6c80255bff 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -2194,6 +2194,8 @@ iscsi_action_abort(struct iscsi_session *is, union ccb *ccb) } initiator_task_tag = is->is_initiator_task_tag++; + if (initiator_task_tag == 0xffffffff) + initiator_task_tag = is->is_initiator_task_tag++; io = iscsi_outstanding_add(is, request, NULL, &initiator_task_tag); if (io == NULL) { @@ -2254,6 +2256,9 @@ iscsi_action_scsiio(struct iscsi_session *is, union ccb *ccb) } initiator_task_tag = is->is_initiator_task_tag++; + if (initiator_task_tag == 0xffffffff) + initiator_task_tag = is->is_initiator_task_tag++; + io = iscsi_outstanding_add(is, request, ccb, &initiator_task_tag); if (io == NULL) { icl_pdu_free(request); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:33: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 73CC0554EA6; Tue, 23 Feb 2021 00:33: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 4Dl0QX2wlPz3Jrx; Tue, 23 Feb 2021 00:33: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 57763787C; Tue, 23 Feb 2021 00:33: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 11N0XONF062853; Tue, 23 Feb 2021 00:33:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0XO9x062852; Tue, 23 Feb 2021 00:33:24 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:33:24 GMT Message-Id: <202102230033.11N0XO9x062852@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 7cc6daf122e5 - stable/12 - Exclude reserved iSCSI Target Transfer Tag. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7cc6daf122e53859ba786716090d1d536249a793 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, 23 Feb 2021 00:33:24 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=7cc6daf122e53859ba786716090d1d536249a793 commit 7cc6daf122e53859ba786716090d1d536249a793 Author: Alexander Motin AuthorDate: 2021-01-24 18:58:29 +0000 Commit: Alexander Motin CommitDate: 2021-02-23 00:33:19 +0000 Exclude reserved iSCSI Target Transfer Tag. RFC 7143 (11.7.4): The Target Transfer Tag values are not specified by this protocol, except that the value 0xffffffff is reserved and means that the Target Transfer Tag is not supplied. MFC after: 1 month --- sys/cam/ctl/ctl_frontend_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index dfe1a347844b..9b55574590ff 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -2659,6 +2659,10 @@ cfiscsi_datamove_out(union ctl_io *io) target_transfer_tag = atomic_fetchadd_32(&cs->cs_target_transfer_tag, 1); + if (target_transfer_tag == 0xffffffff) { + target_transfer_tag = + atomic_fetchadd_32(&cs->cs_target_transfer_tag, 1); + } cdw = cfiscsi_data_wait_new(cs, io, bhssc->bhssc_initiator_task_tag, &target_transfer_tag); if (cdw == NULL) { From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:33: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 9D72455528E; Tue, 23 Feb 2021 00:33: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 4Dl0QY3ztgz3Jbd; Tue, 23 Feb 2021 00:33: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 79D1D7894; Tue, 23 Feb 2021 00:33: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 11N0XPM4062876; Tue, 23 Feb 2021 00:33:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0XPjC062875; Tue, 23 Feb 2021 00:33:25 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:33:25 GMT Message-Id: <202102230033.11N0XPjC062875@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 0004227346d0 - stable/12 - Exclude reserved iSCSI Initiator Task Tag. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 0004227346d0ceea713b456300794d55e787a5e6 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, 23 Feb 2021 00:33:25 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=0004227346d0ceea713b456300794d55e787a5e6 commit 0004227346d0ceea713b456300794d55e787a5e6 Author: Alexander Motin AuthorDate: 2021-01-24 19:23:04 +0000 Commit: Alexander Motin CommitDate: 2021-02-23 00:33:20 +0000 Exclude reserved iSCSI Initiator Task Tag. RFC 7143 (11.2.1.8): An ITT value of 0xffffffff is reserved and MUST NOT be assigned for a task by the initiator. The only instance in which it may be seen on the wire is in a target-initiated NOP-In PDU (Section 11.19) and in the initiator response to that PDU, if necessary. MFC after: 1 month --- sys/dev/iscsi/iscsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index f0ba48fa7a67..0c891a32feea 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -2194,6 +2194,8 @@ iscsi_action_abort(struct iscsi_session *is, union ccb *ccb) } initiator_task_tag = is->is_initiator_task_tag++; + if (initiator_task_tag == 0xffffffff) + initiator_task_tag = is->is_initiator_task_tag++; io = iscsi_outstanding_add(is, request, NULL, &initiator_task_tag); if (io == NULL) { @@ -2254,6 +2256,9 @@ iscsi_action_scsiio(struct iscsi_session *is, union ccb *ccb) } initiator_task_tag = is->is_initiator_task_tag++; + if (initiator_task_tag == 0xffffffff) + initiator_task_tag = is->is_initiator_task_tag++; + io = iscsi_outstanding_add(is, request, ccb, &initiator_task_tag); if (io == NULL) { icl_pdu_free(request); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:47: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 D9A7155561F; Tue, 23 Feb 2021 00:47: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 4Dl0kT5ctKz3KHv; Tue, 23 Feb 2021 00:47: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 A15917A20; Tue, 23 Feb 2021 00:47: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 11N0lDJ5076424; Tue, 23 Feb 2021 00:47:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0lDTD076423; Tue, 23 Feb 2021 00:47:13 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:47:13 GMT Message-Id: <202102230047.11N0lDTD076423@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: d7296b893969 - releng/13.0 - cxgbe(4): Save proper zone index on low memory in refill_fl(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: d7296b893969c3e77df8bdd001b008050d974c11 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, 23 Feb 2021 00:47:13 -0000 The branch releng/13.0 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=d7296b893969c3e77df8bdd001b008050d974c11 commit d7296b893969c3e77df8bdd001b008050d974c11 Author: Alexander Motin AuthorDate: 2021-02-17 02:15:28 +0000 Commit: Navdeep Parhar CommitDate: 2021-02-23 00:46:10 +0000 cxgbe(4): Save proper zone index on low memory in refill_fl(). When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it falls back to safe (4KB) ones. But it still saved into sd->zidx the original fl->zidx instead of fl->safe_zidx. It caused problems with the later use of that cluster, including memory and/or data corruption. While there, make refill_fl() to use the safe zone for all following clusters for the call, since it is unlikely that large succeed. Approved by: re@ (gjb@) Sponsored by: iXsystems, Inc. Reviewed by: np, jhb Differential Revision: https://reviews.freebsd.org/D28716 (cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8) (cherry picked from commit c930816b76713623ccdef09d682e41266c1d724f) --- sys/dev/cxgbe/t4_sge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 45f07358f0db..d16f17c45614 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4524,7 +4524,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) caddr_t cl; struct rx_buf_info *rxb; struct cluster_metadata *clm; - uint16_t max_pidx; + uint16_t max_pidx, zidx = fl->zidx; uint16_t hw_cidx = fl->hw_cidx; /* stable snapshot */ FL_LOCK_ASSERT_OWNED(fl); @@ -4540,6 +4540,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) d = &fl->desc[fl->pidx]; sd = &fl->sdesc[fl->pidx]; + rxb = &sc->sge.rx_buf_info[zidx]; while (n > 0) { @@ -4573,11 +4574,11 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) sd->cl = NULL; /* gave up my reference */ } MPASS(sd->cl == NULL); - rxb = &sc->sge.rx_buf_info[fl->zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); if (__predict_false(cl == NULL)) { - if (fl->zidx != fl->safe_zidx) { - rxb = &sc->sge.rx_buf_info[fl->safe_zidx]; + if (zidx != fl->safe_zidx) { + zidx = fl->safe_zidx; + rxb = &sc->sge.rx_buf_info[zidx]; cl = uma_zalloc(rxb->zone, M_NOWAIT); } if (cl == NULL) @@ -4588,7 +4589,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) pa = pmap_kextract((vm_offset_t)cl); sd->cl = cl; - sd->zidx = fl->zidx; + sd->zidx = zidx; if (fl->flags & FL_BUF_PACKING) { *d = htobe64(pa | rxb->hwidx2); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:55: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 DBBFE555954; Tue, 23 Feb 2021 00:55: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 4Dl0wL5qH3z3M0v; Tue, 23 Feb 2021 00:55: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 BAC7A7C5E; Tue, 23 Feb 2021 00:55: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 11N0tkH8089681; Tue, 23 Feb 2021 00:55:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0tkh6089680; Tue, 23 Feb 2021 00:55:46 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:55:46 GMT Message-Id: <202102230055.11N0tkh6089680@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: ab3e1bd3c22a - stable/13 - xen-blkback: fix leak of grant maps on ring setup failure 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: ab3e1bd3c22a222520c23c2793cc39e3a23c9b46 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, 23 Feb 2021 00:55:46 -0000 The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ab3e1bd3c22a222520c23c2793cc39e3a23c9b46 commit ab3e1bd3c22a222520c23c2793cc39e3a23c9b46 Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Ed Maste CommitDate: 2021-02-23 00:55:14 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 762f25302c00..678472cc2ab8 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2893,10 +2893,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:57: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 AD6CB555AF2; Tue, 23 Feb 2021 00:57: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 4Dl0yH4Q4Nz3MC0; Tue, 23 Feb 2021 00:57: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 8A48E7B30; Tue, 23 Feb 2021 00:57: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 11N0vRJu090057; Tue, 23 Feb 2021 00:57:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0vRh7090056; Tue, 23 Feb 2021 00:57:27 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:57:27 GMT Message-Id: <202102230057.11N0vRh7090056@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: dfb372f5d38c - stable/12 - xen-blkback: fix leak of grant maps on ring setup failure 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: dfb372f5d38c302953a6a4e2838179cd0a1a6438 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, 23 Feb 2021 00:57:27 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=dfb372f5d38c302953a6a4e2838179cd0a1a6438 commit dfb372f5d38c302953a6a4e2838179cd0a1a6438 Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Ed Maste CommitDate: 2021-02-23 00:57:03 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index d935ba965b00..b98ccb6e2595 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2912,10 +2912,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 00:58: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 1157B555A69; Tue, 23 Feb 2021 00:58: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 4Dl0zH005Rz3MFk; Tue, 23 Feb 2021 00:58: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 E697579E4; Tue, 23 Feb 2021 00:58: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 11N0wIfk090285; Tue, 23 Feb 2021 00:58:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N0wI2B090284; Tue, 23 Feb 2021 00:58:18 GMT (envelope-from git) Date: Tue, 23 Feb 2021 00:58:18 GMT Message-Id: <202102230058.11N0wI2B090284@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: 89238773a37f - stable/11 - xen-blkback: fix leak of grant maps on ring setup failure 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: 89238773a37f4fc8f0bf3ccca3aa03874478f194 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, 23 Feb 2021 00:58:19 -0000 The branch stable/11 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=89238773a37f4fc8f0bf3ccca3aa03874478f194 commit 89238773a37f4fc8f0bf3ccca3aa03874478f194 Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Ed Maste CommitDate: 2021-02-23 00:57:35 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 4b6eeb0cf62f..5fb5cdbe6ea1 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2911,10 +2911,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 01:30: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 DDBED557246; Tue, 23 Feb 2021 01:30: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 4Dl1hf607mz3QHM; Tue, 23 Feb 2021 01:30: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 C08911044C; Tue, 23 Feb 2021 01:30: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 11N1Ugj5037632; Tue, 23 Feb 2021 01:30:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N1Uges037631; Tue, 23 Feb 2021 01:30:42 GMT (envelope-from git) Date: Tue, 23 Feb 2021 01:30:42 GMT Message-Id: <202102230130.11N1Uges037631@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: 3df2766a6916 - stable/13 - linux: Unmap the VDSO page when unloading 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: 3df2766a691679ac383aabc8409a1a84433c15e6 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, 23 Feb 2021 01:30:42 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3df2766a691679ac383aabc8409a1a84433c15e6 commit 3df2766a691679ac383aabc8409a1a84433c15e6 Author: Mark Johnston AuthorDate: 2021-02-16 14:30:21 +0000 Commit: Mark Johnston CommitDate: 2021-02-23 01:29:55 +0000 linux: Unmap the VDSO page when unloading linux_shared_page_init() creates an object and grabs and maps a single page to back the VDSO. When destroying the VDSO object, we failed to destroy the mapping and free KVA. Fix this. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28696 (cherry picked from commit 0fc8a796722846d0d676548aa0f5cc660199db73) --- sys/amd64/linux/linux_sysvec.c | 3 ++- sys/amd64/linux32/linux32_sysvec.c | 3 ++- sys/arm64/linux/linux_sysvec.c | 3 ++- sys/compat/linux/linux_vdso.c | 6 +++++- sys/compat/linux/linux_vdso.h | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index dbfc650a916e..abc750c63682 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -818,7 +818,8 @@ static void linux_vdso_deinstall(void *param) { - __elfN(linux_shared_page_fini)(linux_shared_page_obj); + __elfN(linux_shared_page_fini)(linux_shared_page_obj, + linux_shared_page_mapping); } SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST, linux_vdso_deinstall, NULL); diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index d06a1fb17d9b..bb86baefaec4 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -961,7 +961,8 @@ static void linux_vdso_deinstall(void *param) { - __elfN(linux_shared_page_fini)(linux_shared_page_obj); + __elfN(linux_shared_page_fini)(linux_shared_page_obj, + linux_shared_page_mapping); } SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST, linux_vdso_deinstall, NULL); diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 366fe7c2dc44..1d628ffe6ecb 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -461,7 +461,8 @@ linux_vdso_deinstall(const void *param) { LIN_SDT_PROBE0(sysvec, linux_vdso_deinstall, todo); - __elfN(linux_shared_page_fini)(linux_shared_page_obj); + __elfN(linux_shared_page_fini)(linux_shared_page_obj, + linux_shared_page_mapping); } SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST, linux_vdso_deinstall, NULL); diff --git a/sys/compat/linux/linux_vdso.c b/sys/compat/linux/linux_vdso.c index 096f2e424850..a05c0b01ff40 100644 --- a/sys/compat/linux/linux_vdso.c +++ b/sys/compat/linux/linux_vdso.c @@ -93,9 +93,13 @@ __elfN(linux_shared_page_init)(char **mapping) } void -__elfN(linux_shared_page_fini)(vm_object_t obj) +__elfN(linux_shared_page_fini)(vm_object_t obj, void *mapping) { + vm_offset_t va; + va = (vm_offset_t)mapping; + pmap_qremove(va, 1); + kva_free(va, PAGE_SIZE); vm_object_deallocate(obj); } diff --git a/sys/compat/linux/linux_vdso.h b/sys/compat/linux/linux_vdso.h index 542efef9cb82..073c51696387 100644 --- a/sys/compat/linux/linux_vdso.h +++ b/sys/compat/linux/linux_vdso.h @@ -39,7 +39,7 @@ struct linux_vdso_sym { }; vm_object_t __elfN(linux_shared_page_init)(char **); -void __elfN(linux_shared_page_fini)(vm_object_t); +void __elfN(linux_shared_page_fini)(vm_object_t, void *); void __elfN(linux_vdso_fixup)(struct sysentvec *); void __elfN(linux_vdso_reloc)(struct sysentvec *); void __elfN(linux_vdso_sym_init)(struct linux_vdso_sym *); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 01:30: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 40A2D557415; Tue, 23 Feb 2021 01:30: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 4Dl1hg6fq9z3QDy; Tue, 23 Feb 2021 01:30: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 D738510668; Tue, 23 Feb 2021 01:30: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 11N1UhVb037654; Tue, 23 Feb 2021 01:30:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N1Uh1w037653; Tue, 23 Feb 2021 01:30:43 GMT (envelope-from git) Date: Tue, 23 Feb 2021 01:30:43 GMT Message-Id: <202102230130.11N1Uh1w037653@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: ddfa5b011ca6 - stable/13 - linux: Update the i386/linux vdso deinitialization routine 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: ddfa5b011ca665711fa11926715614c993ee110d 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, 23 Feb 2021 01:30:44 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ddfa5b011ca665711fa11926715614c993ee110d commit ddfa5b011ca665711fa11926715614c993ee110d Author: Mark Johnston AuthorDate: 2021-02-16 22:06:20 +0000 Commit: Mark Johnston CommitDate: 2021-02-23 01:30:01 +0000 linux: Update the i386/linux vdso deinitialization routine This was missed in commit 0fc8a796722 ("linux: Unmap the VDSO page when unloading"). Reported by: Mark Millard MFC with: 0fc8a796722 (cherry picked from commit aa5fef60bf663d31cddf53d7a8c6856d5e4672c0) --- sys/i386/linux/linux_sysvec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 10229d8af57e..ef845675aaa4 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -938,7 +938,8 @@ static void linux_vdso_deinstall(void *param) { - __elfN(linux_shared_page_fini)(linux_shared_page_obj); + __elfN(linux_shared_page_fini)(linux_shared_page_obj, + linux_shared_page_mapping); } SYSUNINIT(elf_linux_vdso_uninit, SI_SUB_EXEC, SI_ORDER_FIRST, linux_vdso_deinstall, NULL); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 07:27: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 77C9F56005B; Tue, 23 Feb 2021 07:27: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 4Dl9cF2w8Yz4XX7; Tue, 23 Feb 2021 07:27: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 56D4614FF2; Tue, 23 Feb 2021 07:27: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 11N7RPvE004195; Tue, 23 Feb 2021 07:27:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N7RP9Y004194; Tue, 23 Feb 2021 07:27:25 GMT (envelope-from git) Date: Tue, 23 Feb 2021 07:27:25 GMT Message-Id: <202102230727.11N7RP9Y004194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: b7f1582221f5 - stable/13 - loader: start kernel in text mode when there is no vbefb vt driver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7f1582221f5259f75564886355ce4106eafd081 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, 23 Feb 2021 07:27:25 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=b7f1582221f5259f75564886355ce4106eafd081 commit b7f1582221f5259f75564886355ce4106eafd081 Author: Toomas Soome AuthorDate: 2021-01-26 22:47:56 +0000 Commit: Toomas Soome CommitDate: 2021-02-21 20:31:38 +0000 loader: start kernel in text mode when there is no vbefb vt driver If kernel is built without VT vbefb driver, make sure we start kernel in text mode. (cherry picked from commit 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd) --- stand/common/gfx_fb.h | 1 + stand/common/load_elf.c | 63 ++++++++++++++++++++++++++++++++++++------- stand/i386/libi386/bootinfo.c | 10 +++++++ stand/loader.mk | 9 +++++++ 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index c62c6441f8ad..04076a2c6d38 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -216,6 +216,7 @@ typedef struct teken_gfx { struct gen_fb tg_fb; teken_funcs_t *tg_functions; void *tg_private; + bool tg_kernel_supported; /* Loaded kernel is supported */ } teken_gfx_t; extern font_list_t fonts; diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index cb542718fe2f..62fdb560ecff 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #define FREEBSD_ELF #include +#include #include "bootstrap.h" @@ -84,12 +85,14 @@ typedef struct elf_file { static int __elfN(loadimage)(struct preloaded_file *mp, elf_file_t ef, uint64_t loadaddr); -static int __elfN(lookup_symbol)(struct preloaded_file *mp, elf_file_t ef, - const char* name, Elf_Sym* sym); +static int __elfN(lookup_symbol)(elf_file_t ef, const char* name, + Elf_Sym *sym, unsigned char type); static int __elfN(reloc_ptr)(struct preloaded_file *mp, elf_file_t ef, Elf_Addr p, void *val, size_t len); static int __elfN(parse_modmetadata)(struct preloaded_file *mp, elf_file_t ef, Elf_Addr p_start, Elf_Addr p_end); +static bool __elfN(parse_vt_drv_set)(struct preloaded_file *mp, elf_file_t ef, + Elf_Addr p_start, Elf_Addr p_end); static symaddr_fn __elfN(symaddr); static char *fake_modname(const char *name); @@ -872,12 +875,24 @@ nosyms: ef->buckets = ef->hashtab + 2; ef->chains = ef->buckets + ef->nbuckets; - if (__elfN(lookup_symbol)(fp, ef, "__start_set_modmetadata_set", - &sym) != 0) + gfx_state.tg_kernel_supported = false; + if (__elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, + STT_NOTYPE) == 0) { + p_start = sym.st_value + ef->off; + if (__elfN(lookup_symbol)(ef, "__stop_set_vt_drv_set", &sym, + STT_NOTYPE) == 0) { + p_end = sym.st_value + ef->off; + gfx_state.tg_kernel_supported = + __elfN(parse_vt_drv_set)(fp, ef, p_start, p_end); + } + } + + if (__elfN(lookup_symbol)(ef, "__start_set_modmetadata_set", &sym, + STT_NOTYPE) != 0) return 0; p_start = sym.st_value + ef->off; - if (__elfN(lookup_symbol)(fp, ef, "__stop_set_modmetadata_set", - &sym) != 0) + if (__elfN(lookup_symbol)(ef, "__stop_set_modmetadata_set", &sym, + STT_NOTYPE) != 0) return ENOENT; p_end = sym.st_value + ef->off; @@ -1072,6 +1087,36 @@ out: return (err); } +/* + * Walk through vt_drv_set, each vt driver structure starts with + * static 16 chars for driver name. If we have "vbefb", return true. + */ +static bool +__elfN(parse_vt_drv_set)(struct preloaded_file *fp, elf_file_t ef, + Elf_Addr p_start, Elf_Addr p_end) +{ + Elf_Addr v, p; + char vd_name[16]; + int error; + + p = p_start; + while (p < p_end) { + COPYOUT(p, &v, sizeof(v)); + + error = __elfN(reloc_ptr)(fp, ef, p, &v, sizeof(v)); + if (error == EOPNOTSUPP) + v += ef->off; + else if (error != 0) + return (false); + COPYOUT(v, &vd_name, sizeof(vd_name)); + if (strncmp(vd_name, "vbefb", sizeof(vd_name)) == 0) + return (true); + p += sizeof(Elf_Addr); + } + + return (false); +} + int __elfN(parse_modmetadata)(struct preloaded_file *fp, elf_file_t ef, Elf_Addr p_start, Elf_Addr p_end) @@ -1185,8 +1230,8 @@ elf_hash(const char *name) static const char __elfN(bad_symtable)[] = "elf" __XSTRING(__ELF_WORD_SIZE) "_lookup_symbol: corrupt symbol table\n"; int -__elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, - const char* name, Elf_Sym *symp) +__elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, + unsigned char type) { Elf_Hashelt symnum; Elf_Sym sym; @@ -1213,7 +1258,7 @@ __elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, free(strp); if (sym.st_shndx != SHN_UNDEF || (sym.st_value != 0 && - ELF_ST_TYPE(sym.st_info) == STT_FUNC)) { + ELF_ST_TYPE(sym.st_info) == type)) { *symp = sym; return 0; } diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c index 71e07cfb9702..57f926b76589 100644 --- a/stand/i386/libi386/bootinfo.c +++ b/stand/i386/libi386/bootinfo.c @@ -41,6 +41,16 @@ __FBSDID("$FreeBSD$"); void bi_load_vbe_data(struct preloaded_file *kfp) { + if (!gfx_state.tg_kernel_supported) { + /* + * Loaded kernel does not have vt/vbe backend, + * switch console to text mode. + */ + if (vbe_available()) + bios_set_text_mode(VGA_TEXT_MODE); + return; + } + if (vbe_available()) { file_addmetadata(kfp, MODINFOMD_VBE_FB, sizeof(gfx_state.tg_fb), &gfx_state.tg_fb); diff --git a/stand/loader.mk b/stand/loader.mk index cde7a31dca7e..3a38a9bc9e63 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -17,23 +17,32 @@ CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib .if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "aarch64" SRCS+= load_elf64.c reloc_elf64.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "powerpc" SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_ARCH:Mmips64*} != "" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE} == "mips" SRCS+= load_elf32.c reloc_elf32.c SRCS+= metadata.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "riscv" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .endif .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 07:27: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 3DDB6560323; Tue, 23 Feb 2021 07:27: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 4Dl9cX1Bdsz4XsX; Tue, 23 Feb 2021 07:27: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 1C09E15154; Tue, 23 Feb 2021 07:27: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 11N7RedH004343; Tue, 23 Feb 2021 07:27:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N7RefG004342; Tue, 23 Feb 2021 07:27:40 GMT (envelope-from git) Date: Tue, 23 Feb 2021 07:27:40 GMT Message-Id: <202102230727.11N7RefG004342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 1714029b8a9c - stable/13 - Fix loader detection of vbefb support on !amd64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1714029b8a9c069f2f35f5c4ec2df453f0fd3f08 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, 23 Feb 2021 07:27:40 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=1714029b8a9c069f2f35f5c4ec2df453f0fd3f08 commit 1714029b8a9c069f2f35f5c4ec2df453f0fd3f08 Author: Dimitry Andric AuthorDate: 2021-01-27 21:28:43 +0000 Commit: Toomas Soome CommitDate: 2021-02-21 20:31:56 +0000 Fix loader detection of vbefb support on !amd64 On i386, after 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd, the vbefb vt driver was no longer detected by the loader, if any kernel module was loaded after the kernel itself. This was caused by the parse_vt_drv_set() function being called multiple times, resetting the detection flag. (It was called multiple times, becuase i386 .ko files are shared objects like the kernel proper, while this is not the case on amd64.) Fix this by skipping the set_vt_drv_set lookup if vbefb was already detected. Reviewed by: tsoome (cherry picked from commit 6e26189be406a9a3799074b16925e6cd63cc703b) --- stand/common/load_elf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 62fdb560ecff..8bb780ef34df 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -875,8 +875,8 @@ nosyms: ef->buckets = ef->hashtab + 2; ef->chains = ef->buckets + ef->nbuckets; - gfx_state.tg_kernel_supported = false; - if (__elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, + if (!gfx_state.tg_kernel_supported && + __elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, STT_NOTYPE) == 0) { p_start = sym.st_value + ef->off; if (__elfN(lookup_symbol)(ef, "__stop_set_vt_drv_set", &sym, From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 07:27:59 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CFB755601D9; Tue, 23 Feb 2021 07:27:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dl9cv43gnz4XWV; Tue, 23 Feb 2021 07:27:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E4F414FF3; Tue, 23 Feb 2021 07:27:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11N7Rxa7004509; Tue, 23 Feb 2021 07:27:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N7RxHg004508; Tue, 23 Feb 2021 07:27:59 GMT (envelope-from git) Date: Tue, 23 Feb 2021 07:27:59 GMT Message-Id: <202102230727.11N7RxHg004508@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: debcf835b16b - stable/13 - loader: unload command should reset tg_kernel_supported in gfx_state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: debcf835b16be30b51ec8bc0951ec0af79036074 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, 23 Feb 2021 07:27:59 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=debcf835b16be30b51ec8bc0951ec0af79036074 commit debcf835b16be30b51ec8bc0951ec0af79036074 Author: Toomas Soome AuthorDate: 2021-01-28 07:45:47 +0000 Commit: Toomas Soome CommitDate: 2021-02-21 20:32:14 +0000 loader: unload command should reset tg_kernel_supported in gfx_state While loading kernel, we check if vt/vbe backend support is included in kernel and set the tg_kernel_supported flag in gfx_state. unload command needs to reset this flag to allow next load to perform this check with new kernel. Reported by: jhb (cherry picked from commit 9b388ac30375ad4e0259b264a006753edcb2bd3c) --- stand/common/module.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stand/common/module.c b/stand/common/module.c index 247fc54b6021..34ffc10cded3 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -271,6 +271,8 @@ unload(void) } loadaddr = 0; unsetenv("kernelname"); + /* Reset tg_kernel_supported to allow next load to check it again. */ + gfx_state.tg_kernel_supported = false; } COMMAND_SET(unload, "unload", "unload all modules", command_unload); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 09:09: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 145E35632F8; Tue, 23 Feb 2021 09:09: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 4DlCtR06fyz4fVb; Tue, 23 Feb 2021 09:09: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 EB1EF16857; Tue, 23 Feb 2021 09:09:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11N99oEZ036512; Tue, 23 Feb 2021 09:09:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11N99ogG036511; Tue, 23 Feb 2021 09:09:50 GMT (envelope-from git) Date: Tue, 23 Feb 2021 09:09:50 GMT Message-Id: <202102230909.11N99ogG036511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1c23f70aeb29 - stable/13 - pgcache read: protect against reads past end of the vm object size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1c23f70aeb299e672a4fc483c45c721548ae1047 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, 23 Feb 2021 09:09:51 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1c23f70aeb299e672a4fc483c45c721548ae1047 commit 1c23f70aeb299e672a4fc483c45c721548ae1047 Author: Konstantin Belousov AuthorDate: 2021-02-15 03:34:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-23 08:50:22 +0000 pgcache read: protect against reads past end of the vm object size PR: 253158 (cherry picked from commit c61fae1475f1864dc4bba667b642f279afd44855) --- sys/kern/vfs_vnops.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6c6727c7f372..1e52a797a1f7 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -951,6 +951,10 @@ vn_read_from_obj(struct vnode *vp, struct uio *uio) #else vsz = atomic_load_64(&obj->un_pager.vnp.vnp_size); #endif + if (uio->uio_offset >= vsz) { + error = EJUSTRETURN; + goto out; + } if (uio->uio_offset + resid > vsz) resid = vsz - uio->uio_offset; From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 11:25: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 8827A5678BA; Tue, 23 Feb 2021 11:25: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 4DlGvW3PTDz4qMn; Tue, 23 Feb 2021 11:25: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 67CA718820; Tue, 23 Feb 2021 11:25:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11NBPxY8020047; Tue, 23 Feb 2021 11:25:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NBPxso020046; Tue, 23 Feb 2021 11:25:59 GMT (envelope-from git) Date: Tue, 23 Feb 2021 11:25:59 GMT Message-Id: <202102231125.11NBPxso020046@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4b737a9c58ca - releng/13.0 - pgcache read: protect against reads past end of the vm object size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 4b737a9c58cac69008f189cc44e7d1a81a0b601c 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, 23 Feb 2021 11:25:59 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4b737a9c58cac69008f189cc44e7d1a81a0b601c commit 4b737a9c58cac69008f189cc44e7d1a81a0b601c Author: Konstantin Belousov AuthorDate: 2021-02-15 03:34:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-23 11:21:00 +0000 pgcache read: protect against reads past end of the vm object size PR: 253158 Approved by: re (gjb) (cherry picked from commit c61fae1475f1864dc4bba667b642f279afd44855) --- sys/kern/vfs_vnops.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6c6727c7f372..1e52a797a1f7 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -951,6 +951,10 @@ vn_read_from_obj(struct vnode *vp, struct uio *uio) #else vsz = atomic_load_64(&obj->un_pager.vnp.vnp_size); #endif + if (uio->uio_offset >= vsz) { + error = EJUSTRETURN; + goto out; + } if (uio->uio_offset + resid > vsz) resid = vsz - uio->uio_offset; From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 11:50:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8103D567E76; Tue, 23 Feb 2021 11:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlHRy3GtFz4rvQ; Tue, 23 Feb 2021 11:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6364F18BD4; Tue, 23 Feb 2021 11:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11NBoc6X054543; Tue, 23 Feb 2021 11:50:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NBoc2f054542; Tue, 23 Feb 2021 11:50:38 GMT (envelope-from git) Date: Tue, 23 Feb 2021 11:50:38 GMT Message-Id: <202102231150.11NBoc2f054542@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: 5d3b3e47a68b - stable/13 - pf: duplicate frames only once when using dup-to pf rule MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5d3b3e47a68bf16b054add5f696d80789d1cb738 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, 23 Feb 2021 11:50:38 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5d3b3e47a68bf16b054add5f696d80789d1cb738 commit 5d3b3e47a68bf16b054add5f696d80789d1cb738 Author: Yannis Planus AuthorDate: 2021-01-28 13:59:07 +0000 Commit: Kristof Provost CommitDate: 2021-02-23 11:46:24 +0000 pf: duplicate frames only once when using dup-to pf rule When using DUP-TO rule, frames are duplicated 3 times on both output interfaces and duplication interface. Add a flag to not duplicate a duplicated frame. Inspired by a patch from Miłosz Kaniewski milosz.kaniewski at gmail.com https://lists.freebsd.org/pipermail/freebsd-pf/2015-November/007886.html Reviewed by: kp@ Differential Revision: https://reviews.freebsd.org/D27018 (cherry picked from commit 0c458752ceee14818034df7bfcdfb04129dceeda) --- sys/netpfil/pf/pf.c | 50 ++++++++++++++++++++++++++++++++++++++++++------ sys/netpfil/pf/pf_mtag.h | 1 + 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 4cccb0101650..86354e69d11f 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5488,10 +5488,29 @@ pf_route(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, } if (r->rt == PF_DUPTO) { - if ((m0 = m_dup(*m, M_NOWAIT)) == NULL) { - if (s) + if ((pd->pf_mtag->flags & PF_DUPLICATED)) { + if (s == NULL) { + ifp = r->rpool.cur->kif ? + r->rpool.cur->kif->pfik_ifp : NULL; + } else { + ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL; PF_STATE_UNLOCK(s); - return; + } + if (ifp == oifp) { + /* When the 2nd interface is not skipped */ + return; + } else { + m0 = *m; + *m = NULL; + goto bad; + } + } else { + pd->pf_mtag->flags |= PF_DUPLICATED; + if (((m0 = m_dup(*m, M_NOWAIT)) == NULL)) { + if (s) + PF_STATE_UNLOCK(s); + return; + } } } else { if ((r->rt == PF_REPLYTO) == (r->direction == dir)) { @@ -5649,10 +5668,29 @@ pf_route6(struct mbuf **m, struct pf_krule *r, int dir, struct ifnet *oifp, } if (r->rt == PF_DUPTO) { - if ((m0 = m_dup(*m, M_NOWAIT)) == NULL) { - if (s) + if ((pd->pf_mtag->flags & PF_DUPLICATED)) { + if (s == NULL) { + ifp = r->rpool.cur->kif ? + r->rpool.cur->kif->pfik_ifp : NULL; + } else { + ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL; PF_STATE_UNLOCK(s); - return; + } + if (ifp == oifp) { + /* When the 2nd interface is not skipped */ + return; + } else { + m0 = *m; + *m = NULL; + goto bad; + } + } else { + pd->pf_mtag->flags |= PF_DUPLICATED; + if (((m0 = m_dup(*m, M_NOWAIT)) == NULL)) { + if (s) + PF_STATE_UNLOCK(s); + return; + } } } else { if ((r->rt == PF_REPLYTO) == (r->direction == dir)) { diff --git a/sys/netpfil/pf/pf_mtag.h b/sys/netpfil/pf/pf_mtag.h index 67c79350e8eb..ad28ab7a7c30 100644 --- a/sys/netpfil/pf/pf_mtag.h +++ b/sys/netpfil/pf/pf_mtag.h @@ -42,6 +42,7 @@ #define PF_PACKET_LOOPED 0x08 #define PF_FASTFWD_OURS_PRESENT 0x10 #define PF_REASSEMBLED 0x20 +#define PF_DUPLICATED 0x40 struct pf_mtag { void *hdr; /* saved hdr pos in mbuf, for ECN */ From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 11:50: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 E3838540160; Tue, 23 Feb 2021 11:50: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 4DlHS05t6Qz4rvS; Tue, 23 Feb 2021 11:50: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 A5E5618D09; Tue, 23 Feb 2021 11:50: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 11NBoedY054587; Tue, 23 Feb 2021 11:50:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NBoe3Z054586; Tue, 23 Feb 2021 11:50:40 GMT (envelope-from git) Date: Tue, 23 Feb 2021 11:50:40 GMT Message-Id: <202102231150.11NBoe3Z054586@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: 04535d6a572a - stable/13 - pf tests: Test unicast reverse path forwarding check 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: 04535d6a572ac63b448a5def4525947bd00d9f8a 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, 23 Feb 2021 11:50:41 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=04535d6a572ac63b448a5def4525947bd00d9f8a commit 04535d6a572ac63b448a5def4525947bd00d9f8a Author: Kristof Provost AuthorDate: 2021-02-15 21:16:36 +0000 Commit: Kristof Provost CommitDate: 2021-02-23 11:46:25 +0000 pf tests: Test unicast reverse path forwarding check Ensure that pf's urpf-failed keyword works as expected. PR: 253479 MFC after: 1 week Reviewed by: melifaro@ Differential Revision: https://reviews.freebsd.org/D28694 (cherry picked from commit 6b52139eb8e8eda0ea263b24735556194f918642) --- tests/sys/netpfil/common/pft_ping.py | 52 ++++++++++++++++++++++++++++ tests/sys/netpfil/pf/pass_block.sh | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/tests/sys/netpfil/common/pft_ping.py b/tests/sys/netpfil/common/pft_ping.py index 812250803309..957123e4f6f8 100644 --- a/tests/sys/netpfil/common/pft_ping.py +++ b/tests/sys/netpfil/common/pft_ping.py @@ -115,6 +115,35 @@ def check_ping6_request(args, packet): return True +def check_ping_reply(args, packet): + return check_ping4_reply(args, packet) + +def check_ping4_reply(args, packet): + """ + Check that this is a reply to the ping request we sent + """ + dst_ip = args.to[0] + + ip = packet.getlayer(sp.IP) + if not ip: + return False + if ip.src != dst_ip: + return False + + icmp = packet.getlayer(sp.ICMP) + if not icmp: + return False + if sp.icmptypes[icmp.type] != 'echo-reply': + return False + + raw = packet.getlayer(sp.Raw) + if not raw: + return False + if raw.load != PAYLOAD_MAGIC: + return False + + return True + def ping(send_if, dst_ip, args): ether = sp.Ether() ip = sp.IP(dst=dst_ip) @@ -124,6 +153,9 @@ def ping(send_if, dst_ip, args): if args.send_tos: ip.tos = int(args.send_tos[0]) + if args.fromaddr: + ip.src = args.fromaddr[0] + req = ether / ip / icmp / raw sp.sendp(req, iface=send_if, verbose=False) @@ -132,6 +164,9 @@ def ping6(send_if, dst_ip, args): ip6 = sp.IPv6(dst=dst_ip) icmp = sp.ICMPv6EchoRequest(data=sp.raw(PAYLOAD_MAGIC)) + if args.fromaddr: + ip.src = args.fromaddr[0] + req = ether / ip6 / icmp sp.sendp(req, iface=send_if, verbose=False) @@ -189,6 +224,8 @@ def main(): required=True, help='The interface through which the packet(s) will be sent') parser.add_argument('--recvif', nargs=1, + help='The interface on which to expect the ICMP echo request') + parser.add_argument('--replyif', nargs=1, help='The interface on which to expect the ICMP echo response') parser.add_argument('--checkdup', nargs=1, help='The interface on which to expect the duplicated ICMP packets') @@ -197,6 +234,8 @@ def main(): parser.add_argument('--to', nargs=1, required=True, help='The destination IP address for the ICMP echo request') + parser.add_argument('--fromaddr', nargs=1, + help='The source IP address for the ICMP echo request') # TCP options parser.add_argument('--tcpsyn', action='store_true', @@ -225,6 +264,11 @@ def main(): sniffer = Sniffer(args, checkfn) + replysniffer = None + if not args.replyif is None: + checkfn=check_ping_reply + replysniffer = Sniffer(args, checkfn, recvif=args.replyif[0]) + dupsniffer = None if args.checkdup is not None: dupsniffer = Sniffer(args, check_dup, recvif=args.checkdup[0]) @@ -250,5 +294,13 @@ def main(): else: sys.exit(1) + if replysniffer: + replysniffer.join() + + if replysniffer.foundCorrectPacket: + sys.exit(0) + else: + sys.exit(1) + if __name__ == '__main__': main() diff --git a/tests/sys/netpfil/pf/pass_block.sh b/tests/sys/netpfil/pf/pass_block.sh index 139adb43bddd..589b89891729 100644 --- a/tests/sys/netpfil/pf/pass_block.sh +++ b/tests/sys/netpfil/pf/pass_block.sh @@ -27,6 +27,8 @@ . $(atf_get_srcdir)/utils.subr +common_dir=$(atf_get_srcdir)/../common + atf_test_case "v4" "cleanup" v4_head() { @@ -189,10 +191,75 @@ nested_inline_cleanup() pft_cleanup } +atf_test_case "urpf" "cleanup" +urpf_head() +{ + atf_set descr "Test unicast reverse path forwarding check" + atf_set require.user root + atf_set require.progs scapy +} + +urpf_body() +{ + pft_init + + epair_one=$(vnet_mkepair) + epair_two=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair_one}b ${epair_two}b + + ifconfig ${epair_one}a 192.0.2.2/24 up + ifconfig ${epair_two}a 198.51.100.2/24 up + + jexec alcatraz ifconfig ${epair_one}b 192.0.2.1/24 up + jexec alcatraz ifconfig ${epair_two}b 198.51.100.1/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + + # Sanity checks + atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.1 + atf_check -s exit:0 -o ignore ping -c 1 -t 1 198.51.100.1 + atf_check -s exit:0 ${common_dir}/pft_ping.py \ + --sendif ${epair_one}a \ + --to 192.0.2.1 \ + --fromaddr 198.51.100.2 \ + --replyif ${epair_two}a + atf_check -s exit:0 ${common_dir}/pft_ping.py \ + --sendif ${epair_two}a \ + --to 198.51.100.1 \ + --fromaddr 192.0.2.2 \ + --replyif ${epair_one}a + + pft_set_rules alcatraz \ + "block quick from urpf-failed" + jexec alcatraz pfctl -e + + # Correct source still works + atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.1 + atf_check -s exit:0 -o ignore ping -c 1 -t 1 198.51.100.1 + + # Unexpected source interface is blocked + atf_check -s exit:1 ${common_dir}/pft_ping.py \ + --sendif ${epair_one}a \ + --to 192.0.2.1 \ + --fromaddr 198.51.100.2 \ + --replyif ${epair_two}a + atf_check -s exit:1 ${common_dir}/pft_ping.py \ + --sendif ${epair_two}a \ + --to 198.51.100.1 \ + --fromaddr 192.0.2.2 \ + --replyif ${epair_one}a +} + +urpf_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "v6" atf_add_test_case "noalias" atf_add_test_case "nested_inline" + atf_add_test_case "urpf" } From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 11:50:39 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 A1BBD54033F; Tue, 23 Feb 2021 11:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlHRz4FKfz4rxs; Tue, 23 Feb 2021 11:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8534C18D07; Tue, 23 Feb 2021 11:50:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11NBodis054565; Tue, 23 Feb 2021 11:50:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NBodLL054564; Tue, 23 Feb 2021 11:50:39 GMT (envelope-from git) Date: Tue, 23 Feb 2021 11:50:39 GMT Message-Id: <202102231150.11NBodLL054564@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: 46b600875685 - stable/13 - pf tests: Test that dup-to doesn't produce extra duplicate packets 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: 46b6008756858eae5bef28fe0fa4d87e8913ab38 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, 23 Feb 2021 11:50:39 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=46b6008756858eae5bef28fe0fa4d87e8913ab38 commit 46b6008756858eae5bef28fe0fa4d87e8913ab38 Author: Kristof Provost AuthorDate: 2021-01-28 10:02:20 +0000 Commit: Kristof Provost CommitDate: 2021-02-23 11:46:25 +0000 pf tests: Test that dup-to doesn't produce extra duplicate packets (cherry picked from commit cd579b6fba46b9f5005358d1e82def7b26703224) --- tests/sys/netpfil/common/pft_ping.py | 32 ++++++++++++++ tests/sys/netpfil/common/sniffer.py | 7 +++- tests/sys/netpfil/pf/Makefile | 1 + tests/sys/netpfil/pf/dup.sh | 81 ++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 2 deletions(-) diff --git a/tests/sys/netpfil/common/pft_ping.py b/tests/sys/netpfil/common/pft_ping.py index d960426e4b42..812250803309 100644 --- a/tests/sys/netpfil/common/pft_ping.py +++ b/tests/sys/netpfil/common/pft_ping.py @@ -34,6 +34,27 @@ from sniffer import Sniffer PAYLOAD_MAGIC = bytes.fromhex('42c0ffee') +dup_found = 0 + +def check_dup(args, packet): + """ + Verify that this is an ICMP packet, and that we only see one + """ + global dup_found + + icmp = packet.getlayer(sp.ICMP) + if not icmp: + return False + + raw = packet.getlayer(sp.Raw) + if not raw: + return False + if raw.load != PAYLOAD_MAGIC: + return False + + dup_found = dup_found + 1 + return False + def check_ping_request(args, packet): if args.ip6: return check_ping6_request(args, packet) @@ -169,6 +190,8 @@ def main(): help='The interface through which the packet(s) will be sent') parser.add_argument('--recvif', nargs=1, help='The interface on which to expect the ICMP echo response') + parser.add_argument('--checkdup', nargs=1, + help='The interface on which to expect the duplicated ICMP packets') parser.add_argument('--ip6', action='store_true', help='Use IPv6') parser.add_argument('--to', nargs=1, @@ -202,6 +225,10 @@ def main(): sniffer = Sniffer(args, checkfn) + dupsniffer = None + if args.checkdup is not None: + dupsniffer = Sniffer(args, check_dup, recvif=args.checkdup[0]) + if args.tcpsyn: tcpsyn(args.sendif[0], args.to[0], args) else: @@ -210,6 +237,11 @@ def main(): else: ping(args.sendif[0], args.to[0], args) + if dupsniffer: + dupsniffer.join() + if dup_found != 1: + sys.exit(1) + if sniffer: sniffer.join() diff --git a/tests/sys/netpfil/common/sniffer.py b/tests/sys/netpfil/common/sniffer.py index 58df32cce276..200ac750dd7f 100644 --- a/tests/sys/netpfil/common/sniffer.py +++ b/tests/sys/netpfil/common/sniffer.py @@ -30,11 +30,14 @@ import threading import scapy.all as sp class Sniffer(threading.Thread): - def __init__(self, args, check_function): + def __init__(self, args, check_function, recvif=None): threading.Thread.__init__(self) self._args = args - self._recvif = args.recvif[0] + if recvif is not None: + self._recvif = recvif + else: + self._recvif = args.recvif[0] self._check_function = check_function self.foundCorrectPacket = False diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 68f54c801297..6b1e34b69a6d 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -7,6 +7,7 @@ TESTS_SUBDIRS+= ioctl ATF_TESTS_SH+= anchor \ checksum \ + dup \ forward \ fragmentation \ icmp \ diff --git a/tests/sys/netpfil/pf/dup.sh b/tests/sys/netpfil/pf/dup.sh new file mode 100644 index 000000000000..7b9a91804e96 --- /dev/null +++ b/tests/sys/netpfil/pf/dup.sh @@ -0,0 +1,81 @@ +# $FreeBSD$ +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Kristof Provost +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +. $(atf_get_srcdir)/utils.subr + +common_dir=$(atf_get_srcdir)/../common + +atf_test_case "dup_to" "cleanup" +do_to_head() +{ + atf_set descr 'dup-to test' + atf_set require.user root +} + +dup_to_body() +{ + pft_init + + epair_send=$(vnet_mkepair) + ifconfig ${epair_send}a 192.0.2.1/24 up + + epair_recv=$(vnet_mkepair) + ifconfig ${epair_recv}a up + + epair_dupto=$(vnet_mkepair) + ifconfig ${epair_dupto}a up + + vnet_mkjail alcatraz ${epair_send}b ${epair_recv}b ${epair_dupto}b + jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up + jexec alcatraz ifconfig ${epair_recv}b 198.51.100.2/24 up + jexec alcatraz ifconfig ${epair_dupto}b 203.0.113.2/24 up + jexec alcatraz sysctl net.inet.ip.forwarding=1 + jexec alcatraz arp -s 198.51.100.3 00:01:02:03:04:05 + jexec alcatraz arp -s 203.0.113.3 01:02:03:04:05:06 + route add -net 198.51.100.0/24 192.0.2.2 + + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "pass out on { ${epair_recv}b } \ + dup-to (${epair_dupto}b 203.0.113.3)" + + atf_check -s exit:0 ${common_dir}/pft_ping.py \ + --sendif ${epair_send}a \ + --to 198.51.100.3 \ + --recv ${epair_recv}a \ + --checkdup ${epair_dupto}a +} + +dup_to_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "dup_to" +} From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 14:35: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 2E575545EA9; Tue, 23 Feb 2021 14:35: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 4DlM6C0jd1z3LT6; Tue, 23 Feb 2021 14:35: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 0B5D01AFAF; Tue, 23 Feb 2021 14:35: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 11NEZUjq070698; Tue, 23 Feb 2021 14:35:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NEZUk2070697; Tue, 23 Feb 2021 14:35:30 GMT (envelope-from git) Date: Tue, 23 Feb 2021 14:35:30 GMT Message-Id: <202102231435.11NEZUk2070697@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 0a223cf980b5 - stable/13 - ddb: fix show devmap output on 32-bit arm MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0a223cf980b5ef8bea726a843fe5a7faf2278330 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, 23 Feb 2021 14:35:31 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=0a223cf980b5ef8bea726a843fe5a7faf2278330 commit 0a223cf980b5ef8bea726a843fe5a7faf2278330 Author: Thomas Skibo AuthorDate: 2021-01-11 20:58:12 +0000 Commit: Mitchell Horne CommitDate: 2021-02-23 14:30:14 +0000 ddb: fix show devmap output on 32-bit arm The output has been broken since 1b6dd6d772ca. Casting to uintmax_t before the call to printf is necessary to ensure that 32-bit addresses are interpreted correctly. PR: 243236 (cherry picked from commit 9976b42b697ce203b1d257b2a6fe64c8a2961645) --- sys/kern/subr_devmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c index 8e07199b7f73..23baceb05129 100644 --- a/sys/kern/subr_devmap.c +++ b/sys/kern/subr_devmap.c @@ -74,7 +74,9 @@ devmap_dump_table(int (*prfunc)(const char *, ...)) prfunc("Static device mappings:\n"); for (pd = devmap_table; pd->pd_size != 0; ++pd) { prfunc(" 0x%08jx - 0x%08jx mapped at VA 0x%08jx\n", - pd->pd_pa, pd->pd_pa + pd->pd_size - 1, pd->pd_va); + (uintmax_t)pd->pd_pa, + (uintmax_t)(pd->pd_pa + pd->pd_size - 1), + (uintmax_t)pd->pd_va); } } From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 14:35: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 49EAC545EAA; Tue, 23 Feb 2021 14:35: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 4DlM6D1QhPz3LWp; Tue, 23 Feb 2021 14:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1D5A81AFB0; Tue, 23 Feb 2021 14:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11NEZWdT070719; Tue, 23 Feb 2021 14:35:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NEZWkL070718; Tue, 23 Feb 2021 14:35:32 GMT (envelope-from git) Date: Tue, 23 Feb 2021 14:35:32 GMT Message-Id: <202102231435.11NEZWkL070718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 007101f87ddf - stable/13 - cgem: improve usage of busdma(9) KPI MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 007101f87ddf679cbcdbff40882a89dbba0e0cf3 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, 23 Feb 2021 14:35:32 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=007101f87ddf679cbcdbff40882a89dbba0e0cf3 commit 007101f87ddf679cbcdbff40882a89dbba0e0cf3 Author: Mitchell Horne AuthorDate: 2021-01-20 15:07:53 +0000 Commit: Mitchell Horne CommitDate: 2021-02-23 14:31:43 +0000 cgem: improve usage of busdma(9) KPI BUS_DMA_NOCACHE should only be used when one needs to guarantee the created mapping has uncached memory attributes, usually as a result of buggy hardware. Normal use cases should pass BUS_DMA_COHERENT, to create an appropriate mapping based on the flags passed to bus_dma_tag_create(). This should have no functional change, since the DMA tags in this driver are created without the BUS_DMA_COHERENT flag. Reported by: mmel Reviewed by: mmel, Thomas Skibo (cherry picked from commit 04d2d2d7fd22bba638ccb5a0b2e0805087a70cd3) --- sys/dev/cadence/if_cgem.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c index 81fc39b831af..0583e846458a 100644 --- a/sys/dev/cadence/if_cgem.c +++ b/sys/dev/cadence/if_cgem.c @@ -443,17 +443,13 @@ cgem_setup_descs(struct cgem_softc *sc) return (err); /* - * Allocate DMA memory in non-cacheable space. We allocate transmit, - * receive and null descriptor queues all at once because the - * hardware only provides one register for the upper 32 bits of - * rx and tx descriptor queues hardware addresses. + * Allocate DMA memory. We allocate transmit, receive and null + * descriptor queues all at once because the hardware only provides + * one register for the upper 32 bits of rx and tx descriptor queues + * hardware addresses. */ err = bus_dmamem_alloc(sc->desc_dma_tag, (void **)&sc->rxring, -#ifdef __arm__ BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, -#else - BUS_DMA_NOWAIT | BUS_DMA_NOCACHE | BUS_DMA_ZERO, -#endif &sc->rxring_dma_map); if (err) return (err); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 21:07: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 4F182552E9C; Tue, 23 Feb 2021 21:07: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 4DlWpk1lnCz4d3v; Tue, 23 Feb 2021 21:07: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 2E4742059D; Tue, 23 Feb 2021 21:07: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 11NL7gkk086281; Tue, 23 Feb 2021 21:07:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NL7giB086280; Tue, 23 Feb 2021 21:07:42 GMT (envelope-from git) Date: Tue, 23 Feb 2021 21:07:42 GMT Message-Id: <202102232107.11NL7giB086280@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 07656628fdbc - stable/13 - ofwfb: fix incorrect colors on powerpc* and add new tunable parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 07656628fdbc813fb10ec6cf819649548fb8303b 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, 23 Feb 2021 21:07:42 -0000 The branch stable/13 has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=07656628fdbc813fb10ec6cf819649548fb8303b commit 07656628fdbc813fb10ec6cf819649548fb8303b Author: Alfredo Dal'Ava Junior AuthorDate: 2021-02-19 06:22:25 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2021-02-24 00:00:56 +0000 ofwfb: fix incorrect colors on powerpc* and add new tunable parameters - Implements little-endian support (powerpc64le) - Adds 'hw.ofwfb.physaddr' kernel parameter so user can manually provide correct address if it's not detected correctly - Adds 'hw.ofwfb.argb32_pixel' so user can set it manually if colors are inverted due to incorrect pixel format (default = 1) - Automatically selects RGBA32 pixel format if NVidia graphic adapter is detected (sets hw.ofwfb.argb32_pixel=0) Machines equipped with NVidia graphic adapters tend to use RGBA32 pixel format. By default ARGB32 pixel format is used, proved to work on machines equipped with ATI graphic adapter and the onboard adapter used on Talos II and Blackbird machines from Raptor Computing Systems. Original patch developed by bdragon Reviewed by: bdragon, luporl MFC after: 3 days Relnotes: yes Differential Revision: https://reviews.freebsd.org/D28604 (cherry picked from commit 50b7c1f530f174be720b83f7e1d13e0fd42c5974) --- sys/dev/vt/hw/ofwfb/ofwfb.c | 165 +++++++++++++++++++++++++++++++++----------- 1 file changed, 123 insertions(+), 42 deletions(-) diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index 833b98b39f78..8a1b7b3688a7 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include struct ofwfb_softc { struct fb_info fb; @@ -55,8 +56,13 @@ struct ofwfb_softc { ihandle_t sc_handle; bus_space_tag_t sc_memt; int iso_palette; + int argb; + int endian_flip; + uint32_t vendor_id; }; +#define PCI_VENDOR_ID_NVIDIA 0x10de + static void ofwfb_initialize(struct vt_device *vd); static vd_probe_t ofwfb_probe; static vd_init_t ofwfb_init; @@ -297,7 +303,6 @@ ofwfb_initialize(struct vt_device *vd) struct ofwfb_softc *sc = vd->vd_softc; int i, err; cell_t retval; - uint32_t oldpix; sc->fb.fb_cmsize = 16; @@ -311,6 +316,10 @@ ofwfb_initialize(struct vt_device *vd) sc->iso_palette = 0; switch (sc->fb.fb_bpp) { case 8: + /* + * No color format issues here, since we are passing the RGB + * components separately to Open Firmware. + */ vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); @@ -330,21 +339,38 @@ ofwfb_initialize(struct vt_device *vd) case 32: /* - * We bypass the usual bus_space_() accessors here, mostly - * for performance reasons. In particular, we don't want - * any barrier operations that may be performed and handle - * endianness slightly different. Figure out the host-view - * endianness of the frame buffer. + * There are two main color formats in use. + * ARGB32 is used mainly on hardware that was designed for + * LE systems, and RGBA32 is used mainly on hardware designed + * for BE systems. + * + * PowerMacs use either, depending on the video card option. + * NVidia cards tend to be RGBA32, and ATI cards tend to be ARGB32. + * + * There is no good way to determine the correct option, as this + * is independent of endian swapping. */ - oldpix = bus_space_read_4(sc->sc_memt, sc->fb.fb_vbase, 0); - bus_space_write_4(sc->sc_memt, sc->fb.fb_vbase, 0, 0xff000000); - if (*(uint8_t *)(sc->fb.fb_vbase) == 0xff) - vt_generate_cons_palette(sc->fb.fb_cmap, - COLOR_FORMAT_RGB, 255, 0, 255, 8, 255, 16); + if (sc->vendor_id == PCI_VENDOR_ID_NVIDIA) + sc->argb = 0; else - vt_generate_cons_palette(sc->fb.fb_cmap, - COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); - bus_space_write_4(sc->sc_memt, sc->fb.fb_vbase, 0, oldpix); + sc->argb = 1; + + TUNABLE_INT_FETCH("hw.ofwfb.argb32_pixel", &sc->argb); + if (sc->endian_flip) { + if (sc->argb) + vt_generate_cons_palette(sc->fb.fb_cmap, + COLOR_FORMAT_RGB, 255, 8, 255, 16, 255, 24); + else + vt_generate_cons_palette(sc->fb.fb_cmap, + COLOR_FORMAT_RGB, 255, 24, 255, 16, 255, 8); + } else { + if (sc->argb) + vt_generate_cons_palette(sc->fb.fb_cmap, + COLOR_FORMAT_RGB, 255, 16, 255, 8, 255, 0); + else + vt_generate_cons_palette(sc->fb.fb_cmap, + COLOR_FORMAT_RGB, 255, 0, 255, 8, 255, 16); + } break; default: @@ -361,8 +387,12 @@ ofwfb_init(struct vt_device *vd) phandle_t chosen; phandle_t node; uint32_t depth, height, width, stride; - uint32_t fb_phys; - int i, len; + uint32_t vendor_id = 0; + cell_t adr[2]; + uint64_t user_phys; + bus_addr_t fb_phys; + bus_size_t fb_phys_size; + int i, j, len; /* Initialize softc */ vd->vd_softc = sc = &ofwfb_conssoftc; @@ -391,6 +421,16 @@ ofwfb_init(struct vt_device *vd) if (strcmp(buf, "display") != 0) return (CN_DEAD); + /* + * Retrieve vendor-id from /chosen parent node, usually pointing to + * video card device. This is used to select pixel format later on + * ofwfb_initialize() + */ + if (OF_getencprop(OF_parent(node), "vendor-id", &vendor_id, + sizeof(vendor_id)) == sizeof(vendor_id)) + sc->vendor_id = vendor_id; + + /* Keep track of the OF node */ sc->sc_node = node; @@ -419,35 +459,69 @@ ofwfb_init(struct vt_device *vd) sizeof(stride)) stride = width*depth/8; + sc->fb.fb_height = height; sc->fb.fb_width = width; sc->fb.fb_stride = stride; sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride; + sc->endian_flip = 0; + +#if defined(__powerpc__) + if (OF_hasprop(node, "little-endian")) { + sc->sc_memt = &bs_le_tag; +#if BYTE_ORDER == BIG_ENDIAN + sc->endian_flip = 1; +#endif + } else if (OF_hasprop(node, "big-endian")) { + sc->sc_memt = &bs_be_tag; +#if BYTE_ORDER == LITTLE_ENDIAN + sc->endian_flip = 1; +#endif + } + else { + /* Assume the framebuffer is in native endian. */ +#if BYTE_ORDER == BIG_ENDIAN + sc->sc_memt = &bs_be_tag; +#else + sc->sc_memt = &bs_le_tag; +#endif + } +#elif defined(__arm__) + sc->sc_memt = fdtbus_bs_tag; +#else + #error Unsupported platform! +#endif + /* * Grab the physical address of the framebuffer, and then map it * into our memory space. If the MMU is not yet up, it will be * remapped for us when relocation turns on. */ - if (OF_getproplen(node, "address") == sizeof(fb_phys)) { - /* XXX We assume #address-cells is 1 at this point. */ - OF_getprop(node, "address", &fb_phys, sizeof(fb_phys)); - - #if defined(__powerpc__) - sc->sc_memt = &bs_be_tag; - bus_space_map(sc->sc_memt, fb_phys, sc->fb.fb_size, - BUS_SPACE_MAP_PREFETCHABLE, &sc->fb.fb_vbase); - #elif defined(__arm__) - sc->sc_memt = fdtbus_bs_tag; - bus_space_map(sc->sc_memt, sc->fb.fb_pbase, sc->fb.fb_size, - BUS_SPACE_MAP_PREFETCHABLE, - (bus_space_handle_t *)&sc->fb.fb_vbase); - #else - #error Unsupported platform! - #endif + user_phys = 0; + TUNABLE_UINT64_FETCH("hw.ofwfb.physaddr", &user_phys); + fb_phys = (bus_addr_t)user_phys; + if (fb_phys) + sc->fb.fb_pbase = (vm_paddr_t)fb_phys; + else if (OF_hasprop(node, "address")) { + + switch (OF_getproplen(node, "address")) { + case 4: + OF_getencprop(node, "address", adr, 4); + fb_phys = adr[0]; + break; + case 8: + OF_getencprop(node, "address", adr, 8); + fb_phys = ((uint64_t)adr[0] << 32) | adr[1]; + break; + default: + /* Bad property? */ + return (CN_DEAD); + } - sc->fb.fb_pbase = fb_phys; + sc->fb.fb_pbase = (vm_paddr_t)fb_phys; } else { +#if defined(__powerpc__) /* * Some IBM systems don't have an address property. Try to * guess the framebuffer region from the assigned addresses. @@ -473,7 +547,7 @@ ofwfb_init(struct vt_device *vd) len = 0; num_pciaddrs = len / sizeof(struct ofw_pci_register); - fb_phys = num_pciaddrs; + j = num_pciaddrs; for (i = 0; i < num_pciaddrs; i++) { /* If it is too small, not the framebuffer */ if (pciaddrs[i].size_lo < sc->fb.fb_stride * height) @@ -484,26 +558,33 @@ ofwfb_init(struct vt_device *vd) continue; /* This could be the framebuffer */ - fb_phys = i; + j = i; /* If it is prefetchable, it certainly is */ if (pciaddrs[i].phys_hi & OFW_PCI_PHYS_HI_PREFETCHABLE) break; } - if (fb_phys == num_pciaddrs) /* No candidates found */ + if (j == num_pciaddrs) /* No candidates found */ return (CN_DEAD); - #if defined(__powerpc__) - OF_decode_addr(node, fb_phys, &sc->sc_memt, &sc->fb.fb_vbase, - NULL); - sc->fb.fb_pbase = sc->fb.fb_vbase & ~DMAP_BASE_ADDRESS; - #else + if (ofw_reg_to_paddr(node, j, &fb_phys, &fb_phys_size, NULL) < 0) + return (CN_DEAD); + + sc->fb.fb_pbase = (vm_paddr_t)fb_phys; +#else /* No ability to interpret assigned-addresses otherwise */ return (CN_DEAD); - #endif +#endif } + if (!sc->fb.fb_pbase) + return (CN_DEAD); + + bus_space_map(sc->sc_memt, sc->fb.fb_pbase, sc->fb.fb_size, + BUS_SPACE_MAP_PREFETCHABLE, + (bus_space_handle_t *)&sc->fb.fb_vbase); + #if defined(__powerpc__) /* * If we are running on PowerPC in real mode (supported only on AIM From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 22:44: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 7895755673A; Tue, 23 Feb 2021 22:44: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 4DlYxt1X9kz4mjG; Tue, 23 Feb 2021 22:44: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 2363F219BC; Tue, 23 Feb 2021 22:44: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 11NMi2Xv017735; Tue, 23 Feb 2021 22:44:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NMi2Pa017734; Tue, 23 Feb 2021 22:44:02 GMT (envelope-from git) Date: Tue, 23 Feb 2021 22:44:02 GMT Message-Id: <202102232244.11NMi2Pa017734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: ea10694336b9 - stable/13 - Fix nd6 rib_action() handling. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ea10694336b9a07d58d22187052291976f4906b2 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, 23 Feb 2021 22:44:02 -0000 The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=ea10694336b9a07d58d22187052291976f4906b2 commit ea10694336b9a07d58d22187052291976f4906b2 Author: Alexander V. Chernikov AuthorDate: 2021-02-23 22:31:07 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-02-23 22:42:28 +0000 Fix nd6 rib_action() handling. rib_action() guarantees valid rc filling IFF it returns without error. Check rib_action() return code instead of checking rc fields. PR: 253800 Reported by: Frederic Denis (cherry picked from commit 9c4a8d24f0ffd5243fa5c6fe27178f669f16d1f5) --- sys/netinet6/nd6_rtr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index eca704dc2843..51b831a956bc 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -698,12 +698,11 @@ defrouter_addreq(struct nd_defrouter *new) NET_EPOCH_ASSERT(); error = rib_action(fibnum, RTM_ADD, &info, &rc); - if (rc.rc_rt != NULL) { + if (error == 0) { struct nhop_object *nh = nhop_select(rc.rc_nh_new, 0); rt_routemsg(RTM_ADD, rc.rc_rt, nh, fibnum); - } - if (error == 0) new->installed = 1; + } } /* @@ -719,6 +718,7 @@ defrouter_delreq(struct nd_defrouter *dr) struct rib_cmd_info rc; struct epoch_tracker et; unsigned int fibnum; + int error; bzero(&def, sizeof(def)); bzero(&mask, sizeof(mask)); @@ -737,8 +737,8 @@ defrouter_delreq(struct nd_defrouter *dr) info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; NET_EPOCH_ENTER(et); - rib_action(fibnum, RTM_DELETE, &info, &rc); - if (rc.rc_rt != NULL) { + error = rib_action(fibnum, RTM_DELETE, &info, &rc); + if (error == 0) { struct nhop_object *nh = nhop_select(rc.rc_nh_old, 0); rt_routemsg(RTM_DELETE, rc.rc_rt, nh, fibnum); } From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 23:43: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 27C01558607; Tue, 23 Feb 2021 23:43: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 4DlbG70fx3z4r2P; Tue, 23 Feb 2021 23:43: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 0984822902; Tue, 23 Feb 2021 23:43: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 11NNhArr096889; Tue, 23 Feb 2021 23:43:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NNhAvO096888; Tue, 23 Feb 2021 23:43:10 GMT (envelope-from git) Date: Tue, 23 Feb 2021 23:43:10 GMT Message-Id: <202102232343.11NNhAvO096888@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9262a9ce06a6 - stable/13 - hidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9262a9ce06a697c7459a03d559b980673fd9c934 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, 23 Feb 2021 23:43:11 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9262a9ce06a697c7459a03d559b980673fd9c934 commit 9262a9ce06a697c7459a03d559b980673fd9c934 Author: Vladimir Kondratyev AuthorDate: 2021-02-13 18:19:02 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-02-23 23:41:49 +0000 hidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size defined by hardware rather than cached one to match HIDIOCGRDESC ioctl. This fixes errors reported by hid-tools being run against /dev/hidraw# device node belonging to driver which overloads report descriptor. MFC after: 1 week (cherry picked from commit f988d7fa050e4886cdeb9483a039e75d58c31883) --- sys/dev/hid/hidraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/hid/hidraw.c b/sys/dev/hid/hidraw.c index 6cc67ff14d23..e71b2e2c7d5d 100644 --- a/sys/dev/hid/hidraw.c +++ b/sys/dev/hid/hidraw.c @@ -703,7 +703,7 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, return (0); case HIDIOCGRDESCSIZE: - *(int *)addr = sc->sc_rdesc->len; + *(int *)addr = sc->sc_hw->rdescsize; return (0); case HIDIOCGRDESC: From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 23:43: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 48EAE558438; Tue, 23 Feb 2021 23:43: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 4DlbG81f7xz4r2Q; Tue, 23 Feb 2021 23:43: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 2B42822903; Tue, 23 Feb 2021 23:43: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 11NNhCT3096912; Tue, 23 Feb 2021 23:43:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NNhC8u096911; Tue, 23 Feb 2021 23:43:12 GMT (envelope-from git) Date: Tue, 23 Feb 2021 23:43:12 GMT Message-Id: <202102232343.11NNhC8u096911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: e7211ca03a85 - stable/13 - ukbd: Fix handling of keyboard ErrorRollOver reports MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e7211ca03a85e3a980daf389af823fefb24b8869 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, 23 Feb 2021 23:43:12 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=e7211ca03a85e3a980daf389af823fefb24b8869 commit e7211ca03a85e3a980daf389af823fefb24b8869 Author: Vladimir Kondratyev AuthorDate: 2021-02-13 18:12:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-02-23 23:41:49 +0000 ukbd: Fix handling of keyboard ErrorRollOver reports Ignore fantom keyboard state reports entirelly rather than ignore RollOver states for each key separatelly. Latter results in spurious release/push pairs of events on each fantom keyboard state report. Reported by: Jan Martin Mikkelsen Submitted by: Jan Martin Mikkelsen (initial version) PR: 253249 MFC after: 1 week (cherry picked from commit 032d3153877ef1767c121bbdf8e00f4f93b30a5d) --- sys/dev/usb/input/ukbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index 3314a3b3e70f..f2ff476150ff 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -722,11 +722,16 @@ ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error) hid_get_udata(sc->sc_buffer, len, &tmp_loc); /* advance to next location */ tmp_loc.pos += tmp_loc.size; + if (key == KEY_ERROR) { + DPRINTF("KEY_ERROR\n"); + sc->sc_ndata = sc->sc_odata; + goto tr_setup; /* ignore */ + } if (modifiers & MOD_FN) key = ukbd_apple_fn(key); if (sc->sc_flags & UKBD_FLAG_APPLE_SWAP) key = ukbd_apple_swap(key); - if (key == KEY_NONE || key == KEY_ERROR || key >= UKBD_NKEYCODE) + if (key == KEY_NONE || key >= UKBD_NKEYCODE) continue; /* set key in bitmap */ sc->sc_ndata.bitmap[key / 64] |= 1ULL << (key % 64); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 23:43: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 0673B5585A5; Tue, 23 Feb 2021 23:43: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 4DlbG93rvbz4r2T; Tue, 23 Feb 2021 23:43: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 4923622655; Tue, 23 Feb 2021 23:43: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 11NNhDpw096932; Tue, 23 Feb 2021 23:43:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NNhD5J096931; Tue, 23 Feb 2021 23:43:13 GMT (envelope-from git) Date: Tue, 23 Feb 2021 23:43:13 GMT Message-Id: <202102232343.11NNhD5J096931@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 98b3658c4e8a - stable/13 - hkbd: Fix handling of keyboard ErrorRollOver reports MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 98b3658c4e8a3760a2e4f71a8a4a3dec2d55065a 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, 23 Feb 2021 23:43:14 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=98b3658c4e8a3760a2e4f71a8a4a3dec2d55065a commit 98b3658c4e8a3760a2e4f71a8a4a3dec2d55065a Author: Vladimir Kondratyev AuthorDate: 2021-02-13 18:18:07 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-02-23 23:41:49 +0000 hkbd: Fix handling of keyboard ErrorRollOver reports Ignore fantom keyboard state reports entirelly rather than ignore RollOver states for each key separatelly. Latter results in spurious release/push pairs of events on each fantom keyboard state report. Reported by: Jan Martin Mikkelsen Submitted by: Jan Martin Mikkelsen (initial version) PR: 253249 MFC after: 1 week (cherry picked from commit 812c59ed614df94380e0b1f9ff4a3d15b78ce1bf) --- sys/dev/hid/hkbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index 6f4b71dd49b6..89325f9b2499 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -715,11 +715,16 @@ hkbd_intr_callback(void *context, void *data, hid_size_t len) uint32_t key = hid_get_data(buf + offset, len - offset, &sc->sc_loc_key[i]); + if (key == KEY_ERROR) { + DPRINTF("KEY_ERROR\n"); + sc->sc_ndata = sc->sc_odata; + return; /* ignore */ + } if (modifiers & MOD_FN) key = hkbd_apple_fn(key); if (sc->sc_flags & HKBD_FLAG_APPLE_SWAP) key = hkbd_apple_swap(key); - if (key == KEY_NONE || key == KEY_ERROR || key >= HKBD_NKEYCODE) + if (key == KEY_NONE || key >= HKBD_NKEYCODE) continue; /* set key in bitmap */ sc->sc_ndata.bitmap[key / 64] |= 1ULL << (key % 64); From owner-dev-commits-src-branches@freebsd.org Tue Feb 23 23:45:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73B6D5588AC; Tue, 23 Feb 2021 23:45:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlbJL2rggz4rRM; Tue, 23 Feb 2021 23:45:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5465C22657; Tue, 23 Feb 2021 23:45:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11NNj6YS097360; Tue, 23 Feb 2021 23:45:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11NNj6Zm097359; Tue, 23 Feb 2021 23:45:06 GMT (envelope-from git) Date: Tue, 23 Feb 2021 23:45:06 GMT Message-Id: <202102232345.11NNj6Zm097359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9bdb559d9726 - stable/12 - ukbd: Fix handling of keyboard ErrorRollOver reports MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9bdb559d97268967e893b9f37dc556ae5dcd44fb 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, 23 Feb 2021 23:45:06 -0000 The branch stable/12 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9bdb559d97268967e893b9f37dc556ae5dcd44fb commit 9bdb559d97268967e893b9f37dc556ae5dcd44fb Author: Vladimir Kondratyev AuthorDate: 2021-02-13 18:12:56 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-02-23 23:43:28 +0000 ukbd: Fix handling of keyboard ErrorRollOver reports Ignore fantom keyboard state reports entirelly rather than ignore RollOver states for each key separatelly. Latter results in spurious release/push pairs of events on each fantom keyboard state report. Reported by: Jan Martin Mikkelsen Submitted by: Jan Martin Mikkelsen (initial version) PR: 253249 MFC after: 1 week (cherry picked from commit 032d3153877ef1767c121bbdf8e00f4f93b30a5d) --- sys/dev/usb/input/ukbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index e438a1521f97..52b358c20324 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -721,11 +721,16 @@ ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error) hid_get_data_unsigned(sc->sc_buffer, len, &tmp_loc); /* advance to next location */ tmp_loc.pos += tmp_loc.size; + if (key == KEY_ERROR) { + DPRINTF("KEY_ERROR\n"); + sc->sc_ndata = sc->sc_odata; + goto tr_setup; /* ignore */ + } if (modifiers & MOD_FN) key = ukbd_apple_fn(key); if (sc->sc_flags & UKBD_FLAG_APPLE_SWAP) key = ukbd_apple_swap(key); - if (key == KEY_NONE || key == KEY_ERROR || key >= UKBD_NKEYCODE) + if (key == KEY_NONE || key >= UKBD_NKEYCODE) continue; /* set key in bitmap */ sc->sc_ndata.bitmap[key / 64] |= 1ULL << (key % 64); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 00:00:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1DA96558B5D; Wed, 24 Feb 2021 00:00:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dlbdk0J8Zz4sLb; Wed, 24 Feb 2021 00:00:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F154622A3D; Wed, 24 Feb 2021 00:00:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O009ce014075; Wed, 24 Feb 2021 00:00:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O009S2014072; Wed, 24 Feb 2021 00:00:09 GMT (envelope-from git) Date: Wed, 24 Feb 2021 00:00:09 GMT Message-Id: <202102240000.11O009S2014072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: fc6c898ec5f4 - stable/13 - Fix divide-by-zero panic when ASLR is enabled and superpages disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fc6c898ec5f46c730b8f2902c2692549de47d7d6 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, 24 Feb 2021 00:00:10 -0000 The branch stable/13 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=fc6c898ec5f46c730b8f2902c2692549de47d7d6 commit fc6c898ec5f46c730b8f2902c2692549de47d7d6 Author: Jason A. Harmening AuthorDate: 2021-02-15 02:47:22 +0000 Commit: Jason A. Harmening CommitDate: 2021-02-24 00:01:30 +0000 Fix divide-by-zero panic when ASLR is enabled and superpages disabled When locating the anonymous memory region for a vm_map with ASLR enabled, we try to keep the slid base address aligned on a superpage boundary to minimize pagetable fragmentation and maximize the potential usage of superpage mappings. We can't (portably) do this if superpages have been disabled by loader tunable and pagesizes[1] is 0, and it would be less beneficial in that case anyway. PR: 253511 (cherry picked from commit 41032835dc2d489ec7841d7529f74f6389329cd3) --- sys/kern/imgact_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index dae11ab92a6c..245894926ee1 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1287,7 +1287,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) maxv1 = maxv / 2 + addr / 2; MPASS(maxv1 >= addr); /* No overflow */ map->anon_loc = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1, - MAXPAGESIZES > 1 ? pagesizes[1] : pagesizes[0]); + (MAXPAGESIZES > 1 && pagesizes[1] != 0) ? + pagesizes[1] : pagesizes[0]); } else { map->anon_loc = addr; } @@ -1297,7 +1298,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) if (interp != NULL) { VOP_UNLOCK(imgp->vp); if ((map->flags & MAP_ASLR) != 0) { - /* Assume that interpeter fits into 1/4 of AS */ + /* Assume that interpreter fits into 1/4 of AS */ maxv1 = maxv / 2 + addr / 2; MPASS(maxv1 >= addr); /* No overflow */ addr = __CONCAT(rnd_, __elfN(base))(map, addr, From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 00:02: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 69AED558F7D; Wed, 24 Feb 2021 00:02: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 4Dlbgv2QJCz4sTY; Wed, 24 Feb 2021 00:02: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 4602322C27; Wed, 24 Feb 2021 00:02: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 11O023o1020909; Wed, 24 Feb 2021 00:02:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O023wP020908; Wed, 24 Feb 2021 00:02:03 GMT (envelope-from git) Date: Wed, 24 Feb 2021 00:02:03 GMT Message-Id: <202102240002.11O023wP020908@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: 941747f63cfa - stable/12 - Fix divide-by-zero panic when ASLR is enabled and superpages disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 941747f63cfa127248e6c7246f75c5ac5e142fcc 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, 24 Feb 2021 00:02:03 -0000 The branch stable/12 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=941747f63cfa127248e6c7246f75c5ac5e142fcc commit 941747f63cfa127248e6c7246f75c5ac5e142fcc Author: Jason A. Harmening AuthorDate: 2021-02-15 02:47:22 +0000 Commit: Jason A. Harmening CommitDate: 2021-02-24 00:04:00 +0000 Fix divide-by-zero panic when ASLR is enabled and superpages disabled When locating the anonymous memory region for a vm_map with ASLR enabled, we try to keep the slid base address aligned on a superpage boundary to minimize pagetable fragmentation and maximize the potential usage of superpage mappings. We can't (portably) do this if superpages have been disabled by loader tunable and pagesizes[1] is 0, and it would be less beneficial in that case anyway. PR: 253511 (cherry picked from commit 41032835dc2d489ec7841d7529f74f6389329cd3) --- sys/kern/imgact_elf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 18b83d6b499a..4c05be66e51f 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1271,7 +1271,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) maxv1 = maxv / 2 + addr / 2; MPASS(maxv1 >= addr); /* No overflow */ map->anon_loc = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1, - MAXPAGESIZES > 1 ? pagesizes[1] : pagesizes[0]); + (MAXPAGESIZES > 1 && pagesizes[1] != 0) ? + pagesizes[1] : pagesizes[0]); } else { map->anon_loc = addr; } @@ -1281,7 +1282,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) if (interp != NULL) { VOP_UNLOCK(imgp->vp, 0); if ((map->flags & MAP_ASLR) != 0) { - /* Assume that interpeter fits into 1/4 of AS */ + /* Assume that interpreter fits into 1/4 of AS */ maxv1 = maxv / 2 + addr / 2; MPASS(maxv1 >= addr); /* No overflow */ addr = __CONCAT(rnd_, __elfN(base))(map, addr, From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:38:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54E6F55B651; Wed, 24 Feb 2021 01:38:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dldpk21lkz3FgR; Wed, 24 Feb 2021 01:38:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3859E23D44; Wed, 24 Feb 2021 01:38:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1c6Oj042638; Wed, 24 Feb 2021 01:38:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1c6RS042637; Wed, 24 Feb 2021 01:38:06 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:38:06 GMT Message-Id: <202102240138.11O1c6RS042637@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: 8cf559d6b9b4 - stable/13 - pam_login_access: Fix negative entry matching logic 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: 8cf559d6b9b4782bf67eb868ea480f47fc8c64a4 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, 24 Feb 2021 01:38:06 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf559d6b9b4782bf67eb868ea480f47fc8c64a4 commit 8cf559d6b9b4782bf67eb868ea480f47fc8c64a4 Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:20:53 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:38:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9DCE55B6BD; Wed, 24 Feb 2021 01:38:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dldpx3yrsz3FSZ; Wed, 24 Feb 2021 01:38:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9FF423D45; Wed, 24 Feb 2021 01:38:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1cFMh042769; Wed, 24 Feb 2021 01:38:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1cFAf042768; Wed, 24 Feb 2021 01:38:15 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:38:15 GMT Message-Id: <202102240138.11O1cFAf042768@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: c99e3e2d9693 - stable/12 - pam_login_access: Fix negative entry matching logic 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: c99e3e2d96935ae4d61948bf7660e9b9c2afb4d9 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, 24 Feb 2021 01:38:17 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c99e3e2d96935ae4d61948bf7660e9b9c2afb4d9 commit c99e3e2d96935ae4d61948bf7660e9b9c2afb4d9 Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:21:06 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:38: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 7375655BA70; Wed, 24 Feb 2021 01:38: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 4Dldq141fZz3FnN; Wed, 24 Feb 2021 01:38: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 4084123B62; Wed, 24 Feb 2021 01:38:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1cLU7042896; Wed, 24 Feb 2021 01:38:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1cLaK042895; Wed, 24 Feb 2021 01:38:21 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:38:21 GMT Message-Id: <202102240138.11O1cLaK042895@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: dae05d22d64e - stable/11 - pam_login_access: Fix negative entry matching logic 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: dae05d22d64ea218abe5883be539c2b41c20b1fb 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, 24 Feb 2021 01:38:22 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=dae05d22d64ea218abe5883be539c2b41c20b1fb commit dae05d22d64ea218abe5883be539c2b41c20b1fb Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:21:13 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:40: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 5602255BB84; Wed, 24 Feb 2021 01:40: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 4DldsK1y4Zz3G7J; Wed, 24 Feb 2021 01:40: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 35A4E23DBA; Wed, 24 Feb 2021 01:40:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1eLeW050825; Wed, 24 Feb 2021 01:40:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1eL6G050824; Wed, 24 Feb 2021 01:40:21 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:21 GMT Message-Id: <202102240140.11O1eL6G050824@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: 491cafa96113 - releng/11.4 - MFC jail: Handle a possible race between jail_remove(2) and fork(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: 491cafa9611306ec513c9cbcb766a49ff7167dad 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, 24 Feb 2021 01:40:21 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=491cafa9611306ec513c9cbcb766a49ff7167dad commit 491cafa9611306ec513c9cbcb766a49ff7167dad Author: Jamie Gritton AuthorDate: 2021-02-16 19:19:13 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:35 +0000 MFC jail: Handle a possible race between jail_remove(2) and fork(2) jail_remove(2) includes a loop that sends SIGKILL to all processes in a jail, but skips processes in PRS_NEW state. Thus it is possible the a process in mid-fork(2) during jail removal can survive the jail being removed. Add a prison flag PR_REMOVE, which is checked before the new process returns. If the jail is being removed, the process will then exit. Also check this flag in jail_attach(2) which has a similar issue. Approved by: so Security: CVE-2020-25581 Security: FreeBSD-SA-21:04.jail_remove Reported by: mjg Approved by: kib (cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d) (cherry picked from commit c837631bd47af73d03e3d8907f1e58b88403007c) --- sys/kern/kern_fork.c | 6 ++++++ sys/kern/kern_jail.c | 18 ++++++++++++++++++ sys/sys/jail.h | 1 + 3 files changed, 25 insertions(+) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 2aa5f405d3c2..ea35afb42f99 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1144,6 +1144,12 @@ fork_return(struct thread *td, struct trapframe *frame) PROC_UNLOCK(p); } + /* + * If the prison was killed mid-fork, die along with it. + */ + if (td->td_ucred->cr_prison->pr_flags & PR_REMOVE) + exit1(td, 0, SIGKILL); + userret(td, frame); #ifdef KTRACE diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 47cc3ddd3bce..0bb9c76a25c9 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1751,6 +1751,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) } } pr->pr_flags = (pr->pr_flags & ~ch_flags) | pr_flags; + pr->pr_flags &= ~PR_REMOVE; mtx_unlock(&pr->pr_mtx); #ifdef RACCT @@ -2287,6 +2288,12 @@ prison_remove_one(struct prison *pr) struct proc *p; int deuref; + /* + * Mark the prison as doomed, so it doesn't accidentally come back + * to life. It may still be explicitly brought back by jail_set(2). + */ + pr->pr_flags |= PR_REMOVE; + /* If the prison was persistent, it is not anymore. */ deuref = 0; if (pr->pr_flags & PR_PERSIST) { @@ -2431,6 +2438,17 @@ do_jail_attach(struct thread *td, struct prison *pr) #endif prison_deref(oldcred->cr_prison, PD_DEREF | PD_DEUREF); crfree(oldcred); + + /* + * If the prison was killed while changing credentials, die along + * with it. + */ + if (pr->pr_flags & PR_REMOVE) { + PROC_LOCK(p); + kern_psignal(p, SIGKILL); + PROC_UNLOCK(p); + } + return (0); e_unlock: diff --git a/sys/sys/jail.h b/sys/sys/jail.h index 7142d0d0d71a..90a3fbce821f 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -209,6 +209,7 @@ struct prison_racct { /* primary jail address. */ /* Internal flag bits */ +#define PR_REMOVE 0x01000000 /* In process of being removed */ #define PR_IP4 0x02000000 /* IPv4 restricted or disabled */ /* by this jail or an ancestor */ #define PR_IP6 0x04000000 /* IPv6 restricted or disabled */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:40: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 7D6E055BB2F; Wed, 24 Feb 2021 01:40: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 4DldsL312bz3G2s; Wed, 24 Feb 2021 01:40: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 58C0823E25; Wed, 24 Feb 2021 01:40: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 11O1eMO0050845; Wed, 24 Feb 2021 01:40:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1eMk1050844; Wed, 24 Feb 2021 01:40:22 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:22 GMT Message-Id: <202102240140.11O1eMk1050844@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: bc0d9b9b84ec - releng/11.4 - MFC jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/11.4 X-Git-Reftype: branch X-Git-Commit: bc0d9b9b84ec5f8c463488c46721dd71fc803ceb 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, 24 Feb 2021 01:40:22 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bc0d9b9b84ec5f8c463488c46721dd71fc803ceb commit bc0d9b9b84ec5f8c463488c46721dd71fc803ceb Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:48 +0000 MFC jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Approved by: so Security: CVE-2020-25582 Security: FreeBSD-SA-21:05.jail_chdir Reported by: mjg Approved by: markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) (cherry picked from commit 570121808a76b85b2709502fb15618dd1e5296f1) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 40 ++++++++++++++++++++++++++++++++++++---- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 26b059c0a4b6..17f773d2b7de 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3052,10 +3052,9 @@ chroot_refuse_vdir_fds(struct filedesc *fdp) } /* - * Common routine for kern_chroot() and jail_attach(). The caller is - * responsible for invoking priv_check() and mac_vnode_check_chroot() to - * authorize this operation. - */ +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. +*/ int pwd_chroot(struct thread *td, struct vnode *vp) { @@ -3101,6 +3100,39 @@ pwd_chdir(struct thread *td, struct vnode *vp) vrele(oldvp); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct filedesc *fdp; + struct vnode *oldvrp, *oldvcp; + int error; + + fdp = td->td_proc->p_fd; + FILEDESC_XLOCK(fdp); + error = chroot_refuse_vdir_fds(fdp); + if (error != 0) { + FILEDESC_XUNLOCK(fdp); + return (error); + } + oldvrp = fdp->fd_rdir; + vrefact(vp); + fdp->fd_rdir = vp; + oldvcp = fdp->fd_cdir; + vrefact(vp); + fdp->fd_cdir = vp; + if (fdp->fd_jdir == NULL) { + vrefact(vp); + fdp->fd_jdir = vp; + } + FILEDESC_XUNLOCK(fdp); + vrele(oldvrp); + vrele(oldvcp); + return (0); +} + /* * Scan all active processes and prisons to see if any of them have a current * or root directory of `olddp'. If so, replace them with the new mount point. diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 0bb9c76a25c9..836bc4e4f8b7 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2418,7 +2418,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root, 0); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index b9ad9fe363e9..5bbc5a3e6fa8 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -239,6 +239,7 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq) /* cdir/rdir/jdir manipulation functions. */ void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); #endif /* _KERNEL */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:40: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 F0D9255B979; Wed, 24 Feb 2021 01:40: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 4DldsM4JYbz3G9H; Wed, 24 Feb 2021 01:40: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 8151623B65; Wed, 24 Feb 2021 01:40: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 11O1eNY3050866; Wed, 24 Feb 2021 01:40:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1eNkQ050865; Wed, 24 Feb 2021 01:40:23 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:23 GMT Message-Id: <202102240140.11O1eNkQ050865@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: 2ca137b4306d - releng/11.4 - MFC freebsd-update: unconditionally regenerate passwd/login.conf files 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/releng/11.4 X-Git-Reftype: branch X-Git-Commit: 2ca137b4306dea2dbe1db31c44102060caedb19a 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, 24 Feb 2021 01:40:24 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2ca137b4306dea2dbe1db31c44102060caedb19a commit 2ca137b4306dea2dbe1db31c44102060caedb19a Author: Kyle Evans AuthorDate: 2020-12-17 03:42:54 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:51 +0000 MFC freebsd-update: unconditionally regenerate passwd/login.conf files The existing logic is nice in theory, but in practice freebsd-update will not preserve the timestamps on these files. When doing a major upgrade, e.g. from 12.1-RELEASE -> 12.2-RELEASE, pwd.mkdb et al. appear in the INDEX and we clobber the timestamp several times in the process of packaging up the existing system into /var/db/freebsd-update/files and extracting for comparisons. This leads to these files not getting regenerated when they're most likely to be needed. Measures could be taken to preserve timestamps, but it's unclear whether the complexity and overhead of doing so is really outweighed by the marginal benefit. I observed this issue when pkg subsequently failed to install a package that wanted to add a user, claiming that the user was removed in the process. bapt@ pointed to this pre-existing bug with freebsd-update as the cause. PR: 234014, 232921 Approved by: so Security: FreeBSD-EN-21:08.freebsd-update (cherry picked from commit ebebc41e4cfe44b8e8fd881badf2fa2c4be65aa4) (cherry picked from commit cd7da1deb581122c94c3735b78fafdd04ce77b67) --- usr.sbin/freebsd-update/freebsd-update.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index 1996996b512b..67c323449745 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -2949,17 +2949,9 @@ Kernel updates have been installed. Please reboot and run env DESTDIR=${BASEDIR} certctl rehash fi - # Rebuild generated pwd files. - if [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/spwd.db ] || - [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/pwd.db ] || - [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/passwd ]; then - pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd - fi - - # Rebuild /etc/login.conf.db if necessary. - if [ ${BASEDIR}/etc/login.conf -nt ${BASEDIR}/etc/login.conf.db ]; then - cap_mkdb ${BASEDIR}/etc/login.conf - fi + # Rebuild generated pwd files and /etc/login.conf.db. + pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd + cap_mkdb ${BASEDIR}/etc/login.conf # Rebuild man page databases, if necessary. for D in /usr/share/man /usr/share/openssl/man; do From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:40: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 0423355B8FF; Wed, 24 Feb 2021 01:40: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 4DldsP0JnYz3G5q; Wed, 24 Feb 2021 01:40: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 C67D223DBB; Wed, 24 Feb 2021 01:40: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 11O1eOWV050884; Wed, 24 Feb 2021 01:40:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1eOAH050883; Wed, 24 Feb 2021 01:40:24 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:24 GMT Message-Id: <202102240140.11O1eOAH050883@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: ab1cd885a619 - releng/11.4 - xen-blkback: fix leak of grant maps on ring setup failure 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/releng/11.4 X-Git-Reftype: branch X-Git-Commit: ab1cd885a619a0304e40fa07795ea9ddcb33134e 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, 24 Feb 2021 01:40:27 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ab1cd885a619a0304e40fa07795ea9ddcb33134e commit ab1cd885a619a0304e40fa07795ea9ddcb33134e Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:52 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Approved by: so Security: CVE-2021-26932 Security: FreeBSD-SA-21:06.xen Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) (cherry picked from commit 89238773a37f4fc8f0bf3ccca3aa03874478f194) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 4b6eeb0cf62f..5fb5cdbe6ea1 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2911,10 +2911,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01: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 BEBDF55BC0C; Wed, 24 Feb 2021 01: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 4DldsR5l4Cz3Fv2; Wed, 24 Feb 2021 01:40: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 2BAE823D4A; Wed, 24 Feb 2021 01:40: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 11O1ePpt050904; Wed, 24 Feb 2021 01:40:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1ePIX050903; Wed, 24 Feb 2021 01:40:25 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:25 GMT Message-Id: <202102240140.11O1ePIX050903@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: 3ea0e6b45274 - releng/11.4 - pam_login_access: Fix negative entry matching logic 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/releng/11.4 X-Git-Reftype: branch X-Git-Commit: 3ea0e6b45274a296b859a3171070834a2e33c5fd 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, 24 Feb 2021 01:40:30 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3ea0e6b45274a296b859a3171070834a2e33c5fd commit 3ea0e6b45274a296b859a3171070834a2e33c5fd Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:52 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) (cherry picked from commit dae05d22d64ea218abe5883be539c2b41c20b1fb) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01: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 EB93055BC0D; Wed, 24 Feb 2021 01: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 4DldsR5kQhz3Ftx; Wed, 24 Feb 2021 01:40: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 F202623E26; Wed, 24 Feb 2021 01:40: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 11O1eQNX050924; Wed, 24 Feb 2021 01:40:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1eQ7C050923; Wed, 24 Feb 2021 01:40:26 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:40:26 GMT Message-Id: <202102240140.11O1eQ7C050923@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: 7a03d4b081a0 - releng/11.4 - Add UPDATING entry and bump version 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/releng/11.4 X-Git-Reftype: branch X-Git-Commit: 7a03d4b081a02c6b8d8d816f4172f0d01980497e 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, 24 Feb 2021 01:40:30 -0000 The branch releng/11.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7a03d4b081a02c6b8d8d816f4172f0d01980497e commit 7a03d4b081a02c6b8d8d816f4172f0d01980497e Author: Mark Johnston AuthorDate: 2021-02-23 22:54:20 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:34:52 +0000 Add UPDATING entry and bump version Approved by: so --- UPDATING | 16 ++++++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 9e75e2201d6b..f67b1d59b118 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,22 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210223: p8 FreeBSD-SA-21:03.pam_login_access + FreeBSD-SA-21:04.jail_remove + FreeBSD-SA-21:05.jail_chdir + FreeBSD-SA-21:06.xen + FreeBSD-EN-21:08.freebsd-update + + login.access fails to apply rules [SA-21:03.pam_login_access] + + jail_remove(2) fails to kill all jailed processes [SA-21:04.jail_remove] + + jail_attach(2) relies on the caller to change the cwd [SA-21:05.jail_chdir] + + Xen grant mapping error handling issues [SA-21:06.xen] + + freebsd-update passwd regeneration [EN-21:08.freebsd-update] + 20210128: p7 FreeBSD-EN-21:01.tzdata FreeBSD-EN-21:02.extattr FreeBSD-EN-21:05.libatomic diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index e9d5ad3f5d41..96d5d515e010 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -44,7 +44,7 @@ TYPE="FreeBSD" REVISION="11.4" -BRANCH="RELEASE-p7" +BRANCH="RELEASE-p8" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 D881355BCF8; Wed, 24 Feb 2021 01:42: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 4DldvJ5qLLz3Gt8; Wed, 24 Feb 2021 01:42: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 BAC2624183; Wed, 24 Feb 2021 01:42: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 11O1g47p054459; Wed, 24 Feb 2021 01:42:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1g4fS054458; Wed, 24 Feb 2021 01:42:04 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:04 GMT Message-Id: <202102240142.11O1g4fS054458@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: b306be13a9c7 - releng/12.2 - MFC jail: Handle a possible race between jail_remove(2) and fork(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: b306be13a9c7ea0db8979a8a53dca93f90ec59cc 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, 24 Feb 2021 01:42:04 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b306be13a9c7ea0db8979a8a53dca93f90ec59cc commit b306be13a9c7ea0db8979a8a53dca93f90ec59cc Author: Jamie Gritton AuthorDate: 2021-02-16 19:19:13 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:41:49 +0000 MFC jail: Handle a possible race between jail_remove(2) and fork(2) jail_remove(2) includes a loop that sends SIGKILL to all processes in a jail, but skips processes in PRS_NEW state. Thus it is possible the a process in mid-fork(2) during jail removal can survive the jail being removed. Add a prison flag PR_REMOVE, which is checked before the new process returns. If the jail is being removed, the process will then exit. Also check this flag in jail_attach(2) which has a similar issue. Approved by: so Security: CVE-2020-25581 Security: FreeBSD-SA-21:04.jail_remove Reported by: mjg Approved by: kib (cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d) (cherry picked from commit f7007a7d05255a6859dea0982b1f0a6d695e8881) --- sys/kern/kern_fork.c | 6 ++++++ sys/kern/kern_jail.c | 18 ++++++++++++++++++ sys/sys/jail.h | 1 + 3 files changed, 25 insertions(+) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index e427164cd150..f8e134c30948 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1138,6 +1138,12 @@ fork_return(struct thread *td, struct trapframe *frame) PROC_UNLOCK(p); } + /* + * If the prison was killed mid-fork, die along with it. + */ + if (td->td_ucred->cr_prison->pr_flags & PR_REMOVE) + exit1(td, 0, SIGKILL); + userret(td, frame); #ifdef KTRACE diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 60cbea3c9849..b4a20b4d29e9 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1768,6 +1768,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) } } pr->pr_flags = (pr->pr_flags & ~ch_flags) | pr_flags; + pr->pr_flags &= ~PR_REMOVE; mtx_unlock(&pr->pr_mtx); #ifdef RACCT @@ -2306,6 +2307,12 @@ prison_remove_one(struct prison *pr) struct proc *p; int deuref; + /* + * Mark the prison as doomed, so it doesn't accidentally come back + * to life. It may still be explicitly brought back by jail_set(2). + */ + pr->pr_flags |= PR_REMOVE; + /* If the prison was persistent, it is not anymore. */ deuref = 0; if (pr->pr_flags & PR_PERSIST) { @@ -2450,6 +2457,17 @@ do_jail_attach(struct thread *td, struct prison *pr) #endif prison_deref(oldcred->cr_prison, PD_DEREF | PD_DEUREF); crfree(oldcred); + + /* + * If the prison was killed while changing credentials, die along + * with it. + */ + if (pr->pr_flags & PR_REMOVE) { + PROC_LOCK(p); + kern_psignal(p, SIGKILL); + PROC_UNLOCK(p); + } + return (0); e_unlock: diff --git a/sys/sys/jail.h b/sys/sys/jail.h index 878b97a064a3..8baf784d6b6d 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -213,6 +213,7 @@ struct prison_racct { /* primary jail address. */ /* Internal flag bits */ +#define PR_REMOVE 0x01000000 /* In process of being removed */ #define PR_IP4 0x02000000 /* IPv4 restricted or disabled */ /* by this jail or an ancestor */ #define PR_IP6 0x04000000 /* IPv6 restricted or disabled */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1154F55BE70; Wed, 24 Feb 2021 01:42:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DldvK6th7z3GqZ; Wed, 24 Feb 2021 01:42: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 D450023E4F; Wed, 24 Feb 2021 01:42: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 11O1g5dD054482; Wed, 24 Feb 2021 01:42:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1g5L6054481; Wed, 24 Feb 2021 01:42:05 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:05 GMT Message-Id: <202102240142.11O1g5L6054481@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: 4dd124c3171d - releng/12.2 - MFC jail: Change both root and working directories in jail_attach(2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 4dd124c3171db9cd7fbcc49d8081de590a065d0b 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, 24 Feb 2021 01:42:06 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4dd124c3171db9cd7fbcc49d8081de590a065d0b commit 4dd124c3171db9cd7fbcc49d8081de590a065d0b Author: Jamie Gritton AuthorDate: 2021-02-19 22:13:35 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:41:57 +0000 MFC jail: Change both root and working directories in jail_attach(2) jail_attach(2) performs an internal chroot operation, leaving it up to the calling process to assure the working directory is inside the jail. Add a matching internal chdir operation to the jail's root. Also ignore kern.chroot_allow_open_directories, and always disallow the operation if there are any directory descriptors open. Approved by: so Security: CVE-2020-25582 Security: FreeBSD-SA-21:05.jail_chdir Reported by: mjg Approved by: markj, kib (cherry picked from commit d4380c0cdd0517dc038403dd5c99242ce78bdeb5) (cherry picked from commit ca9ab8ea17748a1758701fde262cb272fb757989) --- lib/libc/sys/jail.2 | 5 ++++- sys/kern/kern_descrip.c | 40 ++++++++++++++++++++++++++++++++++++---- sys/kern/kern_jail.c | 2 +- sys/sys/filedesc.h | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2 index 2e13a6c3a381..82c2e97d4a7b 100644 --- a/lib/libc/sys/jail.2 +++ b/lib/libc/sys/jail.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 8, 2012 +.Dd February 19, 2021 .Dt JAIL 2 .Os .Sh NAME @@ -228,6 +228,9 @@ The system call attaches the current process to an existing jail, identified by .Fa jid . +It changes the process's root and current directories to the jail's +.Va path +directory. .Pp The .Fn jail_remove diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index cda64931779b..b61b6bc2d66e 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3216,10 +3216,9 @@ chroot_refuse_vdir_fds(struct filedesc *fdp) } /* - * Common routine for kern_chroot() and jail_attach(). The caller is - * responsible for invoking priv_check() and mac_vnode_check_chroot() to - * authorize this operation. - */ +* The caller is responsible for invoking priv_check() and +* mac_vnode_check_chroot() to authorize this operation. +*/ int pwd_chroot(struct thread *td, struct vnode *vp) { @@ -3265,6 +3264,39 @@ pwd_chdir(struct thread *td, struct vnode *vp) vrele(oldvp); } +/* + * jail_attach(2) changes both root and working directories. + */ +int +pwd_chroot_chdir(struct thread *td, struct vnode *vp) +{ + struct filedesc *fdp; + struct vnode *oldvrp, *oldvcp; + int error; + + fdp = td->td_proc->p_fd; + FILEDESC_XLOCK(fdp); + error = chroot_refuse_vdir_fds(fdp); + if (error != 0) { + FILEDESC_XUNLOCK(fdp); + return (error); + } + oldvrp = fdp->fd_rdir; + vrefact(vp); + fdp->fd_rdir = vp; + oldvcp = fdp->fd_cdir; + vrefact(vp); + fdp->fd_cdir = vp; + if (fdp->fd_jdir == NULL) { + vrefact(vp); + fdp->fd_jdir = vp; + } + FILEDESC_XUNLOCK(fdp); + vrele(oldvrp); + vrele(oldvcp); + return (0); +} + /* * Scan all active processes and prisons to see if any of them have a current * or root directory of `olddp'. If so, replace them with the new mount point. diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b4a20b4d29e9..46b43fa7bbc2 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2437,7 +2437,7 @@ do_jail_attach(struct thread *td, struct prison *pr) goto e_unlock; #endif VOP_UNLOCK(pr->pr_root, 0); - if ((error = pwd_chroot(td, pr->pr_root))) + if ((error = pwd_chroot_chdir(td, pr->pr_root))) goto e_revert_osd; newcred = crget(); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index db5debcfe7c8..ca85f49d7997 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -243,6 +243,7 @@ fd_modified(struct filedesc *fdp, int fd, seq_t seq) /* cdir/rdir/jdir manipulation functions. */ void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); +int pwd_chroot_chdir(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); #endif /* _KERNEL */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B66E55BC75; Wed, 24 Feb 2021 01:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DldvP2Kc1z3HF8; Wed, 24 Feb 2021 01:42:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A55D238ED; Wed, 24 Feb 2021 01:42: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 11O1g8gg054518; Wed, 24 Feb 2021 01:42:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1g8dm054517; Wed, 24 Feb 2021 01:42:08 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:08 GMT Message-Id: <202102240142.11O1g8dm054517@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: df378912ebc2 - releng/12.2 - MFC freebsd-update: unconditionally regenerate passwd/login.conf files 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: df378912ebc2fe2603fcbcedf72af9d7b0e94db7 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, 24 Feb 2021 01:42:11 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=df378912ebc2fe2603fcbcedf72af9d7b0e94db7 commit df378912ebc2fe2603fcbcedf72af9d7b0e94db7 Author: Kyle Evans AuthorDate: 2020-12-17 03:42:54 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:01 +0000 MFC freebsd-update: unconditionally regenerate passwd/login.conf files The existing logic is nice in theory, but in practice freebsd-update will not preserve the timestamps on these files. When doing a major upgrade, e.g. from 12.1-RELEASE -> 12.2-RELEASE, pwd.mkdb et al. appear in the INDEX and we clobber the timestamp several times in the process of packaging up the existing system into /var/db/freebsd-update/files and extracting for comparisons. This leads to these files not getting regenerated when they're most likely to be needed. Measures could be taken to preserve timestamps, but it's unclear whether the complexity and overhead of doing so is really outweighed by the marginal benefit. I observed this issue when pkg subsequently failed to install a package that wanted to add a user, claiming that the user was removed in the process. bapt@ pointed to this pre-existing bug with freebsd-update as the cause. PR: 234014, 232921 Approved by: so Security: FreeBSD-EN-21:08.freebsd-update (cherry picked from commit ebebc41e4cfe44b8e8fd881badf2fa2c4be65aa4) (cherry picked from commit 5cf1ba21eebaf89cf4d8639a18345dc49116d1d5) --- usr.sbin/freebsd-update/freebsd-update.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh index ea85bb7c6831..004515bb8bf8 100644 --- a/usr.sbin/freebsd-update/freebsd-update.sh +++ b/usr.sbin/freebsd-update/freebsd-update.sh @@ -2949,17 +2949,9 @@ Kernel updates have been installed. Please reboot and run env DESTDIR=${BASEDIR} certctl rehash fi - # Rebuild generated pwd files. - if [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/spwd.db ] || - [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/pwd.db ] || - [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/passwd ]; then - pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd - fi - - # Rebuild /etc/login.conf.db if necessary. - if [ ${BASEDIR}/etc/login.conf -nt ${BASEDIR}/etc/login.conf.db ]; then - cap_mkdb ${BASEDIR}/etc/login.conf - fi + # Rebuild generated pwd files and /etc/login.conf.db. + pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd + cap_mkdb ${BASEDIR}/etc/login.conf # Rebuild man page databases, if necessary. for D in /usr/share/man /usr/share/openssl/man; do From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 F27B955BF14; Wed, 24 Feb 2021 01:42: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 4DldvM36QLz3H2x; Wed, 24 Feb 2021 01:42: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 036D424118; Wed, 24 Feb 2021 01:42: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 11O1g6VD054500; Wed, 24 Feb 2021 01:42:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1g6eF054499; Wed, 24 Feb 2021 01:42:06 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:06 GMT Message-Id: <202102240142.11O1g6eF054499@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: 0f1ee1523649 - releng/12.2 - Free microcode memory later. 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 0f1ee1523649b745535f14988880eea239c2af3f 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, 24 Feb 2021 01:42:08 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0f1ee1523649b745535f14988880eea239c2af3f commit 0f1ee1523649b745535f14988880eea239c2af3f Author: Konstantin Belousov AuthorDate: 2019-05-17 17:11:01 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:00 +0000 Free microcode memory later. Approved by: so Security: FreeBSD-EN-21:06.microcode (cherry picked from commit 8f7f38457f940798c149ae40b73e0d20672812de) (cherry picked from commit 79bee465de342b82fa300293d04f155f2d6a6183) --- sys/x86/x86/ucode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/x86/ucode.c b/sys/x86/x86/ucode.c index 93f82e37eb66..d8beeed68215 100644 --- a/sys/x86/x86/ucode.c +++ b/sys/x86/x86/ucode.c @@ -260,7 +260,7 @@ restart: goto restart; } } -SYSINIT(ucode_release, SI_SUB_KMEM + 1, SI_ORDER_ANY, ucode_release, NULL); +SYSINIT(ucode_release, SI_SUB_SMP + 1, SI_ORDER_ANY, ucode_release, NULL); void ucode_load_ap(int cpu) From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 168AA55BD7D; Wed, 24 Feb 2021 01:42: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 4DldvR1ffDz3HFN; Wed, 24 Feb 2021 01:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 467B82411B; Wed, 24 Feb 2021 01:42:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1g9QB054540; Wed, 24 Feb 2021 01:42:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1g9w9054539; Wed, 24 Feb 2021 01:42:09 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:09 GMT Message-Id: <202102240142.11O1g9w9054539@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: efc9549ba0c2 - releng/12.2 - MFC r368555: caroot: update bundle 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: efc9549ba0c2caffd45e1f7f88fdd75a0225e568 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, 24 Feb 2021 01:42:14 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=efc9549ba0c2caffd45e1f7f88fdd75a0225e568 commit efc9549ba0c2caffd45e1f7f88fdd75a0225e568 Author: Kyle Evans AuthorDate: 2020-12-15 21:50:05 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:01 +0000 MFC r368555: caroot: update bundle Summary: - One (1) added - Ten (10) removed Approved by: so Security: FreeBSD-EN-21:07.caroot (cherry picked from commit e4e8ecaf63ba6f2767680a7b4666461243d88749) --- .../GeoTrust_Global_CA.pem | 0 .../GeoTrust_Primary_Certification_Authority.pem | 0 ...oTrust_Primary_Certification_Authority_-_G3.pem | 0 .../GeoTrust_Universal_CA.pem | 0 .../GeoTrust_Universal_CA_2.pem | 0 ...Public_Primary_Certification_Authority_-_G4.pem | 0 ...Public_Primary_Certification_Authority_-_G5.pem | 0 .../thawte_Primary_Root_CA.pem | 0 .../thawte_Primary_Root_CA_-_G2.pem | 0 .../thawte_Primary_Root_CA_-_G3.pem | 0 .../NAVER_Global_Root_Certification_Authority.pem | 134 +++++++++++++++++++++ 11 files changed, 134 insertions(+) diff --git a/secure/caroot/trusted/GeoTrust_Global_CA.pem b/secure/caroot/blacklisted/GeoTrust_Global_CA.pem similarity index 100% rename from secure/caroot/trusted/GeoTrust_Global_CA.pem rename to secure/caroot/blacklisted/GeoTrust_Global_CA.pem diff --git a/secure/caroot/trusted/GeoTrust_Primary_Certification_Authority.pem b/secure/caroot/blacklisted/GeoTrust_Primary_Certification_Authority.pem similarity index 100% rename from secure/caroot/trusted/GeoTrust_Primary_Certification_Authority.pem rename to secure/caroot/blacklisted/GeoTrust_Primary_Certification_Authority.pem diff --git a/secure/caroot/trusted/GeoTrust_Primary_Certification_Authority_-_G3.pem b/secure/caroot/blacklisted/GeoTrust_Primary_Certification_Authority_-_G3.pem similarity index 100% rename from secure/caroot/trusted/GeoTrust_Primary_Certification_Authority_-_G3.pem rename to secure/caroot/blacklisted/GeoTrust_Primary_Certification_Authority_-_G3.pem diff --git a/secure/caroot/trusted/GeoTrust_Universal_CA.pem b/secure/caroot/blacklisted/GeoTrust_Universal_CA.pem similarity index 100% rename from secure/caroot/trusted/GeoTrust_Universal_CA.pem rename to secure/caroot/blacklisted/GeoTrust_Universal_CA.pem diff --git a/secure/caroot/trusted/GeoTrust_Universal_CA_2.pem b/secure/caroot/blacklisted/GeoTrust_Universal_CA_2.pem similarity index 100% rename from secure/caroot/trusted/GeoTrust_Universal_CA_2.pem rename to secure/caroot/blacklisted/GeoTrust_Universal_CA_2.pem diff --git a/secure/caroot/trusted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem b/secure/caroot/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem similarity index 100% rename from secure/caroot/trusted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem rename to secure/caroot/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem diff --git a/secure/caroot/trusted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem b/secure/caroot/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem similarity index 100% rename from secure/caroot/trusted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem rename to secure/caroot/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem diff --git a/secure/caroot/trusted/thawte_Primary_Root_CA.pem b/secure/caroot/blacklisted/thawte_Primary_Root_CA.pem similarity index 100% rename from secure/caroot/trusted/thawte_Primary_Root_CA.pem rename to secure/caroot/blacklisted/thawte_Primary_Root_CA.pem diff --git a/secure/caroot/trusted/thawte_Primary_Root_CA_-_G2.pem b/secure/caroot/blacklisted/thawte_Primary_Root_CA_-_G2.pem similarity index 100% rename from secure/caroot/trusted/thawte_Primary_Root_CA_-_G2.pem rename to secure/caroot/blacklisted/thawte_Primary_Root_CA_-_G2.pem diff --git a/secure/caroot/trusted/thawte_Primary_Root_CA_-_G3.pem b/secure/caroot/blacklisted/thawte_Primary_Root_CA_-_G3.pem similarity index 100% rename from secure/caroot/trusted/thawte_Primary_Root_CA_-_G3.pem rename to secure/caroot/blacklisted/thawte_Primary_Root_CA_-_G3.pem diff --git a/secure/caroot/trusted/NAVER_Global_Root_Certification_Authority.pem b/secure/caroot/trusted/NAVER_Global_Root_Certification_Authority.pem new file mode 100644 index 000000000000..3b042c1c2716 --- /dev/null +++ b/secure/caroot/trusted/NAVER_Global_Root_Certification_Authority.pem @@ -0,0 +1,134 @@ +## +## NAVER Global Root Certification Authority +## +## This is a single X.509 certificate for a public Certificate +## Authority (CA). It was automatically extracted from Mozilla's +## root CA list (the file `certdata.txt' in security/nss). +## +## Extracted from nss +## with $FreeBSD: head/secure/caroot/MAca-bundle.pl 352951 2019-10-02 01:27:50Z kevans $ +## +## @generated +## +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 01:94:30:1e:a2:0b:dd:f5:c5:33:2a:b1:43:44:71:f8:d6:50:4d:0d + Signature Algorithm: sha384WithRSAEncryption + Issuer: C = KR, O = NAVER BUSINESS PLATFORM Corp., CN = NAVER Global Root Certification Authority + Validity + Not Before: Aug 18 08:58:42 2017 GMT + Not After : Aug 18 23:59:59 2037 GMT + Subject: C = KR, O = NAVER BUSINESS PLATFORM Corp., CN = NAVER Global Root Certification Authority + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public-Key: (4096 bit) + Modulus: + 00:b6:d4:f1:93:5c:b5:40:89:0a:ab:0d:90:5b:50: + 63:ae:90:94:74:17:45:72:d6:7b:65:5a:29:4b:a7: + 56:a0:4b:b8:2f:42:75:e9:d9:7b:24:5a:31:65:ab: + 17:17:d1:33:3a:d9:11:dc:40:36:87:df:c7:6a:e9: + 26:5e:59:8a:77:e3:e8:48:9c:31:16:fa:3e:91:b1: + ca:c9:a3:e2:9f:ce:21:53:a3:02:36:30:cb:52:02: + e5:da:32:5d:c3:c5:e6:f9:ee:11:c7:8b:c9:44:1e: + 84:93:18:4a:b4:9f:e5:12:64:69:d0:26:85:62:01: + b6:c9:02:1d:be:83:51:bb:5c:da:f8:ad:15:6a:99: + f7:92:54:f7:34:5b:e9:bf:ea:29:81:12:d4:53:91: + 96:b3:91:5a:dd:fe:90:73:28:fb:30:46:b5:ca:08: + 07:c7:71:72:c9:66:d3:34:97:f6:8c:f4:18:4a:e1: + d0:3d:5a:45:b6:69:a7:29:fb:23:ce:88:d8:12:9c: + 00:48:a8:a6:0f:b3:3b:92:8d:71:0e:74:c5:8b:c8: + 4c:f9:f4:9b:8e:b8:3c:69:ed:6f:3b:50:2f:58:ed: + c4:b0:d0:1c:1b:6a:0c:e2:bc:44:aa:d8:cd:14:5d: + 94:78:61:bf:0e:6e:da:2a:bc:2f:0c:0b:71:a6:b3: + 16:3f:9c:e6:f9:cc:9f:53:35:e2:03:a0:a0:18:bf: + bb:f1:be:f4:d6:8c:87:0d:42:f7:06:b9:f1:6d:ed: + 04:94:a8:fe:b6:d3:06:c6:40:61:df:9d:9d:f3:54: + 76:ce:53:3a:01:a6:92:41:ec:04:a3:8f:0d:a2:d5: + 09:ca:d6:cb:9a:f1:ef:43:5d:c0:ab:a5:41:cf:5c: + 53:70:70:c9:88:a6:2d:d4:6b:61:73:50:26:86:61: + 0e:5f:1b:c2:2b:e2:8c:d5:bb:9d:c1:03:42:ba:94: + da:5f:a9:b0:ca:cc:4d:0a:ef:47:69:03:2f:22:fb: + f1:28:ce:bf:5d:50:65:a8:90:6d:b3:74:b0:08:c7: + ac:a8:d1:eb:3e:9c:fc:5d:1a:83:2e:2b:cb:b5:f3: + 44:9d:3a:a7:17:61:96:a2:71:d3:70:96:15:4d:b7: + 4c:73:ee:19:5c:c5:5b:3e:41:fe:ac:75:60:3b:1b: + 63:ce:00:dd:da:08:90:62:b4:e5:2d:ee:48:a7:6b: + 17:99:54:be:87:4a:e3:a9:5e:04:4c:eb:10:6d:54: + d6:ef:f1:e8:f2:62:16:cb:80:6b:ed:3d:ed:f5:1f: + 30:a5:ae:4b:c9:13:ed:8a:01:01:c9:b8:51:58:c0: + 66:3a:b1:66:4b:c4:d5:31:02:62:e9:74:84:0c:db: + 4d:46:2d + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Subject Key Identifier: + D2:9F:88:DF:A1:CD:2C:BD:EC:F5:3B:01:01:93:33:27:B2:EB:60:4B + X509v3 Key Usage: critical + Certificate Sign, CRL Sign + X509v3 Basic Constraints: critical + CA:TRUE + Signature Algorithm: sha384WithRSAEncryption + 32:ca:80:b3:9d:3d:54:06:dd:d2:d2:2e:f0:a4:01:21:0b:67: + 48:ca:6d:8e:e0:c8:aa:0d:aa:8d:21:57:8f:c6:3e:7a:ca:db: + 51:d4:52:b3:d4:96:84:a5:58:60:7f:e5:0b:8e:1f:f5:dc:0a: + 15:81:e5:3b:b6:b7:22:2f:09:9c:13:16:b1:6c:0c:35:08:6d: + ab:63:72:ed:dc:be:ec:c7:57:e6:30:20:71:d6:d7:10:c1:13: + 55:01:8c:2a:43:e4:41:f1:cf:3a:7a:53:92:ce:a2:03:05:0d: + 38:df:02:bb:10:2e:d9:3b:d2:9b:7a:c0:a1:a6:f8:b5:31:e6: + f4:75:c9:b9:53:99:75:47:22:5a:14:15:c7:78:1b:b6:9d:e9: + 0c:f8:1b:76:f1:85:84:de:a1:da:12:ef:a4:e2:10:97:7a:78: + de:0c:51:97:a8:21:40:8b:86:bd:0d:f0:5e:4e:4b:36:bb:3b: + 20:1f:8a:42:56:e1:0b:1a:bf:7b:d0:22:43:2c:44:8c:fb:e5: + 2a:b4:6c:1c:1c:ba:94:e0:13:7e:21:e6:9a:c2:cb:c5:42:64: + b4:1e:94:7b:08:25:c8:71:cc:87:45:57:85:d3:9f:29:62:22: + 83:51:97:00:18:97:77:6a:98:92:c9:7c:60:6c:df:6c:7d:4a: + e4:70:4c:c2:9e:b8:1d:f7:d0:34:c7:0f:cc:fb:a7:ff:03:be: + ad:70:90:da:0b:dd:c8:6d:97:5f:9a:7f:09:32:41:fd:cd:a2: + cc:5a:6d:4c:f2:aa:49:fe:66:f8:e9:d8:35:eb:0e:28:1e:ee: + 48:2f:3a:d0:79:09:38:7c:a6:22:82:93:95:d0:03:be:be:02: + a0:05:dd:20:22:e3:6f:1d:88:34:60:c6:e6:0a:b9:09:75:0b: + f0:07:e8:69:96:35:c7:fb:23:81:8e:38:39:b8:45:2b:43:78: + a2:d1:2c:14:ff:0d:28:72:72:95:9b:5e:09:db:89:44:98:aa: + a1:49:bb:71:52:f2:bf:f6:ff:27:a1:36:af:b8:b6:77:88:dd: + 3a:a4:6d:9b:34:90:dc:14:5d:30:bf:b7:eb:17:e4:87:b7:71: + d0:a1:d7:77:15:d4:42:d7:f2:f3:31:99:5d:9b:dd:16:6d:3f: + ea:06:23:f8:46:a2:22:ed:93:f6:dd:9a:e6:2a:87:b1:98:54: + f1:22:f7:6b:45:e3:e2:8e:76:1d:9a:8d:c4:06:8d:36:b7:14: + f3:9d:54:69:b7:8e:3c:d5:a4:6d:93:81:b7:ad:f6:bd:64:7b: + c2:c9:68:39:a0:92:9c:cd:34:86:91:90:fa:64:51:9d:fe:fe: + eb:a5:f5:75:de:89:f7:72 +SHA1 Fingerprint=8F:6B:F2:A9:27:4A:DA:14:A0:C4:F4:8E:61:27:F9:C0:1E:78:5D:D1 +-----BEGIN CERTIFICATE----- +MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEM +BQAwaTELMAkGA1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRG +T1JNIENvcnAuMTIwMAYDVQQDDClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0 +aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4NDJaFw0zNzA4MTgyMzU5NTlaMGkx +CzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVTUyBQTEFURk9STSBD +b3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVA +iQqrDZBbUGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH +38dq6SZeWYp34+hInDEW+j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lE +HoSTGEq0n+USZGnQJoViAbbJAh2+g1G7XNr4rRVqmfeSVPc0W+m/6imBEtRTkZaz +kVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2aacp+yPOiNgSnABIqKYP +szuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4Yb8Obtoq +vC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHf +nZ3zVHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaG +YQ5fG8Ir4ozVu53BA0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo +0es+nPxdGoMuK8u180SdOqcXYZaicdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3a +CJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejyYhbLgGvtPe31HzClrkvJE+2K +AQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNVHQ4EFgQU0p+I +36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB +Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoN +qo0hV4/GPnrK21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatj +cu3cvuzHV+YwIHHW1xDBE1UBjCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm ++LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bxhYTeodoS76TiEJd6eN4MUZeoIUCL +hr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTgE34h5prCy8VCZLQe +lHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTHD8z7 +p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8 +piKCk5XQA76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLR +LBT/DShycpWbXgnbiUSYqqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX +5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oGI/hGoiLtk/bdmuYqh7GYVPEi92tF4+KO +dh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmgkpzNNIaRkPpkUZ3+/uul +9XXeifdy +-----END CERTIFICATE----- From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 9191555BC7E; Wed, 24 Feb 2021 01:42: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 4DldvS2k4Vz3HCZ; Wed, 24 Feb 2021 01:42: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 BF66224184; Wed, 24 Feb 2021 01:42:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1gA4N054562; Wed, 24 Feb 2021 01:42:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1gAfd054561; Wed, 24 Feb 2021 01:42:10 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:10 GMT Message-Id: <202102240142.11O1gAfd054561@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: 602f1da04217 - releng/12.2 - xen-blkback: fix leak of grant maps on ring setup failure 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 602f1da04217967e7627be3fe19a56098ad29b6f 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, 24 Feb 2021 01:42:15 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=602f1da04217967e7627be3fe19a56098ad29b6f commit 602f1da04217967e7627be3fe19a56098ad29b6f Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:01 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Approved by: so Security: CVE-2021-26932 Security: FreeBSD-SA-21:06.xen Security: XSA-361 Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) (cherry picked from commit dfb372f5d38c302953a6a4e2838179cd0a1a6438) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index d935ba965b00..b98ccb6e2595 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2912,10 +2912,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 98B8355BF92; Wed, 24 Feb 2021 01:42: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 4DldvW6L3sz3HFj; Wed, 24 Feb 2021 01:42:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 863A323FB6; Wed, 24 Feb 2021 01:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1gB0F054795; Wed, 24 Feb 2021 01:42:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1gBhj054781; Wed, 24 Feb 2021 01:42:11 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:11 GMT Message-Id: <202102240142.11O1gBhj054781@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: f8e0874a2d97 - releng/12.2 - pam_login_access: Fix negative entry matching logic 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: f8e0874a2d975f98fd87a63460faa4f09f84b33c 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, 24 Feb 2021 01:42:17 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f8e0874a2d975f98fd87a63460faa4f09f84b33c commit f8e0874a2d975f98fd87a63460faa4f09f84b33c Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:01 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) (cherry picked from commit c99e3e2d96935ae4d61948bf7660e9b9c2afb4d9) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 C440C55C014; Wed, 24 Feb 2021 01:42: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 4DldvX6WzCz3HHl; Wed, 24 Feb 2021 01:42: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 B92F02405E; Wed, 24 Feb 2021 01:42: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 11O1gCJL055455; Wed, 24 Feb 2021 01:42:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1gCqX055454; Wed, 24 Feb 2021 01:42:12 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:12 GMT Message-Id: <202102240142.11O1gCqX055454@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: 142f0d36d909 - releng/12.2 - Add UPDATING entry and bump version 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/releng/12.2 X-Git-Reftype: branch X-Git-Commit: 142f0d36d90979a983e1bb0b69d1d859338b4d90 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, 24 Feb 2021 01:42:19 -0000 The branch releng/12.2 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=142f0d36d90979a983e1bb0b69d1d859338b4d90 commit 142f0d36d90979a983e1bb0b69d1d859338b4d90 Author: Mark Johnston AuthorDate: 2021-02-23 23:00:02 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:01 +0000 Add UPDATING entry and bump version Approved by: so --- UPDATING | 22 ++++++++++++++++++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index 7273d677649d..b33065306a1e 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,28 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20210223: p4 FreeBSD-SA-21:03.pam_login_access + FreeBSD-SA-21:04.jail_remove + FreeBSD-SA-21:05.jail_chdir + FreeBSD-SA-21:06.xen + FreeBSD-EN-21:06.microcode + FreeBSD-EN-21:07.caroot + FreeBSD-EN-21:08.freebsd-update + + login.access fails to apply rules [SA-21:03.pam_login_access] + + jail_remove(2) fails to kill all jailed processes [SA-21:04.jail_remove] + + jail_attach(2) relies on the caller to change the cwd [SA-21:05.jail_chdir] + + Xen grant mapping error handling issues [SA-21:06.xen] + + Boot-time microcode loading causes a boot hang [EN-21:06.microcode] + + Root certificate bundle update [EN-21:07.caroot] + + freebsd-update passwd regeneration [EN-21:08.freebsd-update] + 20210128: p3 FreeBSD-EN-21:01.tzdata FreeBSD-EN-21:03.vnet FreeBSD-EN-21:04.zfs diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 3e08cc3503ef..dfcb11bb7d5d 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -49,7 +49,7 @@ TYPE="FreeBSD" REVISION="12.2" -BRANCH="RELEASE-p3" +BRANCH="RELEASE-p4" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 B34D955C28B; Wed, 24 Feb 2021 01:42: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 4DldwK6sLnz3Hf2; Wed, 24 Feb 2021 01:42:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 62D1C2412C; Wed, 24 Feb 2021 01:42: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 11O1gqaW055758; Wed, 24 Feb 2021 01:42:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1gqcE055756; Wed, 24 Feb 2021 01:42:52 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:52 GMT Message-Id: <202102240142.11O1gqcE055756@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: 035021b98a25 - releng/13.0 - Add UPDATING entries and bump version 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 035021b98a251247ba62ffbb6b6411766b3dd321 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, 24 Feb 2021 01:42:59 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=035021b98a251247ba62ffbb6b6411766b3dd321 commit 035021b98a251247ba62ffbb6b6411766b3dd321 Author: Mark Johnston AuthorDate: 2021-02-24 00:21:19 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:47 +0000 Add UPDATING entries and bump version Approved by: re (implicit, so) Approved by: so --- UPDATING | 7 +++++++ sys/conf/newvers.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UPDATING b/UPDATING index c42fe6639b12..880be2ef12e0 100644 --- a/UPDATING +++ b/UPDATING @@ -11,6 +11,13 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +20210223: p1 FreeBSD-SA-21:03.pam_login_access + FreeBSD-SA-21:06.xen + + login.access fails to apply rules [SA-21:03.pam_login_access] + + Xen grant mapping error handling issues [SA-21:06.xen] + 20210202: Various LinuxKPI functionality was added which conflicts with DRM. Please update your drm-kmod port to after the __FreeBSD_verison 1300139 diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index b0887168026a..fa48289cc39a 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -54,7 +54,7 @@ TYPE="FreeBSD" REVISION="13.0" -BRANCH="BETA3" +BRANCH="BETA3-p1" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 D452D55C1BA; Wed, 24 Feb 2021 01:42: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 4DldwK75csz3Hl4; Wed, 24 Feb 2021 01:42:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C6BD2406F; Wed, 24 Feb 2021 01:42:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O1goRt055714; Wed, 24 Feb 2021 01:42:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1goX9055713; Wed, 24 Feb 2021 01:42:50 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:50 GMT Message-Id: <202102240142.11O1goX9055713@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: ce9af53d0897 - releng/13.0 - xen-blkback: fix leak of grant maps on ring setup failure 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ce9af53d0897a1cb926bd244f499fc09b1626b27 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, 24 Feb 2021 01:43:00 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ce9af53d0897a1cb926bd244f499fc09b1626b27 commit ce9af53d0897a1cb926bd244f499fc09b1626b27 Author: Roger Pau Monné AuthorDate: 2021-01-20 18:40:51 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:35 +0000 xen-blkback: fix leak of grant maps on ring setup failure Multi page rings are mapped using a single hypercall that gets passed an array of grants to map. One of the grants in the array failing to map would lead to the failure of the whole ring setup operation, but there was no cleanup of the rest of the grant maps in the array that could have likely been created as a result of the hypercall. Add proper cleanup on the failure path during ring setup to unmap any grants that could have been created. This is part of XSA-361. Approved by: re (implicit, so) Approved by: so Security: CVE-2021-26932 Security: FreeBSD-SA-21:06.xen Security: XSA-361 Sponsored by: Citrix Systems R&D (cherry picked from commit 808d4aad1022a2a33d222663b0c9badde30b9d45) (cherry picked from commit ab3e1bd3c22a222520c23c2793cc39e3a23c9b46) --- sys/dev/xen/blkback/blkback.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 762f25302c00..678472cc2ab8 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2893,10 +2893,31 @@ xbb_connect_ring(struct xbb_softc *xbb) ring_idx < xbb->ring_config.ring_pages; ring_idx++, gnt++) { if (gnt->status != 0) { + struct gnttab_unmap_grant_ref unmap[XBB_MAX_RING_PAGES]; + unsigned int i, j; + xbb->ring_config.va = 0; xenbus_dev_fatal(xbb->dev, EACCES, "Ring shared page mapping failed. " "Status %d.", gnt->status); + + /* Unmap everything to avoid leaking grant table maps */ + for (i = 0, j = 0; i < xbb->ring_config.ring_pages; + i++) { + if (gnts[i].status != GNTST_okay) + continue; + + unmap[j].host_addr = gnts[i].host_addr; + unmap[j].dev_bus_addr = gnts[i].dev_bus_addr; + unmap[j++].handle = gnts[i].handle; + } + if (j != 0) { + error = HYPERVISOR_grant_table_op( + GNTTABOP_unmap_grant_ref, unmap, j); + if (error != 0) + panic("Unable to unmap grants (%d)", + error); + } return (EACCES); } xbb->ring_config.handle[ring_idx] = gnt->handle; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 01:42: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 BCF0755C304; Wed, 24 Feb 2021 01:42: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 4DldwK75Wwz3Hl3; Wed, 24 Feb 2021 01:42:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 579DF23E5D; Wed, 24 Feb 2021 01:42: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 11O1gpYK055737; Wed, 24 Feb 2021 01:42:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O1gpCT055736; Wed, 24 Feb 2021 01:42:51 GMT (envelope-from git) Date: Wed, 24 Feb 2021 01:42:51 GMT Message-Id: <202102240142.11O1gpCT055736@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: f82cffcf2f44 - releng/13.0 - pam_login_access: Fix negative entry matching logic 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f82cffcf2f44c909bec00d18549826f5d1d62205 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, 24 Feb 2021 01:43:00 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f82cffcf2f44c909bec00d18549826f5d1d62205 commit f82cffcf2f44c909bec00d18549826f5d1d62205 Author: Mark Johnston AuthorDate: 2021-02-23 22:01:29 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 01:42:42 +0000 pam_login_access: Fix negative entry matching logic PR: 252194 Approved by: re (implicit, so) Approved by: so Security: CVE-2020-25580 Security: FreeBSD-SA-21:03.pam_login_access (cherry picked from commit 6ab923cbca8759503a08683a5978b9ebf5efd607) (cherry picked from commit 8cf559d6b9b4782bf67eb868ea480f47fc8c64a4) --- lib/libpam/modules/pam_login_access/login_access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c index 9496081d362e..719808858dac 100644 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ b/lib/libpam/modules/pam_login_access/login_access.c @@ -137,10 +137,10 @@ list_match(char *list, const char *item, if (match != NO) { while ((tok = strtok((char *) 0, listsep)) && strcmp(tok, "EXCEPT")) { /* VOID */ ; - if (tok == NULL || list_match((char *) 0, item, match_fn, - login_access_opts) == NO) { + } + if (tok == NULL || + list_match((char *) 0, item, match_fn, login_access_opts) == NO) { return (match); - } } } return (NO); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 04:49:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D530354807E; Wed, 24 Feb 2021 04:49:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dlk3k5k8vz3lnf; Wed, 24 Feb 2021 04:49:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B2F5226614; Wed, 24 Feb 2021 04:49:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O4ncfg095979; Wed, 24 Feb 2021 04:49:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O4ncm1095978; Wed, 24 Feb 2021 04:49:38 GMT (envelope-from git) Date: Wed, 24 Feb 2021 04:49:38 GMT Message-Id: <202102240449.11O4ncm1095978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 7f73db6d04d0 - stable/13 - 504ebd612ec: kern: sonewconn: set so_options before pru_attach() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7f73db6d04d0fcfe52dde537ba1495886f34762d 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, 24 Feb 2021 04:49:38 -0000 The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7f73db6d04d0fcfe52dde537ba1495886f34762d commit 7f73db6d04d0fcfe52dde537ba1495886f34762d Author: Kyle Evans AuthorDate: 2021-01-20 17:53:05 +0000 Commit: Kyle Evans CommitDate: 2021-02-24 04:48:42 +0000 504ebd612ec: kern: sonewconn: set so_options before pru_attach() Protocol attachment has historically been able to observe and modify so->so_options as needed, and it still can for newly created sockets. 779f106aa169 moved this to after pru_attach() when we re-acquire the lock on the listening socket. Restore the historical behavior so that pru_attach implementations can consistently use it. Note that some pru_attach() do currently rely on this, though that may change in the future. D28265 contains a change to remove the use in TCP and IB/SDP bits, as resetting the requested linger time on incoming connections seems questionable at best. This does move the assignment out from under the head's listen lock, but glebius notes that head won't be going away and applications cannot assume any specific ordering with a race between a connection coming in and the application changing socket options anyways. 4c0bef07be0: kern: net: remove TCP_LINGERTIME TCP_LINGERTIME can be traced back to BSD 4.4 Lite and perhaps beyond, in exactly the same form that it appears here modulo slightly different context. It used to be the case that there was a single pr_usrreq method with requests dispatched to it; these exact two lines appeared in tcp_usrreq's PRU_ATTACH handling. The only purpose of this that I can find is to cause surprising behavior on accepted connections. Newly-created sockets will never hit these paths as one cannot set SO_LINGER prior to socket(2). If SO_LINGER is set on a listening socket and inherited, one would expect the timeout to be inherited rather than changed arbitrarily like this -- noting that SO_LINGER is nonsense on a listening socket beyond inheritance, since they cannot be 'connected' by definition. Neither Illumos nor Linux reset the timer like this based on testing and inspection of Illumos, and testing of Linux. (cherry picked from commit 504ebd612ec61165bb949cfce3a348b0d6f37008) (cherry picked from commit 4c0bef07be071a1633ebc86a653f9bd59d40796e) --- sys/kern/uipc_socket.c | 2 +- sys/netinet/tcp_timer.h | 2 -- sys/netinet/tcp_usrreq.c | 2 -- sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 7b16401b7071..7f06b51cf096 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -718,6 +718,7 @@ sonewconn(struct socket *head, int connstatus) } so->so_listen = head; so->so_type = head->so_type; + so->so_options = head->so_options & ~SO_ACCEPTCONN; so->so_linger = head->so_linger; so->so_state = head->so_state | SS_NOFDREF; so->so_fibnum = head->so_fibnum; @@ -754,7 +755,6 @@ sonewconn(struct socket *head, int connstatus) if (head->sol_accept_filter != NULL) connstatus = 0; so->so_state |= connstatus; - so->so_options = head->so_options & ~SO_ACCEPTCONN; soref(head); /* A socket on (in)complete queue refs head. */ if (connstatus) { TAILQ_INSERT_TAIL(&head->sol_comp, so, so_list); diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 6f0c3a46605a..9a711d173386 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -115,8 +115,6 @@ #define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */ -#define TCP_LINGERTIME 120 /* linger at most 2 minutes */ - #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ #define TCPTV_DELACK ( hz/25 ) /* 40ms timeout */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index bfa96ce093b5..31b580bfafcc 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -204,8 +204,6 @@ tcp_usr_attach(struct socket *so, int proto, struct thread *td) tp->t_state = TCPS_CLOSED; INP_WUNLOCK(inp); TCPSTATES_INC(TCPS_CLOSED); - if ((so->so_options & SO_LINGER) && so->so_linger == 0) - so->so_linger = TCP_LINGERTIME; out: TCPDEBUG2(PRU_ATTACH); TCP_PROBE2(debug__user, tp, PRU_ATTACH); diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c index 46a43e1b8e3b..e7ae4e03365e 100644 --- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c @@ -482,8 +482,6 @@ sdp_attach(struct socket *so, int proto, struct thread *td) LIST_INSERT_HEAD(&sdp_list, ssk, list); sdp_count++; SDP_LIST_WUNLOCK(); - if ((so->so_options & SO_LINGER) && so->so_linger == 0) - so->so_linger = TCP_LINGERTIME; return (0); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 04:52:39 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 CA5515485CF; Wed, 24 Feb 2021 04:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dlk7C5PsWz3mF4; Wed, 24 Feb 2021 04:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A9BC926543; Wed, 24 Feb 2021 04:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O4qd8m008161; Wed, 24 Feb 2021 04:52:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O4qdbq008160; Wed, 24 Feb 2021 04:52:39 GMT (envelope-from git) Date: Wed, 24 Feb 2021 04:52:39 GMT Message-Id: <202102240452.11O4qdbq008160@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 5e57a3806ef3 - stable/12 - 504ebd612ec: kern: sonewconn: set so_options before pru_attach() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5e57a3806ef3dc9d04981b1bc06f69507cc67684 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, 24 Feb 2021 04:52:39 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=5e57a3806ef3dc9d04981b1bc06f69507cc67684 commit 5e57a3806ef3dc9d04981b1bc06f69507cc67684 Author: Kyle Evans AuthorDate: 2021-01-20 17:53:05 +0000 Commit: Kyle Evans CommitDate: 2021-02-24 04:52:18 +0000 504ebd612ec: kern: sonewconn: set so_options before pru_attach() Protocol attachment has historically been able to observe and modify so->so_options as needed, and it still can for newly created sockets. 779f106aa169 moved this to after pru_attach() when we re-acquire the lock on the listening socket. Restore the historical behavior so that pru_attach implementations can consistently use it. Note that some pru_attach() do currently rely on this, though that may change in the future. D28265 contains a change to remove the use in TCP and IB/SDP bits, as resetting the requested linger time on incoming connections seems questionable at best. This does move the assignment out from under the head's listen lock, but glebius notes that head won't be going away and applications cannot assume any specific ordering with a race between a connection coming in and the application changing socket options anyways. 4c0bef07be0: kern: net: remove TCP_LINGERTIME TCP_LINGERTIME can be traced back to BSD 4.4 Lite and perhaps beyond, in exactly the same form that it appears here modulo slightly different context. It used to be the case that there was a single pr_usrreq method with requests dispatched to it; these exact two lines appeared in tcp_usrreq's PRU_ATTACH handling. The only purpose of this that I can find is to cause surprising behavior on accepted connections. Newly-created sockets will never hit these paths as one cannot set SO_LINGER prior to socket(2). If SO_LINGER is set on a listening socket and inherited, one would expect the timeout to be inherited rather than changed arbitrarily like this -- noting that SO_LINGER is nonsense on a listening socket beyond inheritance, since they cannot be 'connected' by definition. Neither Illumos nor Linux reset the timer like this based on testing and inspection of Illumos, and testing of Linux. (cherry picked from commit 504ebd612ec61165bb949cfce3a348b0d6f37008) (cherry picked from commit 4c0bef07be071a1633ebc86a653f9bd59d40796e) --- sys/kern/uipc_socket.c | 2 +- sys/netinet/tcp_timer.h | 2 -- sys/netinet/tcp_usrreq.c | 3 --- sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c | 2 -- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index ba03de4c32fe..ab05da880e46 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -616,6 +616,7 @@ sonewconn(struct socket *head, int connstatus) } so->so_listen = head; so->so_type = head->so_type; + so->so_options = head->so_options & ~SO_ACCEPTCONN; so->so_linger = head->so_linger; so->so_state = head->so_state | SS_NOFDREF; so->so_fibnum = head->so_fibnum; @@ -652,7 +653,6 @@ sonewconn(struct socket *head, int connstatus) if (head->sol_accept_filter != NULL) connstatus = 0; so->so_state |= connstatus; - so->so_options = head->so_options & ~SO_ACCEPTCONN; soref(head); /* A socket on (in)complete queue refs head. */ if (connstatus) { TAILQ_INSERT_TAIL(&head->sol_comp, so, so_list); diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 1f73a806eb7a..b95fcf52861b 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -115,8 +115,6 @@ #define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */ -#define TCP_LINGERTIME 120 /* linger at most 2 minutes */ - #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ #define TCPTV_DELACK ( hz/25 ) /* 40ms timeout */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 71c35c1bed66..968b1f4c5e30 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -163,9 +163,6 @@ tcp_usr_attach(struct socket *so, int proto, struct thread *td) if (error) goto out; - if ((so->so_options & SO_LINGER) && so->so_linger == 0) - so->so_linger = TCP_LINGERTIME; - inp = sotoinpcb(so); tp = intotcpcb(inp); out: diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c index 5fefa2929b12..ba6d822c38e8 100644 --- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c @@ -481,8 +481,6 @@ sdp_attach(struct socket *so, int proto, struct thread *td) LIST_INSERT_HEAD(&sdp_list, ssk, list); sdp_count++; SDP_LIST_WUNLOCK(); - if ((so->so_options & SO_LINGER) && so->so_linger == 0) - so->so_linger = TCP_LINGERTIME; return (0); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38A5A55395F; Wed, 24 Feb 2021 07:58:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpFm19YYz4ZCh; Wed, 24 Feb 2021 07:58:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AFFE28BB2; Wed, 24 Feb 2021 07:58:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7waXi046297; Wed, 24 Feb 2021 07:58:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7waUZ046296; Wed, 24 Feb 2021 07:58:36 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:36 GMT Message-Id: <202102240758.11O7waUZ046296@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 750252612dad - stable/13 - buf SU hooks: track buf_start() calls with B_IOSTARTED flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 750252612dad72149832fac62645919c73cbf5d2 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, 24 Feb 2021 07:58:36 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=750252612dad72149832fac62645919c73cbf5d2 commit 750252612dad72149832fac62645919c73cbf5d2 Author: Konstantin Belousov AuthorDate: 2021-01-30 02:10:34 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:40:04 +0000 buf SU hooks: track buf_start() calls with B_IOSTARTED flag (cherry picked from commit bf0db19339e770a82236b74f523be4b572bde15d) --- sys/kern/vfs_bio.c | 14 ++++++++++++++ sys/sys/buf.h | 16 +++++++++++----- sys/ufs/ffs/ffs_vfsops.c | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 2f18221e9270..9264388e9a3e 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2639,6 +2639,13 @@ brelse(struct buf *bp) return; } + if (LIST_EMPTY(&bp->b_dep)) { + bp->b_flags &= ~B_IOSTARTED; + } else { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("brelse: SU io not finished bp %p", bp)); + } + if ((bp->b_vflags & (BV_BKGRDINPROG | BV_BKGRDERR)) == BV_BKGRDERR) { BO_LOCK(bp->b_bufobj); bp->b_vflags &= ~BV_BKGRDERR; @@ -2826,6 +2833,13 @@ bqrelse(struct buf *bp) bp->b_flags &= ~(B_ASYNC | B_NOCACHE | B_AGE | B_RELBUF); bp->b_xflags &= ~(BX_CVTENXIO); + if (LIST_EMPTY(&bp->b_dep)) { + bp->b_flags &= ~B_IOSTARTED; + } else { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("bqrelse: SU io not finished bp %p", bp)); + } + if (bp->b_flags & B_MANAGED) { if (bp->b_flags & B_REMFREE) bremfreef(bp); diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 50fa0f35491e..2997560b9ab3 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -232,7 +232,7 @@ struct buf { #define B_MALLOC 0x00010000 /* malloced b_data */ #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ #define B_INVALONERR 0x00040000 /* Invalidate on write error. */ -#define B_00080000 0x00080000 /* Available flag. */ +#define B_IOSTARTED 0x00080000 /* buf_start() called */ #define B_00100000 0x00100000 /* Available flag. */ #define B_MAXPHYS 0x00200000 /* nitems(b_pages[]) = atop(MAXPHYS). */ #define B_RELBUF 0x00400000 /* Release VMIO buffer. */ @@ -248,8 +248,8 @@ struct buf { #define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35ram\34managed" \ "\33paging\32infreecnt\31nocopy\30b23\27relbuf\26maxphys\25b20" \ - "\24b19\23invalonerr\22clusterok\21malloc\20nocache\17b14\16inval" \ - "\15reuse\14noreuse\13eintr\12done\11b8\10delwri" \ + "\24iostarted\23invalonerr\22clusterok\21malloc\20nocache\17b14" \ + "\16inval\15reuse\14noreuse\13eintr\12done\11b8\10delwri" \ "\7validsuspwrt\6cache\5deferred\4direct\3async\2needcommit\1age" /* @@ -434,6 +434,9 @@ bstrategy(struct buf *bp) static __inline void buf_start(struct buf *bp) { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("recursed buf_start %p", bp)); + bp->b_flags |= B_IOSTARTED; if (bioops.io_start) (*bioops.io_start)(bp); } @@ -441,8 +444,11 @@ buf_start(struct buf *bp) static __inline void buf_complete(struct buf *bp) { - if (bioops.io_complete) - (*bioops.io_complete)(bp); + if ((bp->b_flags & B_IOSTARTED) != 0) { + bp->b_flags &= ~B_IOSTARTED; + if (bioops.io_complete) + (*bioops.io_complete)(bp); + } } static __inline void diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 60d4dad57d03..04afbfd4d6e4 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2393,10 +2393,10 @@ ffs_backgroundwritedone(struct buf *bp) #endif /* * This buffer is marked B_NOCACHE so when it is released - * by biodone it will be tossed. + * by biodone it will be tossed. Clear B_IOSTARTED in case of error. */ bp->b_flags |= B_NOCACHE; - bp->b_flags &= ~B_CACHE; + bp->b_flags &= ~(B_CACHE | B_IOSTARTED); pbrelvp(bp); /* From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 5AE3B553AE3; Wed, 24 Feb 2021 07:58: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 4DlpFn282Zz4ZJs; Wed, 24 Feb 2021 07:58: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 3C43E28E11; Wed, 24 Feb 2021 07:58:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wbKB046318; Wed, 24 Feb 2021 07:58:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wbiO046317; Wed, 24 Feb 2021 07:58:37 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:37 GMT Message-Id: <202102240758.11O7wbiO046317@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0672f9d80860 - stable/13 - ffs: call ufsdirhash_dirtrunc() right after setting directory size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0672f9d80860c0280aa6b2a24cb3e85df6eaeb1c 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, 24 Feb 2021 07:58:37 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0672f9d80860c0280aa6b2a24cb3e85df6eaeb1c commit 0672f9d80860c0280aa6b2a24cb3e85df6eaeb1c Author: Konstantin Belousov AuthorDate: 2021-01-28 18:33:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:40:29 +0000 ffs: call ufsdirhash_dirtrunc() right after setting directory size (cherry picked from commit e94f2f1be32294cb6d519b6631f7522466fbbb3b) --- sys/ufs/ffs/ffs_inode.c | 13 +++++++++++++ sys/ufs/ufs/ufs_lookup.c | 4 ---- sys/ufs/ufs/ufs_vnops.c | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 0b4172b34300..3df7bf8e8596 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -34,6 +34,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ufs.h" #include "opt_quota.h" #include @@ -59,6 +60,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#ifdef UFS_DIRHASH +#include +#endif #include #include @@ -456,6 +461,10 @@ ffs_truncate(vp, length, flags, cred) ip->i_size = length; DIP_SET(ip, i_size, length); UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); +#ifdef UFS_DIRHASH + if (vp->v_type == VDIR && ip->i_dirhash != NULL) + ufsdirhash_dirtrunc(ip, length); +#endif } else { lbn = lblkno(fs, length); flags |= BA_CLRBUF; @@ -482,6 +491,10 @@ ffs_truncate(vp, length, flags, cred) return (error); ip->i_size = length; DIP_SET(ip, i_size, length); +#ifdef UFS_DIRHASH + if (vp->v_type == VDIR && ip->i_dirhash != NULL) + ufsdirhash_dirtrunc(ip, length); +#endif size = blksize(fs, ip, lbn); if (vp->v_type != VDIR && offset != 0) bzero((char *)bp->b_data + offset, diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 7dbd58f795cc..2f5fbf3d8001 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1131,10 +1131,6 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) vn_printf(dvp, "ufs_direnter: failed to truncate, error %d\n", error); -#ifdef UFS_DIRHASH - if (error == 0 && dp->i_dirhash != NULL) - ufsdirhash_dirtrunc(dp, I_ENDOFF(dp)); -#endif error = 0; if (tvp != NULL) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 0e7ec7ae5453..70b5a44ca21d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1694,8 +1694,6 @@ unlockout: #ifdef UFS_DIRHASH if (error != 0) ufsdirhash_free(tdp); - else if (tdp->i_dirhash != NULL) - ufsdirhash_dirtrunc(tdp, endoff); #endif /* * Even if the directory compaction failed, rename was From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6AE2D553AE6; Wed, 24 Feb 2021 07:58:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpFp2dfBz4ZFl; Wed, 24 Feb 2021 07:58:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C7B228B54; Wed, 24 Feb 2021 07:58:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wcNM046340; Wed, 24 Feb 2021 07:58:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wc9n046339; Wed, 24 Feb 2021 07:58:38 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:38 GMT Message-Id: <202102240758.11O7wc9n046339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9255b36faf8a - stable/13 - ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9255b36faf8a6ba790517c665fb47f174fa185db 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, 24 Feb 2021 07:58:38 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9255b36faf8a6ba790517c665fb47f174fa185db commit 9255b36faf8a6ba790517c665fb47f174fa185db Author: Konstantin Belousov AuthorDate: 2021-01-26 11:35:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:40:52 +0000 ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf() (cherry picked from commit f16c26b1c009fd0d87d07d3b1cf0d5078ad7f511) --- sys/ufs/ffs/ffs_extern.h | 5 +++-- sys/ufs/ffs/ffs_vfsops.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index d54df1deced9..bdb3f533e1ad 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -122,8 +122,9 @@ int ffs_breadz(struct ufsmount *, struct vnode *, daddr_t, daddr_t, int, /* * Flags to ffs_vgetf */ -#define FFSV_FORCEINSMQ 0x0001 -#define FFSV_REPLACE 0x0002 +#define FFSV_FORCEINSMQ 0x0001 +#define FFSV_REPLACE 0x0002 +#define FFSV_REPLACE_DOOMED 0x0004 /* * Flags to ffs_reload diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 04afbfd4d6e4..91b8c30f0919 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1954,13 +1954,16 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) daddr_t dbn; int error; - MPASS((ffs_flags & FFSV_REPLACE) == 0 || (flags & LK_EXCLUSIVE) != 0); + MPASS((ffs_flags & (FFSV_REPLACE | FFSV_REPLACE_DOOMED)) == 0 || + (flags & LK_EXCLUSIVE) != 0); error = vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL); if (error != 0) return (error); if (*vpp != NULL) { - if ((ffs_flags & FFSV_REPLACE) == 0) + if ((ffs_flags & FFSV_REPLACE) == 0 || + ((ffs_flags & FFSV_REPLACE_DOOMED) == 0 || + !VN_IS_DOOMED(*vpp))) return (0); vgone(*vpp); vput(*vpp); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:41 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 83DDE553BDB; Wed, 24 Feb 2021 07:58:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpFr0G1Qz4ZR9; Wed, 24 Feb 2021 07:58:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 88DA628BB3; Wed, 24 Feb 2021 07:58:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wdSO046358; Wed, 24 Feb 2021 07:58:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wdLB046357; Wed, 24 Feb 2021 07:58:39 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:39 GMT Message-Id: <202102240758.11O7wdLB046357@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e3e958f3a4f2 - stable/13 - ffs_inotovp(): interface to convert (ino, gen) into alive vnode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e3e958f3a4f2d3c8cb630e9659bc2a65d0846c52 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, 24 Feb 2021 07:58:42 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e3e958f3a4f2d3c8cb630e9659bc2a65d0846c52 commit e3e958f3a4f2d3c8cb630e9659bc2a65d0846c52 Author: Konstantin Belousov AuthorDate: 2021-01-26 11:52:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:41:12 +0000 ffs_inotovp(): interface to convert (ino, gen) into alive vnode (cherry picked from commit 5952c86c78b177b5e904bf139e6b56519897c7e0) --- sys/ufs/ffs/ffs_extern.h | 2 ++ sys/ufs/ffs/ffs_vfsops.c | 44 ++++++++++++++++++++++++++++++++------------ sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_vfsops.c | 21 +++++---------------- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index bdb3f533e1ad..9694489266b6 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -80,6 +80,8 @@ int ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t, void ffs_fserr(struct fs *, ino_t, char *); int ffs_getcg(struct fs *, struct vnode *, u_int, int, struct buf **, struct cg **); +int ffs_inotovp(struct mount *, ino_t, u_int64_t, int, struct vnode **, + int); int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t); int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t); void ffs_oldfscompat_write(struct fs *, struct ufsmount *); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 91b8c30f0919..596e2f4b4b5f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2153,35 +2153,55 @@ ffs_fhtovp(mp, fhp, flags, vpp) struct vnode **vpp; { struct ufid *ufhp; + + ufhp = (struct ufid *)fhp; + return (ffs_inotovp(mp, ufhp->ufid_ino, ufhp->ufid_gen, flags, + vpp, 0)); +} + +int +ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) + struct mount *mp; + ino_t ino; + u_int64_t gen; + int lflags; + struct vnode **vpp; + int ffs_flags; +{ struct ufsmount *ump; + struct vnode *nvp; struct fs *fs; struct cg *cgp; struct buf *bp; - ino_t ino; u_int cg; int error; - ufhp = (struct ufid *)fhp; - ino = ufhp->ufid_ino; ump = VFSTOUFS(mp); fs = ump->um_fs; if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); + /* * Need to check if inode is initialized because UFS2 does lazy * initialization and nfs_fhtovp can offer arbitrary inode numbers. */ - if (fs->fs_magic != FS_UFS2_MAGIC) - return (ufs_fhtovp(mp, ufhp, flags, vpp)); - cg = ino_to_cg(fs, ino); - if ((error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp)) != 0) - return (error); - if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + if (fs->fs_magic == FS_UFS2_MAGIC) { + cg = ino_to_cg(fs, ino); + error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp); + if (error != 0) + return (error); + if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + brelse(bp); + return (ESTALE); + } brelse(bp); - return (ESTALE); } - brelse(bp); - return (ufs_fhtovp(mp, ufhp, flags, vpp)); + + error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); + if (error == 0) + error = ufs_fhtovp(mp, nvp, gen); + *vpp = error == 0 ? nvp : NULLVP; + return (error); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index a28fcffabd2e..ab26750455e8 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -59,7 +59,7 @@ int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); int ufs_bmap_seekdata(struct vnode *, off_t *); -int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); +int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 4813ac7db763..1a63e92b3e2c 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -222,31 +222,20 @@ ufs_uninit(vfsp) * Call the VFS_CHECKEXP beforehand to verify access. */ int -ufs_fhtovp(mp, ufhp, flags, vpp) +ufs_fhtovp(mp, nvp, gen) struct mount *mp; - struct ufid *ufhp; - int flags; - struct vnode **vpp; + struct vnode *nvp; + u_int64_t gen; { struct inode *ip; - struct vnode *nvp; - int error; - error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp); - if (error) { - *vpp = NULLVP; - return (error); - } ip = VTOI(nvp); - if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || - ip->i_effnlink <= 0) { + if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { if (ip->i_mode == 0) vgone(nvp); vput(nvp); - *vpp = NULLVP; return (ESTALE); } - *vpp = nvp; - vnode_create_vobject(*vpp, DIP(ip, i_size), curthread); + vnode_create_vobject(nvp, DIP(ip, i_size), curthread); return (0); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 807D6553CA5; Wed, 24 Feb 2021 07:58: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 4DlpFy1wt5z4ZTL; Wed, 24 Feb 2021 07:58: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 E383328E80; Wed, 24 Feb 2021 07:58: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 11O7whoH046442; Wed, 24 Feb 2021 07:58:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7whnO046441; Wed, 24 Feb 2021 07:58:43 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:43 GMT Message-Id: <202102240758.11O7whnO046441@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 75f0d88bd3f0 - stable/13 - vn_open(): If the vnode is reclaimed during open(2), do not return error. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 75f0d88bd3f0d85cce17f7d1039c7e14c7d2aa4d 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, 24 Feb 2021 07:58:48 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=75f0d88bd3f0d85cce17f7d1039c7e14c7d2aa4d commit 75f0d88bd3f0d85cce17f7d1039c7e14c7d2aa4d Author: Konstantin Belousov AuthorDate: 2021-02-03 11:02:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:42:42 +0000 vn_open(): If the vnode is reclaimed during open(2), do not return error. (cherry picked from commit ee965dfa64929227ced8adb68900c35f877480e7) --- sys/fs/deadfs/dead_vnops.c | 11 +++++++++-- sys/kern/vfs_vnops.c | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c index 09c3c996ee0e..324bbafd7caf 100644 --- a/sys/fs/deadfs/dead_vnops.c +++ b/sys/fs/deadfs/dead_vnops.c @@ -45,6 +45,7 @@ */ static vop_lookup_t dead_lookup; static vop_open_t dead_open; +static vop_close_t dead_close; static vop_getwritemount_t dead_getwritemount; static vop_rename_t dead_rename; static vop_unset_text_t dead_unset_text; @@ -55,6 +56,7 @@ struct vop_vector dead_vnodeops = { .vop_access = VOP_EBADF, .vop_advlock = VOP_EBADF, .vop_bmap = VOP_EBADF, + .vop_close = dead_close, .vop_create = VOP_PANIC, .vop_getattr = VOP_EBADF, .vop_getwritemount = dead_getwritemount, @@ -104,13 +106,18 @@ dead_lookup(struct vop_lookup_args *ap) } /* - * Open always fails as if device did not exist. + * Silently succeed open and close. */ static int dead_open(struct vop_open_args *ap) { + return (0); +} - return (ENXIO); +static int +dead_close(struct vop_close_args *ap) +{ + return (0); } int diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 1e52a797a1f7..3ec2662dfcd8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -356,8 +356,6 @@ vn_open_vnode_advlock(struct vnode *vp, int fmode, struct file *fp) fp->f_flag |= FHASLOCK; vn_lock(vp, lock_flags | LK_RETRY); - if (error == 0 && VN_IS_DOOMED(vp)) - error = ENOENT; return (error); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 B4A73553C9F; Wed, 24 Feb 2021 07:58: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 4DlpFw5vs6z4ZKT; Wed, 24 Feb 2021 07:58: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 CF10628E12; Wed, 24 Feb 2021 07:58:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wfMg046402; Wed, 24 Feb 2021 07:58:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wfZK046401; Wed, 24 Feb 2021 07:58:41 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:41 GMT Message-Id: <202102240758.11O7wfZK046401@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 861d47845f24 - stable/13 - ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 861d47845f248be085e784dc5ab4221e078f8100 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, 24 Feb 2021 07:58:47 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=861d47845f248be085e784dc5ab4221e078f8100 commit 861d47845f248be085e784dc5ab4221e078f8100 Author: Konstantin Belousov AuthorDate: 2021-01-23 21:50:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:41:58 +0000 ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync (cherry picked from commit 1de1e2bfbf3c089418bbe67c096d60315c8ca5dd) --- sys/ufs/ffs/ffs_vnops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 68985d8715f3..be2653e32adc 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -257,7 +257,6 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags) bool still_dirty, unlocked, wait; ip = VTOI(vp); - ip->i_flag &= ~IN_NEEDSYNC; bo = &vp->v_bufobj; ump = VFSTOUFS(vp->v_mount); @@ -445,6 +444,8 @@ next: } if (error == 0 && unlocked) error = ERELOOKUP; + if (error == 0) + ip->i_flag &= ~IN_NEEDSYNC; return (error); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6157D553CB5; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpG73L20z4ZS8; Wed, 24 Feb 2021 07:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD47228B57; Wed, 24 Feb 2021 07:58: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 11O7wpfM046588; Wed, 24 Feb 2021 07:58:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wpLY046587; Wed, 24 Feb 2021 07:58:51 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:51 GMT Message-Id: <202102240758.11O7wpLY046587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b7d28c4e9073 - stable/13 - ffs_vput_pair(): try harder to recover from the vnode reclaim MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7d28c4e9073299c2a18c5c7d8013f5f55eb73ce 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, 24 Feb 2021 07:58:57 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b7d28c4e9073299c2a18c5c7d8013f5f55eb73ce commit b7d28c4e9073299c2a18c5c7d8013f5f55eb73ce Author: Konstantin Belousov AuthorDate: 2021-01-27 18:10:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:45:01 +0000 ffs_vput_pair(): try harder to recover from the vnode reclaim (cherry picked from commit 30bfb2fa0fad8e5bbcce369df46dcaa2e08324f3) --- sys/ufs/ffs/ffs_vnops.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 623b13790ce0..2ac67adad5f2 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1924,8 +1924,11 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) static int ffs_vput_pair(struct vop_vput_pair_args *ap) { - struct vnode *dvp, *vp, **vpp; - struct inode *dp; + struct mount *mp; + struct vnode *dvp, *vp, *vp1, **vpp; + struct inode *dp, *ip; + ino_t ip_ino; + u_int64_t ip_gen; int error, vp_locked; dvp = ap->a_dvp; @@ -1940,12 +1943,17 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) return (0); } + mp = NULL; if (vp != NULL) { if (ap->a_unlock_vp) { vput(vp); } else { MPASS(vp->v_type != VNON); vp_locked = VOP_ISLOCKED(vp); + ip = VTOI(vp); + ip_ino = ip->i_number; + ip_gen = ip->i_gen; + mp = vp->v_mount; VOP_UNLOCK(vp); } } @@ -1957,6 +1965,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) if (vp == NULL || ap->a_unlock_vp) return (0); + MPASS(mp != NULL); /* * It is possible that vp is reclaimed at this point. Only @@ -1970,5 +1979,29 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) * and respond to dead vnodes by returning ESTALE. */ VOP_LOCK(vp, vp_locked | LK_RETRY); - return (0); + if (!VN_IS_DOOMED(vp)) + return (0); + + /* + * Try harder to recover from reclaimed vp if reclaim was not + * because underlying inode was cleared. We saved inode + * number and inode generation, so we can try to reinstantiate + * exactly same version of inode. If this fails, return + * original doomed vnode and let caller to handle + * consequences. + * + * Note that callers must keep write started around + * VOP_VPUT_PAIR() calls, so it is safe to use mp without + * busying it. + */ + VOP_UNLOCK(vp); + error = ffs_inotovp(mp, ip_ino, ip_gen, LK_EXCLUSIVE, &vp1, + FFSV_REPLACE_DOOMED); + if (error != 0) { + VOP_LOCK(vp, vp_locked | LK_RETRY); + } else { + vrele(vp); + *vpp = vp1; + } + return (error); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7ADEF553A7C; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpG62LZDz4ZS2; Wed, 24 Feb 2021 07:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFA3A28C1E; Wed, 24 Feb 2021 07:58: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 11O7wqcD046608; Wed, 24 Feb 2021 07:58:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wqLq046607; Wed, 24 Feb 2021 07:58:52 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:52 GMT Message-Id: <202102240758.11O7wqLq046607@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c918922cb9a7 - stable/13 - ufs_direnter: move directory truncation to ffs_vput_pair(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c918922cb9a74f4f5f39420527642f207ba1ce50 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, 24 Feb 2021 07:58:58 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c918922cb9a74f4f5f39420527642f207ba1ce50 commit c918922cb9a74f4f5f39420527642f207ba1ce50 Author: Konstantin Belousov AuthorDate: 2021-01-27 20:34:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:45:21 +0000 ufs_direnter: move directory truncation to ffs_vput_pair(). (cherry picked from commit 74a3652f832f4ed0f1ad9f7eb60d70013b478e1a) --- sys/ufs/ffs/ffs_vnops.c | 44 ++++++++++++++++++++++++++++++++++++++------ sys/ufs/ufs/inode.h | 2 ++ sys/ufs/ufs/ufs_lookup.c | 25 ++++++------------------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 2ac67adad5f2..dd0f1ba6b81d 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include "opt_directio.h" #include "opt_ffs.h" +#include "opt_ufs.h" #include #include @@ -99,6 +100,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#ifdef UFS_DIRHASH +#include +#endif #include #include @@ -1929,6 +1934,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) struct inode *dp, *ip; ino_t ip_ino; u_int64_t ip_gen; + off_t old_size; int error, vp_locked; dvp = ap->a_dvp; @@ -1936,14 +1942,14 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) vpp = ap->a_vpp; vp = vpp != NULL ? *vpp : NULL; - if ((dp->i_flag & IN_NEEDSYNC) == 0) { + if ((dp->i_flag & (IN_NEEDSYNC | IN_ENDOFF)) == 0) { vput(dvp); if (vp != NULL && ap->a_unlock_vp) vput(vp); return (0); } - mp = NULL; + mp = dvp->v_mount; if (vp != NULL) { if (ap->a_unlock_vp) { vput(vp); @@ -1953,14 +1959,40 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) ip = VTOI(vp); ip_ino = ip->i_number; ip_gen = ip->i_gen; - mp = vp->v_mount; VOP_UNLOCK(vp); } } - do { - error = ffs_syncvnode(dvp, MNT_WAIT, 0); - } while (error == ERELOOKUP); + /* + * If compaction or fsync was requested do it in ffs_vput_pair() + * now that other locks are no longer held. + */ + if ((dp->i_flag & IN_ENDOFF) != 0) { + dp->i_flag &= ~IN_ENDOFF; + if (I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { + old_size = dp->i_size; + error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), + IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), + curthread->td_ucred); + if (error != 0 && error != ERELOOKUP) { + if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { + vn_printf(dvp, + "IN_ENDOFF: failed to truncate, " + "error %d\n", error); + } +#ifdef UFS_DIRHASH + ufsdirhash_free(dp); +#endif + } + } + SET_I_ENDOFF(dp, 0); + } + if ((dp->i_flag & IN_NEEDSYNC) != 0) { + do { + error = ffs_syncvnode(dvp, MNT_WAIT, 0); + } while (error == ERELOOKUP); + } + vput(dvp); if (vp == NULL || ap->a_unlock_vp) diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 16db8d6d5cea..4515dcbed401 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -152,6 +152,8 @@ struct inode { #define IN_IBLKDATA 0x0800 /* datasync requires inode block update */ #define IN_SIZEMOD 0x1000 /* Inode size has been modified */ +#define IN_ENDOFF 0x2000 /* Free space at the end of directory, + try to truncate when possible */ #define PRINT_INODE_FLAGS "\20\20b16\17b15\16b14\15sizemod" \ "\14iblkdata\13is_ufs2\12truncated\11ea_lockwait\10ea_locked" \ diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index e614f189a623..3036bce81caf 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1112,27 +1112,14 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) } } UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE); + /* - * If all went well, and the directory can be shortened, proceed - * with the truncation. Note that we have to unlock the inode for - * the entry that we just entered, as the truncation may need to - * lock other inodes which can lead to deadlock if we also hold a - * lock on the newly entered node. + * If all went well, and the directory can be shortened, mark directory inode + * with the truncation request right before unlock. */ - if (isrename == 0 && error == 0 && - I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { - if (tvp != NULL) - VOP_UNLOCK(tvp); - error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), - IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), cr); - if (error != 0) - vn_printf(dvp, - "ufs_direnter: failed to truncate, error %d\n", - error); - error = 0; - if (tvp != NULL) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); - } + if (isrename == 0 && error == 0) + UFS_INODE_SET_FLAG(dp, IN_ENDOFF); + return (error); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67006553C31; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpG60qvlz4ZgM; Wed, 24 Feb 2021 07:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BCF1288C2; Wed, 24 Feb 2021 07:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wolc046566; Wed, 24 Feb 2021 07:58:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wolM046565; Wed, 24 Feb 2021 07:58:50 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:50 GMT Message-Id: <202102240758.11O7wolM046565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1de6eb52fdbf - stable/13 - FFS: implement special VOP_VPUT_PAIR(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1de6eb52fdbfca2df545cf4860b8f18c1f140f70 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, 24 Feb 2021 07:58:57 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1de6eb52fdbfca2df545cf4860b8f18c1f140f70 commit 1de6eb52fdbfca2df545cf4860b8f18c1f140f70 Author: Konstantin Belousov AuthorDate: 2021-01-27 18:09:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:44:41 +0000 FFS: implement special VOP_VPUT_PAIR(). (cherry picked from commit f2c9d038bdee547be07c8b0404547617b71f2232) --- sys/ufs/ffs/ffs_vnops.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index be2653e32adc..623b13790ce0 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -130,6 +130,7 @@ static vop_listextattr_t ffs_listextattr; static vop_openextattr_t ffs_openextattr; static vop_setextattr_t ffs_setextattr; static vop_vptofh_t ffs_vptofh; +static vop_vput_pair_t ffs_vput_pair; /* Global vfs data structures for ufs. */ struct vop_vector ffs_vnodeops1 = { @@ -146,6 +147,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_reallocblks = ffs_reallocblks, .vop_write = ffs_write, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops1); @@ -182,6 +184,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_openextattr = ffs_openextattr, .vop_setextattr = ffs_setextattr, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops2); @@ -1917,3 +1920,55 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) return (error); } + +static int +ffs_vput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + struct inode *dp; + int error, vp_locked; + + dvp = ap->a_dvp; + dp = VTOI(dvp); + vpp = ap->a_vpp; + vp = vpp != NULL ? *vpp : NULL; + + if ((dp->i_flag & IN_NEEDSYNC) == 0) { + vput(dvp); + if (vp != NULL && ap->a_unlock_vp) + vput(vp); + return (0); + } + + if (vp != NULL) { + if (ap->a_unlock_vp) { + vput(vp); + } else { + MPASS(vp->v_type != VNON); + vp_locked = VOP_ISLOCKED(vp); + VOP_UNLOCK(vp); + } + } + + do { + error = ffs_syncvnode(dvp, MNT_WAIT, 0); + } while (error == ERELOOKUP); + vput(dvp); + + if (vp == NULL || ap->a_unlock_vp) + return (0); + + /* + * It is possible that vp is reclaimed at this point. Only + * routines that call us with a_unlock_vp == false can find + * that their vp has been reclaimed. There are three areas + * that are affected: + * 1) vn_open_cred() - later VOPs could fail, but + * dead_open() returns 0 to simulate successful open. + * 2) ffs_snapshot() - creation of snapshot fails with EBADF. + * 3) NFS server (several places) - code is prepared to detect + * and respond to dead vnodes by returning ESTALE. + */ + VOP_LOCK(vp, vp_locked | LK_RETRY); + return (0); +} From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 68FED553BDC; Wed, 24 Feb 2021 07:58: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 4DlpFr6NJyz4ZRF; Wed, 24 Feb 2021 07:58: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 8CEB728B55; Wed, 24 Feb 2021 07:58: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 11O7wet8046380; Wed, 24 Feb 2021 07:58:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7weXx046379; Wed, 24 Feb 2021 07:58:40 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:40 GMT Message-Id: <202102240758.11O7weXx046379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ed0639829323 - stable/13 - Merge ufs_fhtovp() into ffs_inotovp(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ed0639829323e813d5ca2c5edb4d8fe17eb04fd2 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, 24 Feb 2021 07:58:42 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ed0639829323e813d5ca2c5edb4d8fe17eb04fd2 commit ed0639829323e813d5ca2c5edb4d8fe17eb04fd2 Author: Konstantin Belousov AuthorDate: 2021-01-28 12:20:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:41:37 +0000 Merge ufs_fhtovp() into ffs_inotovp(). (cherry picked from commit 89fd61d955ada4fdb20030253206201bc279cdf0) --- sys/ufs/ffs/ffs_vfsops.c | 21 +++++++++++++++++---- sys/ufs/ufs/ufs_extern.h | 1 - sys/ufs/ufs/ufs_vfsops.c | 25 ------------------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 596e2f4b4b5f..540dd02c9631 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2170,6 +2170,7 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) { struct ufsmount *ump; struct vnode *nvp; + struct inode *ip; struct fs *fs; struct cg *cgp; struct buf *bp; @@ -2178,6 +2179,8 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) ump = VFSTOUFS(mp); fs = ump->um_fs; + *vpp = NULL; + if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); @@ -2198,10 +2201,20 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) } error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); - if (error == 0) - error = ufs_fhtovp(mp, nvp, gen); - *vpp = error == 0 ? nvp : NULLVP; - return (error); + if (error != 0) + return (error); + + ip = VTOI(nvp); + if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { + if (ip->i_mode == 0) + vgone(nvp); + vput(nvp); + return (ESTALE); + } + + vnode_create_vobject(nvp, DIP(ip, i_size), curthread); + *vpp = nvp; + return (0); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index ab26750455e8..1697f2c0ba61 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -59,7 +59,6 @@ int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); int ufs_bmap_seekdata(struct vnode *, off_t *); -int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 1a63e92b3e2c..0f45baed634f 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -214,28 +214,3 @@ ufs_uninit(vfsp) #endif return (0); } - -/* - * This is the generic part of fhtovp called after the underlying - * filesystem has validated the file handle. - * - * Call the VFS_CHECKEXP beforehand to verify access. - */ -int -ufs_fhtovp(mp, nvp, gen) - struct mount *mp; - struct vnode *nvp; - u_int64_t gen; -{ - struct inode *ip; - - ip = VTOI(nvp); - if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { - if (ip->i_mode == 0) - vgone(nvp); - vput(nvp); - return (ESTALE); - } - vnode_create_vobject(nvp, DIP(ip, i_size), curthread); - return (0); -} From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 F3473553B3C; Wed, 24 Feb 2021 07:58: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 4DlpFw6GKjz4Z9X; Wed, 24 Feb 2021 07:58: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 B42E728BB4; Wed, 24 Feb 2021 07:58: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 11O7wgp0046420; Wed, 24 Feb 2021 07:58:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wg5C046419; Wed, 24 Feb 2021 07:58:42 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:42 GMT Message-Id: <202102240758.11O7wg5C046419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ed3b4bbe359b - stable/13 - ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ed3b4bbe359bc01407e455eb3f535bc0d632e9b4 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, 24 Feb 2021 07:58:46 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ed3b4bbe359bc01407e455eb3f535bc0d632e9b4 commit ed3b4bbe359bc01407e455eb3f535bc0d632e9b4 Author: Konstantin Belousov AuthorDate: 2021-01-23 21:52:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:42:20 +0000 ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory (cherry picked from commit 08c2dc2841214187a162d5e4475aa1b94d03fd77) --- sys/ufs/ufs/ufs_lookup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 2f5fbf3d8001..e614f189a623 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -964,9 +964,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) if (newdirbp) bdwrite(newdirbp); bdwrite(bp); - if ((dp->i_flag & IN_NEEDSYNC) == 0) - return (UFS_UPDATE(dvp, 0)); - return (0); + return (UFS_UPDATE(dvp, 0)); } if (DOINGASYNC(dvp)) { bdwrite(bp); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:49 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0B1CE553D12; Wed, 24 Feb 2021 07:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpG048znz4ZWk; Wed, 24 Feb 2021 07:58:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 578C228E13; Wed, 24 Feb 2021 07:58: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 11O7wliV046504; Wed, 24 Feb 2021 07:58:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wlJT046503; Wed, 24 Feb 2021 07:58:47 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:47 GMT Message-Id: <202102240758.11O7wlJT046503@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b7a3af0b9f01 - stable/13 - Use VOP_VPUT_PAIR() for eligible VFS syscalls. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7a3af0b9f010afa9cc0e29d87827f349ab2db9a 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, 24 Feb 2021 07:58:49 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b7a3af0b9f010afa9cc0e29d87827f349ab2db9a commit b7a3af0b9f010afa9cc0e29d87827f349ab2db9a Author: Konstantin Belousov AuthorDate: 2021-01-28 22:31:30 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:43:40 +0000 Use VOP_VPUT_PAIR() for eligible VFS syscalls. (cherry picked from commit 3b2aa36024abcb2d8fdbf3a6ecc7438b073b04e4) --- sys/kern/uipc_usrreq.c | 5 +++-- sys/kern/vfs_syscalls.c | 29 ++++++++++++----------------- sys/kern/vfs_vnops.c | 5 +++-- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 0809f5180cc1..ca23ccbdb05e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -669,8 +669,8 @@ restart: if (error == 0) error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); if (error) { + VOP_VPUT_PAIR(nd.ni_dvp, NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; @@ -686,7 +686,8 @@ restart: unp->unp_addr = soun; unp->unp_flags &= ~UNP_BINDING; UNP_PCB_UNLOCK(unp); - VOP_UNLOCK(vp); + vref(vp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); free(buf, M_TEMP); return (0); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 35a56510e9ef..aba3d62936bb 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1370,13 +1370,12 @@ restart: else { error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); } } - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 && !whiteout ? &nd.ni_vp : NULL, + true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; return (error); @@ -1457,12 +1456,10 @@ restart: goto out; #endif error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out: #endif - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) @@ -1629,10 +1626,10 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); - VOP_UNLOCK(vp); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); + vp = NULL; } else { vput(nd.ni_dvp); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1640,7 +1637,8 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } } - vrele(vp); + if (vp != NULL) + vrele(vp); return (error); } @@ -1710,6 +1708,7 @@ restart: else vput(nd.ni_dvp); vrele(nd.ni_vp); + nd.ni_vp = NULL; error = EEXIST; goto out; } @@ -1730,14 +1729,12 @@ restart: goto out2; #endif error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out2: #endif - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; out: @@ -3794,9 +3791,7 @@ restart: out: #endif NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); - if (error == 0) - vput(nd.ni_vp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3ec2662dfcd8..71dd379558cb 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -274,8 +274,9 @@ restart: if (error == 0) #endif error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, - &ndp->ni_cnd, vap); - vput(ndp->ni_dvp); + &ndp->ni_cnd, vap); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); vn_finished_write(mp); if (error) { NDFREE(ndp, NDF_ONLY_PNBUF); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ADDB655397D; Wed, 24 Feb 2021 07:58:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpFz3kG3z4ZGP; Wed, 24 Feb 2021 07:58: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 3521D28B56; Wed, 24 Feb 2021 07:58: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 11O7wkW6046482; Wed, 24 Feb 2021 07:58:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wkXn046481; Wed, 24 Feb 2021 07:58:46 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:46 GMT Message-Id: <202102240758.11O7wkXn046481@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e45f7c841983 - stable/13 - nullfs: provide special bypass for VOP_VPUT_PAIR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e45f7c841983f6ccd65d6061a5542989a8201826 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, 24 Feb 2021 07:58:48 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e45f7c841983f6ccd65d6061a5542989a8201826 commit e45f7c841983f6ccd65d6061a5542989a8201826 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:22:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:43:22 +0000 nullfs: provide special bypass for VOP_VPUT_PAIR (cherry picked from commit e4aaf35ab54958f74409790fa2b7df8c2d230cee) --- sys/fs/nullfs/null_vnops.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 1de0cdfca9ac..45065e0be7b5 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -967,6 +967,54 @@ null_read_pgcache(struct vop_read_pgcache_args *ap) return (error); } +/* + * Avoid standard bypass, since lower dvp and vp could be no longer + * valid after vput(). + */ +static int +null_vput_pair(struct vop_vput_pair_args *ap) +{ + struct mount *mp; + struct vnode *dvp, *ldvp, *lvp, *vp, *vp1, **vpp; + int error, res; + + dvp = ap->a_dvp; + ldvp = NULLVPTOLOWERVP(dvp); + vref(ldvp); + + vpp = ap->a_vpp; + vp = NULL; + lvp = NULL; + if (vpp != NULL) { + vp = *vpp; + if (vp != NULL) { + vhold(vp); + mp = vp->v_mount; + lvp = NULLVPTOLOWERVP(vp); + if (ap->a_unlock_vp) + vref(lvp); + } + } + + res = VOP_VPUT_PAIR(ldvp, &lvp, ap->a_unlock_vp); + + /* lvp might have been unlocked and vp reclaimed */ + if (vp != NULL) { + if (!ap->a_unlock_vp && vp->v_vnlock != lvp->v_vnlock) { + error = null_nodeget(mp, lvp, &vp1); + if (error == 0) { + vput(vp); + *vpp = vp1; + } + } + if (ap->a_unlock_vp) + vrele(vp); + vdrop(vp); + } + vrele(dvp); + return (res); +} + /* * Global vfs data structures */ @@ -997,5 +1045,6 @@ struct vop_vector null_vnodeops = { .vop_vptocnp = null_vptocnp, .vop_vptofh = null_vptofh, .vop_add_writecount = null_add_writecount, + .vop_vput_pair = null_vput_pair, }; VFS_VOP_VECTOR_REGISTER(null_vnodeops); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 937AD553BEF; Wed, 24 Feb 2021 07:58: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 4DlpG24dR2z4Z9v; Wed, 24 Feb 2021 07:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 701EA28C1D; Wed, 24 Feb 2021 07:58:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wmsk046526; Wed, 24 Feb 2021 07:58:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wmUw046525; Wed, 24 Feb 2021 07:58:48 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:48 GMT Message-Id: <202102240758.11O7wmUw046525@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6c465e4719ab - stable/13 - ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6c465e4719abe04a2c97f49385c2da3046cf39c9 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, 24 Feb 2021 07:58:53 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6c465e4719abe04a2c97f49385c2da3046cf39c9 commit 6c465e4719abe04a2c97f49385c2da3046cf39c9 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:56:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:44:07 +0000 ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE. (cherry picked from commit be44e986377780f533f961fe7c009b93379b4710) --- sys/ufs/ffs/ffs_snapshot.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 32dc47653d18..b5daec14decf 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -296,16 +296,21 @@ restart: goto restart; } error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vat); - VOP_UNLOCK(nd.ni_dvp); if (error) { + VOP_VPUT_PAIR(nd.ni_dvp, NULL, true); NDFREE(&nd, NDF_ONLY_PNBUF); vn_finished_write(wrtmp); - vrele(nd.ni_dvp); if (error == ERELOOKUP) goto restart; return (error); } vp = nd.ni_vp; + vref(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, false); + if (VN_IS_DOOMED(vp)) { + error = EBADF; + goto out; + } vnode_create_vobject(nd.ni_vp, fs->fs_size, td); vp->v_vflag |= VV_SYSTEM; ip = VTOI(vp); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 AD72D553C36; Wed, 24 Feb 2021 07:59: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 4DlpGB49jDz4ZZw; Wed, 24 Feb 2021 07:58: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 495E428E15; Wed, 24 Feb 2021 07:58: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 11O7wugH046672; Wed, 24 Feb 2021 07:58:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wuWx046671; Wed, 24 Feb 2021 07:58:56 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:56 GMT Message-Id: <202102240758.11O7wuWx046671@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: df1314860ab0 - stable/13 - ffs softdep: remove will_direnter argument of softdep_prelink() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: df1314860ab0eb5dc983bc80b1e6d6dc94610916 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, 24 Feb 2021 07:59:02 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=df1314860ab0eb5dc983bc80b1e6d6dc94610916 commit df1314860ab0eb5dc983bc80b1e6d6dc94610916 Author: Konstantin Belousov AuthorDate: 2021-01-23 22:40:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:46:18 +0000 ffs softdep: remove will_direnter argument of softdep_prelink() (cherry picked from commit ede40b0675155b5cc862652f2fee11c738a46bcd) --- sys/ufs/ffs/ffs_extern.h | 2 +- sys/ufs/ffs/ffs_softdep.c | 46 ++++++++-------------------------------------- sys/ufs/ufs/ufs_vnops.c | 12 ++++++------ 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 9694489266b6..544012089046 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -178,7 +178,7 @@ int softdep_request_cleanup(struct fs *, struct vnode *, struct ucred *, int); int softdep_prerename(struct vnode *, struct vnode *, struct vnode *, struct vnode *); -int softdep_prelink(struct vnode *, struct vnode *, int); +int softdep_prelink(struct vnode *, struct vnode *); void softdep_setup_freeblocks(struct inode *, off_t, int); void softdep_setup_inomapdep(struct buf *, struct inode *, ino_t, int); void softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t, diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e90593b20e40..3cc76f9142c3 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -621,10 +621,9 @@ softdep_prerename(fdvp, fvp, tdvp, tvp) } int -softdep_prelink(dvp, vp, will_direnter) +softdep_prelink(dvp, vp) struct vnode *dvp; struct vnode *vp; - int will_direnter; { panic("softdep_prelink called"); @@ -3358,13 +3357,11 @@ softdep_prerename(fdvp, fvp, tdvp, tvp) * syscall must be restarted at top level from the lookup. */ int -softdep_prelink(dvp, vp, will_direnter) +softdep_prelink(dvp, vp) struct vnode *dvp; struct vnode *vp; - int will_direnter; { struct ufsmount *ump; - int error, error1; ASSERT_VOP_ELOCKED(dvp, "prelink dvp"); if (vp != NULL) @@ -3372,40 +3369,13 @@ softdep_prelink(dvp, vp, will_direnter) ump = VFSTOUFS(dvp->v_mount); /* - * Nothing to do if we have sufficient journal space. - * If we currently hold the snapshot lock, we must avoid - * handling other resources that could cause deadlock. - * - * will_direnter == 1: In case allocated a directory block in - * an indirect block, we must prevent holes in the directory - * created if directory entries are written out of order. To - * accomplish this we fsync when we extend a directory into - * indirects. During rename it's not safe to drop the tvp - * lock so sync must be delayed until it is. - * - * This synchronous step could be removed if fsck and the - * kernel were taught to fill in sparse directories rather - * than panic. + * Nothing to do if we have sufficient journal space. We skip + * flushing when vp is a snapshot to avoid deadlock where + * another thread is trying to update the inodeblock for dvp + * and is waiting on snaplk that vp holds. */ - if (journal_space(ump, 0) || (vp != NULL && IS_SNAPSHOT(VTOI(vp)))) { - error = 0; - if (will_direnter && (vp == NULL || !IS_SNAPSHOT(VTOI(vp)))) { - if (vp != NULL) - VOP_UNLOCK(vp); - error = ffs_syncvnode(dvp, MNT_WAIT, 0); - if (vp != NULL) { - error1 = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error1 != 0) { - vn_lock_pair(dvp, true, vp, false); - if (error == 0) - error = ERELOOKUP; - } else if (vp->v_data == NULL) { - error = ERELOOKUP; - } - } - } - return (error); - } + if (journal_space(ump, 0) || (vp != NULL && IS_SNAPSHOT(VTOI(vp)))) + return (0); stat_journal_low++; if (vp != NULL) { diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 22199a390dd4..b035a8b1c34d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1007,7 +1007,7 @@ ufs_remove(ap) (VTOI(dvp)->i_flags & APPEND)) return (EPERM); if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, vp, true); + error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1072,7 +1072,7 @@ ufs_link(ap) #endif if (DOINGSOFTDEP(tdvp)) { - error = softdep_prelink(tdvp, vp, true); + error = softdep_prelink(tdvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1144,7 +1144,7 @@ ufs_whiteout(ap) if (DOINGSOFTDEP(dvp) && (ap->a_flags == CREATE || ap->a_flags == DELETE)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1946,7 +1946,7 @@ ufs_mkdir(ap) } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -2210,7 +2210,7 @@ ufs_rmdir(ap) goto out; } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, vp, false); + error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -2737,7 +2737,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) return (EINVAL); } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 5B0F4553CA1; Wed, 24 Feb 2021 07:58: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 4DlpFy1ww0z4ZDQ; Wed, 24 Feb 2021 07:58: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 1993828BB5; Wed, 24 Feb 2021 07:58: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 11O7wiwZ046464; Wed, 24 Feb 2021 07:58:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wiaK046463; Wed, 24 Feb 2021 07:58:44 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:44 GMT Message-Id: <202102240758.11O7wiaK046463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1f96e4cd1e3c - stable/13 - Add VOP_VPUT_PAIR() with trivial default implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f96e4cd1e3c500d3837a77811ce47b96353296b 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, 24 Feb 2021 07:58:48 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1f96e4cd1e3c500d3837a77811ce47b96353296b commit 1f96e4cd1e3c500d3837a77811ce47b96353296b Author: Konstantin Belousov AuthorDate: 2021-01-28 22:30:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:43:03 +0000 Add VOP_VPUT_PAIR() with trivial default implementation. (cherry picked from commit 49c117c193768b10f5fb1c5e4d6b88300cfbcdd6) --- sys/kern/vfs_default.c | 15 +++++++++++++++ sys/kern/vnode_if.src | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 4b96d9522ce3..382fbb2d9ace 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -92,6 +92,7 @@ static int vop_stdfdatasync(struct vop_fdatasync_args *ap); static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); static int vop_stdstat(struct vop_stat_args *ap); +static int vop_stdvput_pair(struct vop_vput_pair_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -151,6 +152,7 @@ struct vop_vector default_vnodeops = { .vop_unset_text = vop_stdunset_text, .vop_add_writecount = vop_stdadd_writecount, .vop_copy_file_range = vop_stdcopy_file_range, + .vop_vput_pair = vop_stdvput_pair, }; VFS_VOP_VECTOR_REGISTER(default_vnodeops); @@ -1592,3 +1594,16 @@ vop_stdread_pgcache(struct vop_read_pgcache_args *ap __unused) { return (EJUSTRETURN); } + +static int +vop_stdvput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + + dvp = ap->a_dvp; + vpp = ap->a_vpp; + vput(dvp); + if (vpp != NULL && ap->a_unlock_vp && (vp = *vpp) != NULL) + vput(vp); + return (0); +} diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 5d15d4a0c863..b506237f385d 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -792,6 +792,15 @@ vop_copy_file_range { }; +%% vput_pair dvp E - - + +vop_vput_pair { + IN struct vnode *dvp; + INOUT struct vnode **vpp; + IN bool unlock_vp; +}; + + # The VOPs below are spares at the end of the table to allow new VOPs to be # added in stable branches without breaking the KBI. New VOPs in HEAD should # be added above these spares. When merging a new VOP to a stable branch, From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 87F09553E0A; Wed, 24 Feb 2021 07:59: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 4DlpGC3c0qz4Zmn; Wed, 24 Feb 2021 07:58: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 2A61228E81; Wed, 24 Feb 2021 07:58:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wtgO046650; Wed, 24 Feb 2021 07:58:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wtHc046649; Wed, 24 Feb 2021 07:58:55 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:55 GMT Message-Id: <202102240758.11O7wtHc046649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 220cd6b04580 - stable/13 - ufs_direnter: directory truncation does not need special case for rename MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 220cd6b0458006554944598e170436eb0db683da 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, 24 Feb 2021 07:59:03 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=220cd6b0458006554944598e170436eb0db683da commit 220cd6b0458006554944598e170436eb0db683da Author: Konstantin Belousov AuthorDate: 2021-01-29 12:31:52 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:45:57 +0000 ufs_direnter: directory truncation does not need special case for rename (cherry picked from commit 06f2918ab8a2621c6e6bc5729ed9ab982741aaf2) --- sys/ufs/ffs/ffs_vnops.c | 25 ++++++++++++------------- sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_lookup.c | 12 +++++------- sys/ufs/ufs/ufs_vnops.c | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index dd0f1ba6b81d..38511647c502 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1968,22 +1968,21 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) * now that other locks are no longer held. */ if ((dp->i_flag & IN_ENDOFF) != 0) { + VNASSERT(I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size, dvp, + ("IN_ENDOFF set but I_ENDOFF() is not")); dp->i_flag &= ~IN_ENDOFF; - if (I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { - old_size = dp->i_size; - error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), - IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), - curthread->td_ucred); - if (error != 0 && error != ERELOOKUP) { - if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { - vn_printf(dvp, - "IN_ENDOFF: failed to truncate, " - "error %d\n", error); - } + old_size = dp->i_size; + error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), IO_NORMAL | + (DOINGASYNC(dvp) ? 0 : IO_SYNC), curthread->td_ucred); + if (error != 0 && error != ERELOOKUP) { + if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { + vn_printf(dvp, + "IN_ENDOFF: failed to truncate, " + "error %d\n", error); + } #ifdef UFS_DIRHASH - ufsdirhash_free(dp); + ufsdirhash_free(dp); #endif - } } SET_I_ENDOFF(dp, 0); } diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 1697f2c0ba61..3ac631e6ab0b 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -68,7 +68,7 @@ int ufs_extwrite(struct vop_write_args *); void ufs_makedirentry(struct inode *, struct componentname *, struct direct *); int ufs_direnter(struct vnode *, struct vnode *, struct direct *, - struct componentname *, struct buf *, int); + struct componentname *, struct buf *); int ufs_dirremove(struct vnode *, struct inode *, int, int); int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int); int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *, diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 3036bce81caf..0509185c4663 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -876,13 +876,12 @@ ufs_makedirentry(ip, cnp, newdirp) * soft dependency code). */ int -ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) +ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) struct vnode *dvp; struct vnode *tvp; struct direct *dirp; struct componentname *cnp; struct buf *newdirbp; - int isrename; { struct ucred *cr; struct thread *td; @@ -1111,14 +1110,13 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) error = bwrite(bp); } } - UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE); /* - * If all went well, and the directory can be shortened, mark directory inode - * with the truncation request right before unlock. + * If all went well, and the directory can be shortened, + * mark directory inode with the truncation request. */ - if (isrename == 0 && error == 0) - UFS_INODE_SET_FLAG(dp, IN_ENDOFF); + UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE | (error == 0 && + I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size ? IN_ENDOFF : 0)); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index c101e699bad6..22199a390dd4 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1111,7 +1111,7 @@ ufs_link(ap) error = UFS_UPDATE(vp, !DOINGSOFTDEP(vp) && !DOINGASYNC(vp)); if (!error) { ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(tdvp, vp, &newdir, cnp, NULL, 0); + error = ufs_direnter(tdvp, vp, &newdir, cnp, NULL); } if (error) { @@ -1171,7 +1171,7 @@ ufs_whiteout(ap) newdir.d_namlen = cnp->cn_namelen; bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1); newdir.d_type = DT_WHT; - error = ufs_direnter(dvp, NULL, &newdir, cnp, NULL, 0); + error = ufs_direnter(dvp, NULL, &newdir, cnp, NULL); break; case DELETE: @@ -1511,7 +1511,7 @@ relock: } } ufs_makedirentry(fip, tcnp, &newdir); - error = ufs_direnter(tdvp, NULL, &newdir, tcnp, NULL, 1); + error = ufs_direnter(tdvp, NULL, &newdir, tcnp, NULL); if (error) goto bad; /* Setup tdvp for directory compaction if needed. */ @@ -2132,7 +2132,7 @@ ufs_mkdir(ap) else if (!DOINGSOFTDEP(dvp) && ((error = bwrite(bp)))) goto bad; ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(dvp, tvp, &newdir, cnp, bp, 0); + error = ufs_direnter(dvp, tvp, &newdir, cnp, bp); bad: if (error == 0) { @@ -2865,7 +2865,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) } #endif /* !UFS_ACL */ ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(dvp, tvp, &newdir, cnp, NULL, 0); + error = ufs_direnter(dvp, tvp, &newdir, cnp, NULL); if (error) goto bad; vn_seqc_write_end(tvp); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 8DB86553D43; Wed, 24 Feb 2021 07:59: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 4DlpGL41Hqz4ZdQ; Wed, 24 Feb 2021 07:59: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 10BFB28B5B; Wed, 24 Feb 2021 07:59: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 11O7x2Fe046796; Wed, 24 Feb 2021 07:59:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7x2G5046795; Wed, 24 Feb 2021 07:59:02 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:59:02 GMT Message-Id: <202102240759.11O7x2G5046795@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3f0157cb6578 - stable/13 - ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f0157cb65788ea71e0be15ed0815faaade61054 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, 24 Feb 2021 07:59:08 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3f0157cb65788ea71e0be15ed0815faaade61054 commit 3f0157cb65788ea71e0be15ed0815faaade61054 Author: Konstantin Belousov AuthorDate: 2021-01-31 19:01:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:48:20 +0000 ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope (cherry picked from commit 26af9f72f7cb162abeced8b7e444800b601e5017) --- sys/ufs/ffs/ffs_vnops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 38511647c502..1dfdf5182a42 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -591,6 +591,9 @@ ffs_unlock_debug(struct vop_unlock_args *ap) VI_UNLOCK(vp); } } + KASSERT(vp->v_type != VDIR || vp->v_vnlock->lk_recurse != 0 || + (ip->i_flag & IN_ENDOFF) == 0, + ("ufs dir vp %p ip %p flags %#x", vp, ip, ip->i_flag)); #ifdef DIAGNOSTIC if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE && ip != NULL && vp->v_vnlock->lk_recurse == 0) From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 91D2D553C5D; Wed, 24 Feb 2021 07:59: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 4DlpGJ6zVzz4ZnD; Wed, 24 Feb 2021 07:59: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 CCDC028B59; Wed, 24 Feb 2021 07:59: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 11O7x0RT046754; Wed, 24 Feb 2021 07:59:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7x0b5046753; Wed, 24 Feb 2021 07:59:00 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:59:00 GMT Message-Id: <202102240759.11O7x0b5046753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b1ed1a515137 - stable/13 - softdep_request_cleanup: wait for softdep_request_clean_flush() to pass MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b1ed1a515137fb9cff3037a64c8e4edf7ff9b03f 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, 24 Feb 2021 07:59:08 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b1ed1a515137fb9cff3037a64c8e4edf7ff9b03f commit b1ed1a515137fb9cff3037a64c8e4edf7ff9b03f Author: Konstantin Belousov AuthorDate: 2021-02-03 23:58:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:47:41 +0000 softdep_request_cleanup: wait for softdep_request_clean_flush() to pass (cherry picked from commit 2011b44fa3f2b2bd5a24be01094420cce9144b2d) --- sys/ufs/ffs/ffs_softdep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 8c3ae9dd95fc..8c52139687f9 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -13847,6 +13847,7 @@ retry: failed_vnode = softdep_request_cleanup_flush(mp, ump); ACQUIRE_LOCK(ump); ump->um_softdep->sd_flags &= ~FLUSH_RC_ACTIVE; + wakeup(&ump->um_softdep->sd_flags); FREE_LOCK(ump); if (ump->softdep_on_worklist > 0) { stat_cleanup_retries += 1; @@ -13854,6 +13855,11 @@ retry: goto retry; } } else { + while ((ump->um_softdep->sd_flags & + FLUSH_RC_ACTIVE) != 0) { + msleep(&ump->um_softdep->sd_flags, + LOCK_PTR(ump), PVM, "ffsrca", hz); + } FREE_LOCK(ump); error = 0; } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 BC6F3553D2D; Wed, 24 Feb 2021 07:58: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 4DlpG94PBYz4ZV2; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F379428E14; Wed, 24 Feb 2021 07:58: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 11O7wrQ4046628; Wed, 24 Feb 2021 07:58:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wraZ046627; Wed, 24 Feb 2021 07:58:53 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:53 GMT Message-Id: <202102240758.11O7wraZ046627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e1e108f35102 - stable/13 - ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e1e108f351026e9f06fdc18f0db2d657402b9fcf 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, 24 Feb 2021 07:59:00 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e1e108f351026e9f06fdc18f0db2d657402b9fcf commit e1e108f351026e9f06fdc18f0db2d657402b9fcf Author: Konstantin Belousov AuthorDate: 2021-01-28 13:34:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:45:39 +0000 ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there (cherry picked from commit 038fe6e089f03ca864c1dd5ac0c76404a13bbe79) --- sys/ufs/ufs/ufs_vnops.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 70b5a44ca21d..c101e699bad6 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1676,38 +1676,16 @@ unlockout: vput(fdvp); vput(fvp); - if (tvp) - vput(tvp); + /* - * If compaction or fsync was requested do it now that other locks - * are no longer needed. + * If compaction or fsync was requested do it in + * ffs_vput_pair() now that other locks are no longer needed. */ if (error == 0 && endoff != 0) { - do { - error = UFS_TRUNCATE(tdvp, endoff, IO_NORMAL | - (DOINGASYNC(tdvp) ? 0 : IO_SYNC), tcnp->cn_cred); - } while (error == ERELOOKUP); - if (error != 0 && !ffs_fsfail_cleanup(VFSTOUFS(mp), error)) - vn_printf(tdvp, - "ufs_rename: failed to truncate, error %d\n", - error); -#ifdef UFS_DIRHASH - if (error != 0) - ufsdirhash_free(tdp); -#endif - /* - * Even if the directory compaction failed, rename was - * succesful. Do not propagate a UFS_TRUNCATE() error - * to the caller. - */ - error = 0; - } - if (error == 0 && tdp->i_flag & IN_NEEDSYNC) { - do { - error = VOP_FSYNC(tdvp, MNT_WAIT, td); - } while (error == ERELOOKUP); + UFS_INODE_SET_FLAG(tdp, IN_ENDOFF); + SET_I_ENDOFF(tdp, endoff); } - vput(tdvp); + VOP_VPUT_PAIR(tdvp, &tvp, true); return (error); bad: From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:58: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 8828F553B43; Wed, 24 Feb 2021 07:58: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 4DlpG40zZ3z4Zcq; Wed, 24 Feb 2021 07:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F4D928BB6; Wed, 24 Feb 2021 07:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wnQB046544; Wed, 24 Feb 2021 07:58:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wnjB046543; Wed, 24 Feb 2021 07:58:49 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:49 GMT Message-Id: <202102240758.11O7wnjB046543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: d96c8375a637 - stable/13 - nfsserver: use VOP_VPUT_PAIR(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d96c8375a6373a57a3c2a92b60a9f0dd1215d6c1 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, 24 Feb 2021 07:58:53 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d96c8375a6373a57a3c2a92b60a9f0dd1215d6c1 commit d96c8375a6373a57a3c2a92b60a9f0dd1215d6c1 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:02:27 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:44:24 +0000 nfsserver: use VOP_VPUT_PAIR(). (cherry picked from commit 4a21bcb24174438e0944d6e4d6633290a067b7a8) --- sys/fs/nfsserver/nfs_nfsdport.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index b781503a6815..4d19c73dfa06 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1105,7 +1105,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp, nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, nd->nd_cred, p); } - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); nfsvno_relpathbuf(ndp); if (!error) { if (*exclusive_flagp) { @@ -1140,7 +1141,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp, nvap->na_rdev = rdev; error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); nfsvno_relpathbuf(ndp); vrele(ndp->ni_startdir); if (error) @@ -1221,7 +1223,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred, vrele(ndp->ni_startdir); error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, + false); nfsvno_relpathbuf(ndp); } else { if (nvap->na_type != VFIFO && @@ -1233,7 +1236,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred, } error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, + false); nfsvno_relpathbuf(ndp); vrele(ndp->ni_startdir); /* @@ -1268,7 +1272,7 @@ nfsvno_mkdir(struct nameidata *ndp, struct nfsvattr *nvap, uid_t saved_uid, } error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, false); nfsvno_relpathbuf(ndp); out: @@ -1300,17 +1304,15 @@ nfsvno_symlink(struct nameidata *ndp, struct nfsvattr *nvap, char *pathcp, error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr, pathcp); - vput(ndp->ni_dvp); - vrele(ndp->ni_startdir); - nfsvno_relpathbuf(ndp); /* * Although FreeBSD still had the lookup code in * it for 7/current, there doesn't seem to be any * point, since VOP_SYMLINK() returns the ni_vp. * Just vput it for v2. */ - if (!not_v2 && !error) - vput(ndp->ni_vp); + VOP_VPUT_PAIR(ndp->ni_dvp, &ndp->ni_vp, !not_v2 && error == 0); + vrele(ndp->ni_startdir); + nfsvno_relpathbuf(ndp); out: NFSEXITCODE(error); @@ -1595,11 +1597,13 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred, error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd); else error = EPERM; - if (ndp->ni_dvp == vp) + if (ndp->ni_dvp == vp) { vrele(ndp->ni_dvp); - else - vput(ndp->ni_dvp); - NFSVOPUNLOCK(vp); + NFSVOPUNLOCK(vp); + } else { + vref(vp); + VOP_VPUT_PAIR(ndp->ni_dvp, &vp, true); + } } else { if (ndp->ni_dvp == ndp->ni_vp) vrele(ndp->ni_dvp); @@ -1793,7 +1797,8 @@ nfsvno_open(struct nfsrv_descript *nd, struct nameidata *ndp, nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, cred, p); } - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, nd->nd_repstat == 0 ? + &ndp->ni_vp : NULL, false); nfsvno_relpathbuf(ndp); if (!nd->nd_repstat) { if (*exclusive_flagp) { @@ -4106,7 +4111,8 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, struct vattr *nvap, error = NFSVOPLOCK(dvp, LK_EXCLUSIVE); if (error == 0) { error = VOP_CREATE(dvp, &nvp, &named.ni_cnd, vap); - NFSVOPUNLOCK(dvp); + vref(dvp); + VOP_VPUT_PAIR(dvp, error == 0 ? &nvp : NULL, false); if (error == 0) { /* Set the ownership of the file. */ error = VOP_SETATTR(nvp, nvap, tcred); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 68BA0553D92; Wed, 24 Feb 2021 07:59: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 4DlpGF025Rz4ZkF; Wed, 24 Feb 2021 07:59: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 75E6428B58; Wed, 24 Feb 2021 07:58:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wvQQ046690; Wed, 24 Feb 2021 07:58:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wv86046689; Wed, 24 Feb 2021 07:58:57 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:57 GMT Message-Id: <202102240758.11O7wv86046689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: d72a156fb67d - stable/13 - ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d72a156fb67da00890137b8f1ec5f5117fbe7015 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, 24 Feb 2021 07:59:04 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d72a156fb67da00890137b8f1ec5f5117fbe7015 commit d72a156fb67da00890137b8f1ec5f5117fbe7015 Author: Konstantin Belousov AuthorDate: 2021-01-23 23:12:39 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:46:41 +0000 ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP (cherry picked from commit 6aed2435c8bf1fa55891c7d30186c9ad91064da8) --- sys/ufs/ufs/ufs_vnops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index b035a8b1c34d..e6a78c3655cc 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1006,7 +1006,7 @@ ufs_remove(ap) if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || (VTOI(dvp)->i_flags & APPEND)) return (EPERM); - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -1071,7 +1071,7 @@ ufs_link(ap) panic("ufs_link: no name"); #endif - if (DOINGSOFTDEP(tdvp)) { + if (DOINGSUJ(tdvp)) { error = softdep_prelink(tdvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -1142,7 +1142,7 @@ ufs_whiteout(ap) struct direct newdir; int error = 0; - if (DOINGSOFTDEP(dvp) && (ap->a_flags == CREATE || + if (DOINGSUJ(dvp) && (ap->a_flags == CREATE || ap->a_flags == DELETE)) { error = softdep_prelink(dvp, NULL); if (error != 0) { @@ -1945,7 +1945,7 @@ ufs_mkdir(ap) goto out; } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); @@ -2209,7 +2209,7 @@ ufs_rmdir(ap) error = EINVAL; goto out; } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -2736,7 +2736,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) print_bad_link_count(callfunc, dvp); return (EINVAL); } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 054B4553F04; Wed, 24 Feb 2021 07:59: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 4DlpGN4xjrz4Zkb; Wed, 24 Feb 2021 07:59: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 451FD28B5C; Wed, 24 Feb 2021 07:59: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 11O7x4WQ046816; Wed, 24 Feb 2021 07:59:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7x46M046815; Wed, 24 Feb 2021 07:59:04 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:59:04 GMT Message-Id: <202102240759.11O7x46M046815@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c6e46d0c6b9a - stable/13 - fifo: minor comment and assert improvements. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c6e46d0c6b9a6a79333689c4bf735cb5456200a2 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, 24 Feb 2021 07:59:12 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c6e46d0c6b9a6a79333689c4bf735cb5456200a2 commit c6e46d0c6b9a6a79333689c4bf735cb5456200a2 Author: Konstantin Belousov AuthorDate: 2021-02-01 10:43:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:48:37 +0000 fifo: minor comment and assert improvements. (cherry picked from commit adf28ab45670329459aed8afeec2dbe91c9b3713) --- sys/kern/vfs_syscalls.c | 3 ++- sys/ufs/ufs/ufs_vnops.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index aba3d62936bb..a51d693446e3 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1183,7 +1183,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, * vnode operations here. */ if (fp->f_ops == &badfileops) { - KASSERT(vp->v_type != VFIFO, ("Unexpected fifo.")); + KASSERT(vp->v_type != VFIFO, + ("Unexpected fifo fp %p vp %p", fp, vp)); finit_vnode(fp, flags, NULL, &vnops); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index e6a78c3655cc..301c583291d1 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -252,9 +252,10 @@ ufs_mknod(ap) DIP_SET(ip, i_rdev, vap->va_rdev); } /* - * Remove inode, then reload it through VFS_VGET so it is - * checked to see if it is an alias of an existing entry in - * the inode cache. XXX I don't believe this is necessary now. + * Remove inode, then reload it through VFS_VGET(). This is + * needed to do further inode initialization, for instance + * fifo, which was too early for VFS_VGET() done as part of + * UFS_VALLOC(). */ (*vpp)->v_type = VNON; ino = ip->i_number; /* Save this before vgone() invalidates ip. */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 56ECC553D4C; Wed, 24 Feb 2021 07:59: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 4DlpGN4ytYz4ZYG; Wed, 24 Feb 2021 07:59: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 5C94328D8F; Wed, 24 Feb 2021 07:59: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 11O7x5Go046836; Wed, 24 Feb 2021 07:59:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7x5e5046835; Wed, 24 Feb 2021 07:59:05 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:59:05 GMT Message-Id: <202102240759.11O7x5e5046835@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2947fc2ccf91 - stable/13 - lockf: ensure atomicity of lockf for open(O_CREAT|O_EXCL|O_EXLOCK) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2947fc2ccf918661b0896526a0c0513c59d8d652 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, 24 Feb 2021 07:59:12 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2947fc2ccf918661b0896526a0c0513c59d8d652 commit 2947fc2ccf918661b0896526a0c0513c59d8d652 Author: Konstantin Belousov AuthorDate: 2021-01-29 23:48:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:50:27 +0000 lockf: ensure atomicity of lockf for open(O_CREAT|O_EXCL|O_EXLOCK) (cherry picked from commit fa3bd463cee5c3abeac29a83dc86eb3abfa97b06) (cherry picked from commit 662283b1088d6488671b90ab18a66a997c526448) --- sys/kern/vfs_default.c | 15 +++++++++++++++ sys/kern/vfs_subr.c | 4 +++- sys/kern/vfs_vnops.c | 23 ++++++++++++++++++++--- sys/sys/fcntl.h | 1 + sys/sys/vnode.h | 2 ++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 382fbb2d9ace..3c428d7b7511 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -423,10 +423,25 @@ int vop_stdadvlock(struct vop_advlock_args *ap) { struct vnode *vp; + struct mount *mp; struct vattr vattr; int error; vp = ap->a_vp; + + /* + * Provide atomicity of open(O_CREAT | O_EXCL | O_EXLOCK) for + * local filesystems. See vn_open_cred() for reciprocal part. + */ + mp = vp->v_mount; + if (mp != NULL && (mp->mnt_flag & MNT_LOCAL) != 0 && + ap->a_op == F_SETLK && (ap->a_flags & F_FIRSTOPEN) == 0) { + VI_LOCK(vp); + while ((vp->v_iflag & VI_FOPENING) != 0) + msleep(vp, VI_MTX(vp), PLOCK, "lockfo", 0); + VI_UNLOCK(vp); + } + if (ap->a_fl->l_whence == SEEK_END) { /* * The NFSv4 server must avoid doing a vn_lock() here, since it diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 04cd0e0175f9..3e39d19666e5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4116,8 +4116,10 @@ vn_printf(struct vnode *vp, const char *fmt, ...) strlcat(buf, "|VI_OWEINACT", sizeof(buf)); if (vp->v_iflag & VI_DEFINACT) strlcat(buf, "|VI_DEFINACT", sizeof(buf)); + if (vp->v_iflag & VI_FOPENING) + strlcat(buf, "|VI_FOPENING", sizeof(buf)); flags = vp->v_iflag & ~(VI_TEXT_REF | VI_MOUNT | VI_DOINGINACT | - VI_OWEINACT | VI_DEFINACT); + VI_OWEINACT | VI_DEFINACT | VI_FOPENING); if (flags != 0) { snprintf(buf2, sizeof(buf2), "|VI(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 71dd379558cb..781968f2db53 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -228,8 +228,10 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags, struct vattr vat; struct vattr *vap = &vat; int fmode, error; + bool first_open; restart: + first_open = false; fmode = *flagp; if ((fmode & (O_CREAT | O_EXCL | O_DIRECTORY)) == (O_CREAT | O_EXCL | O_DIRECTORY)) @@ -275,8 +277,16 @@ restart: #endif error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, vap); - VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : - NULL, false); + vp = ndp->ni_vp; + if (error == 0 && (fmode & O_EXCL) != 0 && + (fmode & (O_EXLOCK | O_SHLOCK)) != 0) { + VI_LOCK(vp); + vp->v_iflag |= VI_FOPENING; + VI_UNLOCK(vp); + first_open = true; + } + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &vp : NULL, + false); vn_finished_write(mp); if (error) { NDFREE(ndp, NDF_ONLY_PNBUF); @@ -287,7 +297,6 @@ restart: return (error); } fmode &= ~O_TRUNC; - vp = ndp->ni_vp; } else { if (ndp->ni_dvp == ndp->ni_vp) vrele(ndp->ni_dvp); @@ -317,6 +326,12 @@ restart: vp = ndp->ni_vp; } error = vn_open_vnode(vp, fmode, cred, td, fp); + if (first_open) { + VI_LOCK(vp); + vp->v_iflag &= ~VI_FOPENING; + wakeup(vp); + VI_UNLOCK(vp); + } if (error) goto bad; *flagp = fmode; @@ -352,6 +367,8 @@ vn_open_vnode_advlock(struct vnode *vp, int fmode, struct file *fp) type = F_FLOCK; if ((fmode & FNONBLOCK) == 0) type |= F_WAIT; + if ((fmode & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) + type |= F_FIRSTOPEN; error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type); if (error == 0) fp->f_flag |= FHASLOCK; diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 3c29c04e46db..70e68246be13 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -287,6 +287,7 @@ typedef __pid_t pid_t; #define F_POSIX 0x040 /* Use POSIX semantics for lock */ #define F_REMOTE 0x080 /* Lock owner is remote NFS client */ #define F_NOINTR 0x100 /* Ignore signals when waiting */ +#define F_FIRSTOPEN 0x200 /* First right to advlock file */ #endif /* diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 639a16881e09..9d68f9e236f6 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -254,6 +254,8 @@ struct xvnode { #define VI_DOINGINACT 0x0004 /* VOP_INACTIVE is in progress */ #define VI_OWEINACT 0x0008 /* Need to call inactive */ #define VI_DEFINACT 0x0010 /* deferred inactive */ +#define VI_FOPENING 0x0020 /* In open, with opening process having the + first right to advlock file */ #define VV_ROOT 0x0001 /* root of its filesystem */ #define VV_ISTTY 0x0002 /* vnode represents a tty */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 80A0C553D38; Wed, 24 Feb 2021 07:59: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 4DlpGG6JRzz4ZXq; Wed, 24 Feb 2021 07:59: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 8235B28D8E; Wed, 24 Feb 2021 07:58: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 11O7wwLV046712; Wed, 24 Feb 2021 07:58:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wwgW046711; Wed, 24 Feb 2021 07:58:58 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:58 GMT Message-Id: <202102240758.11O7wwgW046711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: bbf612a1af56 - stable/13 - Stop ignoring ERELOOKUP from VOP_INACTIVE() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bbf612a1af56cc4307650c5f38ec63deeefdbe32 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, 24 Feb 2021 07:59:04 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bbf612a1af56cc4307650c5f38ec63deeefdbe32 commit bbf612a1af56cc4307650c5f38ec63deeefdbe32 Author: Konstantin Belousov AuthorDate: 2021-01-30 19:17:29 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:46:59 +0000 Stop ignoring ERELOOKUP from VOP_INACTIVE() (cherry picked from commit b59a8e63d6bf9092419b7a421c655d0ae2099662) --- sys/kern/vfs_subr.c | 47 ++++++++++++++++++++++++++++++++-------------- sys/sys/vnode.h | 3 ++- sys/ufs/ffs/ffs_snapshot.c | 8 +++++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 047e4c54f0c5..04cd0e0175f9 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3159,9 +3159,21 @@ vput_final(struct vnode *vp, enum vput_op func) break; } if (error == 0) { - vinactive(vp); - if (want_unlock) - VOP_UNLOCK(vp); + if (func == VUNREF) { + VNASSERT((vp->v_vflag & VV_UNREF) == 0, vp, + ("recursive vunref")); + vp->v_vflag |= VV_UNREF; + } + for (;;) { + error = vinactive(vp); + if (want_unlock) + VOP_UNLOCK(vp); + if (error != ERELOOKUP || !want_unlock) + break; + VOP_LOCK(vp, LK_EXCLUSIVE); + } + if (func == VUNREF) + vp->v_vflag &= ~VV_UNREF; vdropl(vp); } else { vdefer_inactive(vp); @@ -3546,10 +3558,11 @@ vdropl(struct vnode *vp) * Call VOP_INACTIVE on the vnode and manage the DOINGINACT and OWEINACT * flags. DOINGINACT prevents us from recursing in calls to vinactive. */ -static void +static int vinactivef(struct vnode *vp) { struct vm_object *obj; + int error; ASSERT_VOP_ELOCKED(vp, "vinactive"); ASSERT_VI_LOCKED(vp, "vinactive"); @@ -3575,14 +3588,15 @@ vinactivef(struct vnode *vp) vm_object_page_clean(obj, 0, 0, 0); VM_OBJECT_WUNLOCK(obj); } - VOP_INACTIVE(vp); + error = VOP_INACTIVE(vp); VI_LOCK(vp); VNASSERT(vp->v_iflag & VI_DOINGINACT, vp, ("vinactive: lost VI_DOINGINACT")); vp->v_iflag &= ~VI_DOINGINACT; + return (error); } -void +int vinactive(struct vnode *vp) { @@ -3591,14 +3605,14 @@ vinactive(struct vnode *vp) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if ((vp->v_iflag & VI_OWEINACT) == 0) - return; + return (0); if (vp->v_iflag & VI_DOINGINACT) - return; + return (0); if (vp->v_usecount > 0) { vp->v_iflag &= ~VI_OWEINACT; - return; + return (0); } - vinactivef(vp); + return (vinactivef(vp)); } /* @@ -3911,10 +3925,15 @@ vgonel(struct vnode *vp) */ if (active) VOP_CLOSE(vp, FNONBLOCK, NOCRED, td); - if ((oweinact || active) && !doinginact) { - VI_LOCK(vp); - vinactivef(vp); - VI_UNLOCK(vp); + if (!doinginact) { + do { + if (oweinact || active) { + VI_LOCK(vp); + vinactivef(vp); + oweinact = (vp->v_iflag & VI_OWEINACT) != 0; + VI_UNLOCK(vp); + } + } while (oweinact); } if (vp->v_type == VSOCK) vfs_unp_reclaim(vp); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 78fbec1bd0ba..639a16881e09 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -269,6 +269,7 @@ struct xvnode { #define VV_MD 0x0800 /* vnode backs the md device */ #define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ #define VV_READLINK 0x2000 /* fdescfs linux vnode */ +#define VV_UNREF 0x4000 /* vunref, do not drop lock in inactive() */ #define VMP_LAZYLIST 0x0001 /* Vnode is on mnt's lazy list */ @@ -710,7 +711,7 @@ void vgone(struct vnode *vp); void vhold(struct vnode *); void vholdnz(struct vnode *); bool vhold_smr(struct vnode *); -void vinactive(struct vnode *vp); +int vinactive(struct vnode *vp); int vinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo); int vtruncbuf(struct vnode *vp, off_t length, int blksize); void v_inval_buf_range(struct vnode *vp, daddr_t startlbn, daddr_t endlbn, diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index b5daec14decf..72c8061917d8 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -2595,6 +2595,7 @@ process_deferred_inactive(struct mount *mp) continue; } vholdl(vp); +retry_vnode: error = vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK); if (error != 0) { vdrop(vp); @@ -2609,7 +2610,12 @@ process_deferred_inactive(struct mount *mp) UFS_INODE_SET_FLAG(ip, IN_MODIFIED); } VI_LOCK(vp); - vinactive(vp); + error = vinactive(vp); + if (error == ERELOOKUP && vp->v_usecount == 0) { + VI_UNLOCK(vp); + VOP_UNLOCK(vp); + goto retry_vnode; + } VI_UNLOCK(vp); VOP_UNLOCK(vp); vdrop(vp); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 43903553CCA; Wed, 24 Feb 2021 07:59: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 4DlpGG2QjBz4ZdB; Wed, 24 Feb 2021 07:59: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 A6A6E28C1F; Wed, 24 Feb 2021 07:58:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7wxXd046734; Wed, 24 Feb 2021 07:58:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7wxlF046733; Wed, 24 Feb 2021 07:58:59 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:58:59 GMT Message-Id: <202102240758.11O7wxlF046733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6dde909bb597 - stable/13 - ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6dde909bb5976988483dacf6c56465c62f795e8a 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, 24 Feb 2021 07:59:04 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6dde909bb5976988483dacf6c56465c62f795e8a commit 6dde909bb5976988483dacf6c56465c62f795e8a Author: Konstantin Belousov AuthorDate: 2021-01-30 19:18:22 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:47:18 +0000 ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it. (cherry picked from commit 013168db8cea926c3dde1247d400d6bedf9a889d) --- sys/ufs/ffs/ffs_softdep.c | 9 +++++---- sys/ufs/ufs/ufs_inode.c | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 3cc76f9142c3..8c3ae9dd95fc 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1493,13 +1493,14 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_t inum, struct buf *bp, } /* - * Do not drop vnode lock while inactivating. This - * would result in leaks of the VI flags and - * reclaiming of non-truncated vnode. Instead, + * Do not drop vnode lock while inactivating during + * vunref. This would result in leaks of the VI flags + * and reclaiming of non-truncated vnode. Instead, * re-schedule inactivation hoping that we would be * able to sync inode later. */ - if ((vp->v_iflag & VI_DOINGINACT) != 0) { + if ((vp->v_iflag & VI_DOINGINACT) != 0 && + (vp->v_vflag & VV_UNREF) != 0) { VI_LOCK(vp); vp->v_iflag |= VI_OWEINACT; VI_UNLOCK(vp); diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 15bd8be448a9..46e4f8e54e41 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -212,8 +212,6 @@ out: vrecycle(vp); if (mp != NULL) vn_finished_secondary_write(mp); - if (error == ERELOOKUP) - error = 0; return (error); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 07:59: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 8CA31553E8F; Wed, 24 Feb 2021 07:59: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 4DlpGK33Q0z4ZXv; Wed, 24 Feb 2021 07:59: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 EE28928B5A; Wed, 24 Feb 2021 07:59: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 11O7x15e046774; Wed, 24 Feb 2021 07:59:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7x1EE046773; Wed, 24 Feb 2021 07:59:01 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:59:01 GMT Message-Id: <202102240759.11O7x1EE046773@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ea8aa5f3edbb - stable/13 - ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ea8aa5f3edbba1048740c42d7d0734f3fd4cc7b2 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, 24 Feb 2021 07:59:08 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ea8aa5f3edbba1048740c42d7d0734f3fd4cc7b2 commit ea8aa5f3edbba1048740c42d7d0734f3fd4cc7b2 Author: Konstantin Belousov AuthorDate: 2021-01-31 18:39:49 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:48:00 +0000 ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage (cherry picked from commit 28703d27130c9cb7e7830ff53155c379a502c248) --- sys/ufs/ffs/ffs_softdep.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ sys/ufs/ffs/softdep.h | 2 ++ 2 files changed, 63 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 8c52139687f9..786fb43c7d81 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1311,6 +1311,7 @@ static int softdep_flushcache = 0; /* Should we do BIO_FLUSH? */ */ static int stat_flush_threads; /* number of softdep flushing threads */ static int stat_worklist_push; /* number of worklist cleanups */ +static int stat_delayed_inact; /* number of delayed inactivation cleanups */ static int stat_blk_limit_push; /* number of times block limit neared */ static int stat_ino_limit_push; /* number of times inode limit neared */ static int stat_blk_limit_hit; /* number of times block slowdown imposed */ @@ -1344,6 +1345,8 @@ SYSCTL_INT(_debug_softdep, OID_AUTO, flush_threads, CTLFLAG_RD, &stat_flush_threads, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, worklist_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_worklist_push, 0,""); +SYSCTL_INT(_debug_softdep, OID_AUTO, delayed_inactivations, CTLFLAG_RD, + &stat_delayed_inact, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, blk_limit_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_blk_limit_push, 0,""); SYSCTL_INT(_debug_softdep, OID_AUTO, ino_limit_push, @@ -13707,6 +13710,37 @@ softdep_slowdown(vp) return (1); } +static int +softdep_request_cleanup_filter(struct vnode *vp, void *arg __unused) +{ + return ((vp->v_iflag & VI_OWEINACT) != 0 && vp->v_usecount == 0 && + ((vp->v_vflag & VV_NOSYNC) != 0 || VTOI(vp)->i_effnlink == 0)); +} + +static void +softdep_request_cleanup_inactivate(struct mount *mp) +{ + struct vnode *vp, *mvp; + int error; + + MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, softdep_request_cleanup_filter, + NULL) { + vholdl(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY); + VI_LOCK(vp); + if (vp->v_data != NULL && vp->v_usecount == 0) { + while ((vp->v_iflag & VI_OWEINACT) != 0) { + error = vinactive(vp); + if (error != 0 && error != ERELOOKUP) + break; + } + atomic_add_int(&stat_delayed_inact, 1); + } + VOP_UNLOCK(vp); + vdropl(vp); + } +} + /* * Called by the allocation routines when they are about to fail * in the hope that we can free up the requested resource (inodes @@ -13819,6 +13853,33 @@ retry: stat_worklist_push += 1; FREE_LOCK(ump); } + + /* + * Check that there are vnodes pending inactivation. As they + * have been unlinked, inactivating them will free up their + * inodes. + */ + ACQUIRE_LOCK(ump); + if (resource == FLUSH_INODES_WAIT && + fs->fs_cstotal.cs_nifree <= needed && + fs->fs_pendinginodes <= needed) { + if ((ump->um_softdep->sd_flags & FLUSH_DI_ACTIVE) == 0) { + ump->um_softdep->sd_flags |= FLUSH_DI_ACTIVE; + FREE_LOCK(ump); + softdep_request_cleanup_inactivate(mp); + ACQUIRE_LOCK(ump); + ump->um_softdep->sd_flags &= ~FLUSH_DI_ACTIVE; + wakeup(&ump->um_softdep->sd_flags); + } else { + while ((ump->um_softdep->sd_flags & + FLUSH_DI_ACTIVE) != 0) { + msleep(&ump->um_softdep->sd_flags, + LOCK_PTR(ump), PVM, "ffsvina", hz); + } + } + } + FREE_LOCK(ump); + /* * If we still need resources and there are no more worklist * entries to process to obtain them, we have to start flushing diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 868ada00f2dc..3493aadafc98 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -1086,6 +1086,8 @@ struct mount_softdeps { #define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */ #define FLUSH_STARTING 0x0004 /* flush thread not yet started */ #define FLUSH_RC_ACTIVE 0x0008 /* a thread is flushing the mount point */ +#define FLUSH_DI_ACTIVE 0x0010 /* a thread is processing delayed + inactivations */ /* * Keep the old names from when these were in the ufsmount structure. From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 13:01: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 8C82E55C44D; Wed, 24 Feb 2021 13:01: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 4DlwzF3ZRDz3Dw0; Wed, 24 Feb 2021 13:01: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 6DC502C96C; Wed, 24 Feb 2021 13:01: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 11OD1TLX054478; Wed, 24 Feb 2021 13:01:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OD1TeX054477; Wed, 24 Feb 2021 13:01:29 GMT (envelope-from git) Date: Wed, 24 Feb 2021 13:01:29 GMT Message-Id: <202102241301.11OD1TeX054477@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: ef160e5cb919 - stable/13 - pf: Remove unused return value from (de)hook_pf() 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: ef160e5cb919659951b3d4f70a966e58d5dce56f 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, 24 Feb 2021 13:01:29 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ef160e5cb919659951b3d4f70a966e58d5dce56f commit ef160e5cb919659951b3d4f70a966e58d5dce56f Author: Kristof Provost AuthorDate: 2021-02-16 11:40:51 +0000 Commit: Kristof Provost CommitDate: 2021-02-24 08:03:43 +0000 pf: Remove unused return value from (de)hook_pf() These functions always return 0, which is good, because the code calling them doesn't handle this error gracefully. As the functions always succeed remove their return value, and the code handling their errors (because it was never executed anyway). MFC after: 1 week Sponsored by: Rubicon Communications, LLC (“Netgate”’) (cherry picked from commit 8a439f324e9010a122fa4c00426bde70dc373c2f) --- sys/netpfil/pf/pf_ioctl.c | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index bd8896cfb772..97be46509acc 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -213,8 +213,8 @@ static pfil_return_t pf_check6_out(struct mbuf **m, struct ifnet *ifp, int flags, void *ruleset __unused, struct inpcb *inp); #endif -static int hook_pf(void); -static int dehook_pf(void); +static void hook_pf(void); +static void dehook_pf(void); static int shutdown_pf(void); static int pf_load(void); static void pf_unload(void); @@ -1814,12 +1814,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td else { int cpu; - error = hook_pf(); - if (error) { - DPFPRINTF(PF_DEBUG_MISC, - ("pf: pfil registration failed\n")); - break; - } + hook_pf(); V_pf_status.running = 1; V_pf_status.since = time_second; @@ -1836,12 +1831,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td error = ENOENT; else { V_pf_status.running = 0; - error = dehook_pf(); - if (error) { - V_pf_status.running = 1; - DPFPRINTF(PF_DEBUG_MISC, - ("pf: pfil unregistration failed\n")); - } + dehook_pf(); V_pf_status.since = time_second; DPFPRINTF(PF_DEBUG_MISC, ("pf: stopped\n")); } @@ -4565,14 +4555,14 @@ VNET_DEFINE_STATIC(pfil_hook_t, pf_ip6_out_hook); #define V_pf_ip6_out_hook VNET(pf_ip6_out_hook) #endif -static int +static void hook_pf(void) { struct pfil_hook_args pha; struct pfil_link_args pla; if (V_pf_pfil_hooked) - return (0); + return; pha.pa_version = PFIL_VERSION; pha.pa_modname = "pf"; @@ -4620,15 +4610,14 @@ hook_pf(void) #endif V_pf_pfil_hooked = 1; - return (0); } -static int +static void dehook_pf(void) { if (V_pf_pfil_hooked == 0) - return (0); + return; #ifdef INET pfil_remove_hook(V_pf_ip4_in_hook); @@ -4640,7 +4629,6 @@ dehook_pf(void) #endif V_pf_pfil_hooked = 0; - return (0); } static void @@ -4688,20 +4676,10 @@ pf_load(void) static void pf_unload_vnet(void) { - int error; V_pf_vnet_active = 0; V_pf_status.running = 0; - error = dehook_pf(); - if (error) { - /* - * Should not happen! - * XXX Due to error code ESRCH, kldunload will show - * a message like 'No such process'. - */ - printf("%s : pfil unregisteration fail\n", __FUNCTION__); - return; - } + dehook_pf(); PF_RULES_WLOCK(); shutdown_pf(); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 13:01: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 AC1F955C3DE; Wed, 24 Feb 2021 13:01: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 4DlwzG4YqJz3DbS; Wed, 24 Feb 2021 13:01:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F7612CB99; Wed, 24 Feb 2021 13:01:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OD1UYS054498; Wed, 24 Feb 2021 13:01:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OD1UH9054497; Wed, 24 Feb 2021 13:01:30 GMT (envelope-from git) Date: Wed, 24 Feb 2021 13:01:30 GMT Message-Id: <202102241301.11OD1UH9054497@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: 720206821fe7 - stable/13 - pf: Assert that pfil_link() calls succeed 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: 720206821fe75cf6e80f78307ef10ec125bbd589 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, 24 Feb 2021 13:01:30 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=720206821fe75cf6e80f78307ef10ec125bbd589 commit 720206821fe75cf6e80f78307ef10ec125bbd589 Author: Kristof Provost AuthorDate: 2021-02-17 10:44:37 +0000 Commit: Kristof Provost CommitDate: 2021-02-24 08:03:56 +0000 pf: Assert that pfil_link() calls succeed These should only fail if we use them incorrectly, so assert that they succeed. MFC after: 1 week Sponsored by: Rubicon Communications, LLC (“Netgate”’) (cherry picked from commit c4e0f7aa1ae7729df8c3e525e511b84f8052375c) --- sys/netpfil/pf/pf_ioctl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 97be46509acc..c32a961f5a0b 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -4560,6 +4560,7 @@ hook_pf(void) { struct pfil_hook_args pha; struct pfil_link_args pla; + int ret; if (V_pf_pfil_hooked) return; @@ -4579,7 +4580,8 @@ hook_pf(void) pla.pa_flags = PFIL_IN | PFIL_HEADPTR | PFIL_HOOKPTR; pla.pa_head = V_inet_pfil_head; pla.pa_hook = V_pf_ip4_in_hook; - (void)pfil_link(&pla); + ret = pfil_link(&pla); + MPASS(ret == 0); pha.pa_func = pf_check_out; pha.pa_flags = PFIL_OUT; pha.pa_rulname = "default-out"; @@ -4587,7 +4589,8 @@ hook_pf(void) pla.pa_flags = PFIL_OUT | PFIL_HEADPTR | PFIL_HOOKPTR; pla.pa_head = V_inet_pfil_head; pla.pa_hook = V_pf_ip4_out_hook; - (void)pfil_link(&pla); + ret = pfil_link(&pla); + MPASS(ret == 0); #endif #ifdef INET6 pha.pa_type = PFIL_TYPE_IP6; @@ -4598,7 +4601,8 @@ hook_pf(void) pla.pa_flags = PFIL_IN | PFIL_HEADPTR | PFIL_HOOKPTR; pla.pa_head = V_inet6_pfil_head; pla.pa_hook = V_pf_ip6_in_hook; - (void)pfil_link(&pla); + ret = pfil_link(&pla); + MPASS(ret == 0); pha.pa_func = pf_check6_out; pha.pa_rulname = "default-out6"; pha.pa_flags = PFIL_OUT; @@ -4606,7 +4610,8 @@ hook_pf(void) pla.pa_flags = PFIL_OUT | PFIL_HEADPTR | PFIL_HOOKPTR; pla.pa_head = V_inet6_pfil_head; pla.pa_hook = V_pf_ip6_out_hook; - (void)pfil_link(&pla); + ret = pfil_link(&pla); + MPASS(ret == 0); #endif V_pf_pfil_hooked = 1; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 13:01:31 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D643B55C44F; Wed, 24 Feb 2021 13:01:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlwzH5cB3z3DQX; Wed, 24 Feb 2021 13:01: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 ABFA42CB5A; Wed, 24 Feb 2021 13:01: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 11OD1VxV054519; Wed, 24 Feb 2021 13:01:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OD1Vci054518; Wed, 24 Feb 2021 13:01:31 GMT (envelope-from git) Date: Wed, 24 Feb 2021 13:01:31 GMT Message-Id: <202102241301.11OD1Vci054518@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: 98e40918a6fa - stable/13 - pf tests: Explicitly ask for python3 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: 98e40918a6fa5113404b0fae15707a9804f447bd 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, 24 Feb 2021 13:01:31 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=98e40918a6fa5113404b0fae15707a9804f447bd commit 98e40918a6fa5113404b0fae15707a9804f447bd Author: Kristof Provost AuthorDate: 2021-02-17 10:45:54 +0000 Commit: Kristof Provost CommitDate: 2021-02-24 08:04:19 +0000 pf tests: Explicitly ask for python3 If we install the scapy package (which we do list as a dependency) we don't automatically install python (but we do have python3). MFC after: 1 week Sponsored by: Rubicon Communications, LLC (“Netgate”’) (cherry picked from commit 4a7d84058d88244c405fc0b73d6985681eb661f5) --- tests/sys/netpfil/common/pft_ping.py | 2 +- tests/sys/netpfil/pf/CVE-2019-5597.py | 2 +- tests/sys/netpfil/pf/CVE-2019-5598.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sys/netpfil/common/pft_ping.py b/tests/sys/netpfil/common/pft_ping.py index 957123e4f6f8..916a019d2f4a 100644 --- a/tests/sys/netpfil/common/pft_ping.py +++ b/tests/sys/netpfil/common/pft_ping.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # SPDX-License-Identifier: BSD-2-Clause # diff --git a/tests/sys/netpfil/pf/CVE-2019-5597.py b/tests/sys/netpfil/pf/CVE-2019-5597.py index bb95e95c13b7..1050af506f8d 100644 --- a/tests/sys/netpfil/pf/CVE-2019-5597.py +++ b/tests/sys/netpfil/pf/CVE-2019-5597.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # diff --git a/tests/sys/netpfil/pf/CVE-2019-5598.py b/tests/sys/netpfil/pf/CVE-2019-5598.py index 53616e681609..ac1e4f3438f5 100644 --- a/tests/sys/netpfil/pf/CVE-2019-5598.py +++ b/tests/sys/netpfil/pf/CVE-2019-5598.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 15:02: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 A256455F17B; Wed, 24 Feb 2021 15:02: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 4Dlzg64Fpvz3N9m; Wed, 24 Feb 2021 15:02: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 849FA2E04F; Wed, 24 Feb 2021 15:02: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 11OF2gCC013441; Wed, 24 Feb 2021 15:02:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OF2gOw013440; Wed, 24 Feb 2021 15:02:42 GMT (envelope-from git) Date: Wed, 24 Feb 2021 15:02:42 GMT Message-Id: <202102241502.11OF2gOw013440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 8837e9c54072 - stable/13 - arm64: validate breakpoint registers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8837e9c54072679b69ae0c0345e7ef7d241255aa 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, 24 Feb 2021 15:02:42 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8837e9c54072679b69ae0c0345e7ef7d241255aa commit 8837e9c54072679b69ae0c0345e7ef7d241255aa Author: Mitchell Horne AuthorDate: 2021-02-09 18:29:38 +0000 Commit: Mitchell Horne CommitDate: 2021-02-24 14:57:04 +0000 arm64: validate breakpoint registers In particular, we want to disallow setting breakpoints on kernel addresses from userspace. The control register fields are validated or ignored as appropriate. Reviewed by: markj Sponsored by: The FreeBSD Foundation (cherry picked from commit de2b9422807586d376ec7ffa7b660cd492464bdf) --- sys/arm64/arm64/machdep.c | 37 +++++++++++++++++++++++++++++++++---- sys/arm64/include/armreg.h | 17 +++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 90fc19d57415..bf44dba19482 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -357,6 +357,8 @@ int set_dbregs(struct thread *td, struct dbreg *regs) { struct debug_monitor_state *monitor; + uint64_t addr; + uint32_t ctrl; int count; int i; @@ -364,11 +366,38 @@ set_dbregs(struct thread *td, struct dbreg *regs) count = 0; monitor->dbg_enable_count = 0; for (i = 0; i < DBG_BRP_MAX; i++) { - /* TODO: Check these values */ - monitor->dbg_bvr[i] = regs->db_regs[i].dbr_addr; - monitor->dbg_bcr[i] = regs->db_regs[i].dbr_ctrl; - if ((monitor->dbg_bcr[i] & 1) != 0) + addr = regs->db_regs[i].dbr_addr; + ctrl = regs->db_regs[i].dbr_ctrl; + + /* Don't let the user set a breakpoint on a kernel address. */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * The lowest 2 bits are ignored, so record the effective + * address. + */ + addr = rounddown2(addr, 4); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked, address-matching breakpoints are supported. + * + * XXX: fields that appear unvalidated, such as BAS, have + * constrained undefined behaviour. If the user mis-programs + * these, there is no risk to the system. + */ + ctrl &= DBG_BCR_EN | DBG_BCR_PMC | DBG_BCR_BAS; + if ((ctrl & DBG_BCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_BCR_PMC) != DBG_BCR_PMC_EL0) + return (EINVAL); + monitor->dbg_enable_count++; + } + + monitor->dbg_bvr[i] = addr; + monitor->dbg_bcr[i] = ctrl; } if (monitor->dbg_enable_count > 0) monitor->dbg_flags |= DBGMON_ENABLED; diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 201d7559320b..73d1010057b9 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -943,6 +943,23 @@ #define DBG_MDSCR_KDE (0x1 << 13) #define DBG_MDSCR_MDE (0x1 << 15) +/* Debug Breakpoint Control Registers */ +#define DBG_BCR_EN 0x1 +#define DBG_BCR_PMC_SHIFT 1 +#define DBG_BCR_PMC (0x3 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_PMC_EL1 (0x1 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_PMC_EL0 (0x2 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_BAS_SHIFT 5 +#define DBG_BCR_BAS (0xf << DBG_BCR_BAS_SHIFT) +#define DBG_BCR_HMC_SHIFT 13 +#define DBG_BCR_HMC (0x1 << DBG_BCR_HMC_SHIFT) +#define DBG_BCR_SSC_SHIFT 14 +#define DBG_BCR_SSC (0x3 << DBG_BCR_SSC_SHIFT) +#define DBG_BCR_LBN_SHIFT 16 +#define DBG_BCR_LBN (0xf << DBG_BCR_LBN_SHIFT) +#define DBG_BCR_BT_SHIFT 20 +#define DBG_BCR_BT (0xf << DBG_BCR_BT_SHIFT) + /* Perfomance Monitoring Counters */ #define PMCR_E (1 << 0) /* Enable all counters */ #define PMCR_P (1 << 1) /* Reset all counters */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 15:02: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 BAAEB55F17C; Wed, 24 Feb 2021 15:02: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 4Dlzg74ysZz3N9n; Wed, 24 Feb 2021 15:02: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 9D46B2E4A8; Wed, 24 Feb 2021 15:02: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 11OF2hsF013464; Wed, 24 Feb 2021 15:02:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OF2hYR013463; Wed, 24 Feb 2021 15:02:43 GMT (envelope-from git) Date: Wed, 24 Feb 2021 15:02:43 GMT Message-Id: <202102241502.11OF2hYR013463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 9372df63ad5b - stable/13 - arm64: handle watchpoint exceptions from EL0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9372df63ad5b814440732d171c8f04f0e1c26b87 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, 24 Feb 2021 15:02:43 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9372df63ad5b814440732d171c8f04f0e1c26b87 commit 9372df63ad5b814440732d171c8f04f0e1c26b87 Author: Mitchell Horne AuthorDate: 2021-02-05 21:46:48 +0000 Commit: Mitchell Horne CommitDate: 2021-02-24 14:58:09 +0000 arm64: handle watchpoint exceptions from EL0 This is a prerequisite to allowing the use of hardware watchpoints for userspace debuggers. This is also a slight departure from the x86 behaviour, since `si_addr` returns the data address that triggered the watchpoint, not the address of the instruction that was executed. Otherwise, there is no straightforward way for the application to determine which watchpoint was triggered. Make a note of this in the siginfo(3) man page. Reviewed by: jhb, markj (earlier version) Tested by: Michał Górny (mgorny@gentoo.org) Sponsored by: The FreeBSD Foundation (cherry picked from commit bd012c71592323d957b409bb5e0cf7940729650e) --- share/man/man3/siginfo.3 | 7 ++++++- sys/arm64/arm64/trap.c | 6 ++++++ sys/arm64/include/armreg.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/share/man/man3/siginfo.3 b/share/man/man3/siginfo.3 index fc4ea2ba1df7..acc8785b2f0d 100644 --- a/share/man/man3/siginfo.3 +++ b/share/man/man3/siginfo.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 28, 2020 +.Dd February 17, 2021 .Dt SIGINFO 3 .Os .Sh NAME @@ -218,6 +218,11 @@ and may report the address of the faulting memory access (if available) in .Va si_addr instead. +Additionally +.Dv SIGTRAP +raised by a hardware watchpoint exception may report the data address that +triggered the watchpoint in +.Va si_addr . .Pp Sychronous signals set .Va si_trapno diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 0b2d4760cea3..cb3a05ad0163 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -474,6 +474,7 @@ do_el0_sync(struct thread *td, struct trapframe *frame) case EXCP_UNKNOWN: case EXCP_DATA_ABORT_L: case EXCP_DATA_ABORT: + case EXCP_WATCHPT_EL0: far = READ_SPECIALREG(far_el1); break; } @@ -534,6 +535,11 @@ do_el0_sync(struct thread *td, struct trapframe *frame) exception); userret(td, frame); break; + case EXCP_WATCHPT_EL0: + call_trapsignal(td, SIGTRAP, TRAP_TRACE, (void *)far, + exception); + userret(td, frame); + break; case EXCP_MSR: /* * The CPU can raise EXCP_MSR when userspace executes an mrs diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 73d1010057b9..66cd8591c7ab 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -230,6 +230,7 @@ #define EXCP_BRKPT_EL0 0x30 /* Hardware breakpoint, from same EL */ #define EXCP_SOFTSTP_EL0 0x32 /* Software Step, from lower EL */ #define EXCP_SOFTSTP_EL1 0x33 /* Software Step, from same EL */ +#define EXCP_WATCHPT_EL0 0x34 /* Watchpoint, from lower EL */ #define EXCP_WATCHPT_EL1 0x35 /* Watchpoint, from same EL */ #define EXCP_BRK 0x3c /* Breakpoint */ From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 15:02:44 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E1F7C55F6B9; Wed, 24 Feb 2021 15:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dlzg85k3qz3N7p; Wed, 24 Feb 2021 15:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B613A2E255; Wed, 24 Feb 2021 15:02:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OF2i2Y013482; Wed, 24 Feb 2021 15:02:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OF2iwc013481; Wed, 24 Feb 2021 15:02:44 GMT (envelope-from git) Date: Wed, 24 Feb 2021 15:02:44 GMT Message-Id: <202102241502.11OF2iwc013481@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 4786c8582c56 - stable/13 - arm64: extend struct db_reg to include watchpoint registers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4786c8582c569a7245dadbdbb4638d1667c10d62 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, 24 Feb 2021 15:02:45 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4786c8582c569a7245dadbdbb4638d1667c10d62 commit 4786c8582c569a7245dadbdbb4638d1667c10d62 Author: Mitchell Horne AuthorDate: 2021-01-28 17:49:47 +0000 Commit: Mitchell Horne CommitDate: 2021-02-24 14:58:43 +0000 arm64: extend struct db_reg to include watchpoint registers The motivation is to provide access to these registers from userspace via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS. This change breaks the ABI of these particular requests, but is justified by the fact that the intended consumers (debuggers) have not been taught to use them yet. Making this change now enables active upstream work on lldb to begin using this interface, and take advantage of the hardware debugging registers available on the platform. PR: 252860 Reported by: Michał Górny (mgorny@gentoo.org) Reviewed by: andrew, markj (earlier version) Tested by: Michał Górny (mgorny@gentoo.org) Sponsored by: The FreeBSD Foundation (cherry picked from commit f2583be110ca3a5b32f0993f1464a5c69151c62f) --- sys/arm64/arm64/identcpu.c | 2 +- sys/arm64/arm64/machdep.c | 71 ++++++++++++++++++++++++++++++++++++++-------- sys/arm64/include/armreg.h | 22 ++++++++++++++ sys/arm64/include/reg.h | 13 +++++++-- 4 files changed, 92 insertions(+), 16 deletions(-) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index bfbaad7a6483..c3544e9de9aa 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -350,7 +350,7 @@ static struct mrs_field id_aa64dfr0_fields[] = { MRS_FIELD(ID_AA64DFR0, PMSVer, false, MRS_EXACT, id_aa64dfr0_pmsver), MRS_FIELD(ID_AA64DFR0, CTX_CMPs, false, MRS_EXACT, id_aa64dfr0_ctx_cmps), - MRS_FIELD(ID_AA64DFR0, WRPs, false, MRS_EXACT, id_aa64dfr0_wrps), + MRS_FIELD(ID_AA64DFR0, WRPs, false, MRS_LOWER, id_aa64dfr0_wrps), MRS_FIELD(ID_AA64DFR0, BRPs, false, MRS_LOWER, id_aa64dfr0_brps), MRS_FIELD(ID_AA64DFR0, PMUVer, false, MRS_EXACT, id_aa64dfr0_pmuver), MRS_FIELD(ID_AA64DFR0, TraceVer, false, MRS_EXACT, diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index bf44dba19482..73b06beeba7e 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -321,8 +321,8 @@ int fill_dbregs(struct thread *td, struct dbreg *regs) { struct debug_monitor_state *monitor; - int count, i; - uint8_t debug_ver, nbkpts; + int i; + uint8_t debug_ver, nbkpts, nwtpts; memset(regs, 0, sizeof(*regs)); @@ -330,23 +330,30 @@ fill_dbregs(struct thread *td, struct dbreg *regs) &debug_ver); extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_BRPs_SHIFT, &nbkpts); + extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_WRPs_SHIFT, + &nwtpts); /* * The BRPs field contains the number of breakpoints - 1. Armv8-A * allows the hardware to provide 2-16 breakpoints so this won't - * overflow an 8 bit value. + * overflow an 8 bit value. The same applies to the WRPs field. */ - count = nbkpts + 1; + nbkpts++; + nwtpts++; - regs->db_info = debug_ver; - regs->db_info <<= 8; - regs->db_info |= count; + regs->db_debug_ver = debug_ver; + regs->db_nbkpts = nbkpts; + regs->db_nwtpts = nwtpts; monitor = &td->td_pcb->pcb_dbg_regs; if ((monitor->dbg_flags & DBGMON_ENABLED) != 0) { - for (i = 0; i < count; i++) { - regs->db_regs[i].dbr_addr = monitor->dbg_bvr[i]; - regs->db_regs[i].dbr_ctrl = monitor->dbg_bcr[i]; + for (i = 0; i < nbkpts; i++) { + regs->db_breakregs[i].dbr_addr = monitor->dbg_bvr[i]; + regs->db_breakregs[i].dbr_ctrl = monitor->dbg_bcr[i]; + } + for (i = 0; i < nwtpts; i++) { + regs->db_watchregs[i].dbw_addr = monitor->dbg_wvr[i]; + regs->db_watchregs[i].dbw_ctrl = monitor->dbg_wcr[i]; } } @@ -365,9 +372,10 @@ set_dbregs(struct thread *td, struct dbreg *regs) monitor = &td->td_pcb->pcb_dbg_regs; count = 0; monitor->dbg_enable_count = 0; + for (i = 0; i < DBG_BRP_MAX; i++) { - addr = regs->db_regs[i].dbr_addr; - ctrl = regs->db_regs[i].dbr_ctrl; + addr = regs->db_breakregs[i].dbr_addr; + ctrl = regs->db_breakregs[i].dbr_ctrl; /* Don't let the user set a breakpoint on a kernel address. */ if (addr >= VM_MAXUSER_ADDRESS) @@ -399,6 +407,45 @@ set_dbregs(struct thread *td, struct dbreg *regs) monitor->dbg_bvr[i] = addr; monitor->dbg_bcr[i] = ctrl; } + + for (i = 0; i < DBG_WRP_MAX; i++) { + addr = regs->db_watchregs[i].dbw_addr; + ctrl = regs->db_watchregs[i].dbw_ctrl; + + /* Don't let the user set a watchpoint on a kernel address. */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked watchpoints are supported. + */ + ctrl &= DBG_WCR_EN | DBG_WCR_PAC | DBG_WCR_LSC | DBG_WCR_BAS | + DBG_WCR_MASK; + + if ((ctrl & DBG_WCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_WCR_PAC) != DBG_WCR_PAC_EL0) + return (EINVAL); + + /* Must set at least one of the load/store bits. */ + if ((ctrl & DBG_WCR_LSC) == 0) + return (EINVAL); + + /* + * When specifying the address range with BAS, the MASK + * field must be zero. + */ + if ((ctrl & DBG_WCR_BAS) != DBG_WCR_BAS_MASK && + (ctrl & DBG_WCR_MASK) != 0) + return (EINVAL); + + monitor->dbg_enable_count++; + } + monitor->dbg_wvr[i] = addr; + monitor->dbg_wcr[i] = ctrl; + } + if (monitor->dbg_enable_count > 0) monitor->dbg_flags |= DBGMON_ENABLED; diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 66cd8591c7ab..81cea5431017 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -961,6 +961,28 @@ #define DBG_BCR_BT_SHIFT 20 #define DBG_BCR_BT (0xf << DBG_BCR_BT_SHIFT) +/* Debug Watchpoint Control Registers */ +#define DBG_WCR_EN 0x1 +#define DBG_WCR_PAC_SHIFT 1 +#define DBG_WCR_PAC (0x3 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_PAC_EL1 (0x1 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_PAC_EL0 (0x2 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_LSC_SHIFT 3 +#define DBG_WCR_LSC (0x3 << DBG_WCR_LSC_SHIFT) +#define DBG_WCR_BAS_SHIFT 5 +#define DBG_WCR_BAS (0xff << DBG_WCR_BAS_SHIFT) +#define DBG_WCR_BAS_MASK DBG_WCR_BAS +#define DBG_WCR_HMC_SHIFT 13 +#define DBG_WCR_HMC (0x1 << DBG_WCR_HMC_SHIFT) +#define DBG_WCR_SSC_SHIFT 14 +#define DBG_WCR_SSC (0x3 << DBG_WCR_SSC_SHIFT) +#define DBG_WCR_LBN_SHIFT 16 +#define DBG_WCR_LBN (0xf << DBG_WCR_LBN_SHIFT) +#define DBG_WCR_WT_SHIFT 20 +#define DBG_WCR_WT (0x1 << DBG_WCR_WT_SHIFT) +#define DBG_WCR_MASK_SHIFT 24 +#define DBG_WCR_MASK (0x1f << DBG_WCR_MASK_SHIFT) + /* Perfomance Monitoring Counters */ #define PMCR_E (1 << 0) /* Enable all counters */ #define PMCR_P (1 << 1) /* Reset all counters */ diff --git a/sys/arm64/include/reg.h b/sys/arm64/include/reg.h index aafe02b70925..9cfc5ea1d437 100644 --- a/sys/arm64/include/reg.h +++ b/sys/arm64/include/reg.h @@ -60,14 +60,21 @@ struct fpreg32 { }; struct dbreg { - uint32_t db_info; - uint32_t db_pad; + uint8_t db_debug_ver; + uint8_t db_nbkpts; + uint8_t db_nwtpts; + uint8_t db_pad[5]; struct { uint64_t dbr_addr; uint32_t dbr_ctrl; uint32_t dbr_pad; - } db_regs[16]; + } db_breakregs[16]; + struct { + uint64_t dbw_addr; + uint32_t dbw_ctrl; + uint32_t dbw_pad; + } db_watchregs[16]; }; struct dbreg32 { From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 15:21: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 91A2855FFF8; Wed, 24 Feb 2021 15:21: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 4Dm04K3khKz3Py7; Wed, 24 Feb 2021 15:21: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 733EC2E6DC; Wed, 24 Feb 2021 15:21: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 11OFL5Nm035990; Wed, 24 Feb 2021 15:21:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OFL5JM035989; Wed, 24 Feb 2021 15:21:05 GMT (envelope-from git) Date: Wed, 24 Feb 2021 15:21:05 GMT Message-Id: <202102241521.11OFL5JM035989@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: 4664afc05402 - stable/13 - iflib: Fix detach of pseudo interfaces 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: 4664afc05402abb8e572975ec65210bdcd8b2ea1 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, 24 Feb 2021 15:21:05 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4664afc05402abb8e572975ec65210bdcd8b2ea1 commit 4664afc05402abb8e572975ec65210bdcd8b2ea1 Author: Mark Johnston AuthorDate: 2021-02-19 22:08:34 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 15:20:55 +0000 iflib: Fix detach of pseudo interfaces In commit 38bfc6dee33b we added an IFDI_DETACH() call to iflib_pseudo_deregister() since it looked like it was missing. One is present in the error-handling path of iflib_pseudo_register(). However, the detach actually comes from the DEVICE_DETACH() method for the above-mentioned device_t, so now we're calling IFDI_DETACH() twice when destroying a pseudo interface. Fix the problem by not calling IFDI_DETACH() from the device detach routine. This way we can ensure that iflib de-initialization always happens in a consistent order. It also ensures that you can't do silly things like "devctl detach ", which would previously detach the driver without tearing down the corresponding ifnet. PR: 253541 Reviewed by: erj Fixes: 38bfc6dee33b Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28774 (cherry picked from commit 0f9544d03e89d180f94a7a84b110ec7d2b6c625a) --- sys/net/iflib_clone.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/net/iflib_clone.c b/sys/net/iflib_clone.c index dc4ccbee659f..975873c4a19c 100644 --- a/sys/net/iflib_clone.c +++ b/sys/net/iflib_clone.c @@ -81,13 +81,11 @@ int iflib_pseudo_detach(device_t dev) { if_ctx_t ctx; - uint32_t ifc_flags; ctx = device_get_softc(dev); - ifc_flags = iflib_get_flags(ctx); - if ((ifc_flags & IFC_INIT_DONE) == 0) - return (0); - return (IFDI_DETACH(ctx)); + if ((iflib_get_flags(ctx) & IFC_IN_DETACH) == 0) + return (EBUSY); + return (0); } static device_t iflib_pseudodev; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 98919564AA0; Wed, 24 Feb 2021 18:10: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 4Dm3qG3yxgz3tN9; Wed, 24 Feb 2021 18:10: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 777C3D8A; Wed, 24 Feb 2021 18:10: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 11OIA24A052888; Wed, 24 Feb 2021 18:10:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA2jj052884; Wed, 24 Feb 2021 18:10:02 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:02 GMT Message-Id: <202102241810.11OIA2jj052884@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: dd9b24be14d4 - stable/13 - boot: remove gptboot.efifat, it never should have been MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dd9b24be14d4311ca6056f41a2d81801d2c0fa03 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, 24 Feb 2021 18:10:02 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=dd9b24be14d4311ca6056f41a2d81801d2c0fa03 commit dd9b24be14d4311ca6056f41a2d81801d2c0fa03 Author: Warner Losh AuthorDate: 2021-02-19 22:34:25 +0000 Commit: Warner Losh CommitDate: 2021-02-24 17:56:06 +0000 boot: remove gptboot.efifat, it never should have been conical hat reduction: Make sure we also remove gotboot.efifat. It was created, briefly, and shouldn't have existed in the first place. Kill it at the same place we kill boot1.efifat. Pointy Hat to: imp@ (cherry picked from commit 8cd1b2b1a7ab55e96aaf40a401d8792f2697b274) --- ObsoleteFiles.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 7ebff0441581..5f4495c50ee6 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -2601,8 +2601,9 @@ OLD_FILES+=usr/bin/mklocale OLD_FILES+=usr/share/man/man1/mklocale.1.gz OLD_FILES+=usr/bin/colldef OLD_FILES+=usr/share/man/man1/colldef.1.gz -# 20190904: Remove boot1.efifat +# 20190904: Remove boot1.efifat and gptboot.efifat (which never should have been) OLD_FILES+=boot/boot1.efifat +OLD_FILES+=boot/gptboot.efifat # 20190903: pc-sysinstall(8) removed OLD_FILES+=usr/share/examples/pc-sysinstall/README OLD_FILES+=usr/share/examples/pc-sysinstall/pc-autoinstall.conf From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 968D5564AA2; Wed, 24 Feb 2021 18:10: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 4Dm3qH3tWZz3tNB; Wed, 24 Feb 2021 18:10: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 78D10ACF; Wed, 24 Feb 2021 18:10: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 11OIA3ZR053099; Wed, 24 Feb 2021 18:10:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA3Pd053096; Wed, 24 Feb 2021 18:10:03 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:03 GMT Message-Id: <202102241810.11OIA3Pd053096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: ef1f20560842 - stable/13 - uart: only use MSI on devices that advertise 1 MSI vector MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ef1f2056084202c554d5482af9586a8995e604d5 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, 24 Feb 2021 18:10:03 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ef1f2056084202c554d5482af9586a8995e604d5 commit ef1f2056084202c554d5482af9586a8995e604d5 Author: Warner Losh AuthorDate: 2021-02-17 22:08:19 +0000 Commit: Warner Losh CommitDate: 2021-02-24 17:57:07 +0000 uart: only use MSI on devices that advertise 1 MSI vector This updates r311987/fb1d9b7f4113d which allowed any number of vectors to be used. Since we're just attaching one instance, the meaning of more than one vector is not clear and seems to cause problems. Fall back to old methods for these cards. PR: 235016 Submitted by: David Cross (cherry picked from commit 955b6109bb36036e9357006be42dfa89cd7cb0f2) --- sys/dev/uart/uart_bus_pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index 0ed3d7f4f974..fbd1d68b88ca 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -227,10 +227,10 @@ uart_pci_attach(device_t dev) sc = device_get_softc(dev); /* - * Use MSI in preference to legacy IRQ if available. - * Whilst some PCIe UARTs support >1 MSI vector, use only the first. + * Use MSI in preference to legacy IRQ if available. However, experience + * suggests this is only reliable when one MSI vector is advertised. */ - if (pci_msi_count(dev) > 0) { + if (pci_msi_count(dev) == 1) { count = 1; if (pci_alloc_msi(dev, &count) == 0) { sc->sc_irid = 1; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 B3D165647F3; Wed, 24 Feb 2021 18:10: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 4Dm3qJ4mDbz3tQy; Wed, 24 Feb 2021 18:10: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 966739DE; Wed, 24 Feb 2021 18:10: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 11OIA4TP053308; Wed, 24 Feb 2021 18:10:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA4Q4053305; Wed, 24 Feb 2021 18:10:04 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:04 GMT Message-Id: <202102241810.11OIA4Q4053305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 78050d4966c5 - stable/13 - Remove incorrect statement about EFI environment variables being unsupported. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 78050d4966c5a9c8e953cab2a286450238d51e4f 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, 24 Feb 2021 18:10:04 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=78050d4966c5a9c8e953cab2a286450238d51e4f commit 78050d4966c5a9c8e953cab2a286450238d51e4f Author: Warner Losh AuthorDate: 2021-02-22 20:19:21 +0000 Commit: Warner Losh CommitDate: 2021-02-24 17:59:37 +0000 Remove incorrect statement about EFI environment variables being unsupported. Our uefi support has included environment variable support for several years now. Remove the bogus blanket statement saying we don't support them. MFC After: 3 days (cherry picked from commit ab77cc9e7bf6d0c2d862dfd514539b81ae248dfd) --- share/man/man8/uefi.8 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/share/man/man8/uefi.8 b/share/man/man8/uefi.8 index 4224af835738..05c74caa6c20 100644 --- a/share/man/man8/uefi.8 +++ b/share/man/man8/uefi.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 9, 2020 +.Dd February 22, 2021 .Dt UEFI 8 .Os .Sh NAME @@ -143,7 +143,3 @@ boot support for amd64 first appeared in .Fx 10.1 and for arm64 in .Fx 11.0 . -.Sh CAVEATS -EFI environment variables are not supported by -.Xr loader 8 -or the kernel. From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 7887C5647F4; Wed, 24 Feb 2021 18:10: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 4Dm3qL2dvGz3tYj; Wed, 24 Feb 2021 18:10: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 B0C8DA3D; Wed, 24 Feb 2021 18:10: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 11OIA5wP053519; Wed, 24 Feb 2021 18:10:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA549053516; Wed, 24 Feb 2021 18:10:05 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:05 GMT Message-Id: <202102241810.11OIA549053516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: f88db54fd874 - stable/13 - uefi: add historical details MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f88db54fd87471802b44520715d8e373ddf86f60 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, 24 Feb 2021 18:10:10 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f88db54fd87471802b44520715d8e373ddf86f60 commit f88db54fd87471802b44520715d8e373ddf86f60 Author: Warner Losh AuthorDate: 2021-02-22 21:20:00 +0000 Commit: Warner Losh CommitDate: 2021-02-24 17:59:44 +0000 uefi: add historical details Add details about when armv6 and armv7 support was added. (cherry picked from commit 8c09ecb2e25155b4f1490a177826608d52b1bd1b) --- share/man/man8/uefi.8 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/share/man/man8/uefi.8 b/share/man/man8/uefi.8 index 05c74caa6c20..dfc144718f7b 100644 --- a/share/man/man8/uefi.8 +++ b/share/man/man8/uefi.8 @@ -140,6 +140,8 @@ EFI boot support for the ia64 architecture first appeared in .Fx 5.0 . .Nm boot support for amd64 first appeared in -.Fx 10.1 -and for arm64 in -.Fx 11.0 . +.Fx 10.1 ; +for arm64 +.Fx 11.0 ; +and for armv6 and armv7 in +.Fx 12.0 . From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC525564B89; Wed, 24 Feb 2021 18:10:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dm3qQ028Sz3tZ2; Wed, 24 Feb 2021 18:10:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F39A0BEC; Wed, 24 Feb 2021 18:10: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 11OIA7bu053941; Wed, 24 Feb 2021 18:10:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA7XS053938; Wed, 24 Feb 2021 18:10:07 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:07 GMT Message-Id: <202102241810.11OIA7XS053938@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 44f483e0fa52 - stable/13 - uefi: Add riscv to historical details MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 44f483e0fa52c42c8f97cf1600c1f7272a283707 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, 24 Feb 2021 18:10:11 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=44f483e0fa52c42c8f97cf1600c1f7272a283707 commit 44f483e0fa52c42c8f97cf1600c1f7272a283707 Author: Jessica Clarke AuthorDate: 2021-02-22 22:27:00 +0000 Commit: Warner Losh CommitDate: 2021-02-24 18:00:13 +0000 uefi: Add riscv to historical details (cherry picked from commit 963cf6cb0fd7e8708c455ecf567fbc34fe2a7156) --- share/man/man8/uefi.8 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/man/man8/uefi.8 b/share/man/man8/uefi.8 index 3ecfe05ac1c4..64bc30139f97 100644 --- a/share/man/man8/uefi.8 +++ b/share/man/man8/uefi.8 @@ -143,5 +143,7 @@ boot support for amd64 first appeared in .Fx 10.1 ; for arm64 in .Fx 11.0 ; -and for armv6 and armv7 in -.Fx 12.0 . +for armv6 and armv7 in +.Fx 12.0 ; +and for riscv in +.Fx 13.0 . From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 0299056497D; Wed, 24 Feb 2021 18:10: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 4Dm3qR1tmmz3tdw; Wed, 24 Feb 2021 18:10:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DACC1849; Wed, 24 Feb 2021 18:10: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 11OIA8Kc054153; Wed, 24 Feb 2021 18:10:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA8fp054150; Wed, 24 Feb 2021 18:10:08 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:08 GMT Message-Id: <202102241810.11OIA8fp054150@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: b8b867a10f56 - stable/13 - efibootmgr: Check for efi supported after parsing args MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b8b867a10f56b4a78b680fb5d2a97c83e745a0ce 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, 24 Feb 2021 18:10:15 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b8b867a10f56b4a78b680fb5d2a97c83e745a0ce commit b8b867a10f56b4a78b680fb5d2a97c83e745a0ce Author: Warner Losh AuthorDate: 2021-02-11 23:06:30 +0000 Commit: Warner Losh CommitDate: 2021-02-24 18:01:41 +0000 efibootmgr: Check for efi supported after parsing args Move the check for efi variables being supported to after parsing the args. This allows '-h' to produce both as a normal user as well as on all systems. (cherry picked from commit 7fe2f504f8a0e4237872f8528e911c5f7b7ed59d) --- usr.sbin/efibootmgr/efibootmgr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c index 8c7ba82cb5a5..53bc417c4e07 100644 --- a/usr.sbin/efibootmgr/efibootmgr.c +++ b/usr.sbin/efibootmgr/efibootmgr.c @@ -1072,11 +1072,12 @@ int main(int argc, char *argv[]) { + memset(&opts, 0, sizeof (bmgr_opts_t)); + parse_args(argc, argv); + if (!efi_variables_supported()) errx(1, "efi variables not supported on this system. root? kldload efirt?"); - memset(&opts, 0, sizeof (bmgr_opts_t)); - parse_args(argc, argv); read_vars(); if (opts.create) From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:10: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 BACC6564B10; Wed, 24 Feb 2021 18:10: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 4Dm3qM1ZX4z3tgs; Wed, 24 Feb 2021 18:10: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 EFBC0C26; Wed, 24 Feb 2021 18:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OIA6Nr053732; Wed, 24 Feb 2021 18:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIA6TO053730; Wed, 24 Feb 2021 18:10:06 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:10:06 GMT Message-Id: <202102241810.11OIA6TO053730@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 1df1b4190b41 - stable/13 - Restore missing word MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1df1b4190b41ee3237486e9daa0a751cbc56312d 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, 24 Feb 2021 18:10:15 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=1df1b4190b41ee3237486e9daa0a751cbc56312d commit 1df1b4190b41ee3237486e9daa0a751cbc56312d Author: Warner Losh AuthorDate: 2021-02-22 21:39:04 +0000 Commit: Warner Losh CommitDate: 2021-02-24 18:00:03 +0000 Restore missing word "in" got dropped when I shuffled things around. Noticed by: rpokala@ MFC After: 3 days (cherry picked from commit f11e9f325aee3459fee94f3a660a8e6c1a25c2ac) --- share/man/man8/uefi.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man8/uefi.8 b/share/man/man8/uefi.8 index dfc144718f7b..3ecfe05ac1c4 100644 --- a/share/man/man8/uefi.8 +++ b/share/man/man8/uefi.8 @@ -141,7 +141,7 @@ EFI boot support for the ia64 architecture first appeared in .Nm boot support for amd64 first appeared in .Fx 10.1 ; -for arm64 +for arm64 in .Fx 11.0 ; and for armv6 and armv7 in .Fx 12.0 . From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:13: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 0C0575652D0; Wed, 24 Feb 2021 18:13: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 4Dm3tg6qsxz3vtw; Wed, 24 Feb 2021 18:12: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 DA80CAFB; Wed, 24 Feb 2021 18:12:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OICxUI063706; Wed, 24 Feb 2021 18:12:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OICxi7063705; Wed, 24 Feb 2021 18:12:59 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:12:59 GMT Message-Id: <202102241812.11OICxi7063705@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 4f4f44f70fb8 - stable/13 - nvme: use NVME_GONE rather than hard-coded 0xffffffff MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4f4f44f70fb87d2456e0a9955b66ae7f3cbc1997 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, 24 Feb 2021 18:13:00 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4f4f44f70fb87d2456e0a9955b66ae7f3cbc1997 commit 4f4f44f70fb87d2456e0a9955b66ae7f3cbc1997 Author: Warner Losh AuthorDate: 2021-02-08 20:08:48 +0000 Commit: Warner Losh CommitDate: 2021-02-24 18:10:45 +0000 nvme: use NVME_GONE rather than hard-coded 0xffffffff Make it clearer that the value 0xfffffff is being used to detect the device is gone. We use it other places in the driver for other meanings. (cherry picked from commit 9600aa31aa633bbb9e8a56d91a781d5a7ce2bff6) --- sys/dev/nvme/nvme_ctrlr.c | 6 +++--- sys/dev/nvme/nvme_private.h | 2 ++ sys/dev/nvme/nvme_qpair.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 2bd7074ee378..c0e6c408ab56 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -261,7 +261,7 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr, int desired_val) ms_waited = 0; while (1) { csts = nvme_mmio_read_4(ctrlr, csts); - if (csts == 0xffffffff) /* Hot unplug. */ + if (csts == NVME_GONE) /* Hot unplug. */ return (ENXIO); if (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK) == desired_val) @@ -1471,7 +1471,7 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) * Check whether it is a hot unplug or a clean driver detach. * If device is not there any more, skip any shutdown commands. */ - gone = (nvme_mmio_read_4(ctrlr, csts) == 0xffffffff); + gone = (nvme_mmio_read_4(ctrlr, csts) == NVME_GONE); if (gone) nvme_ctrlr_fail(ctrlr); else @@ -1549,7 +1549,7 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr) ((uint64_t)ctrlr->cdata.rtd3e * hz + 999999) / 1000000; while (1) { csts = nvme_mmio_read_4(ctrlr, csts); - if (csts == 0xffffffff) /* Hot unplug. */ + if (csts == NVME_GONE) /* Hot unplug. */ break; if (NVME_CSTS_GET_SHST(csts) == NVME_SHST_COMPLETE) break; diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index d44f1989dd71..6c1d293f047d 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -104,6 +104,8 @@ MALLOC_DECLARE(M_NVME); #define CACHE_LINE_SIZE (64) #endif +#define NVME_GONE 0xfffffffful + extern int32_t nvme_retry_count; extern bool nvme_verbose_cmd_dump; diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 45b1568a4c5a..0726ca248442 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -945,7 +945,7 @@ nvme_timeout(void *arg) nvme_abort_complete, tr); } else { nvme_printf(ctrlr, "Resetting controller due to a timeout%s.\n", - (csts == 0xffffffff) ? " and possible hot unplug" : + (csts == NVME_GONE) ? " and possible hot unplug" : (cfs ? " and fatal error status" : "")); nvme_ctrlr_reset(ctrlr); } From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:13: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 4B80256534B; Wed, 24 Feb 2021 18:13: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 4Dm3tj1LvXz3w0t; Wed, 24 Feb 2021 18:13: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 0FA5CDA4; Wed, 24 Feb 2021 18:13: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 11OID0tO063729; Wed, 24 Feb 2021 18:13:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OID05q063728; Wed, 24 Feb 2021 18:13:00 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:13:00 GMT Message-Id: <202102241813.11OID05q063728@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 0b90164992a8 - stable/13 - nvme: Make nvme_ctrlr_hw_reset static MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0b90164992a871052da5f1b72105c6d42ded2172 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, 24 Feb 2021 18:13:01 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=0b90164992a871052da5f1b72105c6d42ded2172 commit 0b90164992a871052da5f1b72105c6d42ded2172 Author: Warner Losh AuthorDate: 2021-02-08 20:28:18 +0000 Commit: Warner Losh CommitDate: 2021-02-24 18:10:51 +0000 nvme: Make nvme_ctrlr_hw_reset static nvme_ctrlr_hw_reset is no longer used outside of nvme_ctrlr.c, so make it static. If we need to change this in the future we can. (cherry picked from commit dd2516fc078f15633ad5aedaad6de140cb491f80) --- sys/dev/nvme/nvme_ctrlr.c | 2 +- sys/dev/nvme/nvme_private.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index c0e6c408ab56..351c6839a6f6 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -403,7 +403,7 @@ nvme_ctrlr_disable_qpairs(struct nvme_controller *ctrlr) } } -int +static int nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr) { int err; diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index 6c1d293f047d..ee0a909e24ec 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -398,7 +398,6 @@ void nvme_completion_poll_cb(void *arg, const struct nvme_completion *cpl); int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev); void nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev); void nvme_ctrlr_shutdown(struct nvme_controller *ctrlr); -int nvme_ctrlr_hw_reset(struct nvme_controller *ctrlr); void nvme_ctrlr_reset(struct nvme_controller *ctrlr); /* ctrlr defined as void * to allow use with config_intrhook. */ void nvme_ctrlr_start_config_hook(void *ctrlr_arg); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:38: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 31E70565CA6; Wed, 24 Feb 2021 18:38: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 4Dm4Sf0VwNz4SN6; Wed, 24 Feb 2021 18:38: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 042E8DDA; Wed, 24 Feb 2021 18:38: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 11OIcvA9091136; Wed, 24 Feb 2021 18:38:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIcvIJ091135; Wed, 24 Feb 2021 18:38:57 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:38:57 GMT Message-Id: <202102241838.11OIcvIJ091135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: b3e822993503 - releng/13.0 - loader_lua: consider userboot console as serial MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b3e822993503a9f18575c71020cb98056e022164 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, 24 Feb 2021 18:38:58 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=b3e822993503a9f18575c71020cb98056e022164 commit b3e822993503a9f18575c71020cb98056e022164 Author: Toomas Soome AuthorDate: 2021-02-14 08:28:29 +0000 Commit: Toomas Soome CommitDate: 2021-02-23 07:39:18 +0000 loader_lua: consider userboot console as serial We use ascii box chars with serial console because we do not know if terminal can draw unixode box chars. Same problem is about userboot console. (cherry picked from commit 5d8c062fe3ee7b2d6aed0b46d22f62c7771c0af8) Approved by: re (gjb) --- stand/lua/core.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stand/lua/core.lua b/stand/lua/core.lua index a119c3c258f8..55c26e0d6d39 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -403,7 +403,10 @@ end function core.isSerialConsole() local c = loader.getenv("console") if c ~= nil then - if c:find("comconsole") ~= nil then + -- serial console is comconsole, but also userboot. + -- userboot is there, because we have no way to know + -- if the user terminal can draw unicode box chars or not. + if c:find("comconsole") ~= nil or c:find("userboot") ~= nil then return true end end From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:38: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 50537565D9C; Wed, 24 Feb 2021 18:38: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 4Dm4Sg1n7kz4S1g; Wed, 24 Feb 2021 18:38: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 2FE1BDDB; Wed, 24 Feb 2021 18:38:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OIcxKu091157; Wed, 24 Feb 2021 18:38:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OIcxHX091156; Wed, 24 Feb 2021 18:38:59 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:38:59 GMT Message-Id: <202102241838.11OIcxHX091156@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: ce132d4aab67 - releng/13.0 - loader: start kernel in text mode when there is no vbefb vt driver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ce132d4aab6762d7287eca1e0f0ade5cf4d7576e 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, 24 Feb 2021 18:38:59 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=ce132d4aab6762d7287eca1e0f0ade5cf4d7576e commit ce132d4aab6762d7287eca1e0f0ade5cf4d7576e Author: Toomas Soome AuthorDate: 2021-01-26 22:47:56 +0000 Commit: Toomas Soome CommitDate: 2021-02-23 07:41:09 +0000 loader: start kernel in text mode when there is no vbefb vt driver If kernel is built without VT vbefb driver, make sure we start kernel in text mode. (cherry picked from commit 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd) Approved by: re (gjb) --- stand/common/gfx_fb.h | 1 + stand/common/load_elf.c | 63 ++++++++++++++++++++++++++++++++++++------- stand/i386/libi386/bootinfo.c | 10 +++++++ stand/loader.mk | 9 +++++++ 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index c62c6441f8ad..04076a2c6d38 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -216,6 +216,7 @@ typedef struct teken_gfx { struct gen_fb tg_fb; teken_funcs_t *tg_functions; void *tg_private; + bool tg_kernel_supported; /* Loaded kernel is supported */ } teken_gfx_t; extern font_list_t fonts; diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index cb542718fe2f..62fdb560ecff 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #define FREEBSD_ELF #include +#include #include "bootstrap.h" @@ -84,12 +85,14 @@ typedef struct elf_file { static int __elfN(loadimage)(struct preloaded_file *mp, elf_file_t ef, uint64_t loadaddr); -static int __elfN(lookup_symbol)(struct preloaded_file *mp, elf_file_t ef, - const char* name, Elf_Sym* sym); +static int __elfN(lookup_symbol)(elf_file_t ef, const char* name, + Elf_Sym *sym, unsigned char type); static int __elfN(reloc_ptr)(struct preloaded_file *mp, elf_file_t ef, Elf_Addr p, void *val, size_t len); static int __elfN(parse_modmetadata)(struct preloaded_file *mp, elf_file_t ef, Elf_Addr p_start, Elf_Addr p_end); +static bool __elfN(parse_vt_drv_set)(struct preloaded_file *mp, elf_file_t ef, + Elf_Addr p_start, Elf_Addr p_end); static symaddr_fn __elfN(symaddr); static char *fake_modname(const char *name); @@ -872,12 +875,24 @@ nosyms: ef->buckets = ef->hashtab + 2; ef->chains = ef->buckets + ef->nbuckets; - if (__elfN(lookup_symbol)(fp, ef, "__start_set_modmetadata_set", - &sym) != 0) + gfx_state.tg_kernel_supported = false; + if (__elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, + STT_NOTYPE) == 0) { + p_start = sym.st_value + ef->off; + if (__elfN(lookup_symbol)(ef, "__stop_set_vt_drv_set", &sym, + STT_NOTYPE) == 0) { + p_end = sym.st_value + ef->off; + gfx_state.tg_kernel_supported = + __elfN(parse_vt_drv_set)(fp, ef, p_start, p_end); + } + } + + if (__elfN(lookup_symbol)(ef, "__start_set_modmetadata_set", &sym, + STT_NOTYPE) != 0) return 0; p_start = sym.st_value + ef->off; - if (__elfN(lookup_symbol)(fp, ef, "__stop_set_modmetadata_set", - &sym) != 0) + if (__elfN(lookup_symbol)(ef, "__stop_set_modmetadata_set", &sym, + STT_NOTYPE) != 0) return ENOENT; p_end = sym.st_value + ef->off; @@ -1072,6 +1087,36 @@ out: return (err); } +/* + * Walk through vt_drv_set, each vt driver structure starts with + * static 16 chars for driver name. If we have "vbefb", return true. + */ +static bool +__elfN(parse_vt_drv_set)(struct preloaded_file *fp, elf_file_t ef, + Elf_Addr p_start, Elf_Addr p_end) +{ + Elf_Addr v, p; + char vd_name[16]; + int error; + + p = p_start; + while (p < p_end) { + COPYOUT(p, &v, sizeof(v)); + + error = __elfN(reloc_ptr)(fp, ef, p, &v, sizeof(v)); + if (error == EOPNOTSUPP) + v += ef->off; + else if (error != 0) + return (false); + COPYOUT(v, &vd_name, sizeof(vd_name)); + if (strncmp(vd_name, "vbefb", sizeof(vd_name)) == 0) + return (true); + p += sizeof(Elf_Addr); + } + + return (false); +} + int __elfN(parse_modmetadata)(struct preloaded_file *fp, elf_file_t ef, Elf_Addr p_start, Elf_Addr p_end) @@ -1185,8 +1230,8 @@ elf_hash(const char *name) static const char __elfN(bad_symtable)[] = "elf" __XSTRING(__ELF_WORD_SIZE) "_lookup_symbol: corrupt symbol table\n"; int -__elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, - const char* name, Elf_Sym *symp) +__elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, + unsigned char type) { Elf_Hashelt symnum; Elf_Sym sym; @@ -1213,7 +1258,7 @@ __elfN(lookup_symbol)(struct preloaded_file *fp, elf_file_t ef, free(strp); if (sym.st_shndx != SHN_UNDEF || (sym.st_value != 0 && - ELF_ST_TYPE(sym.st_info) == STT_FUNC)) { + ELF_ST_TYPE(sym.st_info) == type)) { *symp = sym; return 0; } diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c index 71e07cfb9702..57f926b76589 100644 --- a/stand/i386/libi386/bootinfo.c +++ b/stand/i386/libi386/bootinfo.c @@ -41,6 +41,16 @@ __FBSDID("$FreeBSD$"); void bi_load_vbe_data(struct preloaded_file *kfp) { + if (!gfx_state.tg_kernel_supported) { + /* + * Loaded kernel does not have vt/vbe backend, + * switch console to text mode. + */ + if (vbe_available()) + bios_set_text_mode(VGA_TEXT_MODE); + return; + } + if (vbe_available()) { file_addmetadata(kfp, MODINFOMD_VBE_FB, sizeof(gfx_state.tg_fb), &gfx_state.tg_fb); diff --git a/stand/loader.mk b/stand/loader.mk index cde7a31dca7e..3a38a9bc9e63 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -17,23 +17,32 @@ CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib .if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "aarch64" SRCS+= load_elf64.c reloc_elf64.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "powerpc" SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_ARCH:Mmips64*} != "" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE} == "mips" SRCS+= load_elf32.c reloc_elf32.c SRCS+= metadata.c +CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .elif ${MACHINE_CPUARCH} == "riscv" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c +CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .endif .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:39: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 91718565F2B; Wed, 24 Feb 2021 18:39: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 4Dm4Sh2l7Xz4S90; Wed, 24 Feb 2021 18:39: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 5067813A7; Wed, 24 Feb 2021 18:39: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 11OId0sr091179; Wed, 24 Feb 2021 18:39:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OId0Ze091178; Wed, 24 Feb 2021 18:39:00 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:39:00 GMT Message-Id: <202102241839.11OId0Ze091178@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 6daafec20838 - releng/13.0 - Fix loader detection of vbefb support on !amd64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 6daafec2083848e2da210bd2183e6fb598944bd2 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, 24 Feb 2021 18:39:00 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=6daafec2083848e2da210bd2183e6fb598944bd2 commit 6daafec2083848e2da210bd2183e6fb598944bd2 Author: Dimitry Andric AuthorDate: 2021-01-27 21:28:43 +0000 Commit: Toomas Soome CommitDate: 2021-02-23 07:41:55 +0000 Fix loader detection of vbefb support on !amd64 On i386, after 6c7a932d0b8baaaee16eca0ba061bfa6e0e57bfd, the vbefb vt driver was no longer detected by the loader, if any kernel module was loaded after the kernel itself. This was caused by the parse_vt_drv_set() function being called multiple times, resetting the detection flag. (It was called multiple times, becuase i386 .ko files are shared objects like the kernel proper, while this is not the case on amd64.) Fix this by skipping the set_vt_drv_set lookup if vbefb was already detected. (cherry picked from commit 6e26189be406a9a3799074b16925e6cd63cc703b) Reviewed by: tsoome Approved by: re (gjb) --- stand/common/load_elf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 62fdb560ecff..8bb780ef34df 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -875,8 +875,8 @@ nosyms: ef->buckets = ef->hashtab + 2; ef->chains = ef->buckets + ef->nbuckets; - gfx_state.tg_kernel_supported = false; - if (__elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, + if (!gfx_state.tg_kernel_supported && + __elfN(lookup_symbol)(ef, "__start_set_vt_drv_set", &sym, STT_NOTYPE) == 0) { p_start = sym.st_value + ef->off; if (__elfN(lookup_symbol)(ef, "__stop_set_vt_drv_set", &sym, From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 18:39: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 85723565CC3; Wed, 24 Feb 2021 18:39: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 4Dm4Sk09Csz4SCZ; Wed, 24 Feb 2021 18:39: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 715BE148E; Wed, 24 Feb 2021 18:39: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 11OId1c9091197; Wed, 24 Feb 2021 18:39:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OId1w6091196; Wed, 24 Feb 2021 18:39:01 GMT (envelope-from git) Date: Wed, 24 Feb 2021 18:39:01 GMT Message-Id: <202102241839.11OId1w6091196@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 8305d6906fe9 - releng/13.0 - loader: unload command should reset tg_kernel_supported in gfx_state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 8305d6906fe983ae470184127b5e42cc6f91493a 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, 24 Feb 2021 18:39:06 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=8305d6906fe983ae470184127b5e42cc6f91493a commit 8305d6906fe983ae470184127b5e42cc6f91493a Author: Toomas Soome AuthorDate: 2021-01-28 07:45:47 +0000 Commit: Toomas Soome CommitDate: 2021-02-23 07:42:26 +0000 loader: unload command should reset tg_kernel_supported in gfx_state While loading kernel, we check if vt/vbe backend support is included in kernel and set the tg_kernel_supported flag in gfx_state. unload command needs to reset this flag to allow next load to perform this check with new kernel. (cherry picked from commit 9b388ac30375ad4e0259b264a006753edcb2bd3c) Reported by: jhb Approved by: re (gjb) --- stand/common/module.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stand/common/module.c b/stand/common/module.c index 247fc54b6021..34ffc10cded3 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -271,6 +271,8 @@ unload(void) } loadaddr = 0; unsetenv("kernelname"); + /* Reset tg_kernel_supported to allow next load to check it again. */ + gfx_state.tg_kernel_supported = false; } COMMAND_SET(unload, "unload", "unload all modules", command_unload); From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 19:41: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 15FDD567541; Wed, 24 Feb 2021 19:41: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 4Dm5rd09TJz4XXq; Wed, 24 Feb 2021 19:41: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 ECD732194; Wed, 24 Feb 2021 19:41: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 11OJfKRg079331; Wed, 24 Feb 2021 19:41:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OJfKQa079330; Wed, 24 Feb 2021 19:41:20 GMT (envelope-from git) Date: Wed, 24 Feb 2021 19:41:20 GMT Message-Id: <202102241941.11OJfKQa079330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 1c1460747efd - stable/13 - Fix possibly unitialized variables in __cxa_demangle_gnu3() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1c1460747efd44eb74762b960883656b56134e30 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, 24 Feb 2021 19:41:21 -0000 The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=1c1460747efd44eb74762b960883656b56134e30 commit 1c1460747efd44eb74762b960883656b56134e30 Author: Dimitry Andric AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric CommitDate: 2021-02-24 19:39:15 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) --- contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c index 6e88f7b4bb4c..93e1c41fa034 100644 --- a/contrib/libcxxrt/libelftc_dem_gnu3.c +++ b/contrib/libcxxrt/libelftc_dem_gnu3.c @@ -538,8 +538,8 @@ __cxa_demangle_gnu3(const char *org) struct type_delimit td; ssize_t org_len; unsigned int limit; - char *rtn; - bool has_ret, more_type; + char *rtn = NULL; + bool has_ret = false, more_type = false; if (org == NULL) return (NULL); @@ -562,13 +562,9 @@ __cxa_demangle_gnu3(const char *org) return (rtn); } - if (!cpp_demangle_data_init(&ddata, org + 2)) return (NULL); - rtn = NULL; - has_ret = more_type = false; - if (!cpp_demangle_read_encoding(&ddata)) goto clean; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 19:41:41 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 55244567803; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dm5s120nfz4XWv; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37D1A1F57; Wed, 24 Feb 2021 19:41:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OJffbP082695; Wed, 24 Feb 2021 19:41:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OJffnr082694; Wed, 24 Feb 2021 19:41:41 GMT (envelope-from git) Date: Wed, 24 Feb 2021 19:41:41 GMT Message-Id: <202102241941.11OJffnr082694@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 64809c763b0c - stable/12 - Fix possibly unitialized variables in __cxa_demangle_gnu3() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 64809c763b0c73fe488b61601670067056b07780 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, 24 Feb 2021 19:41:41 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=64809c763b0c73fe488b61601670067056b07780 commit 64809c763b0c73fe488b61601670067056b07780 Author: Dimitry Andric AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric CommitDate: 2021-02-24 19:39:57 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) --- contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c index 6e88f7b4bb4c..93e1c41fa034 100644 --- a/contrib/libcxxrt/libelftc_dem_gnu3.c +++ b/contrib/libcxxrt/libelftc_dem_gnu3.c @@ -538,8 +538,8 @@ __cxa_demangle_gnu3(const char *org) struct type_delimit td; ssize_t org_len; unsigned int limit; - char *rtn; - bool has_ret, more_type; + char *rtn = NULL; + bool has_ret = false, more_type = false; if (org == NULL) return (NULL); @@ -562,13 +562,9 @@ __cxa_demangle_gnu3(const char *org) return (rtn); } - if (!cpp_demangle_data_init(&ddata, org + 2)) return (NULL); - rtn = NULL; - has_ret = more_type = false; - if (!cpp_demangle_read_encoding(&ddata)) goto clean; From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 19:42: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 E0EED567742; Wed, 24 Feb 2021 19:42: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 4Dm5sf60gYz4XwQ; Wed, 24 Feb 2021 19:42: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 C02101DEC; Wed, 24 Feb 2021 19:42: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 11OJgEbC082888; Wed, 24 Feb 2021 19:42:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OJgELR082887; Wed, 24 Feb 2021 19:42:14 GMT (envelope-from git) Date: Wed, 24 Feb 2021 19:42:14 GMT Message-Id: <202102241942.11OJgELR082887@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 696961f67c5e - stable/11 - Fix possibly unitialized variables in __cxa_demangle_gnu3() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 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, 24 Feb 2021 19:42:14 -0000 The branch stable/11 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 commit 696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 Author: Dimitry Andric AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric CommitDate: 2021-02-24 19:40:13 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) --- contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/libcxxrt/libelftc_dem_gnu3.c b/contrib/libcxxrt/libelftc_dem_gnu3.c index 6e88f7b4bb4c..93e1c41fa034 100644 --- a/contrib/libcxxrt/libelftc_dem_gnu3.c +++ b/contrib/libcxxrt/libelftc_dem_gnu3.c @@ -538,8 +538,8 @@ __cxa_demangle_gnu3(const char *org) struct type_delimit td; ssize_t org_len; unsigned int limit; - char *rtn; - bool has_ret, more_type; + char *rtn = NULL; + bool has_ret = false, more_type = false; if (org == NULL) return (NULL); @@ -562,13 +562,9 @@ __cxa_demangle_gnu3(const char *org) return (rtn); } - if (!cpp_demangle_data_init(&ddata, org + 2)) return (NULL); - rtn = NULL; - has_ret = more_type = false; - if (!cpp_demangle_read_encoding(&ddata)) goto clean; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 01:40:39 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 350845524FA; Thu, 25 Feb 2021 01:40:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmFqC14T8z3DbZ; Thu, 25 Feb 2021 01:40:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 17C8369FD; Thu, 25 Feb 2021 01:40:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11P1edpT055879; Thu, 25 Feb 2021 01:40:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P1edYs055878; Thu, 25 Feb 2021 01:40:39 GMT (envelope-from git) Date: Thu, 25 Feb 2021 01:40:39 GMT Message-Id: <202102250140.11P1edYs055878@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 1f3cff343b45 - stable/13 - cxgb(4): Rework my commit 9dc7c250. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f3cff343b451d9fc9c10f4f8c4b416ed5eae23f 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, 25 Feb 2021 01:40:39 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=1f3cff343b451d9fc9c10f4f8c4b416ed5eae23f commit 1f3cff343b451d9fc9c10f4f8c4b416ed5eae23f Author: Alexander Motin AuthorDate: 2021-02-22 22:21:05 +0000 Commit: Alexander Motin CommitDate: 2021-02-25 01:40:29 +0000 cxgb(4): Rework my commit 9dc7c250. The previous implementation was reported to try to coalesce packets in situations when it should not, that resulted in assertion later. This implementation better checks the first packet of the chain for the coallescing elligibility. (cherry picked from commit d510bf133d045d6c83742aeda6949bec150f6cbf) --- sys/dev/cxgb/cxgb_sge.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index 491d1a751f4a..f13d2f03180c 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -312,20 +312,22 @@ set_wr_hdr(struct work_request_hdr *wrp, uint32_t wr_hi, uint32_t wr_lo) struct coalesce_info { int count; int nbytes; + int noncoal; }; static int coalesce_check(struct mbuf *m, void *arg) { struct coalesce_info *ci = arg; - int *count = &ci->count; - int *nbytes = &ci->nbytes; - - if ((*nbytes == 0) || ((*nbytes + m->m_len <= 10500) && - (*count < 7) && (m->m_next == NULL) && - ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len <= PAGE_SIZE))) { - *count += 1; - *nbytes += m->m_len; + + if ((m->m_next != NULL) || + ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len > PAGE_SIZE)) + ci->noncoal = 1; + + if ((ci->count == 0) || (ci->noncoal == 0 && (ci->count < 7) && + (ci->nbytes + m->m_len <= 10500))) { + ci->count++; + ci->nbytes += m->m_len; return (1); } return (0); @@ -342,7 +344,7 @@ cxgb_dequeue(struct sge_qset *qs) return TXQ_RING_DEQUEUE(qs); m_head = m_tail = NULL; - ci.count = ci.nbytes = 0; + ci.count = ci.nbytes = ci.noncoal = 0; do { m = TXQ_RING_DEQUEUE_COND(qs, coalesce_check, &ci); if (m_head == NULL) { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 01:41: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 7139C551EEE; Thu, 25 Feb 2021 01:41: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 4DmFqh2r94z3Dyp; Thu, 25 Feb 2021 01:41: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 546006CC3; Thu, 25 Feb 2021 01:41: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 11P1f4oh056942; Thu, 25 Feb 2021 01:41:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P1f4xc056941; Thu, 25 Feb 2021 01:41:04 GMT (envelope-from git) Date: Thu, 25 Feb 2021 01:41:04 GMT Message-Id: <202102250141.11P1f4xc056941@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 2eb9b105f3e4 - stable/12 - cxgb(4): Rework my commit 9dc7c250. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2eb9b105f3e473e1438944cc95e36d7912b3296e 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, 25 Feb 2021 01:41:04 -0000 The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2eb9b105f3e473e1438944cc95e36d7912b3296e commit 2eb9b105f3e473e1438944cc95e36d7912b3296e Author: Alexander Motin AuthorDate: 2021-02-22 22:21:05 +0000 Commit: Alexander Motin CommitDate: 2021-02-25 01:40:56 +0000 cxgb(4): Rework my commit 9dc7c250. The previous implementation was reported to try to coalesce packets in situations when it should not, that resulted in assertion later. This implementation better checks the first packet of the chain for the coallescing elligibility. (cherry picked from commit d510bf133d045d6c83742aeda6949bec150f6cbf) --- sys/dev/cxgb/cxgb_sge.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index 489d74459ae1..07eb91a4d04c 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -312,20 +312,22 @@ set_wr_hdr(struct work_request_hdr *wrp, uint32_t wr_hi, uint32_t wr_lo) struct coalesce_info { int count; int nbytes; + int noncoal; }; static int coalesce_check(struct mbuf *m, void *arg) { struct coalesce_info *ci = arg; - int *count = &ci->count; - int *nbytes = &ci->nbytes; - - if ((*nbytes == 0) || ((*nbytes + m->m_len <= 10500) && - (*count < 7) && (m->m_next == NULL) && - ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len <= PAGE_SIZE))) { - *count += 1; - *nbytes += m->m_len; + + if ((m->m_next != NULL) || + ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len > PAGE_SIZE)) + ci->noncoal = 1; + + if ((ci->count == 0) || (ci->noncoal == 0 && (ci->count < 7) && + (ci->nbytes + m->m_len <= 10500))) { + ci->count++; + ci->nbytes += m->m_len; return (1); } return (0); @@ -342,7 +344,7 @@ cxgb_dequeue(struct sge_qset *qs) return TXQ_RING_DEQUEUE(qs); m_head = m_tail = NULL; - ci.count = ci.nbytes = 0; + ci.count = ci.nbytes = ci.noncoal = 0; do { m = TXQ_RING_DEQUEUE_COND(qs, coalesce_check, &ci); if (m_head == NULL) { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 06:57:55 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B072C558FA7; Thu, 25 Feb 2021 06:57:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmNsH4f5Gz3mBQ; Thu, 25 Feb 2021 06:57:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9243312CED; Thu, 25 Feb 2021 06:57:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11P6vtTh069283; Thu, 25 Feb 2021 06:57:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P6vtIj069282; Thu, 25 Feb 2021 06:57:55 GMT (envelope-from git) Date: Thu, 25 Feb 2021 06:57:55 GMT Message-Id: <202102250657.11P6vtIj069282@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: 12c27808888b - stable/13 - pwrite(2): add a BUGS section MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 12c27808888b05db09b58af735fbc342080bdb37 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, 25 Feb 2021 06:57:55 -0000 The branch stable/13 has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=12c27808888b05db09b58af735fbc342080bdb37 commit 12c27808888b05db09b58af735fbc342080bdb37 Author: Guangyuan Yang AuthorDate: 2021-02-20 08:03:15 +0000 Commit: Guangyuan Yang CommitDate: 2021-02-25 06:57:35 +0000 pwrite(2): add a BUGS section Add a BUGS section about using pwrite(2) when O_APPEND is set on the fd. Submitted by: Ka Ho Ng Reviewed by: gbe, yuripv Differential Revision: https://reviews.freebsd.org/D28372 (cherry picked from commit 504e64af32ba6c62fdcc894a3b1da76061c64796) --- lib/libc/sys/write.2 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index f05db0de81c4..937e95b53a14 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -28,7 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd October 25, 2020 +.Dd February 11, 2021 .Dt WRITE 2 .Os .Sh NAME @@ -298,3 +298,17 @@ The .Fn write function appeared in .At v1 . +.Sh BUGS +The +.Fn pwrite +system call appends the file without changing the file offset if +.Dv O_APPEND +is set, contrary to +.St -p1003.1-2008 +where +.Fn pwrite +writes into +.Fa offset +regardless of whether +.Dv O_APPEND +is set. From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 07:53: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 9D39B559FDC; Thu, 25 Feb 2021 07:53: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 4DmQ4s45Y7z3q8B; Thu, 25 Feb 2021 07:53: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 7F72013F8A; Thu, 25 Feb 2021 07:53: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 11P7r179047111; Thu, 25 Feb 2021 07:53:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P7r1TG047110; Thu, 25 Feb 2021 07:53:01 GMT (envelope-from git) Date: Thu, 25 Feb 2021 07:53:01 GMT Message-Id: <202102250753.11P7r1TG047110@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: 5d66edf463a0 - stable/12 - ether: add older ethertype definitions for QinQ 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: 5d66edf463a053a840a08322107363cf79249f6f 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, 25 Feb 2021 07:53:01 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=5d66edf463a053a840a08322107363cf79249f6f commit 5d66edf463a053a840a08322107363cf79249f6f Author: Philip Paeps AuthorDate: 2019-10-17 00:34:53 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 07:51:39 +0000 ether: add older ethertype definitions for QinQ Older network equipment used the ethertypes 0x9100, 0x9200, and 0x9300 for outer VLANs, before standardisation introduced 0x88a8. Submitted by: Lutz Donnerhacke Differential Revision: https://reviews.freebsd.org/D21846 (cherry picked from commit 579b70db8922b1debf3bd99bb2b822d60b95575d) --- sys/net/ethernet.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 5e46f124a0f2..fdfc41b55037 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -360,10 +360,13 @@ struct ether_vlan_header { #define ETHERTYPE_PBB 0x88E7 /* 802.1Q Provider Backbone Bridges */ #define ETHERTYPE_FCOE 0x8906 /* Fibre Channel over Ethernet */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ +#define ETHERTYPE_8021Q9100 0x9100 /* IEEE 802.1Q stacking (proprietary) */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ #define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ #define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ +#define ETHERTYPE_8021Q9200 0x9200 /* IEEE 802.1Q stacking (proprietary) */ +#define ETHERTYPE_8021Q9300 0x9300 /* IEEE 802.1Q stacking (proprietary) */ #define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ #define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ #define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 07:53: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 B38F855A20E; Thu, 25 Feb 2021 07:53: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 4DmQ4t4Xnsz3q2w; Thu, 25 Feb 2021 07:53: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 8D927140E3; Thu, 25 Feb 2021 07:53: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 11P7r2XR047134; Thu, 25 Feb 2021 07:53:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P7r2S4047133; Thu, 25 Feb 2021 07:53:02 GMT (envelope-from git) Date: Thu, 25 Feb 2021 07:53:02 GMT Message-Id: <202102250753.11P7r2S4047133@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: a0e2fe87031a - stable/12 - netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type 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: a0e2fe87031a63f336d2a66c383cc017b6207cd1 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, 25 Feb 2021 07:53:02 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=a0e2fe87031a63f336d2a66c383cc017b6207cd1 commit a0e2fe87031a63f336d2a66c383cc017b6207cd1 Author: Lutz Donnerhacke AuthorDate: 2021-01-26 15:50:04 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 07:51:58 +0000 netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type This node is part of an A10-NSP (L2-BSA) development. Carrier networks tend to stack three or more tags for internal purposes and therefore hiding the service tags deep inside of the stack. When decomposing such an access network frame, the processing order is typically reversed: First distinguish by service, than by other means. This new netgragh node allows to bring the relevant VLAN in front (to the out-most position). This way other netgraph nodes (like ng_vlan) can operate on this specific type. Reviewed by: manpages (gbe), brueffer (manpages), kp Relnotes: yes Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22076 (cherry picked from commit cfd6422a5217410fbd66f7a7a8a64d9d85e61229) --- share/man/man4/Makefile | 1 + share/man/man4/ng_vlan_rotate.4 | 252 +++++++++++++++ sys/conf/files | 1 + sys/modules/netgraph/Makefile | 3 +- sys/modules/netgraph/vlan_rotate/Makefile | 6 + sys/netgraph/ng_vlan_rotate.c | 510 ++++++++++++++++++++++++++++++ sys/netgraph/ng_vlan_rotate.h | 67 ++++ 7 files changed, 839 insertions(+), 1 deletion(-) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index f3b227efcfde..1ea16db94550 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -391,6 +391,7 @@ MAN= aac.4 \ ng_uni.4 \ ng_vjc.4 \ ng_vlan.4 \ + ng_vlan_rotate.4 \ nmdm.4 \ nsp.4 \ ${_ntb.4} \ diff --git a/share/man/man4/ng_vlan_rotate.4 b/share/man/man4/ng_vlan_rotate.4 new file mode 100644 index 000000000000..4640737c7d54 --- /dev/null +++ b/share/man/man4/ng_vlan_rotate.4 @@ -0,0 +1,252 @@ +.\"- +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2019-2021 IKS Service GmbH +.\" +.\" 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. +.\" +.\" Author: Lutz Donnerhacke +.\" +.\" $FreeBSD$ +.\" +.Dd January 26, 2021 +.Dt NG_VLAN_ROTATE 4 +.Os +.Sh NAME +.Nm ng_vlan_rotate +.Nd IEEE 802.1ad VLAN manipulation netgraph node type +.Sh SYNOPSIS +.In sys/types.h +.In netgraph.h +.In netgraph/ng_vlan_rotate.h +.Sh DESCRIPTION +The +.Nm +node type manipulates the order of VLAN tags of frames tagged +according to the IEEE 802.1ad (an extension of IEEE 802.1Q) standard +between different hooks. +.Pp +Each node has four special hooks, +.Va original , +.Va ordered , +.Va excessive , +and +.Va incomplete . +.Pp +A frame tagged with an arbitrary number of +.Dv ETHERTYPE_VLAN , +.Dv ETHERTYPE_QINQ , +and +.Dv 0x9100 +tags received on the +.Va original +hook will be rearranged to a new order of those tags and is sent out +the +.Dq ordered +hook. +After successful processing the +.Va histogram +counter for the observed stack size increments. +.Pp +If it contains fewer VLANs in the stack than the configured +.Va min +limit, the frame is sent out to the +.Va incomplete +hook and the +.Va incomplete +counter increments. +.Pp +If there are more VLANs in the stack than the configured +.Va max +limit, the frame is sent out to the +.Va excessive +hook and the +.Va excessive +counter increments. +.Pp +If the destination hook is not connected, the frame is dropped and the +.Va drops +counter increments. +.Pp +For Ethernet frames received on the +.Va ordered +hook, the transformation is reversed and is passed to the +.Va original +hook. +Please note that this process is identical to the one described +above, besides the ordered/original hooks are swapped and the +transformation is reversed. +.Pp +An Ethernet frame received on the +.Va incomplete +or +.Va excessive +hook is forwarded to the +.Va original +hook without any modification. +.Pp +This node supports only one operation at the moment: Rotation of the +VLANs in the stack. +Setting the configuration parameter +.Va rot +to a positive value, the stack will roll up by this amount. +Negative values will roll down. +A typical scenario is setting the value to 1 in order to bring the +innermost VLAN tag to the outmost level. +Rotation includes the VLAN id, the ether type, and the QOS parameters +pcp and cfi. +Typical QOS handling refers to the outmost setting, so be careful to +keep your QOS intact. +.Sh HOOKS +This node type supports the following hooks: +.Bl -tag -width incomplete +.It Va original +Typically this hook would be connected to a +.Xr ng_ether 4 +node, using the +.Va lower +hook connected to a carrier network. +.It Va ordered +Typically this hook would be connected to a +.Xr ng_vlan 4 +type node using the +.Va downstream +hook in order to separate services. +.It Va excessive +see below. +.It Va incomplete +Typically those hooks would be attached to a +.Xr ng_eiface 4 +type node using the +.Va ether +hook for anomaly monitoring purposes. +.El +.Sh CONTROL MESSAGES +This node type supports the generic control messages, plus the following: +.Bl -tag -width foo +.It Dv NGM_VLANROTATE_GET_CONF Pq Ic getconf +Read the current configuration. +.It Dv NGM_VLANROTATE_SET_CONF Pq Ic setconf +Set the current configuration. +.It Dv NGM_VLANROTATE_GET_STAT Pq Ic getstat +Read the current statistics. +.It Dv NGM_VLANROTATE_CLR_STAT Pq Ic clrstat +Zeroize the statistics. +.It Dv NGM_VLANROTATE_GETCLR_STAT Pq Ic getclrstat +Read the current statistics and zeroize it in one step. +.El +.Sh EXAMPLES +The first example demonstrates how to rotate double or triple tagged +frames so that the innermost C-VLAN can be used as service +discriminator. +The single or double tagged frames (C-VLAN removed) are sent out to an +interface pointing to different infrastucture. +.Bd -literal +#!/bin/sh + +BNG_IF=ixl3 +VOIP_IF=bge2 + +ngctl -f- < 00:01:02:03:04:05, + ethertype 802.1Q-9100 (0x9100), length 110: vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype 802.1Q, vlan 123, p 7, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The frame ejected on the +.Va ordered +hook will look like this: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q (0x8100), length 110: vlan 123, p 7, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +Hence, the frame pushed out to the +.Dv VOIP_IF +will have this form: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The second example distinguishes between double tagged and single +tagged frames. +.Bd -literal +#!/bin/sh + +IN_IF=bge1 + +ngctl -f- < diff --git a/sys/netgraph/ng_vlan_rotate.c b/sys/netgraph/ng_vlan_rotate.c new file mode 100644 index 000000000000..e6de782d9bb3 --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.c @@ -0,0 +1,510 @@ +/*- + * Spdx-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +/* + * This section contains the netgraph method declarations for the + * sample node. These methods define the netgraph 'type'. + */ + +static ng_constructor_t ng_vlanrotate_constructor; +static ng_rcvmsg_t ng_vlanrotate_rcvmsg; +static ng_shutdown_t ng_vlanrotate_shutdown; +static ng_newhook_t ng_vlanrotate_newhook; +static ng_rcvdata_t ng_vlanrotate_rcvdata; +static ng_disconnect_t ng_vlanrotate_disconnect; + +/* Parse type for struct ng_vlanrotate_conf */ +static const struct ng_parse_struct_field ng_vlanrotate_conf_fields[] = { + {"rot", &ng_parse_int8_type}, + {"min", &ng_parse_uint8_type}, + {"max", &ng_parse_uint8_type}, + {NULL} +}; +static const struct ng_parse_type ng_vlanrotate_conf_type = { + &ng_parse_struct_type, + &ng_vlanrotate_conf_fields +}; + +/* Parse type for struct ng_vlanrotate_stat */ +static struct ng_parse_fixedarray_info ng_vlanrotate_stat_hist_info = { + &ng_parse_uint64_type, + NG_VLANROTATE_MAX_VLANS +}; +static struct ng_parse_type ng_vlanrotate_stat_hist = { + &ng_parse_fixedarray_type, + &ng_vlanrotate_stat_hist_info +}; +static const struct ng_parse_struct_field ng_vlanrotate_stat_fields[] = { + {"drops", &ng_parse_uint64_type}, + {"excessive", &ng_parse_uint64_type}, + {"incomplete", &ng_parse_uint64_type}, + {"histogram", &ng_vlanrotate_stat_hist}, + {NULL} +}; +static struct ng_parse_type ng_vlanrotate_stat_type = { + &ng_parse_struct_type, + &ng_vlanrotate_stat_fields +}; + + +/* List of commands and how to convert arguments to/from ASCII */ +static const struct ng_cmdlist ng_vlanrotate_cmdlist[] = { + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_CONF, + "getconf", + NULL, + &ng_vlanrotate_conf_type, + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_SET_CONF, + "setconf", + &ng_vlanrotate_conf_type, + NULL + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_STAT, + "getstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_CLR_STAT, + "clrstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GETCLR_STAT, + "getclrstat", + NULL, + &ng_vlanrotate_stat_type + }, + {0} +}; + +/* Netgraph node type descriptor */ +static struct ng_type typestruct = { + .version = NG_ABI_VERSION, + .name = NG_VLANROTATE_NODE_TYPE, + .constructor = ng_vlanrotate_constructor, + .rcvmsg = ng_vlanrotate_rcvmsg, + .shutdown = ng_vlanrotate_shutdown, + .newhook = ng_vlanrotate_newhook, + .rcvdata = ng_vlanrotate_rcvdata, + .disconnect = ng_vlanrotate_disconnect, + .cmdlist = ng_vlanrotate_cmdlist, +}; +NETGRAPH_INIT(vlanrotate, &typestruct); + +struct ng_vlanrotate_kernel_stats { + counter_u64_t drops, excessive, incomplete; + counter_u64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Information we store for each node */ +struct vlanrotate { + hook_p original_hook; + hook_p ordered_hook; + hook_p excessive_hook; + hook_p incomplete_hook; + struct ng_vlanrotate_conf conf; + struct ng_vlanrotate_kernel_stats stats; +}; +typedef struct vlanrotate *vlanrotate_p; + +/* + * Set up the private data structure. + */ +static int +ng_vlanrotate_constructor(node_p node) +{ + int i; + + vlanrotate_p vrp = malloc(sizeof(*vrp), M_NETGRAPH, M_WAITOK | M_ZERO); + + vrp->conf.max = NG_VLANROTATE_MAX_VLANS; + + vrp->stats.drops = counter_u64_alloc(M_WAITOK); + vrp->stats.excessive = counter_u64_alloc(M_WAITOK); + vrp->stats.incomplete = counter_u64_alloc(M_WAITOK); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + vrp->stats.histogram[i] = counter_u64_alloc(M_WAITOK); + + NG_NODE_SET_PRIVATE(node, vrp); + return (0); +} + +/* + * Give our ok for a hook to be added. + */ +static int +ng_vlanrotate_newhook(node_p node, hook_p hook, const char *name) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + hook_p *dst = NULL; + + if (strcmp(name, NG_VLANROTATE_HOOK_ORDERED) == 0) { + dst = &vrp->ordered_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_ORIGINAL) == 0) { + dst = &vrp->original_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_EXCESSIVE) == 0) { + dst = &vrp->excessive_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_INCOMPLETE) == 0) { + dst = &vrp->incomplete_hook; + } else + return (EINVAL); /* not a hook we know about */ + + if (*dst != NULL) + return (EADDRINUSE); /* don't override */ + + *dst = hook; + return (0); +} + +/* + * Get a netgraph control message. + * A response is not required. + */ +static int +ng_vlanrotate_rcvmsg(node_p node, item_p item, hook_p lasthook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + struct ng_mesg *resp = NULL; + struct ng_mesg *msg; + struct ng_vlanrotate_conf *pcf; + int error = 0; + + NGI_GET_MSG(item, msg); + /* Deal with message according to cookie and command */ + switch (msg->header.typecookie) { + case NGM_VLANROTATE_COOKIE: + switch (msg->header.cmd) { + case NGM_VLANROTATE_GET_CONF: + NG_MKRESPONSE(resp, msg, sizeof(vrp->conf), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + *((struct ng_vlanrotate_conf *)resp->data) = vrp->conf; + break; + case NGM_VLANROTATE_SET_CONF: + if (msg->header.arglen != sizeof(*pcf)) { + error = EINVAL; + break; + } + + pcf = (struct ng_vlanrotate_conf *)msg->data; + + if (pcf->max == 0) /* keep current value */ + pcf->max = vrp->conf.max; + + if ((pcf->max > NG_VLANROTATE_MAX_VLANS) || + (pcf->min > pcf->max) || + (abs(pcf->rot) >= pcf->max)) { + error = EINVAL; + break; + } + + vrp->conf = *pcf; + break; + case NGM_VLANROTATE_GET_STAT: + case NGM_VLANROTATE_GETCLR_STAT: + { + struct ng_vlanrotate_stat *p; + int i; + + NG_MKRESPONSE(resp, msg, sizeof(*p), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + p = (struct ng_vlanrotate_stat *)resp->data; + p->drops = counter_u64_fetch(vrp->stats.drops); + p->excessive = counter_u64_fetch(vrp->stats.excessive); + p->incomplete = counter_u64_fetch(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + p->histogram[i] = counter_u64_fetch(vrp->stats.histogram[i]); + if (msg->header.cmd != NGM_VLANROTATE_GETCLR_STAT) + break; + } + case NGM_VLANROTATE_CLR_STAT: + { + int i; + + counter_u64_zero(vrp->stats.drops); + counter_u64_zero(vrp->stats.excessive); + counter_u64_zero(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_zero(vrp->stats.histogram[i]); + break; + } + default: + error = EINVAL; /* unknown command */ + break; + } + break; + default: + error = EINVAL; /* unknown cookie type */ + break; + } + + /* Take care of synchronous response, if any */ + NG_RESPOND_MSG(error, node, item, resp); + /* Free the message and return */ + NG_FREE_MSG(msg); + return (error); +} + +/* + * Receive data, and do rotate the vlans as desired. + * + * Rotating is quite complicated if the rotation offset and the number + * of vlans are not relativly prime. In this case multiple slices need + * to be rotated separately. + * + * Rotation can be additive or subtractive. Some examples: + * 01234 5 vlans given + * ----- + * 34012 +2 rotate + * 12340 +4 rotate + * 12340 -1 rotate + * + * First some helper functions ... + */ + +struct ether_vlan_stack_entry { + uint16_t proto; + uint16_t tag; +} __packed; + +struct ether_vlan_stack_header { + uint8_t dst[ETHER_ADDR_LEN]; + uint8_t src[ETHER_ADDR_LEN]; + struct ether_vlan_stack_entry vlan_stack[1]; +} __packed; + +static int +ng_vlanrotate_gcd(int a, int b) +{ + if (b == 0) + return a; + else + return ng_vlanrotate_gcd(b, a % b); +} + +static void +ng_vlanrotate_rotate(struct ether_vlan_stack_entry arr[], int d, int n) +{ + int i, j, k; + struct ether_vlan_stack_entry temp; + + /* for each commensurable slice */ + for (i = ng_vlanrotate_gcd(d, n); i-- > 0;) { + /* rotate left aka downwards */ + temp = arr[i]; + j = i; + + while (1) { + k = j + d; + if (k >= n) + k = k - n; + if (k == i) + break; + arr[j] = arr[k]; + j = k; + } + + arr[j] = temp; + } +} + +static int +ng_vlanrotate_rcvdata(hook_p hook, item_p item) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + struct ether_vlan_stack_header *evsh; + struct mbuf *m = NULL; + hook_p dst_hook; + int8_t rotate; + int8_t vlans = 0; + int error = ENOSYS; + + NGI_GET_M(item, m); + + if (hook == vrp->ordered_hook) { + rotate = +vrp->conf.rot; + dst_hook = vrp->original_hook; + } else if (hook == vrp->original_hook) { + rotate = -vrp->conf.rot; + dst_hook = vrp->ordered_hook; + } else { + dst_hook = vrp->original_hook; + goto send; /* everything else goes out unmodified */ + } + + if (dst_hook == NULL) { + error = ENETDOWN; + goto fail; + } + + /* count the vlans */ + for (vlans = 0; vlans <= NG_VLANROTATE_MAX_VLANS; vlans++) { + size_t expected_len = sizeof(struct ether_vlan_stack_header) + + vlans * sizeof(struct ether_vlan_stack_entry); + + if (m->m_len < expected_len) { + m = m_pullup(m, expected_len); + if (m == NULL) { + error = EINVAL; + goto fail; + } + } + + evsh = mtod(m, struct ether_vlan_stack_header *); + switch (ntohs(evsh->vlan_stack[vlans].proto)) { + case ETHERTYPE_VLAN: + case ETHERTYPE_QINQ: + case ETHERTYPE_8021Q9100: + case ETHERTYPE_8021Q9200: + case ETHERTYPE_8021Q9300: + break; + default: + goto out; + } + } +out: + if ((vlans > vrp->conf.max) || (vlans >= NG_VLANROTATE_MAX_VLANS)) { + counter_u64_add(vrp->stats.excessive, 1); + dst_hook = vrp->excessive_hook; + goto send; + } + + if ((vlans < vrp->conf.min) || (vlans <= abs(rotate))) { + counter_u64_add(vrp->stats.incomplete, 1); + dst_hook = vrp->incomplete_hook; + goto send; + } + counter_u64_add(vrp->stats.histogram[vlans], 1); + + /* rotating upwards always (using modular arithmetics) */ + if (rotate == 0) { + /* nothing to do */ + } else if (rotate > 0) { + ng_vlanrotate_rotate(evsh->vlan_stack, rotate, vlans); + } else { + ng_vlanrotate_rotate(evsh->vlan_stack, vlans + rotate, vlans); + } + +send: + if (dst_hook == NULL) + goto fail; + NG_FWD_NEW_DATA(error, item, dst_hook, m); + return 0; + +fail: + counter_u64_add(vrp->stats.drops, 1); + if (m != NULL) + m_freem(m); + NG_FREE_ITEM(item); + return (error); +} + +/* + * Do local shutdown processing.. + * All our links and the name have already been removed. + */ +static int +ng_vlanrotate_shutdown(node_p node) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + int i; + + NG_NODE_SET_PRIVATE(node, NULL); + + counter_u64_free(vrp->stats.drops); + counter_u64_free(vrp->stats.excessive); + counter_u64_free(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_free(vrp->stats.histogram[i]); + + free(vrp, M_NETGRAPH); + + NG_NODE_UNREF(node); + return (0); +} + +/* + * Hook disconnection + * For this type, removal of the last link destroys the node + */ +static int +ng_vlanrotate_disconnect(hook_p hook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + + if (vrp->original_hook == hook) + vrp->original_hook = NULL; + if (vrp->ordered_hook == hook) + vrp->ordered_hook = NULL; + if (vrp->excessive_hook == hook) + vrp->excessive_hook = NULL; + if (vrp->incomplete_hook == hook) + vrp->incomplete_hook = NULL; + + /* during shutdown the node is invalid, don't shutdown twice */ + if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) && + (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) + ng_rmnode_self(NG_HOOK_NODE(hook)); + return (0); +} diff --git a/sys/netgraph/ng_vlan_rotate.h b/sys/netgraph/ng_vlan_rotate.h new file mode 100644 index 000000000000..ef6dfd6b506a --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.h @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_NG_VLAN_ROTATE_H_ +#define _NETGRAPH_NG_VLAN_ROTATE_H_ + +#define NG_VLANROTATE_NODE_TYPE "vlan_rotate" +#define NGM_VLANROTATE_COOKIE 1568378766 + +/* Hook names */ +#define NG_VLANROTATE_HOOK_ORDERED "ordered" +#define NG_VLANROTATE_HOOK_ORIGINAL "original" +#define NG_VLANROTATE_HOOK_EXCESSIVE "excessive" +#define NG_VLANROTATE_HOOK_INCOMPLETE "incomplete" + +/* Limits */ +#define NG_VLANROTATE_MAX_VLANS 10 + +/* Datastructures for netgraph commands */ +struct ng_vlanrotate_conf { + int8_t rot; + uint8_t min, max; +}; + +struct ng_vlanrotate_stat { + uint64_t drops, excessive, incomplete; + uint64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Netgraph commands understood by this node type */ +enum { + NGM_VLANROTATE_GET_CONF = 1, + NGM_VLANROTATE_SET_CONF, + NGM_VLANROTATE_GET_STAT, + NGM_VLANROTATE_CLR_STAT, + NGM_VLANROTATE_GETCLR_STAT +}; + +#endif /* _NETGRAPH_NG_VLAN_ROTATE_H_ */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 07:59: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 10D9555A5B6; Thu, 25 Feb 2021 07:59:34 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmQDP5fJhz3qX8; Thu, 25 Feb 2021 07:59:33 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 11P7xHL8009209 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 25 Feb 2021 08:59:17 +0100 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 11P7xHoQ029807; Thu, 25 Feb 2021 08:59:17 +0100 Date: Thu, 25 Feb 2021 08:59:17 +0100 From: Lutz Donnerhacke To: Lutz Donnerhacke Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: Re: git: 5d66edf463a0 - stable/12 - ether: add older ethertype definitions for QinQ Message-ID: <20210225075917.GA29787@belenus.iks-jena.de> References: <202102250753.11P7r1TG047110@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202102250753.11P7r1TG047110@gitrepo.freebsd.org> X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4DmQDP5fJhz3qX8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-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, 25 Feb 2021 07:59:34 -0000 On Thu, Feb 25, 2021 at 07:53:01AM +0000, Lutz Donnerhacke wrote: > The branch stable/12 has been updated by donner: > > URL: https://cgit.FreeBSD.org/src/commit/?id=5d66edf463a053a840a08322107363cf79249f6f > > commit 5d66edf463a053a840a08322107363cf79249f6f > Author: Philip Paeps > AuthorDate: 2019-10-17 00:34:53 +0000 > Commit: Lutz Donnerhacke > CommitDate: 2021-02-25 07:51:39 +0000 > > ether: add older ethertype definitions for QinQ > > Older network equipment used the ethertypes 0x9100, 0x9200, and 0x9300 for > outer VLANs, before standardisation introduced 0x88a8. > > Submitted by: Lutz Donnerhacke > Differential Revision: https://reviews.freebsd.org/D21846 > > (cherry picked from commit 579b70db8922b1debf3bd99bb2b822d60b95575d) That's a prerequisite for the next commit. So I commited it in a bundle with the MFCed one. From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 08:04: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 332A855AC42; Thu, 25 Feb 2021 08:04: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 4DmQLX0xc7z3rBF; Thu, 25 Feb 2021 08:04: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 1316814304; Thu, 25 Feb 2021 08:04: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 11P84q4a061693; Thu, 25 Feb 2021 08:04:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P84qCj061692; Thu, 25 Feb 2021 08:04:52 GMT (envelope-from git) Date: Thu, 25 Feb 2021 08:04:52 GMT Message-Id: <202102250804.11P84qCj061692@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: 522a0b7d029f - stable/13 - netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type 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: 522a0b7d029f4bf966081c10673405c946fe3dc0 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, 25 Feb 2021 08:04:52 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=522a0b7d029f4bf966081c10673405c946fe3dc0 commit 522a0b7d029f4bf966081c10673405c946fe3dc0 Author: Lutz Donnerhacke AuthorDate: 2021-01-26 15:50:04 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 08:04:24 +0000 netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type This node is part of an A10-NSP (L2-BSA) development. Carrier networks tend to stack three or more tags for internal purposes and therefore hiding the service tags deep inside of the stack. When decomposing such an access network frame, the processing order is typically reversed: First distinguish by service, than by other means. This new netgragh node allows to bring the relevant VLAN in front (to the out-most position). This way other netgraph nodes (like ng_vlan) can operate on this specific type. Reviewed by: manpages (gbe), brueffer (manpages), kp Relnotes: yes Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22076 (cherry picked from commit cfd6422a5217410fbd66f7a7a8a64d9d85e61229) --- share/man/man4/Makefile | 1 + share/man/man4/ng_vlan_rotate.4 | 252 +++++++++++++++ sys/conf/files | 1 + sys/modules/netgraph/Makefile | 3 +- sys/modules/netgraph/vlan_rotate/Makefile | 6 + sys/netgraph/ng_vlan_rotate.c | 510 ++++++++++++++++++++++++++++++ sys/netgraph/ng_vlan_rotate.h | 67 ++++ 7 files changed, 839 insertions(+), 1 deletion(-) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index b66dcf135733..5ccb42181482 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -393,6 +393,7 @@ MAN= aac.4 \ ng_uni.4 \ ng_vjc.4 \ ng_vlan.4 \ + ng_vlan_rotate.4 \ nmdm.4 \ ${_ntb.4} \ ${_ntb_hw_amd.4} \ diff --git a/share/man/man4/ng_vlan_rotate.4 b/share/man/man4/ng_vlan_rotate.4 new file mode 100644 index 000000000000..4640737c7d54 --- /dev/null +++ b/share/man/man4/ng_vlan_rotate.4 @@ -0,0 +1,252 @@ +.\"- +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2019-2021 IKS Service GmbH +.\" +.\" 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. +.\" +.\" Author: Lutz Donnerhacke +.\" +.\" $FreeBSD$ +.\" +.Dd January 26, 2021 +.Dt NG_VLAN_ROTATE 4 +.Os +.Sh NAME +.Nm ng_vlan_rotate +.Nd IEEE 802.1ad VLAN manipulation netgraph node type +.Sh SYNOPSIS +.In sys/types.h +.In netgraph.h +.In netgraph/ng_vlan_rotate.h +.Sh DESCRIPTION +The +.Nm +node type manipulates the order of VLAN tags of frames tagged +according to the IEEE 802.1ad (an extension of IEEE 802.1Q) standard +between different hooks. +.Pp +Each node has four special hooks, +.Va original , +.Va ordered , +.Va excessive , +and +.Va incomplete . +.Pp +A frame tagged with an arbitrary number of +.Dv ETHERTYPE_VLAN , +.Dv ETHERTYPE_QINQ , +and +.Dv 0x9100 +tags received on the +.Va original +hook will be rearranged to a new order of those tags and is sent out +the +.Dq ordered +hook. +After successful processing the +.Va histogram +counter for the observed stack size increments. +.Pp +If it contains fewer VLANs in the stack than the configured +.Va min +limit, the frame is sent out to the +.Va incomplete +hook and the +.Va incomplete +counter increments. +.Pp +If there are more VLANs in the stack than the configured +.Va max +limit, the frame is sent out to the +.Va excessive +hook and the +.Va excessive +counter increments. +.Pp +If the destination hook is not connected, the frame is dropped and the +.Va drops +counter increments. +.Pp +For Ethernet frames received on the +.Va ordered +hook, the transformation is reversed and is passed to the +.Va original +hook. +Please note that this process is identical to the one described +above, besides the ordered/original hooks are swapped and the +transformation is reversed. +.Pp +An Ethernet frame received on the +.Va incomplete +or +.Va excessive +hook is forwarded to the +.Va original +hook without any modification. +.Pp +This node supports only one operation at the moment: Rotation of the +VLANs in the stack. +Setting the configuration parameter +.Va rot +to a positive value, the stack will roll up by this amount. +Negative values will roll down. +A typical scenario is setting the value to 1 in order to bring the +innermost VLAN tag to the outmost level. +Rotation includes the VLAN id, the ether type, and the QOS parameters +pcp and cfi. +Typical QOS handling refers to the outmost setting, so be careful to +keep your QOS intact. +.Sh HOOKS +This node type supports the following hooks: +.Bl -tag -width incomplete +.It Va original +Typically this hook would be connected to a +.Xr ng_ether 4 +node, using the +.Va lower +hook connected to a carrier network. +.It Va ordered +Typically this hook would be connected to a +.Xr ng_vlan 4 +type node using the +.Va downstream +hook in order to separate services. +.It Va excessive +see below. +.It Va incomplete +Typically those hooks would be attached to a +.Xr ng_eiface 4 +type node using the +.Va ether +hook for anomaly monitoring purposes. +.El +.Sh CONTROL MESSAGES +This node type supports the generic control messages, plus the following: +.Bl -tag -width foo +.It Dv NGM_VLANROTATE_GET_CONF Pq Ic getconf +Read the current configuration. +.It Dv NGM_VLANROTATE_SET_CONF Pq Ic setconf +Set the current configuration. +.It Dv NGM_VLANROTATE_GET_STAT Pq Ic getstat +Read the current statistics. +.It Dv NGM_VLANROTATE_CLR_STAT Pq Ic clrstat +Zeroize the statistics. +.It Dv NGM_VLANROTATE_GETCLR_STAT Pq Ic getclrstat +Read the current statistics and zeroize it in one step. +.El +.Sh EXAMPLES +The first example demonstrates how to rotate double or triple tagged +frames so that the innermost C-VLAN can be used as service +discriminator. +The single or double tagged frames (C-VLAN removed) are sent out to an +interface pointing to different infrastucture. +.Bd -literal +#!/bin/sh + +BNG_IF=ixl3 +VOIP_IF=bge2 + +ngctl -f- < 00:01:02:03:04:05, + ethertype 802.1Q-9100 (0x9100), length 110: vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype 802.1Q, vlan 123, p 7, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The frame ejected on the +.Va ordered +hook will look like this: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q (0x8100), length 110: vlan 123, p 7, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +Hence, the frame pushed out to the +.Dv VOIP_IF +will have this form: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The second example distinguishes between double tagged and single +tagged frames. +.Bd -literal +#!/bin/sh + +IN_IF=bge1 + +ngctl -f- < diff --git a/sys/netgraph/ng_vlan_rotate.c b/sys/netgraph/ng_vlan_rotate.c new file mode 100644 index 000000000000..e6de782d9bb3 --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.c @@ -0,0 +1,510 @@ +/*- + * Spdx-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +/* + * This section contains the netgraph method declarations for the + * sample node. These methods define the netgraph 'type'. + */ + +static ng_constructor_t ng_vlanrotate_constructor; +static ng_rcvmsg_t ng_vlanrotate_rcvmsg; +static ng_shutdown_t ng_vlanrotate_shutdown; +static ng_newhook_t ng_vlanrotate_newhook; +static ng_rcvdata_t ng_vlanrotate_rcvdata; +static ng_disconnect_t ng_vlanrotate_disconnect; + +/* Parse type for struct ng_vlanrotate_conf */ +static const struct ng_parse_struct_field ng_vlanrotate_conf_fields[] = { + {"rot", &ng_parse_int8_type}, + {"min", &ng_parse_uint8_type}, + {"max", &ng_parse_uint8_type}, + {NULL} +}; +static const struct ng_parse_type ng_vlanrotate_conf_type = { + &ng_parse_struct_type, + &ng_vlanrotate_conf_fields +}; + +/* Parse type for struct ng_vlanrotate_stat */ +static struct ng_parse_fixedarray_info ng_vlanrotate_stat_hist_info = { + &ng_parse_uint64_type, + NG_VLANROTATE_MAX_VLANS +}; +static struct ng_parse_type ng_vlanrotate_stat_hist = { + &ng_parse_fixedarray_type, + &ng_vlanrotate_stat_hist_info +}; +static const struct ng_parse_struct_field ng_vlanrotate_stat_fields[] = { + {"drops", &ng_parse_uint64_type}, + {"excessive", &ng_parse_uint64_type}, + {"incomplete", &ng_parse_uint64_type}, + {"histogram", &ng_vlanrotate_stat_hist}, + {NULL} +}; +static struct ng_parse_type ng_vlanrotate_stat_type = { + &ng_parse_struct_type, + &ng_vlanrotate_stat_fields +}; + + +/* List of commands and how to convert arguments to/from ASCII */ +static const struct ng_cmdlist ng_vlanrotate_cmdlist[] = { + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_CONF, + "getconf", + NULL, + &ng_vlanrotate_conf_type, + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_SET_CONF, + "setconf", + &ng_vlanrotate_conf_type, + NULL + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_STAT, + "getstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_CLR_STAT, + "clrstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GETCLR_STAT, + "getclrstat", + NULL, + &ng_vlanrotate_stat_type + }, + {0} +}; + +/* Netgraph node type descriptor */ +static struct ng_type typestruct = { + .version = NG_ABI_VERSION, + .name = NG_VLANROTATE_NODE_TYPE, + .constructor = ng_vlanrotate_constructor, + .rcvmsg = ng_vlanrotate_rcvmsg, + .shutdown = ng_vlanrotate_shutdown, + .newhook = ng_vlanrotate_newhook, + .rcvdata = ng_vlanrotate_rcvdata, + .disconnect = ng_vlanrotate_disconnect, + .cmdlist = ng_vlanrotate_cmdlist, +}; +NETGRAPH_INIT(vlanrotate, &typestruct); + +struct ng_vlanrotate_kernel_stats { + counter_u64_t drops, excessive, incomplete; + counter_u64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Information we store for each node */ +struct vlanrotate { + hook_p original_hook; + hook_p ordered_hook; + hook_p excessive_hook; + hook_p incomplete_hook; + struct ng_vlanrotate_conf conf; + struct ng_vlanrotate_kernel_stats stats; +}; +typedef struct vlanrotate *vlanrotate_p; + +/* + * Set up the private data structure. + */ +static int +ng_vlanrotate_constructor(node_p node) +{ + int i; + + vlanrotate_p vrp = malloc(sizeof(*vrp), M_NETGRAPH, M_WAITOK | M_ZERO); + + vrp->conf.max = NG_VLANROTATE_MAX_VLANS; + + vrp->stats.drops = counter_u64_alloc(M_WAITOK); + vrp->stats.excessive = counter_u64_alloc(M_WAITOK); + vrp->stats.incomplete = counter_u64_alloc(M_WAITOK); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + vrp->stats.histogram[i] = counter_u64_alloc(M_WAITOK); + + NG_NODE_SET_PRIVATE(node, vrp); + return (0); +} + +/* + * Give our ok for a hook to be added. + */ +static int +ng_vlanrotate_newhook(node_p node, hook_p hook, const char *name) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + hook_p *dst = NULL; + + if (strcmp(name, NG_VLANROTATE_HOOK_ORDERED) == 0) { + dst = &vrp->ordered_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_ORIGINAL) == 0) { + dst = &vrp->original_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_EXCESSIVE) == 0) { + dst = &vrp->excessive_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_INCOMPLETE) == 0) { + dst = &vrp->incomplete_hook; + } else + return (EINVAL); /* not a hook we know about */ + + if (*dst != NULL) + return (EADDRINUSE); /* don't override */ + + *dst = hook; + return (0); +} + +/* + * Get a netgraph control message. + * A response is not required. + */ +static int +ng_vlanrotate_rcvmsg(node_p node, item_p item, hook_p lasthook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + struct ng_mesg *resp = NULL; + struct ng_mesg *msg; + struct ng_vlanrotate_conf *pcf; + int error = 0; + + NGI_GET_MSG(item, msg); + /* Deal with message according to cookie and command */ + switch (msg->header.typecookie) { + case NGM_VLANROTATE_COOKIE: + switch (msg->header.cmd) { + case NGM_VLANROTATE_GET_CONF: + NG_MKRESPONSE(resp, msg, sizeof(vrp->conf), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + *((struct ng_vlanrotate_conf *)resp->data) = vrp->conf; + break; + case NGM_VLANROTATE_SET_CONF: + if (msg->header.arglen != sizeof(*pcf)) { + error = EINVAL; + break; + } + + pcf = (struct ng_vlanrotate_conf *)msg->data; + + if (pcf->max == 0) /* keep current value */ + pcf->max = vrp->conf.max; + + if ((pcf->max > NG_VLANROTATE_MAX_VLANS) || + (pcf->min > pcf->max) || + (abs(pcf->rot) >= pcf->max)) { + error = EINVAL; + break; + } + + vrp->conf = *pcf; + break; + case NGM_VLANROTATE_GET_STAT: + case NGM_VLANROTATE_GETCLR_STAT: + { + struct ng_vlanrotate_stat *p; + int i; + + NG_MKRESPONSE(resp, msg, sizeof(*p), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + p = (struct ng_vlanrotate_stat *)resp->data; + p->drops = counter_u64_fetch(vrp->stats.drops); + p->excessive = counter_u64_fetch(vrp->stats.excessive); + p->incomplete = counter_u64_fetch(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + p->histogram[i] = counter_u64_fetch(vrp->stats.histogram[i]); + if (msg->header.cmd != NGM_VLANROTATE_GETCLR_STAT) + break; + } + case NGM_VLANROTATE_CLR_STAT: + { + int i; + + counter_u64_zero(vrp->stats.drops); + counter_u64_zero(vrp->stats.excessive); + counter_u64_zero(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_zero(vrp->stats.histogram[i]); + break; + } + default: + error = EINVAL; /* unknown command */ + break; + } + break; + default: + error = EINVAL; /* unknown cookie type */ + break; + } + + /* Take care of synchronous response, if any */ + NG_RESPOND_MSG(error, node, item, resp); + /* Free the message and return */ + NG_FREE_MSG(msg); + return (error); +} + +/* + * Receive data, and do rotate the vlans as desired. + * + * Rotating is quite complicated if the rotation offset and the number + * of vlans are not relativly prime. In this case multiple slices need + * to be rotated separately. + * + * Rotation can be additive or subtractive. Some examples: + * 01234 5 vlans given + * ----- + * 34012 +2 rotate + * 12340 +4 rotate + * 12340 -1 rotate + * + * First some helper functions ... + */ + +struct ether_vlan_stack_entry { + uint16_t proto; + uint16_t tag; +} __packed; + +struct ether_vlan_stack_header { + uint8_t dst[ETHER_ADDR_LEN]; + uint8_t src[ETHER_ADDR_LEN]; + struct ether_vlan_stack_entry vlan_stack[1]; +} __packed; + +static int +ng_vlanrotate_gcd(int a, int b) +{ + if (b == 0) + return a; + else + return ng_vlanrotate_gcd(b, a % b); +} + +static void +ng_vlanrotate_rotate(struct ether_vlan_stack_entry arr[], int d, int n) +{ + int i, j, k; + struct ether_vlan_stack_entry temp; + + /* for each commensurable slice */ + for (i = ng_vlanrotate_gcd(d, n); i-- > 0;) { + /* rotate left aka downwards */ + temp = arr[i]; + j = i; + + while (1) { + k = j + d; + if (k >= n) + k = k - n; + if (k == i) + break; + arr[j] = arr[k]; + j = k; + } + + arr[j] = temp; + } +} + +static int +ng_vlanrotate_rcvdata(hook_p hook, item_p item) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + struct ether_vlan_stack_header *evsh; + struct mbuf *m = NULL; + hook_p dst_hook; + int8_t rotate; + int8_t vlans = 0; + int error = ENOSYS; + + NGI_GET_M(item, m); + + if (hook == vrp->ordered_hook) { + rotate = +vrp->conf.rot; + dst_hook = vrp->original_hook; + } else if (hook == vrp->original_hook) { + rotate = -vrp->conf.rot; + dst_hook = vrp->ordered_hook; + } else { + dst_hook = vrp->original_hook; + goto send; /* everything else goes out unmodified */ + } + + if (dst_hook == NULL) { + error = ENETDOWN; + goto fail; + } + + /* count the vlans */ + for (vlans = 0; vlans <= NG_VLANROTATE_MAX_VLANS; vlans++) { + size_t expected_len = sizeof(struct ether_vlan_stack_header) + + vlans * sizeof(struct ether_vlan_stack_entry); + + if (m->m_len < expected_len) { + m = m_pullup(m, expected_len); + if (m == NULL) { + error = EINVAL; + goto fail; + } + } + + evsh = mtod(m, struct ether_vlan_stack_header *); + switch (ntohs(evsh->vlan_stack[vlans].proto)) { + case ETHERTYPE_VLAN: + case ETHERTYPE_QINQ: + case ETHERTYPE_8021Q9100: + case ETHERTYPE_8021Q9200: + case ETHERTYPE_8021Q9300: + break; + default: + goto out; + } + } +out: + if ((vlans > vrp->conf.max) || (vlans >= NG_VLANROTATE_MAX_VLANS)) { + counter_u64_add(vrp->stats.excessive, 1); + dst_hook = vrp->excessive_hook; + goto send; + } + + if ((vlans < vrp->conf.min) || (vlans <= abs(rotate))) { + counter_u64_add(vrp->stats.incomplete, 1); + dst_hook = vrp->incomplete_hook; + goto send; + } + counter_u64_add(vrp->stats.histogram[vlans], 1); + + /* rotating upwards always (using modular arithmetics) */ + if (rotate == 0) { + /* nothing to do */ + } else if (rotate > 0) { + ng_vlanrotate_rotate(evsh->vlan_stack, rotate, vlans); + } else { + ng_vlanrotate_rotate(evsh->vlan_stack, vlans + rotate, vlans); + } + +send: + if (dst_hook == NULL) + goto fail; + NG_FWD_NEW_DATA(error, item, dst_hook, m); + return 0; + +fail: + counter_u64_add(vrp->stats.drops, 1); + if (m != NULL) + m_freem(m); + NG_FREE_ITEM(item); + return (error); +} + +/* + * Do local shutdown processing.. + * All our links and the name have already been removed. + */ +static int +ng_vlanrotate_shutdown(node_p node) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + int i; + + NG_NODE_SET_PRIVATE(node, NULL); + + counter_u64_free(vrp->stats.drops); + counter_u64_free(vrp->stats.excessive); + counter_u64_free(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_free(vrp->stats.histogram[i]); + + free(vrp, M_NETGRAPH); + + NG_NODE_UNREF(node); + return (0); +} + +/* + * Hook disconnection + * For this type, removal of the last link destroys the node + */ +static int +ng_vlanrotate_disconnect(hook_p hook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + + if (vrp->original_hook == hook) + vrp->original_hook = NULL; + if (vrp->ordered_hook == hook) + vrp->ordered_hook = NULL; + if (vrp->excessive_hook == hook) + vrp->excessive_hook = NULL; + if (vrp->incomplete_hook == hook) + vrp->incomplete_hook = NULL; + + /* during shutdown the node is invalid, don't shutdown twice */ + if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) && + (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) + ng_rmnode_self(NG_HOOK_NODE(hook)); + return (0); +} diff --git a/sys/netgraph/ng_vlan_rotate.h b/sys/netgraph/ng_vlan_rotate.h new file mode 100644 index 000000000000..ef6dfd6b506a --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.h @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_NG_VLAN_ROTATE_H_ +#define _NETGRAPH_NG_VLAN_ROTATE_H_ + +#define NG_VLANROTATE_NODE_TYPE "vlan_rotate" +#define NGM_VLANROTATE_COOKIE 1568378766 + +/* Hook names */ +#define NG_VLANROTATE_HOOK_ORDERED "ordered" +#define NG_VLANROTATE_HOOK_ORIGINAL "original" +#define NG_VLANROTATE_HOOK_EXCESSIVE "excessive" +#define NG_VLANROTATE_HOOK_INCOMPLETE "incomplete" + +/* Limits */ +#define NG_VLANROTATE_MAX_VLANS 10 + +/* Datastructures for netgraph commands */ +struct ng_vlanrotate_conf { + int8_t rot; + uint8_t min, max; +}; + +struct ng_vlanrotate_stat { + uint64_t drops, excessive, incomplete; + uint64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Netgraph commands understood by this node type */ +enum { + NGM_VLANROTATE_GET_CONF = 1, + NGM_VLANROTATE_SET_CONF, + NGM_VLANROTATE_GET_STAT, + NGM_VLANROTATE_CLR_STAT, + NGM_VLANROTATE_GETCLR_STAT +}; + +#endif /* _NETGRAPH_NG_VLAN_ROTATE_H_ */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 08:15: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 CD52055AD79; Thu, 25 Feb 2021 08:15: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 4DmQZS5Rvgz3rRR; Thu, 25 Feb 2021 08:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ADD3B14432; Thu, 25 Feb 2021 08:15:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11P8FCeX074617; Thu, 25 Feb 2021 08:15:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P8FC2H074616; Thu, 25 Feb 2021 08:15:12 GMT (envelope-from git) Date: Thu, 25 Feb 2021 08:15:12 GMT Message-Id: <202102250815.11P8FC2H074616@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: 08f47db5d580 - stable/12 - netgraph/ng_bridge: Introduce "uplink" ports without MAC learning 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: 08f47db5d580e6c7bf1ed91b7488e4d529502731 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, 25 Feb 2021 08:15:12 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=08f47db5d580e6c7bf1ed91b7488e4d529502731 commit 08f47db5d580e6c7bf1ed91b7488e4d529502731 Author: Lutz Donnerhacke AuthorDate: 2021-02-06 10:08:24 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 08:10:30 +0000 netgraph/ng_bridge: Introduce "uplink" ports without MAC learning The ng_bridge(4) node is designed to work in moderately small environments. Connecting such a node to a larger network rapidly fills the MAC table for no reason. It even become complicated to obtain data from the gettable message, because the result is too large to transmit. This patch introduces, two new functionality bits on the hooks: - Allow or disallow MAC address learning for incoming patckets. - Allow or disallow sending unknown MACs through this hook. Uplinks are characterized by denied learning while sending out unknowns. Normal links are charaterized by allowed learning and sending out unknowns. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D23963 (cherry picked from commit f961caf2184c94d6f59c8d522207156b3533d977) --- share/man/man4/ng_bridge.4 | 30 +++++++++++++-- sys/netgraph/ng_bridge.c | 95 +++++++++++++++++++++++++++++----------------- sys/netgraph/ng_bridge.h | 2 + 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index 85c2d8871c7c..b5937375e87a 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2019 +.Dd February 6, 2021 .Dt NG_BRIDGE 4 .Os .Sh NAME @@ -92,6 +92,23 @@ To connect the host machine to a bridged network, simply connect the hook of an .Xr ng_ether 4 node to the bridge node. +.Pp +Instead of naming a hook +.Dv linkX +the hook might be also named +.Dv uplinkX . +The node does not learn MAC addresses on uplink hooks, which keeps +the internal address table small. +This way it is desirable to connect the +.Dv lower +hook of an +.Xr ng_ether 4 +node to an +.Dv uplink +hook of the bridge, and ignore the complexity of the outside world. +Frames with unknown MACs are always sent out to +.Dv uplink +hooks, so no functionality is lost. .Sh CONTROL MESSAGES This node type supports the generic control messages, plus the following: @@ -141,8 +158,9 @@ The node configuration is not changed. This command takes a four byte link number as an argument and returns a .Dv "struct ng_bridge_link_stats" -containing statistics for the corresponding link, which must be -currently connected: +containing statistics for the corresponding +.Dv link , +which must be currently connected: .Bd -literal -offset 0n /* Statistics structure (one for each link) */ struct ng_bridge_link_stats { @@ -162,6 +180,12 @@ struct ng_bridge_link_stats { uint64_t memoryFailures; /* times couldn't get mem or mbuf */ }; .Ed +.Pp +Negative numbers refer to the +.Dv uplink +hooks. +So querying for -7 will get the statistics for hook +.Dv uplink7 . .It Dv NGM_BRIDGE_CLR_STATS Pq Ic clrstats This command takes a four byte link number as an argument and clears the statistics for that link. diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index e2e533be2c1e..ac1a0f61a89f 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -91,6 +91,8 @@ static MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", struct ng_bridge_link { hook_p hook; /* netgraph hook */ u_int16_t loopCount; /* loop ignore timer */ + unsigned int learnMac : 1, /* autolearn macs */ + sendUnknown : 1;/* send unknown macs out */ struct ng_bridge_link_stats stats; /* link stats */ }; @@ -334,38 +336,49 @@ static int ng_bridge_newhook(node_p node, hook_p hook, const char *name) { const priv_p priv = NG_NODE_PRIVATE(node); + char linkName[NG_HOOKSIZ]; + u_int32_t linkNum; + link_p link; + const char *prefix = NG_BRIDGE_HOOK_LINK_PREFIX; + bool isUplink; /* Check for a link hook */ - if (strlen(name) > strlen(NG_BRIDGE_HOOK_LINK_PREFIX)) { - char linkName[NG_HOOKSIZ]; - u_int32_t linkNum; - link_p link; - - /* primitive parsing */ - linkNum = strtoul(name + strlen(NG_BRIDGE_HOOK_LINK_PREFIX), - NULL, 10); - /* validation by comparing against the reconstucted name */ - snprintf(linkName, sizeof(linkName), - "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, - linkNum); - if (strcmp(linkName, name) != 0) - return (EINVAL); - - if(NG_PEER_NODE(hook) == node) - return (ELOOP); - - link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, - M_WAITOK|M_ZERO); - if (link == NULL) - return (ENOMEM); - link->hook = hook; - NG_HOOK_SET_PRIVATE(hook, link); - priv->numLinks++; - return (0); + if (strlen(name) <= strlen(prefix)) + return (EINVAL); /* Unknown hook name */ + + isUplink = (name[0] == 'u'); + if (isUplink) + prefix = NG_BRIDGE_HOOK_UPLINK_PREFIX; + + /* primitive parsing */ + linkNum = strtoul(name + strlen(prefix), NULL, 10); + /* validation by comparing against the reconstucted name */ + snprintf(linkName, sizeof(linkName), "%s%u", prefix, linkNum); + if (strcmp(linkName, name) != 0) + return (EINVAL); + + if (linkNum == 0 && isUplink) + return (EINVAL); + + if(NG_PEER_NODE(hook) == node) + return (ELOOP); + + link = malloc(sizeof(*link), M_NETGRAPH_BRIDGE, M_ZERO); + if (link == NULL) + return (ENOMEM); + + link->hook = hook; + if (isUplink) { + link->learnMac = 0; + link->sendUnknown = 1; + } else { + link->learnMac = 1; + link->sendUnknown = 1; } - /* Unknown hook name */ - return (EINVAL); + NG_HOOK_SET_PRIVATE(hook, link); + priv->numLinks++; + return (0); } /* @@ -439,6 +452,11 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) i = 0; for (bucket = 0; bucket < priv->numBuckets; bucket++) { SLIST_FOREACH(hent, &priv->tab[bucket], next) { + const char *name = NG_HOOK_NAME(hent->host.link->hook); + const char *prefix = name[0] == 'u' ? + NG_BRIDGE_HOOK_UPLINK_PREFIX : + NG_BRIDGE_HOOK_LINK_PREFIX; + memcpy(ary->hosts[i].addr, hent->host.addr, sizeof(ary->hosts[i].addr)); @@ -446,9 +464,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) ary->hosts[i].staleness = hent->host.staleness; ary->hosts[i].linkNum = strtol( - NG_HOOK_NAME(hent->host.link->hook) + - strlen(NG_BRIDGE_HOOK_LINK_PREFIX), - NULL, 10); + name + strlen(prefix), NULL, 10); i++; } } @@ -507,15 +523,20 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) hook_p hook; link_p link; char linkName[NG_HOOKSIZ]; + int linkNum; /* Get link number */ if (msg->header.arglen != sizeof(u_int32_t)) { error = EINVAL; break; } - snprintf(linkName, sizeof(linkName), - "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, - *((u_int32_t *)msg->data)); + linkNum = *((int32_t *)msg->data); + if (linkNum < 0) + snprintf(linkName, sizeof(linkName), + "%s%u", NG_BRIDGE_HOOK_UPLINK_PREFIX, -linkNum); + else + snprintf(linkName, sizeof(linkName), + "%s%u", NG_BRIDGE_HOOK_LINK_PREFIX, linkNum); if ((hook = ng_findhook(node, linkName)) == NULL) { error = ENOTCONN; @@ -610,6 +631,10 @@ ng_bridge_send_ctx(hook_p dst, void *arg) return (1); } + /* Skip sending unknowns to undesired links */ + if (!ctx->manycast && !destLink->sendUnknown) + return (1); + if (ctx->foundFirst == NULL) { /* * This is the first usable link we have found. @@ -755,7 +780,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) host->link = ctx.incoming; host->age = 0; } - } else { + } else if (ctx.incoming->learnMac) { if (!ng_bridge_put(priv, eh->ether_shost, ctx.incoming)) { ctx.incoming->stats.memoryFailures++; NG_FREE_ITEM(item); diff --git a/sys/netgraph/ng_bridge.h b/sys/netgraph/ng_bridge.h index fa4736370e92..b34bc0f5f55e 100644 --- a/sys/netgraph/ng_bridge.h +++ b/sys/netgraph/ng_bridge.h @@ -64,6 +64,8 @@ /* Hook names */ #define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */ #define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */ +#define NG_BRIDGE_HOOK_UPLINK_PREFIX "uplink" /* append decimal integer */ +#define NG_BRIDGE_HOOK_UPLINK_FMT "uplink%d" /* for use with printf(3) */ /* Node configuration structure */ struct ng_bridge_config { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 08:15: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 ED10B55B0A7; Thu, 25 Feb 2021 08:15:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmQZT6Lz1z3rRS; Thu, 25 Feb 2021 08:15: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 CCCAB14338; Thu, 25 Feb 2021 08:15: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 11P8FDOT074639; Thu, 25 Feb 2021 08:15:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P8FDva074638; Thu, 25 Feb 2021 08:15:13 GMT (envelope-from git) Date: Thu, 25 Feb 2021 08:15:13 GMT Message-Id: <202102250815.11P8FDva074638@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: d148e95cdfb7 - stable/12 - netgraph/ng_bridge: Derive forwarding mode from first attached hook 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: d148e95cdfb78cf3992d71b076a776503979da62 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, 25 Feb 2021 08:15:14 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d148e95cdfb78cf3992d71b076a776503979da62 commit d148e95cdfb78cf3992d71b076a776503979da62 Author: Lutz Donnerhacke AuthorDate: 2021-02-06 10:25:04 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 08:11:45 +0000 netgraph/ng_bridge: Derive forwarding mode from first attached hook Handling of unknown MACs on an bridge with incomplete learning capabilites (aka uplink ports) can be defined in different ways. The classical approach is to broadcast unicast frames send to an unknown MAC, because the unknown devices can be everywhere. This mode is default for ng_bridge(4). In the case of dedicated uplink ports, which prohibit learning of MAC addresses in order to save memory and CPU cycles, the broadcast approach is dangerous. All traffic to the uplink port is broadcasted to every downlink port, too. In this case, it's better to restrict the distribution of frames to unknown MAC to the uplink ports only. In order to keep the chance small and the handling as natural as possible, the first attached link is used to determine the behaviour of the bridge: If it is an "uplink" port, then the bridge switch from classical mode to restricted mode. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D28487 (cherry picked from commit c869d905baa4e329dfd6793e7487b5985248ddb6) --- share/man/man4/ng_bridge.4 | 16 ++++++++++++++++ sys/netgraph/ng_bridge.c | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/share/man/man4/ng_bridge.4 b/share/man/man4/ng_bridge.4 index b5937375e87a..1451773711e9 100644 --- a/share/man/man4/ng_bridge.4 +++ b/share/man/man4/ng_bridge.4 @@ -109,6 +109,22 @@ hook of the bridge, and ignore the complexity of the outside world. Frames with unknown MACs are always sent out to .Dv uplink hooks, so no functionality is lost. +.Pp +Frames with unknown destination MAC addresses are replicated to any +available hook, unless the first connected hook is an +.Ar uplink +hook. +In this case the node assumes, that all unknown MAC addresses are +located soley on the +.Ar uplink +hooks and only those hooks will be used to send out frames with +unknown destination MACs. +If the first connected hook is an +.Ar link +hook, the node will replicate such frames to all types of hooks, +even if +.Ar uplink +hooks are connected later. .Sh CONTROL MESSAGES This node type supports the generic control messages, plus the following: diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index ac1a0f61a89f..a6d78690f371 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -105,7 +105,8 @@ struct ng_bridge_private { u_int numBuckets; /* num buckets in table */ u_int hashMask; /* numBuckets - 1 */ int numLinks; /* num connected links */ - int persistent; /* can exist w/o hooks */ + unsigned int persistent : 1, /* can exist w/o hooks */ + sendUnknown : 1;/* links receive unknowns by default */ struct callout timer; /* one second periodic timer */ }; typedef struct ng_bridge_private *priv_p; @@ -309,6 +310,7 @@ ng_bridge_constructor(node_p node) priv->conf.loopTimeout = DEFAULT_LOOP_TIMEOUT; priv->conf.maxStaleness = DEFAULT_MAX_STALENESS; priv->conf.minStableAge = DEFAULT_MIN_STABLE_AGE; + priv->sendUnknown = 1; /* classic bridge */ /* * This node has all kinds of stuff that could be screwed by SMP. @@ -371,9 +373,11 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if (isUplink) { link->learnMac = 0; link->sendUnknown = 1; + if (priv->numLinks == 0) /* if the first link is an uplink */ + priv->sendUnknown = 0; /* switch to restrictive mode */ } else { link->learnMac = 1; - link->sendUnknown = 1; + link->sendUnknown = priv->sendUnknown; } NG_HOOK_SET_PRIVATE(hook, link); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 08:15: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 90A2855AF19; Thu, 25 Feb 2021 08:15: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 4DmQZW06Lrz3rTw; Thu, 25 Feb 2021 08:15:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E71BB13D68; Thu, 25 Feb 2021 08:15: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 11P8FEqr074658; Thu, 25 Feb 2021 08:15:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P8FEce074657; Thu, 25 Feb 2021 08:15:14 GMT (envelope-from git) Date: Thu, 25 Feb 2021 08:15:14 GMT Message-Id: <202102250815.11P8FEce074657@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: bfe0d8ca0b88 - stable/12 - netgraph/ng_bridge: switch stats to counter framework 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: bfe0d8ca0b88ec72b35ca2b57c5d4bc14063fccf 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, 25 Feb 2021 08:15:15 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=bfe0d8ca0b88ec72b35ca2b57c5d4bc14063fccf commit bfe0d8ca0b88ec72b35ca2b57c5d4bc14063fccf Author: Lutz Donnerhacke AuthorDate: 2021-01-13 06:16:34 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 08:12:30 +0000 netgraph/ng_bridge: switch stats to counter framework This is the first patch of a series of necessary steps to make ng_bridge(4) multithreaded. Reviewed by: melifaro (network), afedorov Differential Revision: https://reviews.freebsd.org/D28125 (cherry picked from commit 66c72859f66dc6c852234589f3508ce5d36d0336) --- sys/netgraph/ng_bridge.c | 133 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 25 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index a6d78690f371..ab4e50f51277 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -65,6 +65,8 @@ #include #include #include +#include +#include #include #include @@ -87,13 +89,31 @@ static MALLOC_DEFINE(M_NETGRAPH_BRIDGE, "netgraph_bridge", #define M_NETGRAPH_BRIDGE M_NETGRAPH #endif +/* Counter based stats */ +struct ng_bridge_link_kernel_stats { + counter_u64_t recvOctets; /* total octets rec'd on link */ + counter_u64_t recvPackets; /* total pkts rec'd on link */ + counter_u64_t recvMulticasts; /* multicast pkts rec'd on link */ + counter_u64_t recvBroadcasts; /* broadcast pkts rec'd on link */ + counter_u64_t recvUnknown; /* pkts rec'd with unknown dest addr */ + counter_u64_t recvRunts; /* pkts rec'd less than 14 bytes */ + counter_u64_t recvInvalid; /* pkts rec'd with bogus source addr */ + counter_u64_t xmitOctets; /* total octets xmit'd on link */ + counter_u64_t xmitPackets; /* total pkts xmit'd on link */ + counter_u64_t xmitMulticasts; /* multicast pkts xmit'd on link */ + counter_u64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */ + counter_u64_t loopDrops; /* pkts dropped due to loopback */ + counter_u64_t loopDetects; /* number of loop detections */ + counter_u64_t memoryFailures; /* times couldn't get mem or mbuf */ +}; + /* Per-link private data */ struct ng_bridge_link { hook_p hook; /* netgraph hook */ u_int16_t loopCount; /* loop ignore timer */ unsigned int learnMac : 1, /* autolearn macs */ sendUnknown : 1;/* send unknown macs out */ - struct ng_bridge_link_stats stats; /* link stats */ + struct ng_bridge_link_kernel_stats stats; /* link stats */ }; /* Per-node private data */ @@ -369,6 +389,21 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) if (link == NULL) return (ENOMEM); + link->stats.recvOctets = counter_u64_alloc(M_WAITOK); + link->stats.recvPackets = counter_u64_alloc(M_WAITOK); + link->stats.recvMulticasts = counter_u64_alloc(M_WAITOK); + link->stats.recvBroadcasts = counter_u64_alloc(M_WAITOK); + link->stats.recvUnknown = counter_u64_alloc(M_WAITOK); + link->stats.recvRunts = counter_u64_alloc(M_WAITOK); + link->stats.recvInvalid = counter_u64_alloc(M_WAITOK); + link->stats.xmitOctets = counter_u64_alloc(M_WAITOK); + link->stats.xmitPackets = counter_u64_alloc(M_WAITOK); + link->stats.xmitMulticasts = counter_u64_alloc(M_WAITOK); + link->stats.xmitBroadcasts = counter_u64_alloc(M_WAITOK); + link->stats.loopDrops = counter_u64_alloc(M_WAITOK); + link->stats.loopDetects = counter_u64_alloc(M_WAITOK); + link->stats.memoryFailures = counter_u64_alloc(M_WAITOK); + link->hook = hook; if (isUplink) { link->learnMac = 0; @@ -388,14 +423,31 @@ ng_bridge_newhook(node_p node, hook_p hook, const char *name) /* * Receive a control message */ +static void ng_bridge_clear_link_stats(struct ng_bridge_link_kernel_stats * p) +{ + counter_u64_zero(p->recvOctets); + counter_u64_zero(p->recvPackets); + counter_u64_zero(p->recvMulticasts); + counter_u64_zero(p->recvBroadcasts); + counter_u64_zero(p->recvUnknown); + counter_u64_zero(p->recvRunts); + counter_u64_zero(p->recvInvalid); + counter_u64_zero(p->xmitOctets); + counter_u64_zero(p->xmitPackets); + counter_u64_zero(p->xmitMulticasts); + counter_u64_zero(p->xmitBroadcasts); + counter_u64_zero(p->loopDrops); + counter_u64_zero(p->loopDetects); + counter_u64_zero(p->memoryFailures); +}; + static int ng_bridge_reset_link(hook_p hook, void *arg __unused) { link_p priv = NG_HOOK_PRIVATE(hook); priv->loopCount = 0; - bzero(&priv->stats, sizeof(priv->stats)); - + ng_bridge_clear_link_stats(&priv->stats); return (1); } @@ -550,17 +602,34 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) /* Get/clear stats */ if (msg->header.cmd != NGM_BRIDGE_CLR_STATS) { + struct ng_bridge_link_stats *rs; + NG_MKRESPONSE(resp, msg, sizeof(link->stats), M_NOWAIT); if (resp == NULL) { error = ENOMEM; break; } - bcopy(&link->stats, - resp->data, sizeof(link->stats)); + rs = (struct ng_bridge_link_stats *)resp->data; +#define FETCH(x) rs->x = counter_u64_fetch(link->stats.x) + FETCH(recvOctets); + FETCH(recvPackets); + FETCH(recvMulticasts); + FETCH(recvBroadcasts); + FETCH(recvUnknown); + FETCH(recvRunts); + FETCH(recvInvalid); + FETCH(xmitOctets); + FETCH(xmitPackets); + FETCH(xmitMulticasts); + FETCH(xmitBroadcasts); + FETCH(loopDrops); + FETCH(loopDetects); + FETCH(memoryFailures); +#undef FETCH } if (msg->header.cmd != NGM_BRIDGE_GET_STATS) - bzero(&link->stats, sizeof(link->stats)); + ng_bridge_clear_link_stats(&link->stats); break; } case NGM_BRIDGE_GET_TABLE: @@ -655,23 +724,23 @@ ng_bridge_send_ctx(hook_p dst, void *arg) */ m2 = m_dup(ctx->m, M_NOWAIT); /* XXX m_copypacket() */ if (m2 == NULL) { - ctx->incoming->stats.memoryFailures++; + counter_u64_add(ctx->incoming->stats.memoryFailures, 1); ctx->error = ENOBUFS; return (0); /* abort loop */ } /* Update stats */ - destLink->stats.xmitPackets++; - destLink->stats.xmitOctets += m2->m_pkthdr.len; + counter_u64_add(destLink->stats.xmitPackets, 1); + counter_u64_add(destLink->stats.xmitOctets, m2->m_pkthdr.len); switch (ctx->manycast) { default: /* unknown unicast */ break; case 1: /* multicast */ - destLink->stats.xmitMulticasts++; + counter_u64_add(destLink->stats.xmitMulticasts, 1); break; case 2: /* broadcast */ - destLink->stats.xmitBroadcasts++; + counter_u64_add(destLink->stats.xmitBroadcasts, 1); break; } @@ -697,19 +766,19 @@ ng_bridge_rcvdata(hook_p hook, item_p item) ctx.incoming = NG_HOOK_PRIVATE(hook); /* Sanity check packet and pull up header */ if (ctx.m->m_pkthdr.len < ETHER_HDR_LEN) { - ctx.incoming->stats.recvRunts++; + counter_u64_add(ctx.incoming->stats.recvRunts, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (EINVAL); } if (ctx.m->m_len < ETHER_HDR_LEN && !(ctx.m = m_pullup(ctx.m, ETHER_HDR_LEN))) { - ctx.incoming->stats.memoryFailures++; + counter_u64_add(ctx.incoming->stats.memoryFailures, 1); NG_FREE_ITEM(item); return (ENOBUFS); } eh = mtod(ctx.m, struct ether_header *); if ((eh->ether_shost[0] & 1) != 0) { - ctx.incoming->stats.recvInvalid++; + counter_u64_add(ctx.incoming->stats.recvInvalid, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (EINVAL); @@ -717,21 +786,21 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Is link disabled due to a loopback condition? */ if (ctx.incoming->loopCount != 0) { - ctx.incoming->stats.loopDrops++; + counter_u64_add(ctx.incoming->stats.loopDrops, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ELOOP); /* XXX is this an appropriate error? */ } /* Update stats */ - ctx.incoming->stats.recvPackets++; - ctx.incoming->stats.recvOctets += ctx.m->m_pkthdr.len; + counter_u64_add(ctx.incoming->stats.recvPackets, 1); + counter_u64_add(ctx.incoming->stats.recvOctets, ctx.m->m_pkthdr.len); if ((ctx.manycast = (eh->ether_dhost[0] & 1)) != 0) { if (ETHER_EQUAL(eh->ether_dhost, ng_bridge_bcast_addr)) { - ctx.incoming->stats.recvBroadcasts++; + counter_u64_add(ctx.incoming->stats.recvBroadcasts, 1); ctx.manycast = 2; } else - ctx.incoming->stats.recvMulticasts++; + counter_u64_add(ctx.incoming->stats.recvMulticasts, 1); } /* Look up packet's source Ethernet address in hashtable */ @@ -768,13 +837,13 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Mark link as linka non grata */ ctx.incoming->loopCount = priv->conf.loopTimeout; - ctx.incoming->stats.loopDetects++; + counter_u64_add(ctx.incoming->stats.loopDetects, 1); /* Forget all hosts on this link */ ng_bridge_remove_hosts(priv, ctx.incoming); /* Drop packet */ - ctx.incoming->stats.loopDrops++; + counter_u64_add(ctx.incoming->stats.loopDrops, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ELOOP); /* XXX appropriate? */ @@ -786,7 +855,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } } else if (ctx.incoming->learnMac) { if (!ng_bridge_put(priv, eh->ether_shost, ctx.incoming)) { - ctx.incoming->stats.memoryFailures++; + counter_u64_add(ctx.incoming->stats.memoryFailures, 1); NG_FREE_ITEM(item); NG_FREE_M(ctx.m); return (ENOMEM); @@ -818,14 +887,14 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } /* Deliver packet out the destination link */ - destLink->stats.xmitPackets++; - destLink->stats.xmitOctets += ctx.m->m_pkthdr.len; + counter_u64_add(destLink->stats.xmitPackets, 1); + counter_u64_add(destLink->stats.xmitOctets, ctx.m->m_pkthdr.len); NG_FWD_NEW_DATA(ctx.error, item, destLink->hook, ctx.m); return (ctx.error); } /* Destination host is not known */ - ctx.incoming->stats.recvUnknown++; + counter_u64_add(ctx.incoming->stats.recvUnknown, 1); } /* Distribute unknown, multicast, broadcast pkts to all other links */ @@ -885,6 +954,20 @@ ng_bridge_disconnect(hook_p hook) ng_bridge_remove_hosts(priv, link); /* Free associated link information */ + counter_u64_free(link->stats.recvOctets); + counter_u64_free(link->stats.recvPackets); + counter_u64_free(link->stats.recvMulticasts); + counter_u64_free(link->stats.recvBroadcasts); + counter_u64_free(link->stats.recvUnknown); + counter_u64_free(link->stats.recvRunts); + counter_u64_free(link->stats.recvInvalid); + counter_u64_free(link->stats.xmitOctets); + counter_u64_free(link->stats.xmitPackets); + counter_u64_free(link->stats.xmitMulticasts); + counter_u64_free(link->stats.xmitBroadcasts); + counter_u64_free(link->stats.loopDrops); + counter_u64_free(link->stats.loopDetects); + counter_u64_free(link->stats.memoryFailures); free(link, M_NETGRAPH_BRIDGE); priv->numLinks--; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 08:15: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 E423F55AC7F; Thu, 25 Feb 2021 08:15: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 4DmQZX4Mn6z3rb9; Thu, 25 Feb 2021 08:15: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 19F8314339; Thu, 25 Feb 2021 08:15: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 11P8FGQc074680; Thu, 25 Feb 2021 08:15:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11P8FGpf074679; Thu, 25 Feb 2021 08:15:16 GMT (envelope-from git) Date: Thu, 25 Feb 2021 08:15:16 GMT Message-Id: <202102250815.11P8FGpf074679@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: 3de9c792eebe - stable/12 - netgraph/ng_bridge: Make simple internal functions read-only 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: 3de9c792eebe77ef2cdf1f6aad28cc4df9e8c37d 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, 25 Feb 2021 08:15:18 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=3de9c792eebe77ef2cdf1f6aad28cc4df9e8c37d commit 3de9c792eebe77ef2cdf1f6aad28cc4df9e8c37d Author: Lutz Donnerhacke AuthorDate: 2021-01-13 22:18:55 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 08:13:32 +0000 netgraph/ng_bridge: Make simple internal functions read-only The data path in netgraph is designed to work on an read only state of the whole netgraph network. Currently this is achived by convention, there is no technical enforcment. In the case of NETGRAPH_DEBUG all nodes can be annotated for debugging purposes, so the strict enforcment needs to be lifted for this purpose. This patch is part of a series to make ng_bridge multithreaded, which is done by rewrite the data path to operate on const. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D28141 (cherry picked from commit 6117aa58fa4f5891badf58b13c759976983f4f04) --- sys/netgraph/netgraph.h | 9 ++++++++- sys/netgraph/ng_base.c | 2 +- sys/netgraph/ng_bridge.c | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index c7b0e67902cf..452be7c72f0a 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -88,6 +88,13 @@ struct ng_item ; typedef struct ng_item *item_p; typedef struct ng_node *node_p; typedef struct ng_hook *hook_p; +typedef struct ng_item const *item_cp; +typedef struct ng_hook const *hook_cp; +#ifdef NETGRAPH_DEBUG +typedef struct ng_node *node_cp; /* annotated during debug */ +#else /* NETGRAPH_DEBUG */ +typedef struct ng_node const *node_cp; +#endif /* NETGRAPH_DEBUG */ /* node method definitions */ typedef int ng_constructor_t(node_p node); @@ -1143,7 +1150,7 @@ int ng_make_node_common(struct ng_type *typep, node_p *nodep); int ng_name_node(node_p node, const char *name); node_p ng_name2noderef(node_p node, const char *name); int ng_newtype(struct ng_type *tp); -ng_ID_t ng_node2ID(node_p node); +ng_ID_t ng_node2ID(node_cp node); item_p ng_package_data(struct mbuf *m, int flags); item_p ng_package_msg(struct ng_mesg *msg, int flags); item_p ng_package_msg_self(node_p here, hook_p hook, struct ng_mesg *msg); diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index cc8df1e45aa6..271397f669be 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -835,7 +835,7 @@ ng_ID2noderef(ng_ID_t ID) } ng_ID_t -ng_node2ID(node_p node) +ng_node2ID(node_cp node) { return (node ? NG_NODE_ID(node) : 0); } diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index ab4e50f51277..c2d0f79a6ca5 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -115,6 +115,7 @@ struct ng_bridge_link { sendUnknown : 1;/* send unknown macs out */ struct ng_bridge_link_kernel_stats stats; /* link stats */ }; +typedef struct ng_bridge_link const *link_cp; /* read only access */ /* Per-node private data */ struct ng_bridge_private { @@ -130,6 +131,7 @@ struct ng_bridge_private { struct callout timer; /* one second periodic timer */ }; typedef struct ng_bridge_private *priv_p; +typedef struct ng_bridge_private const *priv_cp; /* read only access */ /* Information about a host, stored in a hash table entry */ struct ng_bridge_hent { @@ -149,12 +151,12 @@ static ng_rcvdata_t ng_bridge_rcvdata; static ng_disconnect_t ng_bridge_disconnect; /* Other internal functions */ -static struct ng_bridge_host *ng_bridge_get(priv_p priv, const u_char *addr); +static struct ng_bridge_host *ng_bridge_get(priv_cp priv, const u_char *addr); static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link); static void ng_bridge_rehash(priv_p priv); static void ng_bridge_remove_hosts(priv_p priv, link_p link); static void ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2); -static const char *ng_bridge_nodename(node_p node); +static const char *ng_bridge_nodename(node_cp node); /* Ethernet broadcast */ static const u_char ng_bridge_bcast_addr[ETHER_ADDR_LEN] = @@ -995,7 +997,7 @@ ng_bridge_disconnect(hook_p hook) * Find a host entry in the table. */ static struct ng_bridge_host * -ng_bridge_get(priv_p priv, const u_char *addr) +ng_bridge_get(priv_cp priv, const u_char *addr) { const int bucket = HASH(addr, priv->hashMask); struct ng_bridge_hent *hent; @@ -1207,7 +1209,7 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2) * Return node's "name", even if it doesn't have one. */ static const char * -ng_bridge_nodename(node_p node) +ng_bridge_nodename(node_cp node) { static char name[NG_NODESIZ]; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:00: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 5E09555D351; Thu, 25 Feb 2021 10:00: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 4DmSvc2C1Tz4STG; Thu, 25 Feb 2021 10:00: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 3E965155E2; Thu, 25 Feb 2021 10:00: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 11PA0CVP010805; Thu, 25 Feb 2021 10:00:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PA0CQf010798; Thu, 25 Feb 2021 10:00:12 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:00:12 GMT Message-Id: <202102251000.11PA0CQf010798@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: 9a972281e7f1 - stable/12 - netgraph/ng_bridge: Merge internal structures 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: 9a972281e7f1fbd3b1ecf9c5d5bad8880227f0ff 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, 25 Feb 2021 10:00:12 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=9a972281e7f1fbd3b1ecf9c5d5bad8880227f0ff commit 9a972281e7f1fbd3b1ecf9c5d5bad8880227f0ff Author: Lutz Donnerhacke AuthorDate: 2021-02-25 09:59:45 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 09:59:45 +0000 netgraph/ng_bridge: Merge internal structures In a earlier version of ng_bridge(4) the exernal visible host entry structure was a strict subset of the internal one. So internal view was a direct annotation of the external structure. This strict inheritance was lost many versions ago. There is no need to encapsulate a part of the internal represntation as a separate structure. This patch is a preparation to make the internal structure read only in the data path in order to make ng_bridge(4) multithreaded. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28545 (cherry picked from commit ccf4cd2e7830394467d5f6cf546ab453f9657b69) --- sys/netgraph/ng_bridge.c | 99 ++++++++++++++++++++++++------------------------ sys/netgraph/ng_bridge.h | 7 ---- 2 files changed, 50 insertions(+), 56 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index c2d0f79a6ca5..0b2b7f5ca6a3 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -134,13 +134,16 @@ typedef struct ng_bridge_private *priv_p; typedef struct ng_bridge_private const *priv_cp; /* read only access */ /* Information about a host, stored in a hash table entry */ -struct ng_bridge_hent { - struct ng_bridge_host host; /* actual host info */ - SLIST_ENTRY(ng_bridge_hent) next; /* next entry in bucket */ +struct ng_bridge_host { + u_char addr[6]; /* ethernet address */ + link_p link; /* link where addr can be found */ + u_int16_t age; /* seconds ago entry was created */ + u_int16_t staleness; /* seconds ago host last heard from */ + SLIST_ENTRY(ng_bridge_host) next; /* next entry in bucket */ }; /* Hash table bucket declaration */ -SLIST_HEAD(ng_bridge_bucket, ng_bridge_hent); +SLIST_HEAD(ng_bridge_bucket, ng_bridge_host); /* Netgraph node methods */ static ng_constructor_t ng_bridge_constructor; @@ -496,7 +499,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) case NGM_BRIDGE_GET_TABLE: { struct ng_bridge_host_tbl_ary *ary; - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; int i, bucket; NG_MKRESPONSE(resp, msg, sizeof(*ary) + @@ -509,18 +512,16 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) ary->numHosts = priv->numHosts; i = 0; for (bucket = 0; bucket < priv->numBuckets; bucket++) { - SLIST_FOREACH(hent, &priv->tab[bucket], next) { - const char *name = NG_HOOK_NAME(hent->host.link->hook); + SLIST_FOREACH(host, &priv->tab[bucket], next) { + const char *name = NG_HOOK_NAME(host->link->hook); const char *prefix = name[0] == 'u' ? NG_BRIDGE_HOOK_UPLINK_PREFIX : NG_BRIDGE_HOOK_LINK_PREFIX; - memcpy(ary->hosts[i].addr, - hent->host.addr, + memcpy(ary->hosts[i].addr, host->addr, sizeof(ary->hosts[i].addr)); - ary->hosts[i].age = hent->host.age; - ary->hosts[i].staleness = - hent->host.staleness; + ary->hosts[i].age = host->age; + ary->hosts[i].staleness = host->staleness; ary->hosts[i].linkNum = strtol( name + strlen(prefix), NULL, 10); i++; @@ -637,7 +638,7 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) case NGM_BRIDGE_GET_TABLE: { struct ng_bridge_host_ary *ary; - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; int i = 0, bucket; NG_MKRESPONSE(resp, msg, sizeof(*ary) @@ -649,14 +650,14 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) ary = (struct ng_bridge_host_ary *)resp->data; ary->numHosts = priv->numHosts; for (bucket = 0; bucket < priv->numBuckets; bucket++) { - SLIST_FOREACH(hent, &priv->tab[bucket], next) { + SLIST_FOREACH(host, &priv->tab[bucket], next) { memcpy(ary->hosts[i].addr, - hent->host.addr, + host->addr, sizeof(ary->hosts[i].addr)); - ary->hosts[i].age = hent->host.age; - ary->hosts[i].staleness = hent->host.staleness; + ary->hosts[i].age = host->age; + ary->hosts[i].staleness = host->staleness; strncpy(ary->hosts[i].hook, - NG_HOOK_NAME(hent->host.link->hook), + NG_HOOK_NAME(host->link->hook), sizeof(ary->hosts[i].hook)); i++; } @@ -1000,11 +1001,11 @@ static struct ng_bridge_host * ng_bridge_get(priv_cp priv, const u_char *addr) { const int bucket = HASH(addr, priv->hashMask); - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; - SLIST_FOREACH(hent, &priv->tab[bucket], next) { - if (ETHER_EQUAL(hent->host.addr, addr)) - return (&hent->host); + SLIST_FOREACH(host, &priv->tab[bucket], next) { + if (ETHER_EQUAL(host->addr, addr)) + return (host); } return (NULL); } @@ -1018,27 +1019,27 @@ static int ng_bridge_put(priv_p priv, const u_char *addr, link_p link) { const int bucket = HASH(addr, priv->hashMask); - struct ng_bridge_hent *hent; + struct ng_bridge_host *host; #ifdef INVARIANTS /* Assert that entry does not already exist in hashtable */ - SLIST_FOREACH(hent, &priv->tab[bucket], next) { - KASSERT(!ETHER_EQUAL(hent->host.addr, addr), + SLIST_FOREACH(host, &priv->tab[bucket], next) { + KASSERT(!ETHER_EQUAL(host->addr, addr), ("%s: entry %6D exists in table", __func__, addr, ":")); } #endif /* Allocate and initialize new hashtable entry */ - hent = malloc(sizeof(*hent), M_NETGRAPH_BRIDGE, M_NOWAIT); - if (hent == NULL) + host = malloc(sizeof(*host), M_NETGRAPH_BRIDGE, M_NOWAIT); + if (host == NULL) return (0); - bcopy(addr, hent->host.addr, ETHER_ADDR_LEN); - hent->host.link = link; - hent->host.staleness = 0; - hent->host.age = 0; + bcopy(addr, host->addr, ETHER_ADDR_LEN); + host->link = link; + host->staleness = 0; + host->age = 0; /* Add new element to hash bucket */ - SLIST_INSERT_HEAD(&priv->tab[bucket], hent, next); + SLIST_INSERT_HEAD(&priv->tab[bucket], host, next); priv->numHosts++; /* Resize table if necessary */ @@ -1083,12 +1084,12 @@ ng_bridge_rehash(priv_p priv) struct ng_bridge_bucket *const oldList = &priv->tab[oldBucket]; while (!SLIST_EMPTY(oldList)) { - struct ng_bridge_hent *const hent + struct ng_bridge_host *const host = SLIST_FIRST(oldList); SLIST_REMOVE_HEAD(oldList, next); - newBucket = HASH(hent->host.addr, newMask); - SLIST_INSERT_HEAD(&newTab[newBucket], hent, next); + newBucket = HASH(host->addr, newMask); + SLIST_INSERT_HEAD(&newTab[newBucket], host, next); } } @@ -1120,17 +1121,17 @@ ng_bridge_remove_hosts(priv_p priv, link_p link) int bucket; for (bucket = 0; bucket < priv->numBuckets; bucket++) { - struct ng_bridge_hent **hptr = &SLIST_FIRST(&priv->tab[bucket]); + struct ng_bridge_host **hptr = &SLIST_FIRST(&priv->tab[bucket]); while (*hptr != NULL) { - struct ng_bridge_hent *const hent = *hptr; + struct ng_bridge_host *const host = *hptr; - if (link == NULL || hent->host.link == link) { - *hptr = SLIST_NEXT(hent, next); - free(hent, M_NETGRAPH_BRIDGE); + if (link == NULL || host->link == link) { + *hptr = SLIST_NEXT(host, next); + free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else - hptr = &SLIST_NEXT(hent, next); + hptr = &SLIST_NEXT(host, next); } } } @@ -1171,20 +1172,20 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2) /* Update host time counters and remove stale entries */ for (bucket = 0; bucket < priv->numBuckets; bucket++) { - struct ng_bridge_hent **hptr = &SLIST_FIRST(&priv->tab[bucket]); + struct ng_bridge_host **hptr = &SLIST_FIRST(&priv->tab[bucket]); while (*hptr != NULL) { - struct ng_bridge_hent *const hent = *hptr; + struct ng_bridge_host *const host = *hptr; /* Remove hosts we haven't heard from in a while */ - if (++hent->host.staleness >= priv->conf.maxStaleness) { - *hptr = SLIST_NEXT(hent, next); - free(hent, M_NETGRAPH_BRIDGE); + if (++host->staleness >= priv->conf.maxStaleness) { + *hptr = SLIST_NEXT(host, next); + free(host, M_NETGRAPH_BRIDGE); priv->numHosts--; } else { - if (hent->host.age < 0xffff) - hent->host.age++; - hptr = &SLIST_NEXT(hent, next); + if (host->age < 0xffff) + host->age++; + hptr = &SLIST_NEXT(host, next); counter++; } } diff --git a/sys/netgraph/ng_bridge.h b/sys/netgraph/ng_bridge.h index b34bc0f5f55e..790e9c5da11e 100644 --- a/sys/netgraph/ng_bridge.h +++ b/sys/netgraph/ng_bridge.h @@ -130,13 +130,6 @@ struct ng_bridge_link_stats { struct ng_bridge_link; typedef struct ng_bridge_link *link_p; -/* Structure describing a single host */ -struct ng_bridge_host { - u_char addr[6]; /* ethernet address */ - link_p link; /* link where addr can be found */ - u_int16_t age; /* seconds ago entry was created */ - u_int16_t staleness; /* seconds ago host last heard from */ -}; #ifdef NGM_BRIDGE_TABLE_ABI struct ng_bridge_host_tbl { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:02: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 82D6855D369; Thu, 25 Feb 2021 10:02: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 4DmSyB3Lq2z4SpK; Thu, 25 Feb 2021 10:02: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 65FCA15564; Thu, 25 Feb 2021 10:02: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 11PA2QrF019021; Thu, 25 Feb 2021 10:02:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PA2Qt9019006; Thu, 25 Feb 2021 10:02:26 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:02:26 GMT Message-Id: <202102251002.11PA2Qt9019006@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: 1c0b19f9966d - stable/12 - netgraph/ng_bridge: Document staleness in multithreaded operation 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: 1c0b19f9966dd13db7202b44ca79d2170b4f7b8f 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, 25 Feb 2021 10:02:26 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=1c0b19f9966dd13db7202b44ca79d2170b4f7b8f commit 1c0b19f9966dd13db7202b44ca79d2170b4f7b8f Author: Lutz Donnerhacke AuthorDate: 2021-02-09 11:32:46 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:02:06 +0000 netgraph/ng_bridge: Document staleness in multithreaded operation In the data path of ng_bridge(4), the only value of the host struct, which needs to be modified, is the staleness, which is reset every time a frame is received. It's save to leave the code as it is. This patch is part of a series to make ng_bridge(4) multithreaded. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28546 (cherry picked from commit 011b7317dbb5038a95b9b4fca050325a62f3991e) --- sys/netgraph/ng_bridge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 0b2b7f5ca6a3..3d1dc88af3c2 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -808,8 +808,10 @@ ng_bridge_rcvdata(hook_p hook, item_p item) /* Look up packet's source Ethernet address in hashtable */ if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) { - - /* Update time since last heard from this host */ + /* Update time since last heard from this host. + * This is safe without locking, because it's + * the only operation during shared access. + */ host->staleness = 0; /* Did host jump to a different link? */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:05: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 6B40555D37C; Thu, 25 Feb 2021 10:05: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 4DmT192gMMz4Sf4; Thu, 25 Feb 2021 10:05: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 4E50615955; Thu, 25 Feb 2021 10:05: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 11PA51HA019705; Thu, 25 Feb 2021 10:05:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PA51Zw019704; Thu, 25 Feb 2021 10:05:01 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:05:01 GMT Message-Id: <202102251005.11PA51Zw019704@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: d02939510276 - stable/12 - netgraph/ng_bridge: Add counters for the first link, too 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: d02939510276106d3244ce95528245f2114a091a 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, 25 Feb 2021 10:05:01 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d02939510276106d3244ce95528245f2114a091a commit d02939510276106d3244ce95528245f2114a091a Author: Lutz Donnerhacke AuthorDate: 2021-02-10 10:47:38 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:04:47 +0000 netgraph/ng_bridge: Add counters for the first link, too For broadcast, multicast and unknown unicast, the replication loop sends a copy of the packet to each link, beside the first one. This special path is handled later, but the counters are not updated. Factor out the common send and count actions as a function. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D28537 (cherry picked from commit 3c958f5fdfc01b7579ea0fbfc3f15f8a85bebee9) --- sys/netgraph/ng_bridge.c | 60 ++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 3d1dc88af3c2..5917c1084527 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -694,6 +694,41 @@ struct ng_bridge_send_ctx { int manycast, error; }; +/* + * Update stats and send out + */ +static inline int +ng_bridge_send_data(link_cp dst, int manycast, struct mbuf *m, item_p item) { + int error = 0; + size_t len = m->m_pkthdr.len; + + if(item != NULL) + NG_FWD_NEW_DATA(error, item, dst->hook, m); + else + NG_SEND_DATA_ONLY(error, dst->hook, m); + + if (error == 0) { + counter_u64_add(dst->stats.xmitPackets, 1); + counter_u64_add(dst->stats.xmitOctets, len); + switch (manycast) { + default: /* unknown unicast */ + break; + case 1: /* multicast */ + counter_u64_add(dst->stats.xmitMulticasts, 1); + break; + case 2: /* broadcast */ + counter_u64_add(dst->stats.xmitBroadcasts, 1); + break; + } + } + + return (error); +} + +/* + * Loop body for sending to multiple destinations + * return 0 to stop looping + */ static int ng_bridge_send_ctx(hook_p dst, void *arg) { @@ -732,23 +767,8 @@ ng_bridge_send_ctx(hook_p dst, void *arg) return (0); /* abort loop */ } - - /* Update stats */ - counter_u64_add(destLink->stats.xmitPackets, 1); - counter_u64_add(destLink->stats.xmitOctets, m2->m_pkthdr.len); - switch (ctx->manycast) { - default: /* unknown unicast */ - break; - case 1: /* multicast */ - counter_u64_add(destLink->stats.xmitMulticasts, 1); - break; - case 2: /* broadcast */ - counter_u64_add(destLink->stats.xmitBroadcasts, 1); - break; - } - /* Send packet */ - NG_SEND_DATA_ONLY(error, destLink->hook, m2); + error = ng_bridge_send_data(destLink, ctx->manycast, m2, NULL); if(error) ctx->error = error; return (1); @@ -892,10 +912,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) } /* Deliver packet out the destination link */ - counter_u64_add(destLink->stats.xmitPackets, 1); - counter_u64_add(destLink->stats.xmitOctets, ctx.m->m_pkthdr.len); - NG_FWD_NEW_DATA(ctx.error, item, destLink->hook, ctx.m); - return (ctx.error); + return (ng_bridge_send_data(destLink, ctx.manycast, ctx.m, item)); } /* Destination host is not known */ @@ -916,8 +933,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item) * If we've sent all the others, send the original * on the first link we found. */ - NG_FWD_NEW_DATA(ctx.error, item, ctx.foundFirst->hook, ctx.m); - return (ctx.error); + return (ng_bridge_send_data(ctx.foundFirst, ctx.manycast, ctx.m, item)); } /* From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:07: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 D12C355DA02; Thu, 25 Feb 2021 10:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmT4b513Nz4Srd; Thu, 25 Feb 2021 10:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9EECF15AF0; Thu, 25 Feb 2021 10:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PA7xSe020257; Thu, 25 Feb 2021 10:07:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PA7xHQ020256; Thu, 25 Feb 2021 10:07:59 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:07:59 GMT Message-Id: <202102251007.11PA7xHQ020256@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: 8790393123f1 - stable/12 - netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support 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: 8790393123f13c4c5a301939ea65c564033a53b6 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, 25 Feb 2021 10:07:59 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=8790393123f13c4c5a301939ea65c564033a53b6 commit 8790393123f13c4c5a301939ea65c564033a53b6 Author: Neel Chauhan AuthorDate: 2021-01-24 19:23:39 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:07:08 +0000 netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support This extends upon the RFC 6598 support to libalias/ipfw in r357092. Reviewed By: manpages (bcr), donner, adrian, kp Differential Revision: https://reviews.freebsd.org/D23461 (cherry picked from commit 5fe433a6e4d8cab6b64284698301afc0c55a9db2) --- share/man/man4/ng_nat.4 | 8 +++++++- sys/netgraph/ng_nat.c | 2 ++ sys/netgraph/ng_nat.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ng_nat.4 b/share/man/man4/ng_nat.4 index 3baa25a8637c..b2f3780e1002 100644 --- a/share/man/man4/ng_nat.4 +++ b/share/man/man4/ng_nat.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 12, 2018 +.Dd January 24, 2021 .Dt NG_NAT 4 .Os .Sh NAME @@ -75,7 +75,13 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 .Ed +.Pp +The corresponding libalias flags can be found by replacing the +.Vt "NG_NAT" +prefix with +.Vt "PKT_ALIAS" . .It Dv NGM_NAT_SET_TARGET Pq Ic settarget Configure target address for a node. When an incoming packet not associated with any pre-existing aliasing diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c index 4b6039d33654..76da4214f644 100644 --- a/sys/netgraph/ng_nat.c +++ b/sys/netgraph/ng_nat.c @@ -961,6 +961,8 @@ ng_nat_translate_flags(unsigned int x) res |= PKT_ALIAS_PROXY_ONLY; if (x & NG_NAT_REVERSE) res |= PKT_ALIAS_REVERSE; + if (x & NG_NAT_UNREGISTERED_CGN) + res |= PKT_ALIAS_UNREGISTERED_CGN; return (res); } diff --git a/sys/netgraph/ng_nat.h b/sys/netgraph/ng_nat.h index 46c9609772ff..b56d45c10671 100644 --- a/sys/netgraph/ng_nat.h +++ b/sys/netgraph/ng_nat.h @@ -54,6 +54,7 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 #define NG_NAT_DESC_LENGTH 64 #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:09: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 F350155DB01; Thu, 25 Feb 2021 10:09: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 4DmT6t6dMVz4Sy5; Thu, 25 Feb 2021 10:09: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 D69A115956; Thu, 25 Feb 2021 10:09: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 11PA9w8o020659; Thu, 25 Feb 2021 10:09:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PA9wDj020658; Thu, 25 Feb 2021 10:09:58 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:09:58 GMT Message-Id: <202102251009.11PA9wDj020658@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: e600af01eeba - stable/11 - netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support 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: e600af01eeba79f7cc407a778f1d7b4f004900c1 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, 25 Feb 2021 10:09:59 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=e600af01eeba79f7cc407a778f1d7b4f004900c1 commit e600af01eeba79f7cc407a778f1d7b4f004900c1 Author: Neel Chauhan AuthorDate: 2021-01-24 19:23:39 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:09:38 +0000 netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support This extends upon the RFC 6598 support to libalias/ipfw in r357092. Reviewed By: manpages (bcr), donner, adrian, kp Differential Revision: https://reviews.freebsd.org/D23461 (cherry picked from commit 5fe433a6e4d8cab6b64284698301afc0c55a9db2) --- share/man/man4/ng_nat.4 | 8 +++++++- sys/netgraph/ng_nat.c | 2 ++ sys/netgraph/ng_nat.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ng_nat.4 b/share/man/man4/ng_nat.4 index 3baa25a8637c..b2f3780e1002 100644 --- a/share/man/man4/ng_nat.4 +++ b/share/man/man4/ng_nat.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 12, 2018 +.Dd January 24, 2021 .Dt NG_NAT 4 .Os .Sh NAME @@ -75,7 +75,13 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 .Ed +.Pp +The corresponding libalias flags can be found by replacing the +.Vt "NG_NAT" +prefix with +.Vt "PKT_ALIAS" . .It Dv NGM_NAT_SET_TARGET Pq Ic settarget Configure target address for a node. When an incoming packet not associated with any pre-existing aliasing diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c index 6ebfd06bf88a..0806abfbb01b 100644 --- a/sys/netgraph/ng_nat.c +++ b/sys/netgraph/ng_nat.c @@ -959,6 +959,8 @@ ng_nat_translate_flags(unsigned int x) res |= PKT_ALIAS_PROXY_ONLY; if (x & NG_NAT_REVERSE) res |= PKT_ALIAS_REVERSE; + if (x & NG_NAT_UNREGISTERED_CGN) + res |= PKT_ALIAS_UNREGISTERED_CGN; return (res); } diff --git a/sys/netgraph/ng_nat.h b/sys/netgraph/ng_nat.h index df3607540f00..8abeef262489 100644 --- a/sys/netgraph/ng_nat.h +++ b/sys/netgraph/ng_nat.h @@ -52,6 +52,7 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 #define NG_NAT_DESC_LENGTH 64 #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:12: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 AA8A555D9DC; Thu, 25 Feb 2021 10:12: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 4DmTB44SYvz4TJN; Thu, 25 Feb 2021 10:12: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 8BD2115D8E; Thu, 25 Feb 2021 10:12: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 11PACiRR033230; Thu, 25 Feb 2021 10:12:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PACicJ033229; Thu, 25 Feb 2021 10:12:44 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:12:44 GMT Message-Id: <202102251012.11PACicJ033229@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: ea5ebe9cde3c - stable/11 - ether: add older ethertype definitions for QinQ 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: ea5ebe9cde3c4c3ef11b90a15881749125974cfa 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, 25 Feb 2021 10:12:44 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=ea5ebe9cde3c4c3ef11b90a15881749125974cfa commit ea5ebe9cde3c4c3ef11b90a15881749125974cfa Author: Philip Paeps AuthorDate: 2019-10-17 00:34:53 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:12:01 +0000 ether: add older ethertype definitions for QinQ Older network equipment used the ethertypes 0x9100, 0x9200, and 0x9300 for outer VLANs, before standardisation introduced 0x88a8. Submitted by: Lutz Donnerhacke Differential Revision: https://reviews.freebsd.org/D21846 (cherry picked from commit 579b70db8922b1debf3bd99bb2b822d60b95575d) --- sys/net/ethernet.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 5e46f124a0f2..fdfc41b55037 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -360,10 +360,13 @@ struct ether_vlan_header { #define ETHERTYPE_PBB 0x88E7 /* 802.1Q Provider Backbone Bridges */ #define ETHERTYPE_FCOE 0x8906 /* Fibre Channel over Ethernet */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ +#define ETHERTYPE_8021Q9100 0x9100 /* IEEE 802.1Q stacking (proprietary) */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ #define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ #define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ +#define ETHERTYPE_8021Q9200 0x9200 /* IEEE 802.1Q stacking (proprietary) */ +#define ETHERTYPE_8021Q9300 0x9300 /* IEEE 802.1Q stacking (proprietary) */ #define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ #define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ #define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:12: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 C86CA55DB11; Thu, 25 Feb 2021 10:12: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 4DmTB55Dnzz4TWs; Thu, 25 Feb 2021 10:12:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6DA515B40; Thu, 25 Feb 2021 10:12: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 11PACjxu033253; Thu, 25 Feb 2021 10:12:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PACjQf033252; Thu, 25 Feb 2021 10:12:45 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:12:45 GMT Message-Id: <202102251012.11PACjQf033252@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: b2c14db4f8fd - stable/11 - netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type 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: b2c14db4f8fda2c015a9b58f6d8b0e29fea3779d 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, 25 Feb 2021 10:12:45 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=b2c14db4f8fda2c015a9b58f6d8b0e29fea3779d commit b2c14db4f8fda2c015a9b58f6d8b0e29fea3779d Author: Lutz Donnerhacke AuthorDate: 2021-01-26 15:50:04 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:12:17 +0000 netgraph/ng_vlan_rotate: IEEE 802.1ad VLAN manipulation netgraph type This node is part of an A10-NSP (L2-BSA) development. Carrier networks tend to stack three or more tags for internal purposes and therefore hiding the service tags deep inside of the stack. When decomposing such an access network frame, the processing order is typically reversed: First distinguish by service, than by other means. This new netgragh node allows to bring the relevant VLAN in front (to the out-most position). This way other netgraph nodes (like ng_vlan) can operate on this specific type. Reviewed by: manpages (gbe), brueffer (manpages), kp Relnotes: yes Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22076 (cherry picked from commit cfd6422a5217410fbd66f7a7a8a64d9d85e61229) --- share/man/man4/Makefile | 1 + share/man/man4/ng_vlan_rotate.4 | 252 +++++++++++++++ sys/conf/files | 1 + sys/modules/netgraph/Makefile | 3 +- sys/modules/netgraph/vlan_rotate/Makefile | 6 + sys/netgraph/ng_vlan_rotate.c | 510 ++++++++++++++++++++++++++++++ sys/netgraph/ng_vlan_rotate.h | 67 ++++ 7 files changed, 839 insertions(+), 1 deletion(-) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 44e0c3ab22f9..837e667217b3 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -391,6 +391,7 @@ MAN= aac.4 \ ng_uni.4 \ ng_vjc.4 \ ng_vlan.4 \ + ng_vlan_rotate.4 \ nmdm.4 \ nsp.4 \ ${_ntb.4} \ diff --git a/share/man/man4/ng_vlan_rotate.4 b/share/man/man4/ng_vlan_rotate.4 new file mode 100644 index 000000000000..4640737c7d54 --- /dev/null +++ b/share/man/man4/ng_vlan_rotate.4 @@ -0,0 +1,252 @@ +.\"- +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2019-2021 IKS Service GmbH +.\" +.\" 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. +.\" +.\" Author: Lutz Donnerhacke +.\" +.\" $FreeBSD$ +.\" +.Dd January 26, 2021 +.Dt NG_VLAN_ROTATE 4 +.Os +.Sh NAME +.Nm ng_vlan_rotate +.Nd IEEE 802.1ad VLAN manipulation netgraph node type +.Sh SYNOPSIS +.In sys/types.h +.In netgraph.h +.In netgraph/ng_vlan_rotate.h +.Sh DESCRIPTION +The +.Nm +node type manipulates the order of VLAN tags of frames tagged +according to the IEEE 802.1ad (an extension of IEEE 802.1Q) standard +between different hooks. +.Pp +Each node has four special hooks, +.Va original , +.Va ordered , +.Va excessive , +and +.Va incomplete . +.Pp +A frame tagged with an arbitrary number of +.Dv ETHERTYPE_VLAN , +.Dv ETHERTYPE_QINQ , +and +.Dv 0x9100 +tags received on the +.Va original +hook will be rearranged to a new order of those tags and is sent out +the +.Dq ordered +hook. +After successful processing the +.Va histogram +counter for the observed stack size increments. +.Pp +If it contains fewer VLANs in the stack than the configured +.Va min +limit, the frame is sent out to the +.Va incomplete +hook and the +.Va incomplete +counter increments. +.Pp +If there are more VLANs in the stack than the configured +.Va max +limit, the frame is sent out to the +.Va excessive +hook and the +.Va excessive +counter increments. +.Pp +If the destination hook is not connected, the frame is dropped and the +.Va drops +counter increments. +.Pp +For Ethernet frames received on the +.Va ordered +hook, the transformation is reversed and is passed to the +.Va original +hook. +Please note that this process is identical to the one described +above, besides the ordered/original hooks are swapped and the +transformation is reversed. +.Pp +An Ethernet frame received on the +.Va incomplete +or +.Va excessive +hook is forwarded to the +.Va original +hook without any modification. +.Pp +This node supports only one operation at the moment: Rotation of the +VLANs in the stack. +Setting the configuration parameter +.Va rot +to a positive value, the stack will roll up by this amount. +Negative values will roll down. +A typical scenario is setting the value to 1 in order to bring the +innermost VLAN tag to the outmost level. +Rotation includes the VLAN id, the ether type, and the QOS parameters +pcp and cfi. +Typical QOS handling refers to the outmost setting, so be careful to +keep your QOS intact. +.Sh HOOKS +This node type supports the following hooks: +.Bl -tag -width incomplete +.It Va original +Typically this hook would be connected to a +.Xr ng_ether 4 +node, using the +.Va lower +hook connected to a carrier network. +.It Va ordered +Typically this hook would be connected to a +.Xr ng_vlan 4 +type node using the +.Va downstream +hook in order to separate services. +.It Va excessive +see below. +.It Va incomplete +Typically those hooks would be attached to a +.Xr ng_eiface 4 +type node using the +.Va ether +hook for anomaly monitoring purposes. +.El +.Sh CONTROL MESSAGES +This node type supports the generic control messages, plus the following: +.Bl -tag -width foo +.It Dv NGM_VLANROTATE_GET_CONF Pq Ic getconf +Read the current configuration. +.It Dv NGM_VLANROTATE_SET_CONF Pq Ic setconf +Set the current configuration. +.It Dv NGM_VLANROTATE_GET_STAT Pq Ic getstat +Read the current statistics. +.It Dv NGM_VLANROTATE_CLR_STAT Pq Ic clrstat +Zeroize the statistics. +.It Dv NGM_VLANROTATE_GETCLR_STAT Pq Ic getclrstat +Read the current statistics and zeroize it in one step. +.El +.Sh EXAMPLES +The first example demonstrates how to rotate double or triple tagged +frames so that the innermost C-VLAN can be used as service +discriminator. +The single or double tagged frames (C-VLAN removed) are sent out to an +interface pointing to different infrastucture. +.Bd -literal +#!/bin/sh + +BNG_IF=ixl3 +VOIP_IF=bge2 + +ngctl -f- < 00:01:02:03:04:05, + ethertype 802.1Q-9100 (0x9100), length 110: vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype 802.1Q, vlan 123, p 7, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The frame ejected on the +.Va ordered +hook will look like this: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q (0x8100), length 110: vlan 123, p 7, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +Hence, the frame pushed out to the +.Dv VOIP_IF +will have this form: +.Bd -literal +00:00:00:00:01:01 > 00:01:02:03:04:05, + ethertype 802.1Q-9100, vlan 2, p 1, + ethertype 802.1Q-QinQ, vlan 101, p 0, + ethertype IPv4, (tos 0x0, ttl 64, id 15994, offset 0, flags [none], + proto ICMP (1), length 84) 192.168.140.101 > 192.168.140.1: + ICMP echo request, id 40234, seq 0, length 64 +.Ed +.Pp +The second example distinguishes between double tagged and single +tagged frames. +.Bd -literal +#!/bin/sh + +IN_IF=bge1 + +ngctl -f- < diff --git a/sys/netgraph/ng_vlan_rotate.c b/sys/netgraph/ng_vlan_rotate.c new file mode 100644 index 000000000000..e6de782d9bb3 --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.c @@ -0,0 +1,510 @@ +/*- + * Spdx-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +/* + * This section contains the netgraph method declarations for the + * sample node. These methods define the netgraph 'type'. + */ + +static ng_constructor_t ng_vlanrotate_constructor; +static ng_rcvmsg_t ng_vlanrotate_rcvmsg; +static ng_shutdown_t ng_vlanrotate_shutdown; +static ng_newhook_t ng_vlanrotate_newhook; +static ng_rcvdata_t ng_vlanrotate_rcvdata; +static ng_disconnect_t ng_vlanrotate_disconnect; + +/* Parse type for struct ng_vlanrotate_conf */ +static const struct ng_parse_struct_field ng_vlanrotate_conf_fields[] = { + {"rot", &ng_parse_int8_type}, + {"min", &ng_parse_uint8_type}, + {"max", &ng_parse_uint8_type}, + {NULL} +}; +static const struct ng_parse_type ng_vlanrotate_conf_type = { + &ng_parse_struct_type, + &ng_vlanrotate_conf_fields +}; + +/* Parse type for struct ng_vlanrotate_stat */ +static struct ng_parse_fixedarray_info ng_vlanrotate_stat_hist_info = { + &ng_parse_uint64_type, + NG_VLANROTATE_MAX_VLANS +}; +static struct ng_parse_type ng_vlanrotate_stat_hist = { + &ng_parse_fixedarray_type, + &ng_vlanrotate_stat_hist_info +}; +static const struct ng_parse_struct_field ng_vlanrotate_stat_fields[] = { + {"drops", &ng_parse_uint64_type}, + {"excessive", &ng_parse_uint64_type}, + {"incomplete", &ng_parse_uint64_type}, + {"histogram", &ng_vlanrotate_stat_hist}, + {NULL} +}; +static struct ng_parse_type ng_vlanrotate_stat_type = { + &ng_parse_struct_type, + &ng_vlanrotate_stat_fields +}; + + +/* List of commands and how to convert arguments to/from ASCII */ +static const struct ng_cmdlist ng_vlanrotate_cmdlist[] = { + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_CONF, + "getconf", + NULL, + &ng_vlanrotate_conf_type, + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_SET_CONF, + "setconf", + &ng_vlanrotate_conf_type, + NULL + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GET_STAT, + "getstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_CLR_STAT, + "clrstat", + NULL, + &ng_vlanrotate_stat_type + }, + { + NGM_VLANROTATE_COOKIE, + NGM_VLANROTATE_GETCLR_STAT, + "getclrstat", + NULL, + &ng_vlanrotate_stat_type + }, + {0} +}; + +/* Netgraph node type descriptor */ +static struct ng_type typestruct = { + .version = NG_ABI_VERSION, + .name = NG_VLANROTATE_NODE_TYPE, + .constructor = ng_vlanrotate_constructor, + .rcvmsg = ng_vlanrotate_rcvmsg, + .shutdown = ng_vlanrotate_shutdown, + .newhook = ng_vlanrotate_newhook, + .rcvdata = ng_vlanrotate_rcvdata, + .disconnect = ng_vlanrotate_disconnect, + .cmdlist = ng_vlanrotate_cmdlist, +}; +NETGRAPH_INIT(vlanrotate, &typestruct); + +struct ng_vlanrotate_kernel_stats { + counter_u64_t drops, excessive, incomplete; + counter_u64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Information we store for each node */ +struct vlanrotate { + hook_p original_hook; + hook_p ordered_hook; + hook_p excessive_hook; + hook_p incomplete_hook; + struct ng_vlanrotate_conf conf; + struct ng_vlanrotate_kernel_stats stats; +}; +typedef struct vlanrotate *vlanrotate_p; + +/* + * Set up the private data structure. + */ +static int +ng_vlanrotate_constructor(node_p node) +{ + int i; + + vlanrotate_p vrp = malloc(sizeof(*vrp), M_NETGRAPH, M_WAITOK | M_ZERO); + + vrp->conf.max = NG_VLANROTATE_MAX_VLANS; + + vrp->stats.drops = counter_u64_alloc(M_WAITOK); + vrp->stats.excessive = counter_u64_alloc(M_WAITOK); + vrp->stats.incomplete = counter_u64_alloc(M_WAITOK); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + vrp->stats.histogram[i] = counter_u64_alloc(M_WAITOK); + + NG_NODE_SET_PRIVATE(node, vrp); + return (0); +} + +/* + * Give our ok for a hook to be added. + */ +static int +ng_vlanrotate_newhook(node_p node, hook_p hook, const char *name) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + hook_p *dst = NULL; + + if (strcmp(name, NG_VLANROTATE_HOOK_ORDERED) == 0) { + dst = &vrp->ordered_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_ORIGINAL) == 0) { + dst = &vrp->original_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_EXCESSIVE) == 0) { + dst = &vrp->excessive_hook; + } else if (strcmp(name, NG_VLANROTATE_HOOK_INCOMPLETE) == 0) { + dst = &vrp->incomplete_hook; + } else + return (EINVAL); /* not a hook we know about */ + + if (*dst != NULL) + return (EADDRINUSE); /* don't override */ + + *dst = hook; + return (0); +} + +/* + * Get a netgraph control message. + * A response is not required. + */ +static int +ng_vlanrotate_rcvmsg(node_p node, item_p item, hook_p lasthook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + struct ng_mesg *resp = NULL; + struct ng_mesg *msg; + struct ng_vlanrotate_conf *pcf; + int error = 0; + + NGI_GET_MSG(item, msg); + /* Deal with message according to cookie and command */ + switch (msg->header.typecookie) { + case NGM_VLANROTATE_COOKIE: + switch (msg->header.cmd) { + case NGM_VLANROTATE_GET_CONF: + NG_MKRESPONSE(resp, msg, sizeof(vrp->conf), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + *((struct ng_vlanrotate_conf *)resp->data) = vrp->conf; + break; + case NGM_VLANROTATE_SET_CONF: + if (msg->header.arglen != sizeof(*pcf)) { + error = EINVAL; + break; + } + + pcf = (struct ng_vlanrotate_conf *)msg->data; + + if (pcf->max == 0) /* keep current value */ + pcf->max = vrp->conf.max; + + if ((pcf->max > NG_VLANROTATE_MAX_VLANS) || + (pcf->min > pcf->max) || + (abs(pcf->rot) >= pcf->max)) { + error = EINVAL; + break; + } + + vrp->conf = *pcf; + break; + case NGM_VLANROTATE_GET_STAT: + case NGM_VLANROTATE_GETCLR_STAT: + { + struct ng_vlanrotate_stat *p; + int i; + + NG_MKRESPONSE(resp, msg, sizeof(*p), M_NOWAIT); + if (!resp) { + error = ENOMEM; + break; + } + p = (struct ng_vlanrotate_stat *)resp->data; + p->drops = counter_u64_fetch(vrp->stats.drops); + p->excessive = counter_u64_fetch(vrp->stats.excessive); + p->incomplete = counter_u64_fetch(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + p->histogram[i] = counter_u64_fetch(vrp->stats.histogram[i]); + if (msg->header.cmd != NGM_VLANROTATE_GETCLR_STAT) + break; + } + case NGM_VLANROTATE_CLR_STAT: + { + int i; + + counter_u64_zero(vrp->stats.drops); + counter_u64_zero(vrp->stats.excessive); + counter_u64_zero(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_zero(vrp->stats.histogram[i]); + break; + } + default: + error = EINVAL; /* unknown command */ + break; + } + break; + default: + error = EINVAL; /* unknown cookie type */ + break; + } + + /* Take care of synchronous response, if any */ + NG_RESPOND_MSG(error, node, item, resp); + /* Free the message and return */ + NG_FREE_MSG(msg); + return (error); +} + +/* + * Receive data, and do rotate the vlans as desired. + * + * Rotating is quite complicated if the rotation offset and the number + * of vlans are not relativly prime. In this case multiple slices need + * to be rotated separately. + * + * Rotation can be additive or subtractive. Some examples: + * 01234 5 vlans given + * ----- + * 34012 +2 rotate + * 12340 +4 rotate + * 12340 -1 rotate + * + * First some helper functions ... + */ + +struct ether_vlan_stack_entry { + uint16_t proto; + uint16_t tag; +} __packed; + +struct ether_vlan_stack_header { + uint8_t dst[ETHER_ADDR_LEN]; + uint8_t src[ETHER_ADDR_LEN]; + struct ether_vlan_stack_entry vlan_stack[1]; +} __packed; + +static int +ng_vlanrotate_gcd(int a, int b) +{ + if (b == 0) + return a; + else + return ng_vlanrotate_gcd(b, a % b); +} + +static void +ng_vlanrotate_rotate(struct ether_vlan_stack_entry arr[], int d, int n) +{ + int i, j, k; + struct ether_vlan_stack_entry temp; + + /* for each commensurable slice */ + for (i = ng_vlanrotate_gcd(d, n); i-- > 0;) { + /* rotate left aka downwards */ + temp = arr[i]; + j = i; + + while (1) { + k = j + d; + if (k >= n) + k = k - n; + if (k == i) + break; + arr[j] = arr[k]; + j = k; + } + + arr[j] = temp; + } +} + +static int +ng_vlanrotate_rcvdata(hook_p hook, item_p item) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + struct ether_vlan_stack_header *evsh; + struct mbuf *m = NULL; + hook_p dst_hook; + int8_t rotate; + int8_t vlans = 0; + int error = ENOSYS; + + NGI_GET_M(item, m); + + if (hook == vrp->ordered_hook) { + rotate = +vrp->conf.rot; + dst_hook = vrp->original_hook; + } else if (hook == vrp->original_hook) { + rotate = -vrp->conf.rot; + dst_hook = vrp->ordered_hook; + } else { + dst_hook = vrp->original_hook; + goto send; /* everything else goes out unmodified */ + } + + if (dst_hook == NULL) { + error = ENETDOWN; + goto fail; + } + + /* count the vlans */ + for (vlans = 0; vlans <= NG_VLANROTATE_MAX_VLANS; vlans++) { + size_t expected_len = sizeof(struct ether_vlan_stack_header) + + vlans * sizeof(struct ether_vlan_stack_entry); + + if (m->m_len < expected_len) { + m = m_pullup(m, expected_len); + if (m == NULL) { + error = EINVAL; + goto fail; + } + } + + evsh = mtod(m, struct ether_vlan_stack_header *); + switch (ntohs(evsh->vlan_stack[vlans].proto)) { + case ETHERTYPE_VLAN: + case ETHERTYPE_QINQ: + case ETHERTYPE_8021Q9100: + case ETHERTYPE_8021Q9200: + case ETHERTYPE_8021Q9300: + break; + default: + goto out; + } + } +out: + if ((vlans > vrp->conf.max) || (vlans >= NG_VLANROTATE_MAX_VLANS)) { + counter_u64_add(vrp->stats.excessive, 1); + dst_hook = vrp->excessive_hook; + goto send; + } + + if ((vlans < vrp->conf.min) || (vlans <= abs(rotate))) { + counter_u64_add(vrp->stats.incomplete, 1); + dst_hook = vrp->incomplete_hook; + goto send; + } + counter_u64_add(vrp->stats.histogram[vlans], 1); + + /* rotating upwards always (using modular arithmetics) */ + if (rotate == 0) { + /* nothing to do */ + } else if (rotate > 0) { + ng_vlanrotate_rotate(evsh->vlan_stack, rotate, vlans); + } else { + ng_vlanrotate_rotate(evsh->vlan_stack, vlans + rotate, vlans); + } + +send: + if (dst_hook == NULL) + goto fail; + NG_FWD_NEW_DATA(error, item, dst_hook, m); + return 0; + +fail: + counter_u64_add(vrp->stats.drops, 1); + if (m != NULL) + m_freem(m); + NG_FREE_ITEM(item); + return (error); +} + +/* + * Do local shutdown processing.. + * All our links and the name have already been removed. + */ +static int +ng_vlanrotate_shutdown(node_p node) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(node); + int i; + + NG_NODE_SET_PRIVATE(node, NULL); + + counter_u64_free(vrp->stats.drops); + counter_u64_free(vrp->stats.excessive); + counter_u64_free(vrp->stats.incomplete); + for (i = 0; i < NG_VLANROTATE_MAX_VLANS; i++) + counter_u64_free(vrp->stats.histogram[i]); + + free(vrp, M_NETGRAPH); + + NG_NODE_UNREF(node); + return (0); +} + +/* + * Hook disconnection + * For this type, removal of the last link destroys the node + */ +static int +ng_vlanrotate_disconnect(hook_p hook) +{ + const vlanrotate_p vrp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + + if (vrp->original_hook == hook) + vrp->original_hook = NULL; + if (vrp->ordered_hook == hook) + vrp->ordered_hook = NULL; + if (vrp->excessive_hook == hook) + vrp->excessive_hook = NULL; + if (vrp->incomplete_hook == hook) + vrp->incomplete_hook = NULL; + + /* during shutdown the node is invalid, don't shutdown twice */ + if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) && + (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) + ng_rmnode_self(NG_HOOK_NODE(hook)); + return (0); +} diff --git a/sys/netgraph/ng_vlan_rotate.h b/sys/netgraph/ng_vlan_rotate.h new file mode 100644 index 000000000000..ef6dfd6b506a --- /dev/null +++ b/sys/netgraph/ng_vlan_rotate.h @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2021 IKS Service GmbH + * + * 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. + * + * Author: Lutz Donnerhacke + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_NG_VLAN_ROTATE_H_ +#define _NETGRAPH_NG_VLAN_ROTATE_H_ + +#define NG_VLANROTATE_NODE_TYPE "vlan_rotate" +#define NGM_VLANROTATE_COOKIE 1568378766 + +/* Hook names */ +#define NG_VLANROTATE_HOOK_ORDERED "ordered" +#define NG_VLANROTATE_HOOK_ORIGINAL "original" +#define NG_VLANROTATE_HOOK_EXCESSIVE "excessive" +#define NG_VLANROTATE_HOOK_INCOMPLETE "incomplete" + +/* Limits */ +#define NG_VLANROTATE_MAX_VLANS 10 + +/* Datastructures for netgraph commands */ +struct ng_vlanrotate_conf { + int8_t rot; + uint8_t min, max; +}; + +struct ng_vlanrotate_stat { + uint64_t drops, excessive, incomplete; + uint64_t histogram[NG_VLANROTATE_MAX_VLANS]; +}; + +/* Netgraph commands understood by this node type */ +enum { + NGM_VLANROTATE_GET_CONF = 1, + NGM_VLANROTATE_SET_CONF, + NGM_VLANROTATE_GET_STAT, + NGM_VLANROTATE_CLR_STAT, + NGM_VLANROTATE_GETCLR_STAT +}; + +#endif /* _NETGRAPH_NG_VLAN_ROTATE_H_ */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 10:21: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 E415B55DFBD; Thu, 25 Feb 2021 10:21: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 4DmTN96B23z4VCL; Thu, 25 Feb 2021 10:21: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 C734515BAD; Thu, 25 Feb 2021 10:21: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 11PALTtr043572; Thu, 25 Feb 2021 10:21:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PALTHG043571; Thu, 25 Feb 2021 10:21:29 GMT (envelope-from git) Date: Thu, 25 Feb 2021 10:21:29 GMT Message-Id: <202102251021.11PALTHG043571@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: d65b86dd9325 - stable/13 - netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support 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: d65b86dd9325ce8d46fb7e82efb03c73c9957a77 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, 25 Feb 2021 10:21:30 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d65b86dd9325ce8d46fb7e82efb03c73c9957a77 commit d65b86dd9325ce8d46fb7e82efb03c73c9957a77 Author: Neel Chauhan AuthorDate: 2021-01-24 19:23:39 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-25 10:21:03 +0000 netgraph/ng_nat: Add RFC 6598/Carrier Grade NAT support This extends upon the RFC 6598 support to libalias/ipfw in r357092. Reviewed By: manpages (bcr), donner, adrian, kp Differential Revision: https://reviews.freebsd.org/D23461 (cherry picked from commit 5fe433a6e4d8cab6b64284698301afc0c55a9db2) --- share/man/man4/ng_nat.4 | 8 +++++++- sys/netgraph/ng_nat.c | 2 ++ sys/netgraph/ng_nat.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ng_nat.4 b/share/man/man4/ng_nat.4 index b7c65fe89b20..e9c0f2acbcee 100644 --- a/share/man/man4/ng_nat.4 +++ b/share/man/man4/ng_nat.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 12, 2018 +.Dd January 24, 2021 .Dt NG_NAT 4 .Os .Sh NAME @@ -75,7 +75,13 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 .Ed +.Pp +The corresponding libalias flags can be found by replacing the +.Vt "NG_NAT" +prefix with +.Vt "PKT_ALIAS" . .It Dv NGM_NAT_SET_TARGET Pq Ic settarget Configure target address for a node. When an incoming packet not associated with any pre-existing aliasing diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c index a5c776ef6db6..cd3442914311 100644 --- a/sys/netgraph/ng_nat.c +++ b/sys/netgraph/ng_nat.c @@ -961,6 +961,8 @@ ng_nat_translate_flags(unsigned int x) res |= PKT_ALIAS_PROXY_ONLY; if (x & NG_NAT_REVERSE) res |= PKT_ALIAS_REVERSE; + if (x & NG_NAT_UNREGISTERED_CGN) + res |= PKT_ALIAS_UNREGISTERED_CGN; return (res); } diff --git a/sys/netgraph/ng_nat.h b/sys/netgraph/ng_nat.h index 46c9609772ff..b56d45c10671 100644 --- a/sys/netgraph/ng_nat.h +++ b/sys/netgraph/ng_nat.h @@ -54,6 +54,7 @@ struct ng_nat_mode { #define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 +#define NG_NAT_UNREGISTERED_CGN 0x100 #define NG_NAT_DESC_LENGTH 64 #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58: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 DF04D562648; Thu, 25 Feb 2021 12:58: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 4DmXsK5tMlz4gMQ; Thu, 25 Feb 2021 12:58: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 BC6591800E; Thu, 25 Feb 2021 12:58: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 11PCwTiA043888; Thu, 25 Feb 2021 12:58:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwTdr043887; Thu, 25 Feb 2021 12:58:29 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:29 GMT Message-Id: <202102251258.11PCwTdr043887@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: fd61ccfeb448 - stable/13 - ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fd61ccfeb448ff77ff84978df68d9c2b025e0091 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, 25 Feb 2021 12:58:29 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fd61ccfeb448ff77ff84978df68d9c2b025e0091 commit fd61ccfeb448ff77ff84978df68d9c2b025e0091 Author: Konstantin Belousov AuthorDate: 2021-02-19 12:37:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:55:18 +0000 ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ() (cherry picked from commit cc9958bf22f1426faf4be8bf492ce69587a9008f) --- sys/ufs/ffs/ffs_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 3b652ea14303..c7a1e2dec15e 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -543,7 +543,7 @@ ffs_reallocblks(ap) * here. Instead we simply fail to reallocate blocks if this * rare condition arises. */ - if (DOINGSOFTDEP(ap->a_vp)) + if (DOINGSUJ(ap->a_vp)) if (softdep_prealloc(ap->a_vp, MNT_NOWAIT) != 0) return (ENOSPC); if (ump->um_fstype == UFS1) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58: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 0A6F656264F; Thu, 25 Feb 2021 12:58: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 4DmXsL6pkgz4gB6; Thu, 25 Feb 2021 12:58: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 DBC1317E91; Thu, 25 Feb 2021 12:58: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 11PCwUfa043906; Thu, 25 Feb 2021 12:58:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwUcI043905; Thu, 25 Feb 2021 12:58:30 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:30 GMT Message-Id: <202102251258.11PCwUcI043905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 94412c2d00d6 - stable/13 - ffs: do not call softdep_prealloc() from UFS_BALLOC() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 94412c2d00d641fc2f0892e4b9b2f598c48c4eaa 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, 25 Feb 2021 12:58:31 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=94412c2d00d641fc2f0892e4b9b2f598c48c4eaa commit 94412c2d00d641fc2f0892e4b9b2f598c48c4eaa Author: Konstantin Belousov AuthorDate: 2021-02-18 14:51:50 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:55:18 +0000 ffs: do not call softdep_prealloc() from UFS_BALLOC() (cherry picked from commit 49831462794690155ce8dbe02679e6d9390f3d7d) --- sys/ufs/ffs/ffs_balloc.c | 5 ----- sys/ufs/ffs/ffs_vnops.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index daa897dfe032..1b53a90a48c4 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -128,8 +128,6 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); /* * If the next write will extend the file into a new block, * and the file is currently composed of a fragment @@ -621,9 +619,6 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); - /* * Check for allocating external data. */ diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 1dfdf5182a42..c00469c4c7e3 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -834,6 +834,11 @@ ffs_write(ap) int blkoffset, error, flags, ioflag, size, xfersize; vp = ap->a_vp; + if (DOINGSUJ(vp)) + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + uio = ap->a_uio; ioflag = ap->a_ioflag; if (ap->a_ioflag & IO_EXT) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58: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 E4250562359; Thu, 25 Feb 2021 12:58: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 4DmXsP1qtJz4gKC; Thu, 25 Feb 2021 12:58: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 1B11717E92; Thu, 25 Feb 2021 12:58: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 11PCwXlD043951; Thu, 25 Feb 2021 12:58:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwXuT043950; Thu, 25 Feb 2021 12:58:33 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:33 GMT Message-Id: <202102251258.11PCwXuT043950@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e2827f8a1345 - stable/13 - ffs_close_ea: do not relock vnode under lock_ea MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e2827f8a13451f9f6409d111b40fcf6c83b119c5 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, 25 Feb 2021 12:58:34 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e2827f8a13451f9f6409d111b40fcf6c83b119c5 commit e2827f8a13451f9f6409d111b40fcf6c83b119c5 Author: Konstantin Belousov AuthorDate: 2021-02-21 10:10:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:55:18 +0000 ffs_close_ea: do not relock vnode under lock_ea (cherry picked from commit 5e198e7646a27412c0541719f7bf1bbc0bd89223) --- sys/ufs/ffs/ffs_vnops.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index f9a6a36d178a..64c72f3d3cc4 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1422,9 +1422,10 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td { struct inode *ip; struct uio luio; - struct iovec liovec; + struct iovec *liovec; struct ufs2_dinode *dp; - int error; + size_t ea_len, tlen; + int error, i, lcnt; ip = VTOI(vp); @@ -1439,18 +1440,31 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td ASSERT_VOP_ELOCKED(vp, "ffs_close_ea commit"); if (cred == NOCRED) cred = vp->v_mount->mnt_cred; - liovec.iov_base = ip->i_ea_area; - liovec.iov_len = ip->i_ea_len; - luio.uio_iov = &liovec; - luio.uio_iovcnt = 1; + + ea_len = MAX(ip->i_ea_len, dp->di_extsize); + for (lcnt = 1, tlen = ea_len - ip->i_ea_len; tlen > 0;) { + tlen -= MIN(ZERO_REGION_SIZE, tlen); + lcnt++; + } + + liovec = __builtin_alloca(lcnt * sizeof(struct iovec)); + luio.uio_iovcnt = lcnt; + + liovec[0].iov_base = ip->i_ea_area; + liovec[0].iov_len = ip->i_ea_len; + for (i = 1, tlen = ea_len; i < lcnt; i++) { + liovec[i].iov_base = __DECONST(void *, zero_region); + liovec[i].iov_len = MIN(ZERO_REGION_SIZE, tlen); + tlen -= liovec[i].iov_len; + } + MPASS(tlen == ip->i_ea_len); + + luio.uio_iov = liovec; luio.uio_offset = 0; - luio.uio_resid = ip->i_ea_len; + luio.uio_resid = ea_len; luio.uio_segflg = UIO_SYSSPACE; luio.uio_rw = UIO_WRITE; luio.uio_td = td; - /* XXX: I'm not happy about truncating to zero size */ - if (ip->i_ea_len < dp->di_extsize) - error = ffs_truncate(vp, 0, IO_EXT, cred); error = ffs_extwrite(vp, &luio, IO_EXT | IO_SYNC, cred); } if (--ip->i_ea_refs == 0) { @@ -1460,6 +1474,9 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td ip->i_ea_error = 0; } ffs_unlock_ea(vp); + + if (commit && error == 0 && ip->i_ea_len == 0) + ffs_truncate(vp, 0, IO_EXT, cred); return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C746656235B; Thu, 25 Feb 2021 12:58:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmXsS2PZtz4fxV; Thu, 25 Feb 2021 12:58:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5BE8917D94; Thu, 25 Feb 2021 12:58:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PCwZ12043991; Thu, 25 Feb 2021 12:58:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwZlI043990; Thu, 25 Feb 2021 12:58:35 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:35 GMT Message-Id: <202102251258.11PCwZlI043990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 66308a13dddc - stable/13 - Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 66308a13dddcf4282521c044ee668c15a638cdd6 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, 25 Feb 2021 12:58:37 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=66308a13dddcf4282521c044ee668c15a638cdd6 commit 66308a13dddcf4282521c044ee668c15a638cdd6 Author: Kirk McKusick AuthorDate: 2021-02-12 05:31:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:56:20 +0000 Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash PR: 253158 (cherry picked from commit 8563de2f2799b2cb6f2f06e3c9dddd48dca2a986) (cherry picked from commit c31480a1f66537e59b02e935a547bcfc76715278) --- sys/ufs/ffs/ffs_snapshot.c | 141 ++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 72c8061917d8..6da84fb46bb0 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -59,6 +59,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include #include @@ -316,21 +319,21 @@ restart: ip = VTOI(vp); devvp = ITODEVVP(ip); /* - * Allocate and copy the last block contents so as to be able - * to set size to that of the filesystem. + * Calculate the size of the filesystem then allocate the block + * immediately following the last block of the filesystem that + * will contain the snapshot list. This operation allows us to + * set the size of the snapshot. */ numblks = howmany(fs->fs_size, fs->fs_frag); - error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)), + error = UFS_BALLOC(vp, lblktosize(fs, (off_t)numblks), fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); if (error) goto out; - ip->i_size = lblktosize(fs, (off_t)numblks); + bawrite(bp); + ip->i_size = lblktosize(fs, (off_t)(numblks + 1)); + vnode_pager_setsize(vp, ip->i_size); DIP_SET(ip, i_size, ip->i_size); UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); - error = readblock(vp, bp, numblks - 1); - bawrite(bp); - if (error != 0) - goto out; /* * Preallocate critical data structures so that we can copy * them in without further allocation after we suspend all @@ -452,23 +455,13 @@ restart: vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (ip->i_effnlink == 0) { error = ENOENT; /* Snapshot file unlinked */ - goto out1; + goto resumefs; } #ifdef DIAGNOSTIC if (collectsnapstats) nanotime(&starttime); #endif - /* The last block might have changed. Copy it again to be sure. */ - error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)), - fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); - if (error != 0) - goto out1; - error = readblock(vp, bp, numblks - 1); - bp->b_flags |= B_VALIDSUSPWRT; - bawrite(bp); - if (error != 0) - goto out1; /* * First, copy all the cylinder group maps that have changed. */ @@ -479,11 +472,11 @@ restart: error = UFS_BALLOC(vp, lfragtosize(fs, cgtod(fs, cg)), fs->fs_bsize, KERNCRED, 0, &nbp); if (error) - goto out1; + goto resumefs; error = cgaccount(cg, vp, nbp, 2); bawrite(nbp); if (error) - goto out1; + goto resumefs; } /* * Grab a copy of the superblock and its summary information. @@ -513,11 +506,7 @@ restart: if ((error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + loc), len, KERNCRED, &bp)) != 0) { brelse(bp); - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; - goto out1; + goto resumefs; } bcopy(bp->b_data, space, (u_int)len); space = (char *)space + len; @@ -539,10 +528,27 @@ restart: * Note that we skip unlinked snapshot files as they will * be handled separately below. * - * We also calculate the needed size for the snapshot list. + * We also calculate the size needed for the snapshot list. + * Initial number of entries is composed of: + * - one for each cylinder group map + * - one for each block used by superblock summary table + * - one for each snapshot inode block + * - one for the superblock + * - one for the snapshot list + * The direct block entries in the snapshot are always + * copied (see reason below). Note that the superblock and + * the first cylinder group will almost always be allocated + * in the direct blocks, but we add the slop for them in case + * they do not end up there. The snapshot list size may get + * expanded by one because of an update of an inode block for + * an unlinked but still open file when it is expunged. + * + * Because the direct block pointers are always copied, they + * are not added to the list. Instead ffs_copyonwrite() + * explicitly checks for them before checking the snapshot list. */ snaplistsize = fs->fs_ncg + howmany(fs->fs_cssize, fs->fs_bsize) + - FSMAXSNAP + 1 /* superblock */ + 1 /* last block */ + 1 /* size */; + FSMAXSNAP + /* superblock */ 1 + /* snaplist */ 1; MNT_ILOCK(mp); mp->mnt_kern_flag &= ~MNTK_SUSPENDED; MNT_IUNLOCK(mp); @@ -624,12 +630,8 @@ loop: VOP_UNLOCK(xvp); vdrop(xvp); if (error) { - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); - goto out1; + goto resumefs; } } /* @@ -637,13 +639,8 @@ loop: */ if (fs->fs_flags & FS_SUJ) { error = softdep_journal_lookup(mp, &xvp); - if (error) { - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; - goto out1; - } + if (error) + goto resumefs; xp = VTOI(xvp); if (I_IS_UFS1(xp)) error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, @@ -694,6 +691,27 @@ loop: sn->sn_listsize = blkp - snapblklist; VI_UNLOCK(devvp); } + /* + * Preallocate all the direct blocks in the snapshot inode so + * that we never have to write the inode itself to commit an + * update to the contents of the snapshot. Note that once + * created, the size of the snapshot will never change, so + * there will never be a need to write the inode except to + * update the non-integrity-critical time fields and + * allocated-block count. + */ + for (blockno = 0; blockno < UFS_NDADDR; blockno++) { + if (DIP(ip, i_db[blockno]) != 0) + continue; + error = UFS_BALLOC(vp, lblktosize(fs, blockno), + fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); + if (error) + goto resumefs; + error = readblock(vp, bp, blockno); + bawrite(bp); + if (error != 0) + goto resumefs; + } /* * Record snapshot inode. Since this is the newest snapshot, * it must be placed at the end of the list. @@ -706,11 +724,16 @@ loop: TAILQ_INSERT_TAIL(&sn->sn_head, ip, i_nextsnap); devvp->v_vflag |= VV_COPYONWRITE; VI_UNLOCK(devvp); +resumefs: ASSERT_VOP_LOCKED(vp, "ffs_snapshot vp"); -out1: - KASSERT((sn != NULL && copy_fs != NULL && error == 0) || - (sn == NULL && copy_fs == NULL && error != 0), - ("email phk@ and mckusick@")); + if (error != 0 && copy_fs != NULL) { + free(copy_fs->fs_csp, M_UFSMNT); + free(copy_fs->fs_si, M_UFSMNT); + free(copy_fs, M_UFSMNT); + copy_fs = NULL; + } + KASSERT(error != 0 || (sn != NULL && copy_fs != NULL), + ("missing snapshot setup parameters")); /* * Resume operation on filesystem. */ @@ -786,7 +809,7 @@ out1: aiov.iov_base = (void *)snapblklist; aiov.iov_len = snaplistsize * sizeof(daddr_t); auio.uio_resid = aiov.iov_len; - auio.uio_offset = ip->i_size; + auio.uio_offset = lblktosize(fs, (off_t)numblks); auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_WRITE; auio.uio_td = td; @@ -835,27 +858,6 @@ out1: VI_UNLOCK(devvp); if (space != NULL) free(space, M_UFSMNT); - /* - * Preallocate all the direct blocks in the snapshot inode so - * that we never have to write the inode itself to commit an - * update to the contents of the snapshot. Note that once - * created, the size of the snapshot will never change, so - * there will never be a need to write the inode except to - * update the non-integrity-critical time fields and - * allocated-block count. - */ - for (blockno = 0; blockno < UFS_NDADDR; blockno++) { - if (DIP(ip, i_db[blockno]) != 0) - continue; - error = UFS_BALLOC(vp, lblktosize(fs, blockno), - fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); - if (error) - break; - error = readblock(vp, bp, blockno); - bawrite(bp); - if (error != 0) - break; - } done: free(copy_fs->fs_csp, M_UFSMNT); free(copy_fs->fs_si, M_UFSMNT); @@ -1573,7 +1575,8 @@ mapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype) blkno = *oldblkp; if (blkno == 0 || blkno == BLK_NOCOPY) continue; - if (acctit && expungetype == BLK_SNAP && blkno != BLK_SNAP) + if (acctit && expungetype == BLK_SNAP && blkno != BLK_SNAP && + lblkno >= UFS_NDADDR) *ip->i_snapblklist++ = lblkno; if (blkno == BLK_SNAP) blkno = blkstofrags(fs, lblkno); @@ -2320,6 +2323,10 @@ ffs_copyonwrite(devvp, bp) ip = TAILQ_FIRST(&sn->sn_head); fs = ITOFS(ip); lbn = fragstoblks(fs, dbtofsb(fs, bp->b_blkno)); + if (lbn < UFS_NDADDR) { + VI_UNLOCK(devvp); + return (0); /* Direct blocks are always copied */ + } snapblklist = sn->sn_blklist; upper = sn->sn_listsize - 1; lower = 1; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58: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 A4F1256245E; Thu, 25 Feb 2021 12:58: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 4DmXsN1Hl2z4gPp; Thu, 25 Feb 2021 12:58:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 143B71800F; Thu, 25 Feb 2021 12:58:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PCwVqC043929; Thu, 25 Feb 2021 12:58:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwVe0043928; Thu, 25 Feb 2021 12:58:31 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:31 GMT Message-Id: <202102251258.11PCwVe0043928@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 120c4f6405be - stable/13 - ffs_vnops.c: style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 120c4f6405bede7dc5eefe7e63d7acec22fa1d2f 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, 25 Feb 2021 12:58:34 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=120c4f6405bede7dc5eefe7e63d7acec22fa1d2f commit 120c4f6405bede7dc5eefe7e63d7acec22fa1d2f Author: Konstantin Belousov AuthorDate: 2021-02-20 17:01:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:55:18 +0000 ffs_vnops.c: style (cherry picked from commit c6d68ca842a3f5b6814cdd5c87e406bad579b792) --- sys/ufs/ffs/ffs_vnops.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index c00469c4c7e3..f9a6a36d178a 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1423,8 +1423,8 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td struct inode *ip; struct uio luio; struct iovec liovec; - int error; struct ufs2_dinode *dp; + int error; ip = VTOI(vp); @@ -1527,14 +1527,15 @@ struct vop_closeextattr_args { }; */ { + struct vnode *vp; - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + vp = ap->a_vp; + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - - if (ap->a_commit && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) + if (ap->a_commit && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) return (EROFS); - return (ffs_close_ea(ap->a_vp, ap->a_commit, ap->a_cred, ap->a_td)); + return (ffs_close_ea(vp, ap->a_commit, ap->a_cred, ap->a_td)); } /* @@ -1552,6 +1553,7 @@ vop_deleteextattr { }; */ { + struct vnode *vp; struct inode *ip; struct extattr *eap; uint32_t ul; @@ -1559,18 +1561,17 @@ vop_deleteextattr { u_char *eae; void *tmp; - ip = VTOI(ap->a_vp); + vp = ap->a_vp; + ip = VTOI(vp); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - if (strlen(ap->a_name) == 0) return (EINVAL); - - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, + error = extattr_check_cred(vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { /* @@ -1582,7 +1583,7 @@ vop_deleteextattr { return (error); } - error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td); + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1596,7 +1597,7 @@ vop_deleteextattr { if (olen == -1) { /* delete but nonexistent */ free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); return (ENOATTR); } ul = eap->ea_length; @@ -1608,7 +1609,7 @@ vop_deleteextattr { ip->i_ea_area = eae; ip->i_ea_len = easize; free(tmp, M_TEMP); - error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td); + error = ffs_close_ea(vp, 1, ap->a_cred, ap->a_td); return (error); } @@ -1741,6 +1742,7 @@ vop_setextattr { }; */ { + struct vnode *vp; struct inode *ip; struct fs *fs; struct extattr *eap; @@ -1750,12 +1752,12 @@ vop_setextattr { u_char *eae; void *tmp; - ip = VTOI(ap->a_vp); + vp = ap->a_vp; + ip = VTOI(vp); fs = ITOFS(ip); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - if (strlen(ap->a_name) == 0) return (EINVAL); @@ -1763,14 +1765,14 @@ vop_setextattr { if (ap->a_uio == NULL) return (EOPNOTSUPP); - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); ealen = ap->a_uio->uio_resid; if (ealen < 0 || ealen > lblktosize(fs, UFS_NXADDR)) return (EINVAL); - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, + error = extattr_check_cred(vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { /* @@ -1782,7 +1784,7 @@ vop_setextattr { return (error); } - error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td); + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1819,7 +1821,7 @@ vop_setextattr { } if (easize > lblktosize(fs, UFS_NXADDR)) { free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) ip->i_ea_error = ENOSPC; return (ENOSPC); @@ -1833,7 +1835,7 @@ vop_setextattr { error = uiomove(EXTATTR_CONTENT(eap), ealen, ap->a_uio); if (error) { free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) ip->i_ea_error = error; return (error); @@ -1844,7 +1846,7 @@ vop_setextattr { ip->i_ea_area = eae; ip->i_ea_len = easize; free(tmp, M_TEMP); - error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td); + error = ffs_close_ea(vp, 1, ap->a_cred, ap->a_td); return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 12:58: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 E46A656227F; Thu, 25 Feb 2021 12:58: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 4DmXsQ3YQCz4gRq; Thu, 25 Feb 2021 12:58: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 38BFA1808B; Thu, 25 Feb 2021 12:58: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 11PCwYu8043969; Thu, 25 Feb 2021 12:58:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PCwYWX043968; Thu, 25 Feb 2021 12:58:34 GMT (envelope-from git) Date: Thu, 25 Feb 2021 12:58:34 GMT Message-Id: <202102251258.11PCwYWX043968@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ffa424772e9f - stable/13 - Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ffa424772e9f679c59610e4a6173cfab8d0b4943 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, 25 Feb 2021 12:58:36 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ffa424772e9f679c59610e4a6173cfab8d0b4943 commit ffa424772e9f679c59610e4a6173cfab8d0b4943 Author: Konstantin Belousov AuthorDate: 2021-02-21 10:11:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 12:55:18 +0000 Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing (cherry picked from commit 6f30ac9995ff662a2fee5eda4cd87dd0f0e337ba) --- sys/ufs/ffs/ffs_vnops.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 64c72f3d3cc4..af03b369a280 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1552,6 +1552,12 @@ struct vop_closeextattr_args { if (ap->a_commit && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) return (EROFS); + if (ap->a_commit && DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_closeextattr commit"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } return (ffs_close_ea(vp, ap->a_commit, ap->a_cred, ap->a_td)); } @@ -1600,6 +1606,13 @@ vop_deleteextattr { return (error); } + if (DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_deleteextattr"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1801,6 +1814,13 @@ vop_setextattr { return (error); } + if (DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_deleteextattr"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 14:04: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 AEB4C5641B3; Thu, 25 Feb 2021 14:04: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 4DmZKd4PxTz4m9h; Thu, 25 Feb 2021 14:04: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 85E3518AD4; Thu, 25 Feb 2021 14:04:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PE4boJ036541; Thu, 25 Feb 2021 14:04:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PE4bu0036540; Thu, 25 Feb 2021 14:04:37 GMT (envelope-from git) Date: Thu, 25 Feb 2021 14:04:37 GMT Message-Id: <202102251404.11PE4bu0036540@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: 0486986ad81d - stable/13 - vm_kern: Avoid sign extension in the KVA_QUANTUM definition 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: 0486986ad81dbbfca291acf5b15f94d67d8a61bd 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, 25 Feb 2021 14:04:37 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0486986ad81dbbfca291acf5b15f94d67d8a61bd commit 0486986ad81dbbfca291acf5b15f94d67d8a61bd Author: Mark Johnston AuthorDate: 2021-02-22 20:50:09 +0000 Commit: Mark Johnston CommitDate: 2021-02-25 13:56:54 +0000 vm_kern: Avoid sign extension in the KVA_QUANTUM definition Otherwise, on a powerpc64 NUMA system with hashed page tables, the first-level superpage reservation size is large enough that the value of the kernel KVA arena import quantum, KVA_NUMA_IMPORT_QUANTUM, is negative and gets sign-extended when passed to vmem_set_import(). This results in a boot-time hang on such platforms. Reported by: bdragon (cherry picked from commit 23e875fd97fb9f17b3f5dc2b26082f25e1a86b6f) --- sys/vm/vm_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index f1704f834157..0677d901d408 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -127,7 +127,7 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLAG_RD, /* On non-superpage architectures we want large import sizes. */ #define KVA_QUANTUM_SHIFT (8 + PAGE_SHIFT) #endif -#define KVA_QUANTUM (1 << KVA_QUANTUM_SHIFT) +#define KVA_QUANTUM (1ul << KVA_QUANTUM_SHIFT) #define KVA_NUMA_IMPORT_QUANTUM (KVA_QUANTUM * 128) extern void uma_startup2(void); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 14:04:39 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 1FE595641B4; Thu, 25 Feb 2021 14:04:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmZKf5lT3z4lrh; Thu, 25 Feb 2021 14:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3D5318E0D; Thu, 25 Feb 2021 14:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PE4cFN036559; Thu, 25 Feb 2021 14:04:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PE4cnb036558; Thu, 25 Feb 2021 14:04:38 GMT (envelope-from git) Date: Thu, 25 Feb 2021 14:04:38 GMT Message-Id: <202102251404.11PE4cnb036558@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: e2c9871f6a7b - stable/13 - arm64: Include NUMA locality info in the CPU topology 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: e2c9871f6a7ba8a14b2c377a860cfaf1adcdff83 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, 25 Feb 2021 14:04:39 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e2c9871f6a7ba8a14b2c377a860cfaf1adcdff83 commit e2c9871f6a7ba8a14b2c377a860cfaf1adcdff83 Author: Mark Johnston AuthorDate: 2021-02-18 15:50:57 +0000 Commit: Mark Johnston CommitDate: 2021-02-25 13:57:08 +0000 arm64: Include NUMA locality info in the CPU topology The scheduler uses this topology to try and preserve locality when migrating threads between CPUs and when performing work stealing. Ensure that on NUMA systems it will at least take the NUMA topology into account. Reviewed by: mmel Submitted by: Klara, Inc. Sponsored by: Ampere Computing Differential Revision: https://reviews.freebsd.org/D28579 (cherry picked from commit 17d0f830dddf38724068f4139b6bef9a5dab70c5) --- sys/arm64/arm64/mp_machdep.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 8f1118d36bf5..8d5d82879571 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -437,8 +437,35 @@ ipi_stop(void *dummy __unused) struct cpu_group * cpu_topo(void) { + struct cpu_group *dom, *root; + int i; + + root = smp_topo_alloc(1); + dom = smp_topo_alloc(vm_ndomains); + + root->cg_parent = NULL; + root->cg_child = dom; + CPU_COPY(&all_cpus, &root->cg_mask); + root->cg_count = mp_ncpus; + root->cg_children = vm_ndomains; + root->cg_level = CG_SHARE_NONE; + root->cg_flags = 0; + + /* + * Redundant layers will be collapsed by the caller so we don't need a + * special case for a single domain. + */ + for (i = 0; i < vm_ndomains; i++, dom++) { + dom->cg_parent = root; + dom->cg_child = NULL; + CPU_COPY(&cpuset_domain[i], &dom->cg_mask); + dom->cg_count = CPU_COUNT(&dom->cg_mask); + dom->cg_children = 0; + dom->cg_level = CG_SHARE_L3; + dom->cg_flags = 0; + } - return (smp_topo_none()); + return (root); } /* Determine if we running MP machine */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 15:54:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A5E85673E0; Thu, 25 Feb 2021 15:54:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmcmJ6G1wz4vr9; Thu, 25 Feb 2021 15:54: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 AF00E1A074; Thu, 25 Feb 2021 15:54: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 11PFsOvg080924; Thu, 25 Feb 2021 15:54:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PFsOGj080923; Thu, 25 Feb 2021 15:54:24 GMT (envelope-from git) Date: Thu, 25 Feb 2021 15:54:24 GMT Message-Id: <202102251554.11PFsOGj080923@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: 5ad3a9988cc8 - releng/13.0 - vm_kern: Avoid sign extension in the KVA_QUANTUM definition 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 5ad3a9988cc89e41f4c471d7ca5d8b19d216144f 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, 25 Feb 2021 15:54:25 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5ad3a9988cc89e41f4c471d7ca5d8b19d216144f commit 5ad3a9988cc89e41f4c471d7ca5d8b19d216144f Author: Mark Johnston AuthorDate: 2021-02-22 20:50:09 +0000 Commit: Mark Johnston CommitDate: 2021-02-25 15:54:17 +0000 vm_kern: Avoid sign extension in the KVA_QUANTUM definition Otherwise, on a powerpc64 NUMA system with hashed page tables, the first-level superpage reservation size is large enough that the value of the kernel KVA arena import quantum, KVA_NUMA_IMPORT_QUANTUM, is negative and gets sign-extended when passed to vmem_set_import(). This results in a boot-time hang on such platforms. Approved by: re (gjb) Reported by: bdragon (cherry picked from commit 23e875fd97fb9f17b3f5dc2b26082f25e1a86b6f) (cherry picked from commit 0486986ad81dbbfca291acf5b15f94d67d8a61bd) --- sys/vm/vm_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index f1704f834157..0677d901d408 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -127,7 +127,7 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLAG_RD, /* On non-superpage architectures we want large import sizes. */ #define KVA_QUANTUM_SHIFT (8 + PAGE_SHIFT) #endif -#define KVA_QUANTUM (1 << KVA_QUANTUM_SHIFT) +#define KVA_QUANTUM (1ul << KVA_QUANTUM_SHIFT) #define KVA_NUMA_IMPORT_QUANTUM (KVA_QUANTUM * 128) extern void uma_startup2(void); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 16:05:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C971C567D0A; Thu, 25 Feb 2021 16:05:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dmd1G5PDNz4wDv; Thu, 25 Feb 2021 16:05:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AC6591A53A; Thu, 25 Feb 2021 16:05:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PG5cUO094927; Thu, 25 Feb 2021 16:05:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PG5cGZ094926; Thu, 25 Feb 2021 16:05:38 GMT (envelope-from git) Date: Thu, 25 Feb 2021 16:05:38 GMT Message-Id: <202102251605.11PG5cGZ094926@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: e680f3c0bd2b - releng/13.0 - loader: autoload_font will hung loader when there is no local console MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: e680f3c0bd2b6c6d3c76588c7693294d49fa965b 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, 25 Feb 2021 16:05:38 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=e680f3c0bd2b6c6d3c76588c7693294d49fa965b commit e680f3c0bd2b6c6d3c76588c7693294d49fa965b Author: Toomas Soome AuthorDate: 2021-02-21 10:32:18 +0000 Commit: Toomas Soome CommitDate: 2021-02-25 16:05:24 +0000 loader: autoload_font will hung loader when there is no local console If we start with console set to comconsole, the local console (vidconsole, efi) is never initialized and attempt to use the data can render the loader hung. (cherry picked from commit 61c50cbc096d28e44cb8b627e524ae58158c423a) Reported by: Kamigishi Rei Approved by: re (gjb) --- stand/efi/libefi/efi_console.c | 3 +++ stand/i386/libi386/vidconsole.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index 7024f9c8b2f2..3cbd121c41da 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -886,6 +886,9 @@ cons_update_mode(bool use_gfx_mode) EFI_STATUS status; char env[10], *ptr; + if (!efi_started) + return (false); + /* * Despite the use_gfx_mode, we want to make sure we call * efi_find_framebuffer(). This will populate the fb data, diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c index f94ed2d26712..b933a7807687 100644 --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -53,7 +53,7 @@ static int vidc_getchar(void); static int vidc_ischar(void); static void cons_draw_frame(teken_attr_t *); -static int vidc_started; +static bool vidc_started; static uint16_t *vgatext; static tf_bell_t vidc_cons_bell; @@ -877,6 +877,10 @@ cons_update_mode(bool use_gfx_mode) char env[10], *ptr; int format, roff, goff, boff; + /* vidc_init() is not called yet. */ + if (!vidc_started) + return (false); + gfx_state.tg_tp.tp_row = TEXT_ROWS; gfx_state.tg_tp.tp_col = TEXT_COLS; @@ -996,7 +1000,7 @@ vidc_init(int arg) if (vidc_started && arg == 0) return (0); - vidc_started = 1; + vidc_started = true; vbe_init(); /* From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 16:20: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 283E2567F62; Thu, 25 Feb 2021 16:20: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 4DmdL40gCdz4xX7; Thu, 25 Feb 2021 16:20: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 09E9D1A7EE; Thu, 25 Feb 2021 16:20: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 11PGKBtZ012128; Thu, 25 Feb 2021 16:20:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PGKBeA012118; Thu, 25 Feb 2021 16:20:11 GMT (envelope-from git) Date: Thu, 25 Feb 2021 16:20:11 GMT Message-Id: <202102251620.11PGKBeA012118@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: ee0b7e05e72c - releng/13.0 - zfs: fix panic if scrubbing after removing a slog device 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ee0b7e05e72c8820441faff29a9df99b47aed6a0 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, 25 Feb 2021 16:20:12 -0000 The branch releng/13.0 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=ee0b7e05e72c8820441faff29a9df99b47aed6a0 commit ee0b7e05e72c8820441faff29a9df99b47aed6a0 Author: Martin Matuska AuthorDate: 2021-02-22 17:05:07 +0000 Commit: Martin Matuska CommitDate: 2021-02-25 16:19:49 +0000 zfs: fix panic if scrubbing after removing a slog device From openzfs-master 11f2e9a4 commit message: vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL This prevents a panic after a SLOG add/removal on the root pool followed by a zpool scrub. When a SLOG is removed, a hole takes its place - the vdev_ops for a hole is vdev_hole_ops, which defines the handler functions of vdev_op_hold and vdev_op_rele as NULL. Patch Author: Patrick Mooney Obtained from: openzfs/zfs@11f2e9a491baa2ae3fc00f6b8b892fa91a852ca1 PR: 252396 Approved by: re (gjb) (cherry picked from commit 64649f0285424435634c2dfd39f49536fc2b50dd) --- sys/contrib/openzfs/module/zfs/vdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c index 7ffe924212da..5b83f8c22fed 100644 --- a/sys/contrib/openzfs/module/zfs/vdev.c +++ b/sys/contrib/openzfs/module/zfs/vdev.c @@ -2393,7 +2393,7 @@ vdev_hold(vdev_t *vd) for (int c = 0; c < vd->vdev_children; c++) vdev_hold(vd->vdev_child[c]); - if (vd->vdev_ops->vdev_op_leaf) + if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_hold != NULL) vd->vdev_ops->vdev_op_hold(vd); } @@ -2404,7 +2404,7 @@ vdev_rele(vdev_t *vd) for (int c = 0; c < vd->vdev_children; c++) vdev_rele(vd->vdev_child[c]); - if (vd->vdev_ops->vdev_op_leaf) + if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_rele != NULL) vd->vdev_ops->vdev_op_rele(vd); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 16:20: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 C4FFE5682A5; Thu, 25 Feb 2021 16:20: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 4DmdLh5BVSz4xVV; Thu, 25 Feb 2021 16:20: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 A56191A9E3; Thu, 25 Feb 2021 16:20: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 11PGKiN0017141; Thu, 25 Feb 2021 16:20:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PGKiGM017140; Thu, 25 Feb 2021 16:20:44 GMT (envelope-from git) Date: Thu, 25 Feb 2021 16:20:44 GMT Message-Id: <202102251620.11PGKiGM017140@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: 442719c0c6de - releng/13.0 - zfs: disable use of hardware crypto offload drivers 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 442719c0c6de93051d4bf9820420e9863ed3de53 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, 25 Feb 2021 16:20:44 -0000 The branch releng/13.0 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=442719c0c6de93051d4bf9820420e9863ed3de53 commit 442719c0c6de93051d4bf9820420e9863ed3de53 Author: Martin Matuska AuthorDate: 2021-02-22 17:37:47 +0000 Commit: Martin Matuska CommitDate: 2021-02-25 16:20:20 +0000 zfs: disable use of hardware crypto offload drivers From openzfs-master e7adccf7f commit message: First, the crypto request completion handler contains a bug in that it fails to reset fs_done correctly after the request is completed. This is only a problem for asynchronous drivers. Second, some hardware drivers have input constraints which ZFS does not satisfy. For instance, ccp(4) apparently requires the AAD length for AES-GCM to be a multiple of the cipher block size, and with qat(4) the AES-GCM AAD length may not be longer than 240 bytes. FreeBSD's generic crypto framework doesn't have a mechanism to automatically fall back to a software implementation if a hardware driver cannot process a request, and ZFS does not tolerate such errors. Patch Author: Mark Johnston Obtained from: openzfs/zfs@e7adccf7f537a4d07281a2b74b360154bae367bc PR: 252981, 253595 Approved by: re (gjb) (cherry picked from commit 940415f20a784156ec0e247989796385896f32a8) --- sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c index b86ffc59a21d..0a7241699842 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c @@ -293,8 +293,19 @@ freebsd_crypt_newsession(freebsd_crypt_session_t *sessp, error = ENOTSUP; goto bad; } - error = crypto_newsession(&sessp->fs_sid, &csp, - CRYPTOCAP_F_HARDWARE | CRYPTOCAP_F_SOFTWARE); + + /* + * Disable the use of hardware drivers on FreeBSD 13 and later since + * common crypto offload drivers impose constraints on AES-GCM AAD + * lengths that make them unusable for ZFS, and we currently do not have + * a mechanism to fall back to a software driver for requests not + * handled by a hardware driver. + * + * On 12 we continue to permit the use of hardware drivers since + * CPU-accelerated drivers such as aesni(4) register themselves as + * hardware drivers. + */ + error = crypto_newsession(&sessp->fs_sid, &csp, CRYPTOCAP_F_SOFTWARE); mtx_init(&sessp->fs_lock, "FreeBSD Cryptographic Session Lock", NULL, MTX_DEF); crypt_sessions++; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 16:26:39 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 BAAA0568CA1; Thu, 25 Feb 2021 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmdTW4yxlz4yXk; Thu, 25 Feb 2021 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9DBF01AB8C; Thu, 25 Feb 2021 16:26:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PGQdNu021201; Thu, 25 Feb 2021 16:26:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PGQd5D021200; Thu, 25 Feb 2021 16:26:39 GMT (envelope-from git) Date: Thu, 25 Feb 2021 16:26:39 GMT Message-Id: <202102251626.11PGQd5D021200@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: 3d66df702668 - releng/13.0 - zfs: restore FreeBSD resource usage accounting 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 3d66df70266822405db0f5eda235e0bca1ba05ec 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, 25 Feb 2021 16:26:39 -0000 The branch releng/13.0 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=3d66df70266822405db0f5eda235e0bca1ba05ec commit 3d66df70266822405db0f5eda235e0bca1ba05ec Author: Martin Matuska AuthorDate: 2021-02-22 20:57:22 +0000 Commit: Martin Matuska CommitDate: 2021-02-25 16:20:53 +0000 zfs: restore FreeBSD resource usage accounting With the switch to OpenZFS 2.0 the platform-dependent resource usage accounting code got missing. Patch author: Ryan Moeller Obtained from: openzfs/zfs@64e0fe14fff465604952d576051ca80c2f1be898 Approved by: re (gjb) (cherry picked from commit 21269625733f591c998f7d26790179e922ffbde0) --- cddl/lib/libzpool/Makefile | 1 + sys/conf/files | 1 + sys/contrib/openzfs/include/sys/Makefile.am | 1 + sys/contrib/openzfs/include/sys/zfs_racct.h | 37 +++++++++++++++ sys/contrib/openzfs/lib/libzpool/Makefile.am | 1 + sys/contrib/openzfs/module/Makefile.bsd | 1 + .../openzfs/module/os/freebsd/zfs/zfs_racct.c | 55 ++++++++++++++++++++++ .../openzfs/module/os/linux/zfs/Makefile.in | 1 + .../openzfs/module/os/linux/zfs/zfs_racct.c | 36 ++++++++++++++ sys/contrib/openzfs/module/zfs/arc.c | 2 + sys/contrib/openzfs/module/zfs/dmu.c | 5 ++ sys/modules/zfs/Makefile | 1 + 12 files changed, 142 insertions(+) diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index 0e2cc9456faa..2cb1b0446ade 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -161,6 +161,7 @@ KERNEL_C = \ zfs_debug.c \ zfs_fm.c \ zfs_fuid.c \ + zfs_racct.c \ zfs_sa.c \ zfs_znode.c \ zfs_ratelimit.c \ diff --git a/sys/conf/files b/sys/conf/files index f0bf574b3236..1c52f16ff2e1 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -217,6 +217,7 @@ contrib/openzfs/module/os/freebsd/zfs/zfs_dir.c optional zfs compile-with "${ZF contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_ioctl_compat.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_ioctl_os.c optional zfs compile-with "${ZFS_C}" +contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c optional zfs compile-with "${ZFS_C}" diff --git a/sys/contrib/openzfs/include/sys/Makefile.am b/sys/contrib/openzfs/include/sys/Makefile.am index c3ebf17b5288..385c82c926ae 100644 --- a/sys/contrib/openzfs/include/sys/Makefile.am +++ b/sys/contrib/openzfs/include/sys/Makefile.am @@ -111,6 +111,7 @@ COMMON_H = \ zfs_fuid.h \ zfs_project.h \ zfs_quota.h \ + zfs_racct.h \ zfs_ratelimit.h \ zfs_refcount.h \ zfs_rlock.h \ diff --git a/sys/contrib/openzfs/include/sys/zfs_racct.h b/sys/contrib/openzfs/include/sys/zfs_racct.h new file mode 100644 index 000000000000..cfcdd336ea42 --- /dev/null +++ b/sys/contrib/openzfs/include/sys/zfs_racct.h @@ -0,0 +1,37 @@ +/* + * 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 + */ + +/* + * Portions Copyright 2021 iXsystems, Inc. + */ + +#ifndef _SYS_ZFS_RACCT_H +#define _SYS_ZFS_RACCT_H + +#include + +/* + * Platform-dependent resource accounting hooks + */ +void zfs_racct_read(uint64_t size, uint64_t iops); +void zfs_racct_write(uint64_t size, uint64_t iops); + +#endif /* _SYS_ZFS_RACCT_H */ diff --git a/sys/contrib/openzfs/lib/libzpool/Makefile.am b/sys/contrib/openzfs/lib/libzpool/Makefile.am index 7aa7e80985aa..b66e933657ab 100644 --- a/sys/contrib/openzfs/lib/libzpool/Makefile.am +++ b/sys/contrib/openzfs/lib/libzpool/Makefile.am @@ -163,6 +163,7 @@ KERNEL_C = \ zfs_debug.c \ zfs_fm.c \ zfs_fuid.c \ + zfs_racct.c \ zfs_sa.c \ zfs_znode.c \ zfs_ratelimit.c \ diff --git a/sys/contrib/openzfs/module/Makefile.bsd b/sys/contrib/openzfs/module/Makefile.bsd index e7cddcc5bb5e..8aa4ed22275e 100644 --- a/sys/contrib/openzfs/module/Makefile.bsd +++ b/sys/contrib/openzfs/module/Makefile.bsd @@ -153,6 +153,7 @@ SRCS+= abd_os.c \ zfs_dir.c \ zfs_ioctl_compat.c \ zfs_ioctl_os.c \ + zfs_racct.c \ zfs_vfsops.c \ zfs_vnops_os.c \ zfs_znode.c \ diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c new file mode 100644 index 000000000000..b46cc046268e --- /dev/null +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_racct.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 iXsystems, Inc. + * + * 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 +#include + +void +zfs_racct_read(uint64_t size, uint64_t iops) +{ + curthread->td_ru.ru_inblock += iops; +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_force(curproc, RACCT_READBPS, size); + racct_add_force(curproc, RACCT_READIOPS, iops); + PROC_UNLOCK(curproc); + } +#endif /* RACCT */ +} + +void +zfs_racct_write(uint64_t size, uint64_t iops) +{ + curthread->td_ru.ru_oublock += iops; +#ifdef RACCT + if (racct_enable) { + PROC_LOCK(curproc); + racct_add_force(curproc, RACCT_WRITEBPS, size); + racct_add_force(curproc, RACCT_WRITEIOPS, iops); + PROC_UNLOCK(curproc); + } +#endif /* RACCT */ +} diff --git a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in b/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in index 75bec52c94e2..fa990776db83 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in +++ b/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in @@ -22,6 +22,7 @@ $(MODULE)-objs += ../os/linux/zfs/zfs_debug.o $(MODULE)-objs += ../os/linux/zfs/zfs_dir.o $(MODULE)-objs += ../os/linux/zfs/zfs_file_os.o $(MODULE)-objs += ../os/linux/zfs/zfs_ioctl_os.o +$(MODULE)-objs += ../os/linux/zfs/zfs_racct.o $(MODULE)-objs += ../os/linux/zfs/zfs_sysfs.o $(MODULE)-objs += ../os/linux/zfs/zfs_uio.o $(MODULE)-objs += ../os/linux/zfs/zfs_vfsops.o diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c new file mode 100644 index 000000000000..7897e0f9edc1 --- /dev/null +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 iXsystems, Inc. + * + * 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 + +void +zfs_racct_read(uint64_t size, uint64_t iops) +{ +} + +void +zfs_racct_write(uint64_t size, uint64_t iops) +{ +} diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index fecc752e16ff..b01ccd13a0db 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -308,6 +308,7 @@ #include #include #include +#include #include #ifndef _KERNEL @@ -6296,6 +6297,7 @@ top: ARCSTAT_CONDSTAT(!HDR_PREFETCH(hdr), demand, prefetch, !HDR_ISTYPE_METADATA(hdr), data, metadata, misses); + zfs_racct_read(size, 1); } /* Check if the spa even has l2 configured */ diff --git a/sys/contrib/openzfs/module/zfs/dmu.c b/sys/contrib/openzfs/module/zfs/dmu.c index a02f43df13fd..5d6e98d245da 100644 --- a/sys/contrib/openzfs/module/zfs/dmu.c +++ b/sys/contrib/openzfs/module/zfs/dmu.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #ifdef _KERNEL #include @@ -551,6 +552,9 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, dbp[i] = &db->db; } + if (!read) + zfs_racct_write(length, nblks); + if ((flags & DMU_READ_NO_PREFETCH) == 0 && DNODE_META_IS_CACHEABLE(dn) && length <= zfetch_array_rd_sz) { dmu_zfetch(&dn->dn_zfetch, blkid, nblks, @@ -1448,6 +1452,7 @@ dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, arc_buf_t *buf, * same size as the dbuf. */ if (offset == db->db.db_offset && blksz == db->db.db_size) { + zfs_racct_write(blksz, 1); dbuf_assign_arcbuf(db, buf, tx); dbuf_rele(db, FTAG); } else { diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile index e4b92db764ef..7050a40758a3 100644 --- a/sys/modules/zfs/Makefile +++ b/sys/modules/zfs/Makefile @@ -126,6 +126,7 @@ SRCS+= abd_os.c \ zfs_ioctl_compat.c \ zfs_ioctl_os.c \ zfs_log.c \ + zfs_racct.c \ zfs_replay.c \ zfs_vfsops.c \ zfs_vnops_os.c \ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 16:48: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 9281B569631; Thu, 25 Feb 2021 16:48: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 4Dmdyl3pTHz51Dt; Thu, 25 Feb 2021 16:48: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 756891B055; Thu, 25 Feb 2021 16:48: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 11PGmVs2047997; Thu, 25 Feb 2021 16:48:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PGmV7v047996; Thu, 25 Feb 2021 16:48:31 GMT (envelope-from git) Date: Thu, 25 Feb 2021 16:48:31 GMT Message-Id: <202102251648.11PGmV7v047996@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: 8c3fa20b9dd8 - stable/12 - Skip the vm.pmap.kernel_maps sysctl by default. 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: 8c3fa20b9dd81740a18184d205bf8bdc34ba5373 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, 25 Feb 2021 16:48:31 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8c3fa20b9dd81740a18184d205bf8bdc34ba5373 commit 8c3fa20b9dd81740a18184d205bf8bdc34ba5373 Author: John Baldwin AuthorDate: 2020-12-18 20:41:23 +0000 Commit: Mark Johnston CommitDate: 2021-02-25 16:42:30 +0000 Skip the vm.pmap.kernel_maps sysctl by default. This sysctl node can generate very verbose output, so don't trigger it for sysctl -a or sysctl vm.pmap. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D27504 (cherry picked from commit 1dce7d9e7eefead038610df6a8d6c86a0fdbebb8) --- sys/amd64/amd64/pmap.c | 2 +- sys/arm64/arm64/pmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 4a4c50385ca2..876a77902eea 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -10412,7 +10412,7 @@ restart: return (error); } SYSCTL_OID(_vm_pmap, OID_AUTO, kernel_maps, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_SKIP, NULL, 0, sysctl_kmaps, "A", "Dump kernel address layout"); diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index e18e13701203..d74479a15ab0 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -6169,6 +6169,6 @@ sysctl_kmaps(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_OID(_vm_pmap, OID_AUTO, kernel_maps, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_SKIP, NULL, 0, sysctl_kmaps, "A", "Dump kernel address layout"); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 17:03: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 E1CCE569987; Thu, 25 Feb 2021 17:03: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 4DmfHT5vS1z5247; Thu, 25 Feb 2021 17:03: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 BD6A61B498; Thu, 25 Feb 2021 17:03: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 11PH31Sf074582; Thu, 25 Feb 2021 17:03:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PH31Yk074581; Thu, 25 Feb 2021 17:03:01 GMT (envelope-from git) Date: Thu, 25 Feb 2021 17:03:01 GMT Message-Id: <202102251703.11PH31Yk074581@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: d6cb4c5669da - releng/13.0 - cxgb(4): Rework my commit 9dc7c250. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: d6cb4c5669da4f5a904db15963766930ee92af6d 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, 25 Feb 2021 17:03:01 -0000 The branch releng/13.0 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=d6cb4c5669da4f5a904db15963766930ee92af6d commit d6cb4c5669da4f5a904db15963766930ee92af6d Author: Alexander Motin AuthorDate: 2021-02-22 22:21:05 +0000 Commit: Alexander Motin CommitDate: 2021-02-25 17:02:34 +0000 cxgb(4): Rework my commit 9dc7c250. The previous implementation was reported to try to coalesce packets in situations when it should not, that resulted in assertion later. This implementation better checks the first packet of the chain for the coallescing elligibility. Approved by: re (gjb@) (cherry picked from commit d510bf133d045d6c83742aeda6949bec150f6cbf) (cherry picked from commit 1f3cff343b451d9fc9c10f4f8c4b416ed5eae23f) --- sys/dev/cxgb/cxgb_sge.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index 491d1a751f4a..f13d2f03180c 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -312,20 +312,22 @@ set_wr_hdr(struct work_request_hdr *wrp, uint32_t wr_hi, uint32_t wr_lo) struct coalesce_info { int count; int nbytes; + int noncoal; }; static int coalesce_check(struct mbuf *m, void *arg) { struct coalesce_info *ci = arg; - int *count = &ci->count; - int *nbytes = &ci->nbytes; - - if ((*nbytes == 0) || ((*nbytes + m->m_len <= 10500) && - (*count < 7) && (m->m_next == NULL) && - ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len <= PAGE_SIZE))) { - *count += 1; - *nbytes += m->m_len; + + if ((m->m_next != NULL) || + ((mtod(m, vm_offset_t) & PAGE_MASK) + m->m_len > PAGE_SIZE)) + ci->noncoal = 1; + + if ((ci->count == 0) || (ci->noncoal == 0 && (ci->count < 7) && + (ci->nbytes + m->m_len <= 10500))) { + ci->count++; + ci->nbytes += m->m_len; return (1); } return (0); @@ -342,7 +344,7 @@ cxgb_dequeue(struct sge_qset *qs) return TXQ_RING_DEQUEUE(qs); m_head = m_tail = NULL; - ci.count = ci.nbytes = 0; + ci.count = ci.nbytes = ci.noncoal = 0; do { m = TXQ_RING_DEQUEUE_COND(qs, coalesce_check, &ci); if (m_head == NULL) { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 18:56: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 6F7F656CA7F; Thu, 25 Feb 2021 18:56: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 4Dmhp42lC6z3Dy4; Thu, 25 Feb 2021 18:56: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 513D21CB15; Thu, 25 Feb 2021 18:56: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 11PIuCsw020720; Thu, 25 Feb 2021 18:56:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PIuCl7020719; Thu, 25 Feb 2021 18:56:12 GMT (envelope-from git) Date: Thu, 25 Feb 2021 18:56:12 GMT Message-Id: <202102251856.11PIuCl7020719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: cf9829d98dc7 - stable/13 - automount(8): fix absolute path when creating a mountpoint MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cf9829d98dc771f9ca0696e493dc3bb635999536 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, 25 Feb 2021 18:56:12 -0000 The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=cf9829d98dc771f9ca0696e493dc3bb635999536 commit cf9829d98dc771f9ca0696e493dc3bb635999536 Author: Robert Wing AuthorDate: 2021-02-17 09:22:23 +0000 Commit: Robert Wing CommitDate: 2021-02-25 18:53:02 +0000 automount(8): fix absolute path when creating a mountpoint When executing automount(8), it will attempt to create the directory where an autofs filesystem is to be mounted. Explicity set the root path for this directory to "/". This fixes the issue where the directory being created was being treated as a relative path instead of an absolute path (as expected). PR: 224601 Reported by: kusumi.tomohiro@gmail.com Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D27832 (cherry picked from commit 63640b2f552c0476f50484635eb9888eafcd22dc) --- usr.sbin/autofs/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index a6ed90909ec9..7c8df4205a86 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -140,7 +140,7 @@ create_directory(const char *path) */ copy = tofree = checked_strdup(path + 1); - partial = checked_strdup(""); + partial = checked_strdup("/"); for (;;) { component = strsep(©, "/"); if (component == NULL) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 18:58:41 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 83C6D56CECF; Thu, 25 Feb 2021 18:58:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dmhrx3JqDz3FZR; Thu, 25 Feb 2021 18:58:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 647421CD17; Thu, 25 Feb 2021 18:58:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PIwfRo021334; Thu, 25 Feb 2021 18:58:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PIwfOY021333; Thu, 25 Feb 2021 18:58:41 GMT (envelope-from git) Date: Thu, 25 Feb 2021 18:58:41 GMT Message-Id: <202102251858.11PIwfOY021333@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: d9e70f5d97c6 - stable/12 - automount(8): fix absolute path when creating a mountpoint MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d9e70f5d97c63ae5dba93e9b026d1cfa1b1a4759 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, 25 Feb 2021 18:58:41 -0000 The branch stable/12 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=d9e70f5d97c63ae5dba93e9b026d1cfa1b1a4759 commit d9e70f5d97c63ae5dba93e9b026d1cfa1b1a4759 Author: Robert Wing AuthorDate: 2021-02-17 09:22:23 +0000 Commit: Robert Wing CommitDate: 2021-02-25 18:57:37 +0000 automount(8): fix absolute path when creating a mountpoint When executing automount(8), it will attempt to create the directory where an autofs filesystem is to be mounted. Explicity set the root path for this directory to "/". This fixes the issue where the directory being created was being treated as a relative path instead of an absolute path (as expected). PR: 224601 Reported by: kusumi.tomohiro@gmail.com Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D27832 (cherry picked from commit 63640b2f552c0476f50484635eb9888eafcd22dc) --- usr.sbin/autofs/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 65b8737bcff4..b99583652d95 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -141,7 +141,7 @@ create_directory(const char *path) */ copy = tofree = checked_strdup(path + 1); - partial = checked_strdup(""); + partial = checked_strdup("/"); for (;;) { component = strsep(©, "/"); if (component == NULL) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:41: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 D7F7256F1D3; Thu, 25 Feb 2021 20:41: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 4Dml7V58QMz3Mdj; Thu, 25 Feb 2021 20:41: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 A444D1DCED; Thu, 25 Feb 2021 20:41: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 11PKfQSS064979; Thu, 25 Feb 2021 20:41:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKfQ2O064978; Thu, 25 Feb 2021 20:41:26 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:41:26 GMT Message-Id: <202102252041.11PKfQ2O064978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Allan Jude Subject: git: 1eb60112b22e - releng/13.0 - Use iflib_if_init_locked() during media change instead of iflib_init_locked(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 1eb60112b22ea0d61f0d1ba4ac0cca56a0c034c8 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, 25 Feb 2021 20:41:27 -0000 The branch releng/13.0 has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=1eb60112b22ea0d61f0d1ba4ac0cca56a0c034c8 commit 1eb60112b22ea0d61f0d1ba4ac0cca56a0c034c8 Author: Allan Jude AuthorDate: 2021-02-14 18:39:09 +0000 Commit: Allan Jude CommitDate: 2021-02-25 20:41:10 +0000 Use iflib_if_init_locked() during media change instead of iflib_init_locked(). iflib_init_locked() assumes that iflib_stop() has been called, however, it is not called for media changes. iflib_if_init_locked() calls stop then init, so fixes the problem. PR: 253473 Sponsored by: Juniper Networks, Inc., Klara, Inc. Approved by: re (gjb) (cherry picked from commit 922cf8ac43adc9983f9a9e05cfd838306c1ef483) --- sys/net/iflib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index d10c11f865fe..506861b65570 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -2503,7 +2503,7 @@ iflib_media_change(if_t ifp) CTX_LOCK(ctx); if ((err = IFDI_MEDIA_CHANGE(ctx)) == 0) - iflib_init_locked(ctx); + iflib_if_init_locked(ctx); CTX_UNLOCK(ctx); return (err); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 6C39956FA5B; Thu, 25 Feb 2021 20:52: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 4DmlMq2d82z3NbY; Thu, 25 Feb 2021 20:52: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 4CBDD1E7C8; Thu, 25 Feb 2021 20:52: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 11PKq7de076677; Thu, 25 Feb 2021 20:52:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKq78d076676; Thu, 25 Feb 2021 20:52:07 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:07 GMT Message-Id: <202102252052.11PKq78d076676@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 041d9a1e057e - releng/13.0 - buf SU hooks: track buf_start() calls with B_IOSTARTED flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 041d9a1e057e5e16a29070ee149357dde2c77c2c 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, 25 Feb 2021 20:52:07 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=041d9a1e057e5e16a29070ee149357dde2c77c2c commit 041d9a1e057e5e16a29070ee149357dde2c77c2c Author: Konstantin Belousov AuthorDate: 2021-01-30 02:10:34 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:47:01 +0000 buf SU hooks: track buf_start() calls with B_IOSTARTED flag Approved by: re (delphij, gjb) (cherry picked from commit bf0db19339e770a82236b74f523be4b572bde15d) --- sys/kern/vfs_bio.c | 14 ++++++++++++++ sys/sys/buf.h | 16 +++++++++++----- sys/ufs/ffs/ffs_vfsops.c | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 2f18221e9270..9264388e9a3e 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2639,6 +2639,13 @@ brelse(struct buf *bp) return; } + if (LIST_EMPTY(&bp->b_dep)) { + bp->b_flags &= ~B_IOSTARTED; + } else { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("brelse: SU io not finished bp %p", bp)); + } + if ((bp->b_vflags & (BV_BKGRDINPROG | BV_BKGRDERR)) == BV_BKGRDERR) { BO_LOCK(bp->b_bufobj); bp->b_vflags &= ~BV_BKGRDERR; @@ -2826,6 +2833,13 @@ bqrelse(struct buf *bp) bp->b_flags &= ~(B_ASYNC | B_NOCACHE | B_AGE | B_RELBUF); bp->b_xflags &= ~(BX_CVTENXIO); + if (LIST_EMPTY(&bp->b_dep)) { + bp->b_flags &= ~B_IOSTARTED; + } else { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("bqrelse: SU io not finished bp %p", bp)); + } + if (bp->b_flags & B_MANAGED) { if (bp->b_flags & B_REMFREE) bremfreef(bp); diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 50fa0f35491e..2997560b9ab3 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -232,7 +232,7 @@ struct buf { #define B_MALLOC 0x00010000 /* malloced b_data */ #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ #define B_INVALONERR 0x00040000 /* Invalidate on write error. */ -#define B_00080000 0x00080000 /* Available flag. */ +#define B_IOSTARTED 0x00080000 /* buf_start() called */ #define B_00100000 0x00100000 /* Available flag. */ #define B_MAXPHYS 0x00200000 /* nitems(b_pages[]) = atop(MAXPHYS). */ #define B_RELBUF 0x00400000 /* Release VMIO buffer. */ @@ -248,8 +248,8 @@ struct buf { #define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35ram\34managed" \ "\33paging\32infreecnt\31nocopy\30b23\27relbuf\26maxphys\25b20" \ - "\24b19\23invalonerr\22clusterok\21malloc\20nocache\17b14\16inval" \ - "\15reuse\14noreuse\13eintr\12done\11b8\10delwri" \ + "\24iostarted\23invalonerr\22clusterok\21malloc\20nocache\17b14" \ + "\16inval\15reuse\14noreuse\13eintr\12done\11b8\10delwri" \ "\7validsuspwrt\6cache\5deferred\4direct\3async\2needcommit\1age" /* @@ -434,6 +434,9 @@ bstrategy(struct buf *bp) static __inline void buf_start(struct buf *bp) { + KASSERT((bp->b_flags & B_IOSTARTED) == 0, + ("recursed buf_start %p", bp)); + bp->b_flags |= B_IOSTARTED; if (bioops.io_start) (*bioops.io_start)(bp); } @@ -441,8 +444,11 @@ buf_start(struct buf *bp) static __inline void buf_complete(struct buf *bp) { - if (bioops.io_complete) - (*bioops.io_complete)(bp); + if ((bp->b_flags & B_IOSTARTED) != 0) { + bp->b_flags &= ~B_IOSTARTED; + if (bioops.io_complete) + (*bioops.io_complete)(bp); + } } static __inline void diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 60d4dad57d03..04afbfd4d6e4 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2393,10 +2393,10 @@ ffs_backgroundwritedone(struct buf *bp) #endif /* * This buffer is marked B_NOCACHE so when it is released - * by biodone it will be tossed. + * by biodone it will be tossed. Clear B_IOSTARTED in case of error. */ bp->b_flags |= B_NOCACHE; - bp->b_flags &= ~B_CACHE; + bp->b_flags &= ~(B_CACHE | B_IOSTARTED); pbrelvp(bp); /* From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 9D77656FC9F; Thu, 25 Feb 2021 20:52: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 4DmlMr41Cqz3NdV; Thu, 25 Feb 2021 20:52: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 723D51E618; Thu, 25 Feb 2021 20:52: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 11PKq8Gr076715; Thu, 25 Feb 2021 20:52:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKq8Bn076707; Thu, 25 Feb 2021 20:52:08 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:08 GMT Message-Id: <202102252052.11PKq8Bn076707@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b95a45365676 - releng/13.0 - ffs: call ufsdirhash_dirtrunc() right after setting directory size MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b95a45365676204c7bfad1a28bfdbd1831a86e6c 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, 25 Feb 2021 20:52:08 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b95a45365676204c7bfad1a28bfdbd1831a86e6c commit b95a45365676204c7bfad1a28bfdbd1831a86e6c Author: Konstantin Belousov AuthorDate: 2021-01-28 18:33:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:47:36 +0000 ffs: call ufsdirhash_dirtrunc() right after setting directory size Approved by: re (delphij, gjb) (cherry picked from commit e94f2f1be32294cb6d519b6631f7522466fbbb3b) --- sys/ufs/ffs/ffs_inode.c | 13 +++++++++++++ sys/ufs/ufs/ufs_lookup.c | 4 ---- sys/ufs/ufs/ufs_vnops.c | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 0b4172b34300..3df7bf8e8596 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -34,6 +34,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ufs.h" #include "opt_quota.h" #include @@ -59,6 +60,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#ifdef UFS_DIRHASH +#include +#endif #include #include @@ -456,6 +461,10 @@ ffs_truncate(vp, length, flags, cred) ip->i_size = length; DIP_SET(ip, i_size, length); UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); +#ifdef UFS_DIRHASH + if (vp->v_type == VDIR && ip->i_dirhash != NULL) + ufsdirhash_dirtrunc(ip, length); +#endif } else { lbn = lblkno(fs, length); flags |= BA_CLRBUF; @@ -482,6 +491,10 @@ ffs_truncate(vp, length, flags, cred) return (error); ip->i_size = length; DIP_SET(ip, i_size, length); +#ifdef UFS_DIRHASH + if (vp->v_type == VDIR && ip->i_dirhash != NULL) + ufsdirhash_dirtrunc(ip, length); +#endif size = blksize(fs, ip, lbn); if (vp->v_type != VDIR && offset != 0) bzero((char *)bp->b_data + offset, diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 7dbd58f795cc..2f5fbf3d8001 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1131,10 +1131,6 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) vn_printf(dvp, "ufs_direnter: failed to truncate, error %d\n", error); -#ifdef UFS_DIRHASH - if (error == 0 && dp->i_dirhash != NULL) - ufsdirhash_dirtrunc(dp, I_ENDOFF(dp)); -#endif error = 0; if (tvp != NULL) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 0e7ec7ae5453..70b5a44ca21d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1694,8 +1694,6 @@ unlockout: #ifdef UFS_DIRHASH if (error != 0) ufsdirhash_free(tdp); - else if (tdp->i_dirhash != NULL) - ufsdirhash_dirtrunc(tdp, endoff); #endif /* * Even if the directory compaction failed, rename was From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:15 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07C0356FD5F; Thu, 25 Feb 2021 20:52:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlMy07jwz3NhX; Thu, 25 Feb 2021 20:52: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 BA99A1E5A5; Thu, 25 Feb 2021 20:52: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 11PKqBac079110; Thu, 25 Feb 2021 20:52:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqBXZ079109; Thu, 25 Feb 2021 20:52:11 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:11 GMT Message-Id: <202102252052.11PKqBXZ079109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6a61e5e0a1ed - releng/13.0 - Merge ufs_fhtovp() into ffs_inotovp(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 6a61e5e0a1ed058515860b4806d17196cc51195e 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, 25 Feb 2021 20:52:16 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6a61e5e0a1ed058515860b4806d17196cc51195e commit 6a61e5e0a1ed058515860b4806d17196cc51195e Author: Konstantin Belousov AuthorDate: 2021-01-28 12:20:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:13 +0000 Merge ufs_fhtovp() into ffs_inotovp(). Approved by: re (delphij, gjb) (cherry picked from commit 89fd61d955ada4fdb20030253206201bc279cdf0) --- sys/ufs/ffs/ffs_vfsops.c | 21 +++++++++++++++++---- sys/ufs/ufs/ufs_extern.h | 1 - sys/ufs/ufs/ufs_vfsops.c | 25 ------------------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 596e2f4b4b5f..540dd02c9631 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2170,6 +2170,7 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) { struct ufsmount *ump; struct vnode *nvp; + struct inode *ip; struct fs *fs; struct cg *cgp; struct buf *bp; @@ -2178,6 +2179,8 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) ump = VFSTOUFS(mp); fs = ump->um_fs; + *vpp = NULL; + if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); @@ -2198,10 +2201,20 @@ ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) } error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); - if (error == 0) - error = ufs_fhtovp(mp, nvp, gen); - *vpp = error == 0 ? nvp : NULLVP; - return (error); + if (error != 0) + return (error); + + ip = VTOI(nvp); + if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { + if (ip->i_mode == 0) + vgone(nvp); + vput(nvp); + return (ESTALE); + } + + vnode_create_vobject(nvp, DIP(ip, i_size), curthread); + *vpp = nvp; + return (0); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index ab26750455e8..1697f2c0ba61 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -59,7 +59,6 @@ int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); int ufs_bmap_seekdata(struct vnode *, off_t *); -int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 1a63e92b3e2c..0f45baed634f 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -214,28 +214,3 @@ ufs_uninit(vfsp) #endif return (0); } - -/* - * This is the generic part of fhtovp called after the underlying - * filesystem has validated the file handle. - * - * Call the VFS_CHECKEXP beforehand to verify access. - */ -int -ufs_fhtovp(mp, nvp, gen) - struct mount *mp; - struct vnode *nvp; - u_int64_t gen; -{ - struct inode *ip; - - ip = VTOI(nvp); - if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { - if (ip->i_mode == 0) - vgone(nvp); - vput(nvp); - return (ESTALE); - } - vnode_create_vobject(nvp, DIP(ip, i_size), curthread); - return (0); -} From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:10 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A98A56FDF1; Thu, 25 Feb 2021 20:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlMs67NJz3NhG; Thu, 25 Feb 2021 20:52:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8560E1E53F; Thu, 25 Feb 2021 20:52:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKq9B6078147; Thu, 25 Feb 2021 20:52:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKq96B078132; Thu, 25 Feb 2021 20:52:09 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:09 GMT Message-Id: <202102252052.11PKq96B078132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8ecc621480bb - releng/13.0 - ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 8ecc621480bb2e3676c940a63acc3a8ad61a75f5 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, 25 Feb 2021 20:52:10 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8ecc621480bb2e3676c940a63acc3a8ad61a75f5 commit 8ecc621480bb2e3676c940a63acc3a8ad61a75f5 Author: Konstantin Belousov AuthorDate: 2021-01-26 11:35:21 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:47:42 +0000 ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf() Approved by: re (delphij, gjb) (cherry picked from commit f16c26b1c009fd0d87d07d3b1cf0d5078ad7f511) --- sys/ufs/ffs/ffs_extern.h | 5 +++-- sys/ufs/ffs/ffs_vfsops.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index d54df1deced9..bdb3f533e1ad 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -122,8 +122,9 @@ int ffs_breadz(struct ufsmount *, struct vnode *, daddr_t, daddr_t, int, /* * Flags to ffs_vgetf */ -#define FFSV_FORCEINSMQ 0x0001 -#define FFSV_REPLACE 0x0002 +#define FFSV_FORCEINSMQ 0x0001 +#define FFSV_REPLACE 0x0002 +#define FFSV_REPLACE_DOOMED 0x0004 /* * Flags to ffs_reload diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 04afbfd4d6e4..91b8c30f0919 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1954,13 +1954,16 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) daddr_t dbn; int error; - MPASS((ffs_flags & FFSV_REPLACE) == 0 || (flags & LK_EXCLUSIVE) != 0); + MPASS((ffs_flags & (FFSV_REPLACE | FFSV_REPLACE_DOOMED)) == 0 || + (flags & LK_EXCLUSIVE) != 0); error = vfs_hash_get(mp, ino, flags, curthread, vpp, NULL, NULL); if (error != 0) return (error); if (*vpp != NULL) { - if ((ffs_flags & FFSV_REPLACE) == 0) + if ((ffs_flags & FFSV_REPLACE) == 0 || + ((ffs_flags & FFSV_REPLACE_DOOMED) == 0 || + !VN_IS_DOOMED(*vpp))) return (0); vgone(*vpp); vput(*vpp); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38CD256FE0D; Thu, 25 Feb 2021 20:52:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlMz2CVxz3P8W; Thu, 25 Feb 2021 20:52: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 0EB441E452; Thu, 25 Feb 2021 20:52: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 11PKqDRT079154; Thu, 25 Feb 2021 20:52:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqDK1079153; Thu, 25 Feb 2021 20:52:13 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:13 GMT Message-Id: <202102252052.11PKqDK1079153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9ab31d3d60ad - releng/13.0 - ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 9ab31d3d60adc11e3050e0730b6f3dd517084172 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, 25 Feb 2021 20:52:18 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9ab31d3d60adc11e3050e0730b6f3dd517084172 commit 9ab31d3d60adc11e3050e0730b6f3dd517084172 Author: Konstantin Belousov AuthorDate: 2021-01-23 21:52:10 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:23 +0000 ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory Approved by: re (delphij, gjb) (cherry picked from commit 08c2dc2841214187a162d5e4475aa1b94d03fd77) --- sys/ufs/ufs/ufs_lookup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 2f5fbf3d8001..e614f189a623 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -964,9 +964,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) if (newdirbp) bdwrite(newdirbp); bdwrite(bp); - if ((dp->i_flag & IN_NEEDSYNC) == 0) - return (UFS_UPDATE(dvp, 0)); - return (0); + return (UFS_UPDATE(dvp, 0)); } if (DOINGASYNC(dvp)) { bdwrite(bp); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AEA656FE0E; Thu, 25 Feb 2021 20:52:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlMz69Zkz3P8Z; Thu, 25 Feb 2021 20:52: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 E08451E542; Thu, 25 Feb 2021 20:52: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 11PKqCA7079132; Thu, 25 Feb 2021 20:52:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqC6e079131; Thu, 25 Feb 2021 20:52:12 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:12 GMT Message-Id: <202102252052.11PKqC6e079131@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 57582311c3e0 - releng/13.0 - ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 57582311c3e099d91bd213c0c6f3af1f3119bc01 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, 25 Feb 2021 20:52:17 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=57582311c3e099d91bd213c0c6f3af1f3119bc01 commit 57582311c3e099d91bd213c0c6f3af1f3119bc01 Author: Konstantin Belousov AuthorDate: 2021-01-23 21:50:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:18 +0000 ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync Approved by: re (delphij, gjb) (cherry picked from commit 1de1e2bfbf3c089418bbe67c096d60315c8ca5dd) --- sys/ufs/ffs/ffs_vnops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 68985d8715f3..be2653e32adc 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -257,7 +257,6 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags) bool still_dirty, unlocked, wait; ip = VTOI(vp); - ip->i_flag &= ~IN_NEEDSYNC; bo = &vp->v_bufobj; ump = VFSTOUFS(vp->v_mount); @@ -445,6 +444,8 @@ next: } if (error == 0 && unlocked) error = ERELOOKUP; + if (error == 0) + ip->i_flag &= ~IN_NEEDSYNC; return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 B72E056FD78; Thu, 25 Feb 2021 20:52: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 4DmlN443Ynz3P2N; Thu, 25 Feb 2021 20:52: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 684621E68B; Thu, 25 Feb 2021 20:52:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqHfB079216; Thu, 25 Feb 2021 20:52:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqHDE079215; Thu, 25 Feb 2021 20:52:17 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:17 GMT Message-Id: <202102252052.11PKqHDE079215@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b4cc32336d31 - releng/13.0 - nullfs: provide special bypass for VOP_VPUT_PAIR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b4cc32336d31c8d81feaae2aab4d1d2fd9f306a5 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, 25 Feb 2021 20:52:23 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b4cc32336d31c8d81feaae2aab4d1d2fd9f306a5 commit b4cc32336d31c8d81feaae2aab4d1d2fd9f306a5 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:22:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:37 +0000 nullfs: provide special bypass for VOP_VPUT_PAIR Approved by: re (delphij, gjb) (cherry picked from commit e4aaf35ab54958f74409790fa2b7df8c2d230cee) --- sys/fs/nullfs/null_vnops.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 1de0cdfca9ac..45065e0be7b5 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -967,6 +967,54 @@ null_read_pgcache(struct vop_read_pgcache_args *ap) return (error); } +/* + * Avoid standard bypass, since lower dvp and vp could be no longer + * valid after vput(). + */ +static int +null_vput_pair(struct vop_vput_pair_args *ap) +{ + struct mount *mp; + struct vnode *dvp, *ldvp, *lvp, *vp, *vp1, **vpp; + int error, res; + + dvp = ap->a_dvp; + ldvp = NULLVPTOLOWERVP(dvp); + vref(ldvp); + + vpp = ap->a_vpp; + vp = NULL; + lvp = NULL; + if (vpp != NULL) { + vp = *vpp; + if (vp != NULL) { + vhold(vp); + mp = vp->v_mount; + lvp = NULLVPTOLOWERVP(vp); + if (ap->a_unlock_vp) + vref(lvp); + } + } + + res = VOP_VPUT_PAIR(ldvp, &lvp, ap->a_unlock_vp); + + /* lvp might have been unlocked and vp reclaimed */ + if (vp != NULL) { + if (!ap->a_unlock_vp && vp->v_vnlock != lvp->v_vnlock) { + error = null_nodeget(mp, lvp, &vp1); + if (error == 0) { + vput(vp); + *vpp = vp1; + } + } + if (ap->a_unlock_vp) + vrele(vp); + vdrop(vp); + } + vrele(dvp); + return (res); +} + /* * Global vfs data structures */ @@ -997,5 +1045,6 @@ struct vop_vector null_vnodeops = { .vop_vptocnp = null_vptocnp, .vop_vptofh = null_vptofh, .vop_add_writecount = null_add_writecount, + .vop_vput_pair = null_vput_pair, }; VFS_VOP_VECTOR_REGISTER(null_vnodeops); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 29A5A56FC77; Thu, 25 Feb 2021 20:52: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 4DmlMv4ntdz3NhM; Thu, 25 Feb 2021 20:52: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 B9D8B1E540; Thu, 25 Feb 2021 20:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqAWV079092; Thu, 25 Feb 2021 20:52:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqACx079091; Thu, 25 Feb 2021 20:52:10 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:10 GMT Message-Id: <202102252052.11PKqACx079091@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: fc54784b47b6 - releng/13.0 - ffs_inotovp(): interface to convert (ino, gen) into alive vnode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: fc54784b47b6876e03527fbfff317fcc4764c1b1 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, 25 Feb 2021 20:52:12 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fc54784b47b6876e03527fbfff317fcc4764c1b1 commit fc54784b47b6876e03527fbfff317fcc4764c1b1 Author: Konstantin Belousov AuthorDate: 2021-01-26 11:52:59 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:47:47 +0000 ffs_inotovp(): interface to convert (ino, gen) into alive vnode Approved by: re (delphij, gjb) (cherry picked from commit 5952c86c78b177b5e904bf139e6b56519897c7e0) --- sys/ufs/ffs/ffs_extern.h | 2 ++ sys/ufs/ffs/ffs_vfsops.c | 44 ++++++++++++++++++++++++++++++++------------ sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_vfsops.c | 21 +++++---------------- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index bdb3f533e1ad..9694489266b6 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -80,6 +80,8 @@ int ffs_freefile(struct ufsmount *, struct fs *, struct vnode *, ino_t, void ffs_fserr(struct fs *, ino_t, char *); int ffs_getcg(struct fs *, struct vnode *, u_int, int, struct buf **, struct cg **); +int ffs_inotovp(struct mount *, ino_t, u_int64_t, int, struct vnode **, + int); int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t); int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t); void ffs_oldfscompat_write(struct fs *, struct ufsmount *); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 91b8c30f0919..596e2f4b4b5f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2153,35 +2153,55 @@ ffs_fhtovp(mp, fhp, flags, vpp) struct vnode **vpp; { struct ufid *ufhp; + + ufhp = (struct ufid *)fhp; + return (ffs_inotovp(mp, ufhp->ufid_ino, ufhp->ufid_gen, flags, + vpp, 0)); +} + +int +ffs_inotovp(mp, ino, gen, lflags, vpp, ffs_flags) + struct mount *mp; + ino_t ino; + u_int64_t gen; + int lflags; + struct vnode **vpp; + int ffs_flags; +{ struct ufsmount *ump; + struct vnode *nvp; struct fs *fs; struct cg *cgp; struct buf *bp; - ino_t ino; u_int cg; int error; - ufhp = (struct ufid *)fhp; - ino = ufhp->ufid_ino; ump = VFSTOUFS(mp); fs = ump->um_fs; if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); + /* * Need to check if inode is initialized because UFS2 does lazy * initialization and nfs_fhtovp can offer arbitrary inode numbers. */ - if (fs->fs_magic != FS_UFS2_MAGIC) - return (ufs_fhtovp(mp, ufhp, flags, vpp)); - cg = ino_to_cg(fs, ino); - if ((error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp)) != 0) - return (error); - if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + if (fs->fs_magic == FS_UFS2_MAGIC) { + cg = ino_to_cg(fs, ino); + error = ffs_getcg(fs, ump->um_devvp, cg, 0, &bp, &cgp); + if (error != 0) + return (error); + if (ino >= cg * fs->fs_ipg + cgp->cg_initediblk) { + brelse(bp); + return (ESTALE); + } brelse(bp); - return (ESTALE); } - brelse(bp); - return (ufs_fhtovp(mp, ufhp, flags, vpp)); + + error = ffs_vgetf(mp, ino, lflags, &nvp, ffs_flags); + if (error == 0) + error = ufs_fhtovp(mp, nvp, gen); + *vpp = error == 0 ? nvp : NULLVP; + return (error); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index a28fcffabd2e..ab26750455e8 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -59,7 +59,7 @@ int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); int ufs_bmap_seekdata(struct vnode *, off_t *); -int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); +int ufs_fhtovp(struct mount *, struct vnode *, u_int64_t); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 4813ac7db763..1a63e92b3e2c 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -222,31 +222,20 @@ ufs_uninit(vfsp) * Call the VFS_CHECKEXP beforehand to verify access. */ int -ufs_fhtovp(mp, ufhp, flags, vpp) +ufs_fhtovp(mp, nvp, gen) struct mount *mp; - struct ufid *ufhp; - int flags; - struct vnode **vpp; + struct vnode *nvp; + u_int64_t gen; { struct inode *ip; - struct vnode *nvp; - int error; - error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp); - if (error) { - *vpp = NULLVP; - return (error); - } ip = VTOI(nvp); - if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || - ip->i_effnlink <= 0) { + if (ip->i_mode == 0 || ip->i_gen != gen || ip->i_effnlink <= 0) { if (ip->i_mode == 0) vgone(nvp); vput(nvp); - *vpp = NULLVP; return (ESTALE); } - *vpp = nvp; - vnode_create_vobject(*vpp, DIP(ip, i_size), curthread); + vnode_create_vobject(nvp, DIP(ip, i_size), curthread); return (0); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 923BD56FF88; Thu, 25 Feb 2021 20:52: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 4DmlNK1VLfz3PRp; Thu, 25 Feb 2021 20:52: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 B4C541E5AD; Thu, 25 Feb 2021 20:52: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 11PKqSPQ079426; Thu, 25 Feb 2021 20:52:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqSEu079425; Thu, 25 Feb 2021 20:52:28 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:28 GMT Message-Id: <202102252052.11PKqSEu079425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8ef69a7e8fdf - releng/13.0 - ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 8ef69a7e8fdfdc9968592c5d7eec73d846af2961 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, 25 Feb 2021 20:52:33 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8ef69a7e8fdfdc9968592c5d7eec73d846af2961 commit 8ef69a7e8fdfdc9968592c5d7eec73d846af2961 Author: Konstantin Belousov AuthorDate: 2021-01-23 23:12:39 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:41 +0000 ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP Approved by: re (delphij, gjb) (cherry picked from commit 6aed2435c8bf1fa55891c7d30186c9ad91064da8) --- sys/ufs/ufs/ufs_vnops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index b035a8b1c34d..e6a78c3655cc 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1006,7 +1006,7 @@ ufs_remove(ap) if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) || (VTOI(dvp)->i_flags & APPEND)) return (EPERM); - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -1071,7 +1071,7 @@ ufs_link(ap) panic("ufs_link: no name"); #endif - if (DOINGSOFTDEP(tdvp)) { + if (DOINGSUJ(tdvp)) { error = softdep_prelink(tdvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -1142,7 +1142,7 @@ ufs_whiteout(ap) struct direct newdir; int error = 0; - if (DOINGSOFTDEP(dvp) && (ap->a_flags == CREATE || + if (DOINGSUJ(dvp) && (ap->a_flags == CREATE || ap->a_flags == DELETE)) { error = softdep_prelink(dvp, NULL); if (error != 0) { @@ -1945,7 +1945,7 @@ ufs_mkdir(ap) goto out; } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); @@ -2209,7 +2209,7 @@ ufs_rmdir(ap) error = EINVAL; goto out; } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); @@ -2736,7 +2736,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) print_bad_link_count(callfunc, dvp); return (EINVAL); } - if (DOINGSOFTDEP(dvp)) { + if (DOINGSUJ(dvp)) { error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 BC1EA56FD6F; Thu, 25 Feb 2021 20:52: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 4DmlN3195Lz3Nwk; Thu, 25 Feb 2021 20:52: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 353441E545; Thu, 25 Feb 2021 20:52: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 11PKqGS5079194; Thu, 25 Feb 2021 20:52:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqGrW079193; Thu, 25 Feb 2021 20:52:16 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:16 GMT Message-Id: <202102252052.11PKqGrW079193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 984c11f5aaa0 - releng/13.0 - Add VOP_VPUT_PAIR() with trivial default implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 984c11f5aaa02883d1afbbca31b419194005ac4c 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, 25 Feb 2021 20:52:21 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=984c11f5aaa02883d1afbbca31b419194005ac4c commit 984c11f5aaa02883d1afbbca31b419194005ac4c Author: Konstantin Belousov AuthorDate: 2021-01-28 22:30:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:32 +0000 Add VOP_VPUT_PAIR() with trivial default implementation. Approved by: re (delphij, gjb) (cherry picked from commit 49c117c193768b10f5fb1c5e4d6b88300cfbcdd6) --- sys/kern/vfs_default.c | 15 +++++++++++++++ sys/kern/vnode_if.src | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 4b96d9522ce3..382fbb2d9ace 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -92,6 +92,7 @@ static int vop_stdfdatasync(struct vop_fdatasync_args *ap); static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); static int vop_stdstat(struct vop_stat_args *ap); +static int vop_stdvput_pair(struct vop_vput_pair_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -151,6 +152,7 @@ struct vop_vector default_vnodeops = { .vop_unset_text = vop_stdunset_text, .vop_add_writecount = vop_stdadd_writecount, .vop_copy_file_range = vop_stdcopy_file_range, + .vop_vput_pair = vop_stdvput_pair, }; VFS_VOP_VECTOR_REGISTER(default_vnodeops); @@ -1592,3 +1594,16 @@ vop_stdread_pgcache(struct vop_read_pgcache_args *ap __unused) { return (EJUSTRETURN); } + +static int +vop_stdvput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + + dvp = ap->a_dvp; + vpp = ap->a_vpp; + vput(dvp); + if (vpp != NULL && ap->a_unlock_vp && (vp = *vpp) != NULL) + vput(vp); + return (0); +} diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 5d15d4a0c863..b506237f385d 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -792,6 +792,15 @@ vop_copy_file_range { }; +%% vput_pair dvp E - - + +vop_vput_pair { + IN struct vnode *dvp; + INOUT struct vnode **vpp; + IN bool unlock_vp; +}; + + # The VOPs below are spares at the end of the table to allow new VOPs to be # added in stable branches without breaking the KBI. New VOPs in HEAD should # be added above these spares. When merging a new VOP to a stable branch, From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 53DD7548002; Thu, 25 Feb 2021 20:52: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 4DmlND5npwz3P7M; Thu, 25 Feb 2021 20:52: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 501CF1E349; Thu, 25 Feb 2021 20:52: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 11PKqPd6079364; Thu, 25 Feb 2021 20:52:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqPw3079363; Thu, 25 Feb 2021 20:52:25 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:25 GMT Message-Id: <202102252052.11PKqPw3079363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9fc9a50119fa - releng/13.0 - ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 9fc9a50119fa65bce6612a634f161d9e7dbf9478 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, 25 Feb 2021 20:52:30 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9fc9a50119fa65bce6612a634f161d9e7dbf9478 commit 9fc9a50119fa65bce6612a634f161d9e7dbf9478 Author: Konstantin Belousov AuthorDate: 2021-01-28 13:34:56 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:24 +0000 ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there Approved by: re (delphij, gjb) (cherry picked from commit 038fe6e089f03ca864c1dd5ac0c76404a13bbe79) --- sys/ufs/ufs/ufs_vnops.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 70b5a44ca21d..c101e699bad6 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1676,38 +1676,16 @@ unlockout: vput(fdvp); vput(fvp); - if (tvp) - vput(tvp); + /* - * If compaction or fsync was requested do it now that other locks - * are no longer needed. + * If compaction or fsync was requested do it in + * ffs_vput_pair() now that other locks are no longer needed. */ if (error == 0 && endoff != 0) { - do { - error = UFS_TRUNCATE(tdvp, endoff, IO_NORMAL | - (DOINGASYNC(tdvp) ? 0 : IO_SYNC), tcnp->cn_cred); - } while (error == ERELOOKUP); - if (error != 0 && !ffs_fsfail_cleanup(VFSTOUFS(mp), error)) - vn_printf(tdvp, - "ufs_rename: failed to truncate, error %d\n", - error); -#ifdef UFS_DIRHASH - if (error != 0) - ufsdirhash_free(tdp); -#endif - /* - * Even if the directory compaction failed, rename was - * succesful. Do not propagate a UFS_TRUNCATE() error - * to the caller. - */ - error = 0; - } - if (error == 0 && tdp->i_flag & IN_NEEDSYNC) { - do { - error = VOP_FSYNC(tdvp, MNT_WAIT, td); - } while (error == ERELOOKUP); + UFS_INODE_SET_FLAG(tdp, IN_ENDOFF); + SET_I_ENDOFF(tdp, endoff); } - vput(tdvp); + VOP_VPUT_PAIR(tdvp, &tvp, true); return (error); bad: From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:39 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 7A34356FCC9; Thu, 25 Feb 2021 20:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNQ3GpSz3PPc; Thu, 25 Feb 2021 20:52:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48ED11E625; Thu, 25 Feb 2021 20:52: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 11PKqXLn079510; Thu, 25 Feb 2021 20:52:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqX7j079509; Thu, 25 Feb 2021 20:52:33 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:33 GMT Message-Id: <202102252052.11PKqX7j079509@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: eadca59970c1 - releng/13.0 - ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: eadca59970c1ad89d79991423488adc3cd113f1f 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, 25 Feb 2021 20:52:39 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=eadca59970c1ad89d79991423488adc3cd113f1f commit eadca59970c1ad89d79991423488adc3cd113f1f Author: Konstantin Belousov AuthorDate: 2021-01-31 18:39:49 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:22 +0000 ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage Approved by: re (delphij, gjb) (cherry picked from commit 28703d27130c9cb7e7830ff53155c379a502c248) --- sys/ufs/ffs/ffs_softdep.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ sys/ufs/ffs/softdep.h | 2 ++ 2 files changed, 63 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 8c52139687f9..786fb43c7d81 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1311,6 +1311,7 @@ static int softdep_flushcache = 0; /* Should we do BIO_FLUSH? */ */ static int stat_flush_threads; /* number of softdep flushing threads */ static int stat_worklist_push; /* number of worklist cleanups */ +static int stat_delayed_inact; /* number of delayed inactivation cleanups */ static int stat_blk_limit_push; /* number of times block limit neared */ static int stat_ino_limit_push; /* number of times inode limit neared */ static int stat_blk_limit_hit; /* number of times block slowdown imposed */ @@ -1344,6 +1345,8 @@ SYSCTL_INT(_debug_softdep, OID_AUTO, flush_threads, CTLFLAG_RD, &stat_flush_threads, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, worklist_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_worklist_push, 0,""); +SYSCTL_INT(_debug_softdep, OID_AUTO, delayed_inactivations, CTLFLAG_RD, + &stat_delayed_inact, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, blk_limit_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_blk_limit_push, 0,""); SYSCTL_INT(_debug_softdep, OID_AUTO, ino_limit_push, @@ -13707,6 +13710,37 @@ softdep_slowdown(vp) return (1); } +static int +softdep_request_cleanup_filter(struct vnode *vp, void *arg __unused) +{ + return ((vp->v_iflag & VI_OWEINACT) != 0 && vp->v_usecount == 0 && + ((vp->v_vflag & VV_NOSYNC) != 0 || VTOI(vp)->i_effnlink == 0)); +} + +static void +softdep_request_cleanup_inactivate(struct mount *mp) +{ + struct vnode *vp, *mvp; + int error; + + MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, softdep_request_cleanup_filter, + NULL) { + vholdl(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY); + VI_LOCK(vp); + if (vp->v_data != NULL && vp->v_usecount == 0) { + while ((vp->v_iflag & VI_OWEINACT) != 0) { + error = vinactive(vp); + if (error != 0 && error != ERELOOKUP) + break; + } + atomic_add_int(&stat_delayed_inact, 1); + } + VOP_UNLOCK(vp); + vdropl(vp); + } +} + /* * Called by the allocation routines when they are about to fail * in the hope that we can free up the requested resource (inodes @@ -13819,6 +13853,33 @@ retry: stat_worklist_push += 1; FREE_LOCK(ump); } + + /* + * Check that there are vnodes pending inactivation. As they + * have been unlinked, inactivating them will free up their + * inodes. + */ + ACQUIRE_LOCK(ump); + if (resource == FLUSH_INODES_WAIT && + fs->fs_cstotal.cs_nifree <= needed && + fs->fs_pendinginodes <= needed) { + if ((ump->um_softdep->sd_flags & FLUSH_DI_ACTIVE) == 0) { + ump->um_softdep->sd_flags |= FLUSH_DI_ACTIVE; + FREE_LOCK(ump); + softdep_request_cleanup_inactivate(mp); + ACQUIRE_LOCK(ump); + ump->um_softdep->sd_flags &= ~FLUSH_DI_ACTIVE; + wakeup(&ump->um_softdep->sd_flags); + } else { + while ((ump->um_softdep->sd_flags & + FLUSH_DI_ACTIVE) != 0) { + msleep(&ump->um_softdep->sd_flags, + LOCK_PTR(ump), PVM, "ffsvina", hz); + } + } + } + FREE_LOCK(ump); + /* * If we still need resources and there are no more worklist * entries to process to obtain them, we have to start flushing diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 868ada00f2dc..3493aadafc98 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -1086,6 +1086,8 @@ struct mount_softdeps { #define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */ #define FLUSH_STARTING 0x0004 /* flush thread not yet started */ #define FLUSH_RC_ACTIVE 0x0008 /* a thread is flushing the mount point */ +#define FLUSH_DI_ACTIVE 0x0010 /* a thread is processing delayed + inactivations */ /* * Keep the old names from when these were in the ufsmount structure. From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 A4F5156FA6F; Thu, 25 Feb 2021 20:52: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 4DmlN23LDrz3P28; Thu, 25 Feb 2021 20:52: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 381FA1E5A6; Thu, 25 Feb 2021 20:52:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqEgI079172; Thu, 25 Feb 2021 20:52:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqEql079171; Thu, 25 Feb 2021 20:52:14 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:14 GMT Message-Id: <202102252052.11PKqEql079171@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c2007457027d - releng/13.0 - vn_open(): If the vnode is reclaimed during open(2), do not return error. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: c2007457027d54f60d4558b4e8f90673596357a2 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, 25 Feb 2021 20:52:21 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c2007457027d54f60d4558b4e8f90673596357a2 commit c2007457027d54f60d4558b4e8f90673596357a2 Author: Konstantin Belousov AuthorDate: 2021-02-03 11:02:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:28 +0000 vn_open(): If the vnode is reclaimed during open(2), do not return error. Approved by: re (delphij, gjb) (cherry picked from commit ee965dfa64929227ced8adb68900c35f877480e7) --- sys/fs/deadfs/dead_vnops.c | 11 +++++++++-- sys/kern/vfs_vnops.c | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c index 09c3c996ee0e..324bbafd7caf 100644 --- a/sys/fs/deadfs/dead_vnops.c +++ b/sys/fs/deadfs/dead_vnops.c @@ -45,6 +45,7 @@ */ static vop_lookup_t dead_lookup; static vop_open_t dead_open; +static vop_close_t dead_close; static vop_getwritemount_t dead_getwritemount; static vop_rename_t dead_rename; static vop_unset_text_t dead_unset_text; @@ -55,6 +56,7 @@ struct vop_vector dead_vnodeops = { .vop_access = VOP_EBADF, .vop_advlock = VOP_EBADF, .vop_bmap = VOP_EBADF, + .vop_close = dead_close, .vop_create = VOP_PANIC, .vop_getattr = VOP_EBADF, .vop_getwritemount = dead_getwritemount, @@ -104,13 +106,18 @@ dead_lookup(struct vop_lookup_args *ap) } /* - * Open always fails as if device did not exist. + * Silently succeed open and close. */ static int dead_open(struct vop_open_args *ap) { + return (0); +} - return (ENXIO); +static int +dead_close(struct vop_close_args *ap) +{ + return (0); } int diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 1e52a797a1f7..3ec2662dfcd8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -356,8 +356,6 @@ vn_open_vnode_advlock(struct vnode *vp, int fmode, struct file *fp) fp->f_flag |= FHASLOCK; vn_lock(vp, lock_flags | LK_RETRY); - if (error == 0 && VN_IS_DOOMED(vp)) - error = ENOENT; return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 63DEC56FADD; Thu, 25 Feb 2021 20:52: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 4DmlN95Q9xz3P0W; Thu, 25 Feb 2021 20:52: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 EFB551E54B; Thu, 25 Feb 2021 20:52: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 11PKqMni079320; Thu, 25 Feb 2021 20:52:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqMV5079319; Thu, 25 Feb 2021 20:52:22 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:22 GMT Message-Id: <202102252052.11PKqMV5079319@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0c3cdbf4293a - releng/13.0 - ffs_vput_pair(): try harder to recover from the vnode reclaim MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 0c3cdbf4293afa1f6faa50e368e47327957ceb85 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, 25 Feb 2021 20:52:28 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0c3cdbf4293afa1f6faa50e368e47327957ceb85 commit 0c3cdbf4293afa1f6faa50e368e47327957ceb85 Author: Konstantin Belousov AuthorDate: 2021-01-27 18:10:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:04 +0000 ffs_vput_pair(): try harder to recover from the vnode reclaim Approved by: re (delphij, gjb) (cherry picked from commit 30bfb2fa0fad8e5bbcce369df46dcaa2e08324f3) --- sys/ufs/ffs/ffs_vnops.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 623b13790ce0..2ac67adad5f2 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1924,8 +1924,11 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) static int ffs_vput_pair(struct vop_vput_pair_args *ap) { - struct vnode *dvp, *vp, **vpp; - struct inode *dp; + struct mount *mp; + struct vnode *dvp, *vp, *vp1, **vpp; + struct inode *dp, *ip; + ino_t ip_ino; + u_int64_t ip_gen; int error, vp_locked; dvp = ap->a_dvp; @@ -1940,12 +1943,17 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) return (0); } + mp = NULL; if (vp != NULL) { if (ap->a_unlock_vp) { vput(vp); } else { MPASS(vp->v_type != VNON); vp_locked = VOP_ISLOCKED(vp); + ip = VTOI(vp); + ip_ino = ip->i_number; + ip_gen = ip->i_gen; + mp = vp->v_mount; VOP_UNLOCK(vp); } } @@ -1957,6 +1965,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) if (vp == NULL || ap->a_unlock_vp) return (0); + MPASS(mp != NULL); /* * It is possible that vp is reclaimed at this point. Only @@ -1970,5 +1979,29 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) * and respond to dead vnodes by returning ESTALE. */ VOP_LOCK(vp, vp_locked | LK_RETRY); - return (0); + if (!VN_IS_DOOMED(vp)) + return (0); + + /* + * Try harder to recover from reclaimed vp if reclaim was not + * because underlying inode was cleared. We saved inode + * number and inode generation, so we can try to reinstantiate + * exactly same version of inode. If this fails, return + * original doomed vnode and let caller to handle + * consequences. + * + * Note that callers must keep write started around + * VOP_VPUT_PAIR() calls, so it is safe to use mp without + * busying it. + */ + VOP_UNLOCK(vp); + error = ffs_inotovp(mp, ip_ino, ip_gen, LK_EXCLUSIVE, &vp1, + FFSV_REPLACE_DOOMED); + if (error != 0) { + VOP_LOCK(vp, vp_locked | LK_RETRY); + } else { + vrele(vp); + *vpp = vp1; + } + return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 AA87654801A; Thu, 25 Feb 2021 20:52: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 4DmlNG5Ymtz3P7n; Thu, 25 Feb 2021 20:52: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 7CBA51E7CD; Thu, 25 Feb 2021 20:52: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 11PKqQVf079382; Thu, 25 Feb 2021 20:52:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqQO9079381; Thu, 25 Feb 2021 20:52:26 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:26 GMT Message-Id: <202102252052.11PKqQO9079381@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: bccb8dda0ee2 - releng/13.0 - ufs_direnter: directory truncation does not need special case for rename MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: bccb8dda0ee259cc35561d87836db477be7d20ea 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, 25 Feb 2021 20:52:32 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bccb8dda0ee259cc35561d87836db477be7d20ea commit bccb8dda0ee259cc35561d87836db477be7d20ea Author: Konstantin Belousov AuthorDate: 2021-01-29 12:31:52 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:29 +0000 ufs_direnter: directory truncation does not need special case for rename Approved by: re (delphij, gjb) (cherry picked from commit 06f2918ab8a2621c6e6bc5729ed9ab982741aaf2) --- sys/ufs/ffs/ffs_vnops.c | 25 ++++++++++++------------- sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_lookup.c | 12 +++++------- sys/ufs/ufs/ufs_vnops.c | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index dd0f1ba6b81d..38511647c502 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1968,22 +1968,21 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) * now that other locks are no longer held. */ if ((dp->i_flag & IN_ENDOFF) != 0) { + VNASSERT(I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size, dvp, + ("IN_ENDOFF set but I_ENDOFF() is not")); dp->i_flag &= ~IN_ENDOFF; - if (I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { - old_size = dp->i_size; - error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), - IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), - curthread->td_ucred); - if (error != 0 && error != ERELOOKUP) { - if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { - vn_printf(dvp, - "IN_ENDOFF: failed to truncate, " - "error %d\n", error); - } + old_size = dp->i_size; + error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), IO_NORMAL | + (DOINGASYNC(dvp) ? 0 : IO_SYNC), curthread->td_ucred); + if (error != 0 && error != ERELOOKUP) { + if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { + vn_printf(dvp, + "IN_ENDOFF: failed to truncate, " + "error %d\n", error); + } #ifdef UFS_DIRHASH - ufsdirhash_free(dp); + ufsdirhash_free(dp); #endif - } } SET_I_ENDOFF(dp, 0); } diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 1697f2c0ba61..3ac631e6ab0b 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -68,7 +68,7 @@ int ufs_extwrite(struct vop_write_args *); void ufs_makedirentry(struct inode *, struct componentname *, struct direct *); int ufs_direnter(struct vnode *, struct vnode *, struct direct *, - struct componentname *, struct buf *, int); + struct componentname *, struct buf *); int ufs_dirremove(struct vnode *, struct inode *, int, int); int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int); int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *, diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 3036bce81caf..0509185c4663 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -876,13 +876,12 @@ ufs_makedirentry(ip, cnp, newdirp) * soft dependency code). */ int -ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) +ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) struct vnode *dvp; struct vnode *tvp; struct direct *dirp; struct componentname *cnp; struct buf *newdirbp; - int isrename; { struct ucred *cr; struct thread *td; @@ -1111,14 +1110,13 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) error = bwrite(bp); } } - UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE); /* - * If all went well, and the directory can be shortened, mark directory inode - * with the truncation request right before unlock. + * If all went well, and the directory can be shortened, + * mark directory inode with the truncation request. */ - if (isrename == 0 && error == 0) - UFS_INODE_SET_FLAG(dp, IN_ENDOFF); + UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE | (error == 0 && + I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size ? IN_ENDOFF : 0)); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index c101e699bad6..22199a390dd4 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1111,7 +1111,7 @@ ufs_link(ap) error = UFS_UPDATE(vp, !DOINGSOFTDEP(vp) && !DOINGASYNC(vp)); if (!error) { ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(tdvp, vp, &newdir, cnp, NULL, 0); + error = ufs_direnter(tdvp, vp, &newdir, cnp, NULL); } if (error) { @@ -1171,7 +1171,7 @@ ufs_whiteout(ap) newdir.d_namlen = cnp->cn_namelen; bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1); newdir.d_type = DT_WHT; - error = ufs_direnter(dvp, NULL, &newdir, cnp, NULL, 0); + error = ufs_direnter(dvp, NULL, &newdir, cnp, NULL); break; case DELETE: @@ -1511,7 +1511,7 @@ relock: } } ufs_makedirentry(fip, tcnp, &newdir); - error = ufs_direnter(tdvp, NULL, &newdir, tcnp, NULL, 1); + error = ufs_direnter(tdvp, NULL, &newdir, tcnp, NULL); if (error) goto bad; /* Setup tdvp for directory compaction if needed. */ @@ -2132,7 +2132,7 @@ ufs_mkdir(ap) else if (!DOINGSOFTDEP(dvp) && ((error = bwrite(bp)))) goto bad; ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(dvp, tvp, &newdir, cnp, bp, 0); + error = ufs_direnter(dvp, tvp, &newdir, cnp, bp); bad: if (error == 0) { @@ -2865,7 +2865,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) } #endif /* !UFS_ACL */ ufs_makedirentry(ip, cnp, &newdir); - error = ufs_direnter(dvp, tvp, &newdir, cnp, NULL, 0); + error = ufs_direnter(dvp, tvp, &newdir, cnp, NULL); if (error) goto bad; vn_seqc_write_end(tvp); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:35 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 9FDF856FE39; Thu, 25 Feb 2021 20:52:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNL2pWhz3PTv; Thu, 25 Feb 2021 20:52: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 1F2161E3EA; Thu, 25 Feb 2021 20:52: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 11PKqUVh079466; Thu, 25 Feb 2021 20:52:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqUU8079465; Thu, 25 Feb 2021 20:52:30 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:30 GMT Message-Id: <202102252052.11PKqUU8079465@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f8272ff1d26b - releng/13.0 - ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f8272ff1d26b2fa6936a2ef294e494e43429f973 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, 25 Feb 2021 20:52:36 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f8272ff1d26b2fa6936a2ef294e494e43429f973 commit f8272ff1d26b2fa6936a2ef294e494e43429f973 Author: Konstantin Belousov AuthorDate: 2021-01-30 19:18:22 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:00 +0000 ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it. Approved by: re (delphij, gjb) (cherry picked from commit 013168db8cea926c3dde1247d400d6bedf9a889d) --- sys/ufs/ffs/ffs_softdep.c | 9 +++++---- sys/ufs/ufs/ufs_inode.c | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 3cc76f9142c3..8c3ae9dd95fc 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1493,13 +1493,14 @@ get_parent_vp(struct vnode *vp, struct mount *mp, ino_t inum, struct buf *bp, } /* - * Do not drop vnode lock while inactivating. This - * would result in leaks of the VI flags and - * reclaiming of non-truncated vnode. Instead, + * Do not drop vnode lock while inactivating during + * vunref. This would result in leaks of the VI flags + * and reclaiming of non-truncated vnode. Instead, * re-schedule inactivation hoping that we would be * able to sync inode later. */ - if ((vp->v_iflag & VI_DOINGINACT) != 0) { + if ((vp->v_iflag & VI_DOINGINACT) != 0 && + (vp->v_vflag & VV_UNREF) != 0) { VI_LOCK(vp); vp->v_iflag |= VI_OWEINACT; VI_UNLOCK(vp); diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 15bd8be448a9..46e4f8e54e41 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -212,8 +212,6 @@ out: vrecycle(vp); if (mp != NULL) vn_finished_secondary_write(mp); - if (error == ERELOOKUP) - error = 0; return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2E9656FB74; Thu, 25 Feb 2021 20:52:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNM0H0Yz3PXV; Thu, 25 Feb 2021 20:52: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 219F81E624; Thu, 25 Feb 2021 20:52:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqW2Z079488; Thu, 25 Feb 2021 20:52:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqWPM079487; Thu, 25 Feb 2021 20:52:32 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:32 GMT Message-Id: <202102252052.11PKqWPM079487@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 28d0541398bf - releng/13.0 - softdep_request_cleanup: wait for softdep_request_clean_flush() to pass MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 28d0541398bffc9930fd027613fb1bdc43a61704 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, 25 Feb 2021 20:52:36 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=28d0541398bffc9930fd027613fb1bdc43a61704 commit 28d0541398bffc9930fd027613fb1bdc43a61704 Author: Konstantin Belousov AuthorDate: 2021-02-03 23:58:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:12 +0000 softdep_request_cleanup: wait for softdep_request_clean_flush() to pass Approved by: re (delphij, gjb) (cherry picked from commit 2011b44fa3f2b2bd5a24be01094420cce9144b2d) --- sys/ufs/ffs/ffs_softdep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 8c3ae9dd95fc..8c52139687f9 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -13847,6 +13847,7 @@ retry: failed_vnode = softdep_request_cleanup_flush(mp, ump); ACQUIRE_LOCK(ump); ump->um_softdep->sd_flags &= ~FLUSH_RC_ACTIVE; + wakeup(&ump->um_softdep->sd_flags); FREE_LOCK(ump); if (ump->softdep_on_worklist > 0) { stat_cleanup_retries += 1; @@ -13854,6 +13855,11 @@ retry: goto retry; } } else { + while ((ump->um_softdep->sd_flags & + FLUSH_RC_ACTIVE) != 0) { + msleep(&ump->um_softdep->sd_flags, + LOCK_PTR(ump), PVM, "ffsrca", hz); + } FREE_LOCK(ump); error = 0; } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:35 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 CB41F56FB73; Thu, 25 Feb 2021 20:52:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNL0wXwz3PTr; Thu, 25 Feb 2021 20:52: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 D3D911E3E9; Thu, 25 Feb 2021 20:52: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 11PKqT39079446; Thu, 25 Feb 2021 20:52:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqTaj079445; Thu, 25 Feb 2021 20:52:29 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:29 GMT Message-Id: <202102252052.11PKqTaj079445@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2e4940262c71 - releng/13.0 - Stop ignoring ERELOOKUP from VOP_INACTIVE() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 2e4940262c719672763181a6a735b17a6fb50b64 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, 25 Feb 2021 20:52:36 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2e4940262c719672763181a6a735b17a6fb50b64 commit 2e4940262c719672763181a6a735b17a6fb50b64 Author: Konstantin Belousov AuthorDate: 2021-01-30 19:17:29 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:49 +0000 Stop ignoring ERELOOKUP from VOP_INACTIVE() Approved by: re (delphij, gjb) (cherry picked from commit b59a8e63d6bf9092419b7a421c655d0ae2099662) --- sys/kern/vfs_subr.c | 47 ++++++++++++++++++++++++++++++++-------------- sys/sys/vnode.h | 3 ++- sys/ufs/ffs/ffs_snapshot.c | 8 +++++++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 047e4c54f0c5..04cd0e0175f9 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3159,9 +3159,21 @@ vput_final(struct vnode *vp, enum vput_op func) break; } if (error == 0) { - vinactive(vp); - if (want_unlock) - VOP_UNLOCK(vp); + if (func == VUNREF) { + VNASSERT((vp->v_vflag & VV_UNREF) == 0, vp, + ("recursive vunref")); + vp->v_vflag |= VV_UNREF; + } + for (;;) { + error = vinactive(vp); + if (want_unlock) + VOP_UNLOCK(vp); + if (error != ERELOOKUP || !want_unlock) + break; + VOP_LOCK(vp, LK_EXCLUSIVE); + } + if (func == VUNREF) + vp->v_vflag &= ~VV_UNREF; vdropl(vp); } else { vdefer_inactive(vp); @@ -3546,10 +3558,11 @@ vdropl(struct vnode *vp) * Call VOP_INACTIVE on the vnode and manage the DOINGINACT and OWEINACT * flags. DOINGINACT prevents us from recursing in calls to vinactive. */ -static void +static int vinactivef(struct vnode *vp) { struct vm_object *obj; + int error; ASSERT_VOP_ELOCKED(vp, "vinactive"); ASSERT_VI_LOCKED(vp, "vinactive"); @@ -3575,14 +3588,15 @@ vinactivef(struct vnode *vp) vm_object_page_clean(obj, 0, 0, 0); VM_OBJECT_WUNLOCK(obj); } - VOP_INACTIVE(vp); + error = VOP_INACTIVE(vp); VI_LOCK(vp); VNASSERT(vp->v_iflag & VI_DOINGINACT, vp, ("vinactive: lost VI_DOINGINACT")); vp->v_iflag &= ~VI_DOINGINACT; + return (error); } -void +int vinactive(struct vnode *vp) { @@ -3591,14 +3605,14 @@ vinactive(struct vnode *vp) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if ((vp->v_iflag & VI_OWEINACT) == 0) - return; + return (0); if (vp->v_iflag & VI_DOINGINACT) - return; + return (0); if (vp->v_usecount > 0) { vp->v_iflag &= ~VI_OWEINACT; - return; + return (0); } - vinactivef(vp); + return (vinactivef(vp)); } /* @@ -3911,10 +3925,15 @@ vgonel(struct vnode *vp) */ if (active) VOP_CLOSE(vp, FNONBLOCK, NOCRED, td); - if ((oweinact || active) && !doinginact) { - VI_LOCK(vp); - vinactivef(vp); - VI_UNLOCK(vp); + if (!doinginact) { + do { + if (oweinact || active) { + VI_LOCK(vp); + vinactivef(vp); + oweinact = (vp->v_iflag & VI_OWEINACT) != 0; + VI_UNLOCK(vp); + } + } while (oweinact); } if (vp->v_type == VSOCK) vfs_unp_reclaim(vp); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 78fbec1bd0ba..639a16881e09 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -269,6 +269,7 @@ struct xvnode { #define VV_MD 0x0800 /* vnode backs the md device */ #define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ #define VV_READLINK 0x2000 /* fdescfs linux vnode */ +#define VV_UNREF 0x4000 /* vunref, do not drop lock in inactive() */ #define VMP_LAZYLIST 0x0001 /* Vnode is on mnt's lazy list */ @@ -710,7 +711,7 @@ void vgone(struct vnode *vp); void vhold(struct vnode *); void vholdnz(struct vnode *); bool vhold_smr(struct vnode *); -void vinactive(struct vnode *vp); +int vinactive(struct vnode *vp); int vinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo); int vtruncbuf(struct vnode *vp, off_t length, int blksize); void v_inval_buf_range(struct vnode *vp, daddr_t startlbn, daddr_t endlbn, diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index b5daec14decf..72c8061917d8 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -2595,6 +2595,7 @@ process_deferred_inactive(struct mount *mp) continue; } vholdl(vp); +retry_vnode: error = vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK); if (error != 0) { vdrop(vp); @@ -2609,7 +2610,12 @@ process_deferred_inactive(struct mount *mp) UFS_INODE_SET_FLAG(ip, IN_MODIFIED); } VI_LOCK(vp); - vinactive(vp); + error = vinactive(vp); + if (error == ERELOOKUP && vp->v_usecount == 0) { + VI_UNLOCK(vp); + VOP_UNLOCK(vp); + goto retry_vnode; + } VI_UNLOCK(vp); VOP_UNLOCK(vp); vdrop(vp); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 B9A2B56FB50; Thu, 25 Feb 2021 20:52: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 4DmlN836PKz3PH1; Thu, 25 Feb 2021 20:52: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 C92D91E3E5; Thu, 25 Feb 2021 20:52:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqLTx079300; Thu, 25 Feb 2021 20:52:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqLuB079299; Thu, 25 Feb 2021 20:52:21 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:21 GMT Message-Id: <202102252052.11PKqLuB079299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b3162f7d998b - releng/13.0 - FFS: implement special VOP_VPUT_PAIR(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b3162f7d998bfb568819ce55046c3ae990512b61 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, 25 Feb 2021 20:52:26 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b3162f7d998bfb568819ce55046c3ae990512b61 commit b3162f7d998bfb568819ce55046c3ae990512b61 Author: Konstantin Belousov AuthorDate: 2021-01-27 18:09:53 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:58 +0000 FFS: implement special VOP_VPUT_PAIR(). Approved by: re (delphij, gjb) (cherry picked from commit f2c9d038bdee547be07c8b0404547617b71f2232) --- sys/ufs/ffs/ffs_vnops.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index be2653e32adc..623b13790ce0 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -130,6 +130,7 @@ static vop_listextattr_t ffs_listextattr; static vop_openextattr_t ffs_openextattr; static vop_setextattr_t ffs_setextattr; static vop_vptofh_t ffs_vptofh; +static vop_vput_pair_t ffs_vput_pair; /* Global vfs data structures for ufs. */ struct vop_vector ffs_vnodeops1 = { @@ -146,6 +147,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_reallocblks = ffs_reallocblks, .vop_write = ffs_write, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops1); @@ -182,6 +184,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_openextattr = ffs_openextattr, .vop_setextattr = ffs_setextattr, .vop_vptofh = ffs_vptofh, + .vop_vput_pair = ffs_vput_pair, }; VFS_VOP_VECTOR_REGISTER(ffs_vnodeops2); @@ -1917,3 +1920,55 @@ ffs_getpages_async(struct vop_getpages_async_args *ap) return (error); } + +static int +ffs_vput_pair(struct vop_vput_pair_args *ap) +{ + struct vnode *dvp, *vp, **vpp; + struct inode *dp; + int error, vp_locked; + + dvp = ap->a_dvp; + dp = VTOI(dvp); + vpp = ap->a_vpp; + vp = vpp != NULL ? *vpp : NULL; + + if ((dp->i_flag & IN_NEEDSYNC) == 0) { + vput(dvp); + if (vp != NULL && ap->a_unlock_vp) + vput(vp); + return (0); + } + + if (vp != NULL) { + if (ap->a_unlock_vp) { + vput(vp); + } else { + MPASS(vp->v_type != VNON); + vp_locked = VOP_ISLOCKED(vp); + VOP_UNLOCK(vp); + } + } + + do { + error = ffs_syncvnode(dvp, MNT_WAIT, 0); + } while (error == ERELOOKUP); + vput(dvp); + + if (vp == NULL || ap->a_unlock_vp) + return (0); + + /* + * It is possible that vp is reclaimed at this point. Only + * routines that call us with a_unlock_vp == false can find + * that their vp has been reclaimed. There are three areas + * that are affected: + * 1) vn_open_cred() - later VOPs could fail, but + * dead_open() returns 0 to simulate successful open. + * 2) ffs_snapshot() - creation of snapshot fails with EBADF. + * 3) NFS server (several places) - code is prepared to detect + * and respond to dead vnodes by returning ESTALE. + */ + VOP_LOCK(vp, vp_locked | LK_RETRY); + return (0); +} From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 855BD56FD77; Thu, 25 Feb 2021 20:52: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 4DmlN60w0zz3P5P; Thu, 25 Feb 2021 20:52: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 6C1E61E547; Thu, 25 Feb 2021 20:52: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 11PKqICP079234; Thu, 25 Feb 2021 20:52:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqIRQ079233; Thu, 25 Feb 2021 20:52:18 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:18 GMT Message-Id: <202102252052.11PKqIRQ079233@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 02c163e49b03 - releng/13.0 - Use VOP_VPUT_PAIR() for eligible VFS syscalls. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 02c163e49b03e6e6121f9e0d14a2f15c90b73bbd 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, 25 Feb 2021 20:52:24 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=02c163e49b03e6e6121f9e0d14a2f15c90b73bbd commit 02c163e49b03e6e6121f9e0d14a2f15c90b73bbd Author: Konstantin Belousov AuthorDate: 2021-01-28 22:31:30 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:42 +0000 Use VOP_VPUT_PAIR() for eligible VFS syscalls. Approved by: re (delphij, gjb) (cherry picked from commit 3b2aa36024abcb2d8fdbf3a6ecc7438b073b04e4) --- sys/kern/uipc_usrreq.c | 5 +++-- sys/kern/vfs_syscalls.c | 29 ++++++++++++----------------- sys/kern/vfs_vnops.c | 5 +++-- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 0809f5180cc1..ca23ccbdb05e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -669,8 +669,8 @@ restart: if (error == 0) error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); if (error) { + VOP_VPUT_PAIR(nd.ni_dvp, NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; @@ -686,7 +686,8 @@ restart: unp->unp_addr = soun; unp->unp_flags &= ~UNP_BINDING; UNP_PCB_UNLOCK(unp); - VOP_UNLOCK(vp); + vref(vp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); free(buf, M_TEMP); return (0); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 35a56510e9ef..aba3d62936bb 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1370,13 +1370,12 @@ restart: else { error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); } } - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 && !whiteout ? &nd.ni_vp : NULL, + true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; return (error); @@ -1457,12 +1456,10 @@ restart: goto out; #endif error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out: #endif - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) @@ -1629,10 +1626,10 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); - VOP_UNLOCK(vp); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, true); vn_finished_write(mp); NDFREE(&nd, NDF_ONLY_PNBUF); + vp = NULL; } else { vput(nd.ni_dvp); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1640,7 +1637,8 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, return (EAGAIN); } } - vrele(vp); + if (vp != NULL) + vrele(vp); return (error); } @@ -1710,6 +1708,7 @@ restart: else vput(nd.ni_dvp); vrele(nd.ni_vp); + nd.ni_vp = NULL; error = EEXIST; goto out; } @@ -1730,14 +1729,12 @@ restart: goto out2; #endif error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath); - if (error == 0) - vput(nd.ni_vp); #ifdef MAC out2: #endif - NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); if (error == ERELOOKUP) goto restart; out: @@ -3794,9 +3791,7 @@ restart: out: #endif NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_dvp); - if (error == 0) - vput(nd.ni_vp); + VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true); vn_finished_write(mp); if (error == ERELOOKUP) goto restart; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 3ec2662dfcd8..71dd379558cb 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -274,8 +274,9 @@ restart: if (error == 0) #endif error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, - &ndp->ni_cnd, vap); - vput(ndp->ni_dvp); + &ndp->ni_cnd, vap); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); vn_finished_write(mp); if (error) { NDFREE(ndp, NDF_ONLY_PNBUF); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 EB4DE56FF26; Thu, 25 Feb 2021 20:52: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 4DmlNT5CRkz3PF5; Thu, 25 Feb 2021 20:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DE53D1E3EB; Thu, 25 Feb 2021 20:52:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqbeS079592; Thu, 25 Feb 2021 20:52:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqbb6079591; Thu, 25 Feb 2021 20:52:37 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:37 GMT Message-Id: <202102252052.11PKqbb6079591@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9bef28f29446 - releng/13.0 - ffs: do not call softdep_prealloc() from UFS_BALLOC() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 9bef28f2944696906c7fa68223faaf12b17695dd 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, 25 Feb 2021 20:52:44 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9bef28f2944696906c7fa68223faaf12b17695dd commit 9bef28f2944696906c7fa68223faaf12b17695dd Author: Konstantin Belousov AuthorDate: 2021-02-18 14:51:50 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:42 +0000 ffs: do not call softdep_prealloc() from UFS_BALLOC() Approved by: re (delphij, gjb) (cherry picked from commit 49831462794690155ce8dbe02679e6d9390f3d7d) --- sys/ufs/ffs/ffs_balloc.c | 5 ----- sys/ufs/ffs/ffs_vnops.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index daa897dfe032..1b53a90a48c4 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -128,8 +128,6 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); /* * If the next write will extend the file into a new block, * and the file is currently composed of a fragment @@ -621,9 +619,6 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); - /* * Check for allocating external data. */ diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 1dfdf5182a42..c00469c4c7e3 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -834,6 +834,11 @@ ffs_write(ap) int blkoffset, error, flags, ioflag, size, xfersize; vp = ap->a_vp; + if (DOINGSUJ(vp)) + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + uio = ap->a_uio; ioflag = ap->a_ioflag; if (ap->a_ioflag & IO_EXT) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 BC2EB56FA72; Thu, 25 Feb 2021 20:52: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 4DmlN70mwrz3P2Z; Thu, 25 Feb 2021 20:52: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 8BA8D1E548; Thu, 25 Feb 2021 20:52: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 11PKqJSq079256; Thu, 25 Feb 2021 20:52:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqJXO079255; Thu, 25 Feb 2021 20:52:19 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:19 GMT Message-Id: <202102252052.11PKqJXO079255@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 56119250bbfe - releng/13.0 - ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 56119250bbfecee2121b309ecf7a61952c0c1998 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, 25 Feb 2021 20:52:24 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=56119250bbfecee2121b309ecf7a61952c0c1998 commit 56119250bbfecee2121b309ecf7a61952c0c1998 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:56:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:47 +0000 ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE. Approved by: re (delphij, gjb) (cherry picked from commit be44e986377780f533f961fe7c009b93379b4710) --- sys/ufs/ffs/ffs_snapshot.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 32dc47653d18..b5daec14decf 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -296,16 +296,21 @@ restart: goto restart; } error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vat); - VOP_UNLOCK(nd.ni_dvp); if (error) { + VOP_VPUT_PAIR(nd.ni_dvp, NULL, true); NDFREE(&nd, NDF_ONLY_PNBUF); vn_finished_write(wrtmp); - vrele(nd.ni_dvp); if (error == ERELOOKUP) goto restart; return (error); } vp = nd.ni_vp; + vref(nd.ni_dvp); + VOP_VPUT_PAIR(nd.ni_dvp, &vp, false); + if (VN_IS_DOOMED(vp)) { + error = EBADF; + goto out; + } vnode_create_vobject(nd.ni_vp, fs->fs_size, td); vp->v_vflag |= VV_SYSTEM; ip = VTOI(vp); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:39 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 A6A4056FE4E; Thu, 25 Feb 2021 20:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNQ0sY4z3PDr; Thu, 25 Feb 2021 20:52:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D9531E626; Thu, 25 Feb 2021 20:52: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 11PKqYC0079528; Thu, 25 Feb 2021 20:52:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqYAm079527; Thu, 25 Feb 2021 20:52:34 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:34 GMT Message-Id: <202102252052.11PKqYAm079527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: eed0fd5903e5 - releng/13.0 - ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: eed0fd5903e5629af1062d6047d090a1aca74bdd 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, 25 Feb 2021 20:52:39 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=eed0fd5903e5629af1062d6047d090a1aca74bdd commit eed0fd5903e5629af1062d6047d090a1aca74bdd Author: Konstantin Belousov AuthorDate: 2021-01-31 19:01:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:27 +0000 ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope Approved by: re (delphij, gjb) (cherry picked from commit 26af9f72f7cb162abeced8b7e444800b601e5017) --- sys/ufs/ffs/ffs_vnops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 38511647c502..1dfdf5182a42 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -591,6 +591,9 @@ ffs_unlock_debug(struct vop_unlock_args *ap) VI_UNLOCK(vp); } } + KASSERT(vp->v_type != VDIR || vp->v_vnlock->lk_recurse != 0 || + (ip->i_flag & IN_ENDOFF) == 0, + ("ufs dir vp %p ip %p flags %#x", vp, ip, ip->i_flag)); #ifdef DIAGNOSTIC if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE && ip != NULL && vp->v_vnlock->lk_recurse == 0) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 26F1856FF1F; Thu, 25 Feb 2021 20:52: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 4DmlNS4yfbz3PVF; Thu, 25 Feb 2021 20:52: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 DD27C1E550; Thu, 25 Feb 2021 20:52: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 11PKqahw079572; Thu, 25 Feb 2021 20:52:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqaU2079571; Thu, 25 Feb 2021 20:52:36 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:36 GMT Message-Id: <202102252052.11PKqaU2079571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 298fde182f38 - releng/13.0 - ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 298fde182f389b48eecd0f6f84c6479e743b70a8 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, 25 Feb 2021 20:52:43 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=298fde182f389b48eecd0f6f84c6479e743b70a8 commit 298fde182f389b48eecd0f6f84c6479e743b70a8 Author: Konstantin Belousov AuthorDate: 2021-02-19 12:37:12 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:37 +0000 ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ() Approved by: re (delphij, gjb) (cherry picked from commit cc9958bf22f1426faf4be8bf492ce69587a9008f) --- sys/ufs/ffs/ffs_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 3b652ea14303..c7a1e2dec15e 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -543,7 +543,7 @@ ffs_reallocblks(ap) * here. Instead we simply fail to reallocate blocks if this * rare condition arises. */ - if (DOINGSOFTDEP(ap->a_vp)) + if (DOINGSUJ(ap->a_vp)) if (softdep_prealloc(ap->a_vp, MNT_NOWAIT) != 0) return (ENOSPC); if (ump->um_fstype == UFS1) From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 1A1CA56FB51; Thu, 25 Feb 2021 20:52: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 4DmlN72ft7z3P0Q; Thu, 25 Feb 2021 20:52: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 A89001E61E; Thu, 25 Feb 2021 20:52: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 11PKqKXF079280; Thu, 25 Feb 2021 20:52:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqKSk079279; Thu, 25 Feb 2021 20:52:20 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:20 GMT Message-Id: <202102252052.11PKqKSk079279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2b2c2c7128ea - releng/13.0 - nfsserver: use VOP_VPUT_PAIR(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 2b2c2c7128ea1ee9ed049e9bca939772ed8d6ce1 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, 25 Feb 2021 20:52:26 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2b2c2c7128ea1ee9ed049e9bca939772ed8d6ce1 commit 2b2c2c7128ea1ee9ed049e9bca939772ed8d6ce1 Author: Konstantin Belousov AuthorDate: 2021-01-24 13:02:27 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:48:52 +0000 nfsserver: use VOP_VPUT_PAIR(). Approved by: re (delphij, gjb) (cherry picked from commit 4a21bcb24174438e0944d6e4d6633290a067b7a8) --- sys/fs/nfsserver/nfs_nfsdport.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index b781503a6815..4d19c73dfa06 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1105,7 +1105,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp, nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, nd->nd_cred, p); } - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); nfsvno_relpathbuf(ndp); if (!error) { if (*exclusive_flagp) { @@ -1140,7 +1141,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp, nvap->na_rdev = rdev; error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : + NULL, false); nfsvno_relpathbuf(ndp); vrele(ndp->ni_startdir); if (error) @@ -1221,7 +1223,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred, vrele(ndp->ni_startdir); error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, + false); nfsvno_relpathbuf(ndp); } else { if (nvap->na_type != VFIFO && @@ -1233,7 +1236,8 @@ nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred, } error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, + false); nfsvno_relpathbuf(ndp); vrele(ndp->ni_startdir); /* @@ -1268,7 +1272,7 @@ nfsvno_mkdir(struct nameidata *ndp, struct nfsvattr *nvap, uid_t saved_uid, } error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, false); nfsvno_relpathbuf(ndp); out: @@ -1300,17 +1304,15 @@ nfsvno_symlink(struct nameidata *ndp, struct nfsvattr *nvap, char *pathcp, error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr, pathcp); - vput(ndp->ni_dvp); - vrele(ndp->ni_startdir); - nfsvno_relpathbuf(ndp); /* * Although FreeBSD still had the lookup code in * it for 7/current, there doesn't seem to be any * point, since VOP_SYMLINK() returns the ni_vp. * Just vput it for v2. */ - if (!not_v2 && !error) - vput(ndp->ni_vp); + VOP_VPUT_PAIR(ndp->ni_dvp, &ndp->ni_vp, !not_v2 && error == 0); + vrele(ndp->ni_startdir); + nfsvno_relpathbuf(ndp); out: NFSEXITCODE(error); @@ -1595,11 +1597,13 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred, error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd); else error = EPERM; - if (ndp->ni_dvp == vp) + if (ndp->ni_dvp == vp) { vrele(ndp->ni_dvp); - else - vput(ndp->ni_dvp); - NFSVOPUNLOCK(vp); + NFSVOPUNLOCK(vp); + } else { + vref(vp); + VOP_VPUT_PAIR(ndp->ni_dvp, &vp, true); + } } else { if (ndp->ni_dvp == ndp->ni_vp) vrele(ndp->ni_dvp); @@ -1793,7 +1797,8 @@ nfsvno_open(struct nfsrv_descript *nd, struct nameidata *ndp, nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, cred, p); } - vput(ndp->ni_dvp); + VOP_VPUT_PAIR(ndp->ni_dvp, nd->nd_repstat == 0 ? + &ndp->ni_vp : NULL, false); nfsvno_relpathbuf(ndp); if (!nd->nd_repstat) { if (*exclusive_flagp) { @@ -4106,7 +4111,8 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, struct vattr *nvap, error = NFSVOPLOCK(dvp, LK_EXCLUSIVE); if (error == 0) { error = VOP_CREATE(dvp, &nvp, &named.ni_cnd, vap); - NFSVOPUNLOCK(dvp); + vref(dvp); + VOP_VPUT_PAIR(dvp, error == 0 ? &nvp : NULL, false); if (error == 0) { /* Set the ownership of the file. */ error = VOP_SETATTR(nvp, nvap, tcred); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 2745356FF20; Thu, 25 Feb 2021 20:52: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 4DmlNS6XTBz3PKD; Thu, 25 Feb 2021 20:52: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 0213E1E691; Thu, 25 Feb 2021 20:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqcWr079612; Thu, 25 Feb 2021 20:52:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqcBb079611; Thu, 25 Feb 2021 20:52:38 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:38 GMT Message-Id: <202102252052.11PKqcBb079611@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 16961e5e3fa4 - releng/13.0 - ffs_vnops.c: style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 16961e5e3fa47563743b7e4dd8892d017000477a 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, 25 Feb 2021 20:52:43 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=16961e5e3fa47563743b7e4dd8892d017000477a commit 16961e5e3fa47563743b7e4dd8892d017000477a Author: Konstantin Belousov AuthorDate: 2021-02-20 17:01:40 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:47 +0000 ffs_vnops.c: style Approved by: re (delphij, gjb) (cherry picked from commit c6d68ca842a3f5b6814cdd5c87e406bad579b792) --- sys/ufs/ffs/ffs_vnops.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index c00469c4c7e3..f9a6a36d178a 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1423,8 +1423,8 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td struct inode *ip; struct uio luio; struct iovec liovec; - int error; struct ufs2_dinode *dp; + int error; ip = VTOI(vp); @@ -1527,14 +1527,15 @@ struct vop_closeextattr_args { }; */ { + struct vnode *vp; - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + vp = ap->a_vp; + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - - if (ap->a_commit && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) + if (ap->a_commit && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) return (EROFS); - return (ffs_close_ea(ap->a_vp, ap->a_commit, ap->a_cred, ap->a_td)); + return (ffs_close_ea(vp, ap->a_commit, ap->a_cred, ap->a_td)); } /* @@ -1552,6 +1553,7 @@ vop_deleteextattr { }; */ { + struct vnode *vp; struct inode *ip; struct extattr *eap; uint32_t ul; @@ -1559,18 +1561,17 @@ vop_deleteextattr { u_char *eae; void *tmp; - ip = VTOI(ap->a_vp); + vp = ap->a_vp; + ip = VTOI(vp); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - if (strlen(ap->a_name) == 0) return (EINVAL); - - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, + error = extattr_check_cred(vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { /* @@ -1582,7 +1583,7 @@ vop_deleteextattr { return (error); } - error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td); + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1596,7 +1597,7 @@ vop_deleteextattr { if (olen == -1) { /* delete but nonexistent */ free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); return (ENOATTR); } ul = eap->ea_length; @@ -1608,7 +1609,7 @@ vop_deleteextattr { ip->i_ea_area = eae; ip->i_ea_len = easize; free(tmp, M_TEMP); - error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td); + error = ffs_close_ea(vp, 1, ap->a_cred, ap->a_td); return (error); } @@ -1741,6 +1742,7 @@ vop_setextattr { }; */ { + struct vnode *vp; struct inode *ip; struct fs *fs; struct extattr *eap; @@ -1750,12 +1752,12 @@ vop_setextattr { u_char *eae; void *tmp; - ip = VTOI(ap->a_vp); + vp = ap->a_vp; + ip = VTOI(vp); fs = ITOFS(ip); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (vp->v_type == VCHR || vp->v_type == VBLK) return (EOPNOTSUPP); - if (strlen(ap->a_name) == 0) return (EINVAL); @@ -1763,14 +1765,14 @@ vop_setextattr { if (ap->a_uio == NULL) return (EOPNOTSUPP); - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) + if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); ealen = ap->a_uio->uio_resid; if (ealen < 0 || ealen > lblktosize(fs, UFS_NXADDR)) return (EINVAL); - error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, + error = extattr_check_cred(vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); if (error) { /* @@ -1782,7 +1784,7 @@ vop_setextattr { return (error); } - error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td); + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1819,7 +1821,7 @@ vop_setextattr { } if (easize > lblktosize(fs, UFS_NXADDR)) { free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) ip->i_ea_error = ENOSPC; return (ENOSPC); @@ -1833,7 +1835,7 @@ vop_setextattr { error = uiomove(EXTATTR_CONTENT(eap), ealen, ap->a_uio); if (error) { free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); + ffs_close_ea(vp, 0, ap->a_cred, ap->a_td); if (ip->i_ea_area != NULL && ip->i_ea_error == 0) ip->i_ea_error = error; return (error); @@ -1844,7 +1846,7 @@ vop_setextattr { ip->i_ea_area = eae; ip->i_ea_len = easize; free(tmp, M_TEMP); - error = ffs_close_ea(ap->a_vp, 1, ap->a_cred, ap->a_td); + error = ffs_close_ea(vp, 1, ap->a_cred, ap->a_td); return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 CAA7F56FE54; Thu, 25 Feb 2021 20:52: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 4DmlNX23J5z3PSb; Thu, 25 Feb 2021 20:52: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 226211E551; Thu, 25 Feb 2021 20:52: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 11PKqeNV079634; Thu, 25 Feb 2021 20:52:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqeD6079633; Thu, 25 Feb 2021 20:52:40 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:40 GMT Message-Id: <202102252052.11PKqeD6079633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b287d46c385b - releng/13.0 - ffs_close_ea: do not relock vnode under lock_ea MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b287d46c385be71440693d3c0d8f4e098dee1207 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, 25 Feb 2021 20:52:46 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b287d46c385be71440693d3c0d8f4e098dee1207 commit b287d46c385be71440693d3c0d8f4e098dee1207 Author: Konstantin Belousov AuthorDate: 2021-02-21 10:10:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:52 +0000 ffs_close_ea: do not relock vnode under lock_ea Approved by: re (delphij, gjb) (cherry picked from commit 5e198e7646a27412c0541719f7bf1bbc0bd89223) --- sys/ufs/ffs/ffs_vnops.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index f9a6a36d178a..64c72f3d3cc4 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1422,9 +1422,10 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td { struct inode *ip; struct uio luio; - struct iovec liovec; + struct iovec *liovec; struct ufs2_dinode *dp; - int error; + size_t ea_len, tlen; + int error, i, lcnt; ip = VTOI(vp); @@ -1439,18 +1440,31 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td ASSERT_VOP_ELOCKED(vp, "ffs_close_ea commit"); if (cred == NOCRED) cred = vp->v_mount->mnt_cred; - liovec.iov_base = ip->i_ea_area; - liovec.iov_len = ip->i_ea_len; - luio.uio_iov = &liovec; - luio.uio_iovcnt = 1; + + ea_len = MAX(ip->i_ea_len, dp->di_extsize); + for (lcnt = 1, tlen = ea_len - ip->i_ea_len; tlen > 0;) { + tlen -= MIN(ZERO_REGION_SIZE, tlen); + lcnt++; + } + + liovec = __builtin_alloca(lcnt * sizeof(struct iovec)); + luio.uio_iovcnt = lcnt; + + liovec[0].iov_base = ip->i_ea_area; + liovec[0].iov_len = ip->i_ea_len; + for (i = 1, tlen = ea_len; i < lcnt; i++) { + liovec[i].iov_base = __DECONST(void *, zero_region); + liovec[i].iov_len = MIN(ZERO_REGION_SIZE, tlen); + tlen -= liovec[i].iov_len; + } + MPASS(tlen == ip->i_ea_len); + + luio.uio_iov = liovec; luio.uio_offset = 0; - luio.uio_resid = ip->i_ea_len; + luio.uio_resid = ea_len; luio.uio_segflg = UIO_SYSSPACE; luio.uio_rw = UIO_WRITE; luio.uio_td = td; - /* XXX: I'm not happy about truncating to zero size */ - if (ip->i_ea_len < dp->di_extsize) - error = ffs_truncate(vp, 0, IO_EXT, cred); error = ffs_extwrite(vp, &luio, IO_EXT | IO_SYNC, cred); } if (--ip->i_ea_refs == 0) { @@ -1460,6 +1474,9 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td ip->i_ea_error = 0; } ffs_unlock_ea(vp); + + if (commit && error == 0 && ip->i_ea_len == 0) + ffs_truncate(vp, 0, IO_EXT, cred); return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52:48 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 10CD956FAFD; Thu, 25 Feb 2021 20:52:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmlNY049pz3PVW; Thu, 25 Feb 2021 20:52: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 749BD1E5B1; Thu, 25 Feb 2021 20:52: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 11PKqgZc079674; Thu, 25 Feb 2021 20:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqgvh079673; Thu, 25 Feb 2021 20:52:42 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:42 GMT Message-Id: <202102252052.11PKqgvh079673@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f3a1daebaff5 - releng/13.0 - Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f3a1daebaff5181c69ba1086d63de694bf298c64 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, 25 Feb 2021 20:52:48 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f3a1daebaff5181c69ba1086d63de694bf298c64 commit f3a1daebaff5181c69ba1086d63de694bf298c64 Author: Kirk McKusick AuthorDate: 2021-02-12 05:31:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:51:10 +0000 Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash PR: 253158 Approved by: re (delphij, gjb) (cherry picked from commit 8563de2f2799b2cb6f2f06e3c9dddd48dca2a986) (cherry picked from commit c31480a1f66537e59b02e935a547bcfc76715278) --- sys/ufs/ffs/ffs_snapshot.c | 141 ++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 72c8061917d8..6da84fb46bb0 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -59,6 +59,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include #include @@ -316,21 +319,21 @@ restart: ip = VTOI(vp); devvp = ITODEVVP(ip); /* - * Allocate and copy the last block contents so as to be able - * to set size to that of the filesystem. + * Calculate the size of the filesystem then allocate the block + * immediately following the last block of the filesystem that + * will contain the snapshot list. This operation allows us to + * set the size of the snapshot. */ numblks = howmany(fs->fs_size, fs->fs_frag); - error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)), + error = UFS_BALLOC(vp, lblktosize(fs, (off_t)numblks), fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); if (error) goto out; - ip->i_size = lblktosize(fs, (off_t)numblks); + bawrite(bp); + ip->i_size = lblktosize(fs, (off_t)(numblks + 1)); + vnode_pager_setsize(vp, ip->i_size); DIP_SET(ip, i_size, ip->i_size); UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); - error = readblock(vp, bp, numblks - 1); - bawrite(bp); - if (error != 0) - goto out; /* * Preallocate critical data structures so that we can copy * them in without further allocation after we suspend all @@ -452,23 +455,13 @@ restart: vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (ip->i_effnlink == 0) { error = ENOENT; /* Snapshot file unlinked */ - goto out1; + goto resumefs; } #ifdef DIAGNOSTIC if (collectsnapstats) nanotime(&starttime); #endif - /* The last block might have changed. Copy it again to be sure. */ - error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)), - fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); - if (error != 0) - goto out1; - error = readblock(vp, bp, numblks - 1); - bp->b_flags |= B_VALIDSUSPWRT; - bawrite(bp); - if (error != 0) - goto out1; /* * First, copy all the cylinder group maps that have changed. */ @@ -479,11 +472,11 @@ restart: error = UFS_BALLOC(vp, lfragtosize(fs, cgtod(fs, cg)), fs->fs_bsize, KERNCRED, 0, &nbp); if (error) - goto out1; + goto resumefs; error = cgaccount(cg, vp, nbp, 2); bawrite(nbp); if (error) - goto out1; + goto resumefs; } /* * Grab a copy of the superblock and its summary information. @@ -513,11 +506,7 @@ restart: if ((error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + loc), len, KERNCRED, &bp)) != 0) { brelse(bp); - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; - goto out1; + goto resumefs; } bcopy(bp->b_data, space, (u_int)len); space = (char *)space + len; @@ -539,10 +528,27 @@ restart: * Note that we skip unlinked snapshot files as they will * be handled separately below. * - * We also calculate the needed size for the snapshot list. + * We also calculate the size needed for the snapshot list. + * Initial number of entries is composed of: + * - one for each cylinder group map + * - one for each block used by superblock summary table + * - one for each snapshot inode block + * - one for the superblock + * - one for the snapshot list + * The direct block entries in the snapshot are always + * copied (see reason below). Note that the superblock and + * the first cylinder group will almost always be allocated + * in the direct blocks, but we add the slop for them in case + * they do not end up there. The snapshot list size may get + * expanded by one because of an update of an inode block for + * an unlinked but still open file when it is expunged. + * + * Because the direct block pointers are always copied, they + * are not added to the list. Instead ffs_copyonwrite() + * explicitly checks for them before checking the snapshot list. */ snaplistsize = fs->fs_ncg + howmany(fs->fs_cssize, fs->fs_bsize) + - FSMAXSNAP + 1 /* superblock */ + 1 /* last block */ + 1 /* size */; + FSMAXSNAP + /* superblock */ 1 + /* snaplist */ 1; MNT_ILOCK(mp); mp->mnt_kern_flag &= ~MNTK_SUSPENDED; MNT_IUNLOCK(mp); @@ -624,12 +630,8 @@ loop: VOP_UNLOCK(xvp); vdrop(xvp); if (error) { - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp); - goto out1; + goto resumefs; } } /* @@ -637,13 +639,8 @@ loop: */ if (fs->fs_flags & FS_SUJ) { error = softdep_journal_lookup(mp, &xvp); - if (error) { - free(copy_fs->fs_csp, M_UFSMNT); - free(copy_fs->fs_si, M_UFSMNT); - free(copy_fs, M_UFSMNT); - copy_fs = NULL; - goto out1; - } + if (error) + goto resumefs; xp = VTOI(xvp); if (I_IS_UFS1(xp)) error = expunge_ufs1(vp, xp, copy_fs, fullacct_ufs1, @@ -694,6 +691,27 @@ loop: sn->sn_listsize = blkp - snapblklist; VI_UNLOCK(devvp); } + /* + * Preallocate all the direct blocks in the snapshot inode so + * that we never have to write the inode itself to commit an + * update to the contents of the snapshot. Note that once + * created, the size of the snapshot will never change, so + * there will never be a need to write the inode except to + * update the non-integrity-critical time fields and + * allocated-block count. + */ + for (blockno = 0; blockno < UFS_NDADDR; blockno++) { + if (DIP(ip, i_db[blockno]) != 0) + continue; + error = UFS_BALLOC(vp, lblktosize(fs, blockno), + fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); + if (error) + goto resumefs; + error = readblock(vp, bp, blockno); + bawrite(bp); + if (error != 0) + goto resumefs; + } /* * Record snapshot inode. Since this is the newest snapshot, * it must be placed at the end of the list. @@ -706,11 +724,16 @@ loop: TAILQ_INSERT_TAIL(&sn->sn_head, ip, i_nextsnap); devvp->v_vflag |= VV_COPYONWRITE; VI_UNLOCK(devvp); +resumefs: ASSERT_VOP_LOCKED(vp, "ffs_snapshot vp"); -out1: - KASSERT((sn != NULL && copy_fs != NULL && error == 0) || - (sn == NULL && copy_fs == NULL && error != 0), - ("email phk@ and mckusick@")); + if (error != 0 && copy_fs != NULL) { + free(copy_fs->fs_csp, M_UFSMNT); + free(copy_fs->fs_si, M_UFSMNT); + free(copy_fs, M_UFSMNT); + copy_fs = NULL; + } + KASSERT(error != 0 || (sn != NULL && copy_fs != NULL), + ("missing snapshot setup parameters")); /* * Resume operation on filesystem. */ @@ -786,7 +809,7 @@ out1: aiov.iov_base = (void *)snapblklist; aiov.iov_len = snaplistsize * sizeof(daddr_t); auio.uio_resid = aiov.iov_len; - auio.uio_offset = ip->i_size; + auio.uio_offset = lblktosize(fs, (off_t)numblks); auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_WRITE; auio.uio_td = td; @@ -835,27 +858,6 @@ out1: VI_UNLOCK(devvp); if (space != NULL) free(space, M_UFSMNT); - /* - * Preallocate all the direct blocks in the snapshot inode so - * that we never have to write the inode itself to commit an - * update to the contents of the snapshot. Note that once - * created, the size of the snapshot will never change, so - * there will never be a need to write the inode except to - * update the non-integrity-critical time fields and - * allocated-block count. - */ - for (blockno = 0; blockno < UFS_NDADDR; blockno++) { - if (DIP(ip, i_db[blockno]) != 0) - continue; - error = UFS_BALLOC(vp, lblktosize(fs, blockno), - fs->fs_bsize, KERNCRED, BA_CLRBUF, &bp); - if (error) - break; - error = readblock(vp, bp, blockno); - bawrite(bp); - if (error != 0) - break; - } done: free(copy_fs->fs_csp, M_UFSMNT); free(copy_fs->fs_si, M_UFSMNT); @@ -1573,7 +1575,8 @@ mapacct_ufs2(vp, oldblkp, lastblkp, fs, lblkno, expungetype) blkno = *oldblkp; if (blkno == 0 || blkno == BLK_NOCOPY) continue; - if (acctit && expungetype == BLK_SNAP && blkno != BLK_SNAP) + if (acctit && expungetype == BLK_SNAP && blkno != BLK_SNAP && + lblkno >= UFS_NDADDR) *ip->i_snapblklist++ = lblkno; if (blkno == BLK_SNAP) blkno = blkstofrags(fs, lblkno); @@ -2320,6 +2323,10 @@ ffs_copyonwrite(devvp, bp) ip = TAILQ_FIRST(&sn->sn_head); fs = ITOFS(ip); lbn = fragstoblks(fs, dbtofsb(fs, bp->b_blkno)); + if (lbn < UFS_NDADDR) { + VI_UNLOCK(devvp); + return (0); /* Direct blocks are always copied */ + } snapblklist = sn->sn_blklist; upper = sn->sn_listsize - 1; lower = 1; From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 9D79D56FAE5; Thu, 25 Feb 2021 20:52: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 4DmlNF5HfSz3PMw; Thu, 25 Feb 2021 20:52: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 9B7701E54F; Thu, 25 Feb 2021 20:52: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 11PKqRNg079404; Thu, 25 Feb 2021 20:52:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqR5k079403; Thu, 25 Feb 2021 20:52:27 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:27 GMT Message-Id: <202102252052.11PKqR5k079403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f889959e0a35 - releng/13.0 - ffs softdep: remove will_direnter argument of softdep_prelink() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f889959e0a35ae47205105d3074860272c639c04 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, 25 Feb 2021 20:52:32 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f889959e0a35ae47205105d3074860272c639c04 commit f889959e0a35ae47205105d3074860272c639c04 Author: Konstantin Belousov AuthorDate: 2021-01-23 22:40:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:35 +0000 ffs softdep: remove will_direnter argument of softdep_prelink() Approved by: re (delphij, gjb) (cherry picked from commit ede40b0675155b5cc862652f2fee11c738a46bcd) --- sys/ufs/ffs/ffs_extern.h | 2 +- sys/ufs/ffs/ffs_softdep.c | 46 ++++++++-------------------------------------- sys/ufs/ufs/ufs_vnops.c | 12 ++++++------ 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 9694489266b6..544012089046 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -178,7 +178,7 @@ int softdep_request_cleanup(struct fs *, struct vnode *, struct ucred *, int); int softdep_prerename(struct vnode *, struct vnode *, struct vnode *, struct vnode *); -int softdep_prelink(struct vnode *, struct vnode *, int); +int softdep_prelink(struct vnode *, struct vnode *); void softdep_setup_freeblocks(struct inode *, off_t, int); void softdep_setup_inomapdep(struct buf *, struct inode *, ino_t, int); void softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t, diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e90593b20e40..3cc76f9142c3 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -621,10 +621,9 @@ softdep_prerename(fdvp, fvp, tdvp, tvp) } int -softdep_prelink(dvp, vp, will_direnter) +softdep_prelink(dvp, vp) struct vnode *dvp; struct vnode *vp; - int will_direnter; { panic("softdep_prelink called"); @@ -3358,13 +3357,11 @@ softdep_prerename(fdvp, fvp, tdvp, tvp) * syscall must be restarted at top level from the lookup. */ int -softdep_prelink(dvp, vp, will_direnter) +softdep_prelink(dvp, vp) struct vnode *dvp; struct vnode *vp; - int will_direnter; { struct ufsmount *ump; - int error, error1; ASSERT_VOP_ELOCKED(dvp, "prelink dvp"); if (vp != NULL) @@ -3372,40 +3369,13 @@ softdep_prelink(dvp, vp, will_direnter) ump = VFSTOUFS(dvp->v_mount); /* - * Nothing to do if we have sufficient journal space. - * If we currently hold the snapshot lock, we must avoid - * handling other resources that could cause deadlock. - * - * will_direnter == 1: In case allocated a directory block in - * an indirect block, we must prevent holes in the directory - * created if directory entries are written out of order. To - * accomplish this we fsync when we extend a directory into - * indirects. During rename it's not safe to drop the tvp - * lock so sync must be delayed until it is. - * - * This synchronous step could be removed if fsck and the - * kernel were taught to fill in sparse directories rather - * than panic. + * Nothing to do if we have sufficient journal space. We skip + * flushing when vp is a snapshot to avoid deadlock where + * another thread is trying to update the inodeblock for dvp + * and is waiting on snaplk that vp holds. */ - if (journal_space(ump, 0) || (vp != NULL && IS_SNAPSHOT(VTOI(vp)))) { - error = 0; - if (will_direnter && (vp == NULL || !IS_SNAPSHOT(VTOI(vp)))) { - if (vp != NULL) - VOP_UNLOCK(vp); - error = ffs_syncvnode(dvp, MNT_WAIT, 0); - if (vp != NULL) { - error1 = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error1 != 0) { - vn_lock_pair(dvp, true, vp, false); - if (error == 0) - error = ERELOOKUP; - } else if (vp->v_data == NULL) { - error = ERELOOKUP; - } - } - } - return (error); - } + if (journal_space(ump, 0) || (vp != NULL && IS_SNAPSHOT(VTOI(vp)))) + return (0); stat_journal_low++; if (vp != NULL) { diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 22199a390dd4..b035a8b1c34d 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1007,7 +1007,7 @@ ufs_remove(ap) (VTOI(dvp)->i_flags & APPEND)) return (EPERM); if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, vp, true); + error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1072,7 +1072,7 @@ ufs_link(ap) #endif if (DOINGSOFTDEP(tdvp)) { - error = softdep_prelink(tdvp, vp, true); + error = softdep_prelink(tdvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1144,7 +1144,7 @@ ufs_whiteout(ap) if (DOINGSOFTDEP(dvp) && (ap->a_flags == CREATE || ap->a_flags == DELETE)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -1946,7 +1946,7 @@ ufs_mkdir(ap) } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -2210,7 +2210,7 @@ ufs_rmdir(ap) goto out; } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, vp, false); + error = softdep_prelink(dvp, vp); if (error != 0) { MPASS(error == ERELOOKUP); return (error); @@ -2737,7 +2737,7 @@ ufs_makeinode(mode, dvp, vpp, cnp, callfunc) return (EINVAL); } if (DOINGSOFTDEP(dvp)) { - error = softdep_prelink(dvp, NULL, true); + error = softdep_prelink(dvp, NULL); if (error != 0) { MPASS(error == ERELOOKUP); return (error); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 7A21356FEB5; Thu, 25 Feb 2021 20:52: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 4DmlNX4QPBz3PNf; Thu, 25 Feb 2021 20:52: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 35ED31E629; Thu, 25 Feb 2021 20:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqf60079656; Thu, 25 Feb 2021 20:52:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqf1T079655; Thu, 25 Feb 2021 20:52:41 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:41 GMT Message-Id: <202102252052.11PKqf1T079655@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6e3f19537ae6 - releng/13.0 - Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 6e3f19537ae6e91560fe7130a13cd47e63399146 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, 25 Feb 2021 20:52:48 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6e3f19537ae6e91560fe7130a13cd47e63399146 commit 6e3f19537ae6e91560fe7130a13cd47e63399146 Author: Konstantin Belousov AuthorDate: 2021-02-21 10:11:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:57 +0000 Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing Approved by: re (delphij, gjb) (cherry picked from commit 6f30ac9995ff662a2fee5eda4cd87dd0f0e337ba) --- sys/ufs/ffs/ffs_vnops.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 64c72f3d3cc4..af03b369a280 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1552,6 +1552,12 @@ struct vop_closeextattr_args { if (ap->a_commit && (vp->v_mount->mnt_flag & MNT_RDONLY) != 0) return (EROFS); + if (ap->a_commit && DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_closeextattr commit"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } return (ffs_close_ea(vp, ap->a_commit, ap->a_cred, ap->a_td)); } @@ -1600,6 +1606,13 @@ vop_deleteextattr { return (error); } + if (DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_deleteextattr"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); @@ -1801,6 +1814,13 @@ vop_setextattr { return (error); } + if (DOINGSUJ(vp)) { + ASSERT_VOP_ELOCKED(vp, "ffs_deleteextattr"); + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + } + error = ffs_open_ea(vp, ap->a_cred, ap->a_td); if (error) return (error); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 EA03556FB52; Thu, 25 Feb 2021 20:52: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 4DmlND0Kd2z3PCy; Thu, 25 Feb 2021 20:52: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 38FF81E5A9; Thu, 25 Feb 2021 20:52: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 11PKqOa3079342; Thu, 25 Feb 2021 20:52:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqOsa079341; Thu, 25 Feb 2021 20:52:24 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:24 GMT Message-Id: <202102252052.11PKqOsa079341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: b62d17802dcf - releng/13.0 - ufs_direnter: move directory truncation to ffs_vput_pair(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: b62d17802dcf9b589b6572a010e1a65820117155 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, 25 Feb 2021 20:52:29 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b62d17802dcf9b589b6572a010e1a65820117155 commit b62d17802dcf9b589b6572a010e1a65820117155 Author: Konstantin Belousov AuthorDate: 2021-01-27 20:34:14 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:49:09 +0000 ufs_direnter: move directory truncation to ffs_vput_pair(). Approved by: re (delphij, gjb) (cherry picked from commit 74a3652f832f4ed0f1ad9f7eb60d70013b478e1a) --- sys/ufs/ffs/ffs_vnops.c | 44 ++++++++++++++++++++++++++++++++++++++------ sys/ufs/ufs/inode.h | 2 ++ sys/ufs/ufs/ufs_lookup.c | 25 ++++++------------------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 2ac67adad5f2..dd0f1ba6b81d 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include "opt_directio.h" #include "opt_ffs.h" +#include "opt_ufs.h" #include #include @@ -99,6 +100,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#ifdef UFS_DIRHASH +#include +#endif #include #include @@ -1929,6 +1934,7 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) struct inode *dp, *ip; ino_t ip_ino; u_int64_t ip_gen; + off_t old_size; int error, vp_locked; dvp = ap->a_dvp; @@ -1936,14 +1942,14 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) vpp = ap->a_vpp; vp = vpp != NULL ? *vpp : NULL; - if ((dp->i_flag & IN_NEEDSYNC) == 0) { + if ((dp->i_flag & (IN_NEEDSYNC | IN_ENDOFF)) == 0) { vput(dvp); if (vp != NULL && ap->a_unlock_vp) vput(vp); return (0); } - mp = NULL; + mp = dvp->v_mount; if (vp != NULL) { if (ap->a_unlock_vp) { vput(vp); @@ -1953,14 +1959,40 @@ ffs_vput_pair(struct vop_vput_pair_args *ap) ip = VTOI(vp); ip_ino = ip->i_number; ip_gen = ip->i_gen; - mp = vp->v_mount; VOP_UNLOCK(vp); } } - do { - error = ffs_syncvnode(dvp, MNT_WAIT, 0); - } while (error == ERELOOKUP); + /* + * If compaction or fsync was requested do it in ffs_vput_pair() + * now that other locks are no longer held. + */ + if ((dp->i_flag & IN_ENDOFF) != 0) { + dp->i_flag &= ~IN_ENDOFF; + if (I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { + old_size = dp->i_size; + error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), + IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), + curthread->td_ucred); + if (error != 0 && error != ERELOOKUP) { + if (!ffs_fsfail_cleanup(VFSTOUFS(mp), error)) { + vn_printf(dvp, + "IN_ENDOFF: failed to truncate, " + "error %d\n", error); + } +#ifdef UFS_DIRHASH + ufsdirhash_free(dp); +#endif + } + } + SET_I_ENDOFF(dp, 0); + } + if ((dp->i_flag & IN_NEEDSYNC) != 0) { + do { + error = ffs_syncvnode(dvp, MNT_WAIT, 0); + } while (error == ERELOOKUP); + } + vput(dvp); if (vp == NULL || ap->a_unlock_vp) diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 16db8d6d5cea..4515dcbed401 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -152,6 +152,8 @@ struct inode { #define IN_IBLKDATA 0x0800 /* datasync requires inode block update */ #define IN_SIZEMOD 0x1000 /* Inode size has been modified */ +#define IN_ENDOFF 0x2000 /* Free space at the end of directory, + try to truncate when possible */ #define PRINT_INODE_FLAGS "\20\20b16\17b15\16b14\15sizemod" \ "\14iblkdata\13is_ufs2\12truncated\11ea_lockwait\10ea_locked" \ diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index e614f189a623..3036bce81caf 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1112,27 +1112,14 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp, isrename) } } UFS_INODE_SET_FLAG(dp, IN_CHANGE | IN_UPDATE); + /* - * If all went well, and the directory can be shortened, proceed - * with the truncation. Note that we have to unlock the inode for - * the entry that we just entered, as the truncation may need to - * lock other inodes which can lead to deadlock if we also hold a - * lock on the newly entered node. + * If all went well, and the directory can be shortened, mark directory inode + * with the truncation request right before unlock. */ - if (isrename == 0 && error == 0 && - I_ENDOFF(dp) != 0 && I_ENDOFF(dp) < dp->i_size) { - if (tvp != NULL) - VOP_UNLOCK(tvp); - error = UFS_TRUNCATE(dvp, (off_t)I_ENDOFF(dp), - IO_NORMAL | (DOINGASYNC(dvp) ? 0 : IO_SYNC), cr); - if (error != 0) - vn_printf(dvp, - "ufs_direnter: failed to truncate, error %d\n", - error); - error = 0; - if (tvp != NULL) - vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); - } + if (isrename == 0 && error == 0) + UFS_INODE_SET_FLAG(dp, IN_ENDOFF); + return (error); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 20:52: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 B00E356FEAD; Thu, 25 Feb 2021 20:52: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 4DmlNS0L3Bz3PZr; Thu, 25 Feb 2021 20:52: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 9AE8E1E627; Thu, 25 Feb 2021 20:52:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PKqZZv079550; Thu, 25 Feb 2021 20:52:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PKqZtc079549; Thu, 25 Feb 2021 20:52:35 GMT (envelope-from git) Date: Thu, 25 Feb 2021 20:52:35 GMT Message-Id: <202102252052.11PKqZtc079549@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: d1015ac54429 - releng/13.0 - fifo: minor comment and assert improvements. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: d1015ac5442990b1e916b7d0c4886f63b7079468 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, 25 Feb 2021 20:52:41 -0000 The branch releng/13.0 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d1015ac5442990b1e916b7d0c4886f63b7079468 commit d1015ac5442990b1e916b7d0c4886f63b7079468 Author: Konstantin Belousov AuthorDate: 2021-02-01 10:43:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-25 20:50:32 +0000 fifo: minor comment and assert improvements. Approved by: re (delphij, gjb) (cherry picked from commit adf28ab45670329459aed8afeec2dbe91c9b3713) --- sys/kern/vfs_syscalls.c | 3 ++- sys/ufs/ufs/ufs_vnops.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index aba3d62936bb..a51d693446e3 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1183,7 +1183,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, * vnode operations here. */ if (fp->f_ops == &badfileops) { - KASSERT(vp->v_type != VFIFO, ("Unexpected fifo.")); + KASSERT(vp->v_type != VFIFO, + ("Unexpected fifo fp %p vp %p", fp, vp)); finit_vnode(fp, flags, NULL, &vnops); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index e6a78c3655cc..301c583291d1 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -252,9 +252,10 @@ ufs_mknod(ap) DIP_SET(ip, i_rdev, vap->va_rdev); } /* - * Remove inode, then reload it through VFS_VGET so it is - * checked to see if it is an alias of an existing entry in - * the inode cache. XXX I don't believe this is necessary now. + * Remove inode, then reload it through VFS_VGET(). This is + * needed to do further inode initialization, for instance + * fifo, which was too early for VFS_VGET() done as part of + * UFS_VALLOC(). */ (*vpp)->v_type = VNON; ino = ip->i_number; /* Save this before vgone() invalidates ip. */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:32: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 11FBE54A323; Thu, 25 Feb 2021 21:32: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 4DmmG673G5z3msj; Thu, 25 Feb 2021 21:32: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 E4D261EEA4; Thu, 25 Feb 2021 21:32: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 11PLWEdQ033493; Thu, 25 Feb 2021 21:32:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLWECa033491; Thu, 25 Feb 2021 21:32:14 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:32:14 GMT Message-Id: <202102252132.11PLWECa033491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: ce9bc83f9146 - releng/13.0 - arm64: validate breakpoint registers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: ce9bc83f914623a2f2309b10786bafc0d481054c 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, 25 Feb 2021 21:32:15 -0000 The branch releng/13.0 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=ce9bc83f914623a2f2309b10786bafc0d481054c commit ce9bc83f914623a2f2309b10786bafc0d481054c Author: Mitchell Horne AuthorDate: 2021-02-09 18:29:38 +0000 Commit: Mitchell Horne CommitDate: 2021-02-25 21:30:45 +0000 arm64: validate breakpoint registers In particular, we want to disallow setting breakpoints on kernel addresses from userspace. The control register fields are validated or ignored as appropriate. Reviewed by: markj Sponsored by: The FreeBSD Foundation Approved by: re (gjb) (cherry picked from commit de2b9422807586d376ec7ffa7b660cd492464bdf) (cherry picked from commit 8837e9c54072679b69ae0c0345e7ef7d241255aa) --- sys/arm64/arm64/machdep.c | 37 +++++++++++++++++++++++++++++++++---- sys/arm64/include/armreg.h | 17 +++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 90fc19d57415..bf44dba19482 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -357,6 +357,8 @@ int set_dbregs(struct thread *td, struct dbreg *regs) { struct debug_monitor_state *monitor; + uint64_t addr; + uint32_t ctrl; int count; int i; @@ -364,11 +366,38 @@ set_dbregs(struct thread *td, struct dbreg *regs) count = 0; monitor->dbg_enable_count = 0; for (i = 0; i < DBG_BRP_MAX; i++) { - /* TODO: Check these values */ - monitor->dbg_bvr[i] = regs->db_regs[i].dbr_addr; - monitor->dbg_bcr[i] = regs->db_regs[i].dbr_ctrl; - if ((monitor->dbg_bcr[i] & 1) != 0) + addr = regs->db_regs[i].dbr_addr; + ctrl = regs->db_regs[i].dbr_ctrl; + + /* Don't let the user set a breakpoint on a kernel address. */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * The lowest 2 bits are ignored, so record the effective + * address. + */ + addr = rounddown2(addr, 4); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked, address-matching breakpoints are supported. + * + * XXX: fields that appear unvalidated, such as BAS, have + * constrained undefined behaviour. If the user mis-programs + * these, there is no risk to the system. + */ + ctrl &= DBG_BCR_EN | DBG_BCR_PMC | DBG_BCR_BAS; + if ((ctrl & DBG_BCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_BCR_PMC) != DBG_BCR_PMC_EL0) + return (EINVAL); + monitor->dbg_enable_count++; + } + + monitor->dbg_bvr[i] = addr; + monitor->dbg_bcr[i] = ctrl; } if (monitor->dbg_enable_count > 0) monitor->dbg_flags |= DBGMON_ENABLED; diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 201d7559320b..73d1010057b9 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -943,6 +943,23 @@ #define DBG_MDSCR_KDE (0x1 << 13) #define DBG_MDSCR_MDE (0x1 << 15) +/* Debug Breakpoint Control Registers */ +#define DBG_BCR_EN 0x1 +#define DBG_BCR_PMC_SHIFT 1 +#define DBG_BCR_PMC (0x3 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_PMC_EL1 (0x1 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_PMC_EL0 (0x2 << DBG_BCR_PMC_SHIFT) +#define DBG_BCR_BAS_SHIFT 5 +#define DBG_BCR_BAS (0xf << DBG_BCR_BAS_SHIFT) +#define DBG_BCR_HMC_SHIFT 13 +#define DBG_BCR_HMC (0x1 << DBG_BCR_HMC_SHIFT) +#define DBG_BCR_SSC_SHIFT 14 +#define DBG_BCR_SSC (0x3 << DBG_BCR_SSC_SHIFT) +#define DBG_BCR_LBN_SHIFT 16 +#define DBG_BCR_LBN (0xf << DBG_BCR_LBN_SHIFT) +#define DBG_BCR_BT_SHIFT 20 +#define DBG_BCR_BT (0xf << DBG_BCR_BT_SHIFT) + /* Perfomance Monitoring Counters */ #define PMCR_E (1 << 0) /* Enable all counters */ #define PMCR_P (1 << 1) /* Reset all counters */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:32: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 1960454A329; Thu, 25 Feb 2021 21:32: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 4DmmG80G7Lz3mWL; Thu, 25 Feb 2021 21:32: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 EE43D1EDAE; Thu, 25 Feb 2021 21:32:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PLWFm0033512; Thu, 25 Feb 2021 21:32:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLWFPl033511; Thu, 25 Feb 2021 21:32:15 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:32:15 GMT Message-Id: <202102252132.11PLWFPl033511@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 8f686c0f29f0 - releng/13.0 - arm64: handle watchpoint exceptions from EL0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 8f686c0f29f094eba305d7911195bd629c3954bb 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, 25 Feb 2021 21:32:16 -0000 The branch releng/13.0 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8f686c0f29f094eba305d7911195bd629c3954bb commit 8f686c0f29f094eba305d7911195bd629c3954bb Author: Mitchell Horne AuthorDate: 2021-02-05 21:46:48 +0000 Commit: Mitchell Horne CommitDate: 2021-02-25 21:31:17 +0000 arm64: handle watchpoint exceptions from EL0 This is a prerequisite to allowing the use of hardware watchpoints for userspace debuggers. This is also a slight departure from the x86 behaviour, since `si_addr` returns the data address that triggered the watchpoint, not the address of the instruction that was executed. Otherwise, there is no straightforward way for the application to determine which watchpoint was triggered. Make a note of this in the siginfo(3) man page. Reviewed by: jhb, markj (earlier version) Tested by: Michał Górny (mgorny@gentoo.org) Sponsored by: The FreeBSD Foundation Approved by: re (gjb) (cherry picked from commit bd012c71592323d957b409bb5e0cf7940729650e) (cherry picked from commit 9372df63ad5b814440732d171c8f04f0e1c26b87) --- share/man/man3/siginfo.3 | 7 ++++++- sys/arm64/arm64/trap.c | 6 ++++++ sys/arm64/include/armreg.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/share/man/man3/siginfo.3 b/share/man/man3/siginfo.3 index fc4ea2ba1df7..acc8785b2f0d 100644 --- a/share/man/man3/siginfo.3 +++ b/share/man/man3/siginfo.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 28, 2020 +.Dd February 17, 2021 .Dt SIGINFO 3 .Os .Sh NAME @@ -218,6 +218,11 @@ and may report the address of the faulting memory access (if available) in .Va si_addr instead. +Additionally +.Dv SIGTRAP +raised by a hardware watchpoint exception may report the data address that +triggered the watchpoint in +.Va si_addr . .Pp Sychronous signals set .Va si_trapno diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 0b2d4760cea3..cb3a05ad0163 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -474,6 +474,7 @@ do_el0_sync(struct thread *td, struct trapframe *frame) case EXCP_UNKNOWN: case EXCP_DATA_ABORT_L: case EXCP_DATA_ABORT: + case EXCP_WATCHPT_EL0: far = READ_SPECIALREG(far_el1); break; } @@ -534,6 +535,11 @@ do_el0_sync(struct thread *td, struct trapframe *frame) exception); userret(td, frame); break; + case EXCP_WATCHPT_EL0: + call_trapsignal(td, SIGTRAP, TRAP_TRACE, (void *)far, + exception); + userret(td, frame); + break; case EXCP_MSR: /* * The CPU can raise EXCP_MSR when userspace executes an mrs diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 73d1010057b9..66cd8591c7ab 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -230,6 +230,7 @@ #define EXCP_BRKPT_EL0 0x30 /* Hardware breakpoint, from same EL */ #define EXCP_SOFTSTP_EL0 0x32 /* Software Step, from lower EL */ #define EXCP_SOFTSTP_EL1 0x33 /* Software Step, from same EL */ +#define EXCP_WATCHPT_EL0 0x34 /* Watchpoint, from lower EL */ #define EXCP_WATCHPT_EL1 0x35 /* Watchpoint, from same EL */ #define EXCP_BRK 0x3c /* Breakpoint */ From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:32:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 97B2554A32E; Thu, 25 Feb 2021 21:32:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmmG91fMKz3mf6; Thu, 25 Feb 2021 21:32:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 20C2C1EE2B; Thu, 25 Feb 2021 21:32:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PLWH2f033530; Thu, 25 Feb 2021 21:32:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLWHKU033529; Thu, 25 Feb 2021 21:32:17 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:32:17 GMT Message-Id: <202102252132.11PLWHKU033529@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: f1847ed16ebd - releng/13.0 - arm64: extend struct db_reg to include watchpoint registers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: f1847ed16ebd16d91766934ff7c28e887fbd2846 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, 25 Feb 2021 21:32:18 -0000 The branch releng/13.0 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=f1847ed16ebd16d91766934ff7c28e887fbd2846 commit f1847ed16ebd16d91766934ff7c28e887fbd2846 Author: Mitchell Horne AuthorDate: 2021-01-28 17:49:47 +0000 Commit: Mitchell Horne CommitDate: 2021-02-25 21:31:31 +0000 arm64: extend struct db_reg to include watchpoint registers The motivation is to provide access to these registers from userspace via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS. This change breaks the ABI of these particular requests, but is justified by the fact that the intended consumers (debuggers) have not been taught to use them yet. Making this change now enables active upstream work on lldb to begin using this interface, and take advantage of the hardware debugging registers available on the platform. PR: 252860 Reported by: Michał Górny (mgorny@gentoo.org) Reviewed by: andrew, markj (earlier version) Tested by: Michał Górny (mgorny@gentoo.org) Sponsored by: The FreeBSD Foundation Approved by: re (gjb) (cherry picked from commit f2583be110ca3a5b32f0993f1464a5c69151c62f) (cherry picked from commit 4786c8582c569a7245dadbdbb4638d1667c10d62) --- sys/arm64/arm64/identcpu.c | 2 +- sys/arm64/arm64/machdep.c | 71 ++++++++++++++++++++++++++++++++++++++-------- sys/arm64/include/armreg.h | 22 ++++++++++++++ sys/arm64/include/reg.h | 13 +++++++-- 4 files changed, 92 insertions(+), 16 deletions(-) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index bfbaad7a6483..c3544e9de9aa 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -350,7 +350,7 @@ static struct mrs_field id_aa64dfr0_fields[] = { MRS_FIELD(ID_AA64DFR0, PMSVer, false, MRS_EXACT, id_aa64dfr0_pmsver), MRS_FIELD(ID_AA64DFR0, CTX_CMPs, false, MRS_EXACT, id_aa64dfr0_ctx_cmps), - MRS_FIELD(ID_AA64DFR0, WRPs, false, MRS_EXACT, id_aa64dfr0_wrps), + MRS_FIELD(ID_AA64DFR0, WRPs, false, MRS_LOWER, id_aa64dfr0_wrps), MRS_FIELD(ID_AA64DFR0, BRPs, false, MRS_LOWER, id_aa64dfr0_brps), MRS_FIELD(ID_AA64DFR0, PMUVer, false, MRS_EXACT, id_aa64dfr0_pmuver), MRS_FIELD(ID_AA64DFR0, TraceVer, false, MRS_EXACT, diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index bf44dba19482..73b06beeba7e 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -321,8 +321,8 @@ int fill_dbregs(struct thread *td, struct dbreg *regs) { struct debug_monitor_state *monitor; - int count, i; - uint8_t debug_ver, nbkpts; + int i; + uint8_t debug_ver, nbkpts, nwtpts; memset(regs, 0, sizeof(*regs)); @@ -330,23 +330,30 @@ fill_dbregs(struct thread *td, struct dbreg *regs) &debug_ver); extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_BRPs_SHIFT, &nbkpts); + extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_WRPs_SHIFT, + &nwtpts); /* * The BRPs field contains the number of breakpoints - 1. Armv8-A * allows the hardware to provide 2-16 breakpoints so this won't - * overflow an 8 bit value. + * overflow an 8 bit value. The same applies to the WRPs field. */ - count = nbkpts + 1; + nbkpts++; + nwtpts++; - regs->db_info = debug_ver; - regs->db_info <<= 8; - regs->db_info |= count; + regs->db_debug_ver = debug_ver; + regs->db_nbkpts = nbkpts; + regs->db_nwtpts = nwtpts; monitor = &td->td_pcb->pcb_dbg_regs; if ((monitor->dbg_flags & DBGMON_ENABLED) != 0) { - for (i = 0; i < count; i++) { - regs->db_regs[i].dbr_addr = monitor->dbg_bvr[i]; - regs->db_regs[i].dbr_ctrl = monitor->dbg_bcr[i]; + for (i = 0; i < nbkpts; i++) { + regs->db_breakregs[i].dbr_addr = monitor->dbg_bvr[i]; + regs->db_breakregs[i].dbr_ctrl = monitor->dbg_bcr[i]; + } + for (i = 0; i < nwtpts; i++) { + regs->db_watchregs[i].dbw_addr = monitor->dbg_wvr[i]; + regs->db_watchregs[i].dbw_ctrl = monitor->dbg_wcr[i]; } } @@ -365,9 +372,10 @@ set_dbregs(struct thread *td, struct dbreg *regs) monitor = &td->td_pcb->pcb_dbg_regs; count = 0; monitor->dbg_enable_count = 0; + for (i = 0; i < DBG_BRP_MAX; i++) { - addr = regs->db_regs[i].dbr_addr; - ctrl = regs->db_regs[i].dbr_ctrl; + addr = regs->db_breakregs[i].dbr_addr; + ctrl = regs->db_breakregs[i].dbr_ctrl; /* Don't let the user set a breakpoint on a kernel address. */ if (addr >= VM_MAXUSER_ADDRESS) @@ -399,6 +407,45 @@ set_dbregs(struct thread *td, struct dbreg *regs) monitor->dbg_bvr[i] = addr; monitor->dbg_bcr[i] = ctrl; } + + for (i = 0; i < DBG_WRP_MAX; i++) { + addr = regs->db_watchregs[i].dbw_addr; + ctrl = regs->db_watchregs[i].dbw_ctrl; + + /* Don't let the user set a watchpoint on a kernel address. */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked watchpoints are supported. + */ + ctrl &= DBG_WCR_EN | DBG_WCR_PAC | DBG_WCR_LSC | DBG_WCR_BAS | + DBG_WCR_MASK; + + if ((ctrl & DBG_WCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_WCR_PAC) != DBG_WCR_PAC_EL0) + return (EINVAL); + + /* Must set at least one of the load/store bits. */ + if ((ctrl & DBG_WCR_LSC) == 0) + return (EINVAL); + + /* + * When specifying the address range with BAS, the MASK + * field must be zero. + */ + if ((ctrl & DBG_WCR_BAS) != DBG_WCR_BAS_MASK && + (ctrl & DBG_WCR_MASK) != 0) + return (EINVAL); + + monitor->dbg_enable_count++; + } + monitor->dbg_wvr[i] = addr; + monitor->dbg_wcr[i] = ctrl; + } + if (monitor->dbg_enable_count > 0) monitor->dbg_flags |= DBGMON_ENABLED; diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 66cd8591c7ab..81cea5431017 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -961,6 +961,28 @@ #define DBG_BCR_BT_SHIFT 20 #define DBG_BCR_BT (0xf << DBG_BCR_BT_SHIFT) +/* Debug Watchpoint Control Registers */ +#define DBG_WCR_EN 0x1 +#define DBG_WCR_PAC_SHIFT 1 +#define DBG_WCR_PAC (0x3 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_PAC_EL1 (0x1 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_PAC_EL0 (0x2 << DBG_WCR_PAC_SHIFT) +#define DBG_WCR_LSC_SHIFT 3 +#define DBG_WCR_LSC (0x3 << DBG_WCR_LSC_SHIFT) +#define DBG_WCR_BAS_SHIFT 5 +#define DBG_WCR_BAS (0xff << DBG_WCR_BAS_SHIFT) +#define DBG_WCR_BAS_MASK DBG_WCR_BAS +#define DBG_WCR_HMC_SHIFT 13 +#define DBG_WCR_HMC (0x1 << DBG_WCR_HMC_SHIFT) +#define DBG_WCR_SSC_SHIFT 14 +#define DBG_WCR_SSC (0x3 << DBG_WCR_SSC_SHIFT) +#define DBG_WCR_LBN_SHIFT 16 +#define DBG_WCR_LBN (0xf << DBG_WCR_LBN_SHIFT) +#define DBG_WCR_WT_SHIFT 20 +#define DBG_WCR_WT (0x1 << DBG_WCR_WT_SHIFT) +#define DBG_WCR_MASK_SHIFT 24 +#define DBG_WCR_MASK (0x1f << DBG_WCR_MASK_SHIFT) + /* Perfomance Monitoring Counters */ #define PMCR_E (1 << 0) /* Enable all counters */ #define PMCR_P (1 << 1) /* Reset all counters */ diff --git a/sys/arm64/include/reg.h b/sys/arm64/include/reg.h index aafe02b70925..9cfc5ea1d437 100644 --- a/sys/arm64/include/reg.h +++ b/sys/arm64/include/reg.h @@ -60,14 +60,21 @@ struct fpreg32 { }; struct dbreg { - uint32_t db_info; - uint32_t db_pad; + uint8_t db_debug_ver; + uint8_t db_nbkpts; + uint8_t db_nwtpts; + uint8_t db_pad[5]; struct { uint64_t dbr_addr; uint32_t dbr_ctrl; uint32_t dbr_pad; - } db_regs[16]; + } db_breakregs[16]; + struct { + uint64_t dbw_addr; + uint32_t dbw_ctrl; + uint32_t dbw_pad; + } db_watchregs[16]; }; struct dbreg32 { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:42:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 59F0554A678; Thu, 25 Feb 2021 21:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmmTb235vz3nPf; Thu, 25 Feb 2021 21:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F0AE1F191; Thu, 25 Feb 2021 21:42:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PLgBLn046600; Thu, 25 Feb 2021 21:42:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLgBUi046599; Thu, 25 Feb 2021 21:42:11 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:42:11 GMT Message-Id: <202102252142.11PLgBUi046599@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Watson Subject: git: bbcdd9faca55 - stable/13 - Reimplemen FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rwatson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bbcdd9faca55758b228b949f1c1bb41b85e90a8e 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, 25 Feb 2021 21:42:11 -0000 The branch stable/13 has been updated by rwatson: URL: https://cgit.FreeBSD.org/src/commit/?id=bbcdd9faca55758b228b949f1c1bb41b85e90a8e commit bbcdd9faca55758b228b949f1c1bb41b85e90a8e Author: Robert Watson AuthorDate: 2021-02-16 15:19:05 +0000 Commit: Robert Watson CommitDate: 2021-02-25 21:38:30 +0000 Reimplemen FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. Approved by: re (gjb) Reviewed by: andrew, bsdimp (older version) Useful comments appreciated: jrtc27, emaste Differential Revision: https://reviews.freebsd.org/D28723 --- sys/cddl/dev/dtrace/aarch64/dtrace_subr.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c index 6646e51fc191..9bf9f0798bb5 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c @@ -153,23 +153,26 @@ dtrace_sync(void) } /* - * DTrace needs a high resolution time function which can - * be called from a probe context and guaranteed not to have - * instrumented with probes itself. + * DTrace needs a high resolution time function which can be called from a + * probe context and guaranteed not to have instrumented with probes itself. * - * Returns nanoseconds since boot. + * Returns nanoseconds since some arbitrary point in time (likely SoC reset?). */ uint64_t -dtrace_gethrtime() +dtrace_gethrtime(void) { - struct timespec curtime; - - dtrace_getnanouptime(&curtime); - - return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec); + uint64_t count, freq; + count = READ_SPECIALREG(cntvct_el0); + freq = READ_SPECIALREG(cntfrq_el0); + return ((1000000000UL * count) / freq); } +/* + * Return a much lower resolution wallclock time based on the system clock + * updated by the timer. If needed, we could add a version interpolated from + * the system clock as is the case with dtrace_gethrtime(). + */ uint64_t dtrace_gethrestime(void) { From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:44:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E837B54AAC4; Thu, 25 Feb 2021 21:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmmXQ61J0z3p6d; Thu, 25 Feb 2021 21:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF7CC1F1A3; Thu, 25 Feb 2021 21:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11PLic7h047089; Thu, 25 Feb 2021 21:44:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLic3p047088; Thu, 25 Feb 2021 21:44:38 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:44:38 GMT Message-Id: <202102252144.11PLic3p047088@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 7dfdd039a358 - stable/13 - Fix crash with rtadv-originated multipath IPv6 routes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7dfdd039a3584885648d33888359032479038dc1 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, 25 Feb 2021 21:44:39 -0000 The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=7dfdd039a3584885648d33888359032479038dc1 commit 7dfdd039a3584885648d33888359032479038dc1 Author: Alexander V. Chernikov AuthorDate: 2021-02-24 16:42:48 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-02-25 21:43:37 +0000 Fix crash with rtadv-originated multipath IPv6 routes. PR: 253800 Reported by: Frederic Denis MFC after: immediately (cherry picked from commit cc3fa1e29fda2cc761e793a61cef3bd2522b3468) --- sys/netinet6/nd6_rtr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 51b831a956bc..2f721b4edcc3 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -699,7 +698,7 @@ defrouter_addreq(struct nd_defrouter *new) NET_EPOCH_ASSERT(); error = rib_action(fibnum, RTM_ADD, &info, &rc); if (error == 0) { - struct nhop_object *nh = nhop_select(rc.rc_nh_new, 0); + struct nhop_object *nh = nhop_select_func(rc.rc_nh_new, 0); rt_routemsg(RTM_ADD, rc.rc_rt, nh, fibnum); new->installed = 1; } @@ -739,7 +738,7 @@ defrouter_delreq(struct nd_defrouter *dr) NET_EPOCH_ENTER(et); error = rib_action(fibnum, RTM_DELETE, &info, &rc); if (error == 0) { - struct nhop_object *nh = nhop_select(rc.rc_nh_old, 0); + struct nhop_object *nh = nhop_select_func(rc.rc_nh_old, 0); rt_routemsg(RTM_DELETE, rc.rc_rt, nh, fibnum); } NET_EPOCH_EXIT(et); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:56: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 C6B7654AD45; Thu, 25 Feb 2021 21:56: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 4Dmmp95GkSz3q3G; Thu, 25 Feb 2021 21:56: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 A30C71EDEE; Thu, 25 Feb 2021 21:56: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 11PLuX7Q060455; Thu, 25 Feb 2021 21:56:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLuX3k060454; Thu, 25 Feb 2021 21:56:33 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:56:33 GMT Message-Id: <202102252156.11PLuX3k060454@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 5dde6e460a1f - releng/13.0 - Fix nd6 rib_action() handling. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 5dde6e460a1f76842f884e1f6a53df8e7648756b 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, 25 Feb 2021 21:56:33 -0000 The branch releng/13.0 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=5dde6e460a1f76842f884e1f6a53df8e7648756b commit 5dde6e460a1f76842f884e1f6a53df8e7648756b Author: Alexander V. Chernikov AuthorDate: 2021-02-23 22:31:07 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-02-25 21:55:52 +0000 Fix nd6 rib_action() handling. rib_action() guarantees valid rc filling IFF it returns without error. Check rib_action() return code instead of checking rc fields. PR: 253800 Reported by: Frederic Denis Approved by: re(gjb) (cherry picked from commit ea10694336b9a07d58d22187052291976f4906b2) --- sys/netinet6/nd6_rtr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index eca704dc2843..51b831a956bc 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -698,12 +698,11 @@ defrouter_addreq(struct nd_defrouter *new) NET_EPOCH_ASSERT(); error = rib_action(fibnum, RTM_ADD, &info, &rc); - if (rc.rc_rt != NULL) { + if (error == 0) { struct nhop_object *nh = nhop_select(rc.rc_nh_new, 0); rt_routemsg(RTM_ADD, rc.rc_rt, nh, fibnum); - } - if (error == 0) new->installed = 1; + } } /* @@ -719,6 +718,7 @@ defrouter_delreq(struct nd_defrouter *dr) struct rib_cmd_info rc; struct epoch_tracker et; unsigned int fibnum; + int error; bzero(&def, sizeof(def)); bzero(&mask, sizeof(mask)); @@ -737,8 +737,8 @@ defrouter_delreq(struct nd_defrouter *dr) info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; NET_EPOCH_ENTER(et); - rib_action(fibnum, RTM_DELETE, &info, &rc); - if (rc.rc_rt != NULL) { + error = rib_action(fibnum, RTM_DELETE, &info, &rc); + if (error == 0) { struct nhop_object *nh = nhop_select(rc.rc_nh_old, 0); rt_routemsg(RTM_DELETE, rc.rc_rt, nh, fibnum); } From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 21:56:35 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 0B15854ACE7; Thu, 25 Feb 2021 21:56:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmmpB6FR6z3pvh; Thu, 25 Feb 2021 21:56: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 C0D7C1F0DA; Thu, 25 Feb 2021 21:56: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 11PLuYw7060477; Thu, 25 Feb 2021 21:56:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PLuYvl060476; Thu, 25 Feb 2021 21:56:34 GMT (envelope-from git) Date: Thu, 25 Feb 2021 21:56:34 GMT Message-Id: <202102252156.11PLuYvl060476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 52d4c9e2fa02 - releng/13.0 - Fix crash with rtadv-originated multipath IPv6 routes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 52d4c9e2fa024c36ea75ad17c50a9e66d2dbdc8c 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, 25 Feb 2021 21:56:35 -0000 The branch releng/13.0 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=52d4c9e2fa024c36ea75ad17c50a9e66d2dbdc8c commit 52d4c9e2fa024c36ea75ad17c50a9e66d2dbdc8c Author: Alexander V. Chernikov AuthorDate: 2021-02-24 16:42:48 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-02-25 21:55:58 +0000 Fix crash with rtadv-originated multipath IPv6 routes. PR: 253800 Reported by: Frederic Denis Approved by: re(gjb) (cherry picked from commit 7dfdd039a3584885648d33888359032479038dc1) --- sys/netinet6/nd6_rtr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 51b831a956bc..2f721b4edcc3 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -699,7 +698,7 @@ defrouter_addreq(struct nd_defrouter *new) NET_EPOCH_ASSERT(); error = rib_action(fibnum, RTM_ADD, &info, &rc); if (error == 0) { - struct nhop_object *nh = nhop_select(rc.rc_nh_new, 0); + struct nhop_object *nh = nhop_select_func(rc.rc_nh_new, 0); rt_routemsg(RTM_ADD, rc.rc_rt, nh, fibnum); new->installed = 1; } @@ -739,7 +738,7 @@ defrouter_delreq(struct nd_defrouter *dr) NET_EPOCH_ENTER(et); error = rib_action(fibnum, RTM_DELETE, &info, &rc); if (error == 0) { - struct nhop_object *nh = nhop_select(rc.rc_nh_old, 0); + struct nhop_object *nh = nhop_select_func(rc.rc_nh_old, 0); rt_routemsg(RTM_DELETE, rc.rc_rt, nh, fibnum); } NET_EPOCH_EXIT(et); From owner-dev-commits-src-branches@freebsd.org Thu Feb 25 22:32: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 5BD1254C127; Thu, 25 Feb 2021 22:32: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 4Dmnb8250Bz3s2N; Thu, 25 Feb 2021 22:32: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 30C211F94B; Thu, 25 Feb 2021 22:32: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 11PMW4MW010564; Thu, 25 Feb 2021 22:32:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11PMW4i6010563; Thu, 25 Feb 2021 22:32:04 GMT (envelope-from git) Date: Thu, 25 Feb 2021 22:32:04 GMT Message-Id: <202102252232.11PMW4i6010563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Watson Subject: git: 97bfffafda88 - releng/13.0 - Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rwatson X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 97bfffafda88fde623ca732efbb089cae9eb209f 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, 25 Feb 2021 22:32:04 -0000 The branch releng/13.0 has been updated by rwatson: URL: https://cgit.FreeBSD.org/src/commit/?id=97bfffafda88fde623ca732efbb089cae9eb209f commit 97bfffafda88fde623ca732efbb089cae9eb209f Author: Robert Watson AuthorDate: 2021-02-16 15:19:05 +0000 Commit: Robert Watson CommitDate: 2021-02-25 22:31:52 +0000 Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer. dtrace_gethrtime() is the high-resolution nanosecond timestemp used for the DTrace 'timestamp' built-in variable. The new implementation uses the EL0 cycle counter and frequency registers in ARMv8-A. This replaces a previous implementation that relied on an instrumentation-safe implementation of getnanotime(), which provided only timer resolution. Approved by: re (gjb) Reviewed by: andrew, bsdimp (older version) Useful comments appreciated: jrtc27, emaste Differential Revision: https://reviews.freebsd.org/D28723 --- sys/cddl/dev/dtrace/aarch64/dtrace_subr.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c index 6646e51fc191..9bf9f0798bb5 100644 --- a/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c @@ -153,23 +153,26 @@ dtrace_sync(void) } /* - * DTrace needs a high resolution time function which can - * be called from a probe context and guaranteed not to have - * instrumented with probes itself. + * DTrace needs a high resolution time function which can be called from a + * probe context and guaranteed not to have instrumented with probes itself. * - * Returns nanoseconds since boot. + * Returns nanoseconds since some arbitrary point in time (likely SoC reset?). */ uint64_t -dtrace_gethrtime() +dtrace_gethrtime(void) { - struct timespec curtime; - - dtrace_getnanouptime(&curtime); - - return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec); + uint64_t count, freq; + count = READ_SPECIALREG(cntvct_el0); + freq = READ_SPECIALREG(cntfrq_el0); + return ((1000000000UL * count) / freq); } +/* + * Return a much lower resolution wallclock time based on the system clock + * updated by the timer. If needed, we could add a version interpolated from + * the system clock as is the case with dtrace_gethrtime(). + */ uint64_t dtrace_gethrestime(void) { From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 00:36: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 6E20A54F9B5; Fri, 26 Feb 2021 00:36: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 4DmrLy2K4Nz4TXT; Fri, 26 Feb 2021 00:36: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 3891D2127F; Fri, 26 Feb 2021 00:36: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 11Q0aggZ072285; Fri, 26 Feb 2021 00:36:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11Q0agkb072284; Fri, 26 Feb 2021 00:36:42 GMT (envelope-from git) Date: Fri, 26 Feb 2021 00:36:42 GMT Message-Id: <202102260036.11Q0agkb072284@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 63241a0764c9 - stable/13 - Handle partial data re-sending on ktls/sendfile on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 63241a0764c9414e1bcce3bcb05bfbdba8f1f487 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, 26 Feb 2021 00:36:42 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=63241a0764c9414e1bcce3bcb05bfbdba8f1f487 commit 63241a0764c9414e1bcce3bcb05bfbdba8f1f487 Author: Oleksandr Tymoshenko AuthorDate: 2021-02-17 22:49:30 +0000 Commit: John Baldwin CommitDate: 2021-02-25 22:45:41 +0000 Handle partial data re-sending on ktls/sendfile on FreeBSD Add a handler for EBUSY sendfile error in addition to EAGAIN. With EBUSY returned the data still can be partially sent and user code has to be notified about it, otherwise it may try to send data multiple times. PR: 251969 Obtained from: OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d) Sponsored by: Netflix (merging to FreeBSD) (cherry picked from commit 9b2f020c14af71a2606012143432dd717c7cf90e) --- crypto/openssl/doc/man3/SSL_write.pod | 3 ++- crypto/openssl/include/internal/ktls.h | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crypto/openssl/doc/man3/SSL_write.pod b/crypto/openssl/doc/man3/SSL_write.pod index 20c7953deb06..9b271d8e65a2 100644 --- a/crypto/openssl/doc/man3/SSL_write.pod +++ b/crypto/openssl/doc/man3/SSL_write.pod @@ -120,7 +120,8 @@ For SSL_sendfile(), the following return values can occur: =item Z<>>= 0 The write operation was successful, the return value is the number -of bytes of the file written to the TLS/SSL connection. +of bytes of the file written to the TLS/SSL connection. The return +value can be less than B for a partial write. =item E 0 diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 9032c0ed6174..622d7be76d1e 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -192,15 +192,12 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags) { - off_t sbytes; + off_t sbytes = 0; int ret; ret = sendfile(fd, s, off, size, NULL, &sbytes, flags); - if (ret == -1) { - if (errno == EAGAIN && sbytes != 0) - return sbytes; - return -1; - } + if (ret == -1 && sbytes == 0) + return -1; return sbytes; } From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 00:36: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 80DA954FADD; Fri, 26 Feb 2021 00:36: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 4DmrLz30wyz4TZc; Fri, 26 Feb 2021 00:36: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 5A58621581; Fri, 26 Feb 2021 00:36: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 11Q0ahMJ072303; Fri, 26 Feb 2021 00:36:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11Q0ahFA072302; Fri, 26 Feb 2021 00:36:43 GMT (envelope-from git) Date: Fri, 26 Feb 2021 00:36:43 GMT Message-Id: <202102260036.11Q0ahFA072302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: cdba1277dd26 - stable/13 - OpenSSL: Regen manual page for the previous commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cdba1277dd26c8f7e54a40d86d44748f2d1a8c29 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, 26 Feb 2021 00:36:43 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cdba1277dd26c8f7e54a40d86d44748f2d1a8c29 commit cdba1277dd26c8f7e54a40d86d44748f2d1a8c29 Author: Jung-uk Kim AuthorDate: 2021-02-17 23:19:13 +0000 Commit: John Baldwin CommitDate: 2021-02-25 22:45:59 +0000 OpenSSL: Regen manual page for the previous commit This is regen for 9b2f020c14af71a2606012143432dd717c7cf90e. MFC after: 1 week (cherry picked from commit 351d06eeb509a420f3470c96b4a265467c87e2c2) --- secure/lib/libcrypto/man/man3/SSL_write.3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/secure/lib/libcrypto/man/man3/SSL_write.3 b/secure/lib/libcrypto/man/man3/SSL_write.3 index 99e76b5ac013..db4800fb059d 100644 --- a/secure/lib/libcrypto/man/man3/SSL_write.3 +++ b/secure/lib/libcrypto/man/man3/SSL_write.3 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "SSL_WRITE 3" -.TH SSL_WRITE 3 "2021-02-16" "1.1.1j" "OpenSSL" +.TH SSL_WRITE 3 "2021-02-17" "1.1.1j" "OpenSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -245,7 +245,8 @@ For \fBSSL_sendfile()\fR, the following return values can occur: .IP ">= 0" 4 .IX Item ">= 0" The write operation was successful, the return value is the number -of bytes of the file written to the \s-1TLS/SSL\s0 connection. +of bytes of the file written to the \s-1TLS/SSL\s0 connection. The return +value can be less than \fBsize\fR for a partial write. .IP "< 0" 4 .IX Item "< 0" The write operation was not successful, because either the connection was From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 02:18: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 8DB38551D37; Fri, 26 Feb 2021 02:18: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 4DmtcL3Xm5z4ZwJ; Fri, 26 Feb 2021 02:18: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 6CA1D22758; Fri, 26 Feb 2021 02:18: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 11Q2IQZV004456; Fri, 26 Feb 2021 02:18:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11Q2IQ1c004455; Fri, 26 Feb 2021 02:18:26 GMT (envelope-from git) Date: Fri, 26 Feb 2021 02:18:26 GMT Message-Id: <202102260218.11Q2IQ1c004455@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Glen Barber Subject: git: e32bc2536297 - releng/13.0 - update to BETA4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gjb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: e32bc25362975db9896eeffc2933e078930a5383 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, 26 Feb 2021 02:18:26 -0000 The branch releng/13.0 has been updated by gjb: URL: https://cgit.FreeBSD.org/src/commit/?id=e32bc25362975db9896eeffc2933e078930a5383 commit e32bc25362975db9896eeffc2933e078930a5383 Author: Glen Barber AuthorDate: 2021-02-26 02:18:11 +0000 Commit: Glen Barber CommitDate: 2021-02-26 02:18:11 +0000 update to BETA4 Approved by: re (implicit) Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/conf/newvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index fa48289cc39a..1056611889cf 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -54,7 +54,7 @@ TYPE="FreeBSD" REVISION="13.0" -BRANCH="BETA3-p1" +BRANCH="BETA4" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 10:16: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 C113955C7CC; Fri, 26 Feb 2021 10:16: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 4Dn5DL51vLz3M8H; Fri, 26 Feb 2021 10:16: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 9AA82C9F; Fri, 26 Feb 2021 10:16:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11QAGods040609; Fri, 26 Feb 2021 10:16:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QAGoGr040608; Fri, 26 Feb 2021 10:16:50 GMT (envelope-from git) Date: Fri, 26 Feb 2021 10:16:50 GMT Message-Id: <202102261016.11QAGoGr040608@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: c3aa4ba5dfc0 - stable/13 - Ensure cwnd doesn't shrink to zero with PRR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c3aa4ba5dfc084e40e4151b25a0d5f8d24a036ba 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, 26 Feb 2021 10:16:50 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=c3aa4ba5dfc084e40e4151b25a0d5f8d24a036ba commit c3aa4ba5dfc084e40e4151b25a0d5f8d24a036ba Author: Richard Scheffenegger AuthorDate: 2021-02-19 12:52:06 +0000 Commit: Richard Scheffenegger CommitDate: 2021-02-26 07:39:55 +0000 Ensure cwnd doesn't shrink to zero with PRR Under some circumstances, PRR may end up with a fully collapsed cwnd when finalizing the loss recovery. Reviewed By: #transport, kbowling Reported by: Liang Tian MFC after: 5 days Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28780 (cherry picked from commit 853fd7a2e39802e46bd3d6476529796ac22412d9) --- sys/netinet/tcp_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 459b78cd444a..08d000611407 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -3972,8 +3972,8 @@ tcp_prr_partialack(struct tcpcb *tp, struct tcphdr *th) * If there is going to be a SACK retransmission, adjust snd_cwnd * accordingly. */ - tp->snd_cwnd = tp->snd_nxt - tp->snd_recover + - tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg); + tp->snd_cwnd = max(maxseg, (int64_t)tp->snd_nxt - tp->snd_recover + + tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg)); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); } From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 12:30:38 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 03C75560841; Fri, 26 Feb 2021 12:30:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dn8Bj6hK3z3lFx; Fri, 26 Feb 2021 12:30: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 D8318255A; Fri, 26 Feb 2021 12:30:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11QCUbXQ020107; Fri, 26 Feb 2021 12:30:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QCUbFe020106; Fri, 26 Feb 2021 12:30:37 GMT (envelope-from git) Date: Fri, 26 Feb 2021 12:30:37 GMT Message-Id: <202102261230.11QCUbFe020106@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: 26be401728dc - stable/13 - netgraph/ng_car: Add color marking code 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: 26be401728dc4e0eb30a849186d309488373e6fd 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, 26 Feb 2021 12:30:38 -0000 The branch stable/13 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=26be401728dc4e0eb30a849186d309488373e6fd commit 26be401728dc4e0eb30a849186d309488373e6fd Author: Lutz Donnerhacke AuthorDate: 2021-01-27 20:19:14 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-26 12:29:39 +0000 netgraph/ng_car: Add color marking code Chained policing should be able to reuse the classification of traffic. A new mbuf_tag type is defined to handle gereral QoS marking. A new subtype is defined to track the color marking. Reviewed by: manpages (bcr), melifaro, kp Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22110 (cherry picked from commit d0d2e523bafb74180f8bebb90788790f0d2f0290) --- share/man/man4/ng_car.4 | 9 ++++-- sys/netgraph/ng_car.c | 86 +++++++++++++++++++++++++++++++++++++------------ sys/netgraph/ng_car.h | 5 ++- sys/netgraph/qos.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 27 deletions(-) diff --git a/share/man/man4/ng_car.4 b/share/man/man4/ng_car.4 index f3a01b6880e1..abb522ae151b 100644 --- a/share/man/man4/ng_car.4 +++ b/share/man/man4/ng_car.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 13, 2012 +.Dd January 27, 2021 .Dt NG_CAR 4 .Os .Sh NAME @@ -108,6 +108,7 @@ Traffic shaping is much more polite to the TCP traffic than rate limit on links with bandwidth * delay product less than 6-8 TCP segments, but it consumes additional system resources for queue processing. .El +.Pp By default, all information rates are measured in bits per second and bursts are measured in bytes. But when NG_CAR_COUNT_PACKETS option is enabled, @@ -138,7 +139,8 @@ struct ng_car_hookconf { /* possible actions (..._action) */ enum { NG_CAR_ACTION_FORWARD = 1, - NG_CAR_ACTION_DROP + NG_CAR_ACTION_DROP, + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -149,7 +151,8 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits for opt) */ +#define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 struct ng_car_bulkconf { diff --git a/sys/netgraph/ng_car.c b/sys/netgraph/ng_car.c index 1f74c4b193d0..9474e2467439 100644 --- a/sys/netgraph/ng_car.c +++ b/sys/netgraph/ng_car.c @@ -3,6 +3,7 @@ * * Copyright (c) 2005 Nuno Antunes * Copyright (c) 2007 Alexander Motin + * Copyright (c) 2019 Lutz Donnerhacke * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,9 +35,9 @@ * * TODO: * - Sanitize input config values (impose some limits) - * - Implement internal packet painting (possibly using mbuf tags) - * - Implement color-aware mode * - Implement DSCP marking for IPv4 + * - Decouple functionality into a simple classifier (g/y/r) + * and various action nodes (i.e. shape, dcsp, pcp) */ #include @@ -50,6 +51,8 @@ #include #include +#include "qos.h" + #define NG_CAR_QUEUE_SIZE 100 /* Maximum queue size for SHAPE mode */ #define NG_CAR_QUEUE_MIN_TH 8 /* Minimum RED threshold for SHAPE mode */ @@ -261,6 +264,8 @@ ng_car_rcvdata(hook_p hook, item_p item ) { struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook); struct mbuf *m; + struct m_qos_color *colp; + enum qos_color col; int error = 0; u_int len; @@ -272,15 +277,22 @@ ng_car_rcvdata(hook_p hook, item_p item ) m = NGI_M(item); -#define NG_CAR_PERFORM_MATCH_ACTION(a) \ +#define NG_CAR_PERFORM_MATCH_ACTION(a,col) \ do { \ switch (a) { \ case NG_CAR_ACTION_FORWARD: \ /* Do nothing. */ \ break; \ case NG_CAR_ACTION_MARK: \ - /* XXX find a way to mark packets (mbuf tag?) */ \ - ++hinfo->stats.errors; \ + if (colp == NULL) { \ + colp = (void *)m_tag_alloc( \ + M_QOS_COOKIE, M_QOS_COLOR, \ + MTAG_SIZE(m_qos_color), M_NOWAIT); \ + if (colp != NULL) \ + m_tag_prepend(m, &colp->tag); \ + } \ + if (colp != NULL) \ + colp->color = col; \ break; \ case NG_CAR_ACTION_DROP: \ default: \ @@ -298,22 +310,33 @@ ng_car_rcvdata(hook_p hook, item_p item ) len = m->m_pkthdr.len; } + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Check committed token bucket. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green. */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); } else { /* Refill only if not green without it. */ ng_car_refillhook(hinfo); /* Check committed token bucket again after refill. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); /* If not green and mode is SHAPE, enqueue packet. */ } else if (hinfo->conf.mode == NG_CAR_SHAPE) { @@ -323,40 +346,51 @@ ng_car_rcvdata(hook_p hook, item_p item ) /* If not green and mode is RED, calculate probability. */ } else if (hinfo->conf.mode == NG_CAR_RED) { /* Is packet is bigger then extended burst? */ - if (len - (hinfo->tc - len) > hinfo->conf.ebs) { + if (len - (hinfo->tc - len) > hinfo->conf.ebs || + col >= QOS_COLOR_RED) { /* This packet is definitely red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); /* Use token bucket to simulate RED-like drop probability. */ - } else if (hinfo->te + (len - hinfo->tc) < - hinfo->conf.ebs) { + } else if (hinfo->te + (len - hinfo->tc) < hinfo->conf.ebs && + col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te += len - hinfo->tc; /* Go to negative tokens. */ hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is probably red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } /* If not green and mode is SINGLE/DOUBLE RATE. */ } else { /* Check extended token bucket. */ - if (hinfo->te - len >= 0) { + if (hinfo->te - len >= 0 && col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is red */ ++hinfo->stats.red_pkts; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } } } @@ -709,12 +743,21 @@ ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2) static void ng_car_enqueue(struct hookinfo *hinfo, item_p item) { - struct mbuf *m; - int len; + struct mbuf *m; + int len; + struct m_qos_color *colp; + enum qos_color col; NGI_GET_M(item, m); NG_FREE_ITEM(item); + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Lock queue mutex. */ mtx_lock(&hinfo->q_mtx); @@ -725,7 +768,8 @@ ng_car_enqueue(struct hookinfo *hinfo, item_p item) /* If queue is overflowed or we have no RED tokens. */ if ((len >= (NG_CAR_QUEUE_SIZE - 1)) || - (hinfo->te + len >= NG_CAR_QUEUE_SIZE)) { + (hinfo->te + len >= NG_CAR_QUEUE_SIZE) || + (col >= QOS_COLOR_RED)) { /* Drop packet. */ ++hinfo->stats.red_pkts; ++hinfo->stats.dropped_pkts; diff --git a/sys/netgraph/ng_car.h b/sys/netgraph/ng_car.h index 7f07f87e52b8..410161af29ee 100644 --- a/sys/netgraph/ng_car.h +++ b/sys/netgraph/ng_car.h @@ -103,8 +103,7 @@ struct ng_car_hookconf { enum { NG_CAR_ACTION_FORWARD = 1, NG_CAR_ACTION_DROP, - NG_CAR_ACTION_MARK, - NG_CAR_ACTION_SET_TOS + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -115,7 +114,7 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits in opt) */ #define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 diff --git a/sys/netgraph/qos.h b/sys/netgraph/qos.h new file mode 100644 index 000000000000..0e5dfec479eb --- /dev/null +++ b/sys/netgraph/qos.h @@ -0,0 +1,83 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 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. + * + * THIS SOFTWARE IS PROVIDED BY 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 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. + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_QOS_H_ +#define _NETGRAPH_QOS_H_ + +#include + +/* ABI cookie */ +#define M_QOS_COOKIE 1571268051 +#define MTAG_SIZE(X) ( sizeof(struct X) - sizeof(struct m_tag) ) + +/* + * Definition of types within this ABI: + * - Choose a type (16bit) by i.e. "echo $((1000+$(date +%s)%64536))" + * - Retry if the type is already in use + * - Define the structure for the type according to mbuf_tags(9) + * struct m_qos_foo { + * struct m_tag tag; + * ... + * }; + * Preferred usage: + * struct m_qos_foo *p = (void *)m_tag_locate(m, + * M_QOS_COOKIE, M_QOS_FOO, ...); + * or + * p = (void *)m_tag_alloc( + * M_QOS_COOKIE, M_QOS_FOO, MTAG_SIZE(foo), ...); + m_tag_prepend(m, &p->tag); + */ + +/* Color marking type */ +#define M_QOS_COLOR 23568 +/* Keep colors ordered semantically in order to allow use of "<=" or ">=" */ +enum qos_color { + QOS_COLOR_GREEN, + QOS_COLOR_YELLOW, + QOS_COLOR_RED +}; +struct m_qos_color { + struct m_tag tag; + enum qos_color color; +}; + +/* + * Priority class + * + * Processing per priority requires an overhead, which should + * be static (i.e. for alloctating queues) and small (for memory) + * So keep your chosen range limited. + */ +#define M_QOS_PRIORITY 28858 +struct m_qos_priority { + struct m_tag tag; + uint8_t priority; /* 0 - lowest */ +}; + +#endif /* _NETGRAPH_QOS_H_ */ From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 12:34: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 C947C56075E; Fri, 26 Feb 2021 12:34: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 4Dn8H15Jn3z3lbV; Fri, 26 Feb 2021 12:34: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 A918929F1; Fri, 26 Feb 2021 12:34:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11QCYLD0024703; Fri, 26 Feb 2021 12:34:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QCYLNj024702; Fri, 26 Feb 2021 12:34:21 GMT (envelope-from git) Date: Fri, 26 Feb 2021 12:34:21 GMT Message-Id: <202102261234.11QCYLNj024702@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: d88ac710ce58 - stable/12 - netgraph/ng_car: Add color marking code 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: d88ac710ce5828aad6b2ea76b217f3a17ae64232 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, 26 Feb 2021 12:34:21 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=d88ac710ce5828aad6b2ea76b217f3a17ae64232 commit d88ac710ce5828aad6b2ea76b217f3a17ae64232 Author: Lutz Donnerhacke AuthorDate: 2021-01-27 20:19:14 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-26 12:33:57 +0000 netgraph/ng_car: Add color marking code Chained policing should be able to reuse the classification of traffic. A new mbuf_tag type is defined to handle gereral QoS marking. A new subtype is defined to track the color marking. Reviewed by: manpages (bcr), melifaro, kp Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22110 (cherry picked from commit d0d2e523bafb74180f8bebb90788790f0d2f0290) --- share/man/man4/ng_car.4 | 9 ++++-- sys/netgraph/ng_car.c | 86 +++++++++++++++++++++++++++++++++++++------------ sys/netgraph/ng_car.h | 5 ++- sys/netgraph/qos.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 27 deletions(-) diff --git a/share/man/man4/ng_car.4 b/share/man/man4/ng_car.4 index cb1459fe6987..c42f955a106a 100644 --- a/share/man/man4/ng_car.4 +++ b/share/man/man4/ng_car.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 13, 2012 +.Dd January 27, 2021 .Dt NG_CAR 4 .Os .Sh NAME @@ -108,6 +108,7 @@ Traffic shaping is much more polite to the TCP traffic than rate limit on links with bandwidth * delay product less than 6-8 TCP segments, but it consumes additional system resources for queue processing. .El +.Pp By default, all information rates are measured in bits per second and bursts are measured in bytes. But when NG_CAR_COUNT_PACKETS option is enabled, @@ -138,7 +139,8 @@ struct ng_car_hookconf { /* possible actions (..._action) */ enum { NG_CAR_ACTION_FORWARD = 1, - NG_CAR_ACTION_DROP + NG_CAR_ACTION_DROP, + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -149,7 +151,8 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits for opt) */ +#define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 struct ng_car_bulkconf { diff --git a/sys/netgraph/ng_car.c b/sys/netgraph/ng_car.c index 897576349b22..d3ac2b7042a4 100644 --- a/sys/netgraph/ng_car.c +++ b/sys/netgraph/ng_car.c @@ -3,6 +3,7 @@ * * Copyright (c) 2005 Nuno Antunes * Copyright (c) 2007 Alexander Motin + * Copyright (c) 2019 Lutz Donnerhacke * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,9 +35,9 @@ * * TODO: * - Sanitize input config values (impose some limits) - * - Implement internal packet painting (possibly using mbuf tags) - * - Implement color-aware mode * - Implement DSCP marking for IPv4 + * - Decouple functionality into a simple classifier (g/y/r) + * and various action nodes (i.e. shape, dcsp, pcp) */ #include @@ -50,6 +51,8 @@ #include #include +#include "qos.h" + #define NG_CAR_QUEUE_SIZE 100 /* Maximum queue size for SHAPE mode */ #define NG_CAR_QUEUE_MIN_TH 8 /* Minimum RED threshold for SHAPE mode */ @@ -261,6 +264,8 @@ ng_car_rcvdata(hook_p hook, item_p item ) { struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook); struct mbuf *m; + struct m_qos_color *colp; + enum qos_color col; int error = 0; u_int len; @@ -272,15 +277,22 @@ ng_car_rcvdata(hook_p hook, item_p item ) m = NGI_M(item); -#define NG_CAR_PERFORM_MATCH_ACTION(a) \ +#define NG_CAR_PERFORM_MATCH_ACTION(a,col) \ do { \ switch (a) { \ case NG_CAR_ACTION_FORWARD: \ /* Do nothing. */ \ break; \ case NG_CAR_ACTION_MARK: \ - /* XXX find a way to mark packets (mbuf tag?) */ \ - ++hinfo->stats.errors; \ + if (colp == NULL) { \ + colp = (void *)m_tag_alloc( \ + M_QOS_COOKIE, M_QOS_COLOR, \ + MTAG_SIZE(m_qos_color), M_NOWAIT); \ + if (colp != NULL) \ + m_tag_prepend(m, &colp->tag); \ + } \ + if (colp != NULL) \ + colp->color = col; \ break; \ case NG_CAR_ACTION_DROP: \ default: \ @@ -298,23 +310,34 @@ ng_car_rcvdata(hook_p hook, item_p item ) len = m->m_pkthdr.len; } + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Check committed token bucket. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green. */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); } else { /* Refill only if not green without it. */ ng_car_refillhook(hinfo); /* Check committed token bucket again after refill. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); /* If not green and mode is SHAPE, enqueue packet. */ } else if (hinfo->conf.mode == NG_CAR_SHAPE) { @@ -324,40 +347,51 @@ ng_car_rcvdata(hook_p hook, item_p item ) /* If not green and mode is RED, calculate probability. */ } else if (hinfo->conf.mode == NG_CAR_RED) { /* Is packet is bigger then extended burst? */ - if (len - (hinfo->tc - len) > hinfo->conf.ebs) { + if (len - (hinfo->tc - len) > hinfo->conf.ebs || + col >= QOS_COLOR_RED) { /* This packet is definitely red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); /* Use token bucket to simulate RED-like drop probability. */ - } else if (hinfo->te + (len - hinfo->tc) < - hinfo->conf.ebs) { + } else if (hinfo->te + (len - hinfo->tc) < hinfo->conf.ebs && + col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te += len - hinfo->tc; /* Go to negative tokens. */ hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is probably red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } /* If not green and mode is SINGLE/DOUBLE RATE. */ } else { /* Check extended token bucket. */ - if (hinfo->te - len >= 0) { + if (hinfo->te - len >= 0 && col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is red */ ++hinfo->stats.red_pkts; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } } } @@ -711,12 +745,21 @@ ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2) static void ng_car_enqueue(struct hookinfo *hinfo, item_p item) { - struct mbuf *m; - int len; + struct mbuf *m; + int len; + struct m_qos_color *colp; + enum qos_color col; NGI_GET_M(item, m); NG_FREE_ITEM(item); + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Lock queue mutex. */ mtx_lock(&hinfo->q_mtx); @@ -727,7 +770,8 @@ ng_car_enqueue(struct hookinfo *hinfo, item_p item) /* If queue is overflowed or we have no RED tokens. */ if ((len >= (NG_CAR_QUEUE_SIZE - 1)) || - (hinfo->te + len >= NG_CAR_QUEUE_SIZE)) { + (hinfo->te + len >= NG_CAR_QUEUE_SIZE) || + (col >= QOS_COLOR_RED)) { /* Drop packet. */ ++hinfo->stats.red_pkts; ++hinfo->stats.droped_pkts; diff --git a/sys/netgraph/ng_car.h b/sys/netgraph/ng_car.h index 7ca72ba929cc..d77d5dfc5f9b 100644 --- a/sys/netgraph/ng_car.h +++ b/sys/netgraph/ng_car.h @@ -103,8 +103,7 @@ struct ng_car_hookconf { enum { NG_CAR_ACTION_FORWARD = 1, NG_CAR_ACTION_DROP, - NG_CAR_ACTION_MARK, - NG_CAR_ACTION_SET_TOS + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -115,7 +114,7 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits in opt) */ #define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 diff --git a/sys/netgraph/qos.h b/sys/netgraph/qos.h new file mode 100644 index 000000000000..0e5dfec479eb --- /dev/null +++ b/sys/netgraph/qos.h @@ -0,0 +1,83 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 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. + * + * THIS SOFTWARE IS PROVIDED BY 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 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. + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_QOS_H_ +#define _NETGRAPH_QOS_H_ + +#include + +/* ABI cookie */ +#define M_QOS_COOKIE 1571268051 +#define MTAG_SIZE(X) ( sizeof(struct X) - sizeof(struct m_tag) ) + +/* + * Definition of types within this ABI: + * - Choose a type (16bit) by i.e. "echo $((1000+$(date +%s)%64536))" + * - Retry if the type is already in use + * - Define the structure for the type according to mbuf_tags(9) + * struct m_qos_foo { + * struct m_tag tag; + * ... + * }; + * Preferred usage: + * struct m_qos_foo *p = (void *)m_tag_locate(m, + * M_QOS_COOKIE, M_QOS_FOO, ...); + * or + * p = (void *)m_tag_alloc( + * M_QOS_COOKIE, M_QOS_FOO, MTAG_SIZE(foo), ...); + m_tag_prepend(m, &p->tag); + */ + +/* Color marking type */ +#define M_QOS_COLOR 23568 +/* Keep colors ordered semantically in order to allow use of "<=" or ">=" */ +enum qos_color { + QOS_COLOR_GREEN, + QOS_COLOR_YELLOW, + QOS_COLOR_RED +}; +struct m_qos_color { + struct m_tag tag; + enum qos_color color; +}; + +/* + * Priority class + * + * Processing per priority requires an overhead, which should + * be static (i.e. for alloctating queues) and small (for memory) + * So keep your chosen range limited. + */ +#define M_QOS_PRIORITY 28858 +struct m_qos_priority { + struct m_tag tag; + uint8_t priority; /* 0 - lowest */ +}; + +#endif /* _NETGRAPH_QOS_H_ */ From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 12:37:17 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3517560B89; Fri, 26 Feb 2021 12:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dn8LP4BCTz3lZb; Fri, 26 Feb 2021 12:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E811288C; Fri, 26 Feb 2021 12:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11QCbHhj025247; Fri, 26 Feb 2021 12:37:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QCbH8R025246; Fri, 26 Feb 2021 12:37:17 GMT (envelope-from git) Date: Fri, 26 Feb 2021 12:37:17 GMT Message-Id: <202102261237.11QCbH8R025246@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: 21e24a8f01f7 - stable/11 - netgraph/ng_car: Add color marking code 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: 21e24a8f01f7bd7e0a93ed972b6165e2f9798be5 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, 26 Feb 2021 12:37:17 -0000 The branch stable/11 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=21e24a8f01f7bd7e0a93ed972b6165e2f9798be5 commit 21e24a8f01f7bd7e0a93ed972b6165e2f9798be5 Author: Lutz Donnerhacke AuthorDate: 2021-01-27 20:19:14 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-02-26 12:36:40 +0000 netgraph/ng_car: Add color marking code Chained policing should be able to reuse the classification of traffic. A new mbuf_tag type is defined to handle gereral QoS marking. A new subtype is defined to track the color marking. Reviewed by: manpages (bcr), melifaro, kp Sponsored by: IKS Service GmbH Differential Revision: https://reviews.freebsd.org/D22110 (cherry picked from commit d0d2e523bafb74180f8bebb90788790f0d2f0290) --- share/man/man4/ng_car.4 | 9 ++++-- sys/netgraph/ng_car.c | 86 +++++++++++++++++++++++++++++++++++++------------ sys/netgraph/ng_car.h | 5 ++- sys/netgraph/qos.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 27 deletions(-) diff --git a/share/man/man4/ng_car.4 b/share/man/man4/ng_car.4 index cb1459fe6987..c42f955a106a 100644 --- a/share/man/man4/ng_car.4 +++ b/share/man/man4/ng_car.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 13, 2012 +.Dd January 27, 2021 .Dt NG_CAR 4 .Os .Sh NAME @@ -108,6 +108,7 @@ Traffic shaping is much more polite to the TCP traffic than rate limit on links with bandwidth * delay product less than 6-8 TCP segments, but it consumes additional system resources for queue processing. .El +.Pp By default, all information rates are measured in bits per second and bursts are measured in bytes. But when NG_CAR_COUNT_PACKETS option is enabled, @@ -138,7 +139,8 @@ struct ng_car_hookconf { /* possible actions (..._action) */ enum { NG_CAR_ACTION_FORWARD = 1, - NG_CAR_ACTION_DROP + NG_CAR_ACTION_DROP, + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -149,7 +151,8 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits for opt) */ +#define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 struct ng_car_bulkconf { diff --git a/sys/netgraph/ng_car.c b/sys/netgraph/ng_car.c index cdbaf5a3c920..3705186f26b0 100644 --- a/sys/netgraph/ng_car.c +++ b/sys/netgraph/ng_car.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2005 Nuno Antunes * Copyright (c) 2007 Alexander Motin + * Copyright (c) 2019 Lutz Donnerhacke * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,9 +33,9 @@ * * TODO: * - Sanitize input config values (impose some limits) - * - Implement internal packet painting (possibly using mbuf tags) - * - Implement color-aware mode * - Implement DSCP marking for IPv4 + * - Decouple functionality into a simple classifier (g/y/r) + * and various action nodes (i.e. shape, dcsp, pcp) */ #include @@ -48,6 +49,8 @@ #include #include +#include "qos.h" + #define NG_CAR_QUEUE_SIZE 100 /* Maximum queue size for SHAPE mode */ #define NG_CAR_QUEUE_MIN_TH 8 /* Minimum RED threshold for SHAPE mode */ @@ -259,6 +262,8 @@ ng_car_rcvdata(hook_p hook, item_p item ) { struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook); struct mbuf *m; + struct m_qos_color *colp; + enum qos_color col; int error = 0; u_int len; @@ -270,15 +275,22 @@ ng_car_rcvdata(hook_p hook, item_p item ) m = NGI_M(item); -#define NG_CAR_PERFORM_MATCH_ACTION(a) \ +#define NG_CAR_PERFORM_MATCH_ACTION(a,col) \ do { \ switch (a) { \ case NG_CAR_ACTION_FORWARD: \ /* Do nothing. */ \ break; \ case NG_CAR_ACTION_MARK: \ - /* XXX find a way to mark packets (mbuf tag?) */ \ - ++hinfo->stats.errors; \ + if (colp == NULL) { \ + colp = (void *)m_tag_alloc( \ + M_QOS_COOKIE, M_QOS_COLOR, \ + MTAG_SIZE(m_qos_color), M_NOWAIT); \ + if (colp != NULL) \ + m_tag_prepend(m, &colp->tag); \ + } \ + if (colp != NULL) \ + colp->color = col; \ break; \ case NG_CAR_ACTION_DROP: \ default: \ @@ -296,23 +308,34 @@ ng_car_rcvdata(hook_p hook, item_p item ) len = m->m_pkthdr.len; } + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Check committed token bucket. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green. */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); } else { /* Refill only if not green without it. */ ng_car_refillhook(hinfo); /* Check committed token bucket again after refill. */ - if (hinfo->tc - len >= 0) { + if (hinfo->tc - len >= 0 && col <= QOS_COLOR_GREEN) { /* This packet is green */ ++hinfo->stats.green_pkts; hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.green_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.green_action, + QOS_COLOR_GREEN); /* If not green and mode is SHAPE, enqueue packet. */ } else if (hinfo->conf.mode == NG_CAR_SHAPE) { @@ -322,40 +345,51 @@ ng_car_rcvdata(hook_p hook, item_p item ) /* If not green and mode is RED, calculate probability. */ } else if (hinfo->conf.mode == NG_CAR_RED) { /* Is packet is bigger then extended burst? */ - if (len - (hinfo->tc - len) > hinfo->conf.ebs) { + if (len - (hinfo->tc - len) > hinfo->conf.ebs || + col >= QOS_COLOR_RED) { /* This packet is definitely red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); /* Use token bucket to simulate RED-like drop probability. */ - } else if (hinfo->te + (len - hinfo->tc) < - hinfo->conf.ebs) { + } else if (hinfo->te + (len - hinfo->tc) < hinfo->conf.ebs && + col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te += len - hinfo->tc; /* Go to negative tokens. */ hinfo->tc -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is probably red. */ ++hinfo->stats.red_pkts; hinfo->te = 0; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } /* If not green and mode is SINGLE/DOUBLE RATE. */ } else { /* Check extended token bucket. */ - if (hinfo->te - len >= 0) { + if (hinfo->te - len >= 0 && col <= QOS_COLOR_YELLOW) { /* This packet is yellow */ ++hinfo->stats.yellow_pkts; hinfo->te -= len; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.yellow_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.yellow_action, + QOS_COLOR_YELLOW); } else { /* This packet is red */ ++hinfo->stats.red_pkts; - NG_CAR_PERFORM_MATCH_ACTION(hinfo->conf.red_action); + NG_CAR_PERFORM_MATCH_ACTION( + hinfo->conf.red_action, + QOS_COLOR_RED); } } } @@ -709,12 +743,21 @@ ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2) static void ng_car_enqueue(struct hookinfo *hinfo, item_p item) { - struct mbuf *m; - int len; + struct mbuf *m; + int len; + struct m_qos_color *colp; + enum qos_color col; NGI_GET_M(item, m); NG_FREE_ITEM(item); + /* Determine current color of the packet (default green) */ + colp = (void *)m_tag_locate(m, M_QOS_COOKIE, M_QOS_COLOR, NULL); + if ((hinfo->conf.opt & NG_CAR_COLOR_AWARE) && (colp != NULL)) + col = colp->color; + else + col = QOS_COLOR_GREEN; + /* Lock queue mutex. */ mtx_lock(&hinfo->q_mtx); @@ -725,7 +768,8 @@ ng_car_enqueue(struct hookinfo *hinfo, item_p item) /* If queue is overflowed or we have no RED tokens. */ if ((len >= (NG_CAR_QUEUE_SIZE - 1)) || - (hinfo->te + len >= NG_CAR_QUEUE_SIZE)) { + (hinfo->te + len >= NG_CAR_QUEUE_SIZE) || + (col >= QOS_COLOR_RED)) { /* Drop packet. */ ++hinfo->stats.red_pkts; ++hinfo->stats.droped_pkts; diff --git a/sys/netgraph/ng_car.h b/sys/netgraph/ng_car.h index 3fda67512dd0..09a91df0da87 100644 --- a/sys/netgraph/ng_car.h +++ b/sys/netgraph/ng_car.h @@ -101,8 +101,7 @@ struct ng_car_hookconf { enum { NG_CAR_ACTION_FORWARD = 1, NG_CAR_ACTION_DROP, - NG_CAR_ACTION_MARK, - NG_CAR_ACTION_SET_TOS + NG_CAR_ACTION_MARK }; /* operation modes (mode) */ @@ -113,7 +112,7 @@ enum { NG_CAR_SHAPE }; -/* mode options (opt) */ +/* mode options (bits in opt) */ #define NG_CAR_COLOR_AWARE 1 #define NG_CAR_COUNT_PACKETS 2 diff --git a/sys/netgraph/qos.h b/sys/netgraph/qos.h new file mode 100644 index 000000000000..0e5dfec479eb --- /dev/null +++ b/sys/netgraph/qos.h @@ -0,0 +1,83 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 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. + * + * THIS SOFTWARE IS PROVIDED BY 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 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. + * + * $FreeBSD$ + */ + +#ifndef _NETGRAPH_QOS_H_ +#define _NETGRAPH_QOS_H_ + +#include + +/* ABI cookie */ +#define M_QOS_COOKIE 1571268051 +#define MTAG_SIZE(X) ( sizeof(struct X) - sizeof(struct m_tag) ) + +/* + * Definition of types within this ABI: + * - Choose a type (16bit) by i.e. "echo $((1000+$(date +%s)%64536))" + * - Retry if the type is already in use + * - Define the structure for the type according to mbuf_tags(9) + * struct m_qos_foo { + * struct m_tag tag; + * ... + * }; + * Preferred usage: + * struct m_qos_foo *p = (void *)m_tag_locate(m, + * M_QOS_COOKIE, M_QOS_FOO, ...); + * or + * p = (void *)m_tag_alloc( + * M_QOS_COOKIE, M_QOS_FOO, MTAG_SIZE(foo), ...); + m_tag_prepend(m, &p->tag); + */ + +/* Color marking type */ +#define M_QOS_COLOR 23568 +/* Keep colors ordered semantically in order to allow use of "<=" or ">=" */ +enum qos_color { + QOS_COLOR_GREEN, + QOS_COLOR_YELLOW, + QOS_COLOR_RED +}; +struct m_qos_color { + struct m_tag tag; + enum qos_color color; +}; + +/* + * Priority class + * + * Processing per priority requires an overhead, which should + * be static (i.e. for alloctating queues) and small (for memory) + * So keep your chosen range limited. + */ +#define M_QOS_PRIORITY 28858 +struct m_qos_priority { + struct m_tag tag; + uint8_t priority; /* 0 - lowest */ +}; + +#endif /* _NETGRAPH_QOS_H_ */ From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 21:36: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 CF13F54F4D3; Fri, 26 Feb 2021 21:36: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 4DnNJC5VfKz4vRx; Fri, 26 Feb 2021 21:36: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 AF93F12220; Fri, 26 Feb 2021 21:36: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 11QLaBfH035866; Fri, 26 Feb 2021 21:36:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QLaB2x035865; Fri, 26 Feb 2021 21:36:11 GMT (envelope-from git) Date: Fri, 26 Feb 2021 21:36:11 GMT Message-Id: <202102262136.11QLaB2x035865@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 974504783922 - releng/13.0 - Handle partial data re-sending on ktls/sendfile on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 9745047839225ede45594ae4ec2b26df6bafbd22 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, 26 Feb 2021 21:36:11 -0000 The branch releng/13.0 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9745047839225ede45594ae4ec2b26df6bafbd22 commit 9745047839225ede45594ae4ec2b26df6bafbd22 Author: Oleksandr Tymoshenko AuthorDate: 2021-02-17 22:49:30 +0000 Commit: John Baldwin CommitDate: 2021-02-26 21:35:05 +0000 Handle partial data re-sending on ktls/sendfile on FreeBSD Add a handler for EBUSY sendfile error in addition to EAGAIN. With EBUSY returned the data still can be partially sent and user code has to be notified about it, otherwise it may try to send data multiple times. PR: 251969 Approved by: re (gjb) Obtained from: OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d) Sponsored by: Netflix (merging to FreeBSD) (cherry picked from commit 9b2f020c14af71a2606012143432dd717c7cf90e) (cherry picked from commit 63241a0764c9414e1bcce3bcb05bfbdba8f1f487) --- crypto/openssl/doc/man3/SSL_write.pod | 3 ++- crypto/openssl/include/internal/ktls.h | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crypto/openssl/doc/man3/SSL_write.pod b/crypto/openssl/doc/man3/SSL_write.pod index 20c7953deb06..9b271d8e65a2 100644 --- a/crypto/openssl/doc/man3/SSL_write.pod +++ b/crypto/openssl/doc/man3/SSL_write.pod @@ -120,7 +120,8 @@ For SSL_sendfile(), the following return values can occur: =item Z<>>= 0 The write operation was successful, the return value is the number -of bytes of the file written to the TLS/SSL connection. +of bytes of the file written to the TLS/SSL connection. The return +value can be less than B for a partial write. =item E 0 diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 9032c0ed6174..622d7be76d1e 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -192,15 +192,12 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags) { - off_t sbytes; + off_t sbytes = 0; int ret; ret = sendfile(fd, s, off, size, NULL, &sbytes, flags); - if (ret == -1) { - if (errno == EAGAIN && sbytes != 0) - return sbytes; - return -1; - } + if (ret == -1 && sbytes == 0) + return -1; return sbytes; } From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 21:36: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 0A67954F4D4; Fri, 26 Feb 2021 21:36: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 4DnNJD6gW4z4vXJ; Fri, 26 Feb 2021 21:36: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 D21B612221; Fri, 26 Feb 2021 21:36: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 11QLaCiD035884; Fri, 26 Feb 2021 21:36:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11QLaC4k035883; Fri, 26 Feb 2021 21:36:12 GMT (envelope-from git) Date: Fri, 26 Feb 2021 21:36:12 GMT Message-Id: <202102262136.11QLaC4k035883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 310ae6a0df39 - releng/13.0 - OpenSSL: Regen manual page for the previous commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 310ae6a0df3949784af9b51f7c8e8622730324e6 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, 26 Feb 2021 21:36:13 -0000 The branch releng/13.0 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=310ae6a0df3949784af9b51f7c8e8622730324e6 commit 310ae6a0df3949784af9b51f7c8e8622730324e6 Author: Jung-uk Kim AuthorDate: 2021-02-17 23:19:13 +0000 Commit: John Baldwin CommitDate: 2021-02-26 21:35:20 +0000 OpenSSL: Regen manual page for the previous commit This is regen for 9b2f020c14af71a2606012143432dd717c7cf90e. Approved by: re (gjb) (cherry picked from commit 351d06eeb509a420f3470c96b4a265467c87e2c2) (cherry picked from commit cdba1277dd26c8f7e54a40d86d44748f2d1a8c29) --- secure/lib/libcrypto/man/man3/SSL_write.3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/secure/lib/libcrypto/man/man3/SSL_write.3 b/secure/lib/libcrypto/man/man3/SSL_write.3 index 99e76b5ac013..db4800fb059d 100644 --- a/secure/lib/libcrypto/man/man3/SSL_write.3 +++ b/secure/lib/libcrypto/man/man3/SSL_write.3 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "SSL_WRITE 3" -.TH SSL_WRITE 3 "2021-02-16" "1.1.1j" "OpenSSL" +.TH SSL_WRITE 3 "2021-02-17" "1.1.1j" "OpenSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -245,7 +245,8 @@ For \fBSSL_sendfile()\fR, the following return values can occur: .IP ">= 0" 4 .IX Item ">= 0" The write operation was successful, the return value is the number -of bytes of the file written to the \s-1TLS/SSL\s0 connection. +of bytes of the file written to the \s-1TLS/SSL\s0 connection. The return +value can be less than \fBsize\fR for a partial write. .IP "< 0" 4 .IX Item "< 0" The write operation was not successful, because either the connection was From owner-dev-commits-src-branches@freebsd.org Sat Feb 27 16:09: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 106CA54BBCC; Sat, 27 Feb 2021 16:09: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 4Dns0N01JLz3KCT; Sat, 27 Feb 2021 16:09: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 E758E2057F; Sat, 27 Feb 2021 16: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 11RG97Ar000657; Sat, 27 Feb 2021 16:09:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11RG97Ll000656; Sat, 27 Feb 2021 16:09:07 GMT (envelope-from git) Date: Sat, 27 Feb 2021 16:09:07 GMT Message-Id: <202102271609.11RG97Ll000656@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: 76294b65df64 - stable/13 - iflib: Avoid double counting in rxeof 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: 76294b65df64e87f29a7d7df23c5360dd9ada5aa 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, 27 Feb 2021 16:09:08 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=76294b65df64e87f29a7d7df23c5360dd9ada5aa commit 76294b65df64e87f29a7d7df23c5360dd9ada5aa Author: Mark Johnston AuthorDate: 2021-02-24 15:08:53 +0000 Commit: Mark Johnston CommitDate: 2021-02-27 16:07:46 +0000 iflib: Avoid double counting in rxeof iflib_rxeof() was counting everything twice. This was introduced when pfil hooks were added to the iflib receive path. We want to count rx packets/bytes before the pfil hooks are executed, so remove the counter adjustments that are executed after. PR: 253583 Reviewed by: gallatin, erj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28900 (cherry picked from commit b6999635b195e8c0dd5c08ac9ff268c92107cc66) --- sys/net/iflib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index a33ddbe5b8ae..9f3eff555728 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -2973,8 +2973,6 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) if (!IP_ALIGNED(m) && (m = iflib_fixup_rx(m)) == NULL) continue; #endif - rx_bytes += m->m_pkthdr.len; - rx_pkts++; #if defined(INET6) || defined(INET) if (lro_enabled) { if (!lro_possible) { From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 00:43: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 AAE93559E2C; Sun, 28 Feb 2021 00:43: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 4Dp4Pr46tpz4cJH; Sun, 28 Feb 2021 00:43: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 7FE1727421; Sun, 28 Feb 2021 00:43: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 11S0hStO084141; Sun, 28 Feb 2021 00:43:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S0hSRv084139; Sun, 28 Feb 2021 00:43:28 GMT (envelope-from git) Date: Sun, 28 Feb 2021 00:43:28 GMT Message-Id: <202102280043.11S0hSRv084139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 5d684701ca9a - stable/13 - Delete dead CLUSTERDEBUG config option. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5d684701ca9a065ae46e35a2c5f6c2bc6df58e6b 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, 28 Feb 2021 00:43:28 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5d684701ca9a065ae46e35a2c5f6c2bc6df58e6b commit 5d684701ca9a065ae46e35a2c5f6c2bc6df58e6b Author: Konstantin Belousov AuthorDate: 2021-02-18 09:12:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-28 00:42:35 +0000 Delete dead CLUSTERDEBUG config option. (cherry picked from commit 750ea20d3fb143a95ccf3ff84cfbe86cce9b9cac) --- sys/conf/NOTES | 3 --- sys/conf/options | 1 - sys/kern/vfs_cluster.c | 8 -------- 3 files changed, 12 deletions(-) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index b4202bb65618..f73b5a466366 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2732,9 +2732,6 @@ options NSWBUF_MIN=120 options CAM_DEBUG_DELAY -# VFS cluster debugging. -options CLUSTERDEBUG - options DEBUG # Kernel filelock debugging. diff --git a/sys/conf/options b/sys/conf/options index 2f324143c574..b6956193d841 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -570,7 +570,6 @@ TI_JUMBO_HDRSPLIT opt_ti.h # Misc debug flags. Most of these should probably be replaced with # 'DEBUG', and then let people recompile just the interesting modules # with 'make CC="cc -DDEBUG"'. -CLUSTERDEBUG opt_debug_cluster.h DEBUG_1284 opt_ppb_1284.h LPT_DEBUG opt_lpt.h PLIP_DEBUG opt_plip.h diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 6b77adf5df34..60f22fd38764 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -36,8 +36,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_debug_cluster.h" - #include #include #include @@ -56,12 +54,6 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(CLUSTERDEBUG) -static int rcluster= 0; -SYSCTL_INT(_debug, OID_AUTO, rcluster, CTLFLAG_RW, &rcluster, 0, - "Debug VFS clustering code"); -#endif - static MALLOC_DEFINE(M_SEGMENT, "cl_savebuf", "cluster_save buffer"); static uma_zone_t cluster_pbuf_zone; From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 03:49: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 5A4FE55F16B; Sun, 28 Feb 2021 03:49: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 4Dp8X122Nzz4pHk; Sun, 28 Feb 2021 03:49: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 388681C15; Sun, 28 Feb 2021 03:49: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 11S3n5nD024164; Sun, 28 Feb 2021 03:49:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S3n5UX024163; Sun, 28 Feb 2021 03:49:05 GMT (envelope-from git) Date: Sun, 28 Feb 2021 03:49:05 GMT Message-Id: <202102280349.11S3n5UX024163@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: 115ea98aede3 - stable/12 - pwrite(2): add a BUGS section MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 115ea98aede324e6f0c032a4d481d128df7bc81f 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, 28 Feb 2021 03:49:05 -0000 The branch stable/12 has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=115ea98aede324e6f0c032a4d481d128df7bc81f commit 115ea98aede324e6f0c032a4d481d128df7bc81f Author: Guangyuan Yang AuthorDate: 2021-02-20 08:03:15 +0000 Commit: Guangyuan Yang CommitDate: 2021-02-28 02:58:36 +0000 pwrite(2): add a BUGS section Add a BUGS section about using pwrite(2) when O_APPEND is set on the fd. Submitted by: Ka Ho Ng Reviewed by: gbe, yuripv Differential Revision: https://reviews.freebsd.org/D28372 (cherry picked from commit 504e64af32ba6c62fdcc894a3b1da76061c64796) --- lib/libc/sys/write.2 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index fb70c5e4186b..89b1da7f24d9 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -28,7 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd March 30, 2020 +.Dd February 11, 2021 .Dt WRITE 2 .Os .Sh NAME @@ -294,3 +294,17 @@ The .Fn write function appeared in .At v1 . +.Sh BUGS +The +.Fn pwrite +system call appends the file without changing the file offset if +.Dv O_APPEND +is set, contrary to +.St -p1003.1-2008 +where +.Fn pwrite +writes into +.Fa offset +regardless of whether +.Dv O_APPEND +is set. From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 04:21: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 16EB855FBAE; Sun, 28 Feb 2021 04:21: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 4Dp9Dx00Vdz4qSs; Sun, 28 Feb 2021 04:21: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 E719B1ED6; Sun, 28 Feb 2021 04:21: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 11S4L42U071744; Sun, 28 Feb 2021 04:21:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S4L43l071734; Sun, 28 Feb 2021 04:21:04 GMT (envelope-from git) Date: Sun, 28 Feb 2021 04:21:04 GMT Message-Id: <202102280421.11S4L43l071734@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: 1350f1ccc156 - stable/11 - pwrite(2): add a BUGS section MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 1350f1ccc156299c4de2772afa8784283c8f6ab4 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, 28 Feb 2021 04:21:05 -0000 The branch stable/11 has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1350f1ccc156299c4de2772afa8784283c8f6ab4 commit 1350f1ccc156299c4de2772afa8784283c8f6ab4 Author: Guangyuan Yang AuthorDate: 2021-02-20 08:03:15 +0000 Commit: Guangyuan Yang CommitDate: 2021-02-28 04:20:26 +0000 pwrite(2): add a BUGS section Add a BUGS section about using pwrite(2) when O_APPEND is set on the fd. Submitted by: Ka Ho Ng Reviewed by: gbe, yuripv Differential Revision: https://reviews.freebsd.org/D28372 (cherry picked from commit 504e64af32ba6c62fdcc894a3b1da76061c64796) --- lib/libc/sys/write.2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index 7c3e4096c708..75574adb0996 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -28,7 +28,11 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" +<<<<<<< HEAD .Dd October 23, 2017 +======= +.Dd February 11, 2021 +>>>>>>> 504e64af32ba (pwrite(2): add a BUGS section) .Dt WRITE 2 .Os .Sh NAME @@ -287,4 +291,22 @@ system call appeared in The .Fn write function appeared in +<<<<<<< HEAD .At v6 . +======= +.At v1 . +.Sh BUGS +The +.Fn pwrite +system call appends the file without changing the file offset if +.Dv O_APPEND +is set, contrary to +.St -p1003.1-2008 +where +.Fn pwrite +writes into +.Fa offset +regardless of whether +.Dv O_APPEND +is set. +>>>>>>> 504e64af32ba (pwrite(2): add a BUGS section) From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 05:06: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 DA2CE5602FC; Sun, 28 Feb 2021 05:06: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 4DpBFM5sLvz4sFj; Sun, 28 Feb 2021 05:06: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 B796C26EF; Sun, 28 Feb 2021 05:06: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 11S56Vkm030694; Sun, 28 Feb 2021 05:06:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S56V9m030693; Sun, 28 Feb 2021 05:06:31 GMT (envelope-from git) Date: Sun, 28 Feb 2021 05:06:31 GMT Message-Id: <202102280506.11S56V9m030693@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Guangyuan Yang Subject: git: aed45a13aea9 - stable/11 - pwrite(2): remove git message that committed by accident MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: aed45a13aea9db0b24299a10f0eac8192776b141 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, 28 Feb 2021 05:06:31 -0000 The branch stable/11 has been updated by ygy (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=aed45a13aea9db0b24299a10f0eac8192776b141 commit aed45a13aea9db0b24299a10f0eac8192776b141 Author: Guangyuan Yang AuthorDate: 2021-02-28 04:48:04 +0000 Commit: Guangyuan Yang CommitDate: 2021-02-28 05:06:07 +0000 pwrite(2): remove git message that committed by accident Fix the manpage after accidentally committed 3-way merge info in 1350f1ccc156299c4de2772afa8784283c8f6ab4. --- lib/libc/sys/write.2 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index 75574adb0996..95f0ca9c0532 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -28,11 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -<<<<<<< HEAD -.Dd October 23, 2017 -======= .Dd February 11, 2021 ->>>>>>> 504e64af32ba (pwrite(2): add a BUGS section) .Dt WRITE 2 .Os .Sh NAME @@ -291,9 +287,6 @@ system call appeared in The .Fn write function appeared in -<<<<<<< HEAD -.At v6 . -======= .At v1 . .Sh BUGS The @@ -309,4 +302,3 @@ writes into regardless of whether .Dv O_APPEND is set. ->>>>>>> 504e64af32ba (pwrite(2): add a BUGS section) From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 08:06:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4E5B1563961; Sun, 28 Feb 2021 08:06:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DpGFT1fR0z3H0h; Sun, 28 Feb 2021 08:06:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2771D51A6; Sun, 28 Feb 2021 08:06:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11S86roq067422; Sun, 28 Feb 2021 08:06:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S86rVL067421; Sun, 28 Feb 2021 08:06:53 GMT (envelope-from git) Date: Sun, 28 Feb 2021 08:06:53 GMT Message-Id: <202102280806.11S86rVL067421@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: 32ed0ef06b83 - stable/13 - PRR: use accurate rfc6675_pipe when enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32ed0ef06b8326271c4665406cac81fa47d0d29c 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, 28 Feb 2021 08:06:53 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=32ed0ef06b8326271c4665406cac81fa47d0d29c commit 32ed0ef06b8326271c4665406cac81fa47d0d29c Author: Richard Scheffenegger AuthorDate: 2021-02-20 19:10:00 +0000 Commit: Richard Scheffenegger CommitDate: 2021-02-28 07:35:37 +0000 PRR: use accurate rfc6675_pipe when enabled Reviewed By: #transport, tuexen MFC after: 1 week Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28816 (cherry picked from commit a8e431e1537d056a3f9e466eaceec28c399c220b) --- sys/netinet/tcp_input.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 08d000611407..aaa9465c00e9 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -2586,8 +2586,11 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, * estimate to be in the network. */ del_data = tp->sackhint.delivered_data; - pipe = (tp->snd_nxt - tp->snd_fack) + - tp->sackhint.sack_bytes_rexmit; + if (V_tcp_do_rfc6675_pipe) + pipe = tcp_compute_pipe(tp); + else + pipe = (tp->snd_nxt - tp->snd_fack) + + tp->sackhint.sack_bytes_rexmit; tp->sackhint.prr_delivered += del_data; if (pipe > tp->snd_ssthresh) { if (tp->sackhint.recover_fs == 0) @@ -3942,7 +3945,10 @@ tcp_prr_partialack(struct tcpcb *tp, struct tcphdr *th) if (SEQ_GEQ(th->th_ack, tp->snd_una)) del_data = BYTES_THIS_ACK(tp, th); del_data += tp->sackhint.delivered_data; - pipe = (tp->snd_nxt - tp->snd_fack) + tp->sackhint.sack_bytes_rexmit; + if (V_tcp_do_rfc6675_pipe) + pipe = tcp_compute_pipe(tp); + else + pipe = (tp->snd_nxt - tp->snd_fack) + tp->sackhint.sack_bytes_rexmit; tp->sackhint.prr_delivered += del_data; /* * Proportional Rate Reduction From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 08:09: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 3075D563AE4; Sun, 28 Feb 2021 08:09: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 4DpGJ40t5Gz3H87; Sun, 28 Feb 2021 08:09: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 0645F52E1; Sun, 28 Feb 2021 08:09: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 11S897Nb067861; Sun, 28 Feb 2021 08:09:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S897B7067860; Sun, 28 Feb 2021 08:09:07 GMT (envelope-from git) Date: Sun, 28 Feb 2021 08:09:07 GMT Message-Id: <202102280809.11S897B7067860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: ffbf1b809ef5 - stable/13 - Address two incorrect calculations and enhance readability of PRR code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ffbf1b809ef5080afa130c11fa4afce9fef7e7fe 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, 28 Feb 2021 08:09:08 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=ffbf1b809ef5080afa130c11fa4afce9fef7e7fe commit ffbf1b809ef5080afa130c11fa4afce9fef7e7fe Author: Richard Scheffenegger AuthorDate: 2021-02-25 16:59:45 +0000 Commit: Richard Scheffenegger CommitDate: 2021-02-28 08:07:54 +0000 Address two incorrect calculations and enhance readability of PRR code - address second instance of cwnd potentially becoming zero - fix sublte bug due to implicit int to uint typecase in max() - fix bug due to typo in hand-coded CEILING() function by using howmany() macro - use int instead of long, and add a missing long typecast - replace if conditionals with easier to read imax/imin (as in pseudocode) Reviewed By: #transport, kbowling MFC after: 3 days Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28813 (cherry picked from commit 48396dc77922c68377ecac0ead2f8b0b5453c451) --- sys/netinet/tcp_input.c | 60 ++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index aaa9465c00e9..96c594a4c7cd 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -2577,8 +2577,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (V_tcp_do_prr && IN_FASTRECOVERY(tp->t_flags) && (tp->t_flags & TF_SACK_PERMIT)) { - long snd_cnt = 0, limit = 0; - long del_data = 0, pipe = 0; + int snd_cnt = 0, limit = 0; + int del_data = 0, pipe = 0; /* * In a duplicate ACK del_data is only the * diff_in_sack. If no SACK is used del_data @@ -2595,39 +2595,29 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (pipe > tp->snd_ssthresh) { if (tp->sackhint.recover_fs == 0) tp->sackhint.recover_fs = - max(1, tp->snd_nxt - tp->snd_una); - snd_cnt = (tp->sackhint.prr_delivered * - tp->snd_ssthresh / - tp->sackhint.recover_fs) + - 1 - tp->sackhint.sack_bytes_rexmit; + imax(1, tp->snd_nxt - tp->snd_una); + snd_cnt = howmany((long)tp->sackhint.prr_delivered * + tp->snd_ssthresh, tp->sackhint.recover_fs) - + tp->sackhint.sack_bytes_rexmit; } else { if (V_tcp_do_prr_conservative) limit = tp->sackhint.prr_delivered - tp->sackhint.sack_bytes_rexmit; else - if ((tp->sackhint.prr_delivered - - tp->sackhint.sack_bytes_rexmit) > - del_data) - limit = tp->sackhint.prr_delivered - - tp->sackhint.sack_bytes_rexmit + - maxseg; - else - limit = del_data + maxseg; - if ((tp->snd_ssthresh - pipe) < limit) - snd_cnt = tp->snd_ssthresh - pipe; - else - snd_cnt = limit; + limit = imax(tp->sackhint.prr_delivered - + tp->sackhint.sack_bytes_rexmit, + del_data) + maxseg; + snd_cnt = imin(tp->snd_ssthresh - pipe, limit); } - snd_cnt = max((snd_cnt / maxseg), 0); + snd_cnt = imax(snd_cnt, 0) / maxseg; /* * Send snd_cnt new data into the network in * response to this ACK. If there is a going * to be a SACK retransmission, adjust snd_cwnd * accordingly. */ - tp->snd_cwnd = tp->snd_nxt - tp->snd_recover + - tp->sackhint.sack_bytes_rexmit + - (snd_cnt * maxseg); + tp->snd_cwnd = imax(maxseg, tp->snd_nxt - tp->snd_recover + + tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg)); } else if ((tp->t_flags & TF_SACK_PERMIT) && IN_FASTRECOVERY(tp->t_flags)) { int awnd; @@ -3930,7 +3920,7 @@ tcp_mssopt(struct in_conninfo *inc) void tcp_prr_partialack(struct tcpcb *tp, struct tcphdr *th) { - long snd_cnt = 0, limit = 0, del_data = 0, pipe = 0; + int snd_cnt = 0, limit = 0, del_data = 0, pipe = 0; int maxseg = tcp_maxseg(tp); INP_WLOCK_ASSERT(tp->t_inpcb); @@ -3956,29 +3946,27 @@ tcp_prr_partialack(struct tcpcb *tp, struct tcphdr *th) if (pipe > tp->snd_ssthresh) { if (tp->sackhint.recover_fs == 0) tp->sackhint.recover_fs = - max(1, tp->snd_nxt - tp->snd_una); - snd_cnt = (tp->sackhint.prr_delivered * tp->snd_ssthresh / - tp->sackhint.recover_fs) - tp->sackhint.sack_bytes_rexmit; + imax(1, tp->snd_nxt - tp->snd_una); + snd_cnt = howmany((long)tp->sackhint.prr_delivered * + tp->snd_ssthresh, tp->sackhint.recover_fs) - + tp->sackhint.sack_bytes_rexmit; } else { if (V_tcp_do_prr_conservative) limit = tp->sackhint.prr_delivered - tp->sackhint.sack_bytes_rexmit; else - if ((tp->sackhint.prr_delivered - - tp->sackhint.sack_bytes_rexmit) > del_data) - limit = tp->sackhint.prr_delivered - - tp->sackhint.sack_bytes_rexmit + maxseg; - else - limit = del_data + maxseg; - snd_cnt = min((tp->snd_ssthresh - pipe), limit); + limit = imax(tp->sackhint.prr_delivered - + tp->sackhint.sack_bytes_rexmit, + del_data) + maxseg; + snd_cnt = imin((tp->snd_ssthresh - pipe), limit); } - snd_cnt = max((snd_cnt / maxseg), 0); + snd_cnt = imax(snd_cnt, 0) / maxseg; /* * Send snd_cnt new data into the network in response to this ack. * If there is going to be a SACK retransmission, adjust snd_cwnd * accordingly. */ - tp->snd_cwnd = max(maxseg, (int64_t)tp->snd_nxt - tp->snd_recover + + tp->snd_cwnd = imax(maxseg, tp->snd_nxt - tp->snd_recover + tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg)); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 08:10: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 1F581563D27; Sun, 28 Feb 2021 08:10: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 4DpGL10LMnz3H29; Sun, 28 Feb 2021 08:10: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 F2742517B; Sun, 28 Feb 2021 08:10: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 11S8AmIG075564; Sun, 28 Feb 2021 08:10:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S8AmP5075563; Sun, 28 Feb 2021 08:10:48 GMT (envelope-from git) Date: Sun, 28 Feb 2021 08:10:48 GMT Message-Id: <202102280810.11S8AmP5075563@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: 25fb4c363b29 - stable/13 - PRR: Avoid accounting left-edge twice in partial ACK. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 25fb4c363b299c26c35158fa059379af4a007253 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, 28 Feb 2021 08:10:49 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=25fb4c363b299c26c35158fa059379af4a007253 commit 25fb4c363b299c26c35158fa059379af4a007253 Author: Richard Scheffenegger AuthorDate: 2021-02-25 17:36:49 +0000 Commit: Richard Scheffenegger CommitDate: 2021-02-28 08:09:33 +0000 PRR: Avoid accounting left-edge twice in partial ACK. Reviewed By: #transport, kbowling MFC after: 3 days Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28819 (cherry picked from commit 31d7a27c6e88c3d5bd0907774ec70176a92da5bb) --- sys/netinet/tcp_input.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 96c594a4c7cd..e096f2a13679 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -3932,9 +3932,7 @@ tcp_prr_partialack(struct tcpcb *tp, struct tcphdr *th) * (del_data) and an estimate of how many bytes are in the * network. */ - if (SEQ_GEQ(th->th_ack, tp->snd_una)) - del_data = BYTES_THIS_ACK(tp, th); - del_data += tp->sackhint.delivered_data; + del_data = tp->sackhint.delivered_data; if (V_tcp_do_rfc6675_pipe) pipe = tcp_compute_pipe(tp); else From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 08:22:36 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EBB3656428D; Sun, 28 Feb 2021 08:22:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DpGbc6LZgz3Hl8; Sun, 28 Feb 2021 08:22:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C26F251D6; Sun, 28 Feb 2021 08:22: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 11S8Maks093417; Sun, 28 Feb 2021 08:22:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11S8MakS093416; Sun, 28 Feb 2021 08:22:36 GMT (envelope-from git) Date: Sun, 28 Feb 2021 08:22:36 GMT Message-Id: <202102280822.11S8MakS093416@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Richard Scheffenegger Subject: git: c0c928636156 - stable/13 - TCP_NOOPT may prevent the negotiation of TCP features, which a server has to take into consideration. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c0c928636156dd913302bc34e5ac9d70810f5cdd 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, 28 Feb 2021 08:22:37 -0000 The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=c0c928636156dd913302bc34e5ac9d70810f5cdd commit c0c928636156dd913302bc34e5ac9d70810f5cdd Author: Richard Scheffenegger AuthorDate: 2021-02-25 18:10:55 +0000 Commit: Richard Scheffenegger CommitDate: 2021-02-28 08:11:18 +0000 TCP_NOOPT may prevent the negotiation of TCP features, which a server has to take into consideration. PR: 253576 Reviewed By: tuexen, #transport MFC after: 3 days Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D28652 (cherry picked from commit 2593f858d7d078efa85f78f20b6bfa0931cc1dc5) --- sys/netinet/tcp_input.c | 12 ++++++++---- sys/netinet/tcp_syncache.c | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index e096f2a13679..42f983f64502 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1649,7 +1649,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, TCPSTAT_INC(tcps_ecn_shs); } if ((to.to_flags & TOF_SCALE) && - (tp->t_flags & TF_REQ_SCALE)) { + (tp->t_flags & TF_REQ_SCALE) && + !(tp->t_flags & TF_NOOPT)) { tp->t_flags |= TF_RCVD_SCALE; tp->snd_scale = to.to_wscale; } else @@ -1660,7 +1661,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, */ tp->snd_wnd = th->th_win; if ((to.to_flags & TOF_TS) && - (tp->t_flags & TF_REQ_TSTMP)) { + (tp->t_flags & TF_REQ_TSTMP) && + !(tp->t_flags & TF_NOOPT)) { tp->t_flags |= TF_RCVD_TSTMP; tp->ts_recent = to.to_tsval; tp->ts_recent_age = tcp_ts_getticks(); @@ -1669,10 +1671,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (to.to_flags & TOF_MSS) tcp_mss(tp, to.to_mss); if ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACKPERM) == 0) + (!(to.to_flags & TOF_SACKPERM) || + (tp->t_flags & TF_NOOPT))) tp->t_flags &= ~TF_SACK_PERMIT; if (IS_FASTOPEN(tp->t_flags)) { - if (to.to_flags & TOF_FASTOPEN) { + if ((to.to_flags & TOF_FASTOPEN) && + !(tp->t_flags & TF_NOOPT)) { uint16_t mss; if (to.to_flags & TOF_MSS) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index e59a41fc1102..771ff44b8924 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1655,7 +1655,8 @@ skip_alloc: win = imin(win, TCP_MAXWIN); sc->sc_wnd = win; - if (V_tcp_do_rfc1323) { + if (V_tcp_do_rfc1323 && + !(ltflags & TF_NOOPT)) { /* * A timestamp received in a SYN makes * it ok to send timestamp requests and replies. From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 15:57:11 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83A2756F04B; Sun, 28 Feb 2021 15:57:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DpSh736rCz4TyD; Sun, 28 Feb 2021 15:57:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E0A6137A8; Sun, 28 Feb 2021 15:57:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11SFvBYA086516; Sun, 28 Feb 2021 15:57:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SFvBPJ086515; Sun, 28 Feb 2021 15:57:11 GMT (envelope-from git) Date: Sun, 28 Feb 2021 15:57:11 GMT Message-Id: <202102281557.11SFvBPJ086515@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: 86ebf4d3e12c - stable/13 - pf: Fix incorrect fragment handling 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: 86ebf4d3e12c3eae94d3e9a8dcf5bd5741889b58 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, 28 Feb 2021 15:57:11 -0000 The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=86ebf4d3e12c3eae94d3e9a8dcf5bd5741889b58 commit 86ebf4d3e12c3eae94d3e9a8dcf5bd5741889b58 Author: Kristof Provost AuthorDate: 2021-02-25 07:07:36 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:16:29 +0000 pf: Fix incorrect fragment handling A sequence of overlapping IPv4 fragments could crash the kernel in pf due to an assertion. Reported by: Alexander Bluhm Obtained from: OpenBSD MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5f1b1f184b7f12330cf4a027e3db7c6700c67640) --- sys/netpfil/pf/pf_norm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index b7a84437630b..d7310c7bccb4 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -549,6 +549,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, struct pf_frent *after, *next, *prev; struct pf_fragment *frag; uint16_t total; + int old_index, new_index; PF_FRAG_ASSERT(); @@ -660,8 +661,30 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, DPFPRINTF(("adjust overlap %d\n", aftercut)); if (aftercut < after->fe_len) { m_adj(after->fe_m, aftercut); + old_index = pf_frent_index(after); after->fe_off += aftercut; after->fe_len -= aftercut; + new_index = pf_frent_index(after); + if (old_index != new_index) { + DPFPRINTF(("frag index %d, new %d", + old_index, new_index)); + /* Fragment switched queue as fe_off changed */ + after->fe_off -= aftercut; + after->fe_len += aftercut; + /* Remove restored fragment from old queue */ + pf_frent_remove(frag, after); + after->fe_off += aftercut; + after->fe_len -= aftercut; + /* Insert into correct queue */ + if (pf_frent_insert(frag, after, prev)) { + DPFPRINTF( + ("fragment requeue limit exceeded")); + m_freem(after->fe_m); + uma_zfree(V_pf_frent_z, after); + /* There is not way to recover */ + goto bad_fragment; + } + } break; } From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:03: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 860E056F0E4; Sun, 28 Feb 2021 16:03: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 4DpSqy3MQZz4VJr; Sun, 28 Feb 2021 16:03: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 666D513A6A; Sun, 28 Feb 2021 16:03: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 11SG3wvF099909; Sun, 28 Feb 2021 16:03:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG3wd6099908; Sun, 28 Feb 2021 16:03:58 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:03:58 GMT Message-Id: <202102281603.11SG3wd6099908@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: f520c87f3a09 - stable/12 - Revert "pf: Limit the maximum number of fragments per packet" 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: f520c87f3a0993e9b1e872f38177639468f2e64c 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, 28 Feb 2021 16:03:58 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f520c87f3a0993e9b1e872f38177639468f2e64c commit f520c87f3a0993e9b1e872f38177639468f2e64c Author: Kristof Provost AuthorDate: 2018-11-02 15:01:59 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:36:05 +0000 Revert "pf: Limit the maximum number of fragments per packet" This reverts commit r337969. We'll handle this the OpenBSD way, in upcoming commits. (cherry picked from commit 19a22ae31328d9a960732a0904116c1b5566351b) --- sys/netpfil/pf/pf_norm.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index b453bda84721..cadc7a73dca4 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -91,10 +91,8 @@ struct pf_fragment { TAILQ_ENTRY(pf_fragment) frag_next; uint32_t fr_timeout; uint16_t fr_maxlen; /* maximum length of single fragment */ - uint16_t fr_entries; /* Total number of pf_fragment entries */ TAILQ_HEAD(pf_fragq, pf_frent) fr_queue; }; -#define PF_MAX_FRENT_PER_FRAGMENT 64 struct pf_fragment_tag { uint16_t ft_hdrlen; /* header length of reassembled pkt */ @@ -386,7 +384,6 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, *(struct pf_fragment_cmp *)frag = *key; frag->fr_timeout = time_uptime; frag->fr_maxlen = frent->fe_len; - frag->fr_entries = 0; TAILQ_INIT(&frag->fr_queue); RB_INSERT(pf_frag_tree, &V_pf_frag_tree, frag); @@ -398,9 +395,6 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, return (frag); } - if (frag->fr_entries >= PF_MAX_FRENT_PER_FRAGMENT) - goto bad_fragment; - KASSERT(!TAILQ_EMPTY(&frag->fr_queue), ("!TAILQ_EMPTY()->fr_queue")); /* Remember maximum fragment len for refragmentation. */ @@ -473,8 +467,6 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, else TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next); - frag->fr_entries++; - return (frag); bad_fragment: From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:03: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 C085F56F159; Sun, 28 Feb 2021 16:03: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 4DpSqz4111z4V9Q; Sun, 28 Feb 2021 16:03: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 7CF7F13747; Sun, 28 Feb 2021 16:03:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11SG3xgS099931; Sun, 28 Feb 2021 16:03:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG3x9v099930; Sun, 28 Feb 2021 16:03:59 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:03:59 GMT Message-Id: <202102281603.11SG3x9v099930@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: 1d6a2a742c1b - stable/12 - pf: Count holes rather than fragments for reassembly 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: 1d6a2a742c1bcc342408df99bc5f20dec404b1e4 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, 28 Feb 2021 16:03:59 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1d6a2a742c1bcc342408df99bc5f20dec404b1e4 commit 1d6a2a742c1bcc342408df99bc5f20dec404b1e4 Author: Kristof Provost AuthorDate: 2018-11-02 15:23:57 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:36:10 +0000 pf: Count holes rather than fragments for reassembly Avoid traversing the list of fragment entris to check whether the pf(4) reassembly is complete. Instead count the holes that are created when inserting a fragment. If there are no holes left, the fragments are continuous. Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D17732 (cherry picked from commit 2b1c354ee6fb075953d2c3e81c8221f4115ce981) --- sys/netpfil/pf/pf_norm.c | 83 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index cadc7a73dca4..cd94d1de7cf7 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -2,7 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2001 Niels Provos - * Copyright 2011 Alexander Bluhm + * Copyright 2011-2018 Alexander Bluhm * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,6 +91,7 @@ struct pf_fragment { TAILQ_ENTRY(pf_fragment) frag_next; uint32_t fr_timeout; uint16_t fr_maxlen; /* maximum length of single fragment */ + u_int16_t fr_holes; /* number of holes in the queue */ TAILQ_HEAD(pf_fragq, pf_frent) fr_queue; }; @@ -132,11 +133,11 @@ static void pf_remove_fragment(struct pf_fragment *); static int pf_normalize_tcpopt(struct pf_krule *, struct mbuf *, struct tcphdr *, int, sa_family_t); static struct pf_frent *pf_create_fragment(u_short *); +static int pf_frent_holes(struct pf_frent *frent); static struct pf_fragment *pf_find_fragment(struct pf_fragment_cmp *key, struct pf_frag_tree *tree); static struct pf_fragment *pf_fillup_fragment(struct pf_fragment_cmp *, struct pf_frent *, u_short *); -static int pf_isfull_fragment(struct pf_fragment *); static struct mbuf *pf_join_fragment(struct pf_fragment *); #ifdef INET static void pf_scrub_ip(struct mbuf **, uint32_t, uint8_t, uint8_t); @@ -333,6 +334,39 @@ pf_create_fragment(u_short *reason) return (frent); } +/* + * Calculate the additional holes that were created in the fragment + * queue by inserting this fragment. A fragment in the middle + * creates one more hole by splitting. For each connected side, + * it loses one hole. + * Fragment entry must be in the queue when calling this function. + */ +static int +pf_frent_holes(struct pf_frent *frent) +{ + struct pf_frent *prev = TAILQ_PREV(frent, pf_fragq, fr_next); + struct pf_frent *next = TAILQ_NEXT(frent, fr_next); + int holes = 1; + + if (prev == NULL) { + if (frent->fe_off == 0) + holes--; + } else { + KASSERT(frent->fe_off != 0, ("frent->fe_off != 0")); + if (frent->fe_off == prev->fe_off + prev->fe_len) + holes--; + } + if (next == NULL) { + if (!frent->fe_mff) + holes--; + } else { + KASSERT(frent->fe_mff, ("frent->fe_mff")); + if (next->fe_off == frent->fe_off + frent->fe_len) + holes--; + } + return holes; +} + static struct pf_fragment * pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, u_short *reason) @@ -384,6 +418,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, *(struct pf_fragment_cmp *)frag = *key; frag->fr_timeout = time_uptime; frag->fr_maxlen = frent->fe_len; + frag->fr_holes = 1; TAILQ_INIT(&frag->fr_queue); RB_INSERT(pf_frag_tree, &V_pf_frag_tree, frag); @@ -391,6 +426,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, /* We do not have a previous fragment. */ TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); + frag->fr_holes += pf_frent_holes(frent); return (frag); } @@ -457,6 +493,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, /* This fragment is completely overlapped, lose it. */ next = TAILQ_NEXT(after, fr_next); + frag->fr_holes -= pf_frent_holes(after); m_freem(after->fe_m); TAILQ_REMOVE(&frag->fr_queue, after, fr_next); uma_zfree(V_pf_frent_z, after); @@ -466,6 +503,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); else TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next); + frag->fr_holes += pf_frent_holes(frent); return (frag); @@ -476,40 +514,6 @@ drop_fragment: return (NULL); } -static int -pf_isfull_fragment(struct pf_fragment *frag) -{ - struct pf_frent *frent, *next; - uint16_t off, total; - - /* Check if we are completely reassembled */ - if (TAILQ_LAST(&frag->fr_queue, pf_fragq)->fe_mff) - return (0); - - /* Maximum data we have seen already */ - total = TAILQ_LAST(&frag->fr_queue, pf_fragq)->fe_off + - TAILQ_LAST(&frag->fr_queue, pf_fragq)->fe_len; - - /* Check if we have all the data */ - off = 0; - for (frent = TAILQ_FIRST(&frag->fr_queue); frent; frent = next) { - next = TAILQ_NEXT(frent, fr_next); - - off += frent->fe_len; - if (off < total && (next == NULL || next->fe_off != off)) { - DPFPRINTF(("missing fragment at %d, next %d, total %d", - off, next == NULL ? -1 : next->fe_off, total)); - return (0); - } - } - DPFPRINTF(("%d < %d?", off, total)); - if (off < total) - return (0); - KASSERT(off == total, ("off == total")); - - return (1); -} - static struct mbuf * pf_join_fragment(struct pf_fragment *frag) { @@ -570,8 +574,10 @@ pf_reassemble(struct mbuf **m0, struct ip *ip, int dir, u_short *reason) /* The mbuf is part of the fragment entry, no direct free or access */ m = *m0 = NULL; - if (!pf_isfull_fragment(frag)) + if (frag->fr_holes) { + DPFPRINTF(("frag %d, holes %d", frag->fr_id, frag->fr_holes)); return (PF_PASS); /* drop because *m0 is NULL, no error */ + } /* We have all the data */ frent = TAILQ_FIRST(&frag->fr_queue); @@ -654,7 +660,8 @@ pf_reassemble6(struct mbuf **m0, struct ip6_hdr *ip6, struct ip6_frag *fraghdr, /* The mbuf is part of the fragment entry, no direct free or access. */ m = *m0 = NULL; - if (!pf_isfull_fragment(frag)) { + if (frag->fr_holes) { + DPFPRINTF(("frag %d, holes %d", frag->fr_id, frag->fr_holes)); PF_FRAG_UNLOCK(); return (PF_PASS); /* Drop because *m0 is NULL, no error. */ } From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:04: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 6AA8256F319; Sun, 28 Feb 2021 16:04: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 4DpSr06Gt3z4VQL; Sun, 28 Feb 2021 16:04: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 B1BF8136F9; Sun, 28 Feb 2021 16:04: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 11SG40Xv099950; Sun, 28 Feb 2021 16:04:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG409B099949; Sun, 28 Feb 2021 16:04:00 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:04:00 GMT Message-Id: <202102281604.11SG409B099949@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: 11bf4f2fbb3c - stable/12 - pf: Split the fragment reassembly queue into smaller parts 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: 11bf4f2fbb3c10ceeda799893b61cb2d3d41521d 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, 28 Feb 2021 16:04:01 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=11bf4f2fbb3c10ceeda799893b61cb2d3d41521d commit 11bf4f2fbb3c10ceeda799893b61cb2d3d41521d Author: Kristof Provost AuthorDate: 2018-11-02 15:26:51 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:36:18 +0000 pf: Split the fragment reassembly queue into smaller parts Remember 16 entry points based on the fragment offset. Instead of a worst case of 8196 list traversals we now check a maximum of 512 list entries or 16 array elements. Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D17733 (cherry picked from commit fd2ea405e601bd5e240153c5de0f7c264946ce6f) --- sys/net/pfvar.h | 6 ++ sys/netpfil/pf/pf_norm.c | 181 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 168 insertions(+), 19 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index dcc5bf51fdf6..d6c2bf9120e9 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1005,6 +1005,12 @@ struct pf_divert { #define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */ #define PFR_KENTRY_HIWAT 200000 /* Number of table entries */ +/* + * Limit the length of the fragment queue traversal. Remember + * search entry points based on the fragment offset. + */ +#define PF_FRAG_ENTRY_POINTS 16 + /* * ioctl parameter structures */ diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index cd94d1de7cf7..0e2fdca4c2ce 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -87,6 +87,7 @@ struct pf_fragment { #define fr_af fr_key.frc_af #define fr_proto fr_key.frc_proto + struct pf_frent *fr_firstoff[PF_FRAG_ENTRY_POINTS]; RB_ENTRY(pf_fragment) fr_entry; TAILQ_ENTRY(pf_fragment) frag_next; uint32_t fr_timeout; @@ -136,6 +137,13 @@ static struct pf_frent *pf_create_fragment(u_short *); static int pf_frent_holes(struct pf_frent *frent); static struct pf_fragment *pf_find_fragment(struct pf_fragment_cmp *key, struct pf_frag_tree *tree); +static inline int pf_frent_index(struct pf_frent *); +static void pf_frent_insert(struct pf_fragment *, + struct pf_frent *, struct pf_frent *); +void pf_frent_remove(struct pf_fragment *, + struct pf_frent *); +struct pf_frent *pf_frent_previous(struct pf_fragment *, + struct pf_frent *); static struct pf_fragment *pf_fillup_fragment(struct pf_fragment_cmp *, struct pf_frent *, u_short *); static struct mbuf *pf_join_fragment(struct pf_fragment *); @@ -308,6 +316,7 @@ pf_remove_fragment(struct pf_fragment *frag) { PF_FRAG_ASSERT(); + KASSERT(frag, ("frag != NULL")); RB_REMOVE(pf_frag_tree, &V_pf_frag_tree, frag); TAILQ_REMOVE(&V_pf_fragqueue, frag, frag_next); @@ -367,9 +376,150 @@ pf_frent_holes(struct pf_frent *frent) return holes; } +static inline int +pf_frent_index(struct pf_frent *frent) +{ + /* + * We have an array of 16 entry points to the queue. A full size + * 65535 octet IP packet can have 8192 fragments. So the queue + * traversal length is at most 512 and at most 16 entry points are + * checked. We need 128 additional bytes on a 64 bit architecture. + */ + CTASSERT(((u_int16_t)0xffff &~ 7) / (0x10000 / PF_FRAG_ENTRY_POINTS) == + 16 - 1); + CTASSERT(((u_int16_t)0xffff >> 3) / PF_FRAG_ENTRY_POINTS == 512 - 1); + + return frent->fe_off / (0x10000 / PF_FRAG_ENTRY_POINTS); +} + +static void +pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent, + struct pf_frent *prev) +{ + int index; + + if (prev == NULL) { + TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); + } else { + KASSERT(prev->fe_off + prev->fe_len <= frent->fe_off, + ("overlapping fragment")); + TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next); + } + + index = pf_frent_index(frent); + if (frag->fr_firstoff[index] == NULL) { + KASSERT(prev == NULL || pf_frent_index(prev) < index, + ("prev == NULL || pf_frent_index(pref) < index")); + frag->fr_firstoff[index] = frent; + } else { + if (frent->fe_off < frag->fr_firstoff[index]->fe_off) { + KASSERT(prev == NULL || pf_frent_index(prev) < index, + ("prev == NULL || pf_frent_index(pref) < index")); + frag->fr_firstoff[index] = frent; + } else { + KASSERT(prev != NULL, ("prev != NULL")); + KASSERT(pf_frent_index(prev) == index, + ("pf_frent_index(prev) == index")); + } + } + + frag->fr_holes += pf_frent_holes(frent); +} + +void +pf_frent_remove(struct pf_fragment *frag, struct pf_frent *frent) +{ + struct pf_frent *prev = TAILQ_PREV(frent, pf_fragq, fr_next); + struct pf_frent *next = TAILQ_NEXT(frent, fr_next); + int index; + + frag->fr_holes -= pf_frent_holes(frent); + + index = pf_frent_index(frent); + KASSERT(frag->fr_firstoff[index] != NULL, ("frent not found")); + if (frag->fr_firstoff[index]->fe_off == frent->fe_off) { + if (next == NULL) { + frag->fr_firstoff[index] = NULL; + } else { + KASSERT(frent->fe_off + frent->fe_len <= next->fe_off, + ("overlapping fragment")); + if (pf_frent_index(next) == index) { + frag->fr_firstoff[index] = next; + } else { + frag->fr_firstoff[index] = NULL; + } + } + } else { + KASSERT(frag->fr_firstoff[index]->fe_off < frent->fe_off, + ("frag->fr_firstoff[index]->fe_off < frent->fe_off")); + KASSERT(prev != NULL, ("prev != NULL")); + KASSERT(prev->fe_off + prev->fe_len <= frent->fe_off, + ("overlapping fragment")); + KASSERT(pf_frent_index(prev) == index, + ("pf_frent_index(prev) == index")); + } + + TAILQ_REMOVE(&frag->fr_queue, frent, fr_next); +} + +struct pf_frent * +pf_frent_previous(struct pf_fragment *frag, struct pf_frent *frent) +{ + struct pf_frent *prev, *next; + int index; + + /* + * If there are no fragments after frag, take the final one. Assume + * that the global queue is not empty. + */ + prev = TAILQ_LAST(&frag->fr_queue, pf_fragq); + KASSERT(prev != NULL, ("prev != NULL")); + if (prev->fe_off <= frent->fe_off) + return prev; + /* + * We want to find a fragment entry that is before frag, but still + * close to it. Find the first fragment entry that is in the same + * entry point or in the first entry point after that. As we have + * already checked that there are entries behind frag, this will + * succeed. + */ + for (index = pf_frent_index(frent); index < PF_FRAG_ENTRY_POINTS; + index++) { + prev = frag->fr_firstoff[index]; + if (prev != NULL) + break; + } + KASSERT(prev != NULL, ("prev != NULL")); + /* + * In prev we may have a fragment from the same entry point that is + * before frent, or one that is just one position behind frent. + * In the latter case, we go back one step and have the predecessor. + * There may be none if the new fragment will be the first one. + */ + if (prev->fe_off > frent->fe_off) { + prev = TAILQ_PREV(prev, pf_fragq, fr_next); + if (prev == NULL) + return NULL; + KASSERT(prev->fe_off <= frent->fe_off, + ("prev->fe_off <= frent->fe_off")); + return prev; + } + /* + * In prev is the first fragment of the entry point. The offset + * of frag is behind it. Find the closest previous fragment. + */ + for (next = TAILQ_NEXT(prev, fr_next); next != NULL; + next = TAILQ_NEXT(next, fr_next)) { + if (next->fe_off > frent->fe_off) + break; + prev = next; + } + return prev; +} + static struct pf_fragment * pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, - u_short *reason) + u_short *reason) { struct pf_frent *after, *next, *prev; struct pf_fragment *frag; @@ -416,6 +566,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, } *(struct pf_fragment_cmp *)frag = *key; + memset(frag->fr_firstoff, 0, sizeof(frag->fr_firstoff)); frag->fr_timeout = time_uptime; frag->fr_maxlen = frent->fe_len; frag->fr_holes = 1; @@ -425,8 +576,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, TAILQ_INSERT_HEAD(&V_pf_fragqueue, frag, frag_next); /* We do not have a previous fragment. */ - TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); - frag->fr_holes += pf_frent_holes(frent); + pf_frent_insert(frag, frent, NULL); return (frag); } @@ -455,17 +605,15 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, goto bad_fragment; } - /* Find a fragment after the current one. */ - prev = NULL; - TAILQ_FOREACH(after, &frag->fr_queue, fr_next) { - if (after->fe_off > frent->fe_off) - break; - prev = after; + /* Find neighbors for newly inserted fragment */ + prev = pf_frent_previous(frag, frent); + if (prev == NULL) { + after = TAILQ_FIRST(&frag->fr_queue); + KASSERT(after != NULL, ("after != NULL")); + } else { + after = TAILQ_NEXT(prev, fr_next); } - KASSERT(prev != NULL || after != NULL, - ("prev != NULL || after != NULL")); - if (prev != NULL && prev->fe_off + prev->fe_len > frent->fe_off) { uint16_t precut; @@ -493,17 +641,12 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, /* This fragment is completely overlapped, lose it. */ next = TAILQ_NEXT(after, fr_next); - frag->fr_holes -= pf_frent_holes(after); + pf_frent_remove(frag, after); m_freem(after->fe_m); - TAILQ_REMOVE(&frag->fr_queue, after, fr_next); uma_zfree(V_pf_frent_z, after); } - if (prev == NULL) - TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); - else - TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next); - frag->fr_holes += pf_frent_holes(frent); + pf_frent_insert(frag, frent, prev); return (frag); From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:04: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 47D5C56F2FC; Sun, 28 Feb 2021 16:04: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 4DpSr20WJWz4VTx; Sun, 28 Feb 2021 16:04: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 BFCBA13748; Sun, 28 Feb 2021 16:04: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 11SG41jT099972; Sun, 28 Feb 2021 16:04:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG41nX099971; Sun, 28 Feb 2021 16:04:01 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:04:01 GMT Message-Id: <202102281604.11SG41nX099971@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: 8de214ad4d22 - stable/12 - pf: Limit the fragment entry queue length to 64 per bucket. 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: 8de214ad4d225418c8c7befe975637e236ddf93d 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, 28 Feb 2021 16:04:02 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=8de214ad4d225418c8c7befe975637e236ddf93d commit 8de214ad4d225418c8c7befe975637e236ddf93d Author: Kristof Provost AuthorDate: 2018-11-02 15:32:04 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:36:22 +0000 pf: Limit the fragment entry queue length to 64 per bucket. So we have a global limit of 1024 fragments, but it is fine grained to the region of the packet. Smaller packets may have less fragments. This costs another 16 bytes of memory per reassembly and devides the worst case for searching by 8. Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D17734 (cherry picked from commit 790194cd472b1d17e08940e9f839322abcf14ec9) --- sys/net/pfvar.h | 7 +++++++ sys/netpfil/pf/pf_norm.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index d6c2bf9120e9..3a535d04f12f 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1011,6 +1011,13 @@ struct pf_divert { */ #define PF_FRAG_ENTRY_POINTS 16 +/* + * The number of entries in the fragment queue must be limited + * to avoid DoS by linear seaching. Instead of a global limit, + * use a limit per entry point. For large packets these sum up. + */ +#define PF_FRAG_ENTRY_LIMIT 64 + /* * ioctl parameter structures */ diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 0e2fdca4c2ce..eb310e27b9ae 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -87,7 +87,10 @@ struct pf_fragment { #define fr_af fr_key.frc_af #define fr_proto fr_key.frc_proto + /* pointers to queue element */ struct pf_frent *fr_firstoff[PF_FRAG_ENTRY_POINTS]; + /* count entries between pointers */ + uint8_t fr_entries[PF_FRAG_ENTRY_POINTS]; RB_ENTRY(pf_fragment) fr_entry; TAILQ_ENTRY(pf_fragment) frag_next; uint32_t fr_timeout; @@ -138,7 +141,7 @@ static int pf_frent_holes(struct pf_frent *frent); static struct pf_fragment *pf_find_fragment(struct pf_fragment_cmp *key, struct pf_frag_tree *tree); static inline int pf_frent_index(struct pf_frent *); -static void pf_frent_insert(struct pf_fragment *, +static int pf_frent_insert(struct pf_fragment *, struct pf_frent *, struct pf_frent *); void pf_frent_remove(struct pf_fragment *, struct pf_frent *); @@ -392,12 +395,24 @@ pf_frent_index(struct pf_frent *frent) return frent->fe_off / (0x10000 / PF_FRAG_ENTRY_POINTS); } -static void +static int pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent, struct pf_frent *prev) { int index; + CTASSERT(PF_FRAG_ENTRY_LIMIT <= 0xff); + + /* + * A packet has at most 65536 octets. With 16 entry points, each one + * spawns 4096 octets. We limit these to 64 fragments each, which + * means on average every fragment must have at least 64 octets. + */ + index = pf_frent_index(frent); + if (frag->fr_entries[index] >= PF_FRAG_ENTRY_LIMIT) + return ENOBUFS; + frag->fr_entries[index]++; + if (prev == NULL) { TAILQ_INSERT_HEAD(&frag->fr_queue, frent, fr_next); } else { @@ -406,7 +421,6 @@ pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent, TAILQ_INSERT_AFTER(&frag->fr_queue, prev, frent, fr_next); } - index = pf_frent_index(frent); if (frag->fr_firstoff[index] == NULL) { KASSERT(prev == NULL || pf_frent_index(prev) < index, ("prev == NULL || pf_frent_index(pref) < index")); @@ -424,6 +438,8 @@ pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent, } frag->fr_holes += pf_frent_holes(frent); + + return 0; } void @@ -460,6 +476,9 @@ pf_frent_remove(struct pf_fragment *frag, struct pf_frent *frent) } TAILQ_REMOVE(&frag->fr_queue, frent, fr_next); + + KASSERT(frag->fr_entries[index] > 0, ("No fragments remaining")); + frag->fr_entries[index]--; } struct pf_frent * @@ -567,6 +586,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, *(struct pf_fragment_cmp *)frag = *key; memset(frag->fr_firstoff, 0, sizeof(frag->fr_firstoff)); + memset(frag->fr_entries, 0, sizeof(frag->fr_entries)); frag->fr_timeout = time_uptime; frag->fr_maxlen = frent->fe_len; frag->fr_holes = 1; @@ -575,7 +595,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, RB_INSERT(pf_frag_tree, &V_pf_frag_tree, frag); TAILQ_INSERT_HEAD(&V_pf_fragqueue, frag, frag_next); - /* We do not have a previous fragment. */ + /* We do not have a previous fragment, cannot fail. */ pf_frent_insert(frag, frent, NULL); return (frag); @@ -646,7 +666,11 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, uma_zfree(V_pf_frent_z, after); } - pf_frent_insert(frag, frent, prev); + /* If part of the queue gets too long, there is not way to recover. */ + if (pf_frent_insert(frag, frent, prev)) { + DPFPRINTF(("fragment queue limit exceeded")); + goto bad_fragment; + } return (frag); From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:04: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 E408D56F15B; Sun, 28 Feb 2021 16:04: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 4DpSr32VKQz4VDL; Sun, 28 Feb 2021 16:04: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 D6F0E136FA; Sun, 28 Feb 2021 16:04: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 11SG42tl099992; Sun, 28 Feb 2021 16:04:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG42Uu099991; Sun, 28 Feb 2021 16:04:02 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:04:02 GMT Message-Id: <202102281604.11SG42Uu099991@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: 555726fda685 - stable/12 - pf: Fix build if INVARIANTS is not set 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: 555726fda685ab5be9ccdbfcb73b9336dc2d75af 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, 28 Feb 2021 16:04:05 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=555726fda685ab5be9ccdbfcb73b9336dc2d75af commit 555726fda685ab5be9ccdbfcb73b9336dc2d75af Author: Kristof Provost AuthorDate: 2018-11-02 19:23:50 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:36:29 +0000 pf: Fix build if INVARIANTS is not set r340061 included a number of assertions pf_frent_remove(), but these assertions were the only use of the 'prev' variable. As a result builds without INVARIANTS had an unused variable, and failed. Reported by: vangyzen@ (cherry picked from commit 58ef854f8b05508f41aff3bdaf1564c8dd4c1d4f) --- sys/netpfil/pf/pf_norm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index eb310e27b9ae..0770fcfd4c58 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -445,7 +445,9 @@ pf_frent_insert(struct pf_fragment *frag, struct pf_frent *frent, void pf_frent_remove(struct pf_fragment *frag, struct pf_frent *frent) { +#ifdef INVARIANTS struct pf_frent *prev = TAILQ_PREV(frent, pf_fragq, fr_next); +#endif struct pf_frent *next = TAILQ_NEXT(frent, fr_next); int index; From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 16:04: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 1CB1556F320; Sun, 28 Feb 2021 16:04: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 4DpSr518N0z4V5K; Sun, 28 Feb 2021 16:04: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 E97ED136FB; Sun, 28 Feb 2021 16:04: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 11SG43FH000113; Sun, 28 Feb 2021 16:04:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SG43m8000112; Sun, 28 Feb 2021 16:04:03 GMT (envelope-from git) Date: Sun, 28 Feb 2021 16:04:03 GMT Message-Id: <202102281604.11SG43m8000112@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: 5f5a45463ea0 - stable/12 - pf: Fix incorrect fragment handling 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: 5f5a45463ea068983092588ab897602f7aea328b 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, 28 Feb 2021 16:04:12 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5f5a45463ea068983092588ab897602f7aea328b commit 5f5a45463ea068983092588ab897602f7aea328b Author: Kristof Provost AuthorDate: 2021-02-25 07:07:36 +0000 Commit: Kristof Provost CommitDate: 2021-02-28 15:37:07 +0000 pf: Fix incorrect fragment handling A sequence of overlapping IPv4 fragments could crash the kernel in pf due to an assertion. Reported by: Alexander Bluhm Obtained from: OpenBSD MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5f1b1f184b7f12330cf4a027e3db7c6700c67640) --- sys/netpfil/pf/pf_norm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index 0770fcfd4c58..2a3c1d442fd4 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -545,6 +545,7 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, struct pf_frent *after, *next, *prev; struct pf_fragment *frag; uint16_t total; + int old_index, new_index; PF_FRAG_ASSERT(); @@ -656,8 +657,30 @@ pf_fillup_fragment(struct pf_fragment_cmp *key, struct pf_frent *frent, DPFPRINTF(("adjust overlap %d", aftercut)); if (aftercut < after->fe_len) { m_adj(after->fe_m, aftercut); + old_index = pf_frent_index(after); after->fe_off += aftercut; after->fe_len -= aftercut; + new_index = pf_frent_index(after); + if (old_index != new_index) { + DPFPRINTF(("frag index %d, new %d", + old_index, new_index)); + /* Fragment switched queue as fe_off changed */ + after->fe_off -= aftercut; + after->fe_len += aftercut; + /* Remove restored fragment from old queue */ + pf_frent_remove(frag, after); + after->fe_off += aftercut; + after->fe_len -= aftercut; + /* Insert into correct queue */ + if (pf_frent_insert(frag, after, prev)) { + DPFPRINTF( + ("fragment requeue limit exceeded")); + m_freem(after->fe_m); + uma_zfree(V_pf_frent_z, after); + /* There is not way to recover */ + goto bad_fragment; + } + } break; } From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 20:51: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 3AC9354A060; Sun, 28 Feb 2021 20:51: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 4DpbCm1Dsyz4tCj; Sun, 28 Feb 2021 20:51:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1D5831778F; Sun, 28 Feb 2021 20:51:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11SKpWee080288; Sun, 28 Feb 2021 20:51:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SKpWpp080287; Sun, 28 Feb 2021 20:51:32 GMT (envelope-from git) Date: Sun, 28 Feb 2021 20:51:32 GMT Message-Id: <202102282051.11SKpWpp080287@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: 18b6283014a2 - releng/13.0 - iflib: Avoid double counting in rxeof 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/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 18b6283014a291f5fe546092ee16d774a0102691 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, 28 Feb 2021 20:51:32 -0000 The branch releng/13.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=18b6283014a291f5fe546092ee16d774a0102691 commit 18b6283014a291f5fe546092ee16d774a0102691 Author: Mark Johnston AuthorDate: 2021-02-24 15:08:53 +0000 Commit: Mark Johnston CommitDate: 2021-02-28 20:51:21 +0000 iflib: Avoid double counting in rxeof iflib_rxeof() was counting everything twice. This was introduced when pfil hooks were added to the iflib receive path. We want to count rx packets/bytes before the pfil hooks are executed, so remove the counter adjustments that are executed after. Approved by: re (gjb) PR: 253583 Reviewed by: gallatin, erj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28900 (cherry picked from commit b6999635b195e8c0dd5c08ac9ff268c92107cc66) (cherry picked from commit 76294b65df64e87f29a7d7df23c5360dd9ada5aa) --- sys/net/iflib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 506861b65570..70c0ec6a129f 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -2973,8 +2973,6 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget) if (!IP_ALIGNED(m) && (m = iflib_fixup_rx(m)) == NULL) continue; #endif - rx_bytes += m->m_pkthdr.len; - rx_pkts++; #if defined(INET6) || defined(INET) if (lro_enabled) { if (!lro_possible) { From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 20:52:06 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8EF354A30F; Sun, 28 Feb 2021 20:52:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DpbDQ4M8Zz4td4; Sun, 28 Feb 2021 20:52:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 88B62176C4; Sun, 28 Feb 2021 20:52:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11SKq6q1081338; Sun, 28 Feb 2021 20:52:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SKq6rp081337; Sun, 28 Feb 2021 20:52:06 GMT (envelope-from git) Date: Sun, 28 Feb 2021 20:52:06 GMT Message-Id: <202102282052.11SKq6rp081337@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: 5966aae9c7c2 - stable/13 - pmap: Fix largemap restart checks in the kernel_maps sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5966aae9c7c25707c785ec056cb8462a037a480e 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, 28 Feb 2021 20:52:06 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5966aae9c7c25707c785ec056cb8462a037a480e commit 5966aae9c7c25707c785ec056cb8462a037a480e Author: Mark Johnston AuthorDate: 2021-02-25 23:49:47 +0000 Commit: Mark Johnston CommitDate: 2021-02-28 20:51:51 +0000 pmap: Fix largemap restart checks in the kernel_maps sysctl handler The purpose of these checks is to ensure that the address of the next-level page table page is valid, since nothing is synchronizing with a concurrent update of the large map and large map PTPs are freed to the system. However, if PG_PS is set, there is no next level. Reported by: rpokala Reviewed by: kib Tested by: rpokala Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28922 (cherry picked from commit aac25e222525780db8939d07a594d3e090c0a148) --- sys/amd64/amd64/pmap.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 0e1d1c02d1fc..bd23fd176e88 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -11349,9 +11349,6 @@ restart: continue; } pa = pdpe & PG_FRAME; - if (PMAP_ADDRESS_IN_LARGEMAP(sva) && - vm_phys_paddr_to_vm_page(pa) == NULL) - goto restart; if ((pdpe & PG_PS) != 0) { sva = rounddown2(sva, NBPDP); sysctl_kmaps_check(sb, &range, sva, pml4e, pdpe, @@ -11360,6 +11357,15 @@ restart: sva += NBPDP; continue; } + if (PMAP_ADDRESS_IN_LARGEMAP(sva) && + vm_phys_paddr_to_vm_page(pa) == NULL) { + /* + * Page table pages for the large map may be + * freed. Validate the next-level address + * before descending. + */ + goto restart; + } pd = (pd_entry_t *)PHYS_TO_DMAP(pa); for (k = pmap_pde_index(sva); k < NPDEPG; k++) { @@ -11371,9 +11377,6 @@ restart: continue; } pa = pde & PG_FRAME; - if (PMAP_ADDRESS_IN_LARGEMAP(sva) && - vm_phys_paddr_to_vm_page(pa) == NULL) - goto restart; if ((pde & PG_PS) != 0) { sva = rounddown2(sva, NBPDR); sysctl_kmaps_check(sb, &range, sva, @@ -11382,6 +11385,15 @@ restart: sva += NBPDR; continue; } + if (PMAP_ADDRESS_IN_LARGEMAP(sva) && + vm_phys_paddr_to_vm_page(pa) == NULL) { + /* + * Page table pages for the large map + * may be freed. Validate the + * next-level address before descending. + */ + goto restart; + } pt = (pt_entry_t *)PHYS_TO_DMAP(pa); for (l = pmap_pte_index(sva); l < NPTEPG; l++, From owner-dev-commits-src-branches@freebsd.org Sun Feb 28 20:52:41 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 D320254A12F; Sun, 28 Feb 2021 20:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DpbF55NyMz4tkd; Sun, 28 Feb 2021 20:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1C4D175B7; Sun, 28 Feb 2021 20:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11SKqf5U081526; Sun, 28 Feb 2021 20:52:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11SKqfZ0081525; Sun, 28 Feb 2021 20:52:41 GMT (envelope-from git) Date: Sun, 28 Feb 2021 20:52:41 GMT Message-Id: <202102282052.11SKqfZ0081525@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: 39e2c45679a5 - stable/12 - pmap: Fix largemap restart checks in the kernel_maps sysctl handler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 39e2c45679a58ba3a5eaed1ac63212c7dc54b0f3 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, 28 Feb 2021 20:52:41 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=39e2c45679a58ba3a5eaed1ac63212c7dc54b0f3 commit 39e2c45679a58ba3a5eaed1ac63212c7dc54b0f3 Author: Mark Johnston AuthorDate: 2021-02-25 23:49:47 +0000 Commit: Mark Johnston CommitDate: 2021-02-28 20:52:37 +0000 pmap: Fix largemap restart checks in the kernel_maps sysctl handler The purpose of these checks is to ensure that the address of the next-level page table page is valid, since nothing is synchronizing with a concurrent update of the large map and large map PTPs are freed to the system. However, if PG_PS is set, there is no next level. Reported by: rpokala Reviewed by: kib Tested by: rpokala Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28922 (cherry picked from commit aac25e222525780db8939d07a594d3e090c0a148) --- sys/amd64/amd64/pmap.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 876a77902eea..d67823729a48 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -10356,9 +10356,6 @@ restart: continue; } pa = pdpe & PG_FRAME; - if (PMAP_ADDRESS_IN_LARGEMAP(sva) && - vm_phys_paddr_to_vm_page(pa) == NULL) - goto restart; if ((pdpe & PG_PS) != 0) { sva = rounddown2(sva, NBPDP); sysctl_kmaps_check(sb, &range, sva, pml4e, pdpe, @@ -10367,6 +10364,15 @@ restart: sva += NBPDP; continue; } + if (PMAP_ADDRESS_IN_LARGEMAP(sva) && + vm_phys_paddr_to_vm_page(pa) == NULL) { + /* + * Page table pages for the large map may be + * freed. Validate the next-level address + * before descending. + */ + goto restart; + } pd = (pd_entry_t *)PHYS_TO_DMAP(pa); for (k = pmap_pde_index(sva); k < NPDEPG; k++) { @@ -10378,9 +10384,6 @@ restart: continue; } pa = pde & PG_FRAME; - if (PMAP_ADDRESS_IN_LARGEMAP(sva) && - vm_phys_paddr_to_vm_page(pa) == NULL) - goto restart; if ((pde & PG_PS) != 0) { sva = rounddown2(sva, NBPDR); sysctl_kmaps_check(sb, &range, sva, @@ -10389,6 +10392,15 @@ restart: sva += NBPDR; continue; } + if (PMAP_ADDRESS_IN_LARGEMAP(sva) && + vm_phys_paddr_to_vm_page(pa) == NULL) { + /* + * Page table pages for the large map + * may be freed. Validate the + * next-level address before descending. + */ + goto restart; + } pt = (pt_entry_t *)PHYS_TO_DMAP(pa); for (l = pmap_pte_index(sva); l < NPTEPG; l++,