From owner-dev-commits-src-main@freebsd.org Mon May 17 00:00:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E36396365C5; Mon, 17 May 2021 00:00: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 4Fjzm75qNVz4r3c; Mon, 17 May 2021 00:00: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 A582621E61; Mon, 17 May 2021 00:00: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 14H00NWD054354; Mon, 17 May 2021 00:00:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H00NgY054353; Mon, 17 May 2021 00:00:23 GMT (envelope-from git) Date: Mon, 17 May 2021 00:00:23 GMT Message-Id: <202105170000.14H00NgY054353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 9a2fac6ba65f - main - Fix handling of embedded symbolic links (and history lesson). MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a2fac6ba65fbd14d37ccedbc2aec27a190128ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 00:00:24 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=9a2fac6ba65fbd14d37ccedbc2aec27a190128ea commit 9a2fac6ba65fbd14d37ccedbc2aec27a190128ea Author: Kirk McKusick AuthorDate: 2021-05-17 00:02:42 +0000 Commit: Kirk McKusick CommitDate: 2021-05-17 00:04:11 +0000 Fix handling of embedded symbolic links (and history lesson). The original filesystem release (4.2BSD) had no embedded sysmlinks. Historically symbolic links were just a different type of file, so the content of the symbolic link was contained in a single disk block fragment. We observed that most symbolic links were short enough that they could fit in the area of the inode that normally holds the block pointers. So we created embedded symlinks where the content of the link was held in the inode's pointer area thus avoiding the need to seek and read a data fragment and reducing the pressure on the block cache. At the time we had only UFS1 with 32-bit block pointers, so the test for a fastlink was: di_size < (NDADDR + NIADDR) * sizeof(daddr_t) (where daddr_t would be ufs1_daddr_t today). When embedded symlinks were added, a spare field in the superblock with a known zero value became fs_maxsymlinklen. New filesystems set this field to (NDADDR + NIADDR) * sizeof(daddr_t). Embedded symlinks were assumed when di_size < fs->fs_maxsymlinklen. Thus filesystems that preceeded this change always read from blocks (since fs->fs_maxsymlinklen == 0) and newer ones used embedded symlinks if they fit. Similarly symlinks created on pre-embedded symlink filesystems always spill into blocks while newer ones will embed if they fit. At the same time that the embedded symbolic links were added, the on-disk directory structure was changed splitting the former u_int16_t d_namlen into u_int8_t d_type and u_int8_t d_namlen. Thus fs_maxsymlinklen <= 0 (as used by the OFSFMT() macro) can be used to distinguish old directory formats. In retrospect that should have just been an added flag, but we did not realize we needed to know about that change until it was already in production. Code was split into ufs/ffs so that the log structured filesystem could use ufs functionality while doing its own disk layout. This meant that no ffs superblock fields could be used in the ufs code. Thus ffs superblock fields that were needed in ufs code had to be copied to fields in the mount structure. Since ufs_readlink needed to know if a link was embedded, fs_maxlinklen gets copied to mnt_maxsymlinklen. The kernel panic that arose to making this fix was triggered when a disk error created an inode of type symlink with no allocated data blocks but a large size. When readlink was called the uiomove was attempted which segment faulted. static int ufs_readlink(ap) struct vop_readlink_args /* { struct vnode *a_vp; struct uio *a_uio; struct ucred *a_cred; } */ *ap; { struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); doff_t isize; isize = ip->i_size; if ((isize < vp->v_mount->mnt_maxsymlinklen) || DIP(ip, i_blocks) == 0) { /* XXX - for old fastlink support */ return (uiomove(SHORTLINK(ip), isize, ap->a_uio)); } return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred)); } The second part of the "if" statement that adds DIP(ip, i_blocks) == 0) { /* XXX - for old fastlink support */ is problematic. It never appeared in BSD released by Berkeley because as noted above mnt_maxsymlinklen is 0 for old format filesystems, so will always fall through to the VOP_READ as it should. I had to dig back through `git blame' to find that Rodney Grimes added it as part of ``The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.'' He must have brought it across from an earlier FreeBSD. Unfortunately the source-control logs for FreeBSD up to the merger with the AT&T-blessed 4.4BSD-Lite conversion were destroyed as part of the agreement to let FreeBSD remain unencumbered, so I cannot pin-point where that line got added on the FreeBSD side. The one change needed here is that mnt_maxsymlinklen is declared as an `int' and should be changed to be `u_int64_t'. This discovery led us to check out the code that deletes symbolic links. Specifically if (vp->v_type == VLNK && (ip->i_size < vp->v_mount->mnt_maxsymlinklen || datablocks == 0)) { if (length != 0) panic("ffs_truncate: partial truncate of symlink"); bzero(SHORTLINK(ip), (u_int)ip->i_size); ip->i_size = 0; DIP_SET(ip, i_size, 0); UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); if (needextclean) goto extclean; return (ffs_update(vp, waitforupdate)); } Here too our broken symlink inode with no data blocks allocated and a large size will segment fault as we are incorrectly using the test that we have no data blocks to decide that it is an embdedded symbolic link and attempting to bzero past the end of the inode. The test for datablocks == 0 is unnecessary as the test for ip->i_size < vp->v_mount->mnt_maxsymlinklen will do the right thing in all cases. The test for datablocks == 0 was added by David Greenman in this commit: Author: David Greenman Date: Tue Aug 2 13:51:05 1994 +0000 Completed (hopefully) the kernel support for old style "fastlinks". Notes: svn path=/head/; revision=1821 I am guessing that he likely earlier added the incorrect test in the ufs_readlink code. I asked David if he had any recollection of why he made this change. Amazingly, he still had a recollection of why he had made a one-line change more than twenty years ago. And unsurpisingly it was because he had been stuck between a rock and a hard place. FreeBSD was up to 1.1.5 before the switch to the 4.4BSD-Lite code base. Prior to that, there were three years of development in all areas of the kernel, including the filesystem code, from the combined set of people including Bill Jolitz, Patchkit contributors, and FreeBSD Project members. The compatibility issue at hand was caused by the FASTLINKS patches from Curt Mayer. In merging in the 4.4BSD-Lite changes David had to find a way to provide compatibility with both the changes that had been made in FreeBSD 1.1.5 and with 4.4BSD-Lite. He felt that these changes would provide compatibility with both systems. In his words: ``My recollection is that the 'FASTLINKS' symlinks support in FreeBSD-1.x, as implemented by Curt Mayer, worked differently than 4.4BSD. He used a spare field in the inode to duplicately store the length. When the 4.4BSD-Lite merge was done, the optimized symlinks support for existing filesystems (those that were initialized in FreeBSD-1.x) were broken due to the FFS on-disk structure of 4.4BSD-Lite differing from FreeBSD-1.x. My commit was needed to restore the backward compatibility with FreeBSD-1.x filesystems. I think it was the best that could be done in the somewhat urgent circumstances of the post Berkeley-USL settlement. Also, regarding Rod's massive commit with little explanation, some context: John Dyson and I did the initial re-port of the 4.4BSD-Lite kernel to the 386 platform in just 10 days. It was by far the most intense hacking effort of my life. In addition to the porting of tons of FreeBSD-1 code, I think we wrote more than 30,000 lines of new code in that time to deal with the missing pieces and architectural changes of 4.4BSD-Lite. We didn't make many notes along the way. There was a lot of pressure to get something out to the rest of the developer community as fast as possible, so detailed discrete commits didn't happen - it all came as a giant wad, which is why Rod's commit message was worded the way it was.'' Reported by: Chuck Silvers Tested by: Chuck Silvers History by: David Greenman Lawrence MFC after: 1 week Sponsored by: Netflix --- sys/kern/vfs_subr.c | 3 ++- sys/sys/mount.h | 2 +- sys/ufs/ffs/ffs_inode.c | 4 +--- sys/ufs/ufs/ufs_vnops.c | 4 +--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2be3a81ad799..468bd21dae21 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4469,7 +4469,8 @@ DB_SHOW_COMMAND(mount, db_show_mount) mp->mnt_lazyvnodelistsize); db_printf(" mnt_writeopcount = %d (with %d in the struct)\n", vfs_mount_fetch_counter(mp, MNT_COUNT_WRITEOPCOUNT), mp->mnt_writeopcount); - db_printf(" mnt_maxsymlinklen = %d\n", mp->mnt_maxsymlinklen); + db_printf(" mnt_maxsymlinklen = %jd\n", + (uintmax_t)mp->mnt_maxsymlinklen); db_printf(" mnt_iosize_max = %d\n", mp->mnt_iosize_max); db_printf(" mnt_hashseed = %u\n", mp->mnt_hashseed); db_printf(" mnt_lockref = %d (with %d in the struct)\n", diff --git a/sys/sys/mount.h b/sys/sys/mount.h index a6d750a1ff37..f341370ecd86 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -224,7 +224,7 @@ struct mount { int mnt_writeopcount; /* (i) write syscalls pending */ struct vfsoptlist *mnt_opt; /* current mount options */ struct vfsoptlist *mnt_optnew; /* new options passed to fs */ - int mnt_maxsymlinklen; /* max size of short symlink */ + uint64_t mnt_maxsymlinklen; /* max size of short symlink */ struct statfs mnt_stat; /* cache of filesystem stats */ struct ucred *mnt_cred; /* credentials of mounter */ void * mnt_data; /* private data */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 5598c7ba30e8..8fe7f7ab97de 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -329,9 +329,7 @@ ffs_truncate(vp, length, flags, cred) } if ((flags & IO_NORMAL) == 0) return (0); - if (vp->v_type == VLNK && - (ip->i_size < vp->v_mount->mnt_maxsymlinklen || - datablocks == 0)) { + if (vp->v_type == VLNK && ip->i_size < vp->v_mount->mnt_maxsymlinklen) { #ifdef INVARIANTS if (length != 0) panic("ffs_truncate: partial truncate of symlink"); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 301c583291d1..70bf1a1d9036 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -2458,10 +2458,8 @@ ufs_readlink(ap) doff_t isize; isize = ip->i_size; - if ((isize < vp->v_mount->mnt_maxsymlinklen) || - DIP(ip, i_blocks) == 0) { /* XXX - for old fastlink support */ + if (isize < vp->v_mount->mnt_maxsymlinklen) return (uiomove(SHORTLINK(ip), isize, ap->a_uio)); - } return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred)); } From owner-dev-commits-src-main@freebsd.org Mon May 17 02:25:35 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD9CC6390F2; Mon, 17 May 2021 02:25: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 4Fk2zg5kDgz3hKq; Mon, 17 May 2021 02:25: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 A9C4B23F96; Mon, 17 May 2021 02:25: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 14H2PZiS044439; Mon, 17 May 2021 02:25:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H2PZ2w044438; Mon, 17 May 2021 02:25:35 GMT (envelope-from git) Date: Mon, 17 May 2021 02:25:35 GMT Message-Id: <202105170225.14H2PZ2w044438@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 5b81e2e1bcdc - main - virtio_scsi: Zero stack-allocated CCBs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b81e2e1bcdc2692044873e147f84b67e35e8dcd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 02:25:36 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5b81e2e1bcdc2692044873e147f84b67e35e8dcd commit 5b81e2e1bcdc2692044873e147f84b67e35e8dcd Author: Mark Johnston AuthorDate: 2021-05-17 02:14:41 +0000 Commit: Mark Johnston CommitDate: 2021-05-17 02:20:39 +0000 virtio_scsi: Zero stack-allocated CCBs Fixes: 3394d4239b ("cam: allocate CCBs from UMA for SCSI and ATA IO") Reported by: syzbot+2e9ce63919709feb3d1c@syzkaller.appspotmail.com Reviewed by: trasz Sponsored by: The FreeBSD Foundation --- sys/dev/virtio/scsi/virtio_scsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c index 51d9e5f532f7..adf4fd17fc5b 100644 --- a/sys/dev/virtio/scsi/virtio_scsi.c +++ b/sys/dev/virtio/scsi/virtio_scsi.c @@ -700,6 +700,7 @@ vtscsi_register_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE | AC_FOUND_DEVICE; @@ -716,6 +717,7 @@ vtscsi_deregister_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = 0; From owner-dev-commits-src-main@freebsd.org Mon May 17 02:25:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9EE0363943C; Mon, 17 May 2021 02:25: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 4Fk2zj1ZkLz3hV3; Mon, 17 May 2021 02:25: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 C415E24007; Mon, 17 May 2021 02:25:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14H2PaDs044460; Mon, 17 May 2021 02:25:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H2Papd044459; Mon, 17 May 2021 02:25:36 GMT (envelope-from git) Date: Mon, 17 May 2021 02:25:36 GMT Message-Id: <202105170225.14H2Papd044459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 60cb98a1bd2e - main - linux: Fix a mistake in commit fb58045145 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 02:25:37 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0 commit 60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0 Author: Mark Johnston AuthorDate: 2021-05-17 02:17:53 +0000 Commit: Mark Johnston CommitDate: 2021-05-17 02:23:14 +0000 linux: Fix a mistake in commit fb58045145 The change to futex_andl_smap() should have ordered stac before the load from a user address, otherwise it does not fix anything. Fixes: fb58045145 ("linux: Fix SMAP-enabled futex routines") MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/amd64/linux32/linux32_support.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/linux32/linux32_support.s b/sys/amd64/linux32/linux32_support.s index f3ec3bd8c776..da076010c13c 100644 --- a/sys/amd64/linux32/linux32_support.s +++ b/sys/amd64/linux32/linux32_support.s @@ -168,8 +168,8 @@ ENTRY(futex_andl_smap) movq $VM_MAXUSER_ADDRESS-4,%rax cmpq %rax,%rsi ja futex_fault - movl (%rsi),%eax stac + movl (%rsi),%eax 1: movl %eax,%ecx andl %edi,%ecx #ifdef SMP From owner-dev-commits-src-main@freebsd.org Mon May 17 03:57:21 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 31BF863B01C; Mon, 17 May 2021 03:57: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 4Fk51Y109bz3vGy; Mon, 17 May 2021 03:57: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 0A93424EEC; Mon, 17 May 2021 03:57: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 14H3vKTd064741; Mon, 17 May 2021 03:57:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H3vK4Z064740; Mon, 17 May 2021 03:57:20 GMT (envelope-from git) Date: Mon, 17 May 2021 03:57:20 GMT Message-Id: <202105170357.14H3vK4Z064740@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Guangyuan Yang Subject: git: a44489fb5132 - main - Add myself (ygy) as a ports committer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ygy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a44489fb51325c54bedc2e7c97f148694e6f6eaf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 03:57:21 -0000 The branch main has been updated by ygy (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a44489fb51325c54bedc2e7c97f148694e6f6eaf commit a44489fb51325c54bedc2e7c97f148694e6f6eaf Author: Guangyuan Yang AuthorDate: 2021-05-17 03:54:25 +0000 Commit: Guangyuan Yang CommitDate: 2021-05-17 03:54:25 +0000 Add myself (ygy) as a ports committer Approved by: lwhsu (mentor) Differential Revision: https://reviews.freebsd.org/D30308 --- share/misc/committers-ports.dot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index fd594645a5d0..cc600bc03fff 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -291,6 +291,7 @@ woodsb02 [label="Ben Woods\nwoodsb02@FreeBSD.org\n2016/05/09"] wxs [label="Wesley Shields\nwxs@FreeBSD.org\n2008/01/03"] xmj [label="Johannes Jost Meixner\nxmj@FreeBSD.org\n2014/04/07"] xride [label="Soeren Straarup\nxride@FreeBSD.org\n2006/09/27"] +ygy [label="Guangyuan Yang\nygy@FreeBSD.org\n2021/05/17"] yuri [label="Yuri Victorovich\nyuri@FreeBSD.org\n2017/10/30"] yzlin [label="Yi-Jheng Lin\nyzlin@FreeBSD.org\n2009/07/19"] zeising [label="Niclas Zeising\nzeising@FreeBSD.org\n2012/07/03"] @@ -563,6 +564,7 @@ lioux -> pat lme -> pizzamig lme -> tobik +lwhsu -> ygy lwhsu -> yzlin maho -> stephen From owner-dev-commits-src-main@freebsd.org Mon May 17 06:52:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 76E8B63E712; Mon, 17 May 2021 06:52:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fk8w61sSpz4mVj; Mon, 17 May 2021 06:52:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14H6qj5I043000 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 17 May 2021 09:52:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14H6qj5I043000 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14H6qjS2042999; Mon, 17 May 2021 09:52:45 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 17 May 2021 09:52:45 +0300 From: Konstantin Belousov To: Warner Losh , Mark Johnston , src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. Message-ID: References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4Fk8w61sSpz4mVj X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.93 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2001:470:d5e7:1::1:from]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-0.95)[-0.946]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.983]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_FIVE(0.00)[5]; SPAMHAUS_ZRD(0.00)[2001:470:d5e7:1::1:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 06:52:55 -0000 On Sun, May 16, 2021 at 07:03:24PM +0100, Edward Tomasz Napierala wrote: > On 0516T1227, Warner Losh wrote: > > On Sun, May 16, 2021, 11:55 AM Mark Johnston wrote: > > > > > On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala wrote: > > > > The branch main has been updated by trasz: > > > > > > > > URL: > > > https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > > > > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > Author: Edward Tomasz Napierala > > > > AuthorDate: 2021-05-16 09:28:04 +0000 > > > > Commit: Edward Tomasz Napierala > > > > CommitDate: 2021-05-16 10:38:26 +0000 > > > > > > > > cam: add missing zeroing of a stack-allocated CCB. > > > > > > > > This could cause a panic at boot. > > > > > > There are other instances of this, for example syzbot is currently > > > hitting an assertion, seemingly because the alloc_flags field of a > > > stack-allocated CCB was not zeroed: > > > https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c > > > > > > I think the patch below will fix it, but I did not audit other callers. > > > It feels a bit strange to require all callers of xpt_setup_ccb() to > > > manually zero the structure first, can we provide a single routine to > > > initialize stack-allocated CCBs? > > We definitely could, although in some cases it's a bit more > complicated than that - a function that gets passed a CCB and then > calls xpt_setup_ccb() to fill it shouldn't zero it, as that would > be making assumption on how the CCB passed to it was allocated. > > Now that I look at the code, I can definitely see that I've missed > a couple of places. Perhaps I should replace those two KASSERTs with > diagnostic printfs for now, until I get that sorted out? > > > If we did, we could set a flag we could assert on, and/or do static > > analysis to find any others... > > That sounds promising, except I've never done anything like that; > I don't even know where to start. Are stack-allocated ccbs passed around? In particular, can the thread that allocated the ccb, put to sleep while ccb is processed elsewere? This should break under swapping. From owner-dev-commits-src-main@freebsd.org Mon May 17 06:55:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CBEC863E8A9; Mon, 17 May 2021 06:55:58 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fk8zf3tM1z4nDx; Mon, 17 May 2021 06:55:58 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14H6toMF044176 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 17 May 2021 09:55:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14H6toMF044176 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14H6toQx044175; Mon, 17 May 2021 09:55:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 17 May 2021 09:55:50 +0300 From: Konstantin Belousov To: Kirk McKusick Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 9a2fac6ba65f - main - Fix handling of embedded symbolic links (and history lesson). Message-ID: References: <202105170000.14H00NgY054353@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105170000.14H00NgY054353@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4Fk8zf3tM1z4nDx 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 06:55:58 -0000 On Mon, May 17, 2021 at 12:00:23AM +0000, Kirk McKusick wrote: > diff --git a/sys/sys/mount.h b/sys/sys/mount.h > index a6d750a1ff37..f341370ecd86 100644 > --- a/sys/sys/mount.h > +++ b/sys/sys/mount.h > @@ -224,7 +224,7 @@ struct mount { > int mnt_writeopcount; /* (i) write syscalls pending */ > struct vfsoptlist *mnt_opt; /* current mount options */ > struct vfsoptlist *mnt_optnew; /* new options passed to fs */ > - int mnt_maxsymlinklen; /* max size of short symlink */ > + uint64_t mnt_maxsymlinklen; /* max size of short symlink */ Thank you for the interesting reading in the commit message. Somewhat (un)related question is, why maxsymlinklen is put into struct mount? Shouldn't it be contained to struct ufsmount and similar ext2 data structure. The value is private to UFS, it has no use outside sys/ufs. From owner-dev-commits-src-main@freebsd.org Mon May 17 09:43:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EEA62641AE0; Mon, 17 May 2021 09:43: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 4FkDhR6QD0z3j6F; Mon, 17 May 2021 09:43: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 C44D91C97; Mon, 17 May 2021 09:43: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 14H9h39l030586; Mon, 17 May 2021 09:43:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H9h38q030585; Mon, 17 May 2021 09:43:03 GMT (envelope-from git) Date: Mon, 17 May 2021 09:43:03 GMT Message-Id: <202105170943.14H9h38q030585@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: git: c93e6ea344a1 - main - xen: remove support for PVHv1 bootpath MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c93e6ea344a1616219d18b6a2b6761ef19d38c39 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 09:43:04 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=c93e6ea344a1616219d18b6a2b6761ef19d38c39 commit c93e6ea344a1616219d18b6a2b6761ef19d38c39 Author: Mitchell Horne AuthorDate: 2021-05-06 20:45:40 +0000 Commit: Roger Pau Monné CommitDate: 2021-05-17 08:56:52 +0000 xen: remove support for PVHv1 bootpath PVHv1 is a legacy interface supported only by Xen versions 4.4 through 4.9. Reviewed by: royger --- sys/amd64/amd64/xen-locore.S | 24 ------ sys/x86/xen/pv.c | 186 ------------------------------------------- 2 files changed, 210 deletions(-) diff --git a/sys/amd64/amd64/xen-locore.S b/sys/amd64/amd64/xen-locore.S index 97d81711a051..c112fa909adf 100644 --- a/sys/amd64/amd64/xen-locore.S +++ b/sys/amd64/amd64/xen-locore.S @@ -54,7 +54,6 @@ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0") ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad, KERNBASE) ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0) - ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, xen_start) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .quad, HYPERVISOR_VIRT_START) ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel|hvm_callback_vector") @@ -72,29 +71,6 @@ ENTRY(hypercall_page) .skip 0x1000, 0x90 /* Fill with "nop"s */ -/* Legacy PVH entry point, to be removed. */ -ENTRY(xen_start) - /* Don't trust what the loader gives for rflags. */ - pushq $PSL_KERNEL - popfq - - /* Parameters for the xen init function */ - movq %rsi, %rdi /* shared_info (arg 1) */ - movq %rsp, %rsi /* xenstack (arg 2) */ - - /* Use our own stack */ - movq $bootstack,%rsp - xorl %ebp, %ebp - - /* u_int64_t hammer_time_xen(start_info_t *si, u_int64_t xenstack); */ - call hammer_time_xen_legacy - movq %rax, %rsp /* set up kstack for mi_startup() */ - call mi_startup /* autoconfiguration, mountroot etc */ - - /* NOTREACHED */ -0: hlt - jmp 0b - /* PVH entry point. */ .code32 ENTRY(xen_start32) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index a2424423aded..3511df779a92 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -88,13 +88,11 @@ __FBSDID("$FreeBSD$"); /* Native initial function */ extern u_int64_t hammer_time(u_int64_t, u_int64_t); /* Xen initial function */ -uint64_t hammer_time_xen_legacy(start_info_t *, uint64_t); uint64_t hammer_time_xen(vm_paddr_t); #define MAX_E820_ENTRIES 128 /*--------------------------- Forward Declarations ---------------------------*/ -static caddr_t xen_legacy_pvh_parse_preload_data(uint64_t); static caddr_t xen_pvh_parse_preload_data(uint64_t); static void xen_pvh_parse_memmap(caddr_t, vm_paddr_t *, int *); @@ -118,18 +116,6 @@ extern char *dbg_stack; extern uint32_t end; /*-------------------------------- Global Data -------------------------------*/ -/* Xen init_ops implementation. */ -struct init_ops xen_legacy_init_ops = { - .parse_preload_data = xen_legacy_pvh_parse_preload_data, - .early_clock_source_init = xen_clock_init, - .early_delay = xen_delay, - .parse_memmap = xen_pvh_parse_memmap, -#ifdef SMP - .start_all_aps = xen_pv_start_all_aps, -#endif - .msi_init = xen_msi_init, -}; - struct init_ops xen_pvh_init_ops = { .parse_preload_data = xen_pvh_parse_preload_data, .early_clock_source_init = xen_clock_init, @@ -144,134 +130,9 @@ struct init_ops xen_pvh_init_ops = { static struct bios_smap xen_smap[MAX_E820_ENTRIES]; -static start_info_t *legacy_start_info; static struct hvm_start_info *start_info; -/*----------------------- Legacy PVH start_info accessors --------------------*/ -static vm_paddr_t -legacy_get_xenstore_mfn(void) -{ - - return (legacy_start_info->store_mfn); -} - -static evtchn_port_t -legacy_get_xenstore_evtchn(void) -{ - - return (legacy_start_info->store_evtchn); -} - -static vm_paddr_t -legacy_get_console_mfn(void) -{ - - return (legacy_start_info->console.domU.mfn); -} - -static evtchn_port_t -legacy_get_console_evtchn(void) -{ - - return (legacy_start_info->console.domU.evtchn); -} - -static uint32_t -legacy_get_start_flags(void) -{ - - return (legacy_start_info->flags); -} - -struct hypervisor_info legacy_info = { - .get_xenstore_mfn = legacy_get_xenstore_mfn, - .get_xenstore_evtchn = legacy_get_xenstore_evtchn, - .get_console_mfn = legacy_get_console_mfn, - .get_console_evtchn = legacy_get_console_evtchn, - .get_start_flags = legacy_get_start_flags, -}; - /*-------------------------------- Xen PV init -------------------------------*/ -/* - * First function called by the Xen legacy PVH boot sequence. - * - * Set some Xen global variables and prepare the environment so it is - * as similar as possible to what native FreeBSD init function expects. - */ -uint64_t -hammer_time_xen_legacy(start_info_t *si, uint64_t xenstack) -{ - uint64_t physfree; - uint64_t *PT4 = (u_int64_t *)xenstack; - uint64_t *PT3 = (u_int64_t *)(xenstack + PAGE_SIZE); - uint64_t *PT2 = (u_int64_t *)(xenstack + 2 * PAGE_SIZE); - int i; - char *kenv; - - xen_domain_type = XEN_PV_DOMAIN; - vm_guest = VM_GUEST_XEN; - - if ((si == NULL) || (xenstack == 0)) { - xc_printf("ERROR: invalid start_info or xen stack, halting\n"); - HYPERVISOR_shutdown(SHUTDOWN_crash); - } - - xc_printf("FreeBSD PVH running on %s\n", si->magic); - - /* We use 3 pages of xen stack for the boot pagetables */ - physfree = xenstack + 3 * PAGE_SIZE - KERNBASE; - - /* Setup Xen global variables */ - legacy_start_info = si; - HYPERVISOR_shared_info = - (shared_info_t *)(si->shared_info + KERNBASE); - - /* - * Use the stack Xen gives us to build the page tables - * as native FreeBSD expects to find them (created - * by the boot trampoline). - */ - for (i = 0; i < (PAGE_SIZE / sizeof(uint64_t)); i++) { - /* - * Each slot of the level 4 pages points - * to the same level 3 page - */ - PT4[i] = ((uint64_t)&PT3[0]) - KERNBASE; - PT4[i] |= PG_V | PG_RW | PG_U; - - /* - * Each slot of the level 3 pages points - * to the same level 2 page - */ - PT3[i] = ((uint64_t)&PT2[0]) - KERNBASE; - PT3[i] |= PG_V | PG_RW | PG_U; - - /* - * The level 2 page slots are mapped with - * 2MB pages for 1GB. - */ - PT2[i] = i * (2 * 1024 * 1024); - PT2[i] |= PG_V | PG_RW | PG_PS | PG_U; - } - load_cr3(((uint64_t)&PT4[0]) - KERNBASE); - - /* - * Init an empty static kenv using a free page. The contents will be - * filled from the parse_preload_data hook. - */ - kenv = (void *)(physfree + KERNBASE); - physfree += PAGE_SIZE; - bzero_early(kenv, PAGE_SIZE); - init_static_kenv(kenv, PAGE_SIZE); - - /* Set the hooks for early functions that diverge from bare metal */ - init_ops = xen_legacy_init_ops; - apic_ops = xen_apic_ops; - hypervisor_info = legacy_info; - - /* Now we can jump into the native init function */ - return (hammer_time(0, physfree)); -} uint64_t hammer_time_xen(vm_paddr_t start_info_paddr) @@ -512,53 +373,6 @@ xen_pvh_parse_symtab(void) } #endif -static caddr_t -xen_legacy_pvh_parse_preload_data(uint64_t modulep) -{ - caddr_t kmdp; - vm_ooffset_t off; - vm_paddr_t metadata; - char *envp; - - if (legacy_start_info->mod_start != 0) { - preload_metadata = (caddr_t)legacy_start_info->mod_start; - - kmdp = preload_search_by_type("elf kernel"); - if (kmdp == NULL) - kmdp = preload_search_by_type("elf64 kernel"); - KASSERT(kmdp != NULL, ("unable to find kernel")); - - /* - * Xen has relocated the metadata and the modules, - * so we need to recalculate it's position. This is - * done by saving the original modulep address and - * then calculating the offset with mod_start, - * which contains the relocated modulep address. - */ - metadata = MD_FETCH(kmdp, MODINFOMD_MODULEP, vm_paddr_t); - off = legacy_start_info->mod_start - metadata; - - preload_bootstrap_relocate(off); - - boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); - if (envp != NULL) - envp += off; - xen_pvh_set_env(envp, NULL); - } else { - /* Parse the extra boot information given by Xen */ - boot_parse_cmdline_delim(legacy_start_info->cmd_line, ","); - kmdp = NULL; - } - - boothowto |= boot_env_to_howto(); - -#ifdef DDB - xen_pvh_parse_symtab(); -#endif - return (kmdp); -} - static caddr_t xen_pvh_parse_preload_data(uint64_t modulep) { From owner-dev-commits-src-main@freebsd.org Mon May 17 09:43:05 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20611641DE8; Mon, 17 May 2021 09:43: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 4FkDhT0HDrz3j8T; Mon, 17 May 2021 09:43: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 E75841AB5; Mon, 17 May 2021 09:43: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 14H9h4u5030617; Mon, 17 May 2021 09:43:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H9h4Vh030616; Mon, 17 May 2021 09:43:04 GMT (envelope-from git) Date: Mon, 17 May 2021 09:43:04 GMT Message-Id: <202105170943.14H9h4Vh030616@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: git: 2117a66af54f - main - xen: remove hypervisor_info MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2117a66af54f63cc474b4358bbb6967267e452cb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 09:43:05 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=2117a66af54f63cc474b4358bbb6967267e452cb commit 2117a66af54f63cc474b4358bbb6967267e452cb Author: Mitchell Horne AuthorDate: 2021-05-06 21:16:10 +0000 Commit: Roger Pau Monné CommitDate: 2021-05-17 08:56:52 +0000 xen: remove hypervisor_info This was a source of indirection needed to support PVHv1. Now that that support has been removed, we can eliminate it. Reviewed by: royger --- sys/x86/xen/hvm.c | 44 -------------------------------------------- sys/xen/xen-os.h | 27 ++++++--------------------- 2 files changed, 6 insertions(+), 65 deletions(-) diff --git a/sys/x86/xen/hvm.c b/sys/x86/xen/hvm.c index 9b5b588234c4..569b113364b1 100644 --- a/sys/x86/xen/hvm.c +++ b/sys/x86/xen/hvm.c @@ -489,47 +489,3 @@ xen_hvm_cpu_init(void) DPCPU_SET(vcpu_info, vcpu_info); } SYSINIT(xen_hvm_cpu_init, SI_SUB_INTR, SI_ORDER_FIRST, xen_hvm_cpu_init, NULL); - -/* HVM/PVH start_info accessors */ -static vm_paddr_t -hvm_get_xenstore_mfn(void) -{ - - return (hvm_get_parameter(HVM_PARAM_STORE_PFN)); -} - -static evtchn_port_t -hvm_get_xenstore_evtchn(void) -{ - - return (hvm_get_parameter(HVM_PARAM_STORE_EVTCHN)); -} - -static vm_paddr_t -hvm_get_console_mfn(void) -{ - - return (hvm_get_parameter(HVM_PARAM_CONSOLE_PFN)); -} - -static evtchn_port_t -hvm_get_console_evtchn(void) -{ - - return (hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN)); -} - -static uint32_t -hvm_get_start_flags(void) -{ - - return (hvm_start_flags); -} - -struct hypervisor_info hypervisor_info = { - .get_xenstore_mfn = hvm_get_xenstore_mfn, - .get_xenstore_evtchn = hvm_get_xenstore_evtchn, - .get_console_mfn = hvm_get_console_mfn, - .get_console_evtchn = hvm_get_console_evtchn, - .get_start_flags = hvm_get_start_flags, -}; diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h index 874c3b71b861..cd8a53aab54f 100644 --- a/sys/xen/xen-os.h +++ b/sys/xen/xen-os.h @@ -43,50 +43,35 @@ #include #ifndef __ASSEMBLY__ +#include #include -struct hypervisor_info { - vm_paddr_t (*get_xenstore_mfn)(void); - evtchn_port_t (*get_xenstore_evtchn)(void); - vm_paddr_t (*get_console_mfn)(void); - evtchn_port_t (*get_console_evtchn)(void); - uint32_t (*get_start_flags)(void); -}; -extern struct hypervisor_info hypervisor_info; - static inline vm_paddr_t xen_get_xenstore_mfn(void) { - return (hypervisor_info.get_xenstore_mfn()); + return (hvm_get_parameter(HVM_PARAM_STORE_PFN)); } static inline evtchn_port_t xen_get_xenstore_evtchn(void) { - return (hypervisor_info.get_xenstore_evtchn()); + return (hvm_get_parameter(HVM_PARAM_STORE_EVTCHN)); } static inline vm_paddr_t xen_get_console_mfn(void) { - return (hypervisor_info.get_console_mfn()); + return (hvm_get_parameter(HVM_PARAM_CONSOLE_PFN)); } static inline evtchn_port_t xen_get_console_evtchn(void) { - return (hypervisor_info.get_console_evtchn()); -} - -static inline uint32_t -xen_get_start_flags(void) -{ - - return (hypervisor_info.get_start_flags()); + return (hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN)); } #endif @@ -132,7 +117,7 @@ static inline bool xen_initial_domain(void) { - return (xen_domain() && (xen_get_start_flags() & SIF_INITDOMAIN) != 0); + return (xen_domain() && (hvm_start_flags & SIF_INITDOMAIN) != 0); } /* From owner-dev-commits-src-main@freebsd.org Mon May 17 09:43:06 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7865D641F23; Mon, 17 May 2021 09:43: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 4FkDhV1Srbz3j8Z; Mon, 17 May 2021 09:43: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 196501D00; Mon, 17 May 2021 09:43: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 14H9h6vu030643; Mon, 17 May 2021 09:43:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14H9h5cG030642; Mon, 17 May 2021 09:43:05 GMT (envelope-from git) Date: Mon, 17 May 2021 09:43:05 GMT Message-Id: <202105170943.14H9h5cG030642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: git: ac3ede5371af - main - x86/xen: remove PVHv1 code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ac3ede5371af34b0a89fa72b7a5bb706457b99ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 09:43:06 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=ac3ede5371af34b0a89fa72b7a5bb706457b99ad commit ac3ede5371af34b0a89fa72b7a5bb706457b99ad Author: Roger Pau Monné AuthorDate: 2021-05-12 10:17:53 +0000 Commit: Roger Pau Monné CommitDate: 2021-05-17 09:41:21 +0000 x86/xen: remove PVHv1 code PVHv1 was officially removed from Xen in 4.9, so just axe the related code from FreeBSD. Note FreeBSD supports PVHv2, which is the replacement for PVHv1. Sponsored by: Citrix Systems R&D Reviewed by: kib, Elliott Mitchell Differential Revision: https://reviews.freebsd.org/D30228 --- sys/amd64/amd64/machdep.c | 12 +- sys/amd64/amd64/mp_machdep.c | 4 +- sys/amd64/include/smp.h | 2 +- sys/conf/files | 1 - sys/conf/files.amd64 | 4 - sys/conf/files.x86 | 2 - sys/dev/xen/pci/xen_acpi_pci.c | 97 ------------ sys/dev/xen/pci/xen_pci.c | 79 ---------- sys/dev/xen/pvcpu/pvcpu.c | 99 ------------ sys/i386/i386/machdep.c | 3 - sys/x86/include/init.h | 3 - sys/x86/x86/local_apic.c | 2 +- sys/x86/xen/pv.c | 6 - sys/x86/xen/pvcpu_enum.c | 264 -------------------------------- sys/x86/xen/xen_intr.c | 340 +---------------------------------------- sys/x86/xen/xen_msi.c | 133 ---------------- sys/x86/xen/xen_nexus.c | 166 -------------------- sys/x86/xen/xen_pci_bus.c | 90 ----------- sys/xen/evtchn/evtchnvar.h | 1 - sys/xen/xen_intr.h | 44 ------ sys/xen/xen_msi.h | 39 ----- sys/xen/xen_pci.h | 37 ----- 22 files changed, 14 insertions(+), 1414 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 497975f0ee30..9ddad323449b 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -187,13 +187,6 @@ struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, .parse_memmap = native_parse_memmap, -#ifdef SMP - .mp_bootaddress = mp_bootaddress, - .start_all_aps = native_start_all_aps, -#endif -#ifdef DEV_PCI - .msi_init = msi_init, -#endif }; /* @@ -1283,8 +1276,9 @@ getmemsize(caddr_t kmdp, u_int64_t first) * is configured to support APs and APs for the system start * in real mode mode (e.g. SMP bare metal). */ - if (init_ops.mp_bootaddress) - init_ops.mp_bootaddress(physmap, &physmap_idx); +#ifdef SMP + mp_bootaddress(physmap, &physmap_idx); +#endif /* call pmap initialization to make new kernel address space */ pmap_bootstrap(&first); diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 11f2bb8bbfc1..6f788c087f06 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -245,7 +245,7 @@ cpu_mp_start(void) mptramp_la57 = la57; /* Start each Application Processor */ - init_ops.start_all_aps(); + start_all_aps(); set_interrupt_apic_ids(); @@ -397,7 +397,7 @@ mp_realloc_pcpu(int cpuid, int domain) * start each AP in our list */ int -native_start_all_aps(void) +start_all_aps(void) { u_int64_t *pt5, *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index 8fbd89da0e57..ac9ed5f61a23 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -38,7 +38,7 @@ inthand_t IDTVEC(rendezvous_pti); void invlop_handler(void); -int native_start_all_aps(void); +int start_all_aps(void); void mp_bootaddress(vm_paddr_t *, unsigned int *); #endif /* !LOCORE */ diff --git a/sys/conf/files b/sys/conf/files index 40b02aba28d6..22083169bfc7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3545,7 +3545,6 @@ dev/xen/netback/netback.c optional xenhvm dev/xen/netfront/netfront.c optional xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/timer/timer.c optional xenhvm -dev/xen/pvcpu/pvcpu.c optional xenhvm dev/xen/xenstore/xenstore.c optional xenhvm dev/xen/xenstore/xenstore_dev.c optional xenhvm dev/xen/xenstore/xenstored_dev.c optional xenhvm diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 9afaad72af74..1dd3a51a3af3 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -387,8 +387,6 @@ dev/viawd/viawd.c optional viawd dev/vmd/vmd.c optional vmd dev/vmd/vmd_bus.c optional vmd_bus dev/wbwd/wbwd.c optional wbwd -dev/xen/pci/xen_acpi_pci.c optional xenhvm -dev/xen/pci/xen_pci.c optional xenhvm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/imgact_aout.c optional compat_aout @@ -461,8 +459,6 @@ x86/x86/mptable.c optional mptable x86/x86/mptable_pci.c optional mptable pci x86/x86/msi.c optional pci x86/xen/pv.c optional xenhvm -x86/xen/pvcpu_enum.c optional xenhvm -x86/xen/xen_pci_bus.c optional xenhvm compat/linuxkpi/common/src/linux_fpu.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index 0a2cd1554eb4..b8d1e5a17048 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -328,5 +328,3 @@ x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xenhvm x86/xen/xen_apic.c optional xenhvm x86/xen/xenpv.c optional xenhvm -x86/xen/xen_msi.c optional xenhvm -x86/xen/xen_nexus.c optional xenhvm diff --git a/sys/dev/xen/pci/xen_acpi_pci.c b/sys/dev/xen/pci/xen_acpi_pci.c deleted file mode 100644 index 11797fb772dd..000000000000 --- a/sys/dev/xen/pci/xen_acpi_pci.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" -#include "pci_if.h" - -static int -xen_acpi_pci_probe(device_t dev) -{ - - if (!xen_pv_domain()) - return (ENXIO); - if (acpi_get_handle(dev) == NULL) - return (ENXIO); - - device_set_desc(dev, "Xen ACPI PCI bus"); - - return (BUS_PROBE_SPECIFIC); -} - -static void -xen_acpi_pci_child_added(device_t dev, device_t child) -{ - - acpi_pci_child_added(dev, child); - xen_pci_child_added_method(dev, child); -} - -static device_method_t xen_acpi_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, xen_acpi_pci_probe), - - /* PCI interface overwrites */ - DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), - DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), - DEVMETHOD(pci_child_added, xen_acpi_pci_child_added), - - DEVMETHOD_END -}; - -static devclass_t pci_devclass; - -DECLARE_CLASS(acpi_pci_driver); -DEFINE_CLASS_1(pci, xen_acpi_pci_driver, xen_acpi_pci_methods, - sizeof(struct pci_softc), acpi_pci_driver); -DRIVER_MODULE(xen_acpi_pci, pcib, xen_acpi_pci_driver, pci_devclass, 0, 0); -MODULE_DEPEND(xen_acpi_pci, pci, 1, 1, 1); -MODULE_DEPEND(xen_acpi_pci, acpi, 1, 1, 1); -MODULE_VERSION(xen_acpi_pci, 1); diff --git a/sys/dev/xen/pci/xen_pci.c b/sys/dev/xen/pci/xen_pci.c deleted file mode 100644 index d1bd439d4b76..000000000000 --- a/sys/dev/xen/pci/xen_pci.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" -#include "pci_if.h" - -static int -xen_pci_probe(device_t dev) -{ - - if (!xen_pv_domain()) - return (ENXIO); - - device_set_desc(dev, "Xen PCI bus"); - - return (BUS_PROBE_DEFAULT); -} - -static device_method_t xen_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, xen_pci_probe), - - /* PCI interface overwrites */ - DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), - DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), - DEVMETHOD(pci_child_added, xen_pci_child_added_method), - - DEVMETHOD_END -}; - -static devclass_t pci_devclass; - -DEFINE_CLASS_1(pci, xen_pci_driver, xen_pci_methods, sizeof(struct pci_softc), - pci_driver); -DRIVER_MODULE(xen_pci, pcib, xen_pci_driver, pci_devclass, 0, 0); -MODULE_DEPEND(xen_pci, pci, 1, 1, 1); -MODULE_VERSION(xen_pci, 1); diff --git a/sys/dev/xen/pvcpu/pvcpu.c b/sys/dev/xen/pvcpu/pvcpu.c deleted file mode 100644 index 2d41dac387ad..000000000000 --- a/sys/dev/xen/pvcpu/pvcpu.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013 Roger Pau Monné - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * Dummy Xen cpu device - * - * Since there's no ACPI on PVH guests, we need to create a dummy - * CPU device in order to fill the pcpu->pc_device field. - */ - -static void -xenpvcpu_identify(driver_t *driver, device_t parent) -{ - int i; - - /* Only attach in case the per-CPU device is not set. */ - if (!xen_domain() || PCPU_GET(device) != NULL) - return; - - CPU_FOREACH(i) { - if (BUS_ADD_CHILD(parent, 0, "pvcpu", i) == NULL) - panic("Unable to add Xen PV CPU device."); - } -} - -static int -xenpvcpu_probe(device_t dev) -{ - - device_set_desc(dev, "Xen PV CPU"); - return (BUS_PROBE_NOWILDCARD); -} - -static int -xenpvcpu_attach(device_t dev) -{ - struct pcpu *pc; - int cpu; - - cpu = device_get_unit(dev); - pc = pcpu_find(cpu); - pc->pc_device = dev; - return (0); -} - -static device_method_t xenpvcpu_methods[] = { - DEVMETHOD(device_identify, xenpvcpu_identify), - DEVMETHOD(device_probe, xenpvcpu_probe), - DEVMETHOD(device_attach, xenpvcpu_attach), - - DEVMETHOD_END -}; - -static driver_t xenpvcpu_driver = { - "pvcpu", - xenpvcpu_methods, - 0, -}; - -devclass_t xenpvcpu_devclass; - -DRIVER_MODULE(xenpvcpu, xenpv, xenpvcpu_driver, xenpvcpu_devclass, 0, 0); -MODULE_DEPEND(xenpvcpu, xenpv, 1, 1, 1); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 5fec2e448c53..ce4a264ede01 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -212,9 +212,6 @@ extern struct sysentvec elf32_freebsd_sysvec; struct init_ops init_ops = { .early_clock_source_init = i8254_init, .early_delay = i8254_delay, -#ifdef DEV_APIC - .msi_init = msi_init, -#endif }; static void diff --git a/sys/x86/include/init.h b/sys/x86/include/init.h index 880cabaa9496..4b1d318a6523 100644 --- a/sys/x86/include/init.h +++ b/sys/x86/include/init.h @@ -41,9 +41,6 @@ struct init_ops { void (*early_clock_source_init)(void); void (*early_delay)(int); void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); - void (*mp_bootaddress)(vm_paddr_t *, unsigned int *); - int (*start_all_aps)(void); - void (*msi_init)(void); }; extern struct init_ops init_ops; diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 36010fe38102..5b4910d4b891 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -1979,7 +1979,7 @@ apic_setup_io(void *dummy __unused) lapic_dump("BSP"); /* Enable the MSI "pic". */ - init_ops.msi_init(); + msi_init(); #ifdef XENHVM xen_intr_alloc_irqs(); diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 3511df779a92..c6dfff511c0c 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -121,11 +120,6 @@ struct init_ops xen_pvh_init_ops = { .early_clock_source_init = xen_clock_init, .early_delay = xen_delay, .parse_memmap = xen_pvh_parse_memmap, -#ifdef SMP - .mp_bootaddress = mp_bootaddress, - .start_all_aps = native_start_all_aps, -#endif - .msi_init = msi_init, }; static struct bios_smap xen_smap[MAX_E820_ENTRIES]; diff --git a/sys/x86/xen/pvcpu_enum.c b/sys/x86/xen/pvcpu_enum.c deleted file mode 100644 index 5d5c265fcc5f..000000000000 --- a/sys/x86/xen/pvcpu_enum.c +++ /dev/null @@ -1,264 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2013 Roger Pau Monné - * All rights reserved. - * Copyright (c) 2003 John Baldwin - * - * 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -static int xenpv_probe(void); -static int xenpv_probe_cpus(void); -static int xenpv_setup_local(void); -static int xenpv_setup_io(void); - -static ACPI_TABLE_MADT *madt; -static vm_paddr_t madt_physaddr; -static vm_offset_t madt_length; - -static struct apic_enumerator xenpv_enumerator = { - .apic_name = "Xen PV", - .apic_probe = xenpv_probe, - .apic_probe_cpus = xenpv_probe_cpus, - .apic_setup_local = xenpv_setup_local, - .apic_setup_io = xenpv_setup_io -}; - -/*--------------------- Helper functions to parse MADT -----------------------*/ - -/* - * Parse an interrupt source override for an ISA interrupt. - */ -static void -madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) -{ - enum intr_trigger trig; - enum intr_polarity pol; - int ret; - - if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && - intr->GlobalIrq == 2) { - if (bootverbose) - printf("MADT: Skipping timer override\n"); - return; - } - - madt_parse_interrupt_values(intr, &trig, &pol); - - /* Remap the IRQ if it is mapped to a different interrupt vector. */ - if (intr->SourceIrq != intr->GlobalIrq && intr->GlobalIrq > 15 && - intr->SourceIrq == AcpiGbl_FADT.SciInterrupt) - /* - * If the SCI is remapped to a non-ISA global interrupt, - * then override the vector we use to setup. - */ - acpi_OverrideInterruptLevel(intr->GlobalIrq); - - /* Register the IRQ with the polarity and trigger mode found. */ - ret = xen_register_pirq(intr->GlobalIrq, trig, pol); - if (ret != 0) - panic("Unable to register interrupt override"); -} - -/* - * Call the handler routine for each entry in the MADT table. - */ -static void -madt_walk_table(acpi_subtable_handler *handler, void *arg) -{ - - acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length, - handler, arg); -} - -/* - * Parse interrupt entries. - */ -static void -madt_parse_ints(ACPI_SUBTABLE_HEADER *entry, void *arg __unused) -{ - - if (entry->Type == ACPI_MADT_TYPE_INTERRUPT_OVERRIDE) - madt_parse_interrupt_override( - (ACPI_MADT_INTERRUPT_OVERRIDE *)entry); -} - -/*---------------------------- Xen PV enumerator -----------------------------*/ - -/* - * This enumerator will only be registered on PVH - */ -static int -xenpv_probe(void) -{ - return (0); -} - -/* - * Test each possible vCPU in order to find the number of vCPUs - */ -static int -xenpv_probe_cpus(void) -{ -#ifdef SMP - int i, ret; - - for (i = 0; i < MAXCPU && (i * 2) < MAX_APIC_ID; i++) { - ret = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); - mp_ncpus = min(mp_ncpus + 1, MAXCPU); - } - mp_maxid = mp_ncpus - 1; - max_apic_id = mp_ncpus * 2; -#endif - return (0); -} - -/* - * Initialize the vCPU id of the BSP - */ -static int -xenpv_setup_local(void) -{ -#ifdef SMP - int i, ret; - - for (i = 0; i < MAXCPU && (i * 2) < MAX_APIC_ID; i++) { - ret = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); - if (ret >= 0) - lapic_create((i * 2), (i == 0)); - } -#endif - - PCPU_SET(vcpu_id, 0); - lapic_init(0); - return (0); -} - -/* - * On PVH guests there's no IO APIC - */ -static int -xenpv_setup_io(void) -{ - - if (xen_initial_domain()) { - /* - * NB: we could iterate over the MADT IOAPIC entries in order - * to figure out the exact number of IOAPIC interrupts, but - * this is legacy code so just keep using the previous - * behaviour and assume a maximum of 256 interrupts. - */ - num_io_irqs = max(255, num_io_irqs); - - acpi_SetDefaultIntrModel(ACPI_INTR_APIC); - } - return (0); -} - -void -xenpv_register_pirqs(struct pic *pic __unused) -{ - unsigned int i; - int ret; - - /* Map MADT */ - madt_physaddr = acpi_find_table(ACPI_SIG_MADT); - madt = acpi_map_table(madt_physaddr, ACPI_SIG_MADT); - madt_length = madt->Header.Length; - - /* Try to initialize ACPI so that we can access the FADT. */ - ret = acpi_Startup(); - if (ACPI_FAILURE(ret)) { - printf("MADT: ACPI Startup failed with %s\n", - AcpiFormatException(ret)); - printf("Try disabling either ACPI or apic support.\n"); - panic("Using MADT but ACPI doesn't work"); - } - - /* Run through the table to see if there are any overrides. */ - madt_walk_table(madt_parse_ints, NULL); - - /* - * If there was not an explicit override entry for the SCI, - * force it to use level trigger and active-low polarity. - */ - if (!madt_found_sci_override) { - printf( -"MADT: Forcing active-low polarity and level trigger for SCI\n"); - ret = xen_register_pirq(AcpiGbl_FADT.SciInterrupt, - INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW); - if (ret != 0) - panic("Unable to register SCI IRQ"); - } - - /* Register legacy ISA IRQs */ - for (i = 1; i < 16; i++) { - if (intr_lookup_source(i) != NULL) - continue; - ret = xen_register_pirq(i, INTR_TRIGGER_EDGE, - INTR_POLARITY_LOW); - if (ret != 0 && bootverbose) - printf("Unable to register legacy IRQ#%u: %d\n", i, - ret); - } -} - -static void -xenpv_register(void *dummy __unused) -{ - if (xen_pv_domain()) { - apic_register_enumerator(&xenpv_enumerator); - } -} -SYSINIT(xenpv_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, xenpv_register, NULL); diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index 435db2e31693..c729ffddb345 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -114,8 +114,6 @@ DPCPU_DEFINE_STATIC(struct xen_intr_pcpu_data, xen_intr_pcpu) = { DPCPU_DECLARE(struct vcpu_info *, vcpu_info); -#define XEN_EEXIST 17 /* Xen "already exists" error */ -#define XEN_ALLOCATE_VECTOR 0 /* Allocate a vector for this event channel */ #define XEN_INVALID_EVTCHN 0 /* Invalid event channel */ #define is_valid_evtchn(x) ((x) != XEN_INVALID_EVTCHN) @@ -126,7 +124,6 @@ struct xenisrc { int xi_cpu; /* VCPU for delivery. */ int xi_vector; /* Global isrc vector number. */ evtchn_port_t xi_port; - int xi_pirq; int xi_virq; void *xi_cookie; u_int xi_close:1; /* close on unbind? */ @@ -149,14 +146,6 @@ static int xen_intr_config_intr(struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol); static int xen_intr_assign_cpu(struct intsrc *isrc, u_int apic_id); -static void xen_intr_pirq_enable_source(struct intsrc *isrc); -static void xen_intr_pirq_disable_source(struct intsrc *isrc, int eoi); -static void xen_intr_pirq_eoi_source(struct intsrc *isrc); -static void xen_intr_pirq_enable_intr(struct intsrc *isrc); -static void xen_intr_pirq_disable_intr(struct intsrc *isrc); -static int xen_intr_pirq_config_intr(struct intsrc *isrc, - enum intr_trigger trig, enum intr_polarity pol); - /** * PIC interface for all event channel port types except physical IRQs. */ @@ -174,30 +163,9 @@ struct pic xen_intr_pic = { .pic_assign_cpu = xen_intr_assign_cpu }; -/** - * PIC interface for all event channel representing - * physical interrupt sources. - */ -struct pic xen_intr_pirq_pic = { -#ifdef __amd64__ - .pic_register_sources = xenpv_register_pirqs, -#endif - .pic_enable_source = xen_intr_pirq_enable_source, - .pic_disable_source = xen_intr_pirq_disable_source, - .pic_eoi_source = xen_intr_pirq_eoi_source, - .pic_enable_intr = xen_intr_pirq_enable_intr, - .pic_disable_intr = xen_intr_pirq_disable_intr, - .pic_vector = xen_intr_vector, - .pic_source_pending = xen_intr_source_pending, - .pic_config_intr = xen_intr_pirq_config_intr, - .pic_assign_cpu = xen_intr_assign_cpu -}; - static struct mtx xen_intr_isrc_lock; static u_int xen_intr_auto_vector_count; static struct xenisrc *xen_intr_port_to_isrc[NR_EVENT_CHANNELS]; -static u_long *xen_intr_pirq_eoi_map; -static boolean_t xen_intr_pirq_eoi_map_enabled; /*------------------------- Private Functions --------------------------------*/ /** @@ -305,10 +273,11 @@ xen_intr_find_unused_isrc(enum evtchn_type type) * object or NULL. */ static struct xenisrc * -xen_intr_alloc_isrc(enum evtchn_type type, int vector) +xen_intr_alloc_isrc(enum evtchn_type type) { static int warned; struct xenisrc *isrc; + unsigned int vector; KASSERT(mtx_owned(&xen_intr_isrc_lock), ("Evtchn alloc lock not held")); @@ -320,18 +289,15 @@ xen_intr_alloc_isrc(enum evtchn_type type, int vector) return (NULL); } - if (type != EVTCHN_TYPE_PIRQ) { - vector = first_evtchn_irq + xen_intr_auto_vector_count; - xen_intr_auto_vector_count++; - } + vector = first_evtchn_irq + xen_intr_auto_vector_count; + xen_intr_auto_vector_count++; KASSERT((intr_lookup_source(vector) == NULL), ("Trying to use an already allocated vector")); mtx_unlock(&xen_intr_isrc_lock); isrc = malloc(sizeof(*isrc), M_XENINTR, M_WAITOK | M_ZERO); - isrc->xi_intsrc.is_pic = - (type == EVTCHN_TYPE_PIRQ) ? &xen_intr_pirq_pic : &xen_intr_pic; + isrc->xi_intsrc.is_pic = &xen_intr_pic; isrc->xi_vector = vector; isrc->xi_type = type; intr_register_source(&isrc->xi_intsrc); @@ -416,7 +382,7 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, mtx_lock(&xen_intr_isrc_lock); isrc = xen_intr_find_unused_isrc(type); if (isrc == NULL) { - isrc = xen_intr_alloc_isrc(type, XEN_ALLOCATE_VECTOR); + isrc = xen_intr_alloc_isrc(type); if (isrc == NULL) { mtx_unlock(&xen_intr_isrc_lock); return (ENOSPC); @@ -632,8 +598,7 @@ xen_intr_init(void *dummy __unused) { shared_info_t *s = HYPERVISOR_shared_info; struct xen_intr_pcpu_data *pcpu; - struct physdev_pirq_eoi_gmfn eoi_gmfn; - int i, rc; + int i; if (!xen_domain()) return (0); @@ -653,18 +618,7 @@ xen_intr_init(void *dummy __unused) for (i = 0; i < nitems(s->evtchn_mask); i++) atomic_store_rel_long(&s->evtchn_mask[i], ~0); - /* Try to register PIRQ EOI map */ - xen_intr_pirq_eoi_map = malloc(PAGE_SIZE, M_XENINTR, M_WAITOK | M_ZERO); - eoi_gmfn.gmfn = atop(vtophys(xen_intr_pirq_eoi_map)); - rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn); - if (rc != 0 && bootverbose) - printf("Xen interrupts: unable to register PIRQ EOI map\n"); - else - xen_intr_pirq_eoi_map_enabled = true; - intr_register_pic(&xen_intr_pic); - if (xen_pv_domain() && xen_initial_domain()) - intr_register_pic(&xen_intr_pirq_pic); if (bootverbose) printf("Xen interrupt system initialized\n"); @@ -1020,184 +974,6 @@ xen_intr_enable_intr(struct intsrc *base_isrc) evtchn_unmask_port(isrc->xi_port); } -/*------------------ Physical Interrupt Source PIC Functions -----------------*/ -/* - * Mask a level triggered interrupt source. - * - * \param isrc The interrupt source to mask (if necessary). - * \param eoi If non-zero, perform any necessary end-of-interrupt - * acknowledgements. - */ -static void -xen_intr_pirq_disable_source(struct intsrc *base_isrc, int eoi) -{ - struct xenisrc *isrc; - - isrc = (struct xenisrc *)base_isrc; - - if (isrc->xi_edgetrigger == 0) - evtchn_mask_port(isrc->xi_port); - if (eoi == PIC_EOI) - xen_intr_pirq_eoi_source(base_isrc); -} - -/* - * Unmask a level triggered interrupt source. - * - * \param isrc The interrupt source to unmask (if necessary). - */ -static void -xen_intr_pirq_enable_source(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - - isrc = (struct xenisrc *)base_isrc; - - if (isrc->xi_edgetrigger == 0) - evtchn_unmask_port(isrc->xi_port); -} - -/* - * Perform any necessary end-of-interrupt acknowledgements. - * - * \param isrc The interrupt source to EOI. - */ -static void -xen_intr_pirq_eoi_source(struct intsrc *base_isrc) -{ - struct xenisrc *isrc; - int error; - - isrc = (struct xenisrc *)base_isrc; - - if (xen_test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map)) { - struct physdev_eoi eoi = { .irq = isrc->xi_pirq }; - - error = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); - if (error != 0) - panic("Unable to EOI PIRQ#%d: %d\n", - isrc->xi_pirq, error); - } -} - -/* *** 817 LINES SKIPPED *** From owner-dev-commits-src-main@freebsd.org Mon May 17 13:47:54 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDDBD648974; Mon, 17 May 2021 13:47: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 4FkL6y595tz3Bv7; Mon, 17 May 2021 13:47: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 95D125215; Mon, 17 May 2021 13:47: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 14HDlsXx051552; Mon, 17 May 2021 13:47:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDlsX6051551; Mon, 17 May 2021 13:47:54 GMT (envelope-from git) Date: Mon, 17 May 2021 13:47:54 GMT Message-Id: <202105171347.14HDlsX6051551@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 9aad27931e61 - main - powerpc64/radix mmu: Remove dead variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9aad27931e61b7b418bb71a1e83e206ef549df22 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:47:54 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=9aad27931e61b7b418bb71a1e83e206ef549df22 commit 9aad27931e61b7b418bb71a1e83e206ef549df22 Author: Justin Hibbits AuthorDate: 2021-05-10 00:37:42 +0000 Commit: Justin Hibbits CommitDate: 2021-05-17 13:26:39 +0000 powerpc64/radix mmu: Remove dead variable Remove dead variable from mmu_radix_extract_and_hold(). Based on r352408 for amd64. --- sys/powerpc/aim/mmu_radix.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index 01fcc94bafb5..6ab2edf17dd9 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -3456,10 +3456,8 @@ mmu_radix_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) { pml3_entry_t l3e, *l3ep; pt_entry_t pte; - vm_paddr_t pa; vm_page_t m; - pa = 0; m = NULL; CTR4(KTR_PMAP, "%s(%p, %#x, %#x)", __func__, pmap, va, prot); PMAP_LOCK(pmap); From owner-dev-commits-src-main@freebsd.org Mon May 17 13:47:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 02BDF6484EC; Mon, 17 May 2021 13:47: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 4FkL6z6HfJz3Bp2; Mon, 17 May 2021 13:47: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 AE4704FF4; Mon, 17 May 2021 13:47: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 14HDltVM051580; Mon, 17 May 2021 13:47:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDltNE051579; Mon, 17 May 2021 13:47:55 GMT (envelope-from git) Date: Mon, 17 May 2021 13:47:55 GMT Message-Id: <202105171347.14HDltNE051579@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 7ed09a6778d3 - main - powerpc: Rework IPI message processing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7ed09a6778d3fdd5d0484c9a60f4aa48f7ffbb83 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:47:56 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=7ed09a6778d3fdd5d0484c9a60f4aa48f7ffbb83 commit 7ed09a6778d3fdd5d0484c9a60f4aa48f7ffbb83 Author: Justin Hibbits AuthorDate: 2021-04-27 00:10:41 +0000 Commit: Justin Hibbits CommitDate: 2021-05-17 13:26:40 +0000 powerpc: Rework IPI message processing Summary: There's no need to use a while loop in the IPI handler, the message list is cached once and processed. Instead, since the existing code calls ffs(), sort the handlers, and use a simple 'if' sequence. Reviewed By: nwhitehorn Differential Revision: https://reviews.freebsd.org/D30018 --- sys/powerpc/powerpc/mp_machdep.c | 68 ++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index a9f2aaf36adc..627cde77adbf 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -299,49 +299,43 @@ powerpc_ipi_handler(void *arg) { u_int cpuid; uint32_t ipimask; - int msg; CTR2(KTR_SMP, "%s: MSR 0x%08x", __func__, mfmsr()); ipimask = atomic_readandclear_32(&(pcpup->pc_ipimask)); if (ipimask == 0) return (FILTER_STRAY); - while ((msg = ffs(ipimask) - 1) != -1) { - ipimask &= ~(1u << msg); - switch (msg) { - case IPI_AST: - CTR1(KTR_SMP, "%s: IPI_AST", __func__); - break; - case IPI_PREEMPT: - CTR1(KTR_SMP, "%s: IPI_PREEMPT", __func__); - sched_preempt(curthread); - break; - case IPI_RENDEZVOUS: - CTR1(KTR_SMP, "%s: IPI_RENDEZVOUS", __func__); - smp_rendezvous_action(); - break; - case IPI_STOP: - - /* - * IPI_STOP_HARD is mapped to IPI_STOP so it is not - * necessary to add such case in the switch. - */ - CTR1(KTR_SMP, "%s: IPI_STOP or IPI_STOP_HARD (stop)", - __func__); - cpuid = PCPU_GET(cpuid); - savectx(&stoppcbs[cpuid]); - CPU_SET_ATOMIC(cpuid, &stopped_cpus); - while (!CPU_ISSET(cpuid, &started_cpus)) - cpu_spinwait(); - CPU_CLR_ATOMIC(cpuid, &stopped_cpus); - CPU_CLR_ATOMIC(cpuid, &started_cpus); - CTR1(KTR_SMP, "%s: IPI_STOP (restart)", __func__); - break; - case IPI_HARDCLOCK: - CTR1(KTR_SMP, "%s: IPI_HARDCLOCK", __func__); - hardclockintr(); - break; - } + if (ipimask & (1 << IPI_AST)) { + CTR1(KTR_SMP, "%s: IPI_AST", __func__); + } + if (ipimask & (1 << IPI_PREEMPT)) { + CTR1(KTR_SMP, "%s: IPI_PREEMPT", __func__); + sched_preempt(curthread); + } + if (ipimask & (1 << IPI_RENDEZVOUS)) { + CTR1(KTR_SMP, "%s: IPI_RENDEZVOUS", __func__); + smp_rendezvous_action(); + } + if (ipimask & (1 << IPI_STOP)) { + + /* + * IPI_STOP_HARD is mapped to IPI_STOP so it is not + * necessary to add such case. + */ + CTR1(KTR_SMP, "%s: IPI_STOP or IPI_STOP_HARD (stop)", + __func__); + cpuid = PCPU_GET(cpuid); + savectx(&stoppcbs[cpuid]); + CPU_SET_ATOMIC(cpuid, &stopped_cpus); + while (!CPU_ISSET(cpuid, &started_cpus)) + cpu_spinwait(); + CPU_CLR_ATOMIC(cpuid, &stopped_cpus); + CPU_CLR_ATOMIC(cpuid, &started_cpus); + CTR1(KTR_SMP, "%s: IPI_STOP (restart)", __func__); + } + if (ipimask & (1 << IPI_HARDCLOCK)) { + CTR1(KTR_SMP, "%s: IPI_HARDCLOCK", __func__); + hardclockintr(); } return (FILTER_HANDLED); From owner-dev-commits-src-main@freebsd.org Mon May 17 13:47:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 721926487F0; Mon, 17 May 2021 13:47: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 4FkL7217Vpz3C52; Mon, 17 May 2021 13:47: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 02E4E5216; Mon, 17 May 2021 13:47: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 14HDlvel051626; Mon, 17 May 2021 13:47:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDlvhx051625; Mon, 17 May 2021 13:47:57 GMT (envelope-from git) Date: Mon, 17 May 2021 13:47:57 GMT Message-Id: <202105171347.14HDlvhx051625@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: b2ee069e8cf7 - main - Fix locking in qoriq_gpio MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2ee069e8cf73ea91388dbbc9061af01109c774a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:47:58 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=b2ee069e8cf73ea91388dbbc9061af01109c774a commit b2ee069e8cf73ea91388dbbc9061af01109c774a Author: Justin Hibbits AuthorDate: 2021-05-17 13:22:30 +0000 Commit: Justin Hibbits CommitDate: 2021-05-17 13:46:45 +0000 Fix locking in qoriq_gpio qoriq_gpio_pin_setflags() locks the device mutex, as does qoriq_gpio_map_gpios(), causing a recursion on non-recursive lock. This was missed during testing for 16e549ebe. --- sys/dev/gpio/qoriq_gpio.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/sys/dev/gpio/qoriq_gpio.c b/sys/dev/gpio/qoriq_gpio.c index 82bd6cd9a72b..dc4813e07b8e 100644 --- a/sys/dev/gpio/qoriq_gpio.c +++ b/sys/dev/gpio/qoriq_gpio.c @@ -131,23 +131,15 @@ qoriq_gpio_pin_getname(device_t dev, uint32_t pin, char *name) return (0); } -/* Set flags for the pin. */ static int -qoriq_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +qoriq_gpio_pin_configure(device_t dev, uint32_t pin, uint32_t flags) { - struct qoriq_gpio_softc *sc = device_get_softc(dev); + struct qoriq_gpio_softc *sc; uint32_t reg; - if (!VALID_PIN(pin)) - return (EINVAL); - - if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == - (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) - return (EINVAL); + sc = device_get_softc(dev); - GPIO_LOCK(sc); if ((flags & sc->sc_pins[pin].gp_caps) != flags) { - GPIO_UNLOCK(sc); return (EINVAL); } @@ -168,6 +160,26 @@ qoriq_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) bus_write_4(sc->sc_mem, GPIO_GPODR, reg); } sc->sc_pins[pin].gp_flags = flags; + + return (0); +} + +/* Set flags for the pin. */ +static int +qoriq_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct qoriq_gpio_softc *sc = device_get_softc(dev); + uint32_t ret; + + if (!VALID_PIN(pin)) + return (EINVAL); + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == + (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) + return (EINVAL); + + GPIO_LOCK(sc); + ret = qoriq_gpio_pin_configure(dev, pin, flags); GPIO_UNLOCK(sc); return (0); } @@ -356,7 +368,7 @@ qoriq_gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, sc = device_get_softc(bus); GPIO_LOCK(sc); - err = qoriq_gpio_pin_setflags(bus, gpios[0], gpios[1]); + err = qoriq_gpio_pin_configure(bus, gpios[0], gpios[1]); GPIO_UNLOCK(sc); if (err == 0) { From owner-dev-commits-src-main@freebsd.org Mon May 17 13:47:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AA466487EF; Mon, 17 May 2021 13:47: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 4FkL7109kWz3C6X; Mon, 17 May 2021 13:47: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 DAC854FF5; Mon, 17 May 2021 13:47: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 14HDlucN051601; Mon, 17 May 2021 13:47:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDlumE051600; Mon, 17 May 2021 13:47:56 GMT (envelope-from git) Date: Mon, 17 May 2021 13:47:56 GMT Message-Id: <202105171347.14HDlumE051600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: ffd21bd2892d - main - Make ISA_206_ATOMICS a kernel option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ffd21bd2892df271a8a259b1d98ce81c8637facd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:47:57 -0000 The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=ffd21bd2892df271a8a259b1d98ce81c8637facd commit ffd21bd2892df271a8a259b1d98ce81c8637facd Author: Justin Hibbits AuthorDate: 2021-05-17 13:46:33 +0000 Commit: Justin Hibbits CommitDate: 2021-05-17 13:46:38 +0000 Make ISA_206_ATOMICS a kernel option Summary: To make it easier to build a kernel with PowerISA 2.06 atomics (sub-word atomics), add a kernel config option. User space still needs to specify it as a CFLAG but that seems easier to do than for the kernel config. Reviewed By: luporl Differential Revision: https://reviews.freebsd.org/D29809 --- sys/conf/options.powerpc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/conf/options.powerpc b/sys/conf/options.powerpc index 857fa8091f4a..463c2b9da8c7 100644 --- a/sys/conf/options.powerpc +++ b/sys/conf/options.powerpc @@ -15,6 +15,8 @@ FPU_EMU COMPAT_FREEBSD32 opt_global.h +ISA_206_ATOMICS opt_global.h + MOEA64_STATS opt_pmap.h AMIGAONE opt_platform.h MIKROTIK opt_platform.h From owner-dev-commits-src-main@freebsd.org Mon May 17 13:48:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7BEA6648D86; Mon, 17 May 2021 13:48: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 4FkL7R1zNJz3CB3; Mon, 17 May 2021 13:48: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 2D97C531C; Mon, 17 May 2021 13:48: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 14HDmJJb051825; Mon, 17 May 2021 13:48:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDmJwE051824; Mon, 17 May 2021 13:48:19 GMT (envelope-from git) Date: Mon, 17 May 2021 13:48:19 GMT Message-Id: <202105171348.14HDmJwE051824@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: d69cc0401472 - main - pf: Set the pfik_group for userspace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d69cc040147284c414dfd1c9f498dcc7c8291a8b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:48:19 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d69cc040147284c414dfd1c9f498dcc7c8291a8b commit d69cc040147284c414dfd1c9f498dcc7c8291a8b Author: Kristof Provost AuthorDate: 2021-05-16 06:50:17 +0000 Commit: Kristof Provost CommitDate: 2021-05-17 11:48:06 +0000 pf: Set the pfik_group for userspace Userspace relies on this pointer to work out if the kif is a group or not. It can't use it for anything else, because it's a pointer to a kernel address. Substitute 0xfeedc0de for 'true', so that we don't leak kernel memory addresses to userspace. PR: 255852 Reviewed by: donner MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30284 --- sys/netpfil/pf/pf_if.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index 4630098221c8..3c9b53daa28c 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -831,6 +831,14 @@ pf_kkif_to_kif(const struct pfi_kkif *kkif, struct pfi_kif *kif) kif->pfik_flags = kkif->pfik_flags; kif->pfik_tzero = kkif->pfik_tzero; kif->pfik_rulerefs = kkif->pfik_rulerefs; + /* + * Userspace relies on this pointer to decide if this is a group or + * not. We don't want to share the actual pointer, because it's + * useless to userspace and leaks kernel memory layout information. + * So instead we provide 0xfeedcode as 'true' and NULL as 'false'. + */ + kif->pfik_group = + kkif->pfik_group ? (struct ifg_group *)0xfeedc0de : NULL; } void From owner-dev-commits-src-main@freebsd.org Mon May 17 13:48:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90E78648C17; Mon, 17 May 2021 13:48: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 4FkL7S3X04z3CCj; Mon, 17 May 2021 13:48: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 5C86E510A; Mon, 17 May 2021 13:48: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 14HDmKil051848; Mon, 17 May 2021 13:48:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HDmKn2051847; Mon, 17 May 2021 13:48:20 GMT (envelope-from git) Date: Mon, 17 May 2021 13:48:20 GMT Message-Id: <202105171348.14HDmKn2051847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 45db38554517 - main - pf tests: More set skip on tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45db38554517c7e1b0cc0265113c22f92a0eb494 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 13:48:20 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=45db38554517c7e1b0cc0265113c22f92a0eb494 commit 45db38554517c7e1b0cc0265113c22f92a0eb494 Author: Kristof Provost AuthorDate: 2021-05-16 06:51:54 +0000 Commit: Kristof Provost CommitDate: 2021-05-17 11:48:06 +0000 pf tests: More set skip on tests Test the specific case reported in PR 255852. Clearing the skip flag on groups was broken because pfctl couldn't work out if a kif was a group or not, because the kernel no longer set the pfik_group pointer. PR: 255852 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30285 --- tests/sys/netpfil/pf/set_skip.sh | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/sys/netpfil/pf/set_skip.sh b/tests/sys/netpfil/pf/set_skip.sh index 95c6b6f77825..ce7b1900ae00 100644 --- a/tests/sys/netpfil/pf/set_skip.sh +++ b/tests/sys/netpfil/pf/set_skip.sh @@ -117,9 +117,55 @@ set_skip_dynamic_cleanup() pft_cleanup } +atf_test_case "pr255852" "cleanup" +pr255852_head() +{ + atf_set descr "PR 255852" + atf_set require.user root +} + +pr255852_body() +{ + pft_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig lo0 127.0.0.1/8 up + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + jexec alcatraz pfctl -e + pft_set_rules alcatraz "set skip on { lo0, epair }" \ + "block" + jexec alcatraz pfctl -vsI + + # We're skipping on epair, so this should work + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + # Note: flushing avoid the issue + pft_set_rules noflush alcatraz "set skip on { lo0 }" \ + "block" + + jexec alcatraz pfctl -vsI + + # No longer skipping, so this should fail + atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2 +} + +pr255852_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "set_skip_group" atf_add_test_case "set_skip_group_lo" atf_add_test_case "set_skip_dynamic" + atf_add_test_case "pr255852" } From owner-dev-commits-src-main@freebsd.org Mon May 17 15:05:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6B38D64AEAC; Mon, 17 May 2021 15:05: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 4FkMrq2dLCz3kPL; Mon, 17 May 2021 15:05: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 41DFA604A; Mon, 17 May 2021 15:05: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 14HF5lY7059162; Mon, 17 May 2021 15:05:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HF5lNN059161; Mon, 17 May 2021 15:05:47 GMT (envelope-from git) Date: Mon, 17 May 2021 15:05:47 GMT Message-Id: <202105171505.14HF5lNN059161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 02c44f40f984 - main - dummynet: Remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02c44f40f984951fe34a1c5a43f40ff8147c52ca Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 15:05:47 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=02c44f40f984951fe34a1c5a43f40ff8147c52ca commit 02c44f40f984951fe34a1c5a43f40ff8147c52ca Author: Kristof Provost AuthorDate: 2021-05-17 11:41:39 +0000 Commit: Kristof Provost CommitDate: 2021-05-17 13:03:55 +0000 dummynet: Remove unused code We never set 'busy' and never dequeue from the pending mq. Remove this code. Reviewed by: ae MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30313 --- sys/netpfil/ipfw/ip_dn_io.c | 8 -------- sys/netpfil/ipfw/ip_dn_private.h | 7 ------- 2 files changed, 15 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index b439d2679f3c..4a65bd0ef798 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -870,14 +870,6 @@ dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; - if (dn_cfg.busy) { - /* if the upper half is busy doing something expensive, - * lets queue the packet and move forward - */ - mq_append(&dn_cfg.pending, m); - m = *m0 = NULL; /* consumed */ - goto done; /* already active, nothing to do */ - } /* XXX locate_flowset could be optimised with a direct ref. */ fs = dn_ht_find(dn_cfg.fshash, fs_id, 0, NULL); if (fs == NULL) diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 6e48bc5116a7..e6e699bf35b2 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -171,13 +171,6 @@ struct dn_parms { int init_done; - /* if the upper half is busy doing something long, - * can set the busy flag and we will enqueue packets in - * a queue for later processing. - */ - int busy; - struct mq pending; - #ifdef _KERNEL /* * This file is normally used in the kernel, unless we do From owner-dev-commits-src-main@freebsd.org Mon May 17 17:06:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B6F164DA46; Mon, 17 May 2021 17:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FkQXX1BYSz4cc5; Mon, 17 May 2021 17:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 11FCF7E12; Mon, 17 May 2021 17:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14HH6ptl021362; Mon, 17 May 2021 17:06:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HH6paS021361; Mon, 17 May 2021 17:06:51 GMT (envelope-from git) Date: Mon, 17 May 2021 17:06:51 GMT Message-Id: <202105171706.14HH6paS021361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4224dbf4c7c4 - main - xen: Remove leftover bits missed in commit ac3ede5371 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4224dbf4c7c497130150eafb0442f5306389e068 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 17:06:52 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4224dbf4c7c497130150eafb0442f5306389e068 commit 4224dbf4c7c497130150eafb0442f5306389e068 Author: Mark Johnston AuthorDate: 2021-05-17 17:05:58 +0000 Commit: Mark Johnston CommitDate: 2021-05-17 17:06:44 +0000 xen: Remove leftover bits missed in commit ac3ede5371 Fixes: ac3ede5371 ("x86/xen: remove PVHv1 code") Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D30316 --- sys/x86/xen/pv.c | 69 -------------------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index c6dfff511c0c..254ca4002bda 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -95,10 +95,6 @@ uint64_t hammer_time_xen(vm_paddr_t); static caddr_t xen_pvh_parse_preload_data(uint64_t); static void xen_pvh_parse_memmap(caddr_t, vm_paddr_t *, int *); -#ifdef SMP -static int xen_pv_start_all_aps(void); -#endif - /*---------------------------- Extern Declarations ---------------------------*/ #ifdef SMP /* Variables used by amd64 mp_machdep to start APs */ @@ -208,71 +204,6 @@ hammer_time_xen(vm_paddr_t start_info_paddr) } /*-------------------------------- PV specific -------------------------------*/ -#ifdef SMP -static bool -start_xen_ap(int cpu) -{ - struct vcpu_guest_context *ctxt; - int ms, cpus = mp_naps; - const size_t stacksize = kstack_pages * PAGE_SIZE; - - /* allocate and set up an idle stack data page */ - bootstacks[cpu] = (void *)kmem_malloc(stacksize, M_WAITOK | M_ZERO); - doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - nmi_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - dbg_stack = (void *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - dpcpu = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); - - bootSTK = (char *)bootstacks[cpu] + kstack_pages * PAGE_SIZE - 8; - bootAP = cpu; - - ctxt = malloc(sizeof(*ctxt), M_TEMP, M_WAITOK | M_ZERO); - - ctxt->flags = VGCF_IN_KERNEL; - ctxt->user_regs.rip = (unsigned long) init_secondary; - ctxt->user_regs.rsp = (unsigned long) bootSTK; - - /* Set the AP to use the same page tables */ - ctxt->ctrlreg[3] = KPML4phys; - - if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt)) - panic("unable to initialize AP#%d", cpu); - - free(ctxt, M_TEMP); - - /* Launch the vCPU */ - if (HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL)) - panic("unable to start AP#%d", cpu); - - /* Wait up to 5 seconds for it to start. */ - for (ms = 0; ms < 5000; ms++) { - if (mp_naps > cpus) - return (true); - DELAY(1000); - } - - return (false); -} - -static int -xen_pv_start_all_aps(void) -{ - int cpu; - - mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - - for (cpu = 1; cpu < mp_ncpus; cpu++) { - /* attempt to start the Application Processor */ - if (!start_xen_ap(cpu)) - panic("AP #%d failed to start!", cpu); - - CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ - } - - return (mp_naps); -} -#endif /* SMP */ /* * When booted as a PVH guest FreeBSD needs to avoid using the RSDP address From owner-dev-commits-src-main@freebsd.org Mon May 17 21:26:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83E0E6339AF; Mon, 17 May 2021 21:26: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 4FkXHn3Htzz3vy6; Mon, 17 May 2021 21:26: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 556421367B; Mon, 17 May 2021 21:26: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 14HLQDDB067704; Mon, 17 May 2021 21:26:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HLQDM2067703; Mon, 17 May 2021 21:26:13 GMT (envelope-from git) Date: Mon, 17 May 2021 21:26:13 GMT Message-Id: <202105172126.14HLQDM2067703@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: f5b5de1a3210 - main - ipfw: reload sysctl.conf variables if needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f5b5de1a3210234f3a6864c88a2d3e11ac2dbf04 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 21:26:13 -0000 The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=f5b5de1a3210234f3a6864c88a2d3e11ac2dbf04 commit f5b5de1a3210234f3a6864c88a2d3e11ac2dbf04 Author: Eugene Grosbein AuthorDate: 2021-05-17 21:03:15 +0000 Commit: Eugene Grosbein CommitDate: 2021-05-17 21:03:15 +0000 ipfw: reload sysctl.conf variables if needed Currently ipfw has multiple components that are not parts of GENERIC kernel like dummynet etc. They can bring in important sysctls if enabled with rc.conf(5) and loaded with ipfw startup script by means of "required_modules" after initial consult with /etc/sysctl.conf at boot time. Here is an example of one increasing limit for dummynet hold queues that defaults to 100: net.inet.ip.dummynet.pipe_slot_limit=1000 This makes it possible to use ipfw/dummynet rules such as: ipfw pipe 1 config bw 50Mbit/s queue 1000 Such rule is rejected unless above sysctl is applied. Another example is a group of net.inet.ip.alias.* sysctls created after libalias.ko loaded as dependency of ipfw_nat. This is not a problem if corresponding code compiled in custom kernel so sysctls exist when sysctl.conf is read early or kernel modules loaded with a loader. This change makes it work also for GENERIC and modules loaded by means of rc.conf(5) settings. MFC after: 1 month --- libexec/rc/rc.d/ipfw | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libexec/rc/rc.d/ipfw b/libexec/rc/rc.d/ipfw index fd1c97671d70..22b65d2908cb 100755 --- a/libexec/rc/rc.d/ipfw +++ b/libexec/rc/rc.d/ipfw @@ -47,7 +47,7 @@ ipfw_prestart() ipfw_start() { - local _firewall_type + local _firewall_type _module _sysctl_reload if [ -n "${1}" ]; then _firewall_type=$1 @@ -55,6 +55,19 @@ ipfw_start() _firewall_type=${firewall_type} fi + _sysctl_reload=no + for _module in ${required_modules} + do + if kldstat -qn ${_module}; then + _sysctl_reload=yes + break + fi + done + + if [ ${_sysctl_reload} = yes ]; then + /etc/rc.d/sysctl reload + fi + # set the firewall rules script if none was specified [ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall From owner-dev-commits-src-main@freebsd.org Mon May 17 23:30:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 849F0635D46; Mon, 17 May 2021 23:30: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 4Fkb3g3KXMz4mS6; Mon, 17 May 2021 23:30: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 5AC1114E77; Mon, 17 May 2021 23:30: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 14HNUtIS037274; Mon, 17 May 2021 23:30:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14HNUtfT037273; Mon, 17 May 2021 23:30:55 GMT (envelope-from git) Date: Mon, 17 May 2021 23:30:55 GMT Message-Id: <202105172330.14HNUtfT037273@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: efe145a7453e - main - Correct assert added to dump program. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: efe145a7453e4208f032816ce3f80e9fb6b0e4ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 23:30:55 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=efe145a7453e4208f032816ce3f80e9fb6b0e4ee commit efe145a7453e4208f032816ce3f80e9fb6b0e4ee Author: Kirk McKusick AuthorDate: 2021-05-17 23:33:59 +0000 Commit: Kirk McKusick CommitDate: 2021-05-17 23:34:53 +0000 Correct assert added to dump program. The dump program was exiting with the message: Assertion failed: (spcl.c_count + blks < TP_NINDIR), function appendextdata, file /usr/src/sbin/dump/traverse.c, line 759. The problem arose when dumping external attributes. This assertion was added in this commit with no review by someone with expertise in the dump program: commit 2d518c6518cdb256ff6f2c463e6b115d89c104c3 Author: Warner Losh AuthorDate: Mon Jun 11 19:32:36 2018 +0000 Commit: Warner Losh CommitDate: Mon Jun 11 19:32:36 2018 +0000 Add asserts to prevent overflows of c_addr. It is clearly wrong as the statement immediately above it in the code which is deciding if the data will fit is: if (spcl.c_count + blks > TP_NINDIR) return (0); As is pointed out in the bug report, the assert should be: (spcl.c_count + blks <= TP_NINDIR) This commit corrects the assert. I am sorry that it took so long to be brought to my attention and get fixed. Reported by: Hampton Finger PR: 244470 MFC after: 3 days Sponsored by: Netflix --- sbin/dump/traverse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index d094a08a7eb0..3630d2240f58 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -756,7 +756,7 @@ appendextdata(union dinode *dp) * data by the writeextdata() routine. */ tbperdb = sblock->fs_bsize >> tp_bshift; - assert(spcl.c_count + blks < TP_NINDIR); + assert(spcl.c_count + blks <= TP_NINDIR); for (i = 0; i < blks; i++) if (&dp->dp2.di_extb[i / tbperdb] != 0) spcl.c_addr[spcl.c_count + i] = 1; From owner-dev-commits-src-main@freebsd.org Tue May 18 00:06:08 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08CE5636E5F; Tue, 18 May 2021 00:06: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 4FkbrH6rwwz4t3F; Tue, 18 May 2021 00:06: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 D00D3153CF; Tue, 18 May 2021 00:06: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 14I067pB080744; Tue, 18 May 2021 00:06:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14I067uC080743; Tue, 18 May 2021 00:06:07 GMT (envelope-from git) Date: Tue, 18 May 2021 00:06:07 GMT Message-Id: <202105180006.14I067uC080743@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 8d2b4b2e7c1e - main - cxgbe: Cast pointer arguments to trunc_page() to vm_offset_t. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d2b4b2e7c1e0b10c4d49963753db31c4794dbc4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 00:06:08 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8d2b4b2e7c1e0b10c4d49963753db31c4794dbc4 commit 8d2b4b2e7c1e0b10c4d49963753db31c4794dbc4 Author: John Baldwin AuthorDate: 2021-05-18 00:04:22 +0000 Commit: John Baldwin CommitDate: 2021-05-18 00:04:22 +0000 cxgbe: Cast pointer arguments to trunc_page() to vm_offset_t. Reported by: mjg, jenkins, rmacklem Fixes: 46bee8043ee2bd352d420cd573e0364ca45f813e Sponsored by: Chelsio Communications --- sys/dev/cxgbe/tom/t4_ddp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index c266a2e39fa9..34c01674659a 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -1042,7 +1042,7 @@ have_pgsz: npages = 0; while (entries--) { npages++; - start_pva = trunc_page(sgl->addr); + start_pva = trunc_page((vm_offset_t)sgl->addr); end_pva = trunc_page((vm_offset_t)sgl->addr + sgl->len - 1); npages += (end_pva - start_pva) >> pr->pr_page_shift[idx]; sgl = sgl + 1; @@ -1297,7 +1297,7 @@ t4_write_page_pods_for_sgl(struct adapter *sc, struct toepcb *toep, ddp_pgsz = 1 << pr->pr_page_shift[G_PPOD_PGSZ(prsv->prsv_tag)]; offset = (vm_offset_t)sgl->addr & PAGE_MASK; ppod_addr = pr->pr_start + (prsv->prsv_tag & pr->pr_tag_mask); - pva = trunc_page(sgl->addr); + pva = trunc_page((vm_offset_t)sgl->addr); mbufq_init(&wrq, INT_MAX); for (i = 0; i < prsv->prsv_nppods; ppod_addr += chunk) { From owner-dev-commits-src-main@freebsd.org Tue May 18 03:08:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D3DD463B978; Tue, 18 May 2021 03:08: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 4FkgtT5gdGz3wQW; Tue, 18 May 2021 03:08: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 AB11D17EA8; Tue, 18 May 2021 03:08: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 14I38HBJ021353; Tue, 18 May 2021 03:08:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14I38Hil021352; Tue, 18 May 2021 03:08:17 GMT (envelope-from git) Date: Tue, 18 May 2021 03:08:17 GMT Message-Id: <202105180308.14I38Hil021352@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 330f110bf1e4 - main - Fix 'hostuuid: preload data malformed' warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 03:08:17 -0000 The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd commit 330f110bf1e420dc8d8ddadc4030e0ae1f1c52bd Author: Colin Percival AuthorDate: 2021-05-15 05:57:38 +0000 Commit: Colin Percival CommitDate: 2021-05-18 03:07:49 +0000 Fix 'hostuuid: preload data malformed' warning If the preloaded hostuuid value is invalid and verbose booting is enabled, a warning is printed. This printf had two bugs: 1. It was missing a trailing \n character. 2. The malformed UUID is printed with %s even though it is not known to be NUL-terminated. This commit adds the missing \n and uses %.*s with the (already known) length of the preloaded UUID to ensure that we don't read past the end of the buffer. Reported by: kevans Fixes: c3188289 Preload hostuuid for early-boot use MFC after: 3 days --- sys/kern/kern_jail.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index b5c8f6ebf9be..f4cd6bd38d35 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -263,8 +263,8 @@ prison0_init(void) (void)strlcpy(prison0.pr_hostuuid, data, size + 1); } else if (bootverbose) { - printf("hostuuid: preload data malformed: '%s'", - data); + printf("hostuuid: preload data malformed: '%.*s'\n", + (int)size, data); } } } From owner-dev-commits-src-main@freebsd.org Tue May 18 03:08:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05D6763BD4E; Tue, 18 May 2021 03:08: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 4FkgtV6cmrz3wQZ; Tue, 18 May 2021 03:08: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 CBF0D17DA3; Tue, 18 May 2021 03:08: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 14I38IDQ021374; Tue, 18 May 2021 03:08:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14I38ImZ021373; Tue, 18 May 2021 03:08:18 GMT (envelope-from git) Date: Tue, 18 May 2021 03:08:18 GMT Message-Id: <202105180308.14I38ImZ021373@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: b6be9566d236 - main - Fix buffer overflow in preloaded hostuuid cleaning MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b6be9566d236f83ad1a44170a64b9a34e382eafa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 03:08:19 -0000 The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=b6be9566d236f83ad1a44170a64b9a34e382eafa commit b6be9566d236f83ad1a44170a64b9a34e382eafa Author: Colin Percival AuthorDate: 2021-05-14 18:07:37 +0000 Commit: Colin Percival CommitDate: 2021-05-18 03:07:49 +0000 Fix buffer overflow in preloaded hostuuid cleaning When a module of type "hostuuid" is provided by the loader, prison0_init strips any trailing whitespace and ASCII control characters by (a) adjusting the buffer length, and (b) zeroing out the characters in question, before storing it as the system's hostuuid. The buffer length adjustment was correct, but the zeroing overwrote one byte higher in memory than intended -- in the typical case, zeroing one byte past the end of the hostuuid buffer. Due to the layout of buffers passed by the boot loader to the kernel, this will be the first byte of a subsequent buffer. This was *probably* harmless; prison0_init runs after preloaded kernel modules have been linked and after the preloaded /boot/entropy cache has been processed, so in both cases having the first byte overwritten will not cause problems. We cannot however rule out the possibility that other objects which are preloaded by the loader could suffer from having the first byte overwritten. Since the zeroing does not in fact serve any purpose, remove it and trim trailing whitespace and ASCII control characters by adjusting the buffer length alone. Fixes: c3188289 Preload hostuuid for early-boot use Reviewed by: kevans, markj MFC after: 3 days --- sys/kern/kern_jail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index f4cd6bd38d35..303e31490eb1 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -257,7 +257,7 @@ prison0_init(void) * non-printable characters to be safe. */ while (size > 0 && data[size - 1] <= 0x20) { - data[size--] = '\0'; + size--; } if (validate_uuid(data, size, NULL, 0) == 0) { (void)strlcpy(prison0.pr_hostuuid, data, From owner-dev-commits-src-main@freebsd.org Tue May 18 07:43:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77561642E61; Tue, 18 May 2021 07:43: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 4Fknzr2vhVz3nC6; Tue, 18 May 2021 07:43: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 4BFC31BBA3; Tue, 18 May 2021 07:43: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 14I7hKPV091547; Tue, 18 May 2021 07:43:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14I7hKa1091546; Tue, 18 May 2021 07:43:20 GMT (envelope-from git) Date: Tue, 18 May 2021 07:43:20 GMT Message-Id: <202105180743.14I7hKa1091546@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ka Ho Ng Subject: git: c232fd4b4191 - main - sndstat.4: Improve manpage wording MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: khng X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c232fd4b4191a722f8c3193ef1e7c6efd8385182 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 07:43:20 -0000 The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=c232fd4b4191a722f8c3193ef1e7c6efd8385182 commit c232fd4b4191a722f8c3193ef1e7c6efd8385182 Author: Goran Mekić AuthorDate: 2021-05-18 07:34:34 +0000 Commit: Ka Ho Ng CommitDate: 2021-05-18 07:40:28 +0000 sndstat.4: Improve manpage wording Reviewed by: bcr, khng Differential Revision: https://reviews.freebsd.org/D30027 --- share/man/man4/sndstat.4 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4 index 26ecf9084dc1..92e17d86116a 100644 --- a/share/man/man4/sndstat.4 +++ b/share/man/man4/sndstat.4 @@ -47,10 +47,11 @@ kernel configuration file: .Sh DESCRIPTION The ioctl interface provided by .Pa /dev/sndstat -device allows callers to enumeration PCM audio devices available for use. +device allows callers to enumerate PCM audio devices available for use. +In other words, it provides means to get the list of all audio devices +available to the system. .Sh IOCTLS -For all ioctls requiring data exchange between the subsystem and callers, -the following structures are used to describe a serialized nvlist: +For ioctl calls that take an argument, the following structure is used: .Bd -literal -offset indent struct sndstioc_nv_arg { size_t nbytes; @@ -58,7 +59,7 @@ struct sndstioc_nv_arg { }; .Ed .Pp -Here is an example of an nvlist, with explanations of the common fields: +Here is an example of an nvlist object with explanations of the common fields: .Bd -literal -offset indent dsps (NVLIST ARRAY): 1 from_user (BOOL): FALSE From owner-dev-commits-src-main@freebsd.org Tue May 18 08:44:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20FCE64534B; Tue, 18 May 2021 08:44: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 4FkqLw0C6Fz4Txb; Tue, 18 May 2021 08:44: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 E38971C4D2; Tue, 18 May 2021 08:44: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 14I8it8p071664; Tue, 18 May 2021 08:44:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14I8it5X071663; Tue, 18 May 2021 08:44:55 GMT (envelope-from git) Date: Tue, 18 May 2021 08:44:55 GMT Message-Id: <202105180844.14I8it5X071663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= Subject: git: 9e14ac116e70 - main - x86/xen: further PVHv1 removal cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e14ac116e70722b7fcc803736184535295b165d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 08:44:56 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=9e14ac116e70722b7fcc803736184535295b165d commit 9e14ac116e70722b7fcc803736184535295b165d Author: Roger Pau Monné AuthorDate: 2021-05-18 08:43:19 +0000 Commit: Roger Pau Monné CommitDate: 2021-05-18 08:43:31 +0000 x86/xen: further PVHv1 removal cleanup The AP startup extern variable declarations are not longer needed, since PVHv2 uses the native AP startup path using the lapic. Remove the declaration and make the variables static to mp_machdep.c Sponsored by: Citrix Systems R&D --- sys/amd64/amd64/mp_machdep.c | 8 ++++---- sys/x86/xen/pv.c | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 6f788c087f06..1513393a4387 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -99,10 +99,10 @@ __FBSDID("$FreeBSD$"); #define AP_BOOTPT_SZ (PAGE_SIZE * 4) /* Temporary variables for init_secondary() */ -char *doublefault_stack; -char *mce_stack; -char *nmi_stack; -char *dbg_stack; +static char *doublefault_stack; +static char *mce_stack; +static char *nmi_stack; +static char *dbg_stack; extern u_int mptramp_la57; diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 254ca4002bda..6e1bba691171 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -96,14 +96,6 @@ static caddr_t xen_pvh_parse_preload_data(uint64_t); static void xen_pvh_parse_memmap(caddr_t, vm_paddr_t *, int *); /*---------------------------- Extern Declarations ---------------------------*/ -#ifdef SMP -/* Variables used by amd64 mp_machdep to start APs */ -extern char *doublefault_stack; -extern char *mce_stack; -extern char *nmi_stack; -extern char *dbg_stack; -#endif - /* * Placed by the linker at the end of the bss section, which is the last * section loaded by Xen before loading the symtab and strtab. From owner-dev-commits-src-main@freebsd.org Tue May 18 14:16:06 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C42E964DF34; Tue, 18 May 2021 14:16: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 4Fkyj25Bszz4XDh; Tue, 18 May 2021 14:16: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 99C8D20B43; Tue, 18 May 2021 14:16: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 14IEG68b010246; Tue, 18 May 2021 14:16:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IEG6cT010245; Tue, 18 May 2021 14:16:06 GMT (envelope-from git) Date: Tue, 18 May 2021 14:16:06 GMT Message-Id: <202105181416.14IEG6cT010245@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 00e501d720d4 - main - Update usb_timings_sysctl_handler() to accept any value for timings between 0 milliseconds and 2 seconds inclusivly. Some style fixes while at it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 00e501d720d46386e6c8d0ebb4b3a8e98cb0390e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 14:16:06 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=00e501d720d46386e6c8d0ebb4b3a8e98cb0390e commit 00e501d720d46386e6c8d0ebb4b3a8e98cb0390e Author: Hans Petter Selasky AuthorDate: 2021-05-18 13:16:29 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-18 13:52:41 +0000 Update usb_timings_sysctl_handler() to accept any value for timings between 0 milliseconds and 2 seconds inclusivly. Some style fixes while at it. The USB specification has minimum values and maximum values, and not only minimum values. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/usb_debug.c | 57 +++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 5b5d141508c3..5e521f7ec3a5 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -249,71 +249,40 @@ unsigned int usb_extra_power_up_time = USB_EXTRA_POWER_UP_TIME; /*------------------------------------------------------------------------* * usb_timings_sysctl_handler * - * This function updates timings variables, adjusting them where necessary. + * This function is used to update USB timing variables. *------------------------------------------------------------------------*/ static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS) { int error = 0; - unsigned int val; + unsigned val; /* * Attempt to get a coherent snapshot by making a copy of the data. */ if (arg1) - val = *(unsigned int *)arg1; + val = *(unsigned *)arg1; else val = arg2; - error = SYSCTL_OUT(req, &val, sizeof(int)); + error = SYSCTL_OUT(req, &val, sizeof(unsigned)); if (error || !req->newptr) return (error); if (!arg1) - return EPERM; + return (EPERM); - error = SYSCTL_IN(req, &val, sizeof(unsigned int)); + error = SYSCTL_IN(req, &val, sizeof(unsigned)); if (error) return (error); /* - * Now make sure the values are decent, and certainly no lower than - * what the USB spec prescribes. + * Make sure the specified value is not too big. Accept any + * value from 0 milliseconds to 2 seconds inclusivly for all + * parameters. */ - unsigned int *p = (unsigned int *)arg1; - if (p == &usb_port_reset_delay) { - if (val < USB_PORT_RESET_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_root_reset_delay) { - if (val < USB_PORT_ROOT_RESET_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_reset_recovery) { - if (val < USB_PORT_RESET_RECOVERY_SPEC) - return (EINVAL); - } else if (p == &usb_port_powerup_delay) { - if (val < USB_PORT_POWERUP_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_resume_delay) { - if (val < USB_PORT_RESUME_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_set_address_settle) { - if (val < USB_SET_ADDRESS_SETTLE_SPEC) - return (EINVAL); - } else if (p == &usb_resume_delay) { - if (val < USB_RESUME_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_resume_wait) { - if (val < USB_RESUME_WAIT_SPEC) - return (EINVAL); - } else if (p == &usb_resume_recovery) { - if (val < USB_RESUME_RECOVERY_SPEC) - return (EINVAL); - } else if (p == &usb_extra_power_up_time) { - if (val < USB_EXTRA_POWER_UP_TIME_SPEC) - return (EINVAL); - } else { - /* noop */ - } + if (val > 2000) + return (EINVAL); - *p = val; - return 0; + *(unsigned *)arg1 = val; + return (0); } #endif From owner-dev-commits-src-main@freebsd.org Tue May 18 14:16:08 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1336A64E236; Tue, 18 May 2021 14:16: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 4Fkyj36D9tz4XGR; Tue, 18 May 2021 14:16: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 BBB0620CC8; Tue, 18 May 2021 14:16: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 14IEG7AR010267; Tue, 18 May 2021 14:16:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IEG7vP010266; Tue, 18 May 2021 14:16:07 GMT (envelope-from git) Date: Tue, 18 May 2021 14:16:07 GMT Message-Id: <202105181416.14IEG7vP010266@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 70ffaaa69c83 - main - Update USB_PORT_RESET_RECOVERY to comply with the USB 2.0 specification which says it should be max 10 milliseconds. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 70ffaaa69c830d26b59136d0b0447ab2f8683db8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 14:16:08 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=70ffaaa69c830d26b59136d0b0447ab2f8683db8 commit 70ffaaa69c830d26b59136d0b0447ab2f8683db8 Author: Hans Petter Selasky AuthorDate: 2021-05-18 13:22:32 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-18 13:52:41 +0000 Update USB_PORT_RESET_RECOVERY to comply with the USB 2.0 specification which says it should be max 10 milliseconds. This may fix some USB enumeration issues: > usbd_req_re_enumerate: addr=3, set address failed! (USB_ERR_IOERROR, ignored) > usbd_setup_device_desc: getting device descriptor at addr 3 failed, Found by: Zhichao1.Li@dell.com MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/usb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index 346ecd3059d7..dcdb62114d63 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -115,7 +115,7 @@ MALLOC_DECLARE(M_USBDEV); /* Allow for marginal and non-conforming devices. */ #define USB_PORT_RESET_DELAY 50 /* ms */ #define USB_PORT_ROOT_RESET_DELAY 200 /* ms */ -#define USB_PORT_RESET_RECOVERY 250 /* ms */ +#define USB_PORT_RESET_RECOVERY 10 /* ms */ #define USB_PORT_POWERUP_DELAY 300 /* ms */ #define USB_PORT_RESUME_DELAY (20*2) /* ms */ #define USB_SET_ADDRESS_SETTLE 10 /* ms */ From owner-dev-commits-src-main@freebsd.org Tue May 18 14:16:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE0C864E0AE; Tue, 18 May 2021 14:16:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fkyj50yVXz4X5Y; Tue, 18 May 2021 14:16: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 DDD58209E9; Tue, 18 May 2021 14:16: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 14IEG829010288; Tue, 18 May 2021 14:16:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IEG8hu010287; Tue, 18 May 2021 14:16:08 GMT (envelope-from git) Date: Tue, 18 May 2021 14:16:08 GMT Message-Id: <202105181416.14IEG8hu010287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: e5ff940a81b5 - main - Propagate down USB explore error codes, so that failures to enumerate USB HUBs behind USB HUBs are detected and the USB reset counter logic will kick in preventing enumeration of continuously failing ports. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e5ff940a81b56cb236795e0059c44981053f8404 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 14:16:10 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=e5ff940a81b56cb236795e0059c44981053f8404 commit e5ff940a81b56cb236795e0059c44981053f8404 Author: Hans Petter Selasky AuthorDate: 2021-05-18 13:52:00 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-18 14:11:35 +0000 Propagate down USB explore error codes, so that failures to enumerate USB HUBs behind USB HUBs are detected and the USB reset counter logic will kick in preventing enumeration of continuously failing ports. Submitted by: phk@ Tested by: bz@ PR: 237666 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/usb_hub.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 6ed30b64b1e0..52ac0a8a7ff7 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -513,7 +513,7 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up) usb_error_t err; bus = sc->sc_udev->bus; - err = 0; + err = USB_ERR_NORMAL_COMPLETION; /* get driver added refcount from USB bus */ refcount = bus->driver_added_refcount; @@ -1013,7 +1013,7 @@ uhub_explore(struct usb_device *udev) if (udev->flags.self_suspended) { /* need to wait until the child signals resume */ DPRINTF("Device is suspended!\n"); - return (0); + return (USB_ERR_NORMAL_COMPLETION); } /* @@ -1022,6 +1022,12 @@ uhub_explore(struct usb_device *udev) */ do_unlock = usbd_enum_lock(udev); + /* + * Set default error code to avoid compiler warnings. + * Note that hub->nports cannot be zero. + */ + err = USB_ERR_NORMAL_COMPLETION; + for (x = 0; x != hub->nports; x++) { up = hub->ports + x; portno = x + 1; @@ -1090,13 +1096,11 @@ uhub_explore(struct usb_device *udev) break; } } - err = uhub_explore_sub(sc, up); - if (err) { - /* no device(s) present */ - continue; + + if (uhub_explore_sub(sc, up) == USB_ERR_NORMAL_COMPLETION) { + /* explore succeeded - reset restart counter */ + up->restartcnt = 0; } - /* explore succeeded - reset restart counter */ - up->restartcnt = 0; } if (do_unlock) @@ -1105,8 +1109,7 @@ uhub_explore(struct usb_device *udev) /* initial status checked */ sc->sc_flags |= UHUB_FLAG_DID_EXPLORE; - /* return success */ - return (USB_ERR_NORMAL_COMPLETION); + return (err); } int From owner-dev-commits-src-main@freebsd.org Tue May 18 15:30:32 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7FE264FEAC; Tue, 18 May 2021 15:30: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 4Fl0Lw5JMzz4mnT; Tue, 18 May 2021 15:30: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 9EA9021E8F; Tue, 18 May 2021 15:30: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 14IFUW1v011746; Tue, 18 May 2021 15:30:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IFUWN6011745; Tue, 18 May 2021 15:30:32 GMT (envelope-from git) Date: Tue, 18 May 2021 15:30:32 GMT Message-Id: <202105181530.14IFUWN6011745@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 715fcc0d3426 - main - vfs: change vn_freevnodes_* prefix to idiomatic vfs_freevnodes_* MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 715fcc0d342684da5d109a7e4891d30aa38667c9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 15:30:32 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=715fcc0d342684da5d109a7e4891d30aa38667c9 commit 715fcc0d342684da5d109a7e4891d30aa38667c9 Author: Mateusz Guzik AuthorDate: 2021-05-14 19:01:56 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-18 15:30:28 +0000 vfs: change vn_freevnodes_* prefix to idiomatic vfs_freevnodes_* --- sys/kern/vfs_subr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 468bd21dae21..875925ac9a58 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1426,7 +1426,7 @@ static int vnlruproc_sig; #define VNLRU_FREEVNODES_SLOP 128 static __inline void -vn_freevnodes_inc(void) +vfs_freevnodes_inc(void) { struct vdbatch *vd; @@ -1437,7 +1437,7 @@ vn_freevnodes_inc(void) } static __inline void -vn_freevnodes_dec(void) +vfs_freevnodes_dec(void) { struct vdbatch *vd; @@ -3369,7 +3369,7 @@ vhold(struct vnode *vp) VNASSERT(old >= 0 && (old & VHOLD_ALL_FLAGS) == 0, vp, ("%s: wrong hold count %d", __func__, old)); if (old == 0) - vn_freevnodes_dec(); + vfs_freevnodes_dec(); } void @@ -3422,7 +3422,7 @@ vhold_smr(struct vnode *vp) VNASSERT(count >= 0, vp, ("invalid hold count %d\n", count)); if (atomic_fcmpset_int(&vp->v_holdcnt, &count, count + 1)) { if (count == 0) - vn_freevnodes_dec(); + vfs_freevnodes_dec(); return (true); } } @@ -3463,7 +3463,7 @@ vhold_recycle_free(struct vnode *vp) return (false); } if (atomic_fcmpset_int(&vp->v_holdcnt, &count, count + 1)) { - vn_freevnodes_dec(); + vfs_freevnodes_dec(); return (true); } } @@ -3624,7 +3624,7 @@ vdropl_final(struct vnode *vp) * we never got this far, they will vdrop later. */ if (__predict_false(!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR))) { - vn_freevnodes_inc(); + vfs_freevnodes_inc(); VI_UNLOCK(vp); /* * We lost the aforementioned race. Any subsequent access is @@ -3661,7 +3661,7 @@ vdropl(struct vnode *vp) return; } if (!VN_IS_DOOMED(vp)) { - vn_freevnodes_inc(); + vfs_freevnodes_inc(); vdrop_deactivate(vp); /* * Also unlocks the interlock. We can't assert on it as we From owner-dev-commits-src-main@freebsd.org Tue May 18 15:30:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE0B564FF91; Tue, 18 May 2021 15:30:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fl0Lx6NJyz4mq5; Tue, 18 May 2021 15:30:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE81521AE2; Tue, 18 May 2021 15:30:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14IFUXJn011767; Tue, 18 May 2021 15:30:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IFUXrq011766; Tue, 18 May 2021 15:30:33 GMT (envelope-from git) Date: Tue, 18 May 2021 15:30:33 GMT Message-Id: <202105181530.14IFUXrq011766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: cc6f46ac2fd5 - main - vfs: refactor vdrop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc6f46ac2fd5d910e632fced3f21d0b0f53030d8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 15:30:34 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=cc6f46ac2fd5d910e632fced3f21d0b0f53030d8 commit cc6f46ac2fd5d910e632fced3f21d0b0f53030d8 Author: Mateusz Guzik AuthorDate: 2021-05-14 19:01:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-18 15:30:28 +0000 vfs: refactor vdrop In particular move vunlazy into its own routine. --- sys/kern/vfs_subr.c | 85 +++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 875925ac9a58..18c5b5b3b148 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3120,6 +3120,31 @@ vlazy(struct vnode *vp) mtx_unlock(&mp->mnt_listmtx); } +static void +vunlazy(struct vnode *vp) +{ + struct mount *mp; + + ASSERT_VI_LOCKED(vp, __func__); + VNPASS(!VN_IS_DOOMED(vp), vp); + + mp = vp->v_mount; + mtx_lock(&mp->mnt_listmtx); + VNPASS(vp->v_mflag & VMP_LAZYLIST, vp); + /* + * Don't remove the vnode from the lazy list if another thread + * has increased the hold count. It may have re-enqueued the + * vnode to the lazy list and is now responsible for its + * removal. + */ + if (vp->v_holdcnt == 0) { + vp->v_mflag &= ~VMP_LAZYLIST; + TAILQ_REMOVE(&mp->mnt_lazyvnodelist, vp, v_lazylist); + mp->mnt_lazyvnodelistsize--; + } + mtx_unlock(&mp->mnt_listmtx); +} + /* * This routine is only meant to be called from vgonel prior to dooming * the vnode. @@ -3575,42 +3600,6 @@ vdbatch_dequeue(struct vnode *vp) * there is at least one resident non-cached page, the vnode cannot * leave the active list without the page cleanup done. */ -static void -vdrop_deactivate(struct vnode *vp) -{ - struct mount *mp; - - ASSERT_VI_LOCKED(vp, __func__); - /* - * Mark a vnode as free: remove it from its active list - * and put it up for recycling on the freelist. - */ - VNASSERT(!VN_IS_DOOMED(vp), vp, - ("vdrop: returning doomed vnode")); - VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp, - ("vnode with VI_OWEINACT set")); - VNASSERT((vp->v_iflag & VI_DEFINACT) == 0, vp, - ("vnode with VI_DEFINACT set")); - if (vp->v_mflag & VMP_LAZYLIST) { - mp = vp->v_mount; - mtx_lock(&mp->mnt_listmtx); - VNASSERT(vp->v_mflag & VMP_LAZYLIST, vp, ("lost VMP_LAZYLIST")); - /* - * Don't remove the vnode from the lazy list if another thread - * has increased the hold count. It may have re-enqueued the - * vnode to the lazy list and is now responsible for its - * removal. - */ - if (vp->v_holdcnt == 0) { - vp->v_mflag &= ~VMP_LAZYLIST; - TAILQ_REMOVE(&mp->mnt_lazyvnodelist, vp, v_lazylist); - mp->mnt_lazyvnodelistsize--; - } - mtx_unlock(&mp->mnt_listmtx); - } - vdbatch_enqueue(vp); -} - static void __noinline vdropl_final(struct vnode *vp) { @@ -3660,17 +3649,23 @@ vdropl(struct vnode *vp) VI_UNLOCK(vp); return; } - if (!VN_IS_DOOMED(vp)) { - vfs_freevnodes_inc(); - vdrop_deactivate(vp); - /* - * Also unlocks the interlock. We can't assert on it as we - * released our hold and by now the vnode might have been - * freed. - */ + VNPASS((vp->v_iflag & VI_OWEINACT) == 0, vp); + VNPASS((vp->v_iflag & VI_DEFINACT) == 0, vp); + if (VN_IS_DOOMED(vp)) { + vdropl_final(vp); return; } - vdropl_final(vp); + + vfs_freevnodes_inc(); + if (vp->v_mflag & VMP_LAZYLIST) { + vunlazy(vp); + } + /* + * Also unlocks the interlock. We can't assert on it as we + * released our hold and by now the vnode might have been + * freed. + */ + vdbatch_enqueue(vp); } /* From owner-dev-commits-src-main@freebsd.org Tue May 18 18:05:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC6406531FF; Tue, 18 May 2021 18:05: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 4Fl3nP5y91z3r55; Tue, 18 May 2021 18:05: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 B4A6C23E27; Tue, 18 May 2021 18:05: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 14II5DoA017577; Tue, 18 May 2021 18:05:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14II5DTG017576; Tue, 18 May 2021 18:05:13 GMT (envelope-from git) Date: Tue, 18 May 2021 18:05:13 GMT Message-Id: <202105181805.14II5DTG017576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 8cf912b017a0 - main - ttydev_write: prevent stops while terminal is busied MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8cf912b017a04a2eec01fbaa1f7b9ef556403ede Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 18:05:13 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf912b017a04a2eec01fbaa1f7b9ef556403ede commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede Author: Konstantin Belousov AuthorDate: 2021-05-13 01:35:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-18 17:52:03 +0000 ttydev_write: prevent stops while terminal is busied Since busy state is checked by all blocked writes, stopping a process which waits in ttydisc_write() causes cascade. Utilize sigdeferstop() to avoid the issue. Submitted by: Jakub Piecuch PR: 255816 MFC after: 1 week --- sys/kern/tty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 00b4df675311..8700eb8f9ef1 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -525,7 +525,7 @@ static int ttydev_write(struct cdev *dev, struct uio *uio, int ioflag) { struct tty *tp = dev->si_drv1; - int error; + int defer, error; error = ttydev_enter(tp); if (error) @@ -549,7 +549,9 @@ ttydev_write(struct cdev *dev, struct uio *uio, int ioflag) } tp->t_flags |= TF_BUSY_OUT; + defer = sigdeferstop(SIGDEFERSTOP_ERESTART); error = ttydisc_write(tp, uio, ioflag); + sigallowstop(defer); tp->t_flags &= ~TF_BUSY_OUT; cv_signal(&tp->t_outserwait); } From owner-dev-commits-src-main@freebsd.org Tue May 18 19:43:49 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 64EF1655DA7; Tue, 18 May 2021 19:43: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 4Fl5z92T2Tz4jhS; Tue, 18 May 2021 19:43: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 3D3D5252D8; Tue, 18 May 2021 19:43: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 14IJhnNx051245; Tue, 18 May 2021 19:43:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IJhnFD051244; Tue, 18 May 2021 19:43:49 GMT (envelope-from git) Date: Tue, 18 May 2021 19:43:49 GMT Message-Id: <202105181943.14IJhnFD051244@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c4a6258d70f7 - main - dummynet: Fix mbuf tag allocation failure handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4a6258d70f73c27d8f0c6233edbcc609791806b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 19:43:49 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c4a6258d70f73c27d8f0c6233edbcc609791806b commit c4a6258d70f73c27d8f0c6233edbcc609791806b Author: Mark Johnston AuthorDate: 2021-05-18 19:22:21 +0000 Commit: Mark Johnston CommitDate: 2021-05-18 19:25:16 +0000 dummynet: Fix mbuf tag allocation failure handling PR: 255875, 255878, 255879, 255880 Reviewed by: donner, kp MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30318 --- sys/netpfil/ipfw/dn_aqm_codel.c | 4 +--- sys/netpfil/ipfw/dn_aqm_pie.c | 6 +++--- sys/netpfil/ipfw/dn_sched_fq_codel.c | 4 +--- sys/netpfil/ipfw/dn_sched_fq_pie.c | 6 +++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm_codel.c b/sys/netpfil/ipfw/dn_aqm_codel.c index 4b921f0f52c8..a1f90461ecab 100644 --- a/sys/netpfil/ipfw/dn_aqm_codel.c +++ b/sys/netpfil/ipfw/dn_aqm_codel.c @@ -256,10 +256,8 @@ aqm_codel_enqueue(struct dn_queue *q, struct mbuf *m) if (mtag == NULL) mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); - if (mtag == NULL) { - m_freem(m); + if (mtag == NULL) goto drop; - } *(aqm_time_t *)(mtag + 1) = AQM_UNOW; m_tag_prepend(m, mtag); diff --git a/sys/netpfil/ipfw/dn_aqm_pie.c b/sys/netpfil/ipfw/dn_aqm_pie.c index abd5bbf0eb9a..2d5d500e275c 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.c +++ b/sys/netpfil/ipfw/dn_aqm_pie.c @@ -542,11 +542,11 @@ aqm_pie_enqueue(struct dn_queue *q, struct mbuf* m) mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); t = DROP; + } else { + *(aqm_time_t *)(mtag + 1) = AQM_UNOW; + m_tag_prepend(m, mtag); } - *(aqm_time_t *)(mtag + 1) = AQM_UNOW; - m_tag_prepend(m, mtag); } if (t != DROP) { diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.c b/sys/netpfil/ipfw/dn_sched_fq_codel.c index 5580dd91bbfe..bc61be867d36 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.c +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.c @@ -189,10 +189,8 @@ codel_enqueue(struct fq_codel_flow *q, struct mbuf *m, struct fq_codel_si *si) if (mtag == NULL) mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); - if (mtag == NULL) { - m_freem(m); + if (mtag == NULL) goto drop; - } *(aqm_time_t *)(mtag + 1) = AQM_UNOW; m_tag_prepend(m, mtag); diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 257dada44345..809ca2b5f4e8 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -734,11 +734,11 @@ pie_enqueue(struct fq_pie_flow *q, struct mbuf* m, struct fq_pie_si *si) mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); t = DROP; + } else { + *(aqm_time_t *)(mtag + 1) = AQM_UNOW; + m_tag_prepend(m, mtag); } - *(aqm_time_t *)(mtag + 1) = AQM_UNOW; - m_tag_prepend(m, mtag); } if (t != DROP) { From owner-dev-commits-src-main@freebsd.org Tue May 18 19:43:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A20236559E2; Tue, 18 May 2021 19:43: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 4Fl5zB3RMRz4jqb; Tue, 18 May 2021 19:43: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 5E09125448; Tue, 18 May 2021 19:43: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 14IJho3L051266; Tue, 18 May 2021 19:43:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IJho7p051265; Tue, 18 May 2021 19:43:50 GMT (envelope-from git) Date: Tue, 18 May 2021 19:43:50 GMT Message-Id: <202105181943.14IJho7p051265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b295c5ddcef4 - main - socket: Release cred reference later in sodealloc() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b295c5ddcef4744ef7044d2327b4258b6ad055f0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 19:43:50 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b295c5ddcef4744ef7044d2327b4258b6ad055f0 commit b295c5ddcef4744ef7044d2327b4258b6ad055f0 Author: Lv Yunlong AuthorDate: 2021-05-18 19:23:15 +0000 Commit: Mark Johnston CommitDate: 2021-05-18 19:25:40 +0000 socket: Release cred reference later in sodealloc() We dereference so->so_cred to update the per-uid socket buffer accounting, so the crfree() call must be deferred until after that point. PR: 255869 MFC after: 1 week --- sys/kern/uipc_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index ea86f66556ea..2a167eb68a22 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -476,7 +476,6 @@ sodealloc(struct socket *so) #endif hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE); - crfree(so->so_cred); khelp_destroy_osd(&so->osd); if (SOLISTENING(so)) { if (so->sol_accept_filter != NULL) @@ -493,6 +492,7 @@ sodealloc(struct socket *so) SOCKBUF_LOCK_DESTROY(&so->so_snd); SOCKBUF_LOCK_DESTROY(&so->so_rcv); } + crfree(so->so_cred); mtx_destroy(&so->so_lock); uma_zfree(socket_zone, so); } From owner-dev-commits-src-main@freebsd.org Tue May 18 20:19:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2F85656938; Tue, 18 May 2021 20:19: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 4Fl6mb5XmBz4rlb; Tue, 18 May 2021 20:19: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 A5AA025C1F; Tue, 18 May 2021 20:19: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 14IKJh5J091858; Tue, 18 May 2021 20:19:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IKJhY6091857; Tue, 18 May 2021 20:19:43 GMT (envelope-from git) Date: Tue, 18 May 2021 20:19:43 GMT Message-Id: <202105182019.14IKJhY6091857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 7fd8baee756e - main - test/libalias: Tests for instantiation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fd8baee756efa18b6bbb17cbf3a652eb2058d87 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 20:19:43 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=7fd8baee756efa18b6bbb17cbf3a652eb2058d87 commit 7fd8baee756efa18b6bbb17cbf3a652eb2058d87 Author: Lutz Donnerhacke AuthorDate: 2021-05-16 21:37:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-18 20:15:39 +0000 test/libalias: Tests for instantiation In order to modify libalias for performance, the existing functionality must not change. Enforce this. Reviewed by: kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30307 --- tests/sys/netinet/Makefile | 2 + tests/sys/netinet/libalias/1_instance.c | 95 +++++++++++++++++++++++++++++++++ tests/sys/netinet/libalias/Makefile | 26 +++++++++ 3 files changed, 123 insertions(+) diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index 56a1cf877135..ec2e6e679c18 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -5,6 +5,8 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netinet BINDIR= ${TESTSDIR} +TESTS_SUBDIRS+= libalias + ATF_TESTS_C= ip_reass_test \ so_reuseport_lb_test \ socket_afinet \ diff --git a/tests/sys/netinet/libalias/1_instance.c b/tests/sys/netinet/libalias/1_instance.c new file mode 100644 index 000000000000..e9137eb99d50 --- /dev/null +++ b/tests/sys/netinet/libalias/1_instance.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include + +static int randcmp(const void *a, const void *b) { + int res, r = rand(); + + (void)a; + (void)b; + res = (r/4 < RAND_MAX/9) ? 1 + : (r/5 < RAND_MAX/9) ? 0 + : -1; + return (res); +} + +ATF_TC(2_destroynull); +ATF_TC_HEAD(2_destroynull, env) +{ + atf_tc_set_md_var(env, "descr", "Destroy the NULL instance"); +} +ATF_TC_BODY(2_destroynull, dummy) +{ + atf_tc_expect_death("Code expects valid pointer."); + LibAliasUninit(NULL); +} + +ATF_TC(1_singleinit); +ATF_TC_HEAD(1_singleinit, env) +{ + atf_tc_set_md_var(env, "descr", "Create an instance"); +} +ATF_TC_BODY(1_singleinit, dummy) +{ + struct libalias *la; + + la = LibAliasInit(NULL); + ATF_CHECK_MSG(la != NULL, "Creating an instance failed."); + LibAliasUninit(la); +} + +ATF_TC(3_multiinit); +ATF_TC_HEAD(3_multiinit, env) +{ + atf_tc_set_md_var(env, "descr", "Recreate an instance multiple times"); +} +ATF_TC_BODY(3_multiinit, dummy) +{ + struct libalias *la; + int i; + + la = LibAliasInit(NULL); + for(i = 1; i < 30; i++) { + struct libalias *lo = la; + + la = LibAliasInit(la); + ATF_CHECK_MSG(la == lo, "Recreating moved the instance around: %d", i); + } + LibAliasUninit(la); +} + +ATF_TC(4_multiinstance); +ATF_TC_HEAD(4_multiinstance, env) +{ + atf_tc_set_md_var(env, "descr", "Create and destoy multiple instances."); +} +ATF_TC_BODY(4_multiinstance, dummy) +{ + struct libalias *la[300]; + int const num_instances = sizeof(la) / sizeof(*la); + int i; + + for (i = 0; i < num_instances; i++) { + la[i] = LibAliasInit(NULL); + ATF_CHECK_MSG(la[i] != NULL, "Creating instance %d failed.", i); + } + + qsort(la, num_instances, sizeof(*la), randcmp); + + for (i = 0; i < num_instances; i++) + LibAliasUninit(la[i]); +} + +ATF_TP_ADD_TCS(instance) +{ + /* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */ + srand(0x5ac4); + + ATF_TP_ADD_TC(instance, 2_destroynull); + ATF_TP_ADD_TC(instance, 1_singleinit); + ATF_TP_ADD_TC(instance, 3_multiinit); + ATF_TP_ADD_TC(instance, 4_multiinstance); + + return atf_no_error(); +} diff --git a/tests/sys/netinet/libalias/Makefile b/tests/sys/netinet/libalias/Makefile new file mode 100644 index 000000000000..3b2a3b144298 --- /dev/null +++ b/tests/sys/netinet/libalias/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +.include + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/netinet/libalias +BINDIR= ${TESTSDIR} + +ATF_TESTS_C+= 1_instance + +LIBADD+= alias + +.include + +# +# Testing during development +# +test: all + cd ${.OBJDIR}; kyua test + +report: + cd ${.OBJDIR}; kyua report + +report-v: + cd ${.OBJDIR}; kyua report --verbose From owner-dev-commits-src-main@freebsd.org Tue May 18 20:39:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16A00657304; Tue, 18 May 2021 20:39: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 4Fl7Cg09RXz3Cbl; Tue, 18 May 2021 20:39: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 E2DA8260B6; Tue, 18 May 2021 20:39: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 14IKdgtV018597; Tue, 18 May 2021 20:39:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IKdgpv018596; Tue, 18 May 2021 20:39:42 GMT (envelope-from git) Date: Tue, 18 May 2021 20:39:42 GMT Message-Id: <202105182039.14IKdgpv018596@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 63b6a08ce246 - main - ng_parse: IP address parsing in netgraph eating too many characters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 63b6a08ce2467b8e230e7a4ecb3e1ddf1b48851c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 20:39:43 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=63b6a08ce2467b8e230e7a4ecb3e1ddf1b48851c commit 63b6a08ce2467b8e230e7a4ecb3e1ddf1b48851c Author: Markus Stoff AuthorDate: 2021-05-18 20:35:33 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-18 20:36:28 +0000 ng_parse: IP address parsing in netgraph eating too many characters Once the final component of the IP address has been parsed, the offset on the input must not be advanced, as this would remove an unparsed character from the input. Submitted by: Markus Stoff Reviewed by: donner MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D26489 --- sys/netgraph/ng_parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c index 8050edbba562..c3c2126bdef5 100644 --- a/sys/netgraph/ng_parse.c +++ b/sys/netgraph/ng_parse.c @@ -960,9 +960,11 @@ ng_ipaddr_parse(const struct ng_parse_type *type, if ((error = ng_int8_parse(&ng_parse_int8_type, s, off, start, buf + i, buflen)) != 0) return (error); - if (i < 3 && s[*off] != '.') - return (EINVAL); - (*off)++; + if (i < 3) { + if (s[*off] != '.') + return (EINVAL); + (*off)++; + } } *buflen = 4; return (0); From owner-dev-commits-src-main@freebsd.org Tue May 18 21:01:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4A626579F8; Tue, 18 May 2021 21:01: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 4Fl7hX4CvTz3JQL; Tue, 18 May 2021 21:01: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 7A39C2678E; Tue, 18 May 2021 21:01: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 14IL1GxA054230; Tue, 18 May 2021 21:01:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IL1Gki054229; Tue, 18 May 2021 21:01:16 GMT (envelope-from git) Date: Tue, 18 May 2021 21:01:16 GMT Message-Id: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3d846e48227e2e78c1e7b35145f57353ffda56ba Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 21:01:16 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=3d846e48227e2e78c1e7b35145f57353ffda56ba commit 3d846e48227e2e78c1e7b35145f57353ffda56ba Author: Zhenlei Huang AuthorDate: 2021-05-18 20:51:37 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-18 20:59:46 +0000 Do not forward datagrams originated by link-local addresses The current implement of ip_input() reject packets destined for 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local addresses. Fix to fully respect RFC 3927 section 2.7. PR: 255388 Reviewed by: donner, rgrimes, karels MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D29968 --- sys/netinet/ip_input.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 43d375c2385f..1139e3a5abfa 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -738,15 +738,10 @@ passin: } ia = NULL; } - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { - IPSTAT_INC(ips_cantforward); - m_freem(m); - return; - } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { MROUTER_RLOCK(); - if (V_ip_mrouter) { + /* Do not forward packets from IN_LINKLOCAL. */ + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all * incoming multicast packets are passed to the @@ -785,6 +780,13 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; + /* Do not forward packets to or from IN_LINKLOCAL. */ + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { + IPSTAT_INC(ips_cantforward); + m_freem(m); + return; + } /* * Not for us; forward if possible and desirable. From owner-dev-commits-src-main@freebsd.org Tue May 18 22:57:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF4F263176F; Tue, 18 May 2021 22:57: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 4FlBG45wNkz4hFw; Tue, 18 May 2021 22:57: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 B3C0D27CB1; Tue, 18 May 2021 22:57: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 14IMv0AI005858; Tue, 18 May 2021 22:57:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14IMv0tl005857; Tue, 18 May 2021 22:57:00 GMT (envelope-from git) Date: Tue, 18 May 2021 22:57:00 GMT Message-Id: <202105182257.14IMv0tl005857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: b3d4c70dc60f - main - nfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b3d4c70dc60f1913f2363751b905b562c39ca126 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 22:57:00 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b3d4c70dc60f1913f2363751b905b562c39ca126 commit b3d4c70dc60f1913f2363751b905b562c39ca126 Author: Rick Macklem AuthorDate: 2021-05-18 22:53:54 +0000 Commit: Rick Macklem CommitDate: 2021-05-18 22:53:54 +0000 nfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open The Linux NFSv4.1/4.2 client now uses the CLAIM_DELEG_CUR_FH variant of the Open operation when delegations are recalled and the client has a local open of the file. This patch adds support for this variant of Open to the NFSv4.1/4.2 server. This patch only affects mounts from Linux clients when delegations are enabled on the server. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdserv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 8aa39e5018d9..5d6cac23b722 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -2981,7 +2981,8 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, */ NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); claim = fxdr_unsigned(int, *tl); - if (claim == NFSV4OPEN_CLAIMDELEGATECUR) { + if (claim == NFSV4OPEN_CLAIMDELEGATECUR || claim == + NFSV4OPEN_CLAIMDELEGATECURFH) { NFSM_DISSECT(tl, u_int32_t *, NFSX_STATEID); stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); NFSBCOPY((caddr_t)tl,(caddr_t)stateid.other,NFSX_STATEIDOTHER); @@ -3056,7 +3057,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, &exclusive_flag, &nva, cverf, create, aclp, &attrbits, nd->nd_cred, exp, &vp); } else if (claim == NFSV4OPEN_CLAIMPREVIOUS || claim == - NFSV4OPEN_CLAIMFH) { + NFSV4OPEN_CLAIMFH || claim == NFSV4OPEN_CLAIMDELEGATECURFH) { if (claim == NFSV4OPEN_CLAIMPREVIOUS) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); @@ -3074,7 +3075,6 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, } stp->ls_flags |= NFSLCK_RECLAIM; } else { - /* CLAIM_NULL_FH */ if (nd->nd_repstat == 0 && create == NFSV4OPEN_CREATE) nd->nd_repstat = NFSERR_INVAL; } From owner-dev-commits-src-main@freebsd.org Tue May 18 23:21:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07E7D6320A2; Tue, 18 May 2021 23:21: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 4FlBnl6gyPz4ncN; Tue, 18 May 2021 23:20: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 CC9EC27B76; Tue, 18 May 2021 23:20: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 14INKxrI043427; Tue, 18 May 2021 23:20:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14INKx5Z043426; Tue, 18 May 2021 23:20:59 GMT (envelope-from git) Date: Tue, 18 May 2021 23:20:59 GMT Message-Id: <202105182320.14INKx5Z043426@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: fc0dc94029df - main - nfsd: Reduce the callback timeout to 800msec MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc0dc94029df8150301b925bda690b20d9d0bcbf Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 23:21:00 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fc0dc94029df8150301b925bda690b20d9d0bcbf commit fc0dc94029df8150301b925bda690b20d9d0bcbf Author: Rick Macklem AuthorDate: 2021-05-18 23:17:58 +0000 Commit: Rick Macklem CommitDate: 2021-05-18 23:17:58 +0000 nfsd: Reduce the callback timeout to 800msec Recent discussion on the nfsv4@ietf.org mailing list confirmed that an NFSv4 server should reply to an RPC in less than 1second. If an NFSv4 RPC requires a delegation be recalled, the server will attempt a CB_RECALL callback. If the client is not responsive, the RPC reply will be delayed until the callback times out. Without this patch, the timeout is set to 4 seconds (set in ticks, but used as seconds), resulting in the RPC reply taking over 4sec. This patch redefines the constant as being in milliseconds and it implements that for a value of 800msec, to ensure the RPC reply is sent in less than 1second. This patch only affects mounts from clients when delegations are enabled on the server and the client is unresponsive to callbacks. MFC after: 2 weeks --- sys/fs/nfs/nfs.h | 2 +- sys/fs/nfs/nfs_commonkrpc.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/fs/nfs/nfs.h b/sys/fs/nfs/nfs.h index 44b6042a2ce7..272b8dbfee22 100644 --- a/sys/fs/nfs/nfs.h +++ b/sys/fs/nfs/nfs.h @@ -50,7 +50,7 @@ #define NFS_MAXRCVTIMEO 60 /* 1 minute in seconds */ #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ #define NFS_MAXREXMIT 100 /* Stop counting after this many */ -#define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */ +#define NFSV4_CALLBACKTIMEO 800 /* Timeout in msec */ #define NFSV4_CALLBACKRETRY 5 /* Number of retries before failure */ #define NFSV4_SLOTS 64 /* Number of slots, fore channel */ #define NFSV4_CBSLOTS 8 /* Number of slots, back channel */ diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 49c68da45a69..04ef04955ce0 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -767,11 +767,13 @@ tryagain: * use the same xid. */ if (nmp == NULL) { - timo.tv_usec = 0; - if (clp == NULL) + if (clp == NULL) { timo.tv_sec = NFSV4_UPCALLTIMEO; - else - timo.tv_sec = NFSV4_CALLBACKTIMEO; + timo.tv_usec = 0; + } else { + timo.tv_sec = NFSV4_CALLBACKTIMEO / 1000; + timo.tv_usec = NFSV4_CALLBACKTIMEO * 1000; + } } else { if (nrp->nr_sotype != SOCK_DGRAM) { timo.tv_usec = 0; From owner-dev-commits-src-main@freebsd.org Tue May 18 23:51:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09DF663269F; Tue, 18 May 2021 23:51:52 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [IPv6:2607:fc50:1:f300::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "*.marcuscom.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlCTM6ldJz4vhW; Tue, 18 May 2021 23:51:51 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from smtpclient.apple ([IPv6:2600:1700:b00:b239:9484:26f7:8d5:dda3]) (authenticated bits=0) by creme-brulee.marcuscom.com (8.16.1/8.16.1) with ESMTPSA id 14INphr6060204 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 18 May 2021 19:51:44 -0400 (EDT) (envelope-from jclarke@marcuscom.com) X-Authentication-Warning: creme-brulee.marcuscom.com: Host [IPv6:2600:1700:b00:b239:9484:26f7:8d5:dda3] claimed to be smtpclient.apple Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joe Clarke Mime-Version: 1.0 (1.0) Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses Date: Tue, 18 May 2021 19:51:38 -0400 Message-Id: References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org In-Reply-To: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> To: Lutz Donnerhacke X-Mailer: iPhone Mail (18E212) X-Spam-Status: No, score=2.5 required=5.0 tests=RDNS_NONE autolearn=disabled version=3.4.5 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on creme-brulee.marcuscom.com X-Rspamd-Queue-Id: 4FlCTM6ldJz4vhW 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 23:51:52 -0000 Just out of curiosity, why remove the RFC reference from the comment? Seems= useful for those that want to know why this is a good practice. Joe PGP Key : https://www.marcuscom.com/pgp.asc > On May 18, 2021, at 17:01, Lutz Donnerhacke wrote: >=20 > =EF=BB=BFThe branch main has been updated by donner: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D3d846e48227e2e78c1e7b35145f= 57353ffda56ba >=20 > commit 3d846e48227e2e78c1e7b35145f57353ffda56ba > Author: Zhenlei Huang > AuthorDate: 2021-05-18 20:51:37 +0000 > Commit: Lutz Donnerhacke > CommitDate: 2021-05-18 20:59:46 +0000 >=20 > Do not forward datagrams originated by link-local addresses >=20 > The current implement of ip_input() reject packets destined for > 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local > addresses. >=20 > Fix to fully respect RFC 3927 section 2.7. >=20 > PR: 255388 > Reviewed by: donner, rgrimes, karels > MFC after: 1 month > Differential Revision: https://reviews.freebsd.org/D29968 > --- > sys/netinet/ip_input.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) >=20 > diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c > index 43d375c2385f..1139e3a5abfa 100644 > --- a/sys/netinet/ip_input.c > +++ b/sys/netinet/ip_input.c > @@ -738,15 +738,10 @@ passin: > } > ia =3D NULL; > } > - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ > - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { > - IPSTAT_INC(ips_cantforward); > - m_freem(m); > - return; > - } > if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > MROUTER_RLOCK(); > - if (V_ip_mrouter) { > + /* Do not forward packets from IN_LINKLOCAL. */ > + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { > /* > * If we are acting as a multicast router, all > * incoming multicast packets are passed to the > @@ -785,6 +780,13 @@ passin: > goto ours; > if (ip->ip_dst.s_addr =3D=3D INADDR_ANY) > goto ours; > + /* Do not forward packets to or from IN_LINKLOCAL. */ > + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || > + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { > + IPSTAT_INC(ips_cantforward); > + m_freem(m); > + return; > + } >=20 > /* > * Not for us; forward if possible and desirable. > _______________________________________________ > dev-commits-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebsd.= org" From owner-dev-commits-src-main@freebsd.org Wed May 19 01:04:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C20AF63362C; Wed, 19 May 2021 01:04:31 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlF5C4Bcvz3GlQ; Wed, 19 May 2021 01:04:31 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 14J14RpI001048; Tue, 18 May 2021 18:04:27 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 14J14Rh6001047; Tue, 18 May 2021 18:04:27 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202105190104.14J14Rh6001047@gndrsh.dnsmgr.net> Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses In-Reply-To: To: Joe Clarke Date: Tue, 18 May 2021 18:04:27 -0700 (PDT) CC: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4FlF5C4Bcvz3GlQ 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 01:04:31 -0000 > Just out of curiosity, why remove the RFC reference from the comment? Seems useful for those that want to know why this is a good practice. RFC's are not immutable and more often that not an RFC comment is out dated in the src. As an example, network "10/8", original RFC 1627, obsoleted by 1918, but the ietf tracker doesnt tell you that this was covered in RFC5735, obsoleted by 6890, updated by 8190 (the 169.254.0.0/16 block is covered in 6890 with no changes to that part by 8190....) SOOOO.. RFC references are very hard to keep upto date and correct. > > Joe > > PGP Key : https://www.marcuscom.com/pgp.asc > > > On May 18, 2021, at 17:01, Lutz Donnerhacke wrote: > > > > ?The branch main has been updated by donner: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3d846e48227e2e78c1e7b35145f57353ffda56ba > > > > commit 3d846e48227e2e78c1e7b35145f57353ffda56ba > > Author: Zhenlei Huang > > AuthorDate: 2021-05-18 20:51:37 +0000 > > Commit: Lutz Donnerhacke > > CommitDate: 2021-05-18 20:59:46 +0000 > > > > Do not forward datagrams originated by link-local addresses > > > > The current implement of ip_input() reject packets destined for > > 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local > > addresses. > > > > Fix to fully respect RFC 3927 section 2.7. > > > > PR: 255388 > > Reviewed by: donner, rgrimes, karels > > MFC after: 1 month > > Differential Revision: https://reviews.freebsd.org/D29968 > > --- > > sys/netinet/ip_input.c | 16 +++++++++------- > > 1 file changed, 9 insertions(+), 7 deletions(-) > > > > diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c > > index 43d375c2385f..1139e3a5abfa 100644 > > --- a/sys/netinet/ip_input.c > > +++ b/sys/netinet/ip_input.c > > @@ -738,15 +738,10 @@ passin: > > } > > ia = NULL; > > } > > - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ > > - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { > > - IPSTAT_INC(ips_cantforward); > > - m_freem(m); > > - return; > > - } > > if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > > MROUTER_RLOCK(); > > - if (V_ip_mrouter) { > > + /* Do not forward packets from IN_LINKLOCAL. */ > > + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { > > /* > > * If we are acting as a multicast router, all > > * incoming multicast packets are passed to the > > @@ -785,6 +780,13 @@ passin: > > goto ours; > > if (ip->ip_dst.s_addr == INADDR_ANY) > > goto ours; > > + /* Do not forward packets to or from IN_LINKLOCAL. */ > > + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || > > + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { > > + IPSTAT_INC(ips_cantforward); > > + m_freem(m); > > + return; > > + } > > > > /* > > * Not for us; forward if possible and desirable. > > _______________________________________________ > > dev-commits-src-all@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > > To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebsd.org" > > > -- Rod Grimes rgrimes@freebsd.org From owner-dev-commits-src-main@freebsd.org Wed May 19 01:57:21 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D691C634AD0; Wed, 19 May 2021 01:57:21 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [IPv6:2607:fc50:1:f300::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "*.marcuscom.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlGG95bsTz3l5y; Wed, 19 May 2021 01:57:21 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from smtpclient.apple ([IPv6:2600:1700:b00:b239:9484:26f7:8d5:dda3]) (authenticated bits=0) by creme-brulee.marcuscom.com (8.16.1/8.16.1) with ESMTPSA id 14J1vJYP000896 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 18 May 2021 21:57:19 -0400 (EDT) (envelope-from jclarke@marcuscom.com) X-Authentication-Warning: creme-brulee.marcuscom.com: Host [IPv6:2600:1700:b00:b239:9484:26f7:8d5:dda3] claimed to be smtpclient.apple Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joe Clarke Mime-Version: 1.0 (1.0) Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses Date: Tue, 18 May 2021 21:57:14 -0400 Message-Id: <79D18D6B-EDD7-4FB4-B3C6-7755A3B9F5F3@marcuscom.com> References: <202105190104.14J14Rh6001047@gndrsh.dnsmgr.net> Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org In-Reply-To: <202105190104.14J14Rh6001047@gndrsh.dnsmgr.net> To: rgrimes@freebsd.org X-Mailer: iPhone Mail (18E212) X-Spam-Status: No, score=2.5 required=5.0 tests=RDNS_NONE autolearn=disabled version=3.4.5 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on creme-brulee.marcuscom.com X-Rspamd-Queue-Id: 4FlGG95bsTz3l5y 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 01:57:21 -0000 To be fair, an obsolete RFC can be followed to the current document. Having= an anchor, even one that is obsolete, has value as a reference. Joe PGP Key : https://www.marcuscom.com/pgp.asc > On May 18, 2021, at 21:04, Rodney W. Grimes wr= ote: >=20 > =EF=BB=BF >>=20 >> Just out of curiosity, why remove the RFC reference from the comment? Se= ems useful for those that want to know why this is a good practice. >=20 > RFC's are not immutable and more often that not an RFC comment > is out dated in the src. >=20 > As an example, network "10/8", original RFC 1627, obsoleted by 1918, > but the ietf tracker doesnt tell you that this was covered > in RFC5735, obsoleted by 6890, updated by 8190 > (the 169.254.0.0/16 block is covered in 6890 with no changes to that > part by 8190....) >=20 > SOOOO.. RFC references are very hard to keep upto date and correct. >=20 >>=20 >> Joe >>=20 >> PGP Key : https://www.marcuscom.com/pgp.asc >>=20 >>>> On May 18, 2021, at 17:01, Lutz Donnerhacke wrote:= >>>=20 >>> ?The branch main has been updated by donner: >>>=20 >>> URL: https://cgit.FreeBSD.org/src/commit/?id=3D3d846e48227e2e78c1e7b3514= 5f57353ffda56ba >>>=20 >>> commit 3d846e48227e2e78c1e7b35145f57353ffda56ba >>> Author: Zhenlei Huang >>> AuthorDate: 2021-05-18 20:51:37 +0000 >>> Commit: Lutz Donnerhacke >>> CommitDate: 2021-05-18 20:59:46 +0000 >>>=20 >>> Do not forward datagrams originated by link-local addresses >>>=20 >>> The current implement of ip_input() reject packets destined for >>> 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local >>> addresses. >>>=20 >>> Fix to fully respect RFC 3927 section 2.7. >>>=20 >>> PR: 255388 >>> Reviewed by: donner, rgrimes, karels >>> MFC after: 1 month >>> Differential Revision: https://reviews.freebsd.org/D29968 >>> --- >>> sys/netinet/ip_input.c | 16 +++++++++------- >>> 1 file changed, 9 insertions(+), 7 deletions(-) >>>=20 >>> diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c >>> index 43d375c2385f..1139e3a5abfa 100644 >>> --- a/sys/netinet/ip_input.c >>> +++ b/sys/netinet/ip_input.c >>> @@ -738,15 +738,10 @@ passin: >>> } >>> ia =3D NULL; >>> } >>> - /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ >>> - if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { >>> - IPSTAT_INC(ips_cantforward); >>> - m_freem(m); >>> - return; >>> - } >>> if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >>> MROUTER_RLOCK(); >>> - if (V_ip_mrouter) { >>> + /* Do not forward packets from IN_LINKLOCAL. */ >>> + if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { >>> /* >>> * If we are acting as a multicast router, all >>> * incoming multicast packets are passed to the >>> @@ -785,6 +780,13 @@ passin: >>> goto ours; >>> if (ip->ip_dst.s_addr =3D=3D INADDR_ANY) >>> goto ours; >>> + /* Do not forward packets to or from IN_LINKLOCAL. */ >>> + if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || >>> + IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { >>> + IPSTAT_INC(ips_cantforward); >>> + m_freem(m); >>> + return; >>> + } >>>=20 >>> /* >>> * Not for us; forward if possible and desirable. >>> _______________________________________________ >>> dev-commits-src-all@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all >>> To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebs= d.org" >>=20 >>=20 >>=20 >=20 > --=20 > Rod Grimes rgrimes@freebsd= .org > _______________________________________________ > dev-commits-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebsd.= org" From owner-dev-commits-src-main@freebsd.org Wed May 19 05:54:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCCF9638248; Wed, 19 May 2021 05:54:20 +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 4FlMWc4MbJz4Tj2; Wed, 19 May 2021 05:54:20 +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 14J5s7Av030977 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 19 May 2021 07:54:07 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14J5s77T009919; Wed, 19 May 2021 07:54:07 +0200 Date: Wed, 19 May 2021 07:54:07 +0200 From: Lutz Donnerhacke To: Joe Clarke , Zhenlei Huang Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses Message-ID: <20210519055407.GA9715@belenus.iks-jena.de> References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4FlMWc4MbJz4Tj2 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 05:54:20 -0000 On Tue, May 18, 2021 at 07:51:38PM -0400, Joe Clarke wrote: > Just out of curiosity, why remove the RFC reference from the comment? May you please include the author of the change for such questions? > > commit 3d846e48227e2e78c1e7b35145f57353ffda56ba > > Author: Zhenlei Huang > > AuthorDate: 2021-05-18 20:51:37 +0000 > > Commit: Lutz Donnerhacke > > CommitDate: 2021-05-18 20:59:46 +0000 > > > > The current implement of ip_input() reject packets destined for > > 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local > > addresses. > > > > Fix to fully respect RFC 3927 section 2.7. > > > > PR: 255388 > > Reviewed by: donner, rgrimes, karels > > MFC after: 1 month > > Differential Revision: https://reviews.freebsd.org/D29968 I did only commit this differential, but set a month for MFC, exactly to have to opportunity to fix such mistakes. From owner-dev-commits-src-main@freebsd.org Wed May 19 06:19:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C98E2638E89; Wed, 19 May 2021 06:19:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlN4F5J6Nz4bTr; Wed, 19 May 2021 06:19: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 9A2B25AD5; Wed, 19 May 2021 06:19: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 14J6J9lQ090211; Wed, 19 May 2021 06:19:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14J6J9a2090210; Wed, 19 May 2021 06:19:09 GMT (envelope-from git) Date: Wed, 19 May 2021 06:19:09 GMT Message-Id: <202105190619.14J6J9a2090210@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: 3965469eaa33 - main - cxgbe(4): Remove some dead code. 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/main X-Git-Reftype: branch X-Git-Commit: 3965469eaa33aca03837baf5f88a55fa89f3f987 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 06:19:09 -0000 The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=3965469eaa33aca03837baf5f88a55fa89f3f987 commit 3965469eaa33aca03837baf5f88a55fa89f3f987 Author: Navdeep Parhar AuthorDate: 2021-05-19 06:16:03 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-19 06:16:03 +0000 cxgbe(4): Remove some dead code. MFC after: 3 days --- sys/dev/cxgbe/adapter.h | 10 ---------- sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index cce58f9729c1..b3b214ce3c96 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -68,16 +68,6 @@ MALLOC_DECLARE(M_CXGBE); #define CXGBE_UNIMPLEMENTED(s) \ panic("%s (%s, line %d) not implemented yet.", s, __FILE__, __LINE__) -#if defined(__i386__) || defined(__amd64__) -static __inline void -prefetch(void *x) -{ - __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); -} -#else -#define prefetch(x) __builtin_prefetch(x) -#endif - #ifndef SYSCTL_ADD_UQUAD #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD #define sysctl_handle_64 sysctl_handle_quad diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h index aa94a40add1e..689eb0644893 100644 --- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h +++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h @@ -56,8 +56,6 @@ #include #include -#undef prefetch - #include "common/common.h" #include "common/t4_msg.h" #include "common/t4_regs.h" From owner-dev-commits-src-main@freebsd.org Wed May 19 06:22:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8AB85638C4E; Wed, 19 May 2021 06:22: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 4FlN8d3QPFz4cxR; Wed, 19 May 2021 06:22: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 5C2FD5CDF; Wed, 19 May 2021 06:22: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 14J6Mv4T003018; Wed, 19 May 2021 06:22:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14J6MvkW003017; Wed, 19 May 2021 06:22:57 GMT (envelope-from git) Date: Wed, 19 May 2021 06:22:57 GMT Message-Id: <202105190622.14J6MvkW003017@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 7de0aa01350e - main - stress2: Added a new "mdconfig -o force" test scenario MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7de0aa01350eba647de862542a40f426e970a796 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 06:22:57 -0000 The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=7de0aa01350eba647de862542a40f426e970a796 commit 7de0aa01350eba647de862542a40f426e970a796 Author: Peter Holm AuthorDate: 2021-05-19 06:22:09 +0000 Commit: Peter Holm CommitDate: 2021-05-19 06:22:09 +0000 stress2: Added a new "mdconfig -o force" test scenario --- tools/test/stress2/misc/force7.sh | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tools/test/stress2/misc/force7.sh b/tools/test/stress2/misc/force7.sh new file mode 100755 index 000000000000..9eef1936cb98 --- /dev/null +++ b/tools/test/stress2/misc/force7.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2020 Peter Holm +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# "mdconfig -o force" test scenario. +# fsck_ffs core dump seen + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +. ../default.cfg + +log=/tmp/force7.sh.log +mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart +truncate -s 1g $diskimage +mdconfig -a -t vnode -f $diskimage -s 1g -u $mdstart +flags=$newfs_flags +echo "newfs $flags md$mdstart" +newfs $flags md$mdstart > /dev/null 2>&1 + +export TESTPROGS=`cd ..; find testcases/ -perm -1 -type f | \ + egrep -Ev "/run/|/badcode/|/pty/|/shm/|/socket/|sysctl|tcp|thr|udp"` +export runRUNTIME=3m +export RUNDIR=$mntpoint/stressX +start=`date +%s` +while [ $((`date +%s` - start)) -lt 300 ]; do + mount /dev/md$mdstart $mntpoint + rm -fr $mntpoint/lost+found + chmod 777 $mntpoint + + su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \ + /dev/null 2>&1 & + + sleep `jot -r 1 5 9` + while mdconfig -l | grep -q md$mdstart; do + mdconfig -d -u $mdstart -o force || sleep 1 + done + sleep 1 + ../tools/killall.sh + wait + n=0 + while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 + [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } + done + mdconfig -a -t vnode -f $diskimage -s 1g -u $mdstart + fsck_ffs -fyR /dev/md$mdstart > $log 2>&1; s=$? + [ $s -ne 0 ] && break +done +[ $s -eq 0 ] && rm -f $diskimage $log || cat $log +exit $s From owner-dev-commits-src-main@freebsd.org Wed May 19 12:14:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9DD80640442; Wed, 19 May 2021 12:14: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 4FlWy243TPz3LW0; Wed, 19 May 2021 12:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 73D2112859; Wed, 19 May 2021 12:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14JCEIJi068727; Wed, 19 May 2021 12:14:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JCEI4m068726; Wed, 19 May 2021 12:14:18 GMT (envelope-from git) Date: Wed, 19 May 2021 12:14:18 GMT Message-Id: <202105191214.14JCEI4m068726@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: f0a5e81af436 - main - arm64: rockchip, implement the two rk805/808 clocks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f0a5e81af4361abfc09ccaefbc375ece35ff79cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 12:14:18 -0000 The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f0a5e81af4361abfc09ccaefbc375ece35ff79cc commit f0a5e81af4361abfc09ccaefbc375ece35ff79cc Author: Bjoern A. Zeeb AuthorDate: 2021-05-06 14:25:52 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-05-19 11:48:11 +0000 arm64: rockchip, implement the two rk805/808 clocks While the xin32k clk was implemented in rk3399_cru as a fixed rate clock, migrate it to rk805 as we will also need the 2nd clock 'rtc_clko_wifi' for SDIO and BT. Both clocks remain fixed rate, and while the 1st one is always on (though that is not expressed in the clk framework), the 2nd one we can toggle on/off. Reviewed-by: manu Tested-by: manu MFC-after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26870 --- sys/arm64/rockchip/clk/rk3399_cru.c | 2 +- sys/arm64/rockchip/rk805.c | 122 +++++++++++++++++++++++++++++++++++- 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/sys/arm64/rockchip/clk/rk3399_cru.c b/sys/arm64/rockchip/clk/rk3399_cru.c index 595085862e13..585f6d4c33b9 100644 --- a/sys/arm64/rockchip/clk/rk3399_cru.c +++ b/sys/arm64/rockchip/clk/rk3399_cru.c @@ -775,7 +775,7 @@ PLIST(uart3_p)= {"clk_uart3_div", "clk_uart3_frac", "xin24m"}; static struct rk_clk rk3399_clks[] = { /* External clocks */ LINK("xin24m"), - FRATE(0, "xin32k", 32768), + LINK("xin32k"), FFACT(0, "xin12m", "xin24m", 1, 2), FRATE(0, "clkin_i2s", 0), FRATE(0, "pclkin_cif", 0), diff --git a/sys/arm64/rockchip/rk805.c b/sys/arm64/rockchip/rk805.c index d3e04081aeb2..2d5635fee72a 100644 --- a/sys/arm64/rockchip/rk805.c +++ b/sys/arm64/rockchip/rk805.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -584,6 +585,118 @@ rk805_reg_attach(device_t dev, phandle_t node, return (reg_sc); } +/* -------------------------------------------------------------------------- */ + +/* Clock class and method */ +struct rk805_clk_sc { + device_t base_dev; +}; + +#define CLK32OUT_REG 0x20 +#define CLK32OUT_CLKOUT2_EN 1 + +static int +rk805_clk_set_gate_1(struct clknode *clk, bool enable) +{ + struct rk805_clk_sc *sc; + uint8_t val; + + sc = clknode_get_softc(clk); + + rk805_read(sc->base_dev, CLK32OUT_REG, &val, sizeof(val)); + if (enable) + val |= CLK32OUT_CLKOUT2_EN; + else + val &= ~CLK32OUT_CLKOUT2_EN; + rk805_write(sc->base_dev, CLK32OUT_REG, &val, 1); + + return (0); +} + +static int +rk805_clk_recalc(struct clknode *clk, uint64_t *freq) +{ + + *freq = 32768; + return (0); +} + +static clknode_method_t rk805_clk_clknode_methods_0[] = { + CLKNODEMETHOD(clknode_recalc_freq, rk805_clk_recalc), + CLKNODEMETHOD_END +}; + +DEFINE_CLASS_1(rk805_clk_clknode_0, rk805_clk_clknode_class_0, + rk805_clk_clknode_methods_0, sizeof(struct rk805_clk_sc), + clknode_class); + +static clknode_method_t rk805_clk_clknode_methods_1[] = { + CLKNODEMETHOD(clknode_set_gate, rk805_clk_set_gate_1), + CLKNODEMETHOD_END +}; + +DEFINE_CLASS_1(rk805_clk_clknode_1, rk805_clk_clknode_class_1, + rk805_clk_clknode_methods_1, sizeof(struct rk805_clk_sc), + rk805_clk_clknode_class_0); + +static int +rk805_export_clocks(device_t dev) +{ + struct clkdom *clkdom; + struct clknode_init_def clkidef; + struct clknode *clk; + struct rk805_clk_sc *clksc; + const char **clknames; + phandle_t node; + int nclks, rv; + + node = ofw_bus_get_node(dev); + + /* clock-output-names are optional. Could use them for clkidef.name. */ + nclks = ofw_bus_string_list_to_array(node, "clock-output-names", + &clknames); + + clkdom = clkdom_create(dev); + + memset(&clkidef, 0, sizeof(clkidef)); + clkidef.id = 0; + clkidef.name = (nclks = 2) ? clknames[0] : "clk32kout1"; + clk = clknode_create(clkdom, &rk805_clk_clknode_class_0, &clkidef); + if (clk == NULL) { + device_printf(dev, "Cannot create '%s'.\n", clkidef.name); + return (ENXIO); + } + clksc = clknode_get_softc(clk); + clksc->base_dev = dev; + clknode_register(clkdom, clk); + + memset(&clkidef, 0, sizeof(clkidef)); + clkidef.id = 1; + clkidef.name = (nclks = 2) ? clknames[1] : "clk32kout2"; + clk = clknode_create(clkdom, &rk805_clk_clknode_class_1, &clkidef); + if (clk == NULL) { + device_printf(dev, "Cannot create '%s'.\n", clkidef.name); + return (ENXIO); + } + clksc = clknode_get_softc(clk); + clksc->base_dev = dev; + clknode_register(clkdom, clk); + + rv = clkdom_finit(clkdom); + if (rv != 0) { + device_printf(dev, "Cannot finalize clkdom initialization: " + "%d\n", rv); + return (ENXIO); + } + + if (bootverbose) + clkdom_dump(clkdom); + + return (0); +} + +/* -------------------------------------------------------------------------- */ + static int rk805_probe(device_t dev) { @@ -745,17 +858,20 @@ rk805_attach(device_t dev) struct rk805_regdef *regdefs; struct reg_list *regp; phandle_t rnode, child; - int i; + int error, i; sc = device_get_softc(dev); + sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + error = rk805_export_clocks(dev); + if (error != 0) + return (error); + sc->intr_hook.ich_func = rk805_start; sc->intr_hook.ich_arg = dev; - if (config_intrhook_establish(&sc->intr_hook) != 0) return (ENOMEM); - sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; switch (sc->type) { case RK805: regdefs = rk805_regdefs; From owner-dev-commits-src-main@freebsd.org Wed May 19 13:09:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6BDDF641553; Wed, 19 May 2021 13:09: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 4FlY9P2YnRz4VF4; Wed, 19 May 2021 13:09: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 40FE91337E; Wed, 19 May 2021 13:09: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 14JD9DnP035425; Wed, 19 May 2021 13:09:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JD9DKq035424; Wed, 19 May 2021 13:09:13 GMT (envelope-from git) Date: Wed, 19 May 2021 13:09:13 GMT Message-Id: <202105191309.14JD9DKq035424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: f4b38c360e63 - main - rc.d: unbreak sysctl lastload MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f4b38c360e63a6e66245efedbd6c070f9c0aee55 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 13:09:13 -0000 The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=f4b38c360e63a6e66245efedbd6c070f9c0aee55 commit f4b38c360e63a6e66245efedbd6c070f9c0aee55 Author: Eugene Grosbein AuthorDate: 2021-05-19 13:02:31 +0000 Commit: Eugene Grosbein CommitDate: 2021-05-19 13:02:31 +0000 rc.d: unbreak sysctl lastload /etc/rc.d/securelevel is supposed to run /etc/rc.d/sysctl lastload late at boot time to apply /etc/sysctl.conf settings that fail to apply early. However, this does not work in default configuration because of kern_securelevel_enable="NO" by default. Add new script /etc/rc.d/sysctl lastload that starts unconditionally. Reported by: Marek Zarychta MFC after: 1 month --- libexec/rc/rc.d/securelevel | 6 +----- libexec/rc/rc.d/sysctl_lastload | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libexec/rc/rc.d/securelevel b/libexec/rc/rc.d/securelevel index 24dbf269df3f..8bb09dd920bd 100755 --- a/libexec/rc/rc.d/securelevel +++ b/libexec/rc/rc.d/securelevel @@ -4,7 +4,7 @@ # # PROVIDE: securelevel -# REQUIRE: adjkerntz ipfw pf +# REQUIRE: adjkerntz ipfw pf sysctl_lastload . /etc/rc.subr @@ -14,10 +14,6 @@ rcvar='kern_securelevel_enable' start_cmd="securelevel_start" stop_cmd=":" -# Last chance to set sysctl variables that failed the first time. -# -/etc/rc.d/sysctl lastload - securelevel_start() { if [ ${kern_securelevel} -ge 0 ]; then diff --git a/libexec/rc/rc.d/sysctl_lastload b/libexec/rc/rc.d/sysctl_lastload new file mode 100755 index 000000000000..22aafd96d051 --- /dev/null +++ b/libexec/rc/rc.d/sysctl_lastload @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: sysctl_lastload +# REQUIRE: LOGIN +# BEFORE: jail + +. /etc/rc.subr + +name="sysctl_lastload" +desc="Last chance to set sysctl variables that failed the first time." +start_cmd="/etc/rc.d/sysctl lastload" +stop_cmd=":" + +load_rc_config $name +run_rc_command "$1" From owner-dev-commits-src-main@freebsd.org Wed May 19 13:42:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE5F5642BEF; Wed, 19 May 2021 13:42:13 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [IPv6:2607:fc50:1:f300::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "*.marcuscom.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlYvT3WTVz4lv0; Wed, 19 May 2021 13:42:12 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from [10.116.79.227] ([173.38.117.71]) (authenticated bits=0) by creme-brulee.marcuscom.com (8.16.1/8.16.1) with ESMTPSA id 14JDg5Hp080695 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Wed, 19 May 2021 09:42:05 -0400 (EDT) (envelope-from jclarke@marcuscom.com) X-Authentication-Warning: creme-brulee.marcuscom.com: Host [173.38.117.71] claimed to be [10.116.79.227] Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses To: Lutz Donnerhacke , Zhenlei Huang Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> From: Joe Clarke Message-ID: <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> Date: Wed, 19 May 2021 09:42:00 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210519055407.GA9715@belenus.iks-jena.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.5 required=5.0 tests=NICE_REPLY_A,RDNS_NONE autolearn=disabled version=3.4.5 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on creme-brulee.marcuscom.com X-Rspamd-Queue-Id: 4FlYvT3WTVz4lv0 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 13:42:13 -0000 On 5/19/21 01:54, Lutz Donnerhacke wrote: > On Tue, May 18, 2021 at 07:51:38PM -0400, Joe Clarke wrote: >> Just out of curiosity, why remove the RFC reference from the comment? > > May you please include the author of the change for such questions? > >>> commit 3d846e48227e2e78c1e7b35145f57353ffda56ba >>> Author: Zhenlei Huang >>> AuthorDate: 2021-05-18 20:51:37 +0000 >>> Commit: Lutz Donnerhacke >>> CommitDate: 2021-05-18 20:59:46 +0000 >>> >>> The current implement of ip_input() reject packets destined for >>> 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local >>> addresses. >>> >>> Fix to fully respect RFC 3927 section 2.7. >>> >>> PR: 255388 >>> Reviewed by: donner, rgrimes, karels >>> MFC after: 1 month >>> Differential Revision: https://reviews.freebsd.org/D29968 > > I did only commit this differential, but set a month for MFC, exactly to > have to opportunity to fix such mistakes. > IMHO, I'd like to see the RFC reference remain. I see rgrimes response that the RFC's can change with errata and bis docs, but the anchor still provides additional context that one can use to learn more about why this code exists, and they can chase any future forward references. It was there in the initial code, and the commit message saw fit to reference it again. Removing it just seems like lost context. Joe -- PGP Key : http://www.marcuscom.com/pgp.asc From owner-dev-commits-src-main@freebsd.org Wed May 19 15:04:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A30A64482B; Wed, 19 May 2021 15:04: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 4Flbk52kB3z3v5b; Wed, 19 May 2021 15:04: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 45AF915013; Wed, 19 May 2021 15:04: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 14JF4DS2095443; Wed, 19 May 2021 15:04:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JF4DTZ095442; Wed, 19 May 2021 15:04:13 GMT (envelope-from git) Date: Wed, 19 May 2021 15:04:13 GMT Message-Id: <202105191504.14JF4DTZ095442@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 4a6830761c65 - main - Fix packet cbs/ebs conversion. 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/main X-Git-Reftype: branch X-Git-Commit: 4a6830761c6552bfe2c118a73a5a461694cb84c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 15:04:13 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=4a6830761c6552bfe2c118a73a5a461694cb84c7 commit 4a6830761c6552bfe2c118a73a5a461694cb84c7 Author: Alexander Motin AuthorDate: 2021-05-19 15:00:21 +0000 Commit: Alexander Motin CommitDate: 2021-05-19 15:04:08 +0000 Fix packet cbs/ebs conversion. Each packet is counted as 128 bytes by the code, not 125. Not sure what I was thinking about here 14 years ago. May be just a typo. Reported by: Dmitry Luhtionov MFC after: 2 weeks --- sys/netgraph/ng_car.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netgraph/ng_car.c b/sys/netgraph/ng_car.c index 9474e2467439..ec61a3565ec9 100644 --- a/sys/netgraph/ng_car.c +++ b/sys/netgraph/ng_car.c @@ -491,14 +491,14 @@ ng_car_rcvmsg(node_p node, item_p item, hook_p lasthook) if (bconf->downstream.opt & NG_CAR_COUNT_PACKETS) { bconf->downstream.cir *= 1024; bconf->downstream.pir *= 1024; - bconf->downstream.cbs *= 125; - bconf->downstream.ebs *= 125; + bconf->downstream.cbs *= 128; + bconf->downstream.ebs *= 128; } if (bconf->upstream.opt & NG_CAR_COUNT_PACKETS) { bconf->upstream.cir *= 1024; bconf->upstream.pir *= 1024; - bconf->upstream.cbs *= 125; - bconf->upstream.ebs *= 125; + bconf->upstream.cbs *= 128; + bconf->upstream.ebs *= 128; } if ((bconf->downstream.cir > 1000000000) || (bconf->downstream.pir > 1000000000) || From owner-dev-commits-src-main@freebsd.org Wed May 19 17:44:06 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4512647B18; Wed, 19 May 2021 17:44: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 4FlgGZ3P79z4k6s; Wed, 19 May 2021 17:44: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 5B31F16ADD; Wed, 19 May 2021 17:44: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 14JHi6pX008047; Wed, 19 May 2021 17:44:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JHi6fA008046; Wed, 19 May 2021 17:44:06 GMT (envelope-from git) Date: Wed, 19 May 2021 17:44:06 GMT Message-Id: <202105191744.14JHi6fA008046@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 086feed850c3 - main - md5: Create md5sum, etc compatible programs 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/main X-Git-Reftype: branch X-Git-Commit: 086feed850c31c278f25c958b97992d024139896 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 17:44:06 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=086feed850c31c278f25c958b97992d024139896 commit 086feed850c31c278f25c958b97992d024139896 Author: Warner Losh AuthorDate: 2021-05-19 17:26:20 +0000 Commit: Warner Losh CommitDate: 2021-05-19 17:41:53 +0000 md5: Create md5sum, etc compatible programs On Linux, there's a similar set of programs to ours, but that end in the letters 'sum'. These act basically like FreeBSD versions run with the -r option. Add code so that when the program ends in 'sum' you get the linux -r behavior. This is enough to make most things that use sha*sum work correctly (the -c / --check options, as well as the long args are not implemented). When running with the -sum programs, ignore -t instead of running internal speed tests and make -c an error. Reviewed by: sef, and kp and allanjude (earlier version) Relnotes: yes Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30309 --- sbin/md5/Makefile | 30 ++++++++++++++++++++++++++---- sbin/md5/md5.1 | 34 ++++++++++++++++++++++++++++++++-- sbin/md5/md5.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 11 deletions(-) diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile index dcbd94dcd381..b1e40713c219 100644 --- a/sbin/md5/Makefile +++ b/sbin/md5/Makefile @@ -4,27 +4,49 @@ PACKAGE=runtime PROG= md5 -LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \ +LINKS= ${BINDIR}/md5 ${BINDIR}/md5sum \ + ${BINDIR}/md5 ${BINDIR}/rmd160 \ + ${BINDIR}/md5 ${BINDIR}/rmd160sum \ ${BINDIR}/md5 ${BINDIR}/sha1 \ + ${BINDIR}/md5 ${BINDIR}/sha1sum \ ${BINDIR}/md5 ${BINDIR}/sha224 \ + ${BINDIR}/md5 ${BINDIR}/sha224sum \ ${BINDIR}/md5 ${BINDIR}/sha256 \ + ${BINDIR}/md5 ${BINDIR}/sha256sum \ ${BINDIR}/md5 ${BINDIR}/sha384 \ + ${BINDIR}/md5 ${BINDIR}/sha384sum \ ${BINDIR}/md5 ${BINDIR}/sha512 \ + ${BINDIR}/md5 ${BINDIR}/sha512sum \ ${BINDIR}/md5 ${BINDIR}/sha512t256 \ + ${BINDIR}/md5 ${BINDIR}/sha512t256sum \ ${BINDIR}/md5 ${BINDIR}/skein256 \ + ${BINDIR}/md5 ${BINDIR}/skein256sum \ ${BINDIR}/md5 ${BINDIR}/skein512 \ - ${BINDIR}/md5 ${BINDIR}/skein1024 + ${BINDIR}/md5 ${BINDIR}/skein512sum \ + ${BINDIR}/md5 ${BINDIR}/skein1024 \ + ${BINDIR}/md5 ${BINDIR}/skein1024sum -MLINKS= md5.1 rmd160.1 \ +MLINKS= md5.1 md5sum.1 \ + md5.1 rmd160.1 \ + md5.1 rmd160sum.1 \ md5.1 sha1.1 \ + md5.1 sha1sum.1 \ md5.1 sha224.1 \ + md5.1 sha224sum.1 \ md5.1 sha256.1 \ + md5.1 sha256sum.1 \ md5.1 sha384.1 \ + md5.1 sha384sum.1 \ md5.1 sha512.1 \ + md5.1 sha512sum.1 \ md5.1 sha512t256.1 \ + md5.1 sha512t256sum.1 \ md5.1 skein256.1 \ + md5.1 skein256sum.1 \ md5.1 skein512.1 \ - md5.1 skein1024.1 + md5.1 skein512sum.1 \ + md5.1 skein1024.1 \ + md5.1 skein1024sum.1 LIBADD= md diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index e6b29233c399..c154c4788f8d 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -1,10 +1,12 @@ .\" $FreeBSD$ -.Dd June 19, 2020 +.Dd May 19, 2021 .Dt MD5 1 .Os .Sh NAME .Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 , -.Nm skein256 , skein512 , skein1024 +.Nm skein256 , skein512 , skein1024 , +.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , +.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , skein1024sum .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm @@ -26,6 +28,15 @@ output a or .Dq message digest of the input. +The +.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , +.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , +and +.Nm skein1024sum +utilities do the same, but default to the reversed format of +the +.Fl r +flag. It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given prespecified target message digest. @@ -59,9 +70,18 @@ precede any files named on the command line. The hexadecimal checksum of each file listed on the command line is printed after the options are processed. .Bl -tag -width indent +.It Fl b +Ignored for compatibility with the coreutils +.Nm -sum +programs. .It Fl c Ar string Compare the digest of the file against this string. .Pq Note that this option is not yet useful if multiple files are specified. +This option causes an error in for the +.Nm -sum +programs because it check the checksums listed in a file for the coreutils +.Nm -sum +programs that is not yet implemented. .It Fl s Ar string Print a checksum of the given .Ar string . @@ -81,6 +101,9 @@ when combined with the options. .It Fl t Run a built-in time trial. +For the +.Nm -sum +versions, this is a nop for compatibility with coreutils. .It Fl x Run a built-in test script. .El @@ -171,6 +194,13 @@ Secure Hash Standard (SHS): .Pp The RIPEMD-160 page: .Pa http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html . +.Sh BUGS +All of the utilities that end in +.Sq sum +are intended to be compatible with the GNU coreutils programs. +However, the long arguments and the +.Fl -check +functionality are not provided. .Sh ACKNOWLEDGMENTS This program is placed in the public domain for free general use by RSA Data Security. diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 96dfcede9711..4381ef124c7b 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -177,13 +177,32 @@ main(int argc, char *argv[]) char buf[HEX_DIGEST_LENGTH]; size_t len; unsigned digest; - const char* progname; + char *progname; + bool gnu_emu = false; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else progname++; + /* + * GNU coreutils has a number of programs named *sum. These produce + * similar results to the BSD version, but in a different format, + * similar to BSD's -r flag. We install links to this program with + * ending 'sum' to provide this compatibility. Check here to see if the + * name of the program ends in 'sum', set the flag and drop the 'sum' so + * the digest lookup works. Also, make -t a nop when running in this mode + * since that means 'text file' there (though it's a nop in coreutils + * on unix-like systems). The -c flag conflicts, so it's just disabled + * in this mode (though in the future it might be implemented). + */ + len = strlen(progname); + if (len > 3 && strcmp(progname + len - 3, "sum") == 0) { + progname[len - 3] = '\0'; + rflag = 1; + gnu_emu = true; + } + for (digest = 0; digest < sizeof(Algorithm)/sizeof(*Algorithm); digest++) if (strcasecmp(Algorithm[digest].progname, progname) == 0) break; @@ -195,9 +214,13 @@ main(int argc, char *argv[]) checkAgainst = NULL; checksFailed = 0; skip = 0; - while ((ch = getopt(argc, argv, "c:pqrs:tx")) != -1) + while ((ch = getopt(argc, argv, "bc:pqrs:tx")) != -1) switch (ch) { + case 'b': + break; case 'c': + if (gnu_emu) + errx(1, "-c check option not supported"); checkAgainst = optarg; break; case 'p': @@ -214,8 +237,10 @@ main(int argc, char *argv[]) string = optarg; break; case 't': - MDTimeTrial(&Algorithm[digest]); - skip = 1; + if (!gnu_emu) { + MDTimeTrial(&Algorithm[digest]); + skip = 1; + } /* else: text mode is a nop */ break; case 'x': MDTestSuite(&Algorithm[digest]); @@ -348,7 +373,7 @@ MDTimeTrial(const Algorithm_t *alg) printf(" done\n"); printf("Digest = %s", p); printf("\nTime = %f seconds\n", seconds); - printf("Speed = %f MiB/second\n", (float) TEST_BLOCK_LEN * + printf("Speed = %f MiB/second\n", (float) TEST_BLOCK_LEN * (float) TEST_BLOCK_COUNT / seconds / (1 << 20)); } /* From owner-dev-commits-src-main@freebsd.org Wed May 19 17:59:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E803648105; Wed, 19 May 2021 17:59: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 4FlgcH43Q1z4qpr; Wed, 19 May 2021 17:59: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 6F9B41703A; Wed, 19 May 2021 17:59: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 14JHxRba021635; Wed, 19 May 2021 17:59:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JHxR3J021634; Wed, 19 May 2021 17:59:27 GMT (envelope-from git) Date: Wed, 19 May 2021 17:59:27 GMT Message-Id: <202105191759.14JHxR3J021634@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 43999a5cba3c - main - pseudofs: use vget_prep + vget_finish instead of vget + the interlock MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43999a5cba3cfbf0a0f6244c76a3cd548b6925e8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 17:59:27 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=43999a5cba3cfbf0a0f6244c76a3cd548b6925e8 commit 43999a5cba3cfbf0a0f6244c76a3cd548b6925e8 Author: Mateusz Guzik AuthorDate: 2021-05-19 14:20:23 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-19 17:58:42 +0000 pseudofs: use vget_prep + vget_finish instead of vget + the interlock --- sys/fs/pseudofs/pseudofs_vncache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c index 8d6f56f6fe27..b0b10d525783 100644 --- a/sys/fs/pseudofs/pseudofs_vncache.c +++ b/sys/fs/pseudofs/pseudofs_vncache.c @@ -120,6 +120,7 @@ pfs_vncache_alloc(struct mount *mp, struct vnode **vpp, struct pfs_vncache_head *hash; struct pfs_vdata *pvd, *pvd2; struct vnode *vp; + enum vgetstate vs; int error; /* @@ -134,9 +135,9 @@ retry: if (pvd->pvd_pn == pn && pvd->pvd_pid == pid && pvd->pvd_vnode->v_mount == mp) { vp = pvd->pvd_vnode; - VI_LOCK(vp); + vs = vget_prep(vp); mtx_unlock(&pfs_vncache_mutex); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK) == 0) { + if (vget_finish(vp, LK_EXCLUSIVE, vs) == 0) { ++pfs_vncache_hits; *vpp = vp; /* From owner-dev-commits-src-main@freebsd.org Wed May 19 17:59:28 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBFEB647DB3; Wed, 19 May 2021 17:59: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 4FlgcJ53kFz4qc3; Wed, 19 May 2021 17:59: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 926C416FBB; Wed, 19 May 2021 17:59: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 14JHxSP1021659; Wed, 19 May 2021 17:59:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JHxSOv021658; Wed, 19 May 2021 17:59:28 GMT (envelope-from git) Date: Wed, 19 May 2021 17:59:28 GMT Message-Id: <202105191759.14JHxSOv021658@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 4fe925b81e75 - main - fdescfs: allow shared locking of root vnode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4fe925b81e75b5885ec6d504c6217f848439164a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 17:59:29 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=4fe925b81e75b5885ec6d504c6217f848439164a commit 4fe925b81e75b5885ec6d504c6217f848439164a Author: Mateusz Guzik AuthorDate: 2021-05-19 15:59:20 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-19 17:58:54 +0000 fdescfs: allow shared locking of root vnode Eliminates fdescfs from lock profile when running poudriere. --- sys/fs/fdescfs/fdesc_vfsops.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c index e7878f115ac2..64f8d28bdcfd 100644 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -107,12 +107,23 @@ fdesc_mount(struct mount *mp) mp->mnt_data = NULL; return (error); } + VN_LOCK_ASHARE(rvp); rvp->v_type = VDIR; rvp->v_vflag |= VV_ROOT; fmp->f_root = rvp; VOP_UNLOCK(rvp); + + MNT_ILOCK(mp); /* XXX -- don't mark as local to work around fts() problems */ /*mp->mnt_flag |= MNT_LOCAL;*/ + /* + * Enable shared locking so that there is no contention on the root + * vnode. Note only root vnode enables shared locking for itself, + * so this end up being a nop for the rest. + */ + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED; + MNT_IUNLOCK(mp); + vfs_getnewfsid(mp); vfs_mountedfrom(mp, "fdescfs"); @@ -163,7 +174,7 @@ fdesc_root(struct mount *mp, int flags, struct vnode **vpp) * Return locked reference to root. */ vp = VFSTOFDESC(mp)->f_root; - vget(vp, LK_EXCLUSIVE | LK_RETRY); + vget(vp, flags | LK_RETRY); *vpp = vp; return (0); } From owner-dev-commits-src-main@freebsd.org Wed May 19 18:32:05 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E9AD64836F for ; Wed, 19 May 2021 18:32:05 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlhKx3tvPz3LjT for ; Wed, 19 May 2021 18:32:05 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f49.google.com with SMTP id d11so15015138wrw.8 for ; Wed, 19 May 2021 11:32:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=gt///jaZUlH+E+/C4Hd30zXGPOifU0F8mwghNacnRqI=; b=qtYq342S5gwz/QrZJ95f649ujheVzPWBmC9wEOnD3f3jdRdjbjNoxRAXInrbqI9Glw A/vbv8FrCglg2P1/6gKTdJxv3JyRunypcD+PcTeHsdq4tRRLTcCGniwlOeXXrtY2PT2o EWFYGkdlSCzFbj1oPRw6m7ON9imN/t8aAXeoizLKqXiLwi4K9MJ/vC7c4J+nbNj+GkVl i9/zgNz3qjiojkjT5bwnx2BMv5EvpwDwyocmTggnFjI4AzQOeD5Rd/LNSPlneUfDWbr1 wfCDaK3716JujzwsAZmpJMA4SJE5DqmgkTf0pFMrTJs4UHGl1es9lQrpXgPN7CYDCdWB kwkg== X-Gm-Message-State: AOAM533eXBiOgvPDJ/dvEAGe41t7SKtkPZpxqgg28+FaQ0LxCZmjfVts /7UDgdqKxdvprlJekrzBfxul2g== X-Google-Smtp-Source: ABdhPJz6qDs+m8i81DAguYdV5088Ok5JFOUiiv+PJsogakJOE2+i2/a7Gp6bQ66xJtFEZ1B2oTeEGw== X-Received: by 2002:a5d:5301:: with SMTP id e1mr326355wrv.36.1621449124025; Wed, 19 May 2021 11:32:04 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id r14sm174247wrx.74.2021.05.19.11.32.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 May 2021 11:32:03 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: 086feed850c3 - main - md5: Create md5sum, etc compatible programs From: Jessica Clarke In-Reply-To: <202105191744.14JHi6fA008046@gitrepo.freebsd.org> Date: Wed, 19 May 2021 19:32:02 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <9BE6FB36-5958-4220-9C95-86DED767F6ED@freebsd.org> References: <202105191744.14JHi6fA008046@gitrepo.freebsd.org> To: Warner Losh X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FlhKx3tvPz3LjT 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 18:32:05 -0000 On 19 May 2021, at 18:44, Warner Losh wrote: >=20 > The branch main has been updated by imp: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D086feed850c31c278f25c958b97992d0= 24139896 >=20 > commit 086feed850c31c278f25c958b97992d024139896 > Author: Warner Losh > AuthorDate: 2021-05-19 17:26:20 +0000 > Commit: Warner Losh > CommitDate: 2021-05-19 17:41:53 +0000 >=20 > md5: Create md5sum, etc compatible programs >=20 > On Linux, there's a similar set of programs to ours, but that end = in the > letters 'sum'. These act basically like FreeBSD versions run with = the -r > option. Add code so that when the program ends in 'sum' you get the > linux -r behavior. This is enough to make most things that use = sha*sum > work correctly (the -c / --check options, as well as the long args = are > not implemented). When running with the -sum programs, ignore -t = instead > of running internal speed tests and make -c an error. >=20 > Reviewed by: sef, and kp and allanjude (earlier version) > Relnotes: yes > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D30309 > --- > diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c > index 96dfcede9711..4381ef124c7b 100644 > --- a/sbin/md5/md5.c > +++ b/sbin/md5/md5.c > @@ -177,13 +177,32 @@ main(int argc, char *argv[]) > char buf[HEX_DIGEST_LENGTH]; > size_t len; > unsigned digest; > - const char* progname; > + char *progname; > + bool gnu_emu =3D false; This file doesn=E2=80=99t currently include stdbool.h explicitly, and = apparently that is not implicitly included by any of the headers on Linux (and I cannot = work out where it comes from on FreeBSD). Could you please add the explicit = include to fix cross-building? Thanks, Jess From owner-dev-commits-src-main@freebsd.org Wed May 19 18:58:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB595648D4F; Wed, 19 May 2021 18:58: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 4Flhvr4mbZz3mJl; Wed, 19 May 2021 18:58: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 8D80917E5B; Wed, 19 May 2021 18:58: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 14JIw0FR000992; Wed, 19 May 2021 18:58:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JIw0L1000991; Wed, 19 May 2021 18:58:00 GMT (envelope-from git) Date: Wed, 19 May 2021 18:58:00 GMT Message-Id: <202105191858.14JIw0L1000991@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: f4583ebabc0d - main - i2c(8): Polish: sort switches, dont confuse address & offset MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f4583ebabc0db99992f65bcfb3eb8d8a95921a34 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 18:58:00 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=f4583ebabc0db99992f65bcfb3eb8d8a95921a34 commit f4583ebabc0db99992f65bcfb3eb8d8a95921a34 Author: Poul-Henning Kamp AuthorDate: 2021-05-19 18:47:32 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-19 18:47:32 +0000 i2c(8): Polish: sort switches, dont confuse address & offset --- usr.sbin/i2c/i2c.c | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index ef0ca0e8fda5..099418a5715c 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -281,7 +281,7 @@ reset_bus(const char *dev, int fd, int verbose) } static const char * -encode_offset(const char *width, unsigned address, uint8_t *dst, size_t *len) +encode_offset(const char *width, unsigned offset, uint8_t *dst, size_t *len) { if (!strcmp(width, "0")) { @@ -289,21 +289,21 @@ encode_offset(const char *width, unsigned address, uint8_t *dst, size_t *len) return (NULL); } if (!strcmp(width, "8")) { - if (address > 0xff) - return ("Invalid 8-bit address\n"); - *dst = address; + if (offset > 0xff) + return ("Invalid 8-bit offset\n"); + *dst = offset; *len = 1; return (NULL); } - if (address > 0xffff) - return ("Invalid 16-bit address\n"); + if (offset > 0xffff) + return ("Invalid 16-bit offset\n"); if (!strcmp(width, "16LE") || !strcmp(width, "16")) { - le16enc(dst, address); + le16enc(dst, offset); *len = 2; return (NULL); } if (!strcmp(width, "16BE")) { - be16enc(dst, address); + be16enc(dst, offset); *len = 2; return (NULL); } @@ -594,26 +594,21 @@ main(int argc, char** argv) usage("Bad -a argument (01..7f)"); i2c_opt.addr <<= 1; break; - case 'f': - dev = optarg; + case 'b': + i2c_opt.binary = 1; + break; + case 'c': + i2c_opt.count = (strtoul(optarg, 0, 10)); + if (i2c_opt.count == 0 && errno == EINVAL) + usage("Bad -c argument (decimal)"); break; case 'd': if (strcmp(optarg, "r") && strcmp(optarg, "w")) usage("Bad -d argument ([r|w])"); i2c_opt.dir = optarg[0]; break; - case 'o': - i2c_opt.off = strtoul(optarg, 0, 16); - if (i2c_opt.off == 0 && errno == EINVAL) - usage("Bad -o argument (hex)"); - break; - case 'w': - i2c_opt.width = optarg; // checked later. - break; - case 'c': - i2c_opt.count = (strtoul(optarg, 0, 10)); - if (i2c_opt.count == 0 && errno == EINVAL) - usage("Bad -c argument (decimal)"); + case 'f': + dev = optarg; break; case 'm': if (!strcmp(optarg, "no")) @@ -630,14 +625,19 @@ main(int argc, char** argv) case 'n': i2c_opt.skip = optarg; break; - case 's': break; - case 'b': - i2c_opt.binary = 1; + case 'o': + i2c_opt.off = strtoul(optarg, 0, 16); + if (i2c_opt.off == 0 && errno == EINVAL) + usage("Bad -o argument (hex)"); break; + case 'r': break; + case 's': break; case 'v': i2c_opt.verbose = 1; break; - case 'r': break; + case 'w': + i2c_opt.width = optarg; // checked later. + break; default: fprintf(stderr, "Illegal -%c option", ch); usage(NULL); @@ -660,7 +660,7 @@ main(int argc, char** argv) i2c_opt.off_buf, &i2c_opt.off_len); if (err_msg != NULL) { fprintf(stderr, "%s", err_msg); - exit(EX_USAGE); + return(EX_USAGE); } if (i2c_opt.verbose) @@ -677,15 +677,15 @@ main(int argc, char** argv) } switch (do_what) { + case 'a': + error = access_bus(fd, i2c_opt); + break; case 's': error = scan_bus(dev, fd, i2c_opt.skip, i2c_opt.verbose); break; case 'r': error = reset_bus(dev, fd, i2c_opt.verbose); break; - case 'a': - error = access_bus(fd, i2c_opt); - break; default: assert("Bad do_what"); } From owner-dev-commits-src-main@freebsd.org Wed May 19 18:58:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 153B8648865; Wed, 19 May 2021 18:58: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 4Flhvs69sgz3mPM; Wed, 19 May 2021 18:58: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 B1FC717E5C; Wed, 19 May 2021 18:58: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 14JIw1PM001020; Wed, 19 May 2021 18:58:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JIw1mE001019; Wed, 19 May 2021 18:58:01 GMT (envelope-from git) Date: Wed, 19 May 2021 18:58:01 GMT Message-Id: <202105191858.14JIw1mE001019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: e32b2bcff02e - main - i2c(8): Change default mode to "transfer", which should work everywhere¹ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e32b2bcff02ee6885c2e2e8db040f91e5a06214d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 18:58:02 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=e32b2bcff02ee6885c2e2e8db040f91e5a06214d commit e32b2bcff02ee6885c2e2e8db040f91e5a06214d Author: Poul-Henning Kamp AuthorDate: 2021-05-19 18:48:28 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-19 18:48:28 +0000 i2c(8): Change default mode to "transfer", which should work everywhere¹ ¹ According to @ian --- usr.sbin/i2c/i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 099418a5715c..a471b6533170 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -550,7 +550,7 @@ main(int argc, char** argv) i2c_opt.count = 1; i2c_opt.binary = 0; /* ASCII text output */ i2c_opt.skip = NULL; /* scan all addresses */ - i2c_opt.mode = I2C_MODE_NOTSET; + i2c_opt.mode = I2C_MODE_TRANSFER; /* Find out what we are going to do */ From owner-dev-commits-src-main@freebsd.org Wed May 19 18:58:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5776E648F93; Wed, 19 May 2021 18:58: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 4Flhvv07YPz3mPY; Wed, 19 May 2021 18:58: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 D296018020; Wed, 19 May 2021 18:58: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 14JIw2KB001041; Wed, 19 May 2021 18:58:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JIw28t001040; Wed, 19 May 2021 18:58:02 GMT (envelope-from git) Date: Wed, 19 May 2021 18:58:02 GMT Message-Id: <202105191858.14JIw28t001040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 9c10d00bf8cd - main - i2c(8): Add interpreted mode for batch/scripted i2c operations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9c10d00bf8cdf7735cdba7c09bc16495ce22095b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 18:58:03 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=9c10d00bf8cdf7735cdba7c09bc16495ce22095b commit 9c10d00bf8cdf7735cdba7c09bc16495ce22095b Author: Poul-Henning Kamp AuthorDate: 2021-05-19 18:56:59 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-19 18:56:59 +0000 i2c(8): Add interpreted mode for batch/scripted i2c operations --- usr.sbin/i2c/i2c.8 | 63 ++++++++++++++-- usr.sbin/i2c/i2c.c | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 274 insertions(+), 7 deletions(-) diff --git a/usr.sbin/i2c/i2c.8 b/usr.sbin/i2c/i2c.8 index 92cc62e983aa..7c995f5743a4 100644 --- a/usr.sbin/i2c/i2c.8 +++ b/usr.sbin/i2c/i2c.8 @@ -43,19 +43,26 @@ .Op Fl b .Op Fl v .Nm -.Cm -s -.Op Fl f Ar device -.Op Fl n Ar skip_addr +.Cm -h +.Nm +.Cm -i .Op Fl v +.Op Ar cmd ... +.Op Ar - .Nm .Cm -r .Op Fl f Ar device .Op Fl v +.Nm +.Cm -s +.Op Fl f Ar device +.Op Fl n Ar skip_addr +.Op Fl v .Sh DESCRIPTION The .Nm -utility can be used to perform raw data transfers (read or write) with devices -on the I2C bus. +utility can be used to perform raw data transfers (read or write) to devices +on an I2C bus. It can also scan the bus for available devices and reset the I2C controller. .Pp The options are as follows: @@ -72,6 +79,10 @@ transfer direction: r - read, w - write. Data to be written is read from stdin as binary bytes. .It Fl f Ar device I2C bus to use (default is /dev/iic0). +.It Fl i +Interpreted mode +.It Fl h +Help .It Fl m Ar tr|ss|rs|no addressing mode, i.e., I2C bus operations performed after the offset for the transfer has been written to the device and before the actual read/write @@ -121,6 +132,37 @@ to the slave. Zero means that the offset is ignored and not passed to the slave at all. The endianess defaults to little-endian. .El +.Sh INTERPRETED MODE +When started with +.Fl i +any remaining arguments are interpreted as commands, and +if the last argument is '-', or there are no arguments, +commands will (also) be read from stdin. +.Pp +Available commands: +.Bl -tag -compact +.It 'r' bus address [0|8|16|16LE|16BE] offset count +Read command, count bytes are read and hexdumped to stdout. +.It 'w' bus address [0|8|16|16LE|16BE] offset hexstring +Write command, hexstring (white-space is allowed) is written to device. +.It 'p' anything +Print command, the entire line is printed to stdout. (This can be used +for synchronization.) +.El +.Pp +All numeric fields accept canonical decimal/octal/hex notation. +.Pp +Without the +.Fl v +option, all errors are fatal with non-zero exit status. +.Pp +With the +.Fl v +option, no errors are fatal, and all commands will return +either "OK\en" or "ERROR\en" on stdout. +In case of error, detailed diagnostics will precede that on stderr. +.Pp +Blank lines and lines starting with '#' are ignored. .Sh EXAMPLES .Bl -bullet .It @@ -148,6 +190,14 @@ i2c -a 0x56 -f /dev/iic1 -d r -c 0x4 -b | i2c -a 0x57 -f /dev/iic0 -d w -c 4 -b Reset the controller: .Pp i2c -f /dev/iic1 -r +.It +Read 8 bytes at address 24 in an EEPROM: +.Pp +i2c -i 'r 0 0x50 16BE 24 8' +.It +Read 2x8 bytes at address 24 and 48 in an EEPROM: +.Pp +echo 'r 0 0x50 16BE 48 8' | i2c -i 'r 0 0x50 16BE 24 8' - .El .Sh WARNING Many systems store critical low-level information in I2C memories, and @@ -171,3 +221,6 @@ utility and this manual page were written by .An Bartlomiej Sieka Aq Mt tur@semihalf.com and .An Michal Hajduk Aq Mt mih@semihalf.com . +.Pp +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org +added interpreted mode. diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index a471b6533170..87bb1f0fe983 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -65,6 +65,9 @@ struct options { size_t off_len; }; +#define N_FDCACHE 128 +static int fd_cache[N_FDCACHE]; + __dead2 static void usage(const char *msg) { @@ -531,6 +534,210 @@ access_bus(int fd, struct options i2c_opt) return (error); } +static const char *widths[] = { + "0", + "8", + "16LE", + "16BE", + "16", + NULL, +}; + +static int +command_bus(struct options i2c_opt, char *cmd) +{ + int error, fd; + char devbuf[64]; + uint8_t dbuf[BUFSIZ]; + unsigned bus; + const char *width = NULL; + const char *err_msg; + unsigned offset; + unsigned u; + size_t length; + + while (isspace(*cmd)) + cmd++; + + switch(*cmd) { + case 0: + case '#': + return (0); + case 'p': + case 'P': + printf("%s", cmd); + return (0); + case 'r': + case 'R': + i2c_opt.dir = 'r'; + break; + case 'w': + case 'W': + i2c_opt.dir = 'w'; + break; + default: + fprintf(stderr, + "Did not understand command: 0x%02x ", *cmd); + if (isgraph(*cmd)) + fprintf(stderr, "'%c'", *cmd); + fprintf(stderr, "\n"); + return(-1); + } + cmd++; + + bus = strtoul(cmd, &cmd, 0); + if (bus == 0 && errno == EINVAL) { + fprintf(stderr, "Could not translate bus number\n"); + return(-1); + } + + i2c_opt.addr = strtoul(cmd, &cmd, 0); + if (i2c_opt.addr == 0 && errno == EINVAL) { + fprintf(stderr, "Could not translate device\n"); + return(-1); + } + if (i2c_opt.addr < 1 || i2c_opt.addr > 0x7f) { + fprintf(stderr, "Invalid device (0x%x)\n", i2c_opt.addr); + return(-1); + } + i2c_opt.addr <<= 1; + + while(isspace(*cmd)) + cmd++; + + for(u = 0; widths[u]; u++) { + length = strlen(widths[u]); + if (memcmp(cmd, widths[u], length)) + continue; + if (!isspace(cmd[length])) + continue; + width = widths[u]; + cmd += length; + break; + } + if (width == NULL) { + fprintf(stderr, "Invalid width\n"); + return(-1); + } + + offset = strtoul(cmd, &cmd, 0); + if (offset == 0 && errno == EINVAL) { + fprintf(stderr, "Could not translate offset\n"); + return(-1); + } + + err_msg = encode_offset(width, offset, + i2c_opt.off_buf, &i2c_opt.off_len); + if (err_msg) { + fprintf(stderr, "%s", err_msg); + return(-1); + } + + if (i2c_opt.dir == 'r') { + i2c_opt.count = strtoul(cmd, &cmd, 0); + if (i2c_opt.count == 0 && errno == EINVAL) { + fprintf(stderr, "Could not translate length\n"); + return(-1); + } + } else { + i2c_opt.count = 0; + while (1) { + while(isspace(*cmd)) + cmd++; + if (!*cmd) + break; + if (!isxdigit(*cmd)) { + fprintf(stderr, "Not a hex digit.\n"); + return(-1); + } + dbuf[i2c_opt.count] = digittoint(*cmd++) << 4; + while(isspace(*cmd)) + cmd++; + if (!*cmd) { + fprintf(stderr, + "Uneven number of hex digits.\n"); + return(-1); + } + if (!isxdigit(*cmd)) { + fprintf(stderr, "Not a hex digit.\n"); + return(-1); + } + dbuf[i2c_opt.count++] |= digittoint(*cmd++); + } + } + assert(bus < N_FDCACHE); + fd = fd_cache[bus]; + if (fd < 0) { + (void)sprintf(devbuf, "/dev/iic%u", bus); + fd = open(devbuf, O_RDWR); + if (fd == -1) { + fprintf(stderr, "Error opening I2C controller (%s): %s\n", + devbuf, strerror(errno)); + return (EX_NOINPUT); + } + fd_cache[bus] = fd; + } + + error = i2c_rdwr_transfer(fd, i2c_opt, dbuf); + if (error) + return(-1); + + if (i2c_opt.dir == 'r') { + for (u = 0; u < i2c_opt.count; u++) + printf("%02x", dbuf[u]); + printf("\n"); + } + return (0); +} + +static int +exec_bus(struct options i2c_opt, char *cmd) +{ + int error; + + while (isspace(*cmd)) + cmd++; + if (*cmd == '#' || *cmd == '\0') + return (0); + error = command_bus(i2c_opt, cmd); + if (i2c_opt.verbose) { + (void)fflush(stderr); + printf(error ? "ERROR\n" : "OK\n"); + error = 0; + } else if (error) { + fprintf(stderr, " in: %s", cmd); + } + (void)fflush(stdout); + return (error); +} + +static int +instruct_bus(struct options i2c_opt, int argc, char **argv) +{ + char buf[BUFSIZ]; + int rd_cmds = (argc == 0); + int error; + + while (argc-- > 0) { + if (argc == 0 && !strcmp(*argv, "-")) { + rd_cmds = 1; + } else { + error = exec_bus(i2c_opt, *argv); + if (error) + return (error); + } + argv++; + } + if (!rd_cmds) + return (0); + while (fgets(buf, sizeof buf, stdin) != NULL) { + error = exec_bus(i2c_opt, buf); + if (error) + return (error); + } + return (0); +} + int main(int argc, char** argv) { @@ -541,6 +748,8 @@ main(int argc, char** argv) char do_what = 0; dev = I2C_DEV; + for (ch = 0; ch < N_FDCACHE; ch++) + fd_cache[ch] = -1; /* Default values */ i2c_opt.off = 0; @@ -554,9 +763,10 @@ main(int argc, char** argv) /* Find out what we are going to do */ - while ((ch = getopt(argc, argv, "a:f:d:o:w:c:m:n:sbvrh")) != -1) { + while ((ch = getopt(argc, argv, "a:f:d:iw:c:m:n:sbvrh")) != -1) { switch(ch) { case 'a': + case 'i': case 'r': case 's': if (do_what) @@ -574,8 +784,9 @@ main(int argc, char** argv) /* Then handle the legal subset of arguments */ switch (do_what) { - case 0: usage("Pick one of [-a|-h|-r|-s]"); break; + case 0: usage("Pick one of [-a|-h|-i|-r|-s]"); break; case 'a': optflags = "a:f:d:w:o:c:m:bv"; break; + case 'i': optflags = "iv"; break; case 'r': optflags = "rf:v"; break; case 's': optflags = "sf:n:v"; break; default: assert("Bad do_what"); @@ -610,6 +821,7 @@ main(int argc, char** argv) case 'f': dev = optarg; break; + case 'i': break; case 'm': if (!strcmp(optarg, "no")) i2c_opt.mode = I2C_MODE_NONE; @@ -645,6 +857,8 @@ main(int argc, char** argv) } argc -= optind; argv += optind; + if (do_what == 'i') + return(instruct_bus(i2c_opt, argc, argv)); if (argc > 0) usage("Too many arguments"); From owner-dev-commits-src-main@freebsd.org Wed May 19 21:02:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFA0164BE65 for ; Wed, 19 May 2021 21:02:23 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FllgJ66Fcz3wCp for ; Wed, 19 May 2021 21:02:20 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x72c.google.com with SMTP id o27so14149668qkj.9 for ; Wed, 19 May 2021 14:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bnLDBG9O91+WOP5nPd+HzZaTii7mLDnN+gkiD+kh784=; b=BfzlTQ5EwP+BZm1iTzwJmNWgX7gFH0UX49fp1HskixLfEfiG20+hlH0b1+jyAAMcVV 3mOfceLhpNAylpCDZ6/mOk3/MC34DbIYhpiM6Rsfk3+BOg+HSFhdIkOshoKtkuqW+I+h qCQ8FbiFgEXy68LuVm4KTzqrAKMhWSAJJVwf5+ah3p0GbWhLj50p5+fuWDLm8aa8AOTH AMAdmxMQ5FbWrpEyDnxmns+oNlNTWvvzSGoLJRb3ITXAq/kNl7cyaj35uS7sjn1+Q39q NrS9FDEUzhPL9+GVnUXZNv8WO7u5Omj3mnisq78oNWAZVlP1Cs45jWCiXh8PTu7/6Os1 aB5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bnLDBG9O91+WOP5nPd+HzZaTii7mLDnN+gkiD+kh784=; b=jWA6WAi7gNWxMk2aSB7JhBYcobsj+oRJe+iNFrRUroeBpbGCH7gK4AjIwNGQiNFrzE K2dAItOGqf1ClLlkUczBjCo0bMBOGyZgxGblH0dqUIR7ZfpPfuP++6A+59VXV5676mGy Zup+NhSfIKN3/LsVEbSIFFPwVmxo2Hjt+4zi21MPhtvGJj0JvOT/Qmni8rQ5+FEBcdX2 4YsydH4GkzibRCDSKgMbxRtzmrE25m3ys7DIa0MSLwq/f8Gzi6SIV95jAJigEWF5JdWK vJcIxM+WNY5AtWB+0PaivREy60oOam1NOXqz0yWMNMtefgTfusaeT8n8LvCMCny+6EPx 8zKg== X-Gm-Message-State: AOAM5333XfZN1+pMiXtDcEw8n+1auAgsnH7cKlkWq8VAXARmohvYEZPu m8D4qCL/tCvLKv0WVptFFm9w7EbPYweTUMDoZV8wmQ== X-Google-Smtp-Source: ABdhPJyTWCjB4uEINxvcmWH+lUdDgh/0tlp9M9cpJ/uqBMH1ofE9Gxt9w4njzas8XMHnX9ZAmjBeIKEt3ISetF+Hb1s= X-Received: by 2002:a37:30b:: with SMTP id 11mr1408279qkd.206.1621458139291; Wed, 19 May 2021 14:02:19 -0700 (PDT) MIME-Version: 1.0 References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> In-Reply-To: From: Warner Losh Date: Wed, 19 May 2021 15:02:08 -0600 Message-ID: Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. To: Konstantin Belousov Cc: Mark Johnston , src-committers , "" , dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4FllgJ66Fcz3wCp X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=BfzlTQ5E; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::72c) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-2.79 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.79)[-0.789]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-main@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; RCPT_COUNT_FIVE(0.00)[5]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::72c:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::72c:from]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::72c:from]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; MAILMAN_DEST(0.00)[dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:02:24 -0000 On Mon, May 17, 2021 at 12:52 AM Konstantin Belousov wrote: > On Sun, May 16, 2021 at 07:03:24PM +0100, Edward Tomasz Napierala wrote: > > On 0516T1227, Warner Losh wrote: > > > On Sun, May 16, 2021, 11:55 AM Mark Johnston > wrote: > > > > > > > On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala > wrote: > > > > > The branch main has been updated by trasz: > > > > > > > > > > URL: > > > > > https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > > > > > > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > > > > Author: Edward Tomasz Napierala > > > > > AuthorDate: 2021-05-16 09:28:04 +0000 > > > > > Commit: Edward Tomasz Napierala > > > > > CommitDate: 2021-05-16 10:38:26 +0000 > > > > > > > > > > cam: add missing zeroing of a stack-allocated CCB. > > > > > > > > > > This could cause a panic at boot. > > > > > > > > There are other instances of this, for example syzbot is currently > > > > hitting an assertion, seemingly because the alloc_flags field of a > > > > stack-allocated CCB was not zeroed: > > > > https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c > > > > > > > > I think the patch below will fix it, but I did not audit other > callers. > > > > It feels a bit strange to require all callers of xpt_setup_ccb() to > > > > manually zero the structure first, can we provide a single routine to > > > > initialize stack-allocated CCBs? > > > > We definitely could, although in some cases it's a bit more > > complicated than that - a function that gets passed a CCB and then > > calls xpt_setup_ccb() to fill it shouldn't zero it, as that would > > be making assumption on how the CCB passed to it was allocated. > > > > Now that I look at the code, I can definitely see that I've missed > > a couple of places. Perhaps I should replace those two KASSERTs with > > diagnostic printfs for now, until I get that sorted out? > > > > > If we did, we could set a flag we could assert on, and/or do static > > > analysis to find any others... > > > > That sounds promising, except I've never done anything like that; > > I don't even know where to start. > > Are stack-allocated ccbs passed around? In particular, can the thread > that allocated the ccb, put to sleep while ccb is processed elsewere? > This should break under swapping. > I don't think so, but we should check. Most of the ones I've spot checked are immediate operations that don't block. I've not checked every single one, though. This is another reason to use xpt_stack_ccb_inint() or similar. That way, we can flag this as 'stack allocated' and assert in xpt_setup_ccb when it is stack allocated and trying to do a queued operation. Sadly, traz reports that there's some tricky uses/reuses of ccbs that make this difficult to do at this time. Warner From owner-dev-commits-src-main@freebsd.org Wed May 19 21:30:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C14F64C881; Wed, 19 May 2021 21:30: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 4FlmJ12Qf9z4jJ6; Wed, 19 May 2021 21:30: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 3475119EB7; Wed, 19 May 2021 21:30: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 14JLUfrR010593; Wed, 19 May 2021 21:30:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JLUfdt010592; Wed, 19 May 2021 21:30:41 GMT (envelope-from git) Date: Wed, 19 May 2021 21:30:41 GMT Message-Id: <202105192130.14JLUfdt010592@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6190ff6104ae - main - tcsh: cleanup source tree to reduce diff size. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6190ff6104aed4cd753019325a252c4d66495b5e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:30:41 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6190ff6104aed4cd753019325a252c4d66495b5e commit 6190ff6104aed4cd753019325a252c4d66495b5e Author: Dmitry Chagin AuthorDate: 2021-05-19 21:08:25 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-19 21:08:25 +0000 tcsh: cleanup source tree to reduce diff size. Remove makefiles, configure files and unused at build time files to reduce the diff size. Otherwise the diff contains a lot of unnecessary lines what makes reviewing and merging proccess so hard, especially for re@. MFC after: 2 weeks --- contrib/tcsh/FREEBSD-Xlist | 15 + contrib/tcsh/Imakefile | 631 --- contrib/tcsh/MAKEDIFFS | 40 - contrib/tcsh/MAKESHAR | 120 - contrib/tcsh/Makefile.ADMIN | 24 - contrib/tcsh/Makefile.in | 782 ---- contrib/tcsh/Makefile.std | 630 --- contrib/tcsh/Makefile.vms | 592 --- contrib/tcsh/config.guess | 1438 ------- contrib/tcsh/config.h.in | 275 -- contrib/tcsh/config.rpath | 571 --- contrib/tcsh/config.sub | 1788 --------- contrib/tcsh/configure | 8842 ------------------------------------------- contrib/tcsh/imake.config | 63 - contrib/tcsh/install-sh | 520 --- contrib/tcsh/svn | 32 - 16 files changed, 15 insertions(+), 16348 deletions(-) diff --git a/contrib/tcsh/FREEBSD-Xlist b/contrib/tcsh/FREEBSD-Xlist index b6e5636aa567..49621ab36f0f 100644 --- a/contrib/tcsh/FREEBSD-Xlist +++ b/contrib/tcsh/FREEBSD-Xlist @@ -1,5 +1,20 @@ $FreeBSD$ */BUGS +*/Imakefile +*/MAKEDIFFS +*/MAKESHAR +*/Makefile.ADMIN +*/Makefile.in +*/Makefile.std +*/Makefile.vms +*/config.guess +*/config.h.in +*/config.rpath +*/config.sub +*/configure +*/imake.config +*/install-sh +*/svn */config/a* */config/bs2000 */config/bsd diff --git a/contrib/tcsh/Imakefile b/contrib/tcsh/Imakefile deleted file mode 100644 index bd1b43b1a24e..000000000000 --- a/contrib/tcsh/Imakefile +++ /dev/null @@ -1,631 +0,0 @@ -XCOMM -XCOMM Imakefile for tcsh 6.12 -XCOMM Marc Horowitz, MIT SIPB -XCOMM - -#ifdef DestDir -#undef DestDir -#endif -#ifdef ManSuffix -#undef ManSuffix -#endif - -/* All config options go in a separate file. */ - -#include "imake.config" - -#ifndef HasGcc -# define HasGcc 0 -#endif - -#ifndef HasGcc2 -# define HasGcc2 0 -#endif - -/* This is a giant conditional block. It should be set up right for -platforms which are in here, but it may need to be changed for new -ones. Please send in your fixes and additions! */ - -/**** tcsh configuration defines ****/ - -/* specific platforms */ - -#ifndef ConfigH -# ifdef UltrixArchitecture -# define ConfigH ultrix -# endif - -# ifdef UxpArchitecture -# define ConfigH sysv4 -# endif - -# if defined(LinuxArchitecture) || defined(GNUArchitecture) -# define ConfigH linux -# endif - -# ifdef AlphaArchitecture -# if !defined(LinuxArchitecture) && !defined(GNUArchitecture) -# define ConfigH decosf1 -# endif -# if !HasGcc -# define MyCflags -std1 -Olimit 2000 -# else -# define NoCombineRegs -# endif -# endif - -# if defined(VaxArchitecture) && !defined(UltrixArchitecture) -# define ConfigH bsd -# endif - -# ifdef NeXTArchitecture -# define ConfigH mach -# endif - -# if defined(SunArchitecture) -# if (OSMajorVersion == 3) -# define ConfigH sunos35 -# else -# if (OSMajorVersion == 4) -# if (OSMinorVersion == 0) -# define ConfigH sunos40 -# else /* OSMinorVersion == 1 */ -# if (OSTeenyVersion == 3) -# define ConfigH sunos413 -# else /* OsTeenyVersion in [0,1,2] */ -# define ConfigH sunos41 -# endif -# endif -# define NoCombineRegs -# else /* OSMajorVersion == 5 */ -# if (OSMinorVersion < 3) -# if (OSMinorVersion < 2) -# define ConfigH sol2 -# else -# define ConfigH sol22 -# endif -# else -# if (OSMinorVersion < 4) -# define ConfigH sol23 -# else -# if (OSMinorVersion < 6) -# define ConfigH sol24 -# else -# if (OSMinorVersion < 9) -# define ConfigH sol26 -# else -# define ConfigH sol29 -# endif -# endif -# endif -# endif -# define NoCombineRegs -# endif -# endif -# endif - -# ifdef HPArchitecture -/* For some stupid reason makedepend on HP requires this */ -DEPENDFLAGS = -o.o -# if (OSMajorVersion >= 8) -# define ConfigH hpux8 -# else -# define ConfigH hpux7 -# endif -# endif - -# ifdef CrayArchitecture -# define ConfigH cray -# endif - -# ifdef SGIArchitecture -# define ConfigH irix -# define UseLibBSD -# if (OSMajorVersion < 5) -# ifdef you_are_using_yp -# define UseSunLib -# endif -# if !HasGCC -# define MyStdc -D__STDC__ -# if SGICompilerMajorVersion < 4 -CCOPTIONS=-float # We don't want -cckr and -prototypes -# endif -# endif -# endif -# if (OSMajorVersion == 6) -# if (OSMinorVersion >= 2) -# undef UseLibBSD -# define ConfigH irix62 -# endif -# endif -# endif - -# ifdef IBMArchitecture -# undef UseLibBSD -# if (SystemV == YES) -# define ConfigH aix -# if OSMajorVersion < 3 -# if OSMinorVersion < 2 -# define UseLibBSD -# endif -# endif -# else -# define ConfigH bsd -# define AOSArchitecture -# endif -# endif - - -#ifdef AOSArchitecture -#define MyStdc -U__STDC__ -#endif - -# if defined(MipsBsdArchitecture) || defined(MipsSysvArchitecture) -# define ConfigH mips -# endif - -# ifdef DguxArchitecture -# define ConfigH dgux -# endif - -# ifdef ConvexArchitecture -# define ConfigH convex -# endif - -# if defined(SQNTArchitecture) || defined(SequentArchitecture) -# define ConfigH sequent -# endif - -# ifdef MacIIArchitecture -# define ConfigH mac2 -# endif - -# ifdef MinixArchitecture -/* Maybe conditional on MACH? */ -SYSSRCS=mi.termios.c mi.wait.h mi.varargs.h -SYSOBJS=mi.termios.${SUF} -EXTF=ma.setp.c vms.termcap.c -# else -/* Maybe conditional on MACH? */ -SYSSRCS=ma.setp.c -SYSOBJS=ma.setp.${SUF} -EXTF=mi.termios.c mi.wait.h mi.varargs.h vms.termcap.c -# endif - -# ifdef i386Isc -# if IscVersion != 202 -# define ConfigH isc -# define UseLibCposix -# else -# define ConfigH isc202 -# endif -# endif /* i386Isc */ - -# ifdef OpenBSDArchitecture -# define ConfigH bsd4.4 -# endif /* OpenBsdArchitecture */ - -# ifdef NetBSDArchitecture -# define ConfigH bsd4.4 -# endif /* NetBsdArchitecture */ - -# ifdef FreeBSDArchitecture -# define ConfigH bsd4.4 -# endif /* FreeBsdArchitecture */ - -# ifdef MidnightBSDArchitecture -# define ConfigH bsd4.4 -# endif /* MidnightBsdArchitecture */ - -# ifdef i386SVR4Architecture -# define ConfigH sysv4 -# ifdef DELL -# define NoCombineRegs -# endif -# endif - -#endif /* !ConfigH */ - -/* generic os's */ - -#ifndef ConfigH - -#if (SystemV == YES) -#define ConfigH sysv3 -#else -/* why this as a default? Why not? */ -#define ConfigH bsd -#endif - -#endif /* !ConfigH */ - -/**** libraries ****/ - -#if (SystemV == NO) || defined(HPArchitecture) || \ - defined(SQNTArchitecture) || defined(SequentArchitecture) || \ - defined(MacIIArchitecture) || defined(UseLibTermcap) -LIBTERMCAP = -ltermcap -#else -LIBTERMCAP = -#endif - -#if defined(SQNTArchitecture) || defined(SequentArchitecture) -LIBSQNT=-lsocket -linet -lnsl -lseq -#endif - -/* This may not be good enough - I don't have access to enough systems -to really test it. */ -#if (SystemV == YES) || defined(UseLibCurses) && !defined(HPArchitecture) -LIBCURSES = -lcurses -#else -LIBCURSES = -#endif - -#if defined(UseLibNet) -LIBNET = -lnet -#else -LIBNET = -#endif - -#if defined(UseLibSocket) -LIBSOCKET = -lsocket -#else -LIBSOCKET = -#endif - -#if defined(UseLibBSD) -LIBBSD = -lbsd -#else -LIBBSD = -#endif - -#if (defined(SGIArchitecture) && \ - (OSMajorVersion == 3) && (OSMinorVersion == 3)) || \ - defined(UseLibC_S) -LIBC_S = -lc_s -#else -LIBC_S = -#endif - -#if defined(UseLibSun) -LIBSUN = -lsun -#else -LIBSUN = -#endif - -#if defined(UseLibCposix) -LIBCPOSIX = -lcposix -#else -LIBCPOSIX = -#endif - -#if defined(UseLibInet) -LIBINET = -linet -#else -LIBINET = -#endif - -#if defined(UseLibDir) -LIBDIRECT = -ldir -#else -LIBDIRECT = -#endif - -#if defined(UseLibX) -LIBX = -lx -#else -LIBX = -#endif - -#if defined(UseLibIntl) -LIBINTL = -lintl -#else -LIBINTL = -#endif - -#if (HasLibCrypt == YES) -LIBCRYPT = -lcrypt -#else -LIBCRYPT = -#endif - -#if defined(MacIIArchitecture) || defined(UseLibPosix) -LIBPOSIX = -lposix -#else -LIBPOSIX = -#endif - -#if defined(ATTArchitecture) || defined(UseLibDirent) -LIBDIRECTENT = -ldirent -#else -LIBDIRECTENT = -#endif - -/* The order here is significant. Although nothing uses all of these, -some platforms which use more than one do care about the order. */ - -SYSLIBS = $(LIBPOSIX) $(LIBDIRECTENT) $(LIBTERMCAP) $(LIBCURSES) \ - $(LIBNET) $(LIBINTL) $(LIBSOCKET) $(LIBSUN) $(LIBBSD) $(LIBCPOSIX) \ - $(LIBINET) $(LIBDIRECT) $(LIBX) $(LIBC_S) $(LIBSQNT) $(LIBCRYPT) - -/* Past here, nothing should need to be changed to compile on a different -platform, unless you have a really weird architecture. */ - -#ifdef MyCC -CC = MyCC -#else -# if HasGcc -# if HasGcc2 -CC = gcc -# else -# ifdef NoCombineRegs -CC = gcc -finline-functions -fstrength-reduce -# else -CC = gcc -fcombine-regs -finline-functions -fstrength-reduce -# endif -# endif -# else -CC = cc -# endif -#endif - -#ifdef HESIOD -HESLIB = -L/usr/athena/lib -lhesiod -/* it seems to me that the -I shouldn't be necessary, but there seems -to be a bug in the Imake stuff, so here it is. */ -HESDEF = -DHESIOD -I/usr/athena/include -#else -HESLIB = -HESDEF = -#endif - -#ifdef AFS -#ifndef AFSDIR -AFSDIR = /usr/afsws -#endif -#ifdef AFS33 -#define AFS33LIB -laudit -#else -#define AFS33LIB -#endif -/* Auxilliary libs needed for AFS */ -/* Both HPUX and Solaris need the BSD libraries. We need -lc before - * the bsd library to avoid using any more of it than is necessary. - */ -#if defined(HPArchitecture) -#define AFSAUXLIB -lc -lBSD -/* This is probably a kludge, but so is imake. */ -#else -#if defined(SunArchitecture) && (OSMajorVersion == 5) -#define AFSAUXLIB -lsocket -lnsl -lc -lucb -#else -#define AFSAUXLIB -#endif -#endif /* AFSAUXLIB */ -AFSLIB = -L$(AFSDIR)/lib -L$(AFSDIR)/lib/afs -lkauth -lprot -lubik\ - -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\ - $(AFSDIR)/lib/afs/util.a AFS33LIB AFSAUXLIB -AFSDEF = -DAFS -I$(AFSDIR)/include -#else -AFSLIB = -AFSDEF = -#endif - -/* This is encore specific, but I don't know what encore's #define is, -and it shouldn't hurt to have it here, so here it is */ -PARALLEL=12 # Make the multi-max run fast. - -#ifndef TcshTop -#define TcshTop /usr/local -#endif -TCSHTOP = TcshTop - -#ifndef ManSuffix -#define ManSuffix 1 -#endif -MANSUFFIX = ManSuffix - -#ifdef TcshPath -PATH_TCSHELL = TcshPath -TCSHPATH = -D_PATH_TCSHELL='"$(PATH_TCSHELL)"' -#else -TCSHPATH = -#endif - -#ifdef DestBin -TCSH_BINDIR = DestBin -#else -TCSH_BINDIR = $(TCSHTOP)/bin -#endif -#ifdef DestMan -TCSH_MANDIR = DestMan -#else -TCSH_MANDIR = $(TCSHTOP)/man/man$(MANSUFFIX) -#endif - -LOCALLIBS = - -#ifndef MyCflags -#define MyCflags -#endif - -#ifndef MyDefines -#define MyDefines -#endif - -#ifndef MyIncludes -#define MyIncludes -#endif - -#ifndef MyStdc -#define MyStdc -#endif - -#ifdef CDebugFlags -CDEBUGFLAGS = CDebugFlags -#else -# if HasGcc2 -CDEBUGFLAGS = -O2 -# else -CDEBUGFLAGS = -O -# endif -#endif - - -#ifdef HostType -HOSTTYPE=HostType -HTDEF = -DHOSTTYPE='"$(HOSTTYPE)"' -#else -HTDEF = -#endif - -DEFINES = $(TCSHPATH) $(HESDEF) $(AFSDEF) $(HTDEF) MyDefines MyCflags MyStdc -INCLUDES = -I. MyIncludes -#ifdef MyLibs -LDLIBS = MyLibs -#endif - -SUF = o -VERSION = 6.12 - -SHSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c \ - sh.char.c sh.exp.c sh.file.c sh.func.c \ - sh.glob.c sh.hist.c sh.init.c sh.lex.c \ - sh.misc.c sh.parse.c sh.print.c sh.proc.c \ - sh.sem.c sh.set.c sh.time.c dotlock.c dotlock.h glob.c \ - sh.char.h sh.dir.h sh.proc.h sh.h \ - sh.decls.h glob.h ${SYSSRCS} -SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \ - sh.char.${SUF} sh.exp.${SUF} sh.file.${SUF} sh.func.${SUF} \ - sh.glob.${SUF} sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} \ - sh.misc.${SUF} sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} \ - sh.sem.${SUF} sh.set.${SUF} sh.time.${SUF} dotlock.${SUF} glob.${SUF} \ - ${SYSOBJS} - -TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \ - tw.comp.c tw.color.c -TWOBJS= tw.help.${SUF} tw.init.${SUF} tw.parse.${SUF} tw.spell.${SUF} \ - tw.comp.${SUF} tw.color.${SUF} - -EDSRCS= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \ - ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h -EDOBJS= ed.chared.${SUF} ed.refresh.${SUF} ed.screen.${SUF} ed.init.${SUF} \ - ed.inputl.${SUF} ed.defns.${SUF} ed.xmap.${SUF} ed.term.${SUF} - -TCSRCS= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \ - tc.func.c tc.nls.c tc.nls.h tc.os.c tc.os.h tc.printf.c tc.prompt.c \ - tc.disc.${SUF} tc.func.${SUF} tc.nls.${SUF} tc.os.${SUF} \ - tc.printf.${SUF} tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h \ - tc.vers.c tc.wait.h tc.who.c tc.h -TCOBJS= tc.alloc.${SUF} tc.bind.${SUF} tc.const.${SUF} tc.defs.${SUF} \ - tc.disc.${SUF} tc.func.${SUF} tc.os.${SUF} tc.printf.${SUF} \ - tc.prompt.${SUF} tc.sched.${SUF} tc.sig.${SUF} tc.str.${SUF} \ - tc.vers.${SUF} tc.who.${SUF} - -MISCF = Makefile.std BUILDING Fixes MAKEDIFFS MAKESHAR NewThings README.md \ - FAQ WishList config_f.h eight-bit.me glob.3 patchlevel.h pathnames.h \ - tcsh.man Ported src.desc Imakefile imake.config complete.tcsh \ - Makefile.vms termcap.vms snames.h host.defs gethost.c tcsh.man2html \ - Makefile.in configure.ac Makefile.win32 aclocal.m4 dot.login dot.tcshrc -CONFSRCS=config/[a-z]* - - -SRCS = $(SHSRCS) $(TWSRCS) $(EDSRCS) $(TCSRCS) -OBJS = $(SHOBJS) $(TWOBJS) $(EDOBJS) $(TCOBJS) - -ALLSRCS= $(MISCF) $(SRCS) $(EXTF) - -AllTarget(tcsh) - -ed.defns.h: config.h ed.defns.c - @rm -f $@ - @echo '/* Do not edit this file, make creates it. */' > $@ - @echo '#ifndef _h_ed_defns' >> $@ - @echo '#define _h_ed_defns' >> $@ - egrep '[FV]_' ed.defns.c | egrep '^#define' >> $@ - @echo '#endif /* _h_ed_defns */' >> $@ - -sh.err.h: config.h sh.err.c - @rm -f $@ - @echo '/* Do not edit this file, make creates it. */' > $@ - @echo '#ifndef _h_sh_err' >> $@ - @echo '#define _h_sh_err' >> $@ - egrep 'ERR_' sh.err.c | egrep '^#define' >> $@ - @echo '#endif /* _h_sh_err */' >> $@ - -tc.const.h: config.h tc.const.c - @rm -f $@ - @echo '/* Do not edit this file, make creates it. */' > $@ - @echo '#ifndef _h_tc_const' >> $@ - @echo '#define _h_tc_const' >> $@ - ${CC} -E $(INCLUDES) ${DEFINES} -D_h_tc_const tc.const.c | \ - grep 'Char STR' | \ - sed -e 's/Char \([a-zA-Z0-9_]*\)\[\].*/extern Char \1[];/' | \ - sort >> $@ - @echo '#endif /* _h_tc_const */' >> $@ - -config.h: config_f.h - cp config/ConfigH config.h - -$(OBJS): sh.err.h tc.const.h ed.defns.h - -tar.Z: - rm -f tcsh-${VERSION}.tar.Z - rm -rf tcsh-${VERSION} - mkdir tcsh-${VERSION} tcsh-${VERSION}/config - cp ${ALLSRCS} tcsh-${VERSION} - cp ${CONFSRCS} tcsh-${VERSION}/config - tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -) - tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z - rm -rf tcsh-${VERSION} - -tar.gz: - rm -f tcsh-${VERSION}.tar.gz - rm -rf tcsh-${VERSION} - mkdir tcsh-${VERSION} tcsh-${VERSION}/config - cp ${ALLSRCS} tcsh-${VERSION} - cp ${CONFSRCS} tcsh-${VERSION}/config - tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -) - tar cvf - tcsh-${VERSION} | gzip > tcsh-${VERSION}.tar.gz - rm -rf tcsh-${VERSION} - -shar: - rm -f tcsh-*.shar - rm -rf tcsh-${VERSION} - mkdir tcsh-${VERSION} tcsh-${VERSION}/config - cp ${ALLSRCS} tcsh-${VERSION} - cp ${CONFSRCS} tcsh-${VERSION}/config - tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -) - MAKESHAR -v -n tcsh-${VERSION} tcsh-${VERSION} \ - tcsh-${VERSION}/?* tcsh-${VERSION}/config/?* \ - tcsh-${VERSION}/?*/set?* - rm -rf tcsh-${VERSION} - -catalogs: - @(cd nls; make catalogs) - -world: - $(MAKE) clean ; $(MAKE) depend ; $(MAKE) tcsh ; $(MAKE) install - -clean:: - rm -f ed.defns.h sh.err.h tc.const.h config.h tc.defs.* - rm -f tcsh.*.m tcsh.*.cat - -depend:: config.h ed.defns.h sh.err.h tc.const.h $(SRCS) tc.defs.c - -tc.defs.${SUF}: tc.defs.c sh.h - -tc.defs.c: gethost host.defs - @rm -f $@ - @echo "/* Do not edit this file, make creates it */" > $@ - ./gethost host.defs >> $@ - -ALIB=$(HESLIB) $(AFSLIB) $(SYSLIBS) -AINC=ed.defns.h sh.err.h tc.const.h sh.h - -NormalProgramTarget(tcsh, $(OBJS), $(AINC), $(LOCALLIBS), $(ALIB)) -NormalProgramTarget(gethost, gethost.${SUF}, $(AINC), $(LOCALLIBS), $(ALIB)) - -InstallProgram(tcsh,$(TCSH_BINDIR)) -InstallManPage(tcsh,$(TCSH_MANDIR)) -DependTarget() diff --git a/contrib/tcsh/MAKEDIFFS b/contrib/tcsh/MAKEDIFFS deleted file mode 100755 index be0e5b242668..000000000000 --- a/contrib/tcsh/MAKEDIFFS +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# MAKEDIFFS.sh: Make context diffs for the csh sources -# -XINUDIR=/usr/share/src/mtXinu/bin/csh -BSDDIR=/usr/share/src/mtXinu/BSD/bin/csh -TAHOEDIR=/usr/share/src/mtXinu/TAHOE/bin/csh -RENODIR=/usr/share/src/mtXinu/RENO/bin/csh -TCSHDIR=`pwd` -case "x$1" in -xxinu) - CSHDIR=$XINUDIR;; -xbsd) - CSHDIR=$BSDDIR;; -xtahoe) - CSHDIR=$TAHOEDIR;; -xreno) - CSHDIR=$RENODIR;; -x*) - echo "Usage: `basename $0` [bsd|tahoe|xinu|reno]";exit 1;; -esac -DIFF1='sh.c sh.char.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.exp.c sh.file.c' -DIFF2='sh.func.c sh.glob.c sh.hist.c sh.init.c sh.lex.c sh.misc.c sh.parse.c sh.print.c' -DIFF3='sh.proc.c sh.sem.c sh.set.c sh.time.c sh.char.h sh.dir.h sh.h sh.local.h sh.proc.h' - -for i in $DIFF1 -do - diff -c $CSHDIR/$i $TCSHDIR/$i -done > DIFFS.1 - -for i in $DIFF2 -do - diff -c $CSHDIR/$i $TCSHDIR/$i -done > DIFFS.2 - -for i in $DIFF3 -do - diff -c $CSHDIR/$i $TCSHDIR/$i -done > DIFFS.3 -exit 0 diff --git a/contrib/tcsh/MAKESHAR b/contrib/tcsh/MAKESHAR deleted file mode 100755 index 48c73b7c74ab..000000000000 --- a/contrib/tcsh/MAKESHAR +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# -# MAKESHAR.sh: Make a shar file for the sources -# - -AWK=/usr/bin/nawk # Must be nawk or gawk cause of 2D arrays -WC=/usr/ucb/wc -GREP=/usr/bin/egrep -SORT=/usr/bin/sort -SH=/bin/sh - -dirs= -name=kit -files= -verbose=0 -size=45000 - -for i -do - case $i in - -n) - name=;; - -v) - verbose=1;; - -d) - SH=/bin/cat;; - -s) - size=$1;; - *) - if [ -z "$name" ] - then - name=$i - elif [ -d $i ] - then - dirs="$dirs $i" - elif [ -f $i ] - then - files="$files $i" - else - echo "$0: File `$i' not found." 1>&2 - exit 1 - fi;; - esac -done - -if [ \( -z "$files" \) -a \( -z "$dirs" \) ] -then - echo "Usage: $0 [-n name] [-s size] [-vd] ." 1>&2 - exit 1 -fi - -$WC $files | $GREP -v total | $SORT +2 | $AWK ' - BEGIN { - i = 0; - seq = 1; - size = 0; - name = 1; - used = 2; - verbose='"$verbose"'; - tty = "/dev/tty"; - maxsize = '"$size"'; - dirs = "'"$dirs"'"; - }; - { - a[i, size] = $3; - a[i, name] = $4; - a[i, used] = 0; - i++; - }; - END { - for (maxi = i--; i >= 0; i--) { - idx = 0; - if (a[i, used] == 0) { - if (verbose && a[i, size] > maxsize) - printf("Warning: File %s is %d > %d\n", - a[i, name], a[i, size], maxsize) > tty; - s = a[i, size]; - a[i, used] = 1; - kit[seq, idx++] = i; - j = 0; - while (j < maxi) { - # Find the greatest file we can add - j = maxi; - for (k = 0; k < maxi; k++) - if (a[k, used] == 0 && a[k, size] + s < maxsize) - j = k; - if (j < maxi) { - s += a[j, size]; - a[j, used] = 1; - kit[seq, idx++] = j; - } - } - sizes[seq] = s; - kit[seq++, idx] = -1; - } - } - for (i = 1; i < seq; i++) { - printf("shar -n%d -e%d %s ", i, seq - 1, dirs); - if (verbose) { - printf("%3d of %3d: ", i, seq - 1) > tty; - len = 12; - } - for (j = 0; kit[i, j] != -1; j++) { - s = a[kit[i, j], name]; - if (verbose) { - clen = length(s) + 1; - len += clen; - if (len > 70) { - printf("\n ") > tty; - len = 12 + clen; - } - printf("%s ", s) > tty; - } - printf("%s ", s); - } - printf("> '"$name"'-%d.shar;", i); - if (verbose) - printf("= %5d\n", sizes[i]) > tty; - } - }' | $SH diff --git a/contrib/tcsh/Makefile.ADMIN b/contrib/tcsh/Makefile.ADMIN deleted file mode 100644 index 5ad3bb8fb3c5..000000000000 --- a/contrib/tcsh/Makefile.ADMIN +++ /dev/null @@ -1,24 +0,0 @@ -# -# Makefile.ADMIN -# -# Maintenance tasks -# -# You can refetch files from the website, then run "git diff" to -# sanity check any changes before committing. -# - -LYNX= lynx -dump -nolist -TRIM= expand | sed -e 's/^ *$$//' | cat -s -WEB= https://www.tcsh.org - -PAGES= FAQ - -all: ${PAGES} - -.for i in ${PAGES} -$i: force - ${LYNX} ${WEB}/${i:tl}/ | ${TRIM} > ${.TARGET} -.endfor - -.DUMMY: force -force: diff --git a/contrib/tcsh/Makefile.in b/contrib/tcsh/Makefile.in deleted file mode 100644 index c6b5f2554cc0..000000000000 --- a/contrib/tcsh/Makefile.in +++ /dev/null @@ -1,782 +0,0 @@ -# -# C Shell with process control; VM/UNIX VAX Makefile -# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria -# -# With an input editor, command completion, etc. and ported to all sorts of -# things; Paul Placeway, CIS Dept., Ohio State University -# -SHELL=/bin/sh -ENVCMD=/usr/bin/env -VERSION=@PACKAGE_VERSION@ -BUILD=tcsh$(EXEEXT) -VPATH=@srcdir@ -srcdir=@srcdir@ - -################################################################ -## CFLAGS. For various -D things, see config.h -################################################################ -# -# These are the default suffixes from .c to .o and -c to get there -# but to use the global optimizer on the mips boxes, see below -# -SUF=o -CF=-c - -CPPFLAGS=-I. -I$(srcdir) - -LFLAGS= -# hpux lint -#LFLAGS= -Zn10000 - - -# This is set by autoconf: -CFLAGS = @CFLAGS@ -# debug: -#CFLAGS= -g -# production: -#CFLAGS= -O -# Broken optimizers.... -#CFLAGS= - -#CFLAGS= -g -pg -DPROF -#CFLAGS= -O -pg -DPROF - -# gcc 1.00-1.37 -#CFLAGS= -O -finline-functions -fstrength-reduce - -# gcc 1.37-1.40 -#CFLAGS= -O -fcombine-regs -finline-functions -fstrength-reduce -# add -msoft-float for 68881 machines. - -# gcc 2.0 -# On the sparc, don't use -O2; it breaks setjmp() and vfork() -#CFLAGS= -O - -# gcc-2.1+ -#CFLAGS= -O2 - -# lucid c on suns -#CFLAGS= -O5 - -# gcc 2.1 on linux -#CFLAGS= -O6 -fomit-frame-pointer - -# HP/UX 8.0, 9.0 -#CFLAGS= +O3 -Aa - -# Ultrix 4.2a -#CFLAGS= -O -Olimit 2000 - -# Intel Paragon OSF/1 with PGI compilers -#CFLAGS= -O -Mnodebug -Mnoperfmon - -# DEC Alpha OSF/1 -## Normal Optimization -#CFLAGS= -O2 -Olimit 2000 -## Full Optimization - may not work -#CFLAGS= -O3 -Olimit 2000 -#CF=-j -#SUF=u -#.SUFFIXES: .u *** 15513 LINES SKIPPED *** From owner-dev-commits-src-main@freebsd.org Wed May 19 21:30:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1220064C443; Wed, 19 May 2021 21:30: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 4FlmJ268sSz4jJL; Wed, 19 May 2021 21: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 B17591A04B; Wed, 19 May 2021 21: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 14JLUgSa010614; Wed, 19 May 2021 21: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 14JLUgvX010613; Wed, 19 May 2021 21:30:42 GMT (envelope-from git) Date: Wed, 19 May 2021 21:30:42 GMT Message-Id: <202105192130.14JLUgvX010613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6560ac57ce87 - main - tcsh: update to version 6.22.04. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6560ac57ce879857203bc456cdc3849808dc0700 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:30:43 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6560ac57ce879857203bc456cdc3849808dc0700 commit 6560ac57ce879857203bc456cdc3849808dc0700 Merge: 6190ff6104ae 174d8b60324d Author: Dmitry Chagin AuthorDate: 2021-05-19 21:12:27 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-19 21:12:27 +0000 tcsh: update to version 6.22.04. Merge commit '174d8b60324d7e8754709f7155e13ca95220b48c' into main. MFC After: 2 weeks contrib/tcsh/Fixes | 1 + contrib/tcsh/ed.chared.c | 98 ++++++++++++++++---------------- contrib/tcsh/ed.defns.c | 10 ++-- contrib/tcsh/ed.h | 10 +++- contrib/tcsh/ed.init.c | 48 ++++++++-------- contrib/tcsh/ed.inputl.c | 20 +++---- contrib/tcsh/ed.refresh.c | 16 +++--- contrib/tcsh/ed.screen.c | 18 +++--- contrib/tcsh/ed.term.c | 34 ++++++------ contrib/tcsh/ed.term.h | 6 +- contrib/tcsh/ed.xmap.c | 10 ++-- contrib/tcsh/gethost.c | 8 +-- contrib/tcsh/glob.c | 18 +++--- contrib/tcsh/glob.h | 2 +- contrib/tcsh/ma.setp.c | 4 +- contrib/tcsh/mi.termios.c | 2 +- contrib/tcsh/mi.wait.h | 2 +- contrib/tcsh/patchlevel.h | 4 +- contrib/tcsh/sh.c | 100 ++++++++++++++++----------------- contrib/tcsh/sh.char.c | 136 ++++++++++++++++++++++----------------------- contrib/tcsh/sh.char.h | 2 +- contrib/tcsh/sh.decls.h | 14 ++--- contrib/tcsh/sh.dir.c | 44 +++++++-------- contrib/tcsh/sh.dol.c | 10 ++-- contrib/tcsh/sh.err.c | 2 +- contrib/tcsh/sh.exec.c | 10 ++-- contrib/tcsh/sh.exp.c | 44 +++++++-------- contrib/tcsh/sh.file.c | 2 +- contrib/tcsh/sh.func.c | 84 ++++++++++++++-------------- contrib/tcsh/sh.glob.c | 18 +++--- contrib/tcsh/sh.h | 36 ++++++------ contrib/tcsh/sh.hist.c | 46 +++++++++------ contrib/tcsh/sh.init.c | 12 ++-- contrib/tcsh/sh.lex.c | 16 +++--- contrib/tcsh/sh.misc.c | 6 +- contrib/tcsh/sh.parse.c | 1 + contrib/tcsh/sh.print.c | 6 +- contrib/tcsh/sh.proc.c | 28 +++++----- contrib/tcsh/sh.sem.c | 22 ++++---- contrib/tcsh/sh.set.c | 16 +++--- contrib/tcsh/sh.time.c | 6 +- contrib/tcsh/sh.types.h | 36 ++++++------ contrib/tcsh/tc.alloc.c | 18 +++--- contrib/tcsh/tc.bind.c | 4 +- contrib/tcsh/tc.const.c | 20 +++---- contrib/tcsh/tc.decls.h | 4 +- contrib/tcsh/tc.func.c | 32 +++++------ contrib/tcsh/tc.os.c | 52 ++++++++--------- contrib/tcsh/tc.os.h | 22 ++++---- contrib/tcsh/tc.printf.c | 4 +- contrib/tcsh/tc.prompt.c | 10 ++-- contrib/tcsh/tc.str.c | 8 +-- contrib/tcsh/tc.vers.c | 22 ++++---- contrib/tcsh/tc.who.c | 8 +-- contrib/tcsh/tcsh.man | 4 +- contrib/tcsh/tw.color.c | 6 +- contrib/tcsh/tw.comp.c | 14 ++--- contrib/tcsh/tw.h | 2 +- contrib/tcsh/tw.init.c | 18 +++--- contrib/tcsh/tw.parse.c | 48 ++++++++-------- contrib/tcsh/vms.termcap.c | 2 +- 61 files changed, 663 insertions(+), 643 deletions(-) diff --cc contrib/tcsh/glob.c index bd9856c8a8af,000000000000..a5a21f1f715c mode 100644,000000..100644 --- a/contrib/tcsh/glob.c +++ b/contrib/tcsh/glob.c @@@ -1,801 -1,0 +1,801 @@@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * 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. + */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)glob.c 5.12 (Berkeley) 6/24/91"; +#endif /* LIBC_SCCS and not lint */ +/* + * Glob: the interface is a superset of the one defined in POSIX 1003.2, + * draft 9. + * + * The [!...] convention to negate a range is supported (SysV, Posix, ksh). + * + * Optional extra services, controlled by flags not defined by POSIX: + * + * GLOB_QUOTE: + * Escaping convention: \ inhibits any special meaning the following + * character might have (except \ at end of string is retained). + * GLOB_MAGCHAR: + * Set in gl_flags if pattern contained a globbing character. + * GLOB_ALTNOT: + * Use ^ instead of ! for "not". + * gl_matchc: + * Number of matches in the current invocation of glob. + */ + +#ifdef WINNT_NATIVE + #pragma warning(disable:4244) +#endif /* WINNT_NATIVE */ + +#define Char __Char +#include "sh.h" +#include "glob.h" + +#ifndef HAVE_MBLEN +#undef mblen +#define mblen(_s,_n) mbrlen((_s),(_n),NULL) +#endif + +#undef Char +#undef QUOTE +#undef TILDE +#undef META +#undef ismeta +#undef Strchr + +#ifndef S_ISDIR +#define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR) +#endif + +#if !defined(S_ISLNK) && defined(S_IFLNK) +#define S_ISLNK(a) (((a) & S_IFMT) == S_IFLNK) +#endif + +#if !defined(S_ISLNK) && !defined(lstat) +#define lstat stat +#endif + +typedef unsigned short Char; + +static int glob1 (Char *, glob_t *, int); +static int glob2 (struct strbuf *, const Char *, glob_t *, int); +static int glob3 (struct strbuf *, const Char *, const Char *, + const Char *, glob_t *, int); +static void globextend (const char *, glob_t *); +static int match (const char *, const Char *, const Char *, + int); +static int compare (const void *, const void *); +static DIR *Opendir (const char *); +#ifdef S_IFLNK +static int Lstat (const char *, struct stat *); +#endif +static int Stat (const char *, struct stat *sb); +static Char *Strchr (Char *, int); +#ifdef DEBUG +static void qprintf (const char *, const Char *); +#endif + +#define DOLLAR '$' +#define DOT '.' +#define EOS '\0' +#define LBRACKET '[' +#define NOT '!' +#define ALTNOT '^' +#define QUESTION '?' +#define QUOTE '\\' +#define RANGE '-' +#define RBRACKET ']' +#define SEP '/' +#define STAR '*' +#define TILDE '~' +#define UNDERSCORE '_' + +#define M_META 0x8000 +#define M_PROTECT 0x4000 +#define M_MASK 0xffff +#define M_ASCII 0x00ff + +#define LCHAR(c) ((c)&M_ASCII) +#define META(c) ((c)|M_META) +#define M_ALL META('*') +#define M_END META(']') +#define M_NOT META('!') +#define M_ALTNOT META('^') +#define M_ONE META('?') +#define M_RNG META('-') +#define M_SET META('[') +#define ismeta(c) (((c)&M_META) != 0) + +int +globcharcoll(__Char c1, __Char c2, int cs) +{ +#if defined(NLS) && defined(LC_COLLATE) && defined(HAVE_STRCOLL) +# if defined(WIDE_STRINGS) + wchar_t s1[2], s2[2]; + + if (c1 == c2) + return (0); + if (cs) { + c1 = towlower(c1); + c2 = towlower(c2); + } else { +#ifndef __FreeBSD__ + /* This should not be here, but I'll rather leave it in than engage in + a LC_COLLATE flamewar about a shell I don't use... */ + if (iswlower(c1) && iswupper(c2)) + return (1); + if (iswupper(c1) && iswlower(c2)) + return (-1); +#endif + } + s1[0] = c1; + s2[0] = c2; + s1[1] = s2[1] = '\0'; + return wcscoll(s1, s2); +# else /* not WIDE_STRINGS */ + char s1[2], s2[2]; + + if (c1 == c2) + return (0); + /* + * From kevin lyda : + * strcoll does not guarantee case sorting, so we pre-process now: + */ + if (cs) { + c1 = islower(c1) ? c1 : tolower(c1); + c2 = islower(c2) ? c2 : tolower(c2); + } else { + if (islower(c1) && isupper(c2)) + return (1); + if (isupper(c1) && islower(c2)) + return (-1); + } + s1[0] = c1; + s2[0] = c2; + s1[1] = s2[1] = '\0'; + return strcoll(s1, s2); +# endif +#else + return (c1 - c2); +#endif +} + +/* + * Need to dodge two kernel bugs: + * opendir("") != opendir(".") + * NAMEI_BUG: on plain files trailing slashes are ignored in some kernels. + * POSIX specifies that they should be ignored in directories. + */ + +static DIR * +Opendir(const char *str) +{ +#if defined(hpux) || defined(__hpux) + struct stat st; +#endif + + if (!*str) + return (opendir(".")); +#if defined(hpux) || defined(__hpux) + /* + * Opendir on some device files hangs, so avoid it + */ + if (stat(str, &st) == -1 || !S_ISDIR(st.st_mode)) + return NULL; +#endif + return opendir(str); +} + +#ifdef S_IFLNK +static int +Lstat(const char *fn, struct stat *sb) +{ + int st; + + st = lstat(fn, sb); +# ifdef NAMEI_BUG + if (*fn != 0 && strend(fn)[-1] == '/' && !S_ISDIR(sb->st_mode)) + st = -1; +# endif /* NAMEI_BUG */ + return st; +} +#else +#define Lstat Stat +#endif /* S_IFLNK */ + +static int +Stat(const char *fn, struct stat *sb) +{ + int st; + + st = stat(fn, sb); +#ifdef NAMEI_BUG + if (*fn != 0 && strend(fn)[-1] == '/' && !S_ISDIR(sb->st_mode)) + st = -1; +#endif /* NAMEI_BUG */ + return st; +} + +static Char * +Strchr(Char *str, int ch) +{ + do + if (*str == ch) + return (str); + while (*str++); + return (NULL); +} + +#ifdef DEBUG +static void +qprintf(const char *pre, const Char *s) +{ + const Char *p; - ++ + xprintf("%s", pre); + for (p = s; *p; p++) + xprintf("%c", *p & 0xff); + xprintf("\n%s", pre); + for (p = s; *p; p++) + xprintf("%c", *p & M_PROTECT ? '"' : ' '); + xprintf("\n%s", pre); + for (p = s; *p; p++) + xprintf("%c", *p & M_META ? '_' : ' '); + xprintf("\n"); +} +#endif /* DEBUG */ + +static int +compare(const void *p, const void *q) +{ +#if defined(NLS) && defined(HAVE_STRCOLL) + return (strcoll(*(char *const *) p, *(char *const *) q)); +#else + return (strcmp(*(char *const *) p, *(char *const *) q)); +#endif /* NLS && HAVE_STRCOLL */ +} + +/* + * The main glob() routine: compiles the pattern (optionally processing + * quotes), calls glob1() to do the real pattern matching, and finally + * sorts the list (unless unsorted operation is requested). Returns 0 + * if things went well, nonzero if errors occurred. It is not an error + * to find no matches. + */ +int +glob(const char *pattern, int flags, int (*errfunc) (const char *, int), + glob_t *pglob) +{ + int err, oldpathc; + Char *bufnext, m_not; + const unsigned char *patnext; + int c, not; + Char *qpatnext, *patbuf; + int no_match; + + patnext = (const unsigned char *) pattern; + if (!(flags & GLOB_APPEND)) { + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + if (!(flags & GLOB_DOOFFS)) + pglob->gl_offs = 0; + } + pglob->gl_flags = flags & ~GLOB_MAGCHAR; + pglob->gl_errfunc = errfunc; + oldpathc = pglob->gl_pathc; + pglob->gl_matchc = 0; + + if (pglob->gl_flags & GLOB_ALTNOT) { + not = ALTNOT; + m_not = M_ALTNOT; + } + else { + not = NOT; + m_not = M_NOT; + } + + patbuf = xmalloc((strlen(pattern) + 1) * sizeof(*patbuf)); + bufnext = patbuf; + + no_match = *patnext == not; + if (no_match) + patnext++; + + if (flags & GLOB_QUOTE) { + /* Protect the quoted characters */ + while ((c = *patnext++) != EOS) { +#ifdef WIDE_STRINGS + int len; - ++ + len = mblen((const char *)(patnext - 1), MB_LEN_MAX); + if (len == -1) + TCSH_IGNORE(mblen(NULL, 0)); + else if (len > 1) { + *bufnext++ = (Char) c; + while (--len != 0) + *bufnext++ = (Char) (*patnext++ | M_PROTECT); + } else +#endif /* WIDE_STRINGS */ + if (c == QUOTE) { + if ((c = *patnext++) == EOS) { + c = QUOTE; + --patnext; + } + *bufnext++ = (Char) (c | M_PROTECT); + } + else + *bufnext++ = (Char) c; + } + } + else + while ((c = *patnext++) != EOS) + *bufnext++ = (Char) c; + *bufnext = EOS; + + bufnext = patbuf; + qpatnext = patbuf; + while ((c = *qpatnext++) != EOS) { + switch (c) { + case LBRACKET: + c = *qpatnext; + if (c == not) + ++qpatnext; + if (*qpatnext == EOS || + Strchr(qpatnext + 1, RBRACKET) == NULL) { + *bufnext++ = LBRACKET; + if (c == not) + --qpatnext; + break; + } + pglob->gl_flags |= GLOB_MAGCHAR; + *bufnext++ = M_SET; + if (c == not) + *bufnext++ = m_not; + c = *qpatnext++; + do { + *bufnext++ = LCHAR(c); + if (*qpatnext == RANGE && + (c = qpatnext[1]) != RBRACKET) { + *bufnext++ = M_RNG; + *bufnext++ = LCHAR(c); + qpatnext += 2; + } + } while ((c = *qpatnext++) != RBRACKET); + *bufnext++ = M_END; + break; + case QUESTION: + pglob->gl_flags |= GLOB_MAGCHAR; + *bufnext++ = M_ONE; + break; + case STAR: + pglob->gl_flags |= GLOB_MAGCHAR; + /* collapse adjacent stars to one [or three if globstar], + * to avoid exponential behavior + */ + if (bufnext == patbuf || bufnext[-1] != M_ALL || - ((flags & GLOB_STAR) != 0 && ++ ((flags & GLOB_STAR) != 0 && + (bufnext - 1 == patbuf || bufnext[-2] != M_ALL || + bufnext - 2 == patbuf || bufnext[-3] != M_ALL))) + *bufnext++ = M_ALL; + break; + default: + *bufnext++ = LCHAR(c); + break; + } + } + *bufnext = EOS; +#ifdef DEBUG + qprintf("patbuf=", patbuf); +#endif + + if ((err = glob1(patbuf, pglob, no_match)) != 0) { + xfree(patbuf); + return (err); + } + + /* - * If there was no match we are going to append the pattern ++ * If there was no match we are going to append the pattern + * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified + * and the pattern did not contain any magic characters + * GLOB_NOMAGIC is there just for compatibility with csh. + */ - if (pglob->gl_pathc == oldpathc && - ((flags & GLOB_NOCHECK) || ++ if (pglob->gl_pathc == oldpathc && ++ ((flags & GLOB_NOCHECK) || + ((flags & GLOB_NOMAGIC) && !(pglob->gl_flags & GLOB_MAGCHAR)))) { + if (!(flags & GLOB_QUOTE)) + globextend(pattern, pglob); + else { + char *copy, *dest; + const char *src; + + /* copy pattern, interpreting quotes */ + copy = xmalloc(strlen(pattern) + 1); + dest = copy; + src = pattern; + while (*src != EOS) { + /* Don't interpret quotes. The spec does not say we should do */ + if (*src == QUOTE) { + if (*++src == EOS) + --src; + } + *dest++ = *src++; + } + *dest = EOS; + globextend(copy, pglob); + xfree(copy); + } + xfree(patbuf); + return 0; + } + else if (!(flags & GLOB_NOSORT) && (pglob->gl_pathc != oldpathc)) + qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, + pglob->gl_pathc - oldpathc, sizeof(char *), compare); + xfree(patbuf); + return (0); +} + +static int +glob1(Char *pattern, glob_t *pglob, int no_match) +{ + struct strbuf pathbuf = strbuf_INIT; + int err; + + /* + * a null pathname is invalid -- POSIX 1003.1 sect. 2.4. + */ + if (*pattern == EOS) + return (0); + err = glob2(&pathbuf, pattern, pglob, no_match); + xfree(pathbuf.s); + return err; +} + +/* + * functions glob2 and glob3 are mutually recursive; there is one level + * of recursion for each segment in the pattern that contains one or + * more meta characters. + */ +static int +glob2(struct strbuf *pathbuf, const Char *pattern, glob_t *pglob, int no_match) +{ + struct stat sbuf; + int anymeta; + const Char *p; + size_t orig_len; + + /* + * loop over pattern segments until end of pattern or until segment with + * meta character found. + */ + anymeta = 0; + for (;;) { + if (*pattern == EOS) { /* end of pattern? */ + strbuf_terminate(pathbuf); + + if (Lstat(pathbuf->s, &sbuf)) + return (0); + + if (((pglob->gl_flags & GLOB_MARK) && + pathbuf->s[pathbuf->len - 1] != SEP) && + (S_ISDIR(sbuf.st_mode) +#ifdef S_IFLNK + || (S_ISLNK(sbuf.st_mode) && + (Stat(pathbuf->s, &sbuf) == 0) && + S_ISDIR(sbuf.st_mode)) +#endif + )) { + strbuf_append1(pathbuf, SEP); + strbuf_terminate(pathbuf); + } + ++pglob->gl_matchc; + globextend(pathbuf->s, pglob); + return 0; + } + + /* find end of next segment, tentatively copy to pathbuf */ + p = pattern; + orig_len = pathbuf->len; + while (*p != EOS && *p != SEP) { + if (ismeta(*p)) + anymeta = 1; + strbuf_append1(pathbuf, *p++); + } + + if (!anymeta) { /* no expansion, do next segment */ + pattern = p; + while (*pattern == SEP) + strbuf_append1(pathbuf, *pattern++); + } + else { /* need expansion, recurse */ + pathbuf->len = orig_len; + return (glob3(pathbuf, pattern, p, pattern, pglob, no_match)); + } + } + /* NOTREACHED */ +} + +static size_t +One_Char_mbtowc(__Char *pwc, const Char *s, size_t n) +{ +#ifdef WIDE_STRINGS + char buf[MB_LEN_MAX], *p; + + if (n > MB_LEN_MAX) + n = MB_LEN_MAX; + p = buf; + while (p < buf + n && (*p++ = LCHAR(*s++)) != 0) + ; + return one_mbtowc(pwc, buf, n); +#else + *pwc = *s & CHAR; + return 1; +#endif +} - ++ +static int +glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern, + const Char *pglobstar, glob_t *pglob, int no_match) +{ + DIR *dirp; + struct dirent *dp; + struct stat sbuf; + int err; + Char m_not = (pglob->gl_flags & GLOB_ALTNOT) ? M_ALTNOT : M_NOT; + size_t orig_len; + int globstar = 0; + int chase_symlinks = 0; + const Char *termstar = NULL; + + strbuf_terminate(pathbuf); + orig_len = pathbuf->len; + errno = err = 0; + + while (pglobstar < restpattern) { + __Char wc; + size_t width = One_Char_mbtowc(&wc, pglobstar, MB_LEN_MAX); + if ((pglobstar[0] & M_MASK) == M_ALL && + (pglobstar[width] & M_MASK) == M_ALL) { + globstar = 1; + chase_symlinks = (pglobstar[2 * width] & M_MASK) == M_ALL; + termstar = pglobstar + (2 + chase_symlinks) * width; + break; + } + pglobstar += width; - } ++ } + + if (globstar) { + err = pglobstar==pattern && termstar==restpattern ? + *restpattern == EOS ? + glob2(pathbuf, restpattern - 1, pglob, no_match) : + glob2(pathbuf, restpattern + 1, pglob, no_match) : + glob3(pathbuf, pattern, restpattern, termstar, pglob, no_match); + if (err) + return err; + pathbuf->len = orig_len; + strbuf_terminate(pathbuf); + } + + if (*pathbuf->s && (Lstat(pathbuf->s, &sbuf) || !S_ISDIR(sbuf.st_mode) +#ifdef S_IFLINK + && ((globstar && !chase_symlinks) || !S_ISLNK(sbuf.st_mode)) +#endif + )) + return 0; + + if (!(dirp = Opendir(pathbuf->s))) { + /* todo: don't call for ENOENT or ENOTDIR? */ + if ((pglob->gl_errfunc && (*pglob->gl_errfunc) (pathbuf->s, errno)) || + (pglob->gl_flags & GLOB_ERR)) + return (GLOB_ABEND); + else + return (0); + } + + /* search directory for matching names */ + while ((dp = readdir(dirp)) != NULL) { + /* initial DOT must be matched literally */ + if (dp->d_name[0] == DOT && *pattern != DOT) + if (!(pglob->gl_flags & GLOB_DOT) || !dp->d_name[1] || + (dp->d_name[1] == DOT && !dp->d_name[2])) + continue; /*unless globdot and not . or .. */ + pathbuf->len = orig_len; + strbuf_append(pathbuf, dp->d_name); + strbuf_terminate(pathbuf); + + if (globstar) { +#ifdef S_IFLNK + if (!chase_symlinks && + (Lstat(pathbuf->s, &sbuf) || S_ISLNK(sbuf.st_mode))) + continue; +#endif + if (match(pathbuf->s + orig_len, pattern, termstar, - (int)m_not) == no_match) ++ (int)m_not) == no_match) + continue; + strbuf_append1(pathbuf, SEP); + strbuf_terminate(pathbuf); + if ((err = glob2(pathbuf, pglobstar, pglob, no_match)) != 0) + break; + } else { + if (match(pathbuf->s + orig_len, pattern, restpattern, + (int) m_not) == no_match) + continue; + if ((err = glob2(pathbuf, restpattern, pglob, no_match)) != 0) + break; + } + } + /* todo: check error from readdir? */ + closedir(dirp); + return (err); +} + + +/* + * Extend the gl_pathv member of a glob_t structure to accomodate a new item, + * add the new item, and update gl_pathc. + * + * This assumes the BSD realloc, which only copies the block when its size + * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic + * behavior. + * + * Return 0 if new item added, error code if memory couldn't be allocated. + * + * Invariant of the glob_t structure: + * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and + * gl_pathv points to (gl_offs + gl_pathc + 1) items. + */ +static void +globextend(const char *path, glob_t *pglob) +{ + char **pathv; + int i; + size_t newsize; + + newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); + pathv = xrealloc(pglob->gl_pathv, newsize); + + if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { + /* first time around -- clear initial gl_offs items */ + pathv += pglob->gl_offs; + for (i = pglob->gl_offs; --i >= 0;) + *--pathv = NULL; + } + pglob->gl_pathv = pathv; + + pathv[pglob->gl_offs + pglob->gl_pathc++] = strsave(path); + pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; +} + +/* + * pattern matching function for filenames. + */ +static int +match(const char *name, const Char *pat, const Char *patend, int m_not) +{ + int ok, negate_range; + const Char *patNext; + const char *nameNext, *nameStart, *nameEnd; + Char c; + + patNext = pat; + nameStart = nameNext = name; + nameEnd = NULL; + + while (pat < patend || *name) { + size_t lwk, pwk; + __Char wc, wk, wc1; + + c = *pat; /* Only for M_MASK bits */ + if (*name == EOS) + nameEnd = name; + + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + lwk = one_mbtowc(&wk, name, MB_LEN_MAX); + switch (c & M_MASK) { + case M_ALL: + while ((*(pat + pwk) & M_MASK) == M_ALL) { + pat += pwk; + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + } + patNext = pat; + nameNext = name + lwk; + pat += pwk; + continue; + case M_ONE: + if (*name == EOS) + break; + name += lwk; + pat += pwk; + continue; + case M_SET: + ok = 0; + if (*name == EOS) + break; + pat += pwk; + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + name += lwk; + if ((negate_range = ((*pat & M_MASK) == m_not)) != 0) { + pat += pwk; + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + } + wc1 = wc; + while ((*pat & M_MASK) != M_END) { + if ((*pat & M_MASK) == M_RNG) { + __Char wc2; + + pat += pwk; + pwk = One_Char_mbtowc(&wc2, pat, MB_LEN_MAX); + if (globcharcoll(wc1, wk, 0) <= 0 && + globcharcoll(wk, wc2, 0) <= 0) + ok = 1; + } else if (wc == wk) + ok = 1; + pat += pwk; + wc1 = wc; + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + } + pat += pwk; + pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); + if (ok == negate_range) + break; + continue; + default: + if (*name == EOS || samecase(wk) != samecase(wc)) + break; + name += lwk; + pat += pwk; + continue; + } + if (nameNext != nameStart + && (nameEnd == NULL || nameNext <= nameEnd)) { + pat = patNext; + name = nameNext; + continue; + } + return 0; + } + return 1; +} + +/* free allocated data belonging to a glob_t structure */ +void +globfree(glob_t *pglob) +{ + int i; + char **pp; + + if (pglob->gl_pathv != NULL) { + pp = pglob->gl_pathv + pglob->gl_offs; + for (i = pglob->gl_pathc; i--; ++pp) + if (*pp) + xfree(*pp), *pp = NULL; + xfree(pglob->gl_pathv), pglob->gl_pathv = NULL; + } +} From owner-dev-commits-src-main@freebsd.org Wed May 19 21:34:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2481F64C7C4; Wed, 19 May 2021 21:34: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 4FlmMq6WKPz4lyG; Wed, 19 May 2021 21:33: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 BF0551A1B7; Wed, 19 May 2021 21:33: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 14JLXxGW014927; Wed, 19 May 2021 21:33:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JLXxcs014926; Wed, 19 May 2021 21:33:59 GMT (envelope-from git) Date: Wed, 19 May 2021 21:33:59 GMT Message-Id: <202105192133.14JLXxcs014926@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 71a071be1c5a - main - bsd-family-tree: Add NetBSD 9.2 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/main X-Git-Reftype: branch X-Git-Commit: 71a071be1c5ae971421a830d76ee30186ffdd199 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:34:00 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=71a071be1c5ae971421a830d76ee30186ffdd199 commit 71a071be1c5ae971421a830d76ee30186ffdd199 Author: Warner Losh AuthorDate: 2021-05-19 21:29:11 +0000 Commit: Warner Losh CommitDate: 2021-05-19 21:31:47 +0000 bsd-family-tree: Add NetBSD 9.2 NetBSD 9.2 was released on May 12, 2021 Submitted by: Martin Husemann Sponsored by: Netflix --- share/misc/bsd-family-tree | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index e9eeae85f6bf..ac69e94502e0 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -420,11 +420,11 @@ FreeBSD 5.2 | | | | | | | | | | DragonFly 5.8.2 | | | | | | DragonFly 5.8.3 | | | | NetBSD 9.1 OpenBSD 6.8 | - | FreeBSD | | | | - | 12.2 | | | | - | | | | | - *--FreeBSD | | | | - | 13.0 | | OpenBSD 6.9 | + | FreeBSD | | | | | + | 12.2 | | | | | + | | | | | | + *--FreeBSD | | | | | + | 13.0 | | NetBSD 9.2 OpenBSD 6.9 | | | | | | FreeBSD 14 -current | NetBSD -current OpenBSD -current DragonFly -current | | | | | @@ -832,6 +832,7 @@ NetBSD 9.1 2020-10-18 [NBD] FreeBSD 12.2 2020-10-27 [FBD] FreeBSD 13.0 2021-04-13 [FBD] OpenBSD 6.9 2021-05-01 [OBD] +NetBSD 9.2 2021-05-12 [NBD] Bibliography ------------------------ From owner-dev-commits-src-main@freebsd.org Wed May 19 21:35:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4312564C936; Wed, 19 May 2021 21:35: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 4FlmPS1H00z4m9c; Wed, 19 May 2021 21:35: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 138EF1A131; Wed, 19 May 2021 21:35: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 14JLZN5i015133; Wed, 19 May 2021 21:35:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JLZNFr015132; Wed, 19 May 2021 21:35:23 GMT (envelope-from git) Date: Wed, 19 May 2021 21:35:23 GMT Message-Id: <202105192135.14JLZNFr015132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: fe815b88b553 - main - Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode". MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe815b88b553667c40353c46b58f9779efa3570e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:35:24 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=fe815b88b553667c40353c46b58f9779efa3570e commit fe815b88b553667c40353c46b58f9779efa3570e Author: Kirk McKusick AuthorDate: 2021-05-19 21:38:21 +0000 Commit: Kirk McKusick CommitDate: 2021-05-19 21:39:24 +0000 Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode". Pass 1b of fsck_ffs runs only when Pass 1 has found duplicate blocks. Pass 1 only knows that a block is duplicate when it finds the second instance of its use. The role of Pass 1b is to find the first use of all the duplicate blocks. It makes a pass over the cylinder groups looking for these blocks. When moving to the next cylinder group, Pass 1b failed to properly calculate the starting inode number for the cylinder group resulting in the above error message when it tried to read the first inode in the cylinder group. Reported by: Px Tested by: Px PR: 255979 MFC after: 3 days Sponsored by: Netflix --- sbin/fsck_ffs/pass1b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c index b44e0107c982..17a3b6495dc4 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -60,7 +60,6 @@ pass1b(void) memset(&idesc, 0, sizeof(struct inodesc)); idesc.id_func = pass1bcheck; duphead = duplist; - inumber = 0; for (c = 0; c < sblock.fs_ncg; c++) { if (got_siginfo) { printf("%s: phase 1b: cyl group %d of %d (%d%%)\n", @@ -77,6 +76,7 @@ pass1b(void) if (inosused == 0) continue; setinodebuf(c, inosused); + inumber = c * sblock.fs_ipg; for (i = 0; i < inosused; i++, inumber++) { if (inumber < UFS_ROOTINO) { (void)getnextinode(inumber, 0); From owner-dev-commits-src-main@freebsd.org Wed May 19 21:56:11 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C1A2164CF30; Wed, 19 May 2021 21:56: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 4FlmsR4xfQz3Bq2; Wed, 19 May 2021 21:56: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 8E3EA19E72; Wed, 19 May 2021 21:56: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 14JLuB57041838; Wed, 19 May 2021 21:56:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JLuBJT041837; Wed, 19 May 2021 21:56:11 GMT (envelope-from git) Date: Wed, 19 May 2021 21:56:11 GMT Message-Id: <202105192156.14JLuBJT041837@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: c28cb257ddfe - main - nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c28cb257ddfe3339756f6fd659fa4a2efa4de2cb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 21:56:11 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=c28cb257ddfe3339756f6fd659fa4a2efa4de2cb commit c28cb257ddfe3339756f6fd659fa4a2efa4de2cb Author: Rick Macklem AuthorDate: 2021-05-19 21:52:56 +0000 Commit: Rick Macklem CommitDate: 2021-05-19 21:52:56 +0000 nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease The most difficult NFSv4 client recovery case happens when the lease has expired on the server. For NFSv4.0, the client will receive a NFSERR_EXPIRED reply from the server to indicate this has happened. For NFSv4.1/4.2, most RPCs have a Sequence operation and, as such, the client will receive a NFSERR_BADSESSION reply when the lease has expired for these RPCs. The client will then call nfscl_recover() to handle the NFSERR_BADSESSION reply. However, for the expired lease case, the first reclaim Open will fail with NFSERR_NOGRACE. This patch recognizes this case and calls nfscl_expireclient() to handle the recovery from an expired lease. This patch only affects NFSv4.1/4.2 mounts when the lease expires on the server, due to a network partitioning that exceeds the lease duration or similar. MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clstate.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 8b5f07b5aa2a..1ed3630ce6e7 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -1996,6 +1996,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, u_int32_t delegtype = NFSV4OPEN_DELEGATEWRITE, mode; int i, igotlock = 0, error, trycnt, firstlock; struct nfscllayout *lyp, *nlyp; + bool recovered_one; /* * First, lock the client structure, so everyone else will @@ -2077,6 +2078,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, * Now traverse the state lists, doing Open and Lock Reclaims. */ tcred = newnfs_getcred(); + recovered_one = false; owp = LIST_FIRST(&clp->nfsc_owner); while (owp != NULL) { nowp = LIST_NEXT(owp, nfsow_list); @@ -2110,6 +2112,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, op->nfso_mode, op, NULL, 0, &ndp, 1, delegtype, tcred, p); if (!error) { + recovered_one = true; /* Handle any replied delegation */ if (ndp != NULL && ((ndp->nfsdl_flags & NFSCLDL_WRITE) || NFSMNT_RDONLY(nmp->nm_mountp))) { @@ -2168,6 +2171,21 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, nfscl_freelockowner(lp, 0); lp = nlp; } + } else if (error == NFSERR_NOGRACE && !recovered_one && + NFSHASNFSV4N(nmp)) { + /* + * For NFSv4.1/4.2, the NFSERR_EXPIRED case will + * actually end up here, since the client will do + * a recovery for NFSERR_BADSESSION, but will get + * an NFSERR_NOGRACE reply for the first "reclaim" + * attempt. + * So, call nfscl_expireclient() to recover the + * opens as best we can and then do a reclaim + * complete and return. + */ + nfsrpc_reclaimcomplete(nmp, cred, p); + nfscl_expireclient(clp, nmp, tcred, p); + goto out; } } if (error != 0 && error != NFSERR_BADSESSION) @@ -2254,6 +2272,23 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, if (error) { if (nop != NULL) free(nop, M_NFSCLOPEN); + if (error == NFSERR_NOGRACE && !recovered_one && + NFSHASNFSV4N(nmp)) { + /* + * For NFSv4.1/4.2, the NFSERR_EXPIRED case will + * actually end up here, since the client will do + * a recovery for NFSERR_BADSESSION, but will get + * an NFSERR_NOGRACE reply for the first "reclaim" + * attempt. + * So, call nfscl_expireclient() to recover the + * opens as best we can and then do a reclaim + * complete and return. + */ + nfsrpc_reclaimcomplete(nmp, cred, p); + nfscl_expireclient(clp, nmp, tcred, p); + free(nowp, M_NFSCLOWNER); + goto out; + } /* * Couldn't reclaim it, so throw the state * away. Ouch!! @@ -2261,6 +2296,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, nfscl_cleandeleg(dp); nfscl_freedeleg(&clp->nfsc_deleg, dp, true); } else { + recovered_one = true; LIST_INSERT_HEAD(&extra_open, nop, nfso_list); } } From owner-dev-commits-src-main@freebsd.org Wed May 19 22:25:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC0B164D2EC; Wed, 19 May 2021 22:25: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 4FlnW94MBWz3jpn; Wed, 19 May 2021 22:25:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74A1C1ABC9; Wed, 19 May 2021 22:25:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14JMPPGM081855; Wed, 19 May 2021 22:25:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JMPPgA081854; Wed, 19 May 2021 22:25:25 GMT (envelope-from git) Date: Wed, 19 May 2021 22:25:25 GMT Message-Id: <202105192225.14JMPPgA081854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 96480d9b338b - main - cam_sim: add doxygen to cam_sim_alloc_dev 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/main X-Git-Reftype: branch X-Git-Commit: 96480d9b338bd501d1a92bd961a0776ff0c39f71 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 22:25:25 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=96480d9b338bd501d1a92bd961a0776ff0c39f71 commit 96480d9b338bd501d1a92bd961a0776ff0c39f71 Author: Warner Losh AuthorDate: 2021-05-16 15:37:26 +0000 Commit: Warner Losh CommitDate: 2021-05-19 21:59:09 +0000 cam_sim: add doxygen to cam_sim_alloc_dev cam_sim_alloc_dev was overlooked when cam_sim_alloc was documented. Add doxygen docs for it, pointing at cam_sim_alloc. Sponsored by: Netflix --- sys/cam/cam_sim.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/cam/cam_sim.c b/sys/cam/cam_sim.c index 5b6d43b81d5d..64427795426e 100644 --- a/sys/cam/cam_sim.c +++ b/sys/cam/cam_sim.c @@ -130,11 +130,19 @@ cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll, return (sim); } +/** + * @brief allocate a new sim and fill in the details with a device_t + * + * Just like @c cam_sim_alloc, but with an additional paramter. + * + * @param dev A newbus device that's associated with the + * sim. Must be non-NULL. + */ struct cam_sim * cam_sim_alloc_dev(sim_action_func sim_action, sim_poll_func sim_poll, - const char *sim_name, void *softc, device_t dev, - struct mtx *mtx, int max_dev_transactions, - int max_tagged_dev_transactions, struct cam_devq *queue) + const char *sim_name, void *softc, device_t dev, struct mtx *mtx, + int max_dev_transactions, int max_tagged_dev_transactions, + struct cam_devq *queue) { struct cam_sim *sim; From owner-dev-commits-src-main@freebsd.org Wed May 19 22:30:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 123F164D80E; Wed, 19 May 2021 22:30: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 4FlndQ6zdJz3lRm; Wed, 19 May 2021 22:30: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 D7B981ABD4; Wed, 19 May 2021 22:30: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 14JMUoI8090581; Wed, 19 May 2021 22:30:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JMUokt090580; Wed, 19 May 2021 22:30:50 GMT (envelope-from git) Date: Wed, 19 May 2021 22:30:50 GMT Message-Id: <202105192230.14JMUokt090580@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 77b637338a36 - main - alc(4): add support for Mikrotik 10/25G NIC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 77b637338a3656d4ccedb9798a3f98ac283962f4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 22:30:51 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=77b637338a3656d4ccedb9798a3f98ac283962f4 commit 77b637338a3656d4ccedb9798a3f98ac283962f4 Author: Konstantin Belousov AuthorDate: 2021-05-19 22:14:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-19 22:30:25 +0000 alc(4): add support for Mikrotik 10/25G NIC The new Mikrotik 10/25G NIC is mostly compatible with AR8151 hardware, with few exceptions: * card supports only 32bit DMA operations * card does not support write-one-to-clear semantics for interrupt status register * MDIO operations can take longer to complete This patch adds support for Mikrotik 10/25G NIC to the alc driver while maintaining support for all earlier HW. The patch was tested with FreeBSD main branch as of commit f4b38c360e63a6e66245efedbd6c070f9c0aee55 This was tested on Intel i7-4790K system with Mikrotik 10/25G NIC. This was tested on Intel i7-4790K system with RB44Ge (AR8151 based 4-port NIC) to verify backwards compatibility. PR: 256000 Submitted by: Gatis Peisenieks MFC after: 1 week --- sys/dev/alc/if_alc.c | 16 ++++++++++++++-- sys/dev/alc/if_alcreg.h | 8 ++++++++ sys/dev/alc/if_alcvar.h | 3 ++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index 255fea53acfa..eb906d60bcbe 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -1438,6 +1438,8 @@ alc_attach(device_t dev) case DEVICEID_ATHEROS_AR8151: case DEVICEID_ATHEROS_AR8151_V2: sc->alc_flags |= ALC_FLAG_APS; + if (CSR_READ_4(sc, ALC_MT_MAGIC) == MT_MAGIC) + sc->alc_flags |= ALC_FLAG_MT; /* FALLTHROUGH */ default: break; @@ -1977,6 +1979,8 @@ alc_dma_alloc(struct alc_softc *sc) int error, i; lowaddr = BUS_SPACE_MAXADDR; + if (sc->alc_flags & ALC_FLAG_MT) + lowaddr = BUS_SPACE_MAXSIZE_32BIT; again: /* Create parent DMA tag. */ error = bus_dma_tag_create( @@ -2219,7 +2223,7 @@ again: error = bus_dma_tag_create( bus_get_dma_tag(sc->alc_dev), /* parent */ 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ @@ -3339,6 +3343,11 @@ alc_intr(void *arg) sc = (struct alc_softc *)arg; + if (sc->alc_flags & ALC_FLAG_MT) { + taskqueue_enqueue(sc->alc_tq, &sc->alc_int_task); + return (FILTER_HANDLED); + } + status = CSR_READ_4(sc, ALC_INTR_STATUS); if ((status & ALC_INTRS) == 0) return (FILTER_STRAY); @@ -3416,7 +3425,10 @@ alc_int_task(void *arg, int pending) done: if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { /* Re-enable interrupts if we're running. */ - CSR_WRITE_4(sc, ALC_INTR_STATUS, 0x7FFFFFFF); + if (sc->alc_flags & ALC_FLAG_MT) + CSR_WRITE_4(sc, ALC_INTR_STATUS, 0); + else + CSR_WRITE_4(sc, ALC_INTR_STATUS, 0x7FFFFFFF); } ALC_UNLOCK(sc); } diff --git a/sys/dev/alc/if_alcreg.h b/sys/dev/alc/if_alcreg.h index 3b4ee133b01a..7668f0960d9f 100644 --- a/sys/dev/alc/if_alcreg.h +++ b/sys/dev/alc/if_alcreg.h @@ -1121,6 +1121,14 @@ #define MII_EXT_ANEG_NLP78 0x8027 #define ANEG_NLP78_120M_DEFAULT 0x8A05 +#define ALC_MT_MAGIC 0x1F00 +#define ALC_MT_MODE 0x1F04 +#define ALC_MT_SPEED 0x1F08 +#define ALC_MT_VERSION 0x1F0C + +#define MT_MAGIC 0xaabb1234 +#define MT_MODE_4Q BIT(0) + /* Statistics counters collected by the MAC. */ struct smb { /* Rx stats. */ diff --git a/sys/dev/alc/if_alcvar.h b/sys/dev/alc/if_alcvar.h index 8dea20196dae..926c80021858 100644 --- a/sys/dev/alc/if_alcvar.h +++ b/sys/dev/alc/if_alcvar.h @@ -239,6 +239,7 @@ struct alc_softc { #define ALC_FLAG_LINK_WAR 0x4000 #define ALC_FLAG_E2X00 0x8000 #define ALC_FLAG_LINK 0x10000 +#define ALC_FLAG_MT 0x20000 struct callout alc_tick_ch; struct alc_hw_stats alc_stats; @@ -284,6 +285,6 @@ do { \ #define ALC_TX_TIMEOUT 5 #define ALC_RESET_TIMEOUT 100 #define ALC_TIMEOUT 1000 -#define ALC_PHY_TIMEOUT 1000 +#define ALC_PHY_TIMEOUT 10000 #endif /* _IF_ALCVAR_H */ From owner-dev-commits-src-main@freebsd.org Wed May 19 22:57:35 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3119664DD56; Wed, 19 May 2021 22:57: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 4FlpDH0vRpz4S1n; Wed, 19 May 2021 22:57: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 07A321B40A; Wed, 19 May 2021 22:57: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 14JMvYlS021592; Wed, 19 May 2021 22:57:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JMvYaF021591; Wed, 19 May 2021 22:57:34 GMT (envelope-from git) Date: Wed, 19 May 2021 22:57:34 GMT Message-Id: <202105192257.14JMvYaF021591@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a9f0cf4838cb - main - cxgbe: Fix some merge-o's for the per-rxq iSCSI counters. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9f0cf4838cb1991707fa32e1cf363ea18076249 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 22:57:35 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a9f0cf4838cb1991707fa32e1cf363ea18076249 commit a9f0cf4838cb1991707fa32e1cf363ea18076249 Author: John Baldwin AuthorDate: 2021-05-19 22:56:31 +0000 Commit: John Baldwin CommitDate: 2021-05-19 22:56:31 +0000 cxgbe: Fix some merge-o's for the per-rxq iSCSI counters. I botched a few of the changes when rebasing the changes in 4b6ed0758dc6fad17081d7bd791cb0edbddbddb8 across the changes in 43bbae19483fbde0a91e61acad8a6e71e334c8b8. - Move the counter allocations into alloc_ofld_rxq(). - Free the counters freeing an ofld rxq. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D30267 --- sys/dev/cxgbe/t4_sge.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index ac79d8002784..8a5dc6acc745 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -4070,6 +4070,9 @@ alloc_ofld_rxq(struct vi_info *vi, struct sge_ofld_rxq *ofld_rxq, int idx, return (rc); } MPASS(ofld_rxq->iq.flags & IQ_SW_ALLOCATED); + ofld_rxq->rx_iscsi_ddp_setup_ok = counter_u64_alloc(M_WAITOK); + ofld_rxq->rx_iscsi_ddp_setup_error = + counter_u64_alloc(M_WAITOK); add_ofld_rxq_sysctls(&vi->ctx, oid, ofld_rxq); } @@ -4102,6 +4105,8 @@ free_ofld_rxq(struct vi_info *vi, struct sge_ofld_rxq *ofld_rxq) MPASS(!(ofld_rxq->iq.flags & IQ_HW_ALLOCATED)); free_iq_fl(vi->adapter, &ofld_rxq->iq, &ofld_rxq->fl); MPASS(!(ofld_rxq->iq.flags & IQ_SW_ALLOCATED)); + counter_u64_free(ofld_rxq->rx_iscsi_ddp_setup_ok); + counter_u64_free(ofld_rxq->rx_iscsi_ddp_setup_error); bzero(ofld_rxq, sizeof(*ofld_rxq)); } } @@ -4127,8 +4132,6 @@ add_ofld_rxq_sysctls(struct sysctl_ctx_list *ctx, struct sysctl_oid *oid, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "TOE iSCSI statistics"); children = SYSCTL_CHILDREN(oid); - ofld_rxq->rx_iscsi_ddp_setup_ok = counter_u64_alloc(M_WAITOK); - ofld_rxq->rx_iscsi_ddp_setup_error = counter_u64_alloc(M_WAITOK); SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "ddp_setup_ok", CTLFLAG_RD, &ofld_rxq->rx_iscsi_ddp_setup_ok, "# of times DDP buffer was setup successfully."); From owner-dev-commits-src-main@freebsd.org Wed May 19 22:57:36 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 897D964DFBD; Wed, 19 May 2021 22:57: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 4FlpDJ2RPZz4S4F; Wed, 19 May 2021 22:57: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 383CF1B40B; Wed, 19 May 2021 22:57: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 14JMvaNl021617; Wed, 19 May 2021 22:57:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JMvalt021616; Wed, 19 May 2021 22:57:36 GMT (envelope-from git) Date: Wed, 19 May 2021 22:57:36 GMT Message-Id: <202105192257.14JMvalt021616@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 671fd0ec8dbe - main - cxgbei: Remove unused sysctls. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 671fd0ec8dbe5fb9c02e4d9cb7080e427dc1048b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 22:57:36 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=671fd0ec8dbe5fb9c02e4d9cb7080e427dc1048b commit 671fd0ec8dbe5fb9c02e4d9cb7080e427dc1048b Author: John Baldwin AuthorDate: 2021-05-19 22:56:45 +0000 Commit: John Baldwin CommitDate: 2021-05-19 22:56:45 +0000 cxgbei: Remove unused sysctls. These were seemingly copied over from icl_soft. Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D30268 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index c4eb4a35ad31..d54464b63542 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -104,13 +104,6 @@ static MALLOC_DEFINE(M_CXGBEI, "cxgbei", "cxgbei(4)"); SYSCTL_NODE(_kern_icl, OID_AUTO, cxgbei, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Chelsio iSCSI offload"); -static int coalesce = 1; -SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, coalesce, CTLFLAG_RWTUN, - &coalesce, 0, "Try to coalesce PDUs before sending"); -static int partial_receive_len = 128 * 1024; -SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, partial_receive_len, CTLFLAG_RWTUN, - &partial_receive_len, 0, "Minimum read size for partially received " - "data segment"); static int sendspace = 1048576; SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, sendspace, CTLFLAG_RWTUN, &sendspace, 0, "Default send socket buffer size"); From owner-dev-commits-src-main@freebsd.org Wed May 19 22:57:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B83C64E0B3; Wed, 19 May 2021 22:57: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 4FlpDL662Mz4Rmr; Wed, 19 May 2021 22:57: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 76F631B210; Wed, 19 May 2021 22:57: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 14JMvbhB021641; Wed, 19 May 2021 22:57:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JMvbfE021640; Wed, 19 May 2021 22:57:37 GMT (envelope-from git) Date: Wed, 19 May 2021 22:57:37 GMT Message-Id: <202105192257.14JMvbfE021640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 3bede2908acc - main - cxgbei: Add tunable sysctls for the FirstBurstLength and MaxBurstLength. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3bede2908acc6cbc8e809d63d7c9b5fd95932dfb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 22:57:39 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3bede2908acc6cbc8e809d63d7c9b5fd95932dfb commit 3bede2908acc6cbc8e809d63d7c9b5fd95932dfb Author: John Baldwin AuthorDate: 2021-05-19 22:56:54 +0000 Commit: John Baldwin CommitDate: 2021-05-19 22:56:54 +0000 cxgbei: Add tunable sysctls for the FirstBurstLength and MaxBurstLength. Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D30269 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index d54464b63542..fce593b54032 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -104,6 +104,12 @@ static MALLOC_DEFINE(M_CXGBEI, "cxgbei", "cxgbei(4)"); SYSCTL_NODE(_kern_icl, OID_AUTO, cxgbei, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Chelsio iSCSI offload"); +static int first_burst_length = 8192; +SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, first_burst_length, CTLFLAG_RWTUN, + &first_burst_length, 0, "First burst length"); +static int max_burst_length = 2 * 1024 * 1024; +SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, max_burst_length, CTLFLAG_RWTUN, + &max_burst_length, 0, "Maximum burst length"); static int sendspace = 1048576; SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, sendspace, CTLFLAG_RWTUN, &sendspace, 0, "Default send socket buffer size"); @@ -1206,8 +1212,8 @@ icl_cxgbei_limits(struct icl_drv_limits *idl) idl->idl_max_send_data_segment_length = (1 << 24) - 1; /* These are somewhat arbitrary. */ - idl->idl_max_burst_length = 2 * 1024 * 1024; - idl->idl_first_burst_length = 8192; + idl->idl_max_burst_length = max_burst_length; + idl->idl_first_burst_length = first_burst_length; t4_iterate(cxgbei_limits, idl); From owner-dev-commits-src-main@freebsd.org Thu May 20 01:39:42 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9048C630C8E for ; Thu, 20 May 2021 01:39:42 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FlsqL3P5pz4fYL for ; Thu, 20 May 2021 01:39:42 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x830.google.com with SMTP id y12so11649422qtx.11 for ; Wed, 19 May 2021 18:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LRdrpbLhHwedpUus4wzNNszy5c4QqGGBw1NsfRXXkkg=; b=R5MzbBSA7vyxVC5PvmqSuveEDNJsh/UFHkK6bqnGd9ochXSjB/rsskVKBjVYmt0E0h XL8GNbIsqf7nbfA1CuHGYpFftgWU+wakXrW9laVAMbCg8Mnohr7/DAqD8QMmLerC7hcz Z9aORPwpesA4sdsOZaNHgGpRT2Jh/JLYZsJA83Wgpa+iRaiRsB3hivI0sLbToayMU8c3 NYiPha3jdTAJCBTW6w/zG8VPgVSJII4jnGWg6sj/daeVo9hoZXAfaOdk1bYMLnfeGUgp /5epDf3/dYdTUIgRfPNK0KCRi5aO4kmG95W1gIvkFDDxPOxig6j1XeNNvJKAVC2yRt7s 9ndQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LRdrpbLhHwedpUus4wzNNszy5c4QqGGBw1NsfRXXkkg=; b=EupBkmDQd4QAEBTy/j85NMTLRFIZXuqyRvlEC0kL/F0qZTe252Bcwj8O/a9biLoes6 g76nrCXF/fBuQJBXfyWkxC0ihK4VM8ufo3JCe5G5esGl3qY09wEwT6zYmx83QBVHHk6a IekmlqEKcBJUlJ0oN7kSrTYj2kQQg0TYOOgc6Ggh0CwZtryR7XZNK4EocZrGhKoza9sn jIsILTHkNtFjM5+q3NrXpMVJ4EFBnKHfebXqAgFPgNab19St1lnRkeljJV28drssA/km G/N3aYJM5AKK0fetkEZYIBjtedYErMOMNa1357m7H6PgIZO+ZZk+Ayjb1Fw+fWex8cPs 25AQ== X-Gm-Message-State: AOAM531qQDCuS6pX4AO70C2IPmXUlTZKHdjoz7iCXckbkqnA0r/sEfPj r3qNcBbcQtIrSyB1OuNm13cqX8weydVViddxPUlx7Q== X-Google-Smtp-Source: ABdhPJy7o2dF7ltEHI+4H9ZlwRjuAcMwQ4M3+sXRn6QmfGSGUlxnf8OYNchjnzmtfWop6Tsj/B8lPQkPfPEB3CdyrBY= X-Received: by 2002:a05:622a:588:: with SMTP id c8mr2618268qtb.49.1621474781496; Wed, 19 May 2021 18:39:41 -0700 (PDT) MIME-Version: 1.0 References: <202105191744.14JHi6fA008046@gitrepo.freebsd.org> <9BE6FB36-5958-4220-9C95-86DED767F6ED@freebsd.org> In-Reply-To: <9BE6FB36-5958-4220-9C95-86DED767F6ED@freebsd.org> From: Warner Losh Date: Wed, 19 May 2021 19:39:30 -0600 Message-ID: Subject: Re: git: 086feed850c3 - main - md5: Create md5sum, etc compatible programs To: Jessica Clarke Cc: Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4FlsqL3P5pz4fYL X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 01:39:42 -0000 On Wed, May 19, 2021, 12:32 PM Jessica Clarke wrote: > On 19 May 2021, at 18:44, Warner Losh wrote: > > > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3D086feed850c31c278f25c958b97992d= 024139896 > > > > commit 086feed850c31c278f25c958b97992d024139896 > > Author: Warner Losh > > AuthorDate: 2021-05-19 17:26:20 +0000 > > Commit: Warner Losh > > CommitDate: 2021-05-19 17:41:53 +0000 > > > > md5: Create md5sum, etc compatible programs > > > > On Linux, there's a similar set of programs to ours, but that end in > the > > letters 'sum'. These act basically like FreeBSD versions run with th= e > -r > > option. Add code so that when the program ends in 'sum' you get the > > linux -r behavior. This is enough to make most things that use sha*s= um > > work correctly (the -c / --check options, as well as the long args a= re > > not implemented). When running with the -sum programs, ignore -t > instead > > of running internal speed tests and make -c an error. > > > > Reviewed by: sef, and kp and allanjude (earlier version) > > Relnotes: yes > > Sponsored by: Netflix > > Differential Revision: https://reviews.freebsd.org/D30309 > > --- > > diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c > > index 96dfcede9711..4381ef124c7b 100644 > > --- a/sbin/md5/md5.c > > +++ b/sbin/md5/md5.c > > @@ -177,13 +177,32 @@ main(int argc, char *argv[]) > > char buf[HEX_DIGEST_LENGTH]; > > size_t len; > > unsigned digest; > > - const char* progname; > > + char *progname; > > + bool gnu_emu =3D false; > > This file doesn=E2=80=99t currently include stdbool.h explicitly, and app= arently > that > is not implicitly included by any of the headers on Linux (and I cannot > work > out where it comes from on FreeBSD). Could you please add the explicit > include > to fix cross-building? > Sure Thanks, > Jess > > From owner-dev-commits-src-main@freebsd.org Thu May 20 02:33:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08B9C6319BF; Thu, 20 May 2021 02:33:38 +0000 (UTC) (envelope-from zlei.huang@gmail.com) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Flv1Y6GDqz3KK8; Thu, 20 May 2021 02:33:37 +0000 (UTC) (envelope-from zlei.huang@gmail.com) Received: by mail-pg1-x52e.google.com with SMTP id k15so10787255pgb.10; Wed, 19 May 2021 19:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Maq6XDlK7RAjJcWDlFIMOPGZmpiFePUlNQvqCC4YrjY=; b=AcfKfxGr/C8jFoprti1j4XaZQwcrbKHwmsSzCvI7cT5VVXZBXkd3romjPHhO47uwdb Y5mmsk63/pKFtPX2/riIrFkplLE19S1BsMSTzAn1xQma8mlCYfIJLX1vfyXtljIeUZlY bNYNrP/QG/zMIjMtU6fXgu1GZb5gcFGB3TdsuHPU5et2q2CAnwehG3JzYVorb1i6/u31 CMTB/p55q05yY55Yg7bI8pItTlLGdhr9BtIljCXRZLbBK5EF/SqbhScp95U1nBL/U1LE LsVL/IQWbwTFJuEPDPMDxlj0/wkzG2PdepJ/RkJZQUIcDX6YB4p3jQvUs5CcNpE3pQKR L+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Maq6XDlK7RAjJcWDlFIMOPGZmpiFePUlNQvqCC4YrjY=; b=Rs+h8kQLEuP1xJdLzmFA/TswjoEXdQPM5nTD1XSBiy1O6Pyy6Oto1V60HjSTePWkbI gTmi3BfaWTbmO39C1h1L7vlOpm+uwP/p+n98tW4FvaIowVaCi8J7fyWVhs0DvQDE4rrw KxHeHsIyWTgBChyNJQzgoQT9XgKFZJmVw9vwun6apV0UlF0mJ2stQmRQNeaVvUXXI1BP /UV5kcQkSD/qFld+5DNHJyUADPPErYVsjMlWFQFSAYlIge/65gLjwJKMJzEasz+I1yEX jGJh0tjAcch8xPELq075Qr3xe0nIXZDHQfc0fPwh/FcQcCbGB6jBaIFOZIEoc5AoNZIN P08w== X-Gm-Message-State: AOAM533fTabNth7i16MjtICXLlodq5vX6LXtN2rXni3POIIVHlhqD0bF InndxsMPRrtHtqvJ9KGJ5eHMM7YFkr0Wu4Ak X-Google-Smtp-Source: ABdhPJwo1J1U80G3tMD0BUljzolbH2OSg1usU5dGdq/eOo/qWr3o/CKbmKtWW4rSSUBrSrlcVzzctA== X-Received: by 2002:a63:2686:: with SMTP id m128mr2188695pgm.406.1621478016422; Wed, 19 May 2021 19:33:36 -0700 (PDT) Received: from [192.168.10.252] ([112.66.183.133]) by smtp.gmail.com with ESMTPSA id u19sm543015pfn.158.2021.05.19.19.33.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 May 2021 19:33:35 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses From: Zhenlei Huang In-Reply-To: <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> Date: Thu, 20 May 2021 10:33:28 +0800 Cc: Lutz Donnerhacke , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> To: Joe Clarke , rgrimes@freebsd.org X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4Flv1Y6GDqz3KK8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 02:33:38 -0000 Hi joe, > On May 19, 2021, at 9:42 PM, Joe Clarke wrote: > > On 5/19/21 01:54, Lutz Donnerhacke wrote: >> On Tue, May 18, 2021 at 07:51:38PM -0400, Joe Clarke wrote: >>> Just out of curiosity, why remove the RFC reference from the comment? >> >> May you please include the author of the change for such questions? >> >>>> commit 3d846e48227e2e78c1e7b35145f57353ffda56ba >>>> Author: Zhenlei Huang >>>> AuthorDate: 2021-05-18 20:51:37 +0000 >>>> Commit: Lutz Donnerhacke >>>> CommitDate: 2021-05-18 20:59:46 +0000 >>>> >>>> The current implement of ip_input() reject packets destined for >>>> 169.254.0.0/16, but not those original from 169.254.0.0/16 link-local >>>> addresses. >>>> >>>> Fix to fully respect RFC 3927 section 2.7. >>>> >>>> PR: 255388 >>>> Reviewed by: donner, rgrimes, karels >>>> MFC after: 1 month >>>> Differential Revision: https://reviews.freebsd.org/D29968 >> >> I did only commit this differential, but set a month for MFC, exactly to >> have to opportunity to fix such mistakes. >> > > IMHO, I'd like to see the RFC reference remain. I see rgrimes response > that the RFC's can change with errata and bis docs, but the anchor still > provides additional context that one can use to learn more about why > this code exists, and they can chase any future forward references. RFC's indeed change, and I think it is common in network stack. Then we need guidelines to better regulate these. CC rgrimes . > > It was there in the initial code, and the commit message saw fit to > reference it again. Removing it just seems like lost context. To track down the changes of the code, I'd personally prefer git-blame. There's still RFC reference in the git commit message, though it is not fully consistent with the comments in the diff. > > Joe > > -- > PGP Key : http://www.marcuscom.com/pgp.asc From owner-dev-commits-src-main@freebsd.org Thu May 20 02:39:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 670D6631BBC; Thu, 20 May 2021 02:39:53 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Flv8m2S5dz3Ly0; Thu, 20 May 2021 02:39:52 +0000 (UTC) (envelope-from bjkfbsd@gmail.com) Received: by mail-ot1-x333.google.com with SMTP id 36-20020a9d0ba70000b02902e0a0a8fe36so13569714oth.8; Wed, 19 May 2021 19:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=81DEhEfWiVgW6/vax+rjmfI/ueXRe16uKlIVc/utYZs=; b=JVlXLaZpTFF/r6vkoFiXSmNQ7ymINVY1ayxjmfwoV0rWoHaEddn0wjIau6MU5Ez3xV Rw2QbgBQOYoddVbLAM4kt04zRvygYBLav0+1NEunWrpgYUWYqy6+fJaUfwLNIFlmJ+Wi bSat9Lb53k7wtcPAguV0JxH/QoVTQIGcAiK33AYiwgNWTjyrsIFsbnyJ6EmyFGY98BHP /mExdLWAwzrgT4X8l1lf3kU4Evx4DkE8lR2ZaCvTi4+oeYXYc5fepebMSiibpvqmDkj6 MHF0d64cKY51PDW6ZG8FnmKhisBErFaXan9nYX5bmSAWGwgoejimeoKkFWNazQuiUAzk 9VFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=81DEhEfWiVgW6/vax+rjmfI/ueXRe16uKlIVc/utYZs=; b=aDvIkffVYh0nCnsHqimC2Wxosbbv2Az098IarLtrHFo2xUpU5tzPmukSYuwDzDGis4 VDb+hq+5yPdqEXp/xUreYTPydZie4RZQy4i36nTLaw6Pj/YwKs6HPhyda8dXD765GRHw p+sp3DuHs+vjGWD2HmHcWCG1IN7C9ukKdhBmYL21SypPx7H3/jv6kmdDKUUQO62MBGdR Mjugb6/K66+2Kgk41LH5nkRbgHFxZihd5bGsHQRDN9CBlFuAFtz7L2nRxAGSDvTtvZM0 b5ijDULEtr9YvgQ57aqh6hqIbAPk8NzL3n3L8QqkPBgtdMFMuyxHQfL8ScN+vKFQv7iz dfig== X-Gm-Message-State: AOAM530//iFT1BUSzx7RmjqzRfukq/aUVjMolZsixGioHXbKHYEF9SVp y1Q9LH07m4lew5i4QnSvJs1FE4FJOhg9BZw/ZR0= X-Google-Smtp-Source: ABdhPJyMCBfT8F9f5UQt33OKmh6ZHAqdWZx+cEJVxkJ4mwvEeDbFllr9RCoABEt5DxZ7AJxi8ZBNWhfNZNt1DRWhxx4= X-Received: by 2002:a9d:2271:: with SMTP id o104mr2106195ota.201.1621478391335; Wed, 19 May 2021 19:39:51 -0700 (PDT) MIME-Version: 1.0 References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> In-Reply-To: <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> From: Benjamin Kaduk Date: Wed, 19 May 2021 19:39:40 -0700 Message-ID: Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses To: Zhenlei Huang Cc: Joe Clarke , "Rodney W. Grimes" , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4Flv8m2S5dz3Ly0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=JVlXLaZp; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of bjkfbsd@gmail.com designates 2607:f8b0:4864:20::333 as permitted sender) smtp.mailfrom=bjkfbsd@gmail.com X-Spamd-Result: default: False [-2.50 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCPT_COUNT_SEVEN(0.00)[7]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::333:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::333:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::333:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 02:39:53 -0000 On Wed, May 19, 2021 at 7:33 PM Zhenlei Huang wrote: > > IMHO, I'd like to see the RFC reference remain. I see rgrimes response > > that the RFC's can change with errata and bis docs, but the anchor still > > provides additional context that one can use to learn more about why > > this code exists, and they can chase any future forward references. > RFC's indeed change, and I think it is common in network stack. Then we > need guidelines to better regulate these. CC rgrimes . > Sorry, RFCs themselves do not change -- one of the distinctive features of RFCs is precisely that they are immutable once published. The sentiment that what the current RFC for a given topic is, can change, is something that I can agree with, but that's not quite what was being discussed. -Ben From owner-dev-commits-src-main@freebsd.org Thu May 20 04:52:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D02806349C2; Thu, 20 May 2021 04:52:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fly5P5YWyz52mw; Thu, 20 May 2021 04: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 A7B611FF76; Thu, 20 May 2021 04: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 14K4q9Cm099256; Thu, 20 May 2021 04: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 14K4q9gf099255; Thu, 20 May 2021 04:52:09 GMT (envelope-from git) Date: Thu, 20 May 2021 04:52:09 GMT Message-Id: <202105200452.14K4q9gf099255@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: 20eb96979392 - main - rc.d: connect sysctl_lastload MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 20eb969793921dce9e524d19fc02b84cabd98f74 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 04:52:09 -0000 The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=20eb969793921dce9e524d19fc02b84cabd98f74 commit 20eb969793921dce9e524d19fc02b84cabd98f74 Author: Eugene Grosbein AuthorDate: 2021-05-20 04:51:31 +0000 Commit: Eugene Grosbein CommitDate: 2021-05-20 04:51:31 +0000 rc.d: connect sysctl_lastload Add recently added sysctl_lastload. --- libexec/rc/rc.d/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index 63dc17eceeaf..0834d8c4c2a0 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -104,6 +104,7 @@ CONFS= DAEMON \ swap \ swaplate \ sysctl \ + sysctl_lastload \ syslogd \ sysvipc \ tmp \ From owner-dev-commits-src-main@freebsd.org Thu May 20 08:14:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DCF9A637F78; Thu, 20 May 2021 08:14: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 4Fm2Zf5rnpz3r47; Thu, 20 May 2021 08:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AF8A2225F8; Thu, 20 May 2021 08:14:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14K8EIU1065073; Thu, 20 May 2021 08:14:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14K8EIfh065072; Thu, 20 May 2021 08:14:18 GMT (envelope-from git) Date: Thu, 20 May 2021 08:14:18 GMT Message-Id: <202105200814.14K8EIfh065072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: d1cd99b14741 - main - ip_mroute: refactor bw_meter API MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d1cd99b147411b331a9bff659533780ef297ef58 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 08:14:19 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=d1cd99b147411b331a9bff659533780ef297ef58 commit d1cd99b147411b331a9bff659533780ef297ef58 Author: Wojciech Macek AuthorDate: 2021-05-05 03:28:56 +0000 Commit: Wojciech Macek CommitDate: 2021-05-20 08:13:55 +0000 ip_mroute: refactor bw_meter API API should work as following: - periodicaly report Lower-or-EQual bandwidth (LEQ) connections over kernel socket, if user application registered for such per-flow notifications - report Grater-or-EQual (GEQ) bandwidth as soon as it reaches specified value in configured time window Custom implementation of callouts was removed. There is no point of doing calout-wheel here as generic callouts are doing exactly the same. The performance is not critical for such reporting, so the biggest concern should be to have a code which can be easily maintained. This is ia preparation for locking rework which is highly inefficient. Approved by: mw Sponsored by: Stormshield Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D30210 --- sys/netinet/ip_mroute.c | 610 +++++++++++++++++------------------------------- sys/netinet/ip_mroute.h | 10 +- 2 files changed, 220 insertions(+), 400 deletions(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index b8e677ba9af1..0cb980b7247e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -49,6 +49,7 @@ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, August 1999, October 2000 * Modified by Hitoshi Asaeda, WIDE, August 2000 * Modified by Pavlin Radoslavov, ICSI, October 2002 + * Modified by Wojciech Macek, Semihalf, May 2021 * * MROUTING Revision: 3.5 * and PIM-SMv2 and PIM-DM support, advanced API support, @@ -202,16 +203,6 @@ VNET_DEFINE_STATIC(struct callout, expire_upcalls_ch); * Bandwidth meter variables and constants */ static MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters"); -/* - * Pending timeouts are stored in a hash table, the key being the - * expiration time. Periodically, the entries are analysed and processed. - */ -#define BW_METER_BUCKETS 1024 -VNET_DEFINE_STATIC(struct bw_meter **, bw_meter_timers); -#define V_bw_meter_timers VNET(bw_meter_timers) -VNET_DEFINE_STATIC(struct callout, bw_meter_ch); -#define V_bw_meter_ch VNET(bw_meter_ch) -#define BW_METER_PERIOD (hz) /* periodical handling of bw meters */ /* * Pending upcalls are stored in a vector which is flushed when @@ -320,14 +311,13 @@ static int add_mfc(struct mfcctl2 *); static int add_vif(struct vifctl *); static void bw_meter_prepare_upcall(struct bw_meter *, struct timeval *); static void bw_meter_process(void); -static void bw_meter_receive_packet(struct bw_meter *, int, +static void bw_meter_geq_receive_packet(struct bw_meter *, int, struct timeval *); static void bw_upcalls_send(void); static int del_bw_upcall(struct bw_upcall *); static int del_mfc(struct mfcctl2 *); static int del_vif(vifi_t); static int del_vif_locked(vifi_t); -static void expire_bw_meter_process(void *); static void expire_bw_upcalls_send(void *); static void expire_mfc(struct mfc *); static void expire_upcalls(void *); @@ -685,8 +675,6 @@ ip_mrouter_init(struct socket *so, int version) curvnet); callout_reset(&V_bw_upcalls_ch, BW_UPCALLS_PERIOD, expire_bw_upcalls_send, curvnet); - callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, - curvnet); V_ip_mrouter = so; ip_mrouter_cnt++; @@ -745,7 +733,6 @@ X_ip_mrouter_done(void) callout_stop(&V_expire_upcalls_ch); callout_stop(&V_bw_upcalls_ch); - callout_stop(&V_bw_meter_ch); MFC_LOCK(); @@ -766,7 +753,6 @@ X_ip_mrouter_done(void) bzero(V_nexpire, sizeof(V_nexpire[0]) * mfchashsize); V_bw_upcalls_n = 0; - bzero(V_bw_meter_timers, BW_METER_BUCKETS * sizeof(*V_bw_meter_timers)); MFC_UNLOCK(); @@ -1036,7 +1022,8 @@ expire_mfc(struct mfc *rt) MFC_LOCK_ASSERT(); - free_bw_list(rt->mfc_bw_meter); + free_bw_list(rt->mfc_bw_meter_leq); + free_bw_list(rt->mfc_bw_meter_geq); TAILQ_FOREACH_SAFE(rte, &rt->mfc_stall, rte_link, nrte) { m_freem(rte->m); @@ -1139,7 +1126,8 @@ add_mfc(struct mfcctl2 *mfccp) rt->mfc_nstall = 0; rt->mfc_expire = 0; - rt->mfc_bw_meter = NULL; + rt->mfc_bw_meter_leq = NULL; + rt->mfc_bw_meter_geq = NULL; /* insert new entry at head of hash chain */ LIST_INSERT_HEAD(&V_mfchashtbl[hash], rt, mfc_hash); @@ -1179,8 +1167,10 @@ del_mfc(struct mfcctl2 *mfccp) /* * free the bw_meter entries */ - free_bw_list(rt->mfc_bw_meter); - rt->mfc_bw_meter = NULL; + free_bw_list(rt->mfc_bw_meter_leq); + rt->mfc_bw_meter_leq = NULL; + free_bw_list(rt->mfc_bw_meter_geq); + rt->mfc_bw_meter_geq = NULL; LIST_REMOVE(rt, mfc_hash); free(rt, M_MRTABLE); @@ -1393,7 +1383,8 @@ fail: /* clear the RP address */ rt->mfc_rp.s_addr = INADDR_ANY; - rt->mfc_bw_meter = NULL; + rt->mfc_bw_meter_leq = NULL; + rt->mfc_bw_meter_geq = NULL; /* initialize pkt counters per src-grp */ rt->mfc_pkt_cnt = 0; @@ -1459,16 +1450,6 @@ expire_upcalls(void *arg) if (rt->mfc_expire == 0 || --rt->mfc_expire > 0) continue; - /* - * free the bw_meter entries - */ - while (rt->mfc_bw_meter != NULL) { - struct bw_meter *x = rt->mfc_bw_meter; - - rt->mfc_bw_meter = x->bm_mfc_next; - free(x, M_BWMETER); - } - MRTSTAT_INC(mrts_cache_cleanups); CTR3(KTR_IPMF, "%s: expire (%lx, %lx)", __func__, (u_long)ntohl(rt->mfc_origin.s_addr), @@ -1602,14 +1583,22 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) /* * Perform upcall-related bw measuring. */ - if (rt->mfc_bw_meter != NULL) { + if ((rt->mfc_bw_meter_geq != NULL) || (rt->mfc_bw_meter_leq != NULL)) { struct bw_meter *x; struct timeval now; microtime(&now); MFC_LOCK_ASSERT(); - for (x = rt->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) - bw_meter_receive_packet(x, plen, &now); + /* Process meters for Greater-or-EQual case */ + for (x = rt->mfc_bw_meter_geq; x != NULL; x = x->bm_mfc_next) + bw_meter_geq_receive_packet(x, plen, &now); + + /* Process meters for Lower-or-EQual case */ + for (x = rt->mfc_bw_meter_leq; x != NULL; x = x->bm_mfc_next) { + /* Record that a packet is received */ + x->bm_measured.b_packets++; + x->bm_measured.b_bytes += plen; + } } return 0; @@ -1759,84 +1748,139 @@ compute_bw_meter_flags(struct bw_upcall *req) return flags; } +static void +expire_bw_meter_leq(void *arg) +{ + struct bw_meter *x = arg; + struct timeval now; + /* + * INFO: + * callout is always executed with MFC_LOCK taken + */ + + CURVNET_SET((struct vnet *)x->arg); + + microtime(&now); + + /* + * Test if we should deliver an upcall + */ + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, &now); + } + + /* Send all upcalls that are pending delivery */ + bw_upcalls_send(); + + /* Reset counters */ + x->bm_start_time = now; + x->bm_measured.b_bytes = 0; + x->bm_measured.b_packets = 0; + + callout_schedule(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time)); + + CURVNET_RESTORE(); +} + /* * Add a bw_meter entry */ static int add_bw_upcall(struct bw_upcall *req) { - struct mfc *mfc; - struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, - BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; - struct timeval now; - struct bw_meter *x; - uint32_t flags; + struct mfc *mfc; + struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, + BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; + struct timeval now; + struct bw_meter *x, **bwm_ptr; + uint32_t flags; - if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) - return EOPNOTSUPP; + if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) + return EOPNOTSUPP; - /* Test if the flags are valid */ - if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) - return EINVAL; - if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) - return EINVAL; - if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - return EINVAL; + /* Test if the flags are valid */ + if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) + return EINVAL; + if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) + return EINVAL; + if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + return EINVAL; - /* Test if the threshold time interval is valid */ - if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) - return EINVAL; + /* Test if the threshold time interval is valid */ + if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) + return EINVAL; - flags = compute_bw_meter_flags(req); + flags = compute_bw_meter_flags(req); - /* - * Find if we have already same bw_meter entry - */ - MFC_LOCK(); - mfc = mfc_find(&req->bu_src, &req->bu_dst); - if (mfc == NULL) { - MFC_UNLOCK(); - return EADDRNOTAVAIL; - } - for (x = mfc->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) { - if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, - &req->bu_threshold.b_time, ==)) && - (x->bm_threshold.b_packets == req->bu_threshold.b_packets) && - (x->bm_threshold.b_bytes == req->bu_threshold.b_bytes) && - (x->bm_flags & BW_METER_USER_FLAGS) == flags) { - MFC_UNLOCK(); - return 0; /* XXX Already installed */ + /* + * Find if we have already same bw_meter entry + */ + MFC_LOCK(); + mfc = mfc_find(&req->bu_src, &req->bu_dst); + if (mfc == NULL) { + MFC_UNLOCK(); + return EADDRNOTAVAIL; } - } - /* Allocate the new bw_meter entry */ - x = (struct bw_meter *)malloc(sizeof(*x), M_BWMETER, M_NOWAIT); - if (x == NULL) { - MFC_UNLOCK(); - return ENOBUFS; - } + /* Choose an appropriate bw_meter list */ + if (req->bu_flags & BW_UPCALL_GEQ) + bwm_ptr = &mfc->mfc_bw_meter_geq; + else + bwm_ptr = &mfc->mfc_bw_meter_leq; + + for (x = *bwm_ptr; x != NULL; x = x->bm_mfc_next) { + if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, + &req->bu_threshold.b_time, ==)) + && (x->bm_threshold.b_packets + == req->bu_threshold.b_packets) + && (x->bm_threshold.b_bytes + == req->bu_threshold.b_bytes) + && (x->bm_flags & BW_METER_USER_FLAGS) + == flags) { + MFC_UNLOCK(); + return 0; /* XXX Already installed */ + } + } - /* Set the new bw_meter entry */ - x->bm_threshold.b_time = req->bu_threshold.b_time; - microtime(&now); - x->bm_start_time = now; - x->bm_threshold.b_packets = req->bu_threshold.b_packets; - x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags = flags; - x->bm_time_next = NULL; - x->bm_time_hash = BW_METER_BUCKETS; - - /* Add the new bw_meter entry to the front of entries for this MFC */ - x->bm_mfc = mfc; - x->bm_mfc_next = mfc->mfc_bw_meter; - mfc->mfc_bw_meter = x; - schedule_bw_meter(x, &now); - MFC_UNLOCK(); + /* Allocate the new bw_meter entry */ + x = (struct bw_meter*) malloc(sizeof(*x), M_BWMETER, M_NOWAIT); + if (x == NULL) { + MFC_UNLOCK(); + return ENOBUFS; + } - return 0; + /* Set the new bw_meter entry */ + x->bm_threshold.b_time = req->bu_threshold.b_time; + microtime(&now); + x->bm_start_time = now; + x->bm_threshold.b_packets = req->bu_threshold.b_packets; + x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; + x->bm_measured.b_packets = 0; + x->bm_measured.b_bytes = 0; + x->bm_flags = flags; + x->bm_time_next = NULL; + x->bm_mfc = mfc; + x->arg = curvnet; + + /* For LEQ case create periodic callout */ + if (req->bu_flags & BW_UPCALL_LEQ) { + callout_init_mtx(&x->bm_meter_callout, &mfc_mtx,0); + callout_reset(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time), + expire_bw_meter_leq, x); + } + + /* Add the new bw_meter entry to the front of entries for this MFC */ + x->bm_mfc_next = *bwm_ptr; + *bwm_ptr = x; + + MFC_UNLOCK(); + + return 0; } static void @@ -1845,8 +1889,11 @@ free_bw_list(struct bw_meter *list) while (list != NULL) { struct bw_meter *x = list; + /* MFC_LOCK must be held here */ + if (x->bm_flags & BW_METER_LEQ) + callout_drain(&x->bm_meter_callout); + list = list->bm_mfc_next; - unschedule_bw_meter(x); free(x, M_BWMETER); } } @@ -1858,7 +1905,7 @@ static int del_bw_upcall(struct bw_upcall *req) { struct mfc *mfc; - struct bw_meter *x; + struct bw_meter *x, **bwm_ptr; if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) return EOPNOTSUPP; @@ -1876,8 +1923,14 @@ del_bw_upcall(struct bw_upcall *req) */ struct bw_meter *list; - list = mfc->mfc_bw_meter; - mfc->mfc_bw_meter = NULL; + /* Free LEQ list */ + list = mfc->mfc_bw_meter_leq; + mfc->mfc_bw_meter_leq = NULL; + free_bw_list(list); + + /* Free GEQ list */ + list = mfc->mfc_bw_meter_geq; + mfc->mfc_bw_meter_geq = NULL; free_bw_list(list); MFC_UNLOCK(); return 0; @@ -1887,8 +1940,14 @@ del_bw_upcall(struct bw_upcall *req) flags = compute_bw_meter_flags(req); + /* Choose an appropriate bw_meter list */ + if (req->bu_flags & BW_UPCALL_GEQ) + bwm_ptr = &mfc->mfc_bw_meter_geq; + else + bwm_ptr = &mfc->mfc_bw_meter_leq; + /* Find the bw_meter entry to delete */ - for (prev = NULL, x = mfc->mfc_bw_meter; x != NULL; + for (prev = NULL, x = *bwm_ptr; x != NULL; prev = x, x = x->bm_mfc_next) { if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, &req->bu_threshold.b_time, ==)) && @@ -1901,9 +1960,11 @@ del_bw_upcall(struct bw_upcall *req) if (prev != NULL) prev->bm_mfc_next = x->bm_mfc_next; /* remove from middle*/ else - x->bm_mfc->mfc_bw_meter = x->bm_mfc_next;/* new head of list */ + *bwm_ptr = x->bm_mfc_next;/* new head of list */ + + if (req->bu_flags & BW_UPCALL_LEQ) + callout_stop(&x->bm_meter_callout); - unschedule_bw_meter(x); MFC_UNLOCK(); /* Free the bw_meter entry */ free(x, M_BWMETER); @@ -1920,16 +1981,15 @@ del_bw_upcall(struct bw_upcall *req) * Perform bandwidth measurement processing that may result in an upcall */ static void -bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) +bw_meter_geq_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) { - struct timeval delta; + struct timeval delta; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); - if (x->bm_flags & BW_METER_GEQ) { /* * Processing for ">=" type of bw_meter entry */ @@ -1949,63 +2009,15 @@ bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) * Test if we should deliver an upcall */ if (!(x->bm_flags & BW_METER_UPCALL_DELIVERED)) { - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, nowp); - x->bm_flags |= BW_METER_UPCALL_DELIVERED; - } - } - } else if (x->bm_flags & BW_METER_LEQ) { - /* - * Processing for "<=" type of bw_meter entry - */ - if (BW_TIMEVALCMP(&delta, &x->bm_threshold.b_time, >)) { - /* - * We are behind time with the multicast forwarding table - * scanning for "<=" type of bw_meter entries, so test now - * if we should deliver an upcall. - */ - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, nowp); - } - /* Reschedule the bw_meter entry */ - unschedule_bw_meter(x); - schedule_bw_meter(x, nowp); - } - - /* Record that a packet is received */ - x->bm_measured.b_packets++; - x->bm_measured.b_bytes += plen; - - /* - * Test if we should restart the measuring interval - */ - if ((x->bm_flags & BW_METER_UNIT_PACKETS && - x->bm_measured.b_packets <= x->bm_threshold.b_packets) || - (x->bm_flags & BW_METER_UNIT_BYTES && - x->bm_measured.b_bytes <= x->bm_threshold.b_bytes)) { - /* Don't restart the measuring interval */ - } else { - /* Do restart the measuring interval */ - /* - * XXX: note that we don't unschedule and schedule, because this - * might be too much overhead per packet. Instead, when we process - * all entries for a given timer hash bin, we check whether it is - * really a timeout. If not, we reschedule at that time. - */ - x->bm_start_time = *nowp; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, nowp); + x->bm_flags |= BW_METER_UPCALL_DELIVERED; + } } - } } /* @@ -2014,44 +2026,44 @@ bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) static void bw_meter_prepare_upcall(struct bw_meter *x, struct timeval *nowp) { - struct timeval delta; - struct bw_upcall *u; + struct timeval delta; + struct bw_upcall *u; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - /* - * Compute the measured time interval - */ - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + /* + * Compute the measured time interval + */ + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); - /* - * If there are too many pending upcalls, deliver them now - */ - if (V_bw_upcalls_n >= BW_UPCALLS_MAX) - bw_upcalls_send(); + /* + * If there are too many pending upcalls, deliver them now + */ + if (V_bw_upcalls_n >= BW_UPCALLS_MAX) + bw_upcalls_send(); - /* - * Set the bw_upcall entry - */ - u = &V_bw_upcalls[V_bw_upcalls_n++]; - u->bu_src = x->bm_mfc->mfc_origin; - u->bu_dst = x->bm_mfc->mfc_mcastgrp; - u->bu_threshold.b_time = x->bm_threshold.b_time; - u->bu_threshold.b_packets = x->bm_threshold.b_packets; - u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; - u->bu_measured.b_time = delta; - u->bu_measured.b_packets = x->bm_measured.b_packets; - u->bu_measured.b_bytes = x->bm_measured.b_bytes; - u->bu_flags = 0; - if (x->bm_flags & BW_METER_UNIT_PACKETS) - u->bu_flags |= BW_UPCALL_UNIT_PACKETS; - if (x->bm_flags & BW_METER_UNIT_BYTES) - u->bu_flags |= BW_UPCALL_UNIT_BYTES; - if (x->bm_flags & BW_METER_GEQ) - u->bu_flags |= BW_UPCALL_GEQ; - if (x->bm_flags & BW_METER_LEQ) - u->bu_flags |= BW_UPCALL_LEQ; + /* + * Set the bw_upcall entry + */ + u = &V_bw_upcalls[V_bw_upcalls_n++]; + u->bu_src = x->bm_mfc->mfc_origin; + u->bu_dst = x->bm_mfc->mfc_mcastgrp; + u->bu_threshold.b_time = x->bm_threshold.b_time; + u->bu_threshold.b_packets = x->bm_threshold.b_packets; + u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; + u->bu_measured.b_time = delta; + u->bu_measured.b_packets = x->bm_measured.b_packets; + u->bu_measured.b_bytes = x->bm_measured.b_bytes; + u->bu_flags = 0; + if (x->bm_flags & BW_METER_UNIT_PACKETS) + u->bu_flags |= BW_UPCALL_UNIT_PACKETS; + if (x->bm_flags & BW_METER_UNIT_BYTES) + u->bu_flags |= BW_UPCALL_UNIT_BYTES; + if (x->bm_flags & BW_METER_GEQ) + u->bu_flags |= BW_UPCALL_GEQ; + if (x->bm_flags & BW_METER_LEQ) + u->bu_flags |= BW_UPCALL_LEQ; } /* @@ -2103,183 +2115,6 @@ bw_upcalls_send(void) } } -/* - * Compute the timeout hash value for the bw_meter entries - */ -#define BW_METER_TIMEHASH(bw_meter, hash) \ - do { \ - struct timeval next_timeval = (bw_meter)->bm_start_time; \ - \ - BW_TIMEVALADD(&next_timeval, &(bw_meter)->bm_threshold.b_time); \ - (hash) = next_timeval.tv_sec; \ - if (next_timeval.tv_usec) \ - (hash)++; /* XXX: make sure we don't timeout early */ \ - (hash) %= BW_METER_BUCKETS; \ - } while (0) - -/* - * Schedule a timer to process periodically bw_meter entry of type "<=" - * by linking the entry in the proper hash bucket. - */ -static void -schedule_bw_meter(struct bw_meter *x, struct timeval *nowp) -{ - int time_hash; - - MFC_LOCK_ASSERT(); - - if (!(x->bm_flags & BW_METER_LEQ)) - return; /* XXX: we schedule timers only for "<=" entries */ - - /* - * Reset the bw_meter entry - */ - x->bm_start_time = *nowp; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; - - /* - * Compute the timeout hash value and insert the entry - */ - BW_METER_TIMEHASH(x, time_hash); - x->bm_time_next = V_bw_meter_timers[time_hash]; - V_bw_meter_timers[time_hash] = x; - x->bm_time_hash = time_hash; -} - -/* - * Unschedule the periodic timer that processes bw_meter entry of type "<=" - * by removing the entry from the proper hash bucket. - */ -static void -unschedule_bw_meter(struct bw_meter *x) -{ - int time_hash; - struct bw_meter *prev, *tmp; - - MFC_LOCK_ASSERT(); - - if (!(x->bm_flags & BW_METER_LEQ)) - return; /* XXX: we schedule timers only for "<=" entries */ - - /* - * Compute the timeout hash value and delete the entry - */ - time_hash = x->bm_time_hash; - if (time_hash >= BW_METER_BUCKETS) - return; /* Entry was not scheduled */ - - for (prev = NULL, tmp = V_bw_meter_timers[time_hash]; - tmp != NULL; prev = tmp, tmp = tmp->bm_time_next) - if (tmp == x) - break; - - if (tmp == NULL) - panic("unschedule_bw_meter: bw_meter entry not found"); - - if (prev != NULL) - prev->bm_time_next = x->bm_time_next; - else - V_bw_meter_timers[time_hash] = x->bm_time_next; - - x->bm_time_next = NULL; - x->bm_time_hash = BW_METER_BUCKETS; -} - -/* - * Process all "<=" type of bw_meter that should be processed now, - * and for each entry prepare an upcall if necessary. Each processed - * entry is rescheduled again for the (periodic) processing. - * - * This is run periodically (once per second normally). On each round, - * all the potentially matching entries are in the hash slot that we are - * looking at. - */ -static void -bw_meter_process() -{ - uint32_t loops; - int i; - struct timeval now, process_endtime; - - microtime(&now); - if (V_last_tv_sec == now.tv_sec) - return; /* nothing to do */ - - loops = now.tv_sec - V_last_tv_sec; - V_last_tv_sec = now.tv_sec; - if (loops > BW_METER_BUCKETS) - loops = BW_METER_BUCKETS; - - MFC_LOCK(); - /* - * Process all bins of bw_meter entries from the one after the last - * processed to the current one. On entry, i points to the last bucket - * visited, so we need to increment i at the beginning of the loop. - */ - for (i = (now.tv_sec - loops) % BW_METER_BUCKETS; loops > 0; loops--) { - struct bw_meter *x, *tmp_list; - - if (++i >= BW_METER_BUCKETS) - i = 0; - - /* Disconnect the list of bw_meter entries from the bin */ - tmp_list = V_bw_meter_timers[i]; - V_bw_meter_timers[i] = NULL; - - /* Process the list of bw_meter entries */ - while (tmp_list != NULL) { - x = tmp_list; - tmp_list = tmp_list->bm_time_next; - - /* Test if the time interval is over */ - process_endtime = x->bm_start_time; - BW_TIMEVALADD(&process_endtime, &x->bm_threshold.b_time); - if (BW_TIMEVALCMP(&process_endtime, &now, >)) { - /* Not yet: reschedule, but don't reset */ - int time_hash; - - BW_METER_TIMEHASH(x, time_hash); - if (time_hash == i && process_endtime.tv_sec == now.tv_sec) { - /* - * XXX: somehow the bin processing is a bit ahead of time. - * Put the entry in the next bin. - */ - if (++time_hash >= BW_METER_BUCKETS) - time_hash = 0; - } - x->bm_time_next = V_bw_meter_timers[time_hash]; - V_bw_meter_timers[time_hash] = x; - x->bm_time_hash = time_hash; - - continue; - } - - /* - * Test if we should deliver an upcall - */ - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, &now); - } - - /* - * Reschedule for next processing - */ - schedule_bw_meter(x, &now); - } - } - - /* Send all upcalls that are pending delivery */ - bw_upcalls_send(); - - MFC_UNLOCK(); -} - /* * A periodic function for sending all upcalls that are pending delivery */ @@ -2297,23 +2132,6 @@ expire_bw_upcalls_send(void *arg) CURVNET_RESTORE(); } -/* - * A periodic function for periodic scanning of the multicast forwarding - * table for processing all "<=" bw_meter entries. - */ -static void -expire_bw_meter_process(void *arg) -{ - CURVNET_SET((struct vnet *) arg); - - if (V_mrt_api_config & MRT_MFC_BW_UPCALL) - bw_meter_process(); - - callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, - curvnet); - CURVNET_RESTORE(); -} - /* * End of bandwidth monitoring code */ @@ -2835,14 +2653,11 @@ vnet_mroute_init(const void *unused __unused) V_viftable = mallocarray(MAXVIFS, sizeof(*V_viftable), M_MRTABLE, M_WAITOK|M_ZERO); - V_bw_meter_timers = mallocarray(BW_METER_BUCKETS, - sizeof(*V_bw_meter_timers), M_MRTABLE, M_WAITOK|M_ZERO); V_bw_upcalls = mallocarray(BW_UPCALLS_MAX, sizeof(*V_bw_upcalls), M_MRTABLE, M_WAITOK|M_ZERO); callout_init(&V_expire_upcalls_ch, 1); callout_init(&V_bw_upcalls_ch, 1); - callout_init(&V_bw_meter_ch, 1); } VNET_SYSINIT(vnet_mroute_init, SI_SUB_PROTO_MC, SI_ORDER_ANY, vnet_mroute_init, @@ -2853,7 +2668,6 @@ vnet_mroute_uninit(const void *unused __unused) { free(V_bw_upcalls, M_MRTABLE); - free(V_bw_meter_timers, M_MRTABLE); free(V_viftable, M_MRTABLE); free(V_nexpire, M_MRTABLE); V_nexpire = NULL; diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h index 6ef99c0172f3..07d77065de33 100644 --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -283,7 +283,10 @@ struct mfc { struct timeval mfc_last_assert; /* last time I sent an assert*/ uint8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ struct in_addr mfc_rp; /* the RP address */ - struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */ + struct bw_meter *mfc_bw_meter_leq; /* list of bandwidth meters + for Lower-or-EQual case */ + struct bw_meter *mfc_bw_meter_geq; /* list of bandwidth meters + for Greater-or-EQual case */ u_long mfc_nstall; /* # of packets awaiting mfc */ TAILQ_HEAD(, rtdetq) mfc_stall; /* q of packets awaiting mfc */ }; @@ -327,7 +330,6 @@ struct rtdetq { struct bw_meter { struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */ struct bw_meter *bm_time_next; /* next bw meter (same time) */ - uint32_t bm_time_hash; /* the time hash value */ struct mfc *bm_mfc; /* the corresponding mfc */ uint32_t bm_flags; /* misc flags (see below) */ #define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ @@ -344,6 +346,10 @@ struct bw_meter { struct bw_data bm_threshold; /* the upcall threshold */ struct bw_data bm_measured; /* the measured bw */ struct timeval bm_start_time; /* abs. time */ +#ifdef _KERNEL + struct callout bm_meter_callout; /* Periodic callout */ + void* arg; /* custom argument */ +#endif }; #ifdef _KERNEL From owner-dev-commits-src-main@freebsd.org Thu May 20 08:27:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8AB6F63889B; Thu, 20 May 2021 08: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 4Fm2t42Zp8z4TVh; Thu, 20 May 2021 08: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 404EC22941; Thu, 20 May 2021 08: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 14K8ReIB078854; Thu, 20 May 2021 08: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 14K8ReTU078853; Thu, 20 May 2021 08:27:40 GMT (envelope-from git) Date: Thu, 20 May 2021 08:27:40 GMT Message-Id: <202105200827.14K8ReTU078853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ceri Davies Subject: git: c1a148873d64 - main - sys/*/conf/*, docs: fix links to handbook MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ceri X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1a148873d6488f1dac1cfb207a5927cef89888e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 08:27:40 -0000 The branch main has been updated by ceri (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c1a148873d6488f1dac1cfb207a5927cef89888e commit c1a148873d6488f1dac1cfb207a5927cef89888e Author: Ceri Davies AuthorDate: 2021-05-20 08:26:02 +0000 Commit: Ceri Davies CommitDate: 2021-05-20 08:27:10 +0000 sys/*/conf/*, docs: fix links to handbook While here, fix all links to older en_US.ISO8859-1 documentation in the src/ tree. PR: 255026 Reported by: Michael Büker Reviewed by: dbaio Approved by: blackend (mentor), re (gjb) MFC after: 10 days Differential Revision: https://reviews.freebsd.org/D30265 --- UPDATING | 2 +- release/Makefile | 1 - share/man/man4/mac.4 | 4 ++-- share/man/man7/release.7 | 6 +++--- share/man/man9/mac.9 | 4 ++-- share/man/man9/pci.9 | 4 ++-- sys/amd64/conf/GENERIC | 2 +- sys/amd64/conf/GENERIC-KCSAN | 2 +- sys/amd64/conf/GENERIC-NODEBUG | 2 +- sys/amd64/conf/MINIMAL | 2 +- sys/arm/conf/ALPINE | 2 +- sys/arm/conf/APALIS-IMX6 | 2 +- sys/arm/conf/ARMADAXP | 2 +- sys/arm/conf/COLIBRI-VF50 | 2 +- sys/arm/conf/COSMIC | 2 +- sys/arm/conf/EFIKA_MX | 2 +- sys/arm/conf/GENERIC | 2 +- sys/arm/conf/GENERIC-NODEBUG | 2 +- sys/arm/conf/IMX53 | 2 +- sys/arm/conf/IMX6 | 2 +- sys/arm/conf/JETSON-TK1 | 2 +- sys/arm/conf/QUARTZ | 2 +- sys/arm/conf/RPI-B | 2 +- sys/arm/conf/SOCDK | 2 +- sys/arm/conf/SOCFPGA | 2 +- sys/arm/conf/SOCKIT | 2 +- sys/arm/conf/SOCKIT-BERI | 2 +- sys/arm/conf/TEGRA124 | 2 +- sys/arm/conf/VYBRID | 2 +- sys/arm/conf/ZEDBOARD | 2 +- sys/arm64/conf/GENERIC | 2 +- sys/arm64/conf/GENERIC-NODEBUG | 2 +- sys/arm64/conf/GENERIC-UP | 2 +- sys/contrib/zstd/FREEBSD-upgrade | 2 +- sys/i386/conf/GENERIC | 2 +- sys/i386/conf/GENERIC-NODEBUG | 2 +- sys/i386/conf/MINIMAL | 2 +- sys/mips/conf/ERL | 2 +- sys/mips/conf/OCTEON1 | 2 +- sys/mips/conf/XLP64 | 2 +- sys/mips/conf/XLPN32 | 2 +- sys/powerpc/conf/GENERIC | 2 +- sys/powerpc/conf/GENERIC-NODEBUG | 2 +- sys/powerpc/conf/GENERIC64 | 2 +- sys/powerpc/conf/GENERIC64-NODEBUG | 2 +- sys/powerpc/conf/GENERIC64LE | 2 +- sys/riscv/conf/GENERIC | 2 +- sys/riscv/conf/GENERIC-NODEBUG | 2 +- usr.bin/fortune/datfiles/freebsd-tips | 3 +-- usr.bin/timeout/timeout.1 | 6 +++--- usr.sbin/lpr/lpd/printcap | 2 +- usr.sbin/mergemaster/mergemaster.8 | 7 +++---- usr.sbin/ppp/ppp.8 | 8 +++----- 53 files changed, 63 insertions(+), 68 deletions(-) diff --git a/UPDATING b/UPDATING index efccbf3b2fff..45f85647980b 100644 --- a/UPDATING +++ b/UPDATING @@ -6,7 +6,7 @@ COMMON ITEMS: section later in the file. These instructions assume that you basically know what you are doing. If not, then please consult the FreeBSD handbook: - https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html + https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before updating system packages diff --git a/release/Makefile b/release/Makefile index c176ae6f2bb7..646b9f8738d2 100644 --- a/release/Makefile +++ b/release/Makefile @@ -36,7 +36,6 @@ WORLDDIR?= ${.CURDIR}/.. PORTSDIR?= /usr/ports -RELNOTES_LANG?= en_US.ISO8859-1 .if !defined(TARGET) || empty(TARGET) TARGET= ${MACHINE} diff --git a/share/man/man4/mac.4 b/share/man/man4/mac.4 index 135301962f3b..ecc13257960d 100644 --- a/share/man/man4/mac.4 +++ b/share/man/man4/mac.4 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 25, 2015 +.Dd May 20, 2021 .Dt MAC 4 .Os .Sh NAME @@ -219,7 +219,7 @@ man page. .Rs .%B "The FreeBSD Handbook" .%T "Mandatory Access Control" -.%U https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/mac.html +.%U https://docs.FreeBSD.org/en/books/handbook/mac/ .Re .Sh HISTORY The diff --git a/share/man/man7/release.7 b/share/man/man7/release.7 index a474de83ec93..aa0cee1e32b8 100644 --- a/share/man/man7/release.7 +++ b/share/man/man7/release.7 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 4, 2021 +.Dd May 20, 2021 .Dt RELEASE 7 .Os .Sh NAME @@ -697,11 +697,11 @@ are therefore no longer supported. .Xr sysctl 8 .Rs .%T "FreeBSD Release Engineering" -.%U https://www.FreeBSD.org/doc/en_US.ISO8859-1/articles/freebsd-releng/ +.%U https://docs.freebsd.org/en/articles/freebsd-releng/ .Re .Rs .%T "FreeBSD Developers' Handbook" -.%U https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-handbook/ +.%U https://docs.freebsd.org/en/books/developers-handbook/ .Re .Sh HISTORY .Fx diff --git a/share/man/man9/mac.9 b/share/man/man9/mac.9 index 89238d28b61c..9357c1189bd7 100644 --- a/share/man/man9/mac.9 +++ b/share/man/man9/mac.9 @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 27, 2021 +.Dd May 20, 2021 .Dt MAC 9 .Os .Sh NAME @@ -166,7 +166,7 @@ for information on the MAC Framework APIs. .Xr VOP_SETLABEL 9 . .Rs .%T "The FreeBSD Architecture Handbook" -.%U "https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/arch-handbook/" +.%U "https://docs.freebsd.org/en/books/arch-handbook/" .Re .Sh HISTORY The diff --git a/share/man/man9/pci.9 b/share/man/man9/pci.9 index e55ea02547b6..5dc9ef099a87 100644 --- a/share/man/man9/pci.9 +++ b/share/man/man9/pci.9 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 15, 2017 +.Dd May 20, 2021 .Dt PCI 9 .Os .Sh NAME @@ -1104,7 +1104,7 @@ is unattached but with valid instance variables. .Rs .%B FreeBSD Developers' Handbook .%T NewBus -.%U https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-handbook/ +.%U https://docs.freebsd.org/en/books/developers-handbook/ .Re .Rs .%A Shanley diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index bb7299a60382..696d15698baf 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/amd64/conf/GENERIC-KCSAN b/sys/amd64/conf/GENERIC-KCSAN index 2864596860ab..b578fbf641cd 100644 --- a/sys/amd64/conf/GENERIC-KCSAN +++ b/sys/amd64/conf/GENERIC-KCSAN @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/amd64/conf/GENERIC-NODEBUG b/sys/amd64/conf/GENERIC-NODEBUG index 332cf85eb372..1c767e84d483 100644 --- a/sys/amd64/conf/GENERIC-NODEBUG +++ b/sys/amd64/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index 603fce8320bb..b03b17b1bfcd 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -18,7 +18,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/ALPINE b/sys/arm/conf/ALPINE index fdfb591f8614..871ee698b953 100644 --- a/sys/arm/conf/ALPINE +++ b/sys/arm/conf/ALPINE @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/APALIS-IMX6 b/sys/arm/conf/APALIS-IMX6 index 9b5886216ada..084bee232a12 100644 --- a/sys/arm/conf/APALIS-IMX6 +++ b/sys/arm/conf/APALIS-IMX6 @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/ARMADAXP b/sys/arm/conf/ARMADAXP index 96c90c639a42..39727aad4403 100644 --- a/sys/arm/conf/ARMADAXP +++ b/sys/arm/conf/ARMADAXP @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/COLIBRI-VF50 b/sys/arm/conf/COLIBRI-VF50 index 86dcb0b9ef73..af0085615786 100644 --- a/sys/arm/conf/COLIBRI-VF50 +++ b/sys/arm/conf/COLIBRI-VF50 @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/COSMIC b/sys/arm/conf/COSMIC index cd49dbc5b050..b9d1ffc5aa42 100644 --- a/sys/arm/conf/COSMIC +++ b/sys/arm/conf/COSMIC @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/EFIKA_MX b/sys/arm/conf/EFIKA_MX index 724d742e03af..d45d6e815269 100644 --- a/sys/arm/conf/EFIKA_MX +++ b/sys/arm/conf/EFIKA_MX @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/GENERIC b/sys/arm/conf/GENERIC index 3cfe16ccfe54..dc6e2657779d 100644 --- a/sys/arm/conf/GENERIC +++ b/sys/arm/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/GENERIC-NODEBUG b/sys/arm/conf/GENERIC-NODEBUG index 6e60deff7569..517d3310c9d5 100644 --- a/sys/arm/conf/GENERIC-NODEBUG +++ b/sys/arm/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/IMX53 b/sys/arm/conf/IMX53 index 0372cb62088d..4cbd14aa13a4 100644 --- a/sys/arm/conf/IMX53 +++ b/sys/arm/conf/IMX53 @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/IMX6 b/sys/arm/conf/IMX6 index 6d8388ff0d60..5288b4a75622 100644 --- a/sys/arm/conf/IMX6 +++ b/sys/arm/conf/IMX6 @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/JETSON-TK1 b/sys/arm/conf/JETSON-TK1 index b12186d91c2c..859d1535842f 100644 --- a/sys/arm/conf/JETSON-TK1 +++ b/sys/arm/conf/JETSON-TK1 @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/QUARTZ b/sys/arm/conf/QUARTZ index 3e7d239785e2..de6d38463b17 100644 --- a/sys/arm/conf/QUARTZ +++ b/sys/arm/conf/QUARTZ @@ -3,7 +3,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/RPI-B b/sys/arm/conf/RPI-B index 36eaff0c0f28..ebaa0462b155 100644 --- a/sys/arm/conf/RPI-B +++ b/sys/arm/conf/RPI-B @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/SOCDK b/sys/arm/conf/SOCDK index 4c92aaea108a..59f93d480a86 100644 --- a/sys/arm/conf/SOCDK +++ b/sys/arm/conf/SOCDK @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/SOCFPGA b/sys/arm/conf/SOCFPGA index 3d7511565307..717f7546a594 100644 --- a/sys/arm/conf/SOCFPGA +++ b/sys/arm/conf/SOCFPGA @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/SOCKIT b/sys/arm/conf/SOCKIT index c83a3f260691..d1e9a85d7bd9 100644 --- a/sys/arm/conf/SOCKIT +++ b/sys/arm/conf/SOCKIT @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/SOCKIT-BERI b/sys/arm/conf/SOCKIT-BERI index 7dd37a340502..0e21f5c27604 100644 --- a/sys/arm/conf/SOCKIT-BERI +++ b/sys/arm/conf/SOCKIT-BERI @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/TEGRA124 b/sys/arm/conf/TEGRA124 index 68d7bf037525..881d6e811a85 100644 --- a/sys/arm/conf/TEGRA124 +++ b/sys/arm/conf/TEGRA124 @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/VYBRID b/sys/arm/conf/VYBRID index e7ded5f42d82..24297a6febe2 100644 --- a/sys/arm/conf/VYBRID +++ b/sys/arm/conf/VYBRID @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm/conf/ZEDBOARD b/sys/arm/conf/ZEDBOARD index 24490a5129e5..1a7d011f51b0 100644 --- a/sys/arm/conf/ZEDBOARD +++ b/sys/arm/conf/ZEDBOARD @@ -5,7 +5,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC index 430ba8a4a45f..23126cc81127 100644 --- a/sys/arm64/conf/GENERIC +++ b/sys/arm64/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm64/conf/GENERIC-NODEBUG b/sys/arm64/conf/GENERIC-NODEBUG index 8b99852be971..accbc464862c 100644 --- a/sys/arm64/conf/GENERIC-NODEBUG +++ b/sys/arm64/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/arm64/conf/GENERIC-UP b/sys/arm64/conf/GENERIC-UP index f6c4e6edeca9..f18c5defc1a6 100644 --- a/sys/arm64/conf/GENERIC-UP +++ b/sys/arm64/conf/GENERIC-UP @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/contrib/zstd/FREEBSD-upgrade b/sys/contrib/zstd/FREEBSD-upgrade index dfcad88572b2..fb46da059004 100644 --- a/sys/contrib/zstd/FREEBSD-upgrade +++ b/sys/contrib/zstd/FREEBSD-upgrade @@ -11,4 +11,4 @@ we don't want. Please find instructions for importing new releases and merging to HEAD here: -https://www.freebsd.org/doc/en_US.ISO8859-1/articles/committers-guide/subversion-primer.html#idp45937784 +https://docs.freebsd.org/en/articles/committers-guide/#vendor-import-git diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 874c3237ec77..1b4d853fe1d4 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/i386/conf/GENERIC-NODEBUG b/sys/i386/conf/GENERIC-NODEBUG index d09663e1b9db..f0b3ecd818fd 100644 --- a/sys/i386/conf/GENERIC-NODEBUG +++ b/sys/i386/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/i386/conf/MINIMAL b/sys/i386/conf/MINIMAL index 8eed963b8f0a..f80c5cf40b48 100644 --- a/sys/i386/conf/MINIMAL +++ b/sys/i386/conf/MINIMAL @@ -18,7 +18,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/mips/conf/ERL b/sys/mips/conf/ERL index d0bb25455fa4..ae18cddd84ba 100644 --- a/sys/mips/conf/ERL +++ b/sys/mips/conf/ERL @@ -5,7 +5,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/mips/conf/OCTEON1 b/sys/mips/conf/OCTEON1 index 99a839ac8b28..7596a61a09da 100644 --- a/sys/mips/conf/OCTEON1 +++ b/sys/mips/conf/OCTEON1 @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/mips/conf/XLP64 b/sys/mips/conf/XLP64 index cf35005f0768..537091458e00 100644 --- a/sys/mips/conf/XLP64 +++ b/sys/mips/conf/XLP64 @@ -3,7 +3,7 @@ # For more information on this file, please read the handbook section on # Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/mips/conf/XLPN32 b/sys/mips/conf/XLPN32 index bc2593d6ebdb..cf8dbcffb020 100644 --- a/sys/mips/conf/XLPN32 +++ b/sys/mips/conf/XLPN32 @@ -3,7 +3,7 @@ # For more information on this file, please read the handbook section on # Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/powerpc/conf/GENERIC b/sys/powerpc/conf/GENERIC index 7854e89d17b7..cdf1266ec5a6 100644 --- a/sys/powerpc/conf/GENERIC +++ b/sys/powerpc/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the handbook section on # Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/powerpc/conf/GENERIC-NODEBUG b/sys/powerpc/conf/GENERIC-NODEBUG index b86116253d78..b21984636e1d 100644 --- a/sys/powerpc/conf/GENERIC-NODEBUG +++ b/sys/powerpc/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/powerpc/conf/GENERIC64 b/sys/powerpc/conf/GENERIC64 index 634a8c2731a8..93a130e07dc6 100644 --- a/sys/powerpc/conf/GENERIC64 +++ b/sys/powerpc/conf/GENERIC64 @@ -4,7 +4,7 @@ # For more information on this file, please read the handbook section on # Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/powerpc/conf/GENERIC64-NODEBUG b/sys/powerpc/conf/GENERIC64-NODEBUG index da382e5e76de..cc82f38fb22c 100644 --- a/sys/powerpc/conf/GENERIC64-NODEBUG +++ b/sys/powerpc/conf/GENERIC64-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/powerpc/conf/GENERIC64LE b/sys/powerpc/conf/GENERIC64LE index 41815a6a01cc..6bd0c8154673 100644 --- a/sys/powerpc/conf/GENERIC64LE +++ b/sys/powerpc/conf/GENERIC64LE @@ -4,7 +4,7 @@ # For more information on this file, please read the handbook section on # Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index a04d5557c83c..4c31e5dcf31d 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -4,7 +4,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/sys/riscv/conf/GENERIC-NODEBUG b/sys/riscv/conf/GENERIC-NODEBUG index 9b1d9fe5a9af..09155b59f46f 100644 --- a/sys/riscv/conf/GENERIC-NODEBUG +++ b/sys/riscv/conf/GENERIC-NODEBUG @@ -12,7 +12,7 @@ # For more information on this file, please read the config(5) manual page, # and/or the handbook section on Kernel Configuration Files: # -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config # # The handbook is also available locally in /usr/share/doc/handbook # if you've installed the doc distribution, otherwise always see the diff --git a/usr.bin/fortune/datfiles/freebsd-tips b/usr.bin/fortune/datfiles/freebsd-tips index 0b596dec4575..eb7339cec698 100644 --- a/usr.bin/fortune/datfiles/freebsd-tips +++ b/usr.bin/fortune/datfiles/freebsd-tips @@ -62,8 +62,7 @@ If you need a reminder to leave your terminal, type "leave +hhmm" where % If you need to ask a question on the FreeBSD-questions mailing list then - https://www.FreeBSD.org/doc/en_US.ISO8859-1/articles/\ - freebsd-questions/index.html + https://docs.freebsd.org/en/articles/freebsd-questions contains lots of useful advice to help you get the best results. % diff --git a/usr.bin/timeout/timeout.1 b/usr.bin/timeout/timeout.1 index b9613128755e..87a86c81e6ee 100644 --- a/usr.bin/timeout/timeout.1 +++ b/usr.bin/timeout/timeout.1 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2020 +.Dd May 20, 2021 .Dt TIMEOUT 1 .Os .Sh NAME @@ -180,7 +180,7 @@ $ echo $? .Pp Try to .Xr fetch 1 -the single page version of the +the PDF version of the .Fx Handbook. Send a @@ -190,7 +190,7 @@ signal after 1 minute and send a signal 5 seconds later if the process refuses to stop: .Bd -literal -offset indent timeout -k 5s 1m fetch \\ -https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html +https://download.freebsd.org/ftp/doc/en/books/handbook/book.pdf .Ed .Sh SEE ALSO .Xr kill 1 , diff --git a/usr.sbin/lpr/lpd/printcap b/usr.sbin/lpr/lpd/printcap index b1f83b344c8f..1bfa1abb4c20 100644 --- a/usr.sbin/lpr/lpd/printcap +++ b/usr.sbin/lpr/lpd/printcap @@ -22,7 +22,7 @@ # # Do also refer to the "printing" section of the handbook. # -# https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing.html +# https://docs.freebsd.org/en/books/handbook/printing/ # # A local copy can be found under # diff --git a/usr.sbin/mergemaster/mergemaster.8 b/usr.sbin/mergemaster/mergemaster.8 index b76799e39cd5..2f5b85f30b4c 100644 --- a/usr.sbin/mergemaster/mergemaster.8 +++ b/usr.sbin/mergemaster/mergemaster.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 27, 2018 +.Dd May 20, 2021 .Dt MERGEMASTER 8 .Os .Sh NAME @@ -458,9 +458,8 @@ comparison, use: .Pp .Pa /usr/src/etc/Makefile .Rs -.%U https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html -.%T The Cutting Edge (using make world) -.%A Nik Clayton +.%U https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld +.%T The FreeBSD Handbook .Re .Sh HISTORY The diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 02819b1b3578..00470f6e5273 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 11, 2020 +.Dd May 20, 2021 .Dt PPP 8 .Os .Sh NAME @@ -5963,12 +5963,10 @@ and .Dq show ?\& to get online information about what is available. .It -The following URLs contain useful information: +The following URL contains useful information: .Bl -bullet -compact .It -https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/faq/ppp.html -.It -https://www.FreeBSD.org/doc/handbook/userppp.html +https://docs.freebsd.org/en/books/handbook/ppp-and-slip/ .El .El .Sh FILES From owner-dev-commits-src-main@freebsd.org Thu May 20 09:22:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7864639A67; Thu, 20 May 2021 09:22: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 4Fm45X4gZTz4rvH; Thu, 20 May 2021 09:22: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 89428235D5; Thu, 20 May 2021 09:22: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 14K9Menn058288; Thu, 20 May 2021 09:22:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14K9MeJV058287; Thu, 20 May 2021 09:22:40 GMT (envelope-from git) Date: Thu, 20 May 2021 09:22:40 GMT Message-Id: <202105200922.14K9MeJV058287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: b08bf4c35caa - main - sdhci_fsl_fdt: Skip vccq reconfiguration without regulator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b08bf4c35caa2baaa0453b7979ed538cf71b6de5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 09:22:40 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=b08bf4c35caa2baaa0453b7979ed538cf71b6de5 commit b08bf4c35caa2baaa0453b7979ed538cf71b6de5 Author: Marcin Wojtas AuthorDate: 2021-05-20 09:16:40 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-20 09:21:53 +0000 sdhci_fsl_fdt: Skip vccq reconfiguration without regulator There is no need to preform any voltage reconfiguration in case the vccq regulator is not physically attached to the slot. Submitted by: Lukasz Hajec Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30355 --- sys/dev/sdhci/sdhci_fsl_fdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fsl_fdt.c b/sys/dev/sdhci/sdhci_fsl_fdt.c index 26092f662406..91d926c343cc 100644 --- a/sys/dev/sdhci/sdhci_fsl_fdt.c +++ b/sys/dev/sdhci/sdhci_fsl_fdt.c @@ -493,15 +493,15 @@ sdhci_fsl_fdt_switch_vccq(device_t brdev, device_t reqdev) struct sdhci_slot *slot; int uvolt, err; - err = sdhci_generic_switch_vccq(brdev, reqdev); - if (err != 0) - return (err); - sc = device_get_softc(brdev); if (sc->fdt_helper.vqmmc_supply == NULL) return EOPNOTSUPP; + err = sdhci_generic_switch_vccq(brdev, reqdev); + if (err != 0) + return (err); + slot = device_get_ivars(reqdev); switch (slot->host.ios.vccq) { case vccq_180: From owner-dev-commits-src-main@freebsd.org Thu May 20 09:22:42 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 317E8639A68; Thu, 20 May 2021 09:22: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 4Fm45Z0Gl3z4rms; Thu, 20 May 2021 09:22: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 B3F2423980; Thu, 20 May 2021 09:22: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 14K9Mf7X058309; Thu, 20 May 2021 09:22:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14K9MfXQ058308; Thu, 20 May 2021 09:22:41 GMT (envelope-from git) Date: Thu, 20 May 2021 09:22:41 GMT Message-Id: <202105200922.14K9MfXQ058308@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: 240429103cd0 - main - Rename ofwpci.c to ofw_pcib.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 240429103cd05bcecb20fbfd8310cf3faff39681 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 09:22:42 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=240429103cd05bcecb20fbfd8310cf3faff39681 commit 240429103cd05bcecb20fbfd8310cf3faff39681 Author: Marcin Wojtas AuthorDate: 2021-05-19 15:27:42 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-20 09:22:25 +0000 Rename ofwpci.c to ofw_pcib.c It's a class0 driver that implements some pcib methods and creates a pci bus as its children. The "ofw_pci" name will be used by a new driver that will be a subclass of the pci bus. No functional changes intended. Submitted by: Kornel Duleba Reviewed by: andrew Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30226 --- sys/arm/nvidia/tegra_pcie.c | 4 +- sys/arm64/rockchip/rk_pcie.c | 4 +- sys/conf/files.arm | 2 +- sys/conf/files.arm64 | 2 +- sys/conf/files.i386 | 2 +- sys/conf/files.mips | 2 +- sys/conf/files.powerpc | 2 +- sys/conf/files.riscv | 2 +- sys/dev/ofw/{ofwpci.c => ofw_pcib.c} | 102 +++++++++++++++++------------------ sys/dev/ofw/ofwpci.h | 14 ++--- sys/dev/pci/pci_dw.c | 4 +- sys/powerpc/mpc85xx/pci_mpc85xx.c | 6 +-- sys/powerpc/powermac/cpcht.c | 4 +- sys/powerpc/powermac/grackle.c | 4 +- sys/powerpc/powermac/uninorthpci.c | 4 +- sys/powerpc/powernv/opal_pci.c | 6 +-- sys/powerpc/pseries/rtas_pci.c | 4 +- 17 files changed, 84 insertions(+), 84 deletions(-) diff --git a/sys/arm/nvidia/tegra_pcie.c b/sys/arm/nvidia/tegra_pcie.c index 44eb682a40b4..aa488bb8c0e4 100644 --- a/sys/arm/nvidia/tegra_pcie.c +++ b/sys/arm/nvidia/tegra_pcie.c @@ -1533,7 +1533,7 @@ tegra_pcib_attach(device_t dev) } sc->ofw_pci.sc_range_mask = 0x3; - rv = ofw_pci_init(dev); + rv = ofw_pcib_init(dev); if (rv != 0) goto out; @@ -1625,6 +1625,6 @@ static device_method_t tegra_pcib_methods[] = { static devclass_t pcib_devclass; DEFINE_CLASS_1(pcib, tegra_pcib_driver, tegra_pcib_methods, - sizeof(struct tegra_pcib_softc), ofw_pci_driver); + sizeof(struct tegra_pcib_softc), ofw_pcib_driver); DRIVER_MODULE(tegra_pcib, simplebus, tegra_pcib_driver, pcib_devclass, NULL, NULL); diff --git a/sys/arm64/rockchip/rk_pcie.c b/sys/arm64/rockchip/rk_pcie.c index ea4ce5b568e6..dabd7931e442 100644 --- a/sys/arm64/rockchip/rk_pcie.c +++ b/sys/arm64/rockchip/rk_pcie.c @@ -1276,7 +1276,7 @@ rk_pcie_attach(device_t dev) if (rv != 0) goto out; - rv = ofw_pci_init(dev); + rv = ofw_pcib_init(dev); if (rv != 0) goto out; @@ -1383,7 +1383,7 @@ static device_method_t rk_pcie_methods[] = { }; DEFINE_CLASS_1(pcib, rk_pcie_driver, rk_pcie_methods, - sizeof(struct rk_pcie_softc), ofw_pci_driver); + sizeof(struct rk_pcie_softc), ofw_pcib_driver); static devclass_t rk_pcie_devclass; DRIVER_MODULE( rk_pcie, simplebus, rk_pcie_driver, rk_pcie_devclass, NULL, NULL); diff --git a/sys/conf/files.arm b/sys/conf/files.arm index ad7a8ddd1fe3..e2af76567549 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -91,7 +91,7 @@ dev/hwpmc/hwpmc_arm.c optional hwpmc dev/hwpmc/hwpmc_armv7.c optional hwpmc armv6 dev/hwpmc/hwpmc_armv7.c optional hwpmc armv7 dev/iicbus/twsi/twsi.c optional twsi -dev/ofw/ofwpci.c optional fdt pci +dev/ofw/ofw_pcib.c optional fdt pci dev/pci/pci_host_generic.c optional pci_host_generic pci dev/pci/pci_host_generic_fdt.c optional pci_host_generic pci fdt dev/psci/psci.c optional psci diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 3b0266736d7a..fed33562b834 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -245,7 +245,7 @@ dev/neta/if_mvneta_fdt.c optional neta fdt dev/neta/if_mvneta.c optional neta mdio mii dev/ofw/ofw_cpu.c optional fdt -dev/ofw/ofwpci.c optional fdt pci +dev/ofw/ofw_pcib.c optional fdt pci dev/pci/controller/pci_n1sdp.c optional pci_n1sdp acpi dev/pci/pci_host_generic.c optional pci diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index f09e7d5844f0..331ad5fec79a 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -115,7 +115,7 @@ dev/ntb/ntb_hw/ntb_hw_intel.c optional ntb_hw_intel | ntb_hw dev/ntb/ntb_hw/ntb_hw_plx.c optional ntb_hw_plx | ntb_hw dev/ntb/test/ntb_tool.c optional ntb_tool dev/nvram/nvram.c optional nvram isa -dev/ofw/ofwpci.c optional fdt pci +dev/ofw/ofw_pcib.c optional fdt pci dev/pcf/pcf_isa.c optional pcf dev/random/ivy.c optional rdrand_rng !random_loadable dev/random/nehemiah.c optional padlock_rng !random_loadable diff --git a/sys/conf/files.mips b/sys/conf/files.mips index 7ee5b0019bd7..6211c90f4e7e 100644 --- a/sys/conf/files.mips +++ b/sys/conf/files.mips @@ -96,7 +96,7 @@ dev/hwpmc/hwpmc_mips24k.c optional hwpmc_mips24k dev/hwpmc/hwpmc_mips74k.c optional hwpmc_mips74k # ofw support -dev/ofw/ofwpci.c optional fdt pci +dev/ofw/ofw_pcib.c optional fdt pci # INTRNG support code kern/msi_if.m optional intrng diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index 19c97c34fa86..a57367a23017 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -90,7 +90,7 @@ dev/ofw/ofw_bus_subr.c standard dev/ofw/ofw_console.c optional aim dev/ofw/ofw_disk.c optional ofwd aim dev/ofw/ofwbus.c standard -dev/ofw/ofwpci.c optional pci +dev/ofw/ofw_pcib.c optional pci dev/ofw/ofw_standard.c optional aim powerpc dev/ofw/ofw_subr.c standard dev/powermac_nvram/powermac_nvram.c optional powermac_nvram powermac diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index c2d911cd68de..cf7b58bfe4e3 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -4,7 +4,7 @@ cddl/dev/dtrace/riscv/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" crypto/des/des_enc.c optional netsmb dev/ofw/ofw_cpu.c optional fdt -dev/ofw/ofwpci.c optional pci fdt +dev/ofw/ofw_pcib.c optional pci fdt dev/pci/pci_host_generic.c optional pci dev/pci/pci_host_generic_fdt.c optional pci fdt dev/uart/uart_cpu_fdt.c optional uart fdt diff --git a/sys/dev/ofw/ofwpci.c b/sys/dev/ofw/ofw_pcib.c similarity index 83% rename from sys/dev/ofw/ofwpci.c rename to sys/dev/ofw/ofw_pcib.c index a912da6698a0..1de5a884ebc9 100644 --- a/sys/dev/ofw/ofwpci.c +++ b/sys/dev/ofw/ofw_pcib.c @@ -66,77 +66,77 @@ __FBSDID("$FreeBSD$"); /* * bus interface. */ -static struct resource * ofw_pci_alloc_resource(device_t, device_t, +static struct resource * ofw_pcib_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); -static int ofw_pci_release_resource(device_t, device_t, int, int, +static int ofw_pcib_release_resource(device_t, device_t, int, int, struct resource *); -static int ofw_pci_activate_resource(device_t, device_t, int, int, +static int ofw_pcib_activate_resource(device_t, device_t, int, int, struct resource *); -static int ofw_pci_deactivate_resource(device_t, device_t, int, int, +static int ofw_pcib_deactivate_resource(device_t, device_t, int, int, struct resource *); -static int ofw_pci_adjust_resource(device_t, device_t, int, +static int ofw_pcib_adjust_resource(device_t, device_t, int, struct resource *, rman_res_t, rman_res_t); -static int ofw_pci_translate_resource(device_t bus, int type, +static int ofw_pcib_translate_resource(device_t bus, int type, rman_res_t start, rman_res_t *newstart); #ifdef __powerpc__ -static bus_space_tag_t ofw_pci_bus_get_bus_tag(device_t, device_t); +static bus_space_tag_t ofw_pcib_bus_get_bus_tag(device_t, device_t); #endif /* * pcib interface */ -static int ofw_pci_maxslots(device_t); +static int ofw_pcib_maxslots(device_t); /* * ofw_bus interface */ -static phandle_t ofw_pci_get_node(device_t, device_t); +static phandle_t ofw_pcib_get_node(device_t, device_t); /* * local methods */ -static int ofw_pci_fill_ranges(phandle_t, struct ofw_pci_range *); -static struct rman *ofw_pci_get_rman(struct ofw_pci_softc *, int, u_int); +static int ofw_pcib_fill_ranges(phandle_t, struct ofw_pci_range *); +static struct rman *ofw_pcib_get_rman(struct ofw_pci_softc *, int, u_int); /* * Driver methods. */ -static device_method_t ofw_pci_methods[] = { +static device_method_t ofw_pcib_methods[] = { /* Device interface */ - DEVMETHOD(device_attach, ofw_pci_attach), + DEVMETHOD(device_attach, ofw_pcib_attach), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, ofw_pci_read_ivar), - DEVMETHOD(bus_write_ivar, ofw_pci_write_ivar), + DEVMETHOD(bus_read_ivar, ofw_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, ofw_pcib_write_ivar), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, ofw_pci_alloc_resource), - DEVMETHOD(bus_release_resource, ofw_pci_release_resource), - DEVMETHOD(bus_activate_resource, ofw_pci_activate_resource), - DEVMETHOD(bus_deactivate_resource, ofw_pci_deactivate_resource), - DEVMETHOD(bus_adjust_resource, ofw_pci_adjust_resource), - DEVMETHOD(bus_translate_resource, ofw_pci_translate_resource), + DEVMETHOD(bus_alloc_resource, ofw_pcib_alloc_resource), + DEVMETHOD(bus_release_resource, ofw_pcib_release_resource), + DEVMETHOD(bus_activate_resource, ofw_pcib_activate_resource), + DEVMETHOD(bus_deactivate_resource, ofw_pcib_deactivate_resource), + DEVMETHOD(bus_adjust_resource, ofw_pcib_adjust_resource), + DEVMETHOD(bus_translate_resource, ofw_pcib_translate_resource), #ifdef __powerpc__ - DEVMETHOD(bus_get_bus_tag, ofw_pci_bus_get_bus_tag), + DEVMETHOD(bus_get_bus_tag, ofw_pcib_bus_get_bus_tag), #endif /* pcib interface */ - DEVMETHOD(pcib_maxslots, ofw_pci_maxslots), - DEVMETHOD(pcib_route_interrupt, ofw_pci_route_interrupt), + DEVMETHOD(pcib_maxslots, ofw_pcib_maxslots), + DEVMETHOD(pcib_route_interrupt, ofw_pcib_route_interrupt), DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pci_get_node), + DEVMETHOD(ofw_bus_get_node, ofw_pcib_get_node), DEVMETHOD_END }; -DEFINE_CLASS_0(ofw_pci, ofw_pci_driver, ofw_pci_methods, 0); +DEFINE_CLASS_0(ofw_pcib, ofw_pcib_driver, ofw_pcib_methods, 0); int -ofw_pci_init(device_t dev) +ofw_pcib_init(device_t dev) { struct ofw_pci_softc *sc; phandle_t node; @@ -169,7 +169,7 @@ ofw_pci_init(device_t dev) sc->sc_nrange = 0; for (c = OF_child(node); c != 0; c = OF_peer(c)) { - n = ofw_pci_nranges(c, cell_info); + n = ofw_pcib_nranges(c, cell_info); if (n > 0) sc->sc_nrange += n; } @@ -181,13 +181,13 @@ ofw_pci_init(device_t dev) M_DEVBUF, M_WAITOK); i = 0; for (c = OF_child(node); c != 0; c = OF_peer(c)) { - n = ofw_pci_fill_ranges(c, &sc->sc_range[i]); + n = ofw_pcib_fill_ranges(c, &sc->sc_range[i]); if (n > 0) i += n; } KASSERT(i == sc->sc_nrange, ("range count mismatch")); } else { - sc->sc_nrange = ofw_pci_nranges(node, cell_info); + sc->sc_nrange = ofw_pcib_nranges(node, cell_info); if (sc->sc_nrange <= 0) { device_printf(dev, "could not getranges\n"); error = ENXIO; @@ -195,7 +195,7 @@ ofw_pci_init(device_t dev) } sc->sc_range = malloc(sc->sc_nrange * sizeof(sc->sc_range[0]), M_DEVBUF, M_WAITOK); - ofw_pci_fill_ranges(node, sc->sc_range); + ofw_pcib_fill_ranges(node, sc->sc_range); } sc->sc_io_rman.rm_type = RMAN_ARRAY; @@ -272,14 +272,14 @@ out: } int -ofw_pci_attach(device_t dev) +ofw_pcib_attach(device_t dev) { struct ofw_pci_softc *sc; int error; sc = device_get_softc(dev); if (!sc->sc_initialized) { - error = ofw_pci_init(dev); + error = ofw_pcib_init(dev); if (error != 0) return (error); } @@ -289,14 +289,14 @@ ofw_pci_attach(device_t dev) } static int -ofw_pci_maxslots(device_t dev) +ofw_pcib_maxslots(device_t dev) { return (PCI_SLOTMAX); } int -ofw_pci_route_interrupt(device_t bus, device_t dev, int pin) +ofw_pcib_route_interrupt(device_t bus, device_t dev, int pin) { struct ofw_pci_softc *sc; struct ofw_pci_register reg; @@ -333,7 +333,7 @@ ofw_pci_route_interrupt(device_t bus, device_t dev, int pin) } int -ofw_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +ofw_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) { struct ofw_pci_softc *sc; @@ -354,7 +354,7 @@ ofw_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) } int -ofw_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +ofw_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) { struct ofw_pci_softc *sc; @@ -372,7 +372,7 @@ ofw_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) } int -ofw_pci_nranges(phandle_t node, struct ofw_pci_cell_info *info) +ofw_pcib_nranges(phandle_t node, struct ofw_pci_cell_info *info) { ssize_t nbase_ranges; @@ -400,7 +400,7 @@ ofw_pci_nranges(phandle_t node, struct ofw_pci_cell_info *info) } static struct resource * -ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, +ofw_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { struct ofw_pci_softc *sc; @@ -420,7 +420,7 @@ ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, } #endif - rm = ofw_pci_get_rman(sc, type, flags); + rm = ofw_pcib_get_rman(sc, type, flags); if (rm == NULL) { return (bus_generic_alloc_resource(bus, child, type, rid, start, end, count, flags | needactivate)); @@ -449,7 +449,7 @@ ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, } static int -ofw_pci_release_resource(device_t bus, device_t child, int type, int rid, +ofw_pcib_release_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { struct ofw_pci_softc *sc; @@ -464,7 +464,7 @@ ofw_pci_release_resource(device_t bus, device_t child, int type, int rid, res)); #endif - rm = ofw_pci_get_rman(sc, type, rman_get_flags(res)); + rm = ofw_pcib_get_rman(sc, type, rman_get_flags(res)); if (rm == NULL) { return (bus_generic_release_resource(bus, child, type, rid, res)); @@ -480,7 +480,7 @@ ofw_pci_release_resource(device_t bus, device_t child, int type, int rid, } static int -ofw_pci_translate_resource(device_t bus, int type, rman_res_t start, +ofw_pcib_translate_resource(device_t bus, int type, rman_res_t start, rman_res_t *newstart) { struct ofw_pci_softc *sc; @@ -519,7 +519,7 @@ ofw_pci_translate_resource(device_t bus, int type, rman_res_t start, } static int -ofw_pci_activate_resource(device_t bus, device_t child, int type, int rid, +ofw_pcib_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { struct ofw_pci_softc *sc; @@ -587,7 +587,7 @@ ofw_pci_activate_resource(device_t bus, device_t child, int type, int rid, #ifdef __powerpc__ static bus_space_tag_t -ofw_pci_bus_get_bus_tag(device_t bus, device_t child) +ofw_pcib_bus_get_bus_tag(device_t bus, device_t child) { return (&bs_le_tag); @@ -595,7 +595,7 @@ ofw_pci_bus_get_bus_tag(device_t bus, device_t child) #endif static int -ofw_pci_deactivate_resource(device_t bus, device_t child, int type, int rid, +ofw_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { vm_size_t psize; @@ -612,7 +612,7 @@ ofw_pci_deactivate_resource(device_t bus, device_t child, int type, int rid, } static int -ofw_pci_adjust_resource(device_t bus, device_t child, int type, +ofw_pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *res, rman_res_t start, rman_res_t end) { struct rman *rm; @@ -625,7 +625,7 @@ ofw_pci_adjust_resource(device_t bus, device_t child, int type, start, end)); #endif - rm = ofw_pci_get_rman(sc, type, rman_get_flags(res)); + rm = ofw_pcib_get_rman(sc, type, rman_get_flags(res)); if (rm == NULL) { return (bus_generic_adjust_resource(bus, child, type, res, start, end)); @@ -638,7 +638,7 @@ ofw_pci_adjust_resource(device_t bus, device_t child, int type, } static phandle_t -ofw_pci_get_node(device_t bus, device_t dev) +ofw_pcib_get_node(device_t bus, device_t dev) { struct ofw_pci_softc *sc; @@ -649,7 +649,7 @@ ofw_pci_get_node(device_t bus, device_t dev) } static int -ofw_pci_fill_ranges(phandle_t node, struct ofw_pci_range *ranges) +ofw_pcib_fill_ranges(phandle_t node, struct ofw_pci_range *ranges) { int host_address_cells = 1, pci_address_cells = 3, size_cells = 2; cell_t *base_ranges; @@ -696,7 +696,7 @@ ofw_pci_fill_ranges(phandle_t node, struct ofw_pci_range *ranges) } static struct rman * -ofw_pci_get_rman(struct ofw_pci_softc *sc, int type, u_int flags) +ofw_pcib_get_rman(struct ofw_pci_softc *sc, int type, u_int flags) { switch (type) { diff --git a/sys/dev/ofw/ofwpci.h b/sys/dev/ofw/ofwpci.h index 3257fe68d49b..d58efa2daaef 100644 --- a/sys/dev/ofw/ofwpci.h +++ b/sys/dev/ofw/ofwpci.h @@ -32,7 +32,7 @@ /* * Export class definition for inheritance purposes */ -DECLARE_CLASS(ofw_pci_driver); +DECLARE_CLASS(ofw_pcib_driver); struct ofw_pci_cell_info { pcell_t host_address_cells; @@ -77,11 +77,11 @@ struct ofw_pci_softc { struct ofw_bus_iinfo sc_pci_iinfo; }; -int ofw_pci_init(device_t); -int ofw_pci_attach(device_t); -int ofw_pci_read_ivar(device_t, device_t, int, uintptr_t *); -int ofw_pci_write_ivar(device_t, device_t, int, uintptr_t); -int ofw_pci_route_interrupt(device_t, device_t, int); -int ofw_pci_nranges(phandle_t, struct ofw_pci_cell_info *); +int ofw_pcib_init(device_t); +int ofw_pcib_attach(device_t); +int ofw_pcib_read_ivar(device_t, device_t, int, uintptr_t *); +int ofw_pcib_write_ivar(device_t, device_t, int, uintptr_t); +int ofw_pcib_route_interrupt(device_t, device_t, int); +int ofw_pcib_nranges(phandle_t, struct ofw_pci_cell_info *); #endif /* _DEV_OFW_OFWPCI_H_ */ diff --git a/sys/dev/pci/pci_dw.c b/sys/dev/pci/pci_dw.c index f0aae5bf8418..47324eb70c8a 100644 --- a/sys/dev/pci/pci_dw.c +++ b/sys/dev/pci/pci_dw.c @@ -638,7 +638,7 @@ pci_dw_init(device_t dev) if (rv != 0) goto out; - rv = ofw_pci_init(dev); + rv = ofw_pcib_init(dev); if (rv != 0) goto out; rv = pci_dw_decode_ranges(sc, sc->ofw_pci.sc_range, @@ -686,4 +686,4 @@ static device_method_t pci_dw_methods[] = { }; DEFINE_CLASS_1(pcib, pci_dw_driver, pci_dw_methods, - sizeof(struct pci_dw_softc), ofw_pci_driver); + sizeof(struct pci_dw_softc), ofw_pcib_driver); diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx.c b/sys/powerpc/mpc85xx/pci_mpc85xx.c index b7035e372105..ced24d224860 100644 --- a/sys/powerpc/mpc85xx/pci_mpc85xx.c +++ b/sys/powerpc/mpc85xx/pci_mpc85xx.c @@ -258,7 +258,7 @@ static device_method_t fsl_pcib_methods[] = { static devclass_t fsl_pcib_devclass; DEFINE_CLASS_1(pcib, fsl_pcib_driver, fsl_pcib_methods, - sizeof(struct fsl_pcib_softc), ofw_pci_driver); + sizeof(struct fsl_pcib_softc), ofw_pcib_driver); EARLY_DRIVER_MODULE(pcib, ofwbus, fsl_pcib_driver, fsl_pcib_devclass, 0, 0, BUS_PASS_BUS); @@ -361,7 +361,7 @@ fsl_pcib_attach(device_t dev) * Initialize generic OF PCI interface (ranges, etc.) */ - error = ofw_pci_init(dev); + error = ofw_pcib_init(dev); if (error) return (error); @@ -429,7 +429,7 @@ fsl_pcib_attach(device_t dev) fsl_pcib_err_init(dev); - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); err: return (ENXIO); diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c index a475cafb93cd..965b1eeb45e7 100644 --- a/sys/powerpc/powermac/cpcht.c +++ b/sys/powerpc/powermac/cpcht.c @@ -140,7 +140,7 @@ struct cpcht_softc { static devclass_t cpcht_devclass; DEFINE_CLASS_1(pcib, cpcht_driver, cpcht_methods, sizeof(struct cpcht_softc), - ofw_pci_driver); + ofw_pcib_driver); EARLY_DRIVER_MODULE(cpcht, ofwbus, cpcht_driver, cpcht_devclass, 0, 0, BUS_PASS_BUS); @@ -212,7 +212,7 @@ cpcht_attach(device_t dev) /* Now make the mapping table available to the MPIC */ cpcht_irqmap = sc->htirq_map; - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); } static void diff --git a/sys/powerpc/powermac/grackle.c b/sys/powerpc/powermac/grackle.c index af5f5a389998..d3eb9ded1736 100644 --- a/sys/powerpc/powermac/grackle.c +++ b/sys/powerpc/powermac/grackle.c @@ -100,7 +100,7 @@ static device_method_t grackle_methods[] = { static devclass_t grackle_devclass; DEFINE_CLASS_1(pcib, grackle_driver, grackle_methods, - sizeof(struct grackle_softc), ofw_pci_driver); + sizeof(struct grackle_softc), ofw_pcib_driver); DRIVER_MODULE(grackle, ofwbus, grackle_driver, grackle_devclass, 0, 0); static int @@ -137,7 +137,7 @@ grackle_attach(device_t dev) sc->sc_addr = (vm_offset_t)pmap_mapdev(GRACKLE_ADDR, PAGE_SIZE); sc->sc_data = (vm_offset_t)pmap_mapdev(GRACKLE_DATA, PAGE_SIZE); - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); } static u_int32_t diff --git a/sys/powerpc/powermac/uninorthpci.c b/sys/powerpc/powermac/uninorthpci.c index 8933693963f5..508bcd29df0e 100644 --- a/sys/powerpc/powermac/uninorthpci.c +++ b/sys/powerpc/powermac/uninorthpci.c @@ -100,7 +100,7 @@ static device_method_t uninorth_methods[] = { static devclass_t uninorth_devclass; DEFINE_CLASS_1(pcib, uninorth_driver, uninorth_methods, - sizeof(struct uninorth_softc), ofw_pci_driver); + sizeof(struct uninorth_softc), ofw_pcib_driver); EARLY_DRIVER_MODULE(uninorth, ofwbus, uninorth_driver, uninorth_devclass, 0, 0, BUS_PASS_BUS); @@ -176,7 +176,7 @@ uninorth_attach(device_t dev) mtx_init(&sc->sc_cfg_mtx, "uninorth pcicfg", NULL, MTX_SPIN); - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); } static u_int32_t diff --git a/sys/powerpc/powernv/opal_pci.c b/sys/powerpc/powernv/opal_pci.c index 7bbffdff8e62..cbaa638863c7 100644 --- a/sys/powerpc/powernv/opal_pci.c +++ b/sys/powerpc/powernv/opal_pci.c @@ -169,7 +169,7 @@ struct opalpci_softc { static devclass_t opalpci_devclass; DEFINE_CLASS_1(pcib, opalpci_driver, opalpci_methods, - sizeof(struct opalpci_softc), ofw_pci_driver); + sizeof(struct opalpci_softc), ofw_pcib_driver); EARLY_DRIVER_MODULE(opalpci, ofwbus, opalpci_driver, opalpci_devclass, 0, 0, BUS_PASS_BUS); @@ -464,7 +464,7 @@ opalpci_attach(device_t dev) /* * General OFW PCI attach */ - err = ofw_pci_init(dev); + err = ofw_pcib_init(dev); if (err != 0) return (err); @@ -496,7 +496,7 @@ opalpci_attach(device_t dev) rp->pci + rp->size - 1); } - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); } static uint32_t diff --git a/sys/powerpc/pseries/rtas_pci.c b/sys/powerpc/pseries/rtas_pci.c index 97ece878aa7b..3c03724cf3d6 100644 --- a/sys/powerpc/pseries/rtas_pci.c +++ b/sys/powerpc/pseries/rtas_pci.c @@ -101,7 +101,7 @@ struct rtaspci_softc { static devclass_t rtaspci_devclass; DEFINE_CLASS_1(pcib, rtaspci_driver, rtaspci_methods, - sizeof(struct rtaspci_softc), ofw_pci_driver); + sizeof(struct rtaspci_softc), ofw_pcib_driver); DRIVER_MODULE(rtaspci, ofwbus, rtaspci_driver, rtaspci_devclass, 0, 0); static int @@ -143,7 +143,7 @@ rtaspci_attach(device_t dev) OF_getencprop(ofw_bus_get_node(dev), "ibm,pci-config-space-type", &sc->sc_extended_config, sizeof(sc->sc_extended_config)); - return (ofw_pci_attach(dev)); + return (ofw_pcib_attach(dev)); } static uint32_t From owner-dev-commits-src-main@freebsd.org Thu May 20 09:51:36 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83A3B63A586; Thu, 20 May 2021 09:51:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm4kw3R8Nz3NFF; Thu, 20 May 2021 09:51:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "R3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 4073727A95; Thu, 20 May 2021 09:51:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: by venus.codepro.be (Postfix, authenticated sender kp) id 6771C2A691; Thu, 20 May 2021 11:51:34 +0200 (CEST) From: "Kristof Provost" To: "Wojciech Macek" Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: d1cd99b14741 - main - ip_mroute: refactor bw_meter API Date: Thu, 20 May 2021 11:51:33 +0200 X-Mailer: MailMate (1.13.2r5673) Message-ID: <56731159-4265-4869-B253-F6FBFE573E71@FreeBSD.org> In-Reply-To: <202105200814.14K8EIfh065072@gitrepo.freebsd.org> References: <202105200814.14K8EIfh065072@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 09:51:36 -0000 Hi Wojciech, On 20 May 2021, at 10:14, Wojciech Macek wrote: > The branch main has been updated by wma: > > URL: = > https://cgit.FreeBSD.org/src/commit/?id=3Dd1cd99b147411b331a9bff6595337= 80ef297ef58 > > commit d1cd99b147411b331a9bff659533780ef297ef58 > Author: Wojciech Macek > AuthorDate: 2021-05-05 03:28:56 +0000 > Commit: Wojciech Macek > CommitDate: 2021-05-20 08:13:55 +0000 > > ip_mroute: refactor bw_meter API > It looks like this fails to build: = https://ci.freebsd.org/job/FreeBSD-main-amd64-build/20963/console Best regards, Kristof From owner-dev-commits-src-main@freebsd.org Thu May 20 10:13:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 528F363AA14 for ; Thu, 20 May 2021 10:13:33 +0000 (UTC) (envelope-from wma@semihalf.com) Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm5DF140Tz3mDs for ; Thu, 20 May 2021 10:13:32 +0000 (UTC) (envelope-from wma@semihalf.com) Received: by mail-yb1-xb34.google.com with SMTP id 191so16135437ybn.7 for ; Thu, 20 May 2021 03:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kRqvFCrdnE3cCamfUHp3DBs5VkAmL1jf7KOu7a/8iGM=; b=i4bPcjysZfNGkw0axUOSlARtBn5A/kpWfdxzLdXSo99sZePwF19+uj8ckbROqEsbGq dXwhthR8gjpLWz+FSoz/ncc8JCo2FB6gKaaKvKNKg65EDhgMoIle6fcWRvdeYT4/iLJa Q6RHtf0ohdgUHUXnazHiwDbTkw1xDtiewVn9bENqgQ23DvggaxF5se2dsYKVAS+NLstg eFfmPzY5xEtfm8PsjZi6wX7qatEegPWEvIOA7aJDBJZ27K3T7eZ+vRQJjrBUlVwcQE8s qLpfDdEPLN1dU2AjbW+z8+IDIuAPqAsOtsZK04L2UZDOAiLvLDuOPwuGhid2yvC2T4QM zUfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kRqvFCrdnE3cCamfUHp3DBs5VkAmL1jf7KOu7a/8iGM=; b=rGnUNNGr2TOrcNpEIeWkPlfPfBLO7wJ3PGjDqUqfddTaLce2kzr/QCvPyAlPmJ5jkZ hJTK164QUoRpNehCoSNtSgDy2pDeu4+jGFxB/Se/ENf7VbW9XJ9PSYI8DrRkT/EtMor7 jH7O9Rsg1CSu/CYT7yNlUQys0B21mCCaFoLR6KazDq5C7ltZy3QVxx2+cNp5tlBQpMJI NcafoUg2YZfr/zwYrme9DVMLIEMiZqcrt2M8mnY79YRiXo0lXgOX1iQU7ExhhqgWh6T1 STTJCBAa6qdgvmCcy8Z0bGnn66aihmFvk+HFaXyC2qX3puEEDDV60fUxTsES43x3+CrX lpuw== X-Gm-Message-State: AOAM531S5Mxud0XN1TchweIVUr47A0VK/nUBQB4+sWY/jag2H5eTGF1A V26eiIuTYivJRick8N+8is5vuk0YvuPzaT31oiwNjg== X-Google-Smtp-Source: ABdhPJxtl6GRSMYHU2TuYzit94xyU8DBvfXLjBfwjLw0dDJFAu7bO/EfPH3XWYps8flvIblm92GPxAnnQBfaeLWgOIg= X-Received: by 2002:a25:af0d:: with SMTP id a13mr6214802ybh.14.1621505612132; Thu, 20 May 2021 03:13:32 -0700 (PDT) MIME-Version: 1.0 References: <202105200814.14K8EIfh065072@gitrepo.freebsd.org> <56731159-4265-4869-B253-F6FBFE573E71@FreeBSD.org> In-Reply-To: <56731159-4265-4869-B253-F6FBFE573E71@FreeBSD.org> From: Wojciech Macek Date: Thu, 20 May 2021 12:13:21 +0200 Message-ID: Subject: Re: git: d1cd99b14741 - main - ip_mroute: refactor bw_meter API To: Kristof Provost Cc: Wojciech Macek , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4Fm5DF140Tz3mDs X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 10:13:33 -0000 Sorry, I will handle it. For now I'm going to revert it and push a fixed one tomorrow. Wojtek czw., 20 maj 2021 o 11:51 Kristof Provost napisa=C5=82(a): > Hi Wojciech, > > On 20 May 2021, at 10:14, Wojciech Macek wrote: > > The branch main has been updated by wma: > > > > URL: > > > https://cgit.FreeBSD.org/src/commit/?id=3Dd1cd99b147411b331a9bff659533780= ef297ef58 > > > > commit d1cd99b147411b331a9bff659533780ef297ef58 > > Author: Wojciech Macek > > AuthorDate: 2021-05-05 03:28:56 +0000 > > Commit: Wojciech Macek > > CommitDate: 2021-05-20 08:13:55 +0000 > > > > ip_mroute: refactor bw_meter API > > > It looks like this fails to build: > https://ci.freebsd.org/job/FreeBSD-main-amd64-build/20963/console > > Best regards, > Kristof > From owner-dev-commits-src-main@freebsd.org Thu May 20 10:15:10 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E014263AB9C; Thu, 20 May 2021 10:15: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 4Fm5G65B9Yz3nMY; Thu, 20 May 2021 10:15: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 8209F23FC4; Thu, 20 May 2021 10:15: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 14KAFACI025534; Thu, 20 May 2021 10:15:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KAFAq5025533; Thu, 20 May 2021 10:15:10 GMT (envelope-from git) Date: Thu, 20 May 2021 10:15:10 GMT Message-Id: <202105201015.14KAFAq5025533@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 787845c0e8e8 - main - Revert "ip_mroute: refactor bw_meter API" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 787845c0e8e831bf5b2d000950241cb23c16ca45 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 10:15:11 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=787845c0e8e831bf5b2d000950241cb23c16ca45 commit 787845c0e8e831bf5b2d000950241cb23c16ca45 Author: Wojciech Macek AuthorDate: 2021-05-20 10:14:58 +0000 Commit: Wojciech Macek CommitDate: 2021-05-20 10:14:58 +0000 Revert "ip_mroute: refactor bw_meter API" This reverts commit d1cd99b147411b331a9bff659533780ef297ef58. --- sys/netinet/ip_mroute.c | 610 +++++++++++++++++++++++++++++++----------------- sys/netinet/ip_mroute.h | 10 +- 2 files changed, 400 insertions(+), 220 deletions(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 0cb980b7247e..b8e677ba9af1 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -49,7 +49,6 @@ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, August 1999, October 2000 * Modified by Hitoshi Asaeda, WIDE, August 2000 * Modified by Pavlin Radoslavov, ICSI, October 2002 - * Modified by Wojciech Macek, Semihalf, May 2021 * * MROUTING Revision: 3.5 * and PIM-SMv2 and PIM-DM support, advanced API support, @@ -203,6 +202,16 @@ VNET_DEFINE_STATIC(struct callout, expire_upcalls_ch); * Bandwidth meter variables and constants */ static MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters"); +/* + * Pending timeouts are stored in a hash table, the key being the + * expiration time. Periodically, the entries are analysed and processed. + */ +#define BW_METER_BUCKETS 1024 +VNET_DEFINE_STATIC(struct bw_meter **, bw_meter_timers); +#define V_bw_meter_timers VNET(bw_meter_timers) +VNET_DEFINE_STATIC(struct callout, bw_meter_ch); +#define V_bw_meter_ch VNET(bw_meter_ch) +#define BW_METER_PERIOD (hz) /* periodical handling of bw meters */ /* * Pending upcalls are stored in a vector which is flushed when @@ -311,13 +320,14 @@ static int add_mfc(struct mfcctl2 *); static int add_vif(struct vifctl *); static void bw_meter_prepare_upcall(struct bw_meter *, struct timeval *); static void bw_meter_process(void); -static void bw_meter_geq_receive_packet(struct bw_meter *, int, +static void bw_meter_receive_packet(struct bw_meter *, int, struct timeval *); static void bw_upcalls_send(void); static int del_bw_upcall(struct bw_upcall *); static int del_mfc(struct mfcctl2 *); static int del_vif(vifi_t); static int del_vif_locked(vifi_t); +static void expire_bw_meter_process(void *); static void expire_bw_upcalls_send(void *); static void expire_mfc(struct mfc *); static void expire_upcalls(void *); @@ -675,6 +685,8 @@ ip_mrouter_init(struct socket *so, int version) curvnet); callout_reset(&V_bw_upcalls_ch, BW_UPCALLS_PERIOD, expire_bw_upcalls_send, curvnet); + callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, + curvnet); V_ip_mrouter = so; ip_mrouter_cnt++; @@ -733,6 +745,7 @@ X_ip_mrouter_done(void) callout_stop(&V_expire_upcalls_ch); callout_stop(&V_bw_upcalls_ch); + callout_stop(&V_bw_meter_ch); MFC_LOCK(); @@ -753,6 +766,7 @@ X_ip_mrouter_done(void) bzero(V_nexpire, sizeof(V_nexpire[0]) * mfchashsize); V_bw_upcalls_n = 0; + bzero(V_bw_meter_timers, BW_METER_BUCKETS * sizeof(*V_bw_meter_timers)); MFC_UNLOCK(); @@ -1022,8 +1036,7 @@ expire_mfc(struct mfc *rt) MFC_LOCK_ASSERT(); - free_bw_list(rt->mfc_bw_meter_leq); - free_bw_list(rt->mfc_bw_meter_geq); + free_bw_list(rt->mfc_bw_meter); TAILQ_FOREACH_SAFE(rte, &rt->mfc_stall, rte_link, nrte) { m_freem(rte->m); @@ -1126,8 +1139,7 @@ add_mfc(struct mfcctl2 *mfccp) rt->mfc_nstall = 0; rt->mfc_expire = 0; - rt->mfc_bw_meter_leq = NULL; - rt->mfc_bw_meter_geq = NULL; + rt->mfc_bw_meter = NULL; /* insert new entry at head of hash chain */ LIST_INSERT_HEAD(&V_mfchashtbl[hash], rt, mfc_hash); @@ -1167,10 +1179,8 @@ del_mfc(struct mfcctl2 *mfccp) /* * free the bw_meter entries */ - free_bw_list(rt->mfc_bw_meter_leq); - rt->mfc_bw_meter_leq = NULL; - free_bw_list(rt->mfc_bw_meter_geq); - rt->mfc_bw_meter_geq = NULL; + free_bw_list(rt->mfc_bw_meter); + rt->mfc_bw_meter = NULL; LIST_REMOVE(rt, mfc_hash); free(rt, M_MRTABLE); @@ -1383,8 +1393,7 @@ fail: /* clear the RP address */ rt->mfc_rp.s_addr = INADDR_ANY; - rt->mfc_bw_meter_leq = NULL; - rt->mfc_bw_meter_geq = NULL; + rt->mfc_bw_meter = NULL; /* initialize pkt counters per src-grp */ rt->mfc_pkt_cnt = 0; @@ -1450,6 +1459,16 @@ expire_upcalls(void *arg) if (rt->mfc_expire == 0 || --rt->mfc_expire > 0) continue; + /* + * free the bw_meter entries + */ + while (rt->mfc_bw_meter != NULL) { + struct bw_meter *x = rt->mfc_bw_meter; + + rt->mfc_bw_meter = x->bm_mfc_next; + free(x, M_BWMETER); + } + MRTSTAT_INC(mrts_cache_cleanups); CTR3(KTR_IPMF, "%s: expire (%lx, %lx)", __func__, (u_long)ntohl(rt->mfc_origin.s_addr), @@ -1583,22 +1602,14 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) /* * Perform upcall-related bw measuring. */ - if ((rt->mfc_bw_meter_geq != NULL) || (rt->mfc_bw_meter_leq != NULL)) { + if (rt->mfc_bw_meter != NULL) { struct bw_meter *x; struct timeval now; microtime(&now); MFC_LOCK_ASSERT(); - /* Process meters for Greater-or-EQual case */ - for (x = rt->mfc_bw_meter_geq; x != NULL; x = x->bm_mfc_next) - bw_meter_geq_receive_packet(x, plen, &now); - - /* Process meters for Lower-or-EQual case */ - for (x = rt->mfc_bw_meter_leq; x != NULL; x = x->bm_mfc_next) { - /* Record that a packet is received */ - x->bm_measured.b_packets++; - x->bm_measured.b_bytes += plen; - } + for (x = rt->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) + bw_meter_receive_packet(x, plen, &now); } return 0; @@ -1748,139 +1759,84 @@ compute_bw_meter_flags(struct bw_upcall *req) return flags; } -static void -expire_bw_meter_leq(void *arg) -{ - struct bw_meter *x = arg; - struct timeval now; - /* - * INFO: - * callout is always executed with MFC_LOCK taken - */ - - CURVNET_SET((struct vnet *)x->arg); - - microtime(&now); - - /* - * Test if we should deliver an upcall - */ - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, &now); - } - - /* Send all upcalls that are pending delivery */ - bw_upcalls_send(); - - /* Reset counters */ - x->bm_start_time = now; - x->bm_measured.b_bytes = 0; - x->bm_measured.b_packets = 0; - - callout_schedule(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time)); - - CURVNET_RESTORE(); -} - /* * Add a bw_meter entry */ static int add_bw_upcall(struct bw_upcall *req) { - struct mfc *mfc; - struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, - BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; - struct timeval now; - struct bw_meter *x, **bwm_ptr; - uint32_t flags; - - if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) - return EOPNOTSUPP; - - /* Test if the flags are valid */ - if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) - return EINVAL; - if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) - return EINVAL; - if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - return EINVAL; - - /* Test if the threshold time interval is valid */ - if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) - return EINVAL; + struct mfc *mfc; + struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, + BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; + struct timeval now; + struct bw_meter *x; + uint32_t flags; - flags = compute_bw_meter_flags(req); + if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) + return EOPNOTSUPP; - /* - * Find if we have already same bw_meter entry - */ - MFC_LOCK(); - mfc = mfc_find(&req->bu_src, &req->bu_dst); - if (mfc == NULL) { - MFC_UNLOCK(); - return EADDRNOTAVAIL; - } + /* Test if the flags are valid */ + if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) + return EINVAL; + if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) + return EINVAL; + if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + return EINVAL; - /* Choose an appropriate bw_meter list */ - if (req->bu_flags & BW_UPCALL_GEQ) - bwm_ptr = &mfc->mfc_bw_meter_geq; - else - bwm_ptr = &mfc->mfc_bw_meter_leq; - - for (x = *bwm_ptr; x != NULL; x = x->bm_mfc_next) { - if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, - &req->bu_threshold.b_time, ==)) - && (x->bm_threshold.b_packets - == req->bu_threshold.b_packets) - && (x->bm_threshold.b_bytes - == req->bu_threshold.b_bytes) - && (x->bm_flags & BW_METER_USER_FLAGS) - == flags) { - MFC_UNLOCK(); - return 0; /* XXX Already installed */ - } - } + /* Test if the threshold time interval is valid */ + if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) + return EINVAL; - /* Allocate the new bw_meter entry */ - x = (struct bw_meter*) malloc(sizeof(*x), M_BWMETER, M_NOWAIT); - if (x == NULL) { - MFC_UNLOCK(); - return ENOBUFS; - } + flags = compute_bw_meter_flags(req); - /* Set the new bw_meter entry */ - x->bm_threshold.b_time = req->bu_threshold.b_time; - microtime(&now); - x->bm_start_time = now; - x->bm_threshold.b_packets = req->bu_threshold.b_packets; - x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags = flags; - x->bm_time_next = NULL; - x->bm_mfc = mfc; - x->arg = curvnet; - - /* For LEQ case create periodic callout */ - if (req->bu_flags & BW_UPCALL_LEQ) { - callout_init_mtx(&x->bm_meter_callout, &mfc_mtx,0); - callout_reset(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time), - expire_bw_meter_leq, x); + /* + * Find if we have already same bw_meter entry + */ + MFC_LOCK(); + mfc = mfc_find(&req->bu_src, &req->bu_dst); + if (mfc == NULL) { + MFC_UNLOCK(); + return EADDRNOTAVAIL; + } + for (x = mfc->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) { + if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, + &req->bu_threshold.b_time, ==)) && + (x->bm_threshold.b_packets == req->bu_threshold.b_packets) && + (x->bm_threshold.b_bytes == req->bu_threshold.b_bytes) && + (x->bm_flags & BW_METER_USER_FLAGS) == flags) { + MFC_UNLOCK(); + return 0; /* XXX Already installed */ } + } - /* Add the new bw_meter entry to the front of entries for this MFC */ - x->bm_mfc_next = *bwm_ptr; - *bwm_ptr = x; - + /* Allocate the new bw_meter entry */ + x = (struct bw_meter *)malloc(sizeof(*x), M_BWMETER, M_NOWAIT); + if (x == NULL) { MFC_UNLOCK(); + return ENOBUFS; + } - return 0; + /* Set the new bw_meter entry */ + x->bm_threshold.b_time = req->bu_threshold.b_time; + microtime(&now); + x->bm_start_time = now; + x->bm_threshold.b_packets = req->bu_threshold.b_packets; + x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; + x->bm_measured.b_packets = 0; + x->bm_measured.b_bytes = 0; + x->bm_flags = flags; + x->bm_time_next = NULL; + x->bm_time_hash = BW_METER_BUCKETS; + + /* Add the new bw_meter entry to the front of entries for this MFC */ + x->bm_mfc = mfc; + x->bm_mfc_next = mfc->mfc_bw_meter; + mfc->mfc_bw_meter = x; + schedule_bw_meter(x, &now); + MFC_UNLOCK(); + + return 0; } static void @@ -1889,11 +1845,8 @@ free_bw_list(struct bw_meter *list) while (list != NULL) { struct bw_meter *x = list; - /* MFC_LOCK must be held here */ - if (x->bm_flags & BW_METER_LEQ) - callout_drain(&x->bm_meter_callout); - list = list->bm_mfc_next; + unschedule_bw_meter(x); free(x, M_BWMETER); } } @@ -1905,7 +1858,7 @@ static int del_bw_upcall(struct bw_upcall *req) { struct mfc *mfc; - struct bw_meter *x, **bwm_ptr; + struct bw_meter *x; if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) return EOPNOTSUPP; @@ -1923,14 +1876,8 @@ del_bw_upcall(struct bw_upcall *req) */ struct bw_meter *list; - /* Free LEQ list */ - list = mfc->mfc_bw_meter_leq; - mfc->mfc_bw_meter_leq = NULL; - free_bw_list(list); - - /* Free GEQ list */ - list = mfc->mfc_bw_meter_geq; - mfc->mfc_bw_meter_geq = NULL; + list = mfc->mfc_bw_meter; + mfc->mfc_bw_meter = NULL; free_bw_list(list); MFC_UNLOCK(); return 0; @@ -1940,14 +1887,8 @@ del_bw_upcall(struct bw_upcall *req) flags = compute_bw_meter_flags(req); - /* Choose an appropriate bw_meter list */ - if (req->bu_flags & BW_UPCALL_GEQ) - bwm_ptr = &mfc->mfc_bw_meter_geq; - else - bwm_ptr = &mfc->mfc_bw_meter_leq; - /* Find the bw_meter entry to delete */ - for (prev = NULL, x = *bwm_ptr; x != NULL; + for (prev = NULL, x = mfc->mfc_bw_meter; x != NULL; prev = x, x = x->bm_mfc_next) { if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, &req->bu_threshold.b_time, ==)) && @@ -1960,11 +1901,9 @@ del_bw_upcall(struct bw_upcall *req) if (prev != NULL) prev->bm_mfc_next = x->bm_mfc_next; /* remove from middle*/ else - *bwm_ptr = x->bm_mfc_next;/* new head of list */ - - if (req->bu_flags & BW_UPCALL_LEQ) - callout_stop(&x->bm_meter_callout); + x->bm_mfc->mfc_bw_meter = x->bm_mfc_next;/* new head of list */ + unschedule_bw_meter(x); MFC_UNLOCK(); /* Free the bw_meter entry */ free(x, M_BWMETER); @@ -1981,15 +1920,16 @@ del_bw_upcall(struct bw_upcall *req) * Perform bandwidth measurement processing that may result in an upcall */ static void -bw_meter_geq_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) +bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) { - struct timeval delta; + struct timeval delta; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); + if (x->bm_flags & BW_METER_GEQ) { /* * Processing for ">=" type of bw_meter entry */ @@ -2009,15 +1949,63 @@ bw_meter_geq_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) * Test if we should deliver an upcall */ if (!(x->bm_flags & BW_METER_UPCALL_DELIVERED)) { - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, nowp); - x->bm_flags |= BW_METER_UPCALL_DELIVERED; - } + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, nowp); + x->bm_flags |= BW_METER_UPCALL_DELIVERED; + } + } + } else if (x->bm_flags & BW_METER_LEQ) { + /* + * Processing for "<=" type of bw_meter entry + */ + if (BW_TIMEVALCMP(&delta, &x->bm_threshold.b_time, >)) { + /* + * We are behind time with the multicast forwarding table + * scanning for "<=" type of bw_meter entries, so test now + * if we should deliver an upcall. + */ + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, nowp); + } + /* Reschedule the bw_meter entry */ + unschedule_bw_meter(x); + schedule_bw_meter(x, nowp); + } + + /* Record that a packet is received */ + x->bm_measured.b_packets++; + x->bm_measured.b_bytes += plen; + + /* + * Test if we should restart the measuring interval + */ + if ((x->bm_flags & BW_METER_UNIT_PACKETS && + x->bm_measured.b_packets <= x->bm_threshold.b_packets) || + (x->bm_flags & BW_METER_UNIT_BYTES && + x->bm_measured.b_bytes <= x->bm_threshold.b_bytes)) { + /* Don't restart the measuring interval */ + } else { + /* Do restart the measuring interval */ + /* + * XXX: note that we don't unschedule and schedule, because this + * might be too much overhead per packet. Instead, when we process + * all entries for a given timer hash bin, we check whether it is + * really a timeout. If not, we reschedule at that time. + */ + x->bm_start_time = *nowp; + x->bm_measured.b_packets = 0; + x->bm_measured.b_bytes = 0; + x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; } + } } /* @@ -2026,44 +2014,44 @@ bw_meter_geq_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) static void bw_meter_prepare_upcall(struct bw_meter *x, struct timeval *nowp) { - struct timeval delta; - struct bw_upcall *u; + struct timeval delta; + struct bw_upcall *u; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - /* - * Compute the measured time interval - */ - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + /* + * Compute the measured time interval + */ + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); - /* - * If there are too many pending upcalls, deliver them now - */ - if (V_bw_upcalls_n >= BW_UPCALLS_MAX) - bw_upcalls_send(); + /* + * If there are too many pending upcalls, deliver them now + */ + if (V_bw_upcalls_n >= BW_UPCALLS_MAX) + bw_upcalls_send(); - /* - * Set the bw_upcall entry - */ - u = &V_bw_upcalls[V_bw_upcalls_n++]; - u->bu_src = x->bm_mfc->mfc_origin; - u->bu_dst = x->bm_mfc->mfc_mcastgrp; - u->bu_threshold.b_time = x->bm_threshold.b_time; - u->bu_threshold.b_packets = x->bm_threshold.b_packets; - u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; - u->bu_measured.b_time = delta; - u->bu_measured.b_packets = x->bm_measured.b_packets; - u->bu_measured.b_bytes = x->bm_measured.b_bytes; - u->bu_flags = 0; - if (x->bm_flags & BW_METER_UNIT_PACKETS) - u->bu_flags |= BW_UPCALL_UNIT_PACKETS; - if (x->bm_flags & BW_METER_UNIT_BYTES) - u->bu_flags |= BW_UPCALL_UNIT_BYTES; - if (x->bm_flags & BW_METER_GEQ) - u->bu_flags |= BW_UPCALL_GEQ; - if (x->bm_flags & BW_METER_LEQ) - u->bu_flags |= BW_UPCALL_LEQ; + /* + * Set the bw_upcall entry + */ + u = &V_bw_upcalls[V_bw_upcalls_n++]; + u->bu_src = x->bm_mfc->mfc_origin; + u->bu_dst = x->bm_mfc->mfc_mcastgrp; + u->bu_threshold.b_time = x->bm_threshold.b_time; + u->bu_threshold.b_packets = x->bm_threshold.b_packets; + u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; + u->bu_measured.b_time = delta; + u->bu_measured.b_packets = x->bm_measured.b_packets; + u->bu_measured.b_bytes = x->bm_measured.b_bytes; + u->bu_flags = 0; + if (x->bm_flags & BW_METER_UNIT_PACKETS) + u->bu_flags |= BW_UPCALL_UNIT_PACKETS; + if (x->bm_flags & BW_METER_UNIT_BYTES) + u->bu_flags |= BW_UPCALL_UNIT_BYTES; + if (x->bm_flags & BW_METER_GEQ) + u->bu_flags |= BW_UPCALL_GEQ; + if (x->bm_flags & BW_METER_LEQ) + u->bu_flags |= BW_UPCALL_LEQ; } /* @@ -2115,6 +2103,183 @@ bw_upcalls_send(void) } } +/* + * Compute the timeout hash value for the bw_meter entries + */ +#define BW_METER_TIMEHASH(bw_meter, hash) \ + do { \ + struct timeval next_timeval = (bw_meter)->bm_start_time; \ + \ + BW_TIMEVALADD(&next_timeval, &(bw_meter)->bm_threshold.b_time); \ + (hash) = next_timeval.tv_sec; \ + if (next_timeval.tv_usec) \ + (hash)++; /* XXX: make sure we don't timeout early */ \ + (hash) %= BW_METER_BUCKETS; \ + } while (0) + +/* + * Schedule a timer to process periodically bw_meter entry of type "<=" + * by linking the entry in the proper hash bucket. + */ +static void +schedule_bw_meter(struct bw_meter *x, struct timeval *nowp) +{ + int time_hash; + + MFC_LOCK_ASSERT(); + + if (!(x->bm_flags & BW_METER_LEQ)) + return; /* XXX: we schedule timers only for "<=" entries */ + + /* + * Reset the bw_meter entry + */ + x->bm_start_time = *nowp; + x->bm_measured.b_packets = 0; + x->bm_measured.b_bytes = 0; + x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; + + /* + * Compute the timeout hash value and insert the entry + */ + BW_METER_TIMEHASH(x, time_hash); + x->bm_time_next = V_bw_meter_timers[time_hash]; + V_bw_meter_timers[time_hash] = x; + x->bm_time_hash = time_hash; +} + +/* + * Unschedule the periodic timer that processes bw_meter entry of type "<=" + * by removing the entry from the proper hash bucket. + */ +static void +unschedule_bw_meter(struct bw_meter *x) +{ + int time_hash; + struct bw_meter *prev, *tmp; + + MFC_LOCK_ASSERT(); + + if (!(x->bm_flags & BW_METER_LEQ)) + return; /* XXX: we schedule timers only for "<=" entries */ + + /* + * Compute the timeout hash value and delete the entry + */ + time_hash = x->bm_time_hash; + if (time_hash >= BW_METER_BUCKETS) + return; /* Entry was not scheduled */ + + for (prev = NULL, tmp = V_bw_meter_timers[time_hash]; + tmp != NULL; prev = tmp, tmp = tmp->bm_time_next) + if (tmp == x) + break; + + if (tmp == NULL) + panic("unschedule_bw_meter: bw_meter entry not found"); + + if (prev != NULL) + prev->bm_time_next = x->bm_time_next; + else + V_bw_meter_timers[time_hash] = x->bm_time_next; + + x->bm_time_next = NULL; + x->bm_time_hash = BW_METER_BUCKETS; +} + +/* + * Process all "<=" type of bw_meter that should be processed now, + * and for each entry prepare an upcall if necessary. Each processed + * entry is rescheduled again for the (periodic) processing. + * + * This is run periodically (once per second normally). On each round, + * all the potentially matching entries are in the hash slot that we are + * looking at. + */ +static void +bw_meter_process() +{ + uint32_t loops; + int i; + struct timeval now, process_endtime; + + microtime(&now); + if (V_last_tv_sec == now.tv_sec) + return; /* nothing to do */ + + loops = now.tv_sec - V_last_tv_sec; + V_last_tv_sec = now.tv_sec; + if (loops > BW_METER_BUCKETS) + loops = BW_METER_BUCKETS; + + MFC_LOCK(); + /* + * Process all bins of bw_meter entries from the one after the last + * processed to the current one. On entry, i points to the last bucket + * visited, so we need to increment i at the beginning of the loop. + */ + for (i = (now.tv_sec - loops) % BW_METER_BUCKETS; loops > 0; loops--) { + struct bw_meter *x, *tmp_list; + + if (++i >= BW_METER_BUCKETS) + i = 0; + + /* Disconnect the list of bw_meter entries from the bin */ + tmp_list = V_bw_meter_timers[i]; + V_bw_meter_timers[i] = NULL; + + /* Process the list of bw_meter entries */ + while (tmp_list != NULL) { + x = tmp_list; + tmp_list = tmp_list->bm_time_next; + + /* Test if the time interval is over */ + process_endtime = x->bm_start_time; + BW_TIMEVALADD(&process_endtime, &x->bm_threshold.b_time); + if (BW_TIMEVALCMP(&process_endtime, &now, >)) { + /* Not yet: reschedule, but don't reset */ + int time_hash; + + BW_METER_TIMEHASH(x, time_hash); + if (time_hash == i && process_endtime.tv_sec == now.tv_sec) { + /* + * XXX: somehow the bin processing is a bit ahead of time. + * Put the entry in the next bin. + */ + if (++time_hash >= BW_METER_BUCKETS) + time_hash = 0; + } + x->bm_time_next = V_bw_meter_timers[time_hash]; + V_bw_meter_timers[time_hash] = x; + x->bm_time_hash = time_hash; + + continue; + } + + /* + * Test if we should deliver an upcall + */ + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, &now); + } + + /* + * Reschedule for next processing + */ + schedule_bw_meter(x, &now); + } + } + + /* Send all upcalls that are pending delivery */ + bw_upcalls_send(); + + MFC_UNLOCK(); +} + /* * A periodic function for sending all upcalls that are pending delivery */ @@ -2132,6 +2297,23 @@ expire_bw_upcalls_send(void *arg) CURVNET_RESTORE(); } +/* + * A periodic function for periodic scanning of the multicast forwarding + * table for processing all "<=" bw_meter entries. + */ +static void +expire_bw_meter_process(void *arg) +{ + CURVNET_SET((struct vnet *) arg); + + if (V_mrt_api_config & MRT_MFC_BW_UPCALL) + bw_meter_process(); + + callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, + curvnet); + CURVNET_RESTORE(); +} + /* * End of bandwidth monitoring code */ @@ -2653,11 +2835,14 @@ vnet_mroute_init(const void *unused __unused) V_viftable = mallocarray(MAXVIFS, sizeof(*V_viftable), M_MRTABLE, M_WAITOK|M_ZERO); + V_bw_meter_timers = mallocarray(BW_METER_BUCKETS, + sizeof(*V_bw_meter_timers), M_MRTABLE, M_WAITOK|M_ZERO); V_bw_upcalls = mallocarray(BW_UPCALLS_MAX, sizeof(*V_bw_upcalls), M_MRTABLE, M_WAITOK|M_ZERO); callout_init(&V_expire_upcalls_ch, 1); callout_init(&V_bw_upcalls_ch, 1); + callout_init(&V_bw_meter_ch, 1); } VNET_SYSINIT(vnet_mroute_init, SI_SUB_PROTO_MC, SI_ORDER_ANY, vnet_mroute_init, @@ -2668,6 +2853,7 @@ vnet_mroute_uninit(const void *unused __unused) { free(V_bw_upcalls, M_MRTABLE); + free(V_bw_meter_timers, M_MRTABLE); free(V_viftable, M_MRTABLE); free(V_nexpire, M_MRTABLE); V_nexpire = NULL; diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h index 07d77065de33..6ef99c0172f3 100644 --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -283,10 +283,7 @@ struct mfc { struct timeval mfc_last_assert; /* last time I sent an assert*/ uint8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ struct in_addr mfc_rp; /* the RP address */ - struct bw_meter *mfc_bw_meter_leq; /* list of bandwidth meters - for Lower-or-EQual case */ - struct bw_meter *mfc_bw_meter_geq; /* list of bandwidth meters - for Greater-or-EQual case */ + struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */ u_long mfc_nstall; /* # of packets awaiting mfc */ TAILQ_HEAD(, rtdetq) mfc_stall; /* q of packets awaiting mfc */ }; @@ -330,6 +327,7 @@ struct rtdetq { struct bw_meter { struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */ struct bw_meter *bm_time_next; /* next bw meter (same time) */ + uint32_t bm_time_hash; /* the time hash value */ struct mfc *bm_mfc; /* the corresponding mfc */ uint32_t bm_flags; /* misc flags (see below) */ #define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ @@ -346,10 +344,6 @@ struct bw_meter { struct bw_data bm_threshold; /* the upcall threshold */ struct bw_data bm_measured; /* the measured bw */ struct timeval bm_start_time; /* abs. time */ -#ifdef _KERNEL - struct callout bm_meter_callout; /* Periodic callout */ - void* arg; /* custom argument */ -#endif }; #ifdef _KERNEL From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:49 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F4AD63BFD3; Thu, 20 May 2021 11:54:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm7T53YyTz3G5k; Thu, 20 May 2021 11:54:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 612D7259C9; Thu, 20 May 2021 11:54:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14KBsnx6056820; Thu, 20 May 2021 11:54:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBsn6O056819; Thu, 20 May 2021 11:54:49 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:49 GMT Message-Id: <202105201154.14KBsn6O056819@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 1732afaa0dae - main - pf: Add DIOCGETSTATENV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1732afaa0dae9d844e341f2c1d6ed4b79c403bfb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:49 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1732afaa0dae9d844e341f2c1d6ed4b79c403bfb commit 1732afaa0dae9d844e341f2c1d6ed4b79c403bfb Author: Kristof Provost AuthorDate: 2021-05-05 12:33:55 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:26 +0000 pf: Add DIOCGETSTATENV Add DIOCGETSTATENV, an nvlist-based alternative to DIOCGETSTATE. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30242 --- share/man/man4/pf.4 | 4 +- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 226 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+), 2 deletions(-) diff --git a/share/man/man4/pf.4 b/share/man/man4/pf.4 index 2fb132203908..24843535c924 100644 --- a/share/man/man4/pf.4 +++ b/share/man/man4/pf.4 @@ -326,14 +326,14 @@ struct pfioc_state { struct pfsync_state state; }; .Ed -.It Dv DIOCGETSTATE Fa "struct pfioc_state *ps" +.It Dv DIOCGETSTATENV Fa "struct pfioc_nv *nv" Extract the entry identified by the .Va id and .Va creatorid fields of the .Va state -structure from the state table. +nvlist from the state table. .It Dv DIOCKILLSTATES Fa "struct pfioc_state_kill *psk" Remove matching entries from the state table. This ioctl returns the number of killed states in diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 51c51a82b36d..1bd1ebd27449 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1257,6 +1257,7 @@ struct pfioc_iface { #define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) #define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv) #define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) +#define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) #define DIOCCLRSTATUS _IO ('D', 22) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 2d13ddf1ac61..1ea7310ebebb 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -208,6 +208,7 @@ static int pf_killstates_row(struct pf_kstate_kill *, struct pf_idhash *); static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); +static int pf_getstate(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2474,6 +2475,157 @@ errout: return (error); } +static nvlist_t * +pf_state_key_to_nvstate_key(const struct pf_state_key *key) +{ + nvlist_t *nvl, *tmp; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + for (int i = 0; i < 2; i++) { + tmp = pf_addr_to_nvaddr(&key->addr[i]); + if (tmp == NULL) + goto errout; + nvlist_append_nvlist_array(nvl, "addr", tmp); + nvlist_append_number_array(nvl, "port", key->port[i]); + } + nvlist_add_number(nvl, "af", key->af); + nvlist_add_number(nvl, "proto", key->proto); + + return (nvl); + +errout: + nvlist_destroy(nvl); + return (NULL); +} + +static nvlist_t * +pf_state_scrub_to_nvstate_scrub(const struct pf_state_scrub *scrub) +{ + nvlist_t *nvl; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + nvlist_add_bool(nvl, "timestamp", scrub->pfss_flags & PFSS_TIMESTAMP); + nvlist_add_number(nvl, "ttl", scrub->pfss_ttl); + nvlist_add_number(nvl, "ts_mod", scrub->pfss_ts_mod); + + return (nvl); +} + +static nvlist_t * +pf_state_peer_to_nvstate_peer(const struct pf_state_peer *peer) +{ + nvlist_t *nvl, *tmp; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + if (peer->scrub) { + tmp = pf_state_scrub_to_nvstate_scrub(peer->scrub); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "scrub", tmp); + } + + nvlist_add_number(nvl, "seqlo", peer->seqlo); + nvlist_add_number(nvl, "seqhi", peer->seqhi); + nvlist_add_number(nvl, "seqdiff", peer->seqdiff); + nvlist_add_number(nvl, "max_win", peer->max_win); + nvlist_add_number(nvl, "mss", peer->mss); + nvlist_add_number(nvl, "state", peer->state); + nvlist_add_number(nvl, "wscale", peer->wscale); + + return (nvl); + +errout: + nvlist_destroy(nvl); + return (NULL); +} + + +static nvlist_t * +pf_state_to_nvstate(const struct pf_state *s) +{ + nvlist_t *nvl, *tmp; + uint32_t expire, flags = 0; + + nvl = nvlist_create(0); + if (nvl == NULL) + return (NULL); + + nvlist_add_number(nvl, "id", s->id); + nvlist_add_string(nvl, "ifname", s->kif->pfik_name); + + tmp = pf_state_key_to_nvstate_key(s->key[PF_SK_STACK]); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "stack_key", tmp); + + tmp = pf_state_key_to_nvstate_key(s->key[PF_SK_WIRE]); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "wire_key", tmp); + + tmp = pf_state_peer_to_nvstate_peer(&s->src); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "src", tmp); + + tmp = pf_state_peer_to_nvstate_peer(&s->dst); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "dst", tmp); + + tmp = pf_addr_to_nvaddr(&s->rt_addr); + if (tmp == NULL) + goto errout; + nvlist_add_nvlist(nvl, "rt_addr", tmp); + + nvlist_add_number(nvl, "rule", s->rule.ptr ? s->rule.ptr->nr : -1); + nvlist_add_number(nvl, "anchor", + s->anchor.ptr ? s->anchor.ptr->nr : -1); + nvlist_add_number(nvl, "nat_rule", + s->nat_rule.ptr ? s->nat_rule.ptr->nr : -1); + nvlist_add_number(nvl, "creation", s->creation); + + expire = pf_state_expires(s); + if (expire <= time_uptime) + expire = 0; + else + expire = expire - time_uptime; + nvlist_add_number(nvl, "expire", expire); + + for (int i = 0; i < 2; i++) { + nvlist_append_number_array(nvl, "packets", + counter_u64_fetch(s->packets[i])); + nvlist_append_number_array(nvl, "bytes", + counter_u64_fetch(s->bytes[i])); + } + + nvlist_add_number(nvl, "creatorid", s->creatorid); + nvlist_add_number(nvl, "direction", s->direction); + nvlist_add_number(nvl, "log", s->log); + nvlist_add_number(nvl, "state_flags", s->state_flags); + nvlist_add_number(nvl, "timeout", s->timeout); + if (s->src_node) + flags |= PFSYNC_FLAG_SRCNODE; + if (s->nat_src_node) + flags |= PFSYNC_FLAG_NATSRCNODE; + nvlist_add_number(nvl, "sync_flags", flags); + + return (nvl); + +errout: + nvlist_destroy(nvl); + return (NULL); +} + static int pf_ioctl_addrule(struct pf_krule *rule, uint32_t ticket, uint32_t pool_ticket, const char *anchor, const char *anchor_call, @@ -2789,6 +2941,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETADDRS: case DIOCGETADDR: case DIOCGETSTATE: + case DIOCGETSTATENV: case DIOCSETSTATUSIF: case DIOCGETSTATUS: case DIOCCLRSTATUS: @@ -2844,6 +2997,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETADDRS: case DIOCGETADDR: case DIOCGETSTATE: + case DIOCGETSTATENV: case DIOCGETSTATUS: case DIOCGETSTATES: case DIOCGETTIMEOUT: @@ -3504,6 +3658,11 @@ DIOCCHANGERULE_error: break; } + case DIOCGETSTATENV: { + error = pf_getstate((struct pfioc_nv *)addr); + break; + } + case DIOCGETSTATES: { struct pfioc_states *ps = (struct pfioc_states *)addr; struct pf_state *s; @@ -5684,12 +5843,79 @@ pf_clearstates_nv(struct pfioc_nv *nv) error = copyout(nvlpacked, nv->data, nv->len); +#undef ERROUT on_error: nvlist_destroy(nvl); free(nvlpacked, M_TEMP); return (error); } +static int +pf_getstate(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL, *nvls; + void *nvlpacked = NULL; + struct pf_state *s = NULL; + int error = 0; + uint64_t id, creatorid; + +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + + if (nv->len > pf_ioctl_maxcount) + ERROUT(ENOMEM); + + nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + error = copyin(nv->data, nvlpacked, nv->len); + if (error) + ERROUT(error); + + nvl = nvlist_unpack(nvlpacked, nv->len, 0); + if (nvl == NULL) + ERROUT(EBADMSG); + + PFNV_CHK(pf_nvuint64(nvl, "id", &id)); + PFNV_CHK(pf_nvuint64(nvl, "creatorid", &creatorid)); + + s = pf_find_state_byid(id, creatorid); + if (s == NULL) + ERROUT(ENOENT); + + free(nvlpacked, M_TEMP); + nvlpacked = NULL; + nvlist_destroy(nvl); + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvls = pf_state_to_nvstate(s); + if (nvls == NULL) + ERROUT(ENOMEM); + + nvlist_add_nvlist(nvl, "state", nvls); + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +#undef ERROUT +errout: + if (s != NULL) + PF_STATE_UNLOCK(s); + free(nvlpacked, M_TEMP); + nvlist_destroy(nvl); + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA08A63C501; Thu, 20 May 2021 11:54:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm7T64M8dz3Gd3; Thu, 20 May 2021 11:54:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F35F258A3; Thu, 20 May 2021 11:54: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 14KBsoUv056843; Thu, 20 May 2021 11:54:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBsocI056842; Thu, 20 May 2021 11:54:50 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:50 GMT Message-Id: <202105201154.14KBsocI056842@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 0592a4c83d67 - main - pf: Add DIOCGETSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0592a4c83d67547644763fb023abd5eb28e57f92 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:50 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=0592a4c83d67547644763fb023abd5eb28e57f92 commit 0592a4c83d67547644763fb023abd5eb28e57f92 Author: Kristof Provost AuthorDate: 2021-05-05 19:00:16 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:27 +0000 pf: Add DIOCGETSTATESNV Add DIOCGETSTATESNV, an nvlist-based alternative to DIOCGETSTATES. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30243 --- share/man/man4/pf.4 | 71 ++++++++++++++++++++++++++++++++----------- sys/net/pfvar.h | 1 + sys/netpfil/pf/pf_ioctl.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 18 deletions(-) diff --git a/share/man/man4/pf.4 b/share/man/man4/pf.4 index 24843535c924..133e4d300043 100644 --- a/share/man/man4/pf.4 +++ b/share/man/man4/pf.4 @@ -415,30 +415,65 @@ Set the debug level. enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC, PF_DEBUG_NOISY }; .Ed -.It Dv DIOCGETSTATES Fa "struct pfioc_states *ps" +.It Dv DIOCGETSTATESNV Fa "struct pfioc_nv *nv" Get state table entries. .Bd -literal -struct pfioc_states { - int ps_len; - union { - caddr_t psu_buf; - struct pf_state *psu_states; - } ps_u; -#define ps_buf ps_u.psu_buf -#define ps_states ps_u.psu_states +nvlist pf_state_key { + nvlist pf_addr addr[2]; + number port[2]; + number af; + number proto; +}; + +nvlist pf_state_scrub { + bool timestamp; + number ttl; + number ts_mod; +}; + +nvlist pf_state_peer { + nvlist pf_state_scrub scrub; + number seqlo; + number seqhi; + number seqdiff; + number max_win; + number mss; + number state; + number wscale; +}; + +nvlist pf_state { + number id; + string ifname; + nvlist pf_state_key stack_key; + nvlist pf_state_key wire_key; + nvlist pf_state_peer src; + nvlist pf_state_peer dst; + nvlist pf_addr rt_addr; + number rule; + number anchor; + number nat_rule; + number expire; + number packets[2]; + number bytes[2]; + number creatorid; + number direction; + number log; + number state_flags; + number timeout; + number sync_flags; +}; + +nvlist pf_states { + number count; + nvlist pf_state states[]; }; .Ed .Pp If -.Va ps_len -is non-zero on entry, as many states as possible that can fit into this -size will be copied into the supplied buffer -.Va ps_states . -On exit, -.Va ps_len -is always set to the total size required to hold all state table entries -(i.e., it is set to -.Li sizeof(struct pf_state) * nr ) . +.Va pfioc_nv.size +is insufficiently large, as many states as possible that can fit into this +size will be copied into the supplied buffer. .It Dv DIOCCHANGERULE Fa "struct pfioc_rule *pcr" Add or remove the .Va rule diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 1bd1ebd27449..d9e35dae753a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1264,6 +1264,7 @@ struct pfioc_iface { #define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) #define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) #define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states) +#define DIOCGETSTATESNV _IOWR('D', 25, struct pfioc_nv) #define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule) /* XXX cut 26 - 28 */ #define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 1ea7310ebebb..8424e0ce5689 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -209,6 +209,7 @@ static int pf_killstates_row(struct pf_kstate_kill *, static int pf_killstates_nv(struct pfioc_nv *); static int pf_clearstates_nv(struct pfioc_nv *); static int pf_getstate(struct pfioc_nv *); +static int pf_getstates(struct pfioc_nv *); static int pf_clear_tables(void); static void pf_clear_srcnodes(struct pf_ksrc_node *); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); @@ -2948,6 +2949,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCNATLOOK: case DIOCSETDEBUG: case DIOCGETSTATES: + case DIOCGETSTATESNV: case DIOCGETTIMEOUT: case DIOCCLRRULECTRS: case DIOCGETLIMIT: @@ -3000,6 +3002,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td case DIOCGETSTATENV: case DIOCGETSTATUS: case DIOCGETSTATES: + case DIOCGETSTATESNV: case DIOCGETTIMEOUT: case DIOCGETLIMIT: case DIOCGETALTQSV0: @@ -3709,6 +3712,11 @@ DIOCGETSTATES_full: break; } + case DIOCGETSTATESNV: { + error = pf_getstates((struct pfioc_nv *)addr); + break; + } + case DIOCGETSTATUS: { struct pf_status *s = (struct pf_status *)addr; @@ -5916,6 +5924,74 @@ errout: return (error); } +static int +pf_getstates(struct pfioc_nv *nv) +{ + nvlist_t *nvl = NULL, *nvls; + void *nvlpacked = NULL; + struct pf_state *s = NULL; + int error = 0; + uint64_t count = 0; + +#define ERROUT(x) ERROUT_FUNCTION(errout, x) + + nvl = nvlist_create(0); + if (nvl == NULL) + ERROUT(ENOMEM); + + nvlist_add_number(nvl, "count", uma_zone_get_cur(V_pf_state_z)); + + for (int i = 0; i < pf_hashmask; i++) { + struct pf_idhash *ih = &V_pf_idhash[i]; + + PF_HASHROW_LOCK(ih); + LIST_FOREACH(s, &ih->states, entry) { + if (s->timeout == PFTM_UNLINKED) + continue; + + nvls = pf_state_to_nvstate(s); + if (nvls == NULL) { + PF_HASHROW_UNLOCK(ih); + ERROUT(ENOMEM); + } + if ((nvlist_size(nvl) + nvlist_size(nvls)) > nv->size) { + /* We've run out of room for more states. */ + nvlist_destroy(nvls); + PF_HASHROW_UNLOCK(ih); + goto DIOCGETSTATESNV_full; + } + nvlist_append_nvlist_array(nvl, "states", nvls); + count++; + } + PF_HASHROW_UNLOCK(ih); + } + + /* We've managed to put them all the available space. Let's make sure + * 'count' matches our array (that's racy, because we don't hold a lock + * over all states, only over each row individually. */ + (void)nvlist_take_number(nvl, "count"); + nvlist_add_number(nvl, "count", count); + +DIOCGETSTATESNV_full: + + nvlpacked = nvlist_pack(nvl, &nv->len); + if (nvlpacked == NULL) + ERROUT(ENOMEM); + + if (nv->size == 0) + ERROUT(0); + else if (nv->size < nv->len) + ERROUT(ENOSPC); + + error = copyout(nvlpacked, nv->data, nv->len); + +#undef ERROUT +errout: + free(nvlpacked, M_TEMP); + nvlist_destroy(nvl); + return (error); +} + /* * XXX - Check for version missmatch!!! */ From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D33963C487; Thu, 20 May 2021 11:54:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm7T806mvz3GhQ; Thu, 20 May 2021 11:54:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B33B0254C9; Thu, 20 May 2021 11:54:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14KBspxF056869; Thu, 20 May 2021 11:54:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBsp1Q056868; Thu, 20 May 2021 11:54:51 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:51 GMT Message-Id: <202105201154.14KBsp1Q056868@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: bc941291473d - main - pfctl: Use DIOCGETSTATESNV MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc941291473d8a2164e4ffc3f3e7e6a356cbe747 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:52 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bc941291473d8a2164e4ffc3f3e7e6a356cbe747 commit bc941291473d8a2164e4ffc3f3e7e6a356cbe747 Author: Kristof Provost AuthorDate: 2021-05-10 14:51:38 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:27 +0000 pfctl: Use DIOCGETSTATESNV Migrate to using the new nvlist-based DIOCGETSTATESNV call to obtain the states list. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30244 --- lib/libpfctl/libpfctl.c | 173 ++++++++++++++++++++++++++++++++++++++++++++ lib/libpfctl/libpfctl.h | 60 +++++++++++++++ sbin/pfctl/pf_print_state.c | 82 ++++++++++----------- sbin/pfctl/pfctl.c | 49 ++++--------- sbin/pfctl/pfctl.h | 4 +- 5 files changed, 289 insertions(+), 79 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 8271d9bab3df..6a6ecd8fb136 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -627,6 +627,179 @@ pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name, nvlist_add_nvlist(nvl, name, nv); } +static void +pf_nvstate_scrub_to_state_scrub(const nvlist_t *nvl, + struct pfctl_state_scrub *scrub) +{ + bzero(scrub, sizeof(*scrub)); + + scrub->timestamp = nvlist_get_bool(nvl, "timestamp"); + scrub->ttl = nvlist_get_number(nvl, "ttl"); + scrub->ts_mod = nvlist_get_number(nvl, "ts_mod"); +} + +static void +pf_nvstate_peer_to_state_peer(const nvlist_t *nvl, + struct pfctl_state_peer *peer) +{ + bzero(peer, sizeof(*peer)); + + if (nvlist_exists_nvlist(nvl, "scrub")) { + peer->scrub = malloc(sizeof(*peer->scrub)); + pf_nvstate_scrub_to_state_scrub( + nvlist_get_nvlist(nvl, "scrub"), + peer->scrub); + } + + peer->seqlo = nvlist_get_number(nvl, "seqlo"); + peer->seqhi = nvlist_get_number(nvl, "seqhi"); + peer->seqdiff = nvlist_get_number(nvl, "seqdiff"); + peer->max_win = nvlist_get_number(nvl, "max_win"); + peer->mss = nvlist_get_number(nvl, "mss"); + peer->state = nvlist_get_number(nvl, "state"); + peer->wscale = nvlist_get_number(nvl, "wscale"); +} + +static void +pf_nvstate_key_to_state_key(const nvlist_t *nvl, struct pfctl_state_key *key) +{ + const nvlist_t * const *tmp; + size_t count; + + bzero(key, sizeof(*key)); + + tmp = nvlist_get_nvlist_array(nvl, "addr", &count); + assert(count == 2); + + for (int i = 0; i < 2; i++) + pf_nvaddr_to_addr(tmp[i], &key->addr[i]); + + pf_nvuint_16_array(nvl, "port", 2, key->port, NULL); + + key->af = nvlist_get_number(nvl, "af"); + key->proto = nvlist_get_number(nvl, "proto"); +} + +static void +pf_nvstate_to_state(const nvlist_t *nvl, struct pfctl_state *s) +{ + bzero(s, sizeof(*s)); + + s->id = nvlist_get_number(nvl, "id"); + s->creatorid = nvlist_get_number(nvl, "creatorid"); + s->direction = nvlist_get_number(nvl, "direction"); + + pf_nvstate_peer_to_state_peer(nvlist_get_nvlist(nvl, "src"), &s->src); + pf_nvstate_peer_to_state_peer(nvlist_get_nvlist(nvl, "dst"), &s->dst); + + pf_nvstate_key_to_state_key(nvlist_get_nvlist(nvl, "stack_key"), + &s->key[0]); + pf_nvstate_key_to_state_key(nvlist_get_nvlist(nvl, "wire_key"), + &s->key[1]); + + strlcpy(s->ifname, nvlist_get_string(nvl, "ifname"), + sizeof(s->ifname)); + + pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "rt_addr"), &s->rt_addr); + s->rule = nvlist_get_number(nvl, "rule"); + s->anchor = nvlist_get_number(nvl, "anchor"); + s->nat_rule = nvlist_get_number(nvl, "nat_rule"); + s->creation = nvlist_get_number(nvl, "creation"); + s->expire = nvlist_get_number(nvl, "expire"); + + pf_nvuint_64_array(nvl, "packets", 2, s->packets, NULL); + pf_nvuint_64_array(nvl, "bytes", 2, s->bytes, NULL); + + s->log = nvlist_get_number(nvl, "log"); + s->state_flags = nvlist_get_number(nvl, "state_flags"); + s->timeout = nvlist_get_number(nvl, "timeout"); + s->sync_flags = nvlist_get_number(nvl, "sync_flags"); +} + +int +pfctl_get_states(int dev, struct pfctl_states *states) +{ + struct pfioc_nv nv; + nvlist_t *nvl; + const nvlist_t * const *slist; + size_t found_count; + + bzero(states, sizeof(*states)); + TAILQ_INIT(&states->states); + + /* Just enough to get a number, and we'll grow from there. */ + nv.data = malloc(64); + nv.len = nv.size = 64; + + for (;;) { + if (ioctl(dev, DIOCGETSTATESNV, &nv)) { + free(nv.data); + return (errno); + } + + nvl = nvlist_unpack(nv.data, nv.len, 0); + if (nvl == NULL) { + free(nv.data); + return (EIO); + } + + states->count = nvlist_get_number(nvl, "count"); + + /* Are there any states? */ + if (states->count == 0) + break; + + if (nvlist_exists_nvlist_array(nvl, "states")) + slist = nvlist_get_nvlist_array(nvl, "states", &found_count); + else + found_count = 0; + + if (found_count < states->count) { + size_t new_size = nv.size + + (nv.size * states->count / (found_count + 1) * 2); + + /* Our buffer is too small. Estimate what we need based + * on how many states fit in the previous allocation + * and how many states there are. Doubled for margin. + * */ + nv.data = realloc(nv.data, new_size); + nv.size = new_size; + + if (nv.data == NULL) + return (ENOMEM); + continue; + } + + for (size_t i = 0; i < found_count; i++) { + struct pfctl_state *s = malloc(sizeof(*s)); + if (s == NULL) { + pfctl_free_states(states); + nvlist_destroy(nvl); + free(nv.data); + return (ENOMEM); + } + + pf_nvstate_to_state(slist[i], s); + TAILQ_INSERT_TAIL(&states->states, s, entry); + } + break; + } + + return (0); +} + +void +pfctl_free_states(struct pfctl_states *states) +{ + struct pfctl_state *s, *tmp; + + TAILQ_FOREACH_SAFE(s, &states->states, entry, tmp) { + free(s); + } + + bzero(states, sizeof(*states)); +} + static int _pfctl_clear_states(int dev, const struct pfctl_kill *kill, unsigned int *killed, uint64_t ioctlval) diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 7a1e02f3d01b..05447b5d8673 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -197,6 +197,64 @@ struct pfctl_kill { bool kill_match; }; +struct pfctl_state_scrub { + bool timestamp; + uint8_t ttl; + uint32_t ts_mod; +}; + +struct pfctl_state_peer { + struct pfctl_state_scrub *scrub; + uint32_t seqlo; + uint32_t seqhi; + uint32_t seqdiff; + uint16_t max_win; + uint16_t mss; + uint8_t state; + uint8_t wscale; +}; + +struct pfctl_state_key { + struct pf_addr addr[2]; + uint16_t port[2]; + sa_family_t af; + uint8_t proto; +}; + +struct pfctl_state { + TAILQ_ENTRY(pfctl_state) entry; + + uint64_t id; + uint32_t creatorid; + uint8_t direction; + + struct pfctl_state_peer src; + struct pfctl_state_peer dst; + + uint32_t rule; + uint32_t anchor; + uint32_t nat_rule; + struct pf_addr rt_addr; + struct pfctl_state_key key[2]; /* addresses stack and wire */ + char ifname[IFNAMSIZ]; + uint64_t packets[2]; + uint64_t bytes[2]; + uint32_t creation; + uint32_t expire; + uint32_t pfsync_time; + uint16_t tag; + uint8_t log; + uint8_t state_flags; + uint8_t timeout; + uint32_t sync_flags; +}; + +TAILQ_HEAD(pfctl_statelist, pfctl_state); +struct pfctl_states { + struct pfctl_statelist states; + size_t count; +}; + int pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call); @@ -207,6 +265,8 @@ int pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor, const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket); int pfctl_set_keepcounters(int dev, bool keep); +int pfctl_get_states(int dev, struct pfctl_states *states); +void pfctl_free_states(struct pfctl_states *states); int pfctl_clear_states(int dev, const struct pfctl_kill *kill, unsigned int *killed); int pfctl_kill_states(int dev, const struct pfctl_kill *kill, diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index e2f9d6efe609..7119308d195b 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -196,25 +196,27 @@ print_host(struct pf_addr *addr, u_int16_t port, sa_family_t af, int opts) } void -print_seq(struct pfsync_state_peer *p) +print_seq(struct pfctl_state_peer *p) { if (p->seqdiff) - printf("[%u + %u](+%u)", ntohl(p->seqlo), - ntohl(p->seqhi) - ntohl(p->seqlo), ntohl(p->seqdiff)); + printf("[%u + %u](+%u)", p->seqlo, + p->seqhi - p->seqlo, p->seqdiff); else - printf("[%u + %u]", ntohl(p->seqlo), - ntohl(p->seqhi) - ntohl(p->seqlo)); + printf("[%u + %u]", p->seqlo, + p->seqhi - p->seqlo); } void -print_state(struct pfsync_state *s, int opts) +print_state(struct pfctl_state *s, int opts) { - struct pfsync_state_peer *src, *dst; - struct pfsync_state_key *key, *sk, *nk; + struct pfctl_state_peer *src, *dst; + struct pfctl_state_key *key, *sk, *nk; struct protoent *p; int min, sec; + sa_family_t af; + uint8_t proto; #ifndef __NO_STRICT_ALIGNMENT - struct pfsync_state_key aligned_key[2]; + struct pfctl_state_key aligned_key[2]; bcopy(&s->key, aligned_key, sizeof(aligned_key)); key = aligned_key; @@ -222,48 +224,51 @@ print_state(struct pfsync_state *s, int opts) key = s->key; #endif + af = s->key[PF_SK_WIRE].af; + proto = s->key[PF_SK_WIRE].proto; + if (s->direction == PF_OUT) { src = &s->src; dst = &s->dst; sk = &key[PF_SK_STACK]; nk = &key[PF_SK_WIRE]; - if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) + if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6) sk->port[0] = nk->port[0]; } else { src = &s->dst; dst = &s->src; sk = &key[PF_SK_WIRE]; nk = &key[PF_SK_STACK]; - if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) + if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6) sk->port[1] = nk->port[1]; } printf("%s ", s->ifname); - if ((p = getprotobynumber(s->proto)) != NULL) + if ((p = getprotobynumber(proto)) != NULL) printf("%s ", p->p_name); else - printf("%u ", s->proto); + printf("%u ", proto); - print_host(&nk->addr[1], nk->port[1], s->af, opts); - if (PF_ANEQ(&nk->addr[1], &sk->addr[1], s->af) || + print_host(&nk->addr[1], nk->port[1], af, opts); + if (PF_ANEQ(&nk->addr[1], &sk->addr[1], af) || nk->port[1] != sk->port[1]) { printf(" ("); - print_host(&sk->addr[1], sk->port[1], s->af, opts); + print_host(&sk->addr[1], sk->port[1], af, opts); printf(")"); } if (s->direction == PF_OUT) printf(" -> "); else printf(" <- "); - print_host(&nk->addr[0], nk->port[0], s->af, opts); - if (PF_ANEQ(&nk->addr[0], &sk->addr[0], s->af) || + print_host(&nk->addr[0], nk->port[0], af, opts); + if (PF_ANEQ(&nk->addr[0], &sk->addr[0], af) || nk->port[0] != sk->port[0]) { printf(" ("); - print_host(&sk->addr[0], sk->port[0], s->af, opts); + print_host(&sk->addr[0], sk->port[0], af, opts); printf(")"); } printf(" "); - if (s->proto == IPPROTO_TCP) { + if (proto == IPPROTO_TCP) { if (src->state <= TCPS_TIME_WAIT && dst->state <= TCPS_TIME_WAIT) printf(" %s:%s\n", tcpstates[src->state], @@ -290,16 +295,16 @@ print_state(struct pfsync_state *s, int opts) dst->wscale & PF_WSCALE_MASK); printf("\n"); } - } else if (s->proto == IPPROTO_UDP && src->state < PFUDPS_NSTATES && + } else if (proto == IPPROTO_UDP && src->state < PFUDPS_NSTATES && dst->state < PFUDPS_NSTATES) { const char *states[] = PFUDPS_NAMES; printf(" %s:%s\n", states[src->state], states[dst->state]); #ifndef INET6 - } else if (s->proto != IPPROTO_ICMP && src->state < PFOTHERS_NSTATES && + } else if (proto != IPPROTO_ICMP && src->state < PFOTHERS_NSTATES && dst->state < PFOTHERS_NSTATES) { #else - } else if (s->proto != IPPROTO_ICMP && s->proto != IPPROTO_ICMPV6 && + } else if (proto != IPPROTO_ICMP && proto != IPPROTO_ICMPV6 && src->state < PFOTHERS_NSTATES && dst->state < PFOTHERS_NSTATES) { #endif /* XXX ICMP doesn't really have state levels */ @@ -311,10 +316,8 @@ print_state(struct pfsync_state *s, int opts) } if (opts & PF_OPT_VERBOSE) { - u_int64_t packets[2]; - u_int64_t bytes[2]; - u_int32_t creation = ntohl(s->creation); - u_int32_t expire = ntohl(s->expire); + u_int32_t creation = s->creation; + u_int32_t expire = s->expire; sec = creation % 60; creation /= 60; @@ -327,19 +330,15 @@ print_state(struct pfsync_state *s, int opts) expire /= 60; printf(", expires in %.2u:%.2u:%.2u", expire, min, sec); - bcopy(s->packets[0], &packets[0], sizeof(u_int64_t)); - bcopy(s->packets[1], &packets[1], sizeof(u_int64_t)); - bcopy(s->bytes[0], &bytes[0], sizeof(u_int64_t)); - bcopy(s->bytes[1], &bytes[1], sizeof(u_int64_t)); printf(", %ju:%ju pkts, %ju:%ju bytes", - (uintmax_t )be64toh(packets[0]), - (uintmax_t )be64toh(packets[1]), - (uintmax_t )be64toh(bytes[0]), - (uintmax_t )be64toh(bytes[1])); - if (ntohl(s->anchor) != -1) - printf(", anchor %u", ntohl(s->anchor)); - if (ntohl(s->rule) != -1) - printf(", rule %u", ntohl(s->rule)); + s->packets[0], + s->packets[1], + s->bytes[0], + s->bytes[1]); + if (s->anchor != -1) + printf(", anchor %u", s->anchor); + if (s->rule != -1) + printf(", rule %u", s->rule); if (s->state_flags & PFSTATE_SLOPPY) printf(", sloppy"); if (s->sync_flags & PFSYNC_FLAG_SRCNODE) @@ -352,10 +351,9 @@ print_state(struct pfsync_state *s, int opts) u_int64_t id; bcopy(&s->id, &id, sizeof(u_int64_t)); - printf(" id: %016jx creatorid: %08x", - (uintmax_t )be64toh(id), ntohl(s->creatorid)); + printf(" id: %016jx creatorid: %08x", id, s->creatorid); printf(" gateway: "); - print_host(&s->rt_addr, 0, s->af, opts); + print_host(&s->rt_addr, 0, af, opts); printf("\n"); } } diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index fd937cac9f63..f82d75198d61 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1237,48 +1237,27 @@ done: int pfctl_show_states(int dev, const char *iface, int opts) { - struct pfioc_states ps; - struct pfsync_state *p; - char *inbuf = NULL, *newinbuf = NULL; - unsigned int len = 0; - int i, dotitle = (opts & PF_OPT_SHOWALL); + struct pfctl_states states; + struct pfctl_state *s; + int dotitle = (opts & PF_OPT_SHOWALL); - memset(&ps, 0, sizeof(ps)); - for (;;) { - ps.ps_len = len; - if (len) { - newinbuf = realloc(inbuf, len); - if (newinbuf == NULL) - err(1, "realloc"); - ps.ps_buf = inbuf = newinbuf; - } - if (ioctl(dev, DIOCGETSTATES, &ps) < 0) { - warn("DIOCGETSTATES"); - free(inbuf); - return (-1); - } - if (ps.ps_len + sizeof(struct pfioc_states) < len) - break; - if (len == 0 && ps.ps_len == 0) - goto done; - if (len == 0 && ps.ps_len != 0) - len = ps.ps_len; - if (ps.ps_len == 0) - goto done; /* no states */ - len *= 2; - } - p = ps.ps_states; - for (i = 0; i < ps.ps_len; i += sizeof(*p), p++) { - if (iface != NULL && strcmp(p->ifname, iface)) + memset(&states, 0, sizeof(states)); + + if (pfctl_get_states(dev, &states)) + return (-1); + + TAILQ_FOREACH(s, &states.states, entry) { + if (iface != NULL && strcmp(s->ifname, iface)) continue; if (dotitle) { pfctl_print_title("STATES:"); dotitle = 0; } - print_state(p, opts); + print_state(s, opts); } -done: - free(inbuf); + + pfctl_free_states(&states); + return (0); } diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index 93b3af083b5f..f8ff5012e01b 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -120,8 +120,8 @@ char *rate2str(double); void print_addr(struct pf_addr_wrap *, sa_family_t, int); void print_host(struct pf_addr *, u_int16_t p, sa_family_t, int); -void print_seq(struct pfsync_state_peer *); -void print_state(struct pfsync_state *, int); +void print_seq(struct pfctl_state_peer *); +void print_state(struct pfctl_state *, int); int unmask(struct pf_addr *, sa_family_t); int pfctl_cmdline_symset(char *); From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 427E263C302; Thu, 20 May 2021 11:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm7T90Bbgz3GWm; Thu, 20 May 2021 11:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5A722535E; Thu, 20 May 2021 11:54:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14KBsqTC056890; Thu, 20 May 2021 11:54:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBsqX1056889; Thu, 20 May 2021 11:54:52 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:52 GMT Message-Id: <202105201154.14KBsqX1056889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: d0fdf2b28f9b - main - pf: Track the original kif for floating states MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d0fdf2b28f9b981d2cb98e9da8a715e046ef1e92 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:53 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d0fdf2b28f9b981d2cb98e9da8a715e046ef1e92 commit d0fdf2b28f9b981d2cb98e9da8a715e046ef1e92 Author: Kristof Provost AuthorDate: 2021-05-12 11:24:57 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:27 +0000 pf: Track the original kif for floating states Track (and display) the interface that created a state, even if it's a floating state (and thus uses virtual interface 'all'). MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30245 --- lib/libpfctl/libpfctl.c | 2 ++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/pf_print_state.c | 5 ++++- sys/net/pfvar.h | 2 ++ sys/netpfil/pf/if_pfsync.c | 2 +- sys/netpfil/pf/pf.c | 7 ++++--- sys/netpfil/pf/pf_ioctl.c | 1 + 7 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 6a6ecd8fb136..e207a55a8673 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -699,6 +699,8 @@ pf_nvstate_to_state(const nvlist_t *nvl, struct pfctl_state *s) strlcpy(s->ifname, nvlist_get_string(nvl, "ifname"), sizeof(s->ifname)); + strlcpy(s->orig_ifname, nvlist_get_string(nvl, "orig_ifname"), + sizeof(s->orig_ifname)); pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "rt_addr"), &s->rt_addr); s->rule = nvlist_get_number(nvl, "rule"); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 05447b5d8673..a54ee9db6ec7 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -237,6 +237,7 @@ struct pfctl_state { struct pf_addr rt_addr; struct pfctl_state_key key[2]; /* addresses stack and wire */ char ifname[IFNAMSIZ]; + char orig_ifname[IFNAMSIZ]; uint64_t packets[2]; uint64_t bytes[2]; uint32_t creation; diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index 7119308d195b..b1f0079154cf 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -352,9 +352,12 @@ print_state(struct pfctl_state *s, int opts) bcopy(&s->id, &id, sizeof(u_int64_t)); printf(" id: %016jx creatorid: %08x", id, s->creatorid); - printf(" gateway: "); + printf(" gateway: "); print_host(&s->rt_addr, 0, af, opts); printf("\n"); + + if (strcmp(s->ifname, s->orig_ifname) != 0) + printf(" origif: %s\n", s->orig_ifname); } } diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index d9e35dae753a..2202421086d2 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -522,6 +522,7 @@ struct pf_state { struct pf_addr rt_addr; struct pf_state_key *key[2]; /* addresses stack and wire */ struct pfi_kkif *kif; + struct pfi_kkif *orig_kif; /* The real kif, even if we're a floating state (i.e. if == V_pfi_all). */ struct pfi_kkif *rt_kif; struct pf_ksrc_node *src_node; struct pf_ksrc_node *nat_src_node; @@ -1475,6 +1476,7 @@ extern int pf_unlink_state(struct pf_state *, u_int); #define PF_ENTER_LOCKED 0x00000001 #define PF_RETURN_LOCKED 0x00000002 extern int pf_state_insert(struct pfi_kkif *, + struct pfi_kkif *, struct pf_state_key *, struct pf_state_key *, struct pf_state *); diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 96813fd11dc3..3514c922c361 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -593,7 +593,7 @@ pfsync_state_import(struct pfsync_state *sp, u_int8_t flags) if (!(flags & PFSYNC_SI_IOCTL)) st->state_flags |= PFSTATE_NOSYNC; - if ((error = pf_state_insert(kif, skw, sks, st)) != 0) + if ((error = pf_state_insert(kif, kif, skw, sks, st)) != 0) goto cleanup_state; /* XXX when we have nat_rule/anchors, use STATE_INC_COUNTERS */ diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index a5c4ef6bfbb4..985b55af5263 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1263,8 +1263,8 @@ pf_state_key_clone(struct pf_state_key *orig) } int -pf_state_insert(struct pfi_kkif *kif, struct pf_state_key *skw, - struct pf_state_key *sks, struct pf_state *s) +pf_state_insert(struct pfi_kkif *kif, struct pfi_kkif *orig_kif, + struct pf_state_key *skw, struct pf_state_key *sks, struct pf_state *s) { struct pf_idhash *ih; struct pf_state *cur; @@ -1277,6 +1277,7 @@ pf_state_insert(struct pfi_kkif *kif, struct pf_state_key *skw, KASSERT(s->refs == 0, ("%s: state not pristine", __func__)); s->kif = kif; + s->orig_kif = orig_kif; if (s->id == 0 && s->creatorid == 0) { /* XXX: should be atomic, but probability of collision low */ @@ -3877,7 +3878,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, __func__, nr, sk, nk)); /* Swap sk/nk for PF_OUT. */ - if (pf_state_insert(BOUND_IFACE(r, kif), + if (pf_state_insert(BOUND_IFACE(r, kif), kif, (pd->dir == PF_IN) ? sk : nk, (pd->dir == PF_IN) ? nk : sk, s)) { if (pd->proto == IPPROTO_TCP) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 8424e0ce5689..62c1f35c3c3f 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2562,6 +2562,7 @@ pf_state_to_nvstate(const struct pf_state *s) nvlist_add_number(nvl, "id", s->id); nvlist_add_string(nvl, "ifname", s->kif->pfik_name); + nvlist_add_string(nvl, "orig_ifname", s->orig_kif->pfik_name); tmp = pf_state_key_to_nvstate_key(s->key[PF_SK_STACK]); if (tmp == NULL) From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:54 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4920F63BF5F; Thu, 20 May 2021 11:54: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 4Fm7TB0PFxz3GZD; Thu, 20 May 2021 11:54: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 E456A25A01; Thu, 20 May 2021 11:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14KBsrZQ056911; Thu, 20 May 2021 11:54:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBsrXX056910; Thu, 20 May 2021 11:54:53 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:53 GMT Message-Id: <202105201154.14KBsrXX056910@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: b62489cc92ed - main - pf: Support killing floating states by interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b62489cc92edbec318fb6c57cdc02b5e3cfa3a67 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:54 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b62489cc92edbec318fb6c57cdc02b5e3cfa3a67 commit b62489cc92edbec318fb6c57cdc02b5e3cfa3a67 Author: Kristof Provost AuthorDate: 2021-05-13 07:51:28 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:27 +0000 pf: Support killing floating states by interface Floating states get assigned to interface 'all' (V_pfi_all), so when we try to flush all states for an interface states originally created through this interface are not flushed. Only if-bound states can be flushed in this way. Given that we track the original interface we can check if the state's interface is 'all', and if so compare to the orig_if instead. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30246 --- sys/netpfil/pf/pf_ioctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 62c1f35c3c3f..91a175caa74f 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -2828,10 +2828,14 @@ pf_killstates_row(struct pf_kstate_kill *psk, struct pf_idhash *ih) int idx, killed = 0; unsigned int dir; u_int16_t srcport, dstport; + struct pfi_kkif *kif; relock_DIOCKILLSTATES: PF_HASHROW_LOCK(ih); LIST_FOREACH(s, &ih->states, entry) { + /* For floating states look at the original kif. */ + kif = s->kif == V_pfi_all ? s->orig_kif : s->kif; + sk = s->key[PF_SK_WIRE]; if (s->direction == PF_OUT) { srcaddr = &sk->addr[1]; @@ -2880,7 +2884,7 @@ relock_DIOCKILLSTATES: continue; if (psk->psk_ifname[0] && strcmp(psk->psk_ifname, - s->kif->pfik_name)) + kif->pfik_name)) continue; if (psk->psk_kill_match) { @@ -5662,6 +5666,7 @@ pf_clear_states(const struct pf_kstate_kill *kill) { struct pf_state_key_cmp match_key; struct pf_state *s; + struct pfi_kkif *kif; int idx; unsigned int killed = 0, dir; @@ -5671,9 +5676,12 @@ pf_clear_states(const struct pf_kstate_kill *kill) relock_DIOCCLRSTATES: PF_HASHROW_LOCK(ih); LIST_FOREACH(s, &ih->states, entry) { + /* For floating states look at the original kif. */ + kif = s->kif == V_pfi_all ? s->orig_kif : s->kif; + if (kill->psk_ifname[0] && strcmp(kill->psk_ifname, - s->kif->pfik_name)) + kif->pfik_name)) continue; if (kill->psk_kill_match) { From owner-dev-commits-src-main@freebsd.org Thu May 20 11:54:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F8B363C1C5; Thu, 20 May 2021 11:54: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 4Fm7TC275yz3GdW; Thu, 20 May 2021 11:54: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 1E5D5258A4; Thu, 20 May 2021 11:54: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 14KBssiZ056932; Thu, 20 May 2021 11:54:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KBssbM056931; Thu, 20 May 2021 11:54:54 GMT (envelope-from git) Date: Thu, 20 May 2021 11:54:54 GMT Message-Id: <202105201154.14KBssbM056931@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 7bd7933f9a4f - main - pf tests: Test the ability to kill floating states by interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 11:54:55 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3 commit 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3 Author: Kristof Provost AuthorDate: 2021-05-13 08:04:20 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 10:49:27 +0000 pf tests: Test the ability to kill floating states by interface Reviewed by: eri MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30247 --- tests/sys/netpfil/pf/killstate.sh | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index ec01910f0867..b3d94a245548 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -447,6 +447,65 @@ match_cleanup() pft_cleanup } +atf_test_case "interface" "cleanup" +interface_head() +{ + atf_set descr 'Test killing states based on interface' + atf_set require.user root + atf_set require.progs scapy +} + +interface_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp" + + # Sanity check & establish state + # Note: use pft_ping so we always use the same ID, so pf considers all + # echo requests part of the same flow. + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + + # Established state means we can still ping alcatraz + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Flushing states on a different interface doesn't affect our state + jexec alcatraz pfctl -i ${epair}a -Fs + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Flushing on the correct interface does (even with floating states) + jexec alcatraz pfctl -i ${epair}b -Fs + atf_check -s exit:1 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a +} + +interface_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4" @@ -455,4 +514,5 @@ atf_init_test_cases() atf_add_test_case "multilabel" atf_add_test_case "gateway" atf_add_test_case "match" + atf_add_test_case "interface" } From owner-dev-commits-src-main@freebsd.org Thu May 20 12:06:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24ED763CED9; Thu, 20 May 2021 12:06: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 4Fm7km0WS5z3M67; Thu, 20 May 2021 12:06: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 EE0B825E85; Thu, 20 May 2021 12:06: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 14KC6dQB070975; Thu, 20 May 2021 12:06:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KC6dhR070974; Thu, 20 May 2021 12:06:39 GMT (envelope-from git) Date: Thu, 20 May 2021 12:06:39 GMT Message-Id: <202105201206.14KC6dhR070974@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 26705a39e51e - main - pfctl: Fix crash on ALTQ configuration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26705a39e51eaf5b32efa98fb86df2d4ecfbdc61 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 12:06:40 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=26705a39e51eaf5b32efa98fb86df2d4ecfbdc61 commit 26705a39e51eaf5b32efa98fb86df2d4ecfbdc61 Author: Kristof Provost AuthorDate: 2021-05-18 13:03:01 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 12:06:22 +0000 pfctl: Fix crash on ALTQ configuration The following config could crash pfctl: altq on igb0 fairq bandwidth 1Gb queue { qLink } queue qLink fairq(default) That happens because when we're parsing the parent queue (on igb0) it doesn't have a parent, and the check in eval_pfqueue_fairq() checks pa->parent rather than parent. This was changed in eval_pfqueue_hfsc() in 1d34c9dac8624c5c315ae39ad3ae8e5879b23256, but not for fairq. Reviewed by: pkelsey MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30346 --- sbin/pfctl/pfctl_altq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c index 6541c031c75e..304bf69d7c7a 100644 --- a/sbin/pfctl/pfctl_altq.c +++ b/sbin/pfctl/pfctl_altq.c @@ -864,7 +864,7 @@ eval_pfqueue_fairq(struct pfctl *pf __unused, struct pf_altq *pa, opts = &pa->pq_u.fairq_opts; - if (pa->parent == NULL) { + if (parent == NULL) { /* root queue */ opts->lssc_m1 = pa->ifbandwidth; opts->lssc_m2 = pa->ifbandwidth; From owner-dev-commits-src-main@freebsd.org Thu May 20 12:06:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B32763D1C4; Thu, 20 May 2021 12:06: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 4Fm7kn1XJRz3Ly3; Thu, 20 May 2021 12:06: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 1BDF125B18; Thu, 20 May 2021 12:06: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 14KC6f6D070996; Thu, 20 May 2021 12:06:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KC6fdp070995; Thu, 20 May 2021 12:06:41 GMT (envelope-from git) Date: Thu, 20 May 2021 12:06:41 GMT Message-Id: <202105201206.14KC6fdp070995@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: dc784287967d - main - pfctl: Ensure parent queue is configured for FAIRQ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dc784287967d45ab681dc51e9e20b78c8c535834 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 12:06:41 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dc784287967d45ab681dc51e9e20b78c8c535834 commit dc784287967d45ab681dc51e9e20b78c8c535834 Author: Kristof Provost AuthorDate: 2021-05-18 16:22:13 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 12:06:23 +0000 pfctl: Ensure parent queue is configured for FAIRQ We failed to account for the FAIRQ scheduler in expand_altq(), which led it to be set up without its parent queue. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30347 --- sbin/pfctl/parse.y | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 6acfefbf5ad3..4448a8255ce1 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -5107,7 +5107,8 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces, } if (pa.scheduler == ALTQT_CBQ || - pa.scheduler == ALTQT_HFSC) { + pa.scheduler == ALTQT_HFSC || + pa.scheduler == ALTQT_FAIRQ) { /* now create a root queue */ memset(&pb, 0, sizeof(struct pf_altq)); if (strlcpy(qname, "root_", sizeof(qname)) >= @@ -5138,7 +5139,8 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces, if (n == NULL) err(1, "expand_altq: calloc"); if (pa.scheduler == ALTQT_CBQ || - pa.scheduler == ALTQT_HFSC) + pa.scheduler == ALTQT_HFSC || + pa.scheduler == ALTQT_FAIRQ) if (strlcpy(n->parent, qname, sizeof(n->parent)) >= sizeof(n->parent)) From owner-dev-commits-src-main@freebsd.org Thu May 20 12:06:42 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDAFC63CEDE; Thu, 20 May 2021 12:06: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 4Fm7kp2p1pz3Lq7; Thu, 20 May 2021 12:06: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 364D625A4A; Thu, 20 May 2021 12:06: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 14KC6gEC071021; Thu, 20 May 2021 12:06:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KC6ghH071020; Thu, 20 May 2021 12:06:42 GMT (envelope-from git) Date: Thu, 20 May 2021 12:06:42 GMT Message-Id: <202105201206.14KC6ghH071020@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 9938fcaa6565 - main - pfctl tests: Test fairq configuration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9938fcaa6565a660c555a0e9c712842ba1a2d31c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 12:06:43 -0000 The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9938fcaa6565a660c555a0e9c712842ba1a2d31c commit 9938fcaa6565a660c555a0e9c712842ba1a2d31c Author: Kristof Provost AuthorDate: 2021-05-19 07:52:50 +0000 Commit: Kristof Provost CommitDate: 2021-05-20 12:06:23 +0000 pfctl tests: Test fairq configuration We used to have a bug where pfctl could crash setting fairq queues. Test this case and ensure it does not crash pfctl. Reviewed by: donner MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30348 --- sbin/pfctl/tests/files/pf1006.in | 2 ++ sbin/pfctl/tests/files/pf1006.ok | 2 ++ sbin/pfctl/tests/pfctl_test_list.inc | 1 + 3 files changed, 5 insertions(+) diff --git a/sbin/pfctl/tests/files/pf1006.in b/sbin/pfctl/tests/files/pf1006.in new file mode 100644 index 000000000000..b50c16994cfc --- /dev/null +++ b/sbin/pfctl/tests/files/pf1006.in @@ -0,0 +1,2 @@ +altq on igb0 fairq bandwidth 1Gb queue { qLink } +queue qLink fairq(default) diff --git a/sbin/pfctl/tests/files/pf1006.ok b/sbin/pfctl/tests/files/pf1006.ok new file mode 100644 index 000000000000..be44b765c2e9 --- /dev/null +++ b/sbin/pfctl/tests/files/pf1006.ok @@ -0,0 +1,2 @@ +altq on igb0 fairq bandwidth 1Gb tbrsize 36000 queue { qLink } +queue qLink fairq( default ) diff --git a/sbin/pfctl/tests/pfctl_test_list.inc b/sbin/pfctl/tests/pfctl_test_list.inc index 337dff640f42..060a6019d05c 100644 --- a/sbin/pfctl/tests/pfctl_test_list.inc +++ b/sbin/pfctl/tests/pfctl_test_list.inc @@ -116,3 +116,4 @@ PFCTL_TEST(1002, "Set timeout interval") PFCTL_TEST(1003, "ALTQ") PFCTL_TEST(1004, "ALTQ with Codel") PFCTL_TEST(1005, "PR 231323") +PFCTL_TEST(1006, "pfctl crashes with certain fairq configurations") From owner-dev-commits-src-main@freebsd.org Thu May 20 13:08:32 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1885863E781; Thu, 20 May 2021 13:08:32 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from creme-brulee.marcuscom.com (creme-brulee.marcuscom.com [IPv6:2607:fc50:1:f300::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "*.marcuscom.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fm96773VXz4XKV; Thu, 20 May 2021 13:08:31 +0000 (UTC) (envelope-from jclarke@marcuscom.com) Received: from [10.116.79.227] ([173.38.117.71]) (authenticated bits=0) by creme-brulee.marcuscom.com (8.16.1/8.16.1) with ESMTPSA id 14KD7IY6093125 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 20 May 2021 09:07:34 -0400 (EDT) (envelope-from jclarke@marcuscom.com) X-Authentication-Warning: creme-brulee.marcuscom.com: Host [173.38.117.71] claimed to be [10.116.79.227] Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses To: Benjamin Kaduk , Zhenlei Huang Cc: "Rodney W. Grimes" , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> From: Joe Clarke Message-ID: <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> Date: Thu, 20 May 2021 09:07:08 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.5 required=5.0 tests=NICE_REPLY_A,RDNS_NONE autolearn=disabled version=3.4.5 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on creme-brulee.marcuscom.com X-Rspamd-Queue-Id: 4Fm96773VXz4XKV X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 13:08:32 -0000 On 5/19/21 22:39, Benjamin Kaduk wrote: > On Wed, May 19, 2021 at 7:33 PM Zhenlei Huang wrote: > >>> IMHO, I'd like to see the RFC reference remain. I see rgrimes response >>> that the RFC's can change with errata and bis docs, but the anchor still >>> provides additional context that one can use to learn more about why >>> this code exists, and they can chase any future forward references. >> RFC's indeed change, and I think it is common in network stack. Then we >> need guidelines to better regulate these. CC rgrimes . >> > > Sorry, RFCs themselves do not change -- one of the distinctive features of > RFCs is precisely that they are immutable once published. > The sentiment that what the current RFC for a given topic is, can change, is > something that I can agree with, but that's not quite what was being > discussed. Agreed, which is why I say the reference still has value and one can use it as a basis to follow the errata and newer docs. That said, I've expressed my desire to leave the reference in, and I'll leave it at that. I didn't think this would be that controversial. Joe -- PGP Key : http://www.marcuscom.com/pgp.asc From owner-dev-commits-src-main@freebsd.org Thu May 20 15:27:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2A0FE641B35; Thu, 20 May 2021 15:27: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 4FmDBm0lFcz4frd; Thu, 20 May 2021 15:27: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 01C3E285D0; Thu, 20 May 2021 15:27: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 14KFRhql036649; Thu, 20 May 2021 15:27:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KFRhEL036648; Thu, 20 May 2021 15:27:43 GMT (envelope-from git) Date: Thu, 20 May 2021 15:27:43 GMT Message-Id: <202105201527.14KFRhEL036648@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: f17a5900850b - main - ufs: Avoid M_WAITOK allocations when building a dirhash MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f17a5900850b4d449a91cbe9c61dfb62373c3cd1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 15:27:44 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f17a5900850b4d449a91cbe9c61dfb62373c3cd1 commit f17a5900850b4d449a91cbe9c61dfb62373c3cd1 Author: Don Morris AuthorDate: 2021-05-20 14:54:38 +0000 Commit: Mark Johnston CommitDate: 2021-05-20 15:25:45 +0000 ufs: Avoid M_WAITOK allocations when building a dirhash At this point the directory's vnode lock is held, so blocking while waiting for free pages makes the system more susceptible to deadlock in low memory conditions. This is particularly problematic on NUMA systems as UMA currently implements a strict first-touch policy. ufsdirhash_build() already uses M_NOWAIT for other allocations and already handled failures for the block array allocation, so just convert to M_NOWAIT. PR: 253992 Reviewed by: markj, mckusick, vangyzen MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29045 --- sys/ufs/ufs/ufs_dirhash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c index 13094b5a1c97..d1e1bed0bde4 100644 --- a/sys/ufs/ufs/ufs_dirhash.c +++ b/sys/ufs/ufs/ufs_dirhash.c @@ -108,7 +108,7 @@ static uma_zone_t ufsdirhash_zone; #define DIRHASHLIST_LOCK() mtx_lock(&ufsdirhash_mtx) #define DIRHASHLIST_UNLOCK() mtx_unlock(&ufsdirhash_mtx) -#define DIRHASH_BLKALLOC_WAITOK() uma_zalloc(ufsdirhash_zone, M_WAITOK) +#define DIRHASH_BLKALLOC() uma_zalloc(ufsdirhash_zone, M_NOWAIT) #define DIRHASH_BLKFREE(ptr) uma_zfree(ufsdirhash_zone, (ptr)) #define DIRHASH_ASSERT_LOCKED(dh) \ sx_assert(&(dh)->dh_lock, SA_LOCKED) @@ -425,7 +425,7 @@ ufsdirhash_build(struct inode *ip) if (dh->dh_blkfree == NULL) goto fail; for (i = 0; i < narrays; i++) { - if ((dh->dh_hash[i] = DIRHASH_BLKALLOC_WAITOK()) == NULL) + if ((dh->dh_hash[i] = DIRHASH_BLKALLOC()) == NULL) goto fail; for (j = 0; j < DH_NBLKOFF; j++) dh->dh_hash[i][j] = DIRHASH_EMPTY; From owner-dev-commits-src-main@freebsd.org Thu May 20 16:59:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 71628643E23; Thu, 20 May 2021 16:59: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 4FmGDq2Ztcz4VYr; Thu, 20 May 2021 16:59: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 42379298D2; Thu, 20 May 2021 16:59: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 14KGxd7I056449; Thu, 20 May 2021 16:59:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KGxdOQ056448; Thu, 20 May 2021 16:59:39 GMT (envelope-from git) Date: Thu, 20 May 2021 16:59:39 GMT Message-Id: <202105201659.14KGxdOQ056448@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 71e3d1b3a0ee - main - iscsi: Always free a cdw before its associated ctl_io. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71e3d1b3a0ee4080c53615167bde4d93efe103fe Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 16:59:39 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=71e3d1b3a0ee4080c53615167bde4d93efe103fe commit 71e3d1b3a0ee4080c53615167bde4d93efe103fe Author: John Baldwin AuthorDate: 2021-05-20 16:58:59 +0000 Commit: John Baldwin CommitDate: 2021-05-20 16:58:59 +0000 iscsi: Always free a cdw before its associated ctl_io. cxgbei stores state about a target transfer in the ctl_private[] array of a ctl_io that is freed when a target transfer (represented by the cdw) is freed. As such, freeing a ctl_io before a cdw that references it can result in a use after free in cxgbei. Two of the four places freed the cdw first, and the other two freed the ctl_io first. Fix the latter two places to free the cdw first. Reported by: Jithesh Arakkan @ Chelsio Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D30270 --- sys/cam/ctl/ctl_frontend_iscsi.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index fdbc06150f93..a5a80848c763 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1112,7 +1112,7 @@ static void cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) { struct cfiscsi_data_wait *cdw; - union ctl_io *io; + union ctl_io *io, *cdw_io; int error, last, wait; if (cs->cs_target == NULL) @@ -1144,10 +1144,11 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs) * assuming that the data transfer actually succeeded * and writing uninitialized data to disk. */ - cdw->cdw_ctl_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; - cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 42; - ctl_datamove_done(cdw->cdw_ctl_io, false); + cdw_io = cdw->cdw_ctl_io; + cdw_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; + cdw_io->scsiio.io_hdr.port_status = 42; cfiscsi_data_wait_free(cs, cdw); + ctl_datamove_done(cdw_io, false); CFISCSI_SESSION_LOCK(cs); } CFISCSI_SESSION_UNLOCK(cs); @@ -2920,6 +2921,7 @@ cfiscsi_task_management_done(union ctl_io *io) struct cfiscsi_data_wait *cdw, *tmpcdw; struct cfiscsi_session *cs, *tcs; struct cfiscsi_softc *softc; + union ctl_io *cdw_io; int cold_reset = 0; request = PRIV_REQUEST(io); @@ -2953,10 +2955,11 @@ cfiscsi_task_management_done(union ctl_io *io) #endif TAILQ_REMOVE(&cs->cs_waiting_for_data_out, cdw, cdw_next); - io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; - cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 43; - ctl_datamove_done(cdw->cdw_ctl_io, false); + cdw_io = cdw->cdw_ctl_io; + cdw_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; + cdw_io->scsiio.io_hdr.port_status = 43; cfiscsi_data_wait_free(cs, cdw); + ctl_datamove_done(cdw_io, false); } CFISCSI_SESSION_UNLOCK(cs); } From owner-dev-commits-src-main@freebsd.org Thu May 20 16:59:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78EF5643E29; Thu, 20 May 2021 16:59: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 4FmGDr2xWJz4Vr9; Thu, 20 May 2021 16:59: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 4DCD629C81; Thu, 20 May 2021 16:59: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 14KGxeOA056476; Thu, 20 May 2021 16:59:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KGxeHr056475; Thu, 20 May 2021 16:59:40 GMT (envelope-from git) Date: Thu, 20 May 2021 16:59:40 GMT Message-Id: <202105201659.14KGxeHr056475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 0cc7d64a2a37 - main - iscsi: Move the maximum data segment limits into 'struct icl_conn'. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0cc7d64a2a37533afe03d2b640dc107be41b5f56 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 16:59:40 -0000 The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=0cc7d64a2a37533afe03d2b640dc107be41b5f56 commit 0cc7d64a2a37533afe03d2b640dc107be41b5f56 Author: John Baldwin AuthorDate: 2021-05-20 16:59:11 +0000 Commit: John Baldwin CommitDate: 2021-05-20 16:59:11 +0000 iscsi: Move the maximum data segment limits into 'struct icl_conn'. This fixes a few bugs in iSCSI backends where the backends were using the limits they advertised initially during the login phase as the final values instead of the values negotiated with the other end. Reported by: Jithesh Arakkan @ Chelsio Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D30271 --- sys/cam/ctl/ctl_frontend_iscsi.c | 23 ++++++++++++-------- sys/cam/ctl/ctl_frontend_iscsi.h | 2 -- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 23 +++----------------- sys/dev/iscsi/icl.h | 3 ++- sys/dev/iscsi/icl_soft.c | 9 +++++--- sys/dev/iscsi/iscsi.c | 44 +++++++++++++++++++-------------------- sys/dev/iscsi/iscsi.h | 2 -- 7 files changed, 47 insertions(+), 59 deletions(-) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index a5a80848c763..b3cd8ab79d76 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1568,8 +1568,10 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) */ cs->cs_cmdsn = cihp->cmdsn; cs->cs_statsn = cihp->statsn; - cs->cs_max_recv_data_segment_length = cihp->max_recv_data_segment_length; - cs->cs_max_send_data_segment_length = cihp->max_send_data_segment_length; + cs->cs_conn->ic_max_recv_data_segment_length = + cihp->max_recv_data_segment_length; + cs->cs_conn->ic_max_send_data_segment_length = + cihp->max_send_data_segment_length; cs->cs_max_burst_length = cihp->max_burst_length; cs->cs_first_burst_length = cihp->first_burst_length; cs->cs_immediate_data = !!cihp->immediate_data; @@ -1734,8 +1736,8 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci) cs->cs_target->ct_tag, cs->cs_conn->ic_header_crc32c ? "CRC32C" : "None", cs->cs_conn->ic_data_crc32c ? "CRC32C" : "None", - cs->cs_max_recv_data_segment_length, - cs->cs_max_send_data_segment_length, + cs->cs_conn->ic_max_recv_data_segment_length, + cs->cs_conn->ic_max_send_data_segment_length, cs->cs_max_burst_length, cs->cs_first_burst_length, cs->cs_immediate_data, @@ -2534,12 +2536,14 @@ cfiscsi_datamove_in(union ctl_io *io) /* * Truncate to maximum data segment length. */ - KASSERT(response->ip_data_len < cs->cs_max_send_data_segment_length, + KASSERT(response->ip_data_len < + cs->cs_conn->ic_max_send_data_segment_length, ("ip_data_len %zd >= max_send_data_segment_length %d", - response->ip_data_len, cs->cs_max_send_data_segment_length)); + response->ip_data_len, + cs->cs_conn->ic_max_send_data_segment_length)); if (response->ip_data_len + len > - cs->cs_max_send_data_segment_length) { - len = cs->cs_max_send_data_segment_length - + cs->cs_conn->ic_max_send_data_segment_length) { + len = cs->cs_conn->ic_max_send_data_segment_length - response->ip_data_len; KASSERT(len <= sg_len, ("len %zd > sg_len %zd", len, sg_len)); @@ -2599,7 +2603,8 @@ cfiscsi_datamove_in(union ctl_io *io) i++; } - if (response->ip_data_len == cs->cs_max_send_data_segment_length) { + if (response->ip_data_len == + cs->cs_conn->ic_max_send_data_segment_length) { /* * Can't stuff more data into the current PDU; * queue it. Note that's not enough to check diff --git a/sys/cam/ctl/ctl_frontend_iscsi.h b/sys/cam/ctl/ctl_frontend_iscsi.h index a1c857231428..7c7f422a8d1f 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.h +++ b/sys/cam/ctl/ctl_frontend_iscsi.h @@ -86,8 +86,6 @@ struct cfiscsi_session { bool cs_terminating; bool cs_handoff_in_progress; bool cs_tasks_aborted; - int cs_max_recv_data_segment_length; - int cs_max_send_data_segment_length; int cs_max_burst_length; int cs_first_burst_length; bool cs_immediate_data; diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index fce593b54032..17d5685f1c1a 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -469,7 +469,7 @@ icl_cxgbei_conn_pdu_append_data(struct icl_conn *ic, struct icl_pdu *ip, } MPASS(len == 0); } - MPASS(ip->ip_data_len <= ic->ic_max_data_segment_length); + MPASS(ip->ip_data_len <= ic->ic_max_send_data_segment_length); return (0); } @@ -565,8 +565,6 @@ icl_cxgbei_new_conn(const char *name, struct mtx *lock) #ifdef DIAGNOSTIC refcount_init(&ic->ic_outstanding_pdus, 0); #endif - /* This is a stop-gap value that will be corrected during handoff. */ - ic->ic_max_data_segment_length = 16384; ic->ic_name = name; ic->ic_offload = "cxgbei"; ic->ic_unmapped = false; @@ -806,26 +804,11 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd) icc->toep = toep; icc->cwt = cxgbei_select_worker_thread(icc); - /* - * We maintain the _send_ DSL in this field just to have a - * convenient way to assert that the kernel never sends - * oversized PDUs. This field is otherwise unused in the driver - * or the kernel. - */ - ic->ic_max_data_segment_length = ci->max_tx_pdu_len - - ISCSI_BHS_SIZE; - icc->ulp_submode = 0; - if (ic->ic_header_crc32c) { + if (ic->ic_header_crc32c) icc->ulp_submode |= ULP_CRC_HEADER; - ic->ic_max_data_segment_length -= - ISCSI_HEADER_DIGEST_SIZE; - } - if (ic->ic_data_crc32c) { + if (ic->ic_data_crc32c) icc->ulp_submode |= ULP_CRC_DATA; - ic->ic_max_data_segment_length -= - ISCSI_DATA_DIGEST_SIZE; - } so->so_options |= SO_NO_DDP; toep->params.ulp_mode = ULP_MODE_ISCSI; toep->ulpcb = icc; diff --git a/sys/dev/iscsi/icl.h b/sys/dev/iscsi/icl.h index 0b897a50302a..94600c0edad1 100644 --- a/sys/dev/iscsi/icl.h +++ b/sys/dev/iscsi/icl.h @@ -109,7 +109,8 @@ struct icl_conn { bool ic_data_crc32c; bool ic_send_running; bool ic_receive_running; - size_t ic_max_data_segment_length; + uint32_t ic_max_recv_data_segment_length; + uint32_t ic_max_send_data_segment_length; size_t ic_maxtags; bool ic_disconnecting; bool ic_iser; diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c index 9cede6b44311..c15afbb59a68 100644 --- a/sys/dev/iscsi/icl_soft.c +++ b/sys/dev/iscsi/icl_soft.c @@ -573,7 +573,7 @@ icl_conn_receive_pdu(struct icl_conn *ic, struct mbuf **r, size_t *rs) */ len = icl_pdu_data_segment_length(request); - if (len > ic->ic_max_data_segment_length) { + if (len > ic->ic_max_recv_data_segment_length) { ICL_WARN("received data segment " "length %zd is larger than negotiated; " "dropping connection", len); @@ -1154,7 +1154,6 @@ icl_soft_new_conn(const char *name, struct mtx *lock) #ifdef DIAGNOSTIC refcount_init(&ic->ic_outstanding_pdus, 0); #endif - ic->ic_max_data_segment_length = max_data_segment_length; ic->ic_name = name; ic->ic_offload = "None"; ic->ic_unmapped = false; @@ -1205,13 +1204,17 @@ icl_conn_start(struct icl_conn *ic) * send a PDU in pieces; thus, the minimum buffer size is equal * to the maximum PDU size. "+4" is to account for possible padding. */ - minspace = sizeof(struct iscsi_bhs) + ic->ic_max_data_segment_length + + minspace = sizeof(struct iscsi_bhs) + + ic->ic_max_send_data_segment_length + ISCSI_HEADER_DIGEST_SIZE + ISCSI_DATA_DIGEST_SIZE + 4; if (sendspace < minspace) { ICL_WARN("kern.icl.sendspace too low; must be at least %zd", minspace); sendspace = minspace; } + minspace = sizeof(struct iscsi_bhs) + + ic->ic_max_recv_data_segment_length + + ISCSI_HEADER_DIGEST_SIZE + ISCSI_DATA_DIGEST_SIZE + 4; if (recvspace < minspace) { ICL_WARN("kern.icl.recvspace too low; must be at least %zd", minspace); diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 13a35c371c40..7ddb5a9ce1ec 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -1206,8 +1206,8 @@ iscsi_pdu_handle_r2t(struct icl_pdu *response) for (;;) { len = total_len; - if (len > is->is_max_send_data_segment_length) - len = is->is_max_send_data_segment_length; + if (len > is->is_conn->ic_max_send_data_segment_length) + len = is->is_conn->ic_max_send_data_segment_length; if (off + len > csio->dxfer_len) { ISCSI_SESSION_WARN(is, "target requested invalid " @@ -1433,9 +1433,9 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc, is->is_initial_r2t = handoff->idh_initial_r2t; is->is_immediate_data = handoff->idh_immediate_data; - is->is_max_recv_data_segment_length = + ic->ic_max_recv_data_segment_length = handoff->idh_max_recv_data_segment_length; - is->is_max_send_data_segment_length = + ic->ic_max_send_data_segment_length = handoff->idh_max_send_data_segment_length; is->is_max_burst_length = handoff->idh_max_burst_length; is->is_first_burst_length = handoff->idh_first_burst_length; @@ -1648,7 +1648,7 @@ iscsi_ioctl_daemon_send(struct iscsi_softc *sc, return (EIO); datalen = ids->ids_data_segment_len; - if (datalen > is->is_max_send_data_segment_length) + if (datalen > is->is_conn->ic_max_send_data_segment_length) return (EINVAL); if (datalen > 0) { data = malloc(datalen, M_ISCSI, M_WAITOK); @@ -1793,18 +1793,6 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) is = malloc(sizeof(*is), M_ISCSI, M_ZERO | M_WAITOK); memcpy(&is->is_conf, &isa->isa_conf, sizeof(is->is_conf)); - /* - * Set some default values, from RFC 3720, section 12. - * - * These values are updated by the handoff IOCTL, but are - * needed prior to the handoff to support sending the ISER - * login PDU. - */ - is->is_max_recv_data_segment_length = 8192; - is->is_max_send_data_segment_length = 8192; - is->is_max_burst_length = 262144; - is->is_first_burst_length = 65536; - sx_xlock(&sc->sc_lock); /* @@ -1847,6 +1835,18 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) cv_init(&is->is_login_cv, "iscsi_login"); #endif + /* + * Set some default values, from RFC 3720, section 12. + * + * These values are updated by the handoff IOCTL, but are + * needed prior to the handoff to support sending the ISER + * login PDU. + */ + is->is_conn->ic_max_recv_data_segment_length = 8192; + is->is_conn->ic_max_send_data_segment_length = 8192; + is->is_max_burst_length = 262144; + is->is_first_burst_length = 65536; + is->is_softc = sc; sc->sc_last_session_id++; is->is_id = sc->sc_last_session_id; @@ -1960,9 +1960,9 @@ iscsi_ioctl_session_list(struct iscsi_softc *sc, struct iscsi_session_list *isl) iss.iss_data_digest = ISCSI_DIGEST_NONE; iss.iss_max_send_data_segment_length = - is->is_max_send_data_segment_length; + is->is_conn->ic_max_send_data_segment_length; iss.iss_max_recv_data_segment_length = - is->is_max_recv_data_segment_length; + is->is_conn->ic_max_recv_data_segment_length; iss.iss_max_burst_length = is->is_max_burst_length; iss.iss_first_burst_length = is->is_first_burst_length; iss.iss_immediate_data = is->is_immediate_data; @@ -2330,10 +2330,10 @@ iscsi_action_scsiio(struct iscsi_session *is, union ccb *ccb) ISCSI_SESSION_DEBUG(is, "len %zd -> %d", len, is->is_first_burst_length); len = is->is_first_burst_length; } - if (len > is->is_max_send_data_segment_length) { + if (len > is->is_conn->ic_max_send_data_segment_length) { ISCSI_SESSION_DEBUG(is, "len %zd -> %d", len, - is->is_max_send_data_segment_length); - len = is->is_max_send_data_segment_length; + is->is_conn->ic_max_send_data_segment_length); + len = is->is_conn->ic_max_send_data_segment_length; } error = icl_pdu_append_data(request, csio->data_ptr, len, M_NOWAIT); diff --git a/sys/dev/iscsi/iscsi.h b/sys/dev/iscsi/iscsi.h index 793b7529c7c0..fe1cc64f88db 100644 --- a/sys/dev/iscsi/iscsi.h +++ b/sys/dev/iscsi/iscsi.h @@ -67,8 +67,6 @@ struct iscsi_session { uint8_t is_isid[6]; uint16_t is_tsih; bool is_immediate_data; - int is_max_recv_data_segment_length; - int is_max_send_data_segment_length; char is_target_alias[ISCSI_ALIAS_LEN]; TAILQ_HEAD(, iscsi_outstanding) is_outstanding; From owner-dev-commits-src-main@freebsd.org Thu May 20 17:30:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 272386445FD; Thu, 20 May 2021 17:30: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 4FmGwY0L1Jz4kFg; Thu, 20 May 2021 17: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 E87062A190; Thu, 20 May 2021 17: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 14KHUarS005020; Thu, 20 May 2021 17: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 14KHUaq5005019; Thu, 20 May 2021 17:30:36 GMT (envelope-from git) Date: Thu, 20 May 2021 17:30:36 GMT Message-Id: <202105201730.14KHUaq5005019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: d0ea5e467f3c - main - md5: portability fix -- include stdbool.h explicitly 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/main X-Git-Reftype: branch X-Git-Commit: d0ea5e467f3c44909667c5ee90c3d26653fb6687 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 17:30:37 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d0ea5e467f3c44909667c5ee90c3d26653fb6687 commit d0ea5e467f3c44909667c5ee90c3d26653fb6687 Author: Warner Losh AuthorDate: 2021-05-20 17:26:46 +0000 Commit: Warner Losh CommitDate: 2021-05-20 17:28:18 +0000 md5: portability fix -- include stdbool.h explicitly stdbool.h needs to be included to use type bool variables. Due to namespace pollution, this gets brought in on FreeBSD, but not on other systems. Include it explicilty. Noticed by: arichards@ Sponsored by: Netflix --- sbin/md5/md5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 4381ef124c7b..e553d4c56e85 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include From owner-dev-commits-src-main@freebsd.org Thu May 20 17:42:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D3E3644C03 for ; Thu, 20 May 2021 17:42:37 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmHBP1cJBz4rmm for ; Thu, 20 May 2021 17:42:37 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f48.google.com with SMTP id d11so18488011wrw.8 for ; Thu, 20 May 2021 10:42:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DD5J9xP9FCMUZ9HyHsOWuhxobAQG8y22hwkMVJsMWX8=; b=IWyqEfDWe0fByBXVIgWTz+W3nV5FRVgqfKnK3ChDNHKpjxeVsYryj2dPu0BCG9WCvN WTiU3Ss1X6zxyWBfSH9US0lwtPTsOWMMq7lS+yuaVRJlxzw4cI0N8pZ30yy009pUa5Ut Kko16oyF3WDaiD032GZWN3RstmOa6UuBE9b6h56TU1IpZQ3xLDBfEKyi+IvfPPx24f7X nQpHtPDYZCRdu+6dQydnKMFOWg6OsAdel0PalFeYtYpEcDEgSXyBW9KK6OLCGOExVoqq SiyGWLwHDG3r35hzb1AGqE4fd/lCnWDv6X+T3xNxNh3YTgncDA2sjSiWAMnVnWrt1eHR QDVQ== X-Gm-Message-State: AOAM533VifUYoUQSm2Aiiya938CfluCqaNgNFXnLUN7kUWDKzTQRMGV+ bpAz11mwWp8DhZgMI7vVs4yDQQ== X-Google-Smtp-Source: ABdhPJywIWabfgrrCc+Vyq2ksf1krYddFRFOGE4FO8cOAyLUHDRri065zP3MTQG1Sw6+xiD4lXP3Jw== X-Received: by 2002:a5d:4e0b:: with SMTP id p11mr5378977wrt.220.1621532555466; Thu, 20 May 2021 10:42:35 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id y22sm11720988wma.36.2021.05.20.10.42.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 May 2021 10:42:35 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: d0ea5e467f3c - main - md5: portability fix -- include stdbool.h explicitly From: Jessica Clarke In-Reply-To: <202105201730.14KHUaq5005019@gitrepo.freebsd.org> Date: Thu, 20 May 2021 18:42:33 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <1D5D272D-639A-4CA3-BCBC-F1386E6991DB@freebsd.org> References: <202105201730.14KHUaq5005019@gitrepo.freebsd.org> To: Warner Losh X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FmHBP1cJBz4rmm 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 17:42:37 -0000 =3DOn 20 May 2021, at 18:30, Warner Losh wrote: >=20 > The branch main has been updated by imp: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3Dd0ea5e467f3c44909667c5ee90c3d266= 53fb6687 >=20 > commit d0ea5e467f3c44909667c5ee90c3d26653fb6687 > Author: Warner Losh > AuthorDate: 2021-05-20 17:26:46 +0000 > Commit: Warner Losh > CommitDate: 2021-05-20 17:28:18 +0000 >=20 > md5: portability fix -- include stdbool.h explicitly >=20 > stdbool.h needs to be included to use type bool variables. Due to > namespace pollution, this gets brought in on FreeBSD, but not on > other systems. Include it explicilty. Thanks! > Noticed by: arichards@ For once a cross-building issue not reported by Alex, though still Cambridge :) Jess From owner-dev-commits-src-main@freebsd.org Thu May 20 19:09:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9589664676D; Thu, 20 May 2021 19: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 4FmK7B3sFpz4YBm; Thu, 20 May 2021 19: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 6BD6B2B17D; Thu, 20 May 2021 19: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 14KJ9wx8030000; Thu, 20 May 2021 19: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 14KJ9wkx029999; Thu, 20 May 2021 19:09:58 GMT (envelope-from git) Date: Thu, 20 May 2021 19:09:58 GMT Message-Id: <202105201909.14KJ9wkx029999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 5d698386fbfe - main - hda: correct comment about Asus laptop digital mics MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d698386fbfe166df72a17712ffde8cefeecefab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 19:09:58 -0000 The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=5d698386fbfe166df72a17712ffde8cefeecefab commit 5d698386fbfe166df72a17712ffde8cefeecefab Author: Philippe Michaud-Boudreault AuthorDate: 2021-05-19 14:32:25 +0000 Commit: Ed Maste CommitDate: 2021-05-20 18:58:00 +0000 hda: correct comment about Asus laptop digital mics Reported in review D30333 MFC after: 1 week --- sys/dev/sound/pci/hda/hdaa_patches.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/sound/pci/hda/hdaa_patches.c b/sys/dev/sound/pci/hda/hdaa_patches.c index 755f2aef461b..590c9e4d46fb 100644 --- a/sys/dev/sound/pci/hda/hdaa_patches.c +++ b/sys/dev/sound/pci/hda/hdaa_patches.c @@ -808,10 +808,10 @@ hdaa_patch_direct(struct hdaa_devinfo *devinfo) subid == 0x834a1043 || subid == 0x83981043 || subid == 0x83ce1043) { /* - * The ditital mics on some Asus laptops produce + * The digital mics on some Asus laptops produce * differential signals instead of expected stereo. - * That results in silence if downmix it to mono. - * To workaround, make codec to handle signal as mono. + * That results in silence if downmixing to mono. + * To workaround, make codec handle the signal as mono. */ val = hdaa_read_coef(dev, 0x20, 0x07); hdaa_write_coef(dev, 0x20, 0x07, val|0x80); From owner-dev-commits-src-main@freebsd.org Thu May 20 19:40:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6764646DF3; Thu, 20 May 2021 19:40: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 4FmKpZ4htsz4lhd; Thu, 20 May 2021 19:40: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 8823D2BC17; Thu, 20 May 2021 19:40: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 14KJecp0078331; Thu, 20 May 2021 19:40:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14KJecCB078330; Thu, 20 May 2021 19:40:38 GMT (envelope-from git) Date: Thu, 20 May 2021 19:40:38 GMT Message-Id: <202105201940.14KJecCB078330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d7751071bc41 - main - kldxref: do not error out if specified path is not directory, for -d mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d7751071bc41c63c5dadd81ef4b0a26748d8f9b0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 19:40:38 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d7751071bc41c63c5dadd81ef4b0a26748d8f9b0 commit d7751071bc41c63c5dadd81ef4b0a26748d8f9b0 Author: Konstantin Belousov AuthorDate: 2021-05-20 19:12:11 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-20 19:40:01 +0000 kldxref: do not error out if specified path is not directory, for -d mode kldxref(8) is the only tool that can dump FreeBSD kernel module metadata, with the -d option. But the command line requirements for that are inconvenient, since parser requires that argv[1] is a directory containing whole set of modules to generate xref file. For -d, allow argv[0] to be a regular file, now it is possible to do e.g. $ kldxref -d /boot/kernel/ufs.ko to see only ufs.ko metadata. Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30368 --- usr.sbin/kldxref/kldxref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c index e1996862119a..7a4d704356b8 100644 --- a/usr.sbin/kldxref/kldxref.c +++ b/usr.sbin/kldxref/kldxref.c @@ -716,7 +716,7 @@ main(int argc, char *argv[]) if (stat(argv[0], &sb) != 0) err(1, "%s", argv[0]); - if ((sb.st_mode & S_IFDIR) == 0) { + if ((sb.st_mode & S_IFDIR) == 0 && !dflag) { errno = ENOTDIR; err(1, "%s", argv[0]); } From owner-dev-commits-src-main@freebsd.org Fri May 21 00:24:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 043E664C199 for ; Fri, 21 May 2021 00:24:51 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmS6V62xjz3GrV for ; Fri, 21 May 2021 00:24:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x729.google.com with SMTP id q10so18159792qkc.5 for ; Thu, 20 May 2021 17:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jgLYgMMmVahP/UDOmaYDcfKusxvmdBnE3ncS/PhIkvQ=; b=LEIa1xXWk06gZE9qul881/uDJzC8reAjuVF/renJPKwrBX9rpP4TbVdGvLZr0BWZe9 ZYsQRD2Sjjj376IEcwoR3Lk9SQNrP3RMGyCm0DWVrzHK9/xl9zjek5fJ19cTSw3Bbbiz FDO3RJjS1Lba18U+fmmKZDBd/ilIrugKV2u3yKz3zjTzqEmuQoJp1oPS2FF9SklVzJYv P2W3v711rLAligh0sOhOpNjyyV7Y+oB0TXYLCsZzn3bxvo3ih/bhos8alaUtZZAPVvd6 849C+LY2pE+T/xrd2hErxtesYjT8k0jbENlrmA4lG1zRaw/10eXPjnlkSbp39XP/rWQu eo5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jgLYgMMmVahP/UDOmaYDcfKusxvmdBnE3ncS/PhIkvQ=; b=XTjiE/76AlKUHuOUzdU091X6JBnM2XXgOF9VyhhHmaDi901BBzScueYuMZReCcUL0b kD+uANgPwP48mxUSjLd1RJtx1RasEjbymXSKn6k8Qai4nzW6Sf2GncOqg1WIL7Hq9guI VVTvrPxWL9iIKAxVlfuNWjyTIP6VD40tL7L/ScTY5TZ26eXCHDrhD79sx1dLhHdUmTiP jA4p8KJaSsUxjQ/8Jc/FNan2qbjZapN+XphP9WCyh8xXjl76Kc0DfKzdqOvrx2EblPZf 7FIJCvfKPUOwumyfItjShzfq2VD6rHcT1KHMpudqV2EBIQqb1bhAAN54YyDtd2mOMGNE Kiag== X-Gm-Message-State: AOAM530xNykQIsQ0EPIMkhx5vrbFRzaOhYs/PYg3PFNSlwH2HBQFsihM kU5gJB4Zjj1e4c8tv+oPAfm4k/Lg8GMtY94EPj+fLA== X-Google-Smtp-Source: ABdhPJwuX9f9cOZnAbFdjQxK1ajqsTtCHDmZ7rIdEvu6X2baLM+TWkr8AXlGBCtCtQ+C0G2muSEUTOrqf+5fBgqHEPM= X-Received: by 2002:a37:30b:: with SMTP id 11mr8066201qkd.206.1621556690008; Thu, 20 May 2021 17:24:50 -0700 (PDT) MIME-Version: 1.0 References: <202105201730.14KHUaq5005019@gitrepo.freebsd.org> <1D5D272D-639A-4CA3-BCBC-F1386E6991DB@freebsd.org> In-Reply-To: <1D5D272D-639A-4CA3-BCBC-F1386E6991DB@freebsd.org> From: Warner Losh Date: Thu, 20 May 2021 18:24:39 -0600 Message-ID: Subject: Re: git: d0ea5e467f3c - main - md5: portability fix -- include stdbool.h explicitly To: Jessica Clarke Cc: Warner Losh , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" X-Rspamd-Queue-Id: 4FmS6V62xjz3GrV X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 00:24:51 -0000 On Thu, May 20, 2021 at 11:42 AM Jessica Clarke wrote: > =On 20 May 2021, at 18:30, Warner Losh wrote: > > > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=d0ea5e467f3c44909667c5ee90c3d26653fb6687 > > > > commit d0ea5e467f3c44909667c5ee90c3d26653fb6687 > > Author: Warner Losh > > AuthorDate: 2021-05-20 17:26:46 +0000 > > Commit: Warner Losh > > CommitDate: 2021-05-20 17:28:18 +0000 > > > > md5: portability fix -- include stdbool.h explicitly > > > > stdbool.h needs to be included to use type bool variables. Due to > > namespace pollution, this gets brought in on FreeBSD, but not on > > other systems. Include it explicilty. > > Thanks! > > > Noticed by: arichards@ > > For once a cross-building issue not reported by Alex, though still > Cambridge :) > Doh! I've been in a daze all day. Sorry about that... Warner From owner-dev-commits-src-main@freebsd.org Fri May 21 01:40:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 065EB64D8C0; Fri, 21 May 2021 01:40:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmTp96Txgz4dFc; Fri, 21 May 2021 01:40: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 C2FF9763; Fri, 21 May 2021 01:40: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 14L1en2r052803; Fri, 21 May 2021 01:40:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L1enks052802; Fri, 21 May 2021 01:40:49 GMT (envelope-from git) Date: Fri, 21 May 2021 01:40:49 GMT Message-Id: <202105210140.14L1enks052802@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: d80a903a1c2a - main - nfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d80a903a1c2acd73afbf06598955a0887433f8c6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 01:40:50 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=d80a903a1c2acd73afbf06598955a0887433f8c6 commit d80a903a1c2acd73afbf06598955a0887433f8c6 Author: Rick Macklem AuthorDate: 2021-05-21 01:37:40 +0000 Commit: Rick Macklem CommitDate: 2021-05-21 01:37:40 +0000 nfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open Commit b3d4c70dc60f added support for CLAIM_DELEG_CUR_FH to Open. While doing this, I noticed that CLAIM_DELEG_PREV_FH support could be added the same way. Although I am not aware of any extant NFSv4.1/4.2 client that uses this claim type, it seems prudent to add support for this variant of Open to the NFSv4.1/4.2 server. This patch does not affect mounts from extant NFSv4.1/4.2 clients, as far as I know. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdserv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 5d6cac23b722..ef78f90fabfc 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -2987,7 +2987,8 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, stateid.seqid = fxdr_unsigned(u_int32_t, *tl++); NFSBCOPY((caddr_t)tl,(caddr_t)stateid.other,NFSX_STATEIDOTHER); stp->ls_flags |= NFSLCK_DELEGCUR; - } else if (claim == NFSV4OPEN_CLAIMDELEGATEPREV) { + } else if (claim == NFSV4OPEN_CLAIMDELEGATEPREV || claim == + NFSV4OPEN_CLAIMDELEGATEPREVFH) { stp->ls_flags |= NFSLCK_DELEGPREV; } if (claim == NFSV4OPEN_CLAIMNULL || claim == NFSV4OPEN_CLAIMDELEGATECUR @@ -3057,7 +3058,8 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, &exclusive_flag, &nva, cverf, create, aclp, &attrbits, nd->nd_cred, exp, &vp); } else if (claim == NFSV4OPEN_CLAIMPREVIOUS || claim == - NFSV4OPEN_CLAIMFH || claim == NFSV4OPEN_CLAIMDELEGATECURFH) { + NFSV4OPEN_CLAIMFH || claim == NFSV4OPEN_CLAIMDELEGATECURFH || + claim == NFSV4OPEN_CLAIMDELEGATEPREVFH) { if (claim == NFSV4OPEN_CLAIMPREVIOUS) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); From owner-dev-commits-src-main@freebsd.org Fri May 21 04:57:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D0B16650A8B; Fri, 21 May 2021 04: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 4FmZ9b5LyLz3PBx; Fri, 21 May 2021 04: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 9FA91303E; Fri, 21 May 2021 04: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 14L4vtW5009098; Fri, 21 May 2021 04: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 14L4vtje009097; Fri, 21 May 2021 04:57:55 GMT (envelope-from git) Date: Fri, 21 May 2021 04:57:55 GMT Message-Id: <202105210457.14L4vtje009097@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 741afc623391 - main - ip_mroute: refactor bw_meter API MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 741afc6233915ba33156c2221aa80d2dd2b76b9c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 04:57:55 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=741afc6233915ba33156c2221aa80d2dd2b76b9c commit 741afc6233915ba33156c2221aa80d2dd2b76b9c Author: Wojciech Macek AuthorDate: 2021-05-05 03:28:56 +0000 Commit: Wojciech Macek CommitDate: 2021-05-21 04:43:41 +0000 ip_mroute: refactor bw_meter API API should work as following: - periodicaly report Lower-or-EQual bandwidth (LEQ) connections over kernel socket, if user application registered for such per-flow notifications - report Grater-or-EQual (GEQ) bandwidth as soon as it reaches specified value in configured time window Custom implementation of callouts was removed. There is no point of doing calout-wheel here as generic callouts are doing exactly the same. The performance is not critical for such reporting, so the biggest concern should be to have a code which can be easily maintained. This is ia preparation for locking rework which is highly inefficient. Approved by: mw Sponsored by: Stormshield Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D30210 --- sys/netinet/ip_mroute.c | 610 ++++++++++++++++------------------------------- sys/netinet/ip_mroute.h | 12 +- usr.bin/netstat/mroute.c | 15 +- 3 files changed, 233 insertions(+), 404 deletions(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index b8e677ba9af1..0cb980b7247e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -49,6 +49,7 @@ * Modified by Pavlin Radoslavov, USC/ISI, May 1998, August 1999, October 2000 * Modified by Hitoshi Asaeda, WIDE, August 2000 * Modified by Pavlin Radoslavov, ICSI, October 2002 + * Modified by Wojciech Macek, Semihalf, May 2021 * * MROUTING Revision: 3.5 * and PIM-SMv2 and PIM-DM support, advanced API support, @@ -202,16 +203,6 @@ VNET_DEFINE_STATIC(struct callout, expire_upcalls_ch); * Bandwidth meter variables and constants */ static MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters"); -/* - * Pending timeouts are stored in a hash table, the key being the - * expiration time. Periodically, the entries are analysed and processed. - */ -#define BW_METER_BUCKETS 1024 -VNET_DEFINE_STATIC(struct bw_meter **, bw_meter_timers); -#define V_bw_meter_timers VNET(bw_meter_timers) -VNET_DEFINE_STATIC(struct callout, bw_meter_ch); -#define V_bw_meter_ch VNET(bw_meter_ch) -#define BW_METER_PERIOD (hz) /* periodical handling of bw meters */ /* * Pending upcalls are stored in a vector which is flushed when @@ -320,14 +311,13 @@ static int add_mfc(struct mfcctl2 *); static int add_vif(struct vifctl *); static void bw_meter_prepare_upcall(struct bw_meter *, struct timeval *); static void bw_meter_process(void); -static void bw_meter_receive_packet(struct bw_meter *, int, +static void bw_meter_geq_receive_packet(struct bw_meter *, int, struct timeval *); static void bw_upcalls_send(void); static int del_bw_upcall(struct bw_upcall *); static int del_mfc(struct mfcctl2 *); static int del_vif(vifi_t); static int del_vif_locked(vifi_t); -static void expire_bw_meter_process(void *); static void expire_bw_upcalls_send(void *); static void expire_mfc(struct mfc *); static void expire_upcalls(void *); @@ -685,8 +675,6 @@ ip_mrouter_init(struct socket *so, int version) curvnet); callout_reset(&V_bw_upcalls_ch, BW_UPCALLS_PERIOD, expire_bw_upcalls_send, curvnet); - callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, - curvnet); V_ip_mrouter = so; ip_mrouter_cnt++; @@ -745,7 +733,6 @@ X_ip_mrouter_done(void) callout_stop(&V_expire_upcalls_ch); callout_stop(&V_bw_upcalls_ch); - callout_stop(&V_bw_meter_ch); MFC_LOCK(); @@ -766,7 +753,6 @@ X_ip_mrouter_done(void) bzero(V_nexpire, sizeof(V_nexpire[0]) * mfchashsize); V_bw_upcalls_n = 0; - bzero(V_bw_meter_timers, BW_METER_BUCKETS * sizeof(*V_bw_meter_timers)); MFC_UNLOCK(); @@ -1036,7 +1022,8 @@ expire_mfc(struct mfc *rt) MFC_LOCK_ASSERT(); - free_bw_list(rt->mfc_bw_meter); + free_bw_list(rt->mfc_bw_meter_leq); + free_bw_list(rt->mfc_bw_meter_geq); TAILQ_FOREACH_SAFE(rte, &rt->mfc_stall, rte_link, nrte) { m_freem(rte->m); @@ -1139,7 +1126,8 @@ add_mfc(struct mfcctl2 *mfccp) rt->mfc_nstall = 0; rt->mfc_expire = 0; - rt->mfc_bw_meter = NULL; + rt->mfc_bw_meter_leq = NULL; + rt->mfc_bw_meter_geq = NULL; /* insert new entry at head of hash chain */ LIST_INSERT_HEAD(&V_mfchashtbl[hash], rt, mfc_hash); @@ -1179,8 +1167,10 @@ del_mfc(struct mfcctl2 *mfccp) /* * free the bw_meter entries */ - free_bw_list(rt->mfc_bw_meter); - rt->mfc_bw_meter = NULL; + free_bw_list(rt->mfc_bw_meter_leq); + rt->mfc_bw_meter_leq = NULL; + free_bw_list(rt->mfc_bw_meter_geq); + rt->mfc_bw_meter_geq = NULL; LIST_REMOVE(rt, mfc_hash); free(rt, M_MRTABLE); @@ -1393,7 +1383,8 @@ fail: /* clear the RP address */ rt->mfc_rp.s_addr = INADDR_ANY; - rt->mfc_bw_meter = NULL; + rt->mfc_bw_meter_leq = NULL; + rt->mfc_bw_meter_geq = NULL; /* initialize pkt counters per src-grp */ rt->mfc_pkt_cnt = 0; @@ -1459,16 +1450,6 @@ expire_upcalls(void *arg) if (rt->mfc_expire == 0 || --rt->mfc_expire > 0) continue; - /* - * free the bw_meter entries - */ - while (rt->mfc_bw_meter != NULL) { - struct bw_meter *x = rt->mfc_bw_meter; - - rt->mfc_bw_meter = x->bm_mfc_next; - free(x, M_BWMETER); - } - MRTSTAT_INC(mrts_cache_cleanups); CTR3(KTR_IPMF, "%s: expire (%lx, %lx)", __func__, (u_long)ntohl(rt->mfc_origin.s_addr), @@ -1602,14 +1583,22 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) /* * Perform upcall-related bw measuring. */ - if (rt->mfc_bw_meter != NULL) { + if ((rt->mfc_bw_meter_geq != NULL) || (rt->mfc_bw_meter_leq != NULL)) { struct bw_meter *x; struct timeval now; microtime(&now); MFC_LOCK_ASSERT(); - for (x = rt->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) - bw_meter_receive_packet(x, plen, &now); + /* Process meters for Greater-or-EQual case */ + for (x = rt->mfc_bw_meter_geq; x != NULL; x = x->bm_mfc_next) + bw_meter_geq_receive_packet(x, plen, &now); + + /* Process meters for Lower-or-EQual case */ + for (x = rt->mfc_bw_meter_leq; x != NULL; x = x->bm_mfc_next) { + /* Record that a packet is received */ + x->bm_measured.b_packets++; + x->bm_measured.b_bytes += plen; + } } return 0; @@ -1759,84 +1748,139 @@ compute_bw_meter_flags(struct bw_upcall *req) return flags; } +static void +expire_bw_meter_leq(void *arg) +{ + struct bw_meter *x = arg; + struct timeval now; + /* + * INFO: + * callout is always executed with MFC_LOCK taken + */ + + CURVNET_SET((struct vnet *)x->arg); + + microtime(&now); + + /* + * Test if we should deliver an upcall + */ + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, &now); + } + + /* Send all upcalls that are pending delivery */ + bw_upcalls_send(); + + /* Reset counters */ + x->bm_start_time = now; + x->bm_measured.b_bytes = 0; + x->bm_measured.b_packets = 0; + + callout_schedule(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time)); + + CURVNET_RESTORE(); +} + /* * Add a bw_meter entry */ static int add_bw_upcall(struct bw_upcall *req) { - struct mfc *mfc; - struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, - BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; - struct timeval now; - struct bw_meter *x; - uint32_t flags; + struct mfc *mfc; + struct timeval delta = { BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC, + BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC }; + struct timeval now; + struct bw_meter *x, **bwm_ptr; + uint32_t flags; - if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) - return EOPNOTSUPP; + if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) + return EOPNOTSUPP; - /* Test if the flags are valid */ - if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) - return EINVAL; - if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) - return EINVAL; - if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) - return EINVAL; + /* Test if the flags are valid */ + if (!(req->bu_flags & (BW_UPCALL_UNIT_PACKETS | BW_UPCALL_UNIT_BYTES))) + return EINVAL; + if (!(req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ))) + return EINVAL; + if ((req->bu_flags & (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + == (BW_UPCALL_GEQ | BW_UPCALL_LEQ)) + return EINVAL; - /* Test if the threshold time interval is valid */ - if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) - return EINVAL; + /* Test if the threshold time interval is valid */ + if (BW_TIMEVALCMP(&req->bu_threshold.b_time, &delta, <)) + return EINVAL; - flags = compute_bw_meter_flags(req); + flags = compute_bw_meter_flags(req); - /* - * Find if we have already same bw_meter entry - */ - MFC_LOCK(); - mfc = mfc_find(&req->bu_src, &req->bu_dst); - if (mfc == NULL) { - MFC_UNLOCK(); - return EADDRNOTAVAIL; - } - for (x = mfc->mfc_bw_meter; x != NULL; x = x->bm_mfc_next) { - if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, - &req->bu_threshold.b_time, ==)) && - (x->bm_threshold.b_packets == req->bu_threshold.b_packets) && - (x->bm_threshold.b_bytes == req->bu_threshold.b_bytes) && - (x->bm_flags & BW_METER_USER_FLAGS) == flags) { - MFC_UNLOCK(); - return 0; /* XXX Already installed */ + /* + * Find if we have already same bw_meter entry + */ + MFC_LOCK(); + mfc = mfc_find(&req->bu_src, &req->bu_dst); + if (mfc == NULL) { + MFC_UNLOCK(); + return EADDRNOTAVAIL; } - } - /* Allocate the new bw_meter entry */ - x = (struct bw_meter *)malloc(sizeof(*x), M_BWMETER, M_NOWAIT); - if (x == NULL) { - MFC_UNLOCK(); - return ENOBUFS; - } + /* Choose an appropriate bw_meter list */ + if (req->bu_flags & BW_UPCALL_GEQ) + bwm_ptr = &mfc->mfc_bw_meter_geq; + else + bwm_ptr = &mfc->mfc_bw_meter_leq; + + for (x = *bwm_ptr; x != NULL; x = x->bm_mfc_next) { + if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, + &req->bu_threshold.b_time, ==)) + && (x->bm_threshold.b_packets + == req->bu_threshold.b_packets) + && (x->bm_threshold.b_bytes + == req->bu_threshold.b_bytes) + && (x->bm_flags & BW_METER_USER_FLAGS) + == flags) { + MFC_UNLOCK(); + return 0; /* XXX Already installed */ + } + } - /* Set the new bw_meter entry */ - x->bm_threshold.b_time = req->bu_threshold.b_time; - microtime(&now); - x->bm_start_time = now; - x->bm_threshold.b_packets = req->bu_threshold.b_packets; - x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags = flags; - x->bm_time_next = NULL; - x->bm_time_hash = BW_METER_BUCKETS; - - /* Add the new bw_meter entry to the front of entries for this MFC */ - x->bm_mfc = mfc; - x->bm_mfc_next = mfc->mfc_bw_meter; - mfc->mfc_bw_meter = x; - schedule_bw_meter(x, &now); - MFC_UNLOCK(); + /* Allocate the new bw_meter entry */ + x = (struct bw_meter*) malloc(sizeof(*x), M_BWMETER, M_NOWAIT); + if (x == NULL) { + MFC_UNLOCK(); + return ENOBUFS; + } - return 0; + /* Set the new bw_meter entry */ + x->bm_threshold.b_time = req->bu_threshold.b_time; + microtime(&now); + x->bm_start_time = now; + x->bm_threshold.b_packets = req->bu_threshold.b_packets; + x->bm_threshold.b_bytes = req->bu_threshold.b_bytes; + x->bm_measured.b_packets = 0; + x->bm_measured.b_bytes = 0; + x->bm_flags = flags; + x->bm_time_next = NULL; + x->bm_mfc = mfc; + x->arg = curvnet; + + /* For LEQ case create periodic callout */ + if (req->bu_flags & BW_UPCALL_LEQ) { + callout_init_mtx(&x->bm_meter_callout, &mfc_mtx,0); + callout_reset(&x->bm_meter_callout, tvtohz(&x->bm_threshold.b_time), + expire_bw_meter_leq, x); + } + + /* Add the new bw_meter entry to the front of entries for this MFC */ + x->bm_mfc_next = *bwm_ptr; + *bwm_ptr = x; + + MFC_UNLOCK(); + + return 0; } static void @@ -1845,8 +1889,11 @@ free_bw_list(struct bw_meter *list) while (list != NULL) { struct bw_meter *x = list; + /* MFC_LOCK must be held here */ + if (x->bm_flags & BW_METER_LEQ) + callout_drain(&x->bm_meter_callout); + list = list->bm_mfc_next; - unschedule_bw_meter(x); free(x, M_BWMETER); } } @@ -1858,7 +1905,7 @@ static int del_bw_upcall(struct bw_upcall *req) { struct mfc *mfc; - struct bw_meter *x; + struct bw_meter *x, **bwm_ptr; if (!(V_mrt_api_config & MRT_MFC_BW_UPCALL)) return EOPNOTSUPP; @@ -1876,8 +1923,14 @@ del_bw_upcall(struct bw_upcall *req) */ struct bw_meter *list; - list = mfc->mfc_bw_meter; - mfc->mfc_bw_meter = NULL; + /* Free LEQ list */ + list = mfc->mfc_bw_meter_leq; + mfc->mfc_bw_meter_leq = NULL; + free_bw_list(list); + + /* Free GEQ list */ + list = mfc->mfc_bw_meter_geq; + mfc->mfc_bw_meter_geq = NULL; free_bw_list(list); MFC_UNLOCK(); return 0; @@ -1887,8 +1940,14 @@ del_bw_upcall(struct bw_upcall *req) flags = compute_bw_meter_flags(req); + /* Choose an appropriate bw_meter list */ + if (req->bu_flags & BW_UPCALL_GEQ) + bwm_ptr = &mfc->mfc_bw_meter_geq; + else + bwm_ptr = &mfc->mfc_bw_meter_leq; + /* Find the bw_meter entry to delete */ - for (prev = NULL, x = mfc->mfc_bw_meter; x != NULL; + for (prev = NULL, x = *bwm_ptr; x != NULL; prev = x, x = x->bm_mfc_next) { if ((BW_TIMEVALCMP(&x->bm_threshold.b_time, &req->bu_threshold.b_time, ==)) && @@ -1901,9 +1960,11 @@ del_bw_upcall(struct bw_upcall *req) if (prev != NULL) prev->bm_mfc_next = x->bm_mfc_next; /* remove from middle*/ else - x->bm_mfc->mfc_bw_meter = x->bm_mfc_next;/* new head of list */ + *bwm_ptr = x->bm_mfc_next;/* new head of list */ + + if (req->bu_flags & BW_UPCALL_LEQ) + callout_stop(&x->bm_meter_callout); - unschedule_bw_meter(x); MFC_UNLOCK(); /* Free the bw_meter entry */ free(x, M_BWMETER); @@ -1920,16 +1981,15 @@ del_bw_upcall(struct bw_upcall *req) * Perform bandwidth measurement processing that may result in an upcall */ static void -bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) +bw_meter_geq_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) { - struct timeval delta; + struct timeval delta; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); - if (x->bm_flags & BW_METER_GEQ) { /* * Processing for ">=" type of bw_meter entry */ @@ -1949,63 +2009,15 @@ bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) * Test if we should deliver an upcall */ if (!(x->bm_flags & BW_METER_UPCALL_DELIVERED)) { - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, nowp); - x->bm_flags |= BW_METER_UPCALL_DELIVERED; - } - } - } else if (x->bm_flags & BW_METER_LEQ) { - /* - * Processing for "<=" type of bw_meter entry - */ - if (BW_TIMEVALCMP(&delta, &x->bm_threshold.b_time, >)) { - /* - * We are behind time with the multicast forwarding table - * scanning for "<=" type of bw_meter entries, so test now - * if we should deliver an upcall. - */ - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, nowp); - } - /* Reschedule the bw_meter entry */ - unschedule_bw_meter(x); - schedule_bw_meter(x, nowp); - } - - /* Record that a packet is received */ - x->bm_measured.b_packets++; - x->bm_measured.b_bytes += plen; - - /* - * Test if we should restart the measuring interval - */ - if ((x->bm_flags & BW_METER_UNIT_PACKETS && - x->bm_measured.b_packets <= x->bm_threshold.b_packets) || - (x->bm_flags & BW_METER_UNIT_BYTES && - x->bm_measured.b_bytes <= x->bm_threshold.b_bytes)) { - /* Don't restart the measuring interval */ - } else { - /* Do restart the measuring interval */ - /* - * XXX: note that we don't unschedule and schedule, because this - * might be too much overhead per packet. Instead, when we process - * all entries for a given timer hash bin, we check whether it is - * really a timeout. If not, we reschedule at that time. - */ - x->bm_start_time = *nowp; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; + if (((x->bm_flags & BW_METER_UNIT_PACKETS) && + (x->bm_measured.b_packets >= x->bm_threshold.b_packets)) || + ((x->bm_flags & BW_METER_UNIT_BYTES) && + (x->bm_measured.b_bytes >= x->bm_threshold.b_bytes))) { + /* Prepare an upcall for delivery */ + bw_meter_prepare_upcall(x, nowp); + x->bm_flags |= BW_METER_UPCALL_DELIVERED; + } } - } } /* @@ -2014,44 +2026,44 @@ bw_meter_receive_packet(struct bw_meter *x, int plen, struct timeval *nowp) static void bw_meter_prepare_upcall(struct bw_meter *x, struct timeval *nowp) { - struct timeval delta; - struct bw_upcall *u; + struct timeval delta; + struct bw_upcall *u; - MFC_LOCK_ASSERT(); + MFC_LOCK_ASSERT(); - /* - * Compute the measured time interval - */ - delta = *nowp; - BW_TIMEVALDECR(&delta, &x->bm_start_time); + /* + * Compute the measured time interval + */ + delta = *nowp; + BW_TIMEVALDECR(&delta, &x->bm_start_time); - /* - * If there are too many pending upcalls, deliver them now - */ - if (V_bw_upcalls_n >= BW_UPCALLS_MAX) - bw_upcalls_send(); + /* + * If there are too many pending upcalls, deliver them now + */ + if (V_bw_upcalls_n >= BW_UPCALLS_MAX) + bw_upcalls_send(); - /* - * Set the bw_upcall entry - */ - u = &V_bw_upcalls[V_bw_upcalls_n++]; - u->bu_src = x->bm_mfc->mfc_origin; - u->bu_dst = x->bm_mfc->mfc_mcastgrp; - u->bu_threshold.b_time = x->bm_threshold.b_time; - u->bu_threshold.b_packets = x->bm_threshold.b_packets; - u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; - u->bu_measured.b_time = delta; - u->bu_measured.b_packets = x->bm_measured.b_packets; - u->bu_measured.b_bytes = x->bm_measured.b_bytes; - u->bu_flags = 0; - if (x->bm_flags & BW_METER_UNIT_PACKETS) - u->bu_flags |= BW_UPCALL_UNIT_PACKETS; - if (x->bm_flags & BW_METER_UNIT_BYTES) - u->bu_flags |= BW_UPCALL_UNIT_BYTES; - if (x->bm_flags & BW_METER_GEQ) - u->bu_flags |= BW_UPCALL_GEQ; - if (x->bm_flags & BW_METER_LEQ) - u->bu_flags |= BW_UPCALL_LEQ; + /* + * Set the bw_upcall entry + */ + u = &V_bw_upcalls[V_bw_upcalls_n++]; + u->bu_src = x->bm_mfc->mfc_origin; + u->bu_dst = x->bm_mfc->mfc_mcastgrp; + u->bu_threshold.b_time = x->bm_threshold.b_time; + u->bu_threshold.b_packets = x->bm_threshold.b_packets; + u->bu_threshold.b_bytes = x->bm_threshold.b_bytes; + u->bu_measured.b_time = delta; + u->bu_measured.b_packets = x->bm_measured.b_packets; + u->bu_measured.b_bytes = x->bm_measured.b_bytes; + u->bu_flags = 0; + if (x->bm_flags & BW_METER_UNIT_PACKETS) + u->bu_flags |= BW_UPCALL_UNIT_PACKETS; + if (x->bm_flags & BW_METER_UNIT_BYTES) + u->bu_flags |= BW_UPCALL_UNIT_BYTES; + if (x->bm_flags & BW_METER_GEQ) + u->bu_flags |= BW_UPCALL_GEQ; + if (x->bm_flags & BW_METER_LEQ) + u->bu_flags |= BW_UPCALL_LEQ; } /* @@ -2103,183 +2115,6 @@ bw_upcalls_send(void) } } -/* - * Compute the timeout hash value for the bw_meter entries - */ -#define BW_METER_TIMEHASH(bw_meter, hash) \ - do { \ - struct timeval next_timeval = (bw_meter)->bm_start_time; \ - \ - BW_TIMEVALADD(&next_timeval, &(bw_meter)->bm_threshold.b_time); \ - (hash) = next_timeval.tv_sec; \ - if (next_timeval.tv_usec) \ - (hash)++; /* XXX: make sure we don't timeout early */ \ - (hash) %= BW_METER_BUCKETS; \ - } while (0) - -/* - * Schedule a timer to process periodically bw_meter entry of type "<=" - * by linking the entry in the proper hash bucket. - */ -static void -schedule_bw_meter(struct bw_meter *x, struct timeval *nowp) -{ - int time_hash; - - MFC_LOCK_ASSERT(); - - if (!(x->bm_flags & BW_METER_LEQ)) - return; /* XXX: we schedule timers only for "<=" entries */ - - /* - * Reset the bw_meter entry - */ - x->bm_start_time = *nowp; - x->bm_measured.b_packets = 0; - x->bm_measured.b_bytes = 0; - x->bm_flags &= ~BW_METER_UPCALL_DELIVERED; - - /* - * Compute the timeout hash value and insert the entry - */ - BW_METER_TIMEHASH(x, time_hash); - x->bm_time_next = V_bw_meter_timers[time_hash]; - V_bw_meter_timers[time_hash] = x; - x->bm_time_hash = time_hash; -} - -/* - * Unschedule the periodic timer that processes bw_meter entry of type "<=" - * by removing the entry from the proper hash bucket. - */ -static void -unschedule_bw_meter(struct bw_meter *x) -{ - int time_hash; - struct bw_meter *prev, *tmp; - - MFC_LOCK_ASSERT(); - - if (!(x->bm_flags & BW_METER_LEQ)) - return; /* XXX: we schedule timers only for "<=" entries */ - - /* - * Compute the timeout hash value and delete the entry - */ - time_hash = x->bm_time_hash; - if (time_hash >= BW_METER_BUCKETS) - return; /* Entry was not scheduled */ - - for (prev = NULL, tmp = V_bw_meter_timers[time_hash]; - tmp != NULL; prev = tmp, tmp = tmp->bm_time_next) - if (tmp == x) - break; - - if (tmp == NULL) - panic("unschedule_bw_meter: bw_meter entry not found"); - - if (prev != NULL) - prev->bm_time_next = x->bm_time_next; - else - V_bw_meter_timers[time_hash] = x->bm_time_next; - - x->bm_time_next = NULL; - x->bm_time_hash = BW_METER_BUCKETS; -} - -/* - * Process all "<=" type of bw_meter that should be processed now, - * and for each entry prepare an upcall if necessary. Each processed - * entry is rescheduled again for the (periodic) processing. - * - * This is run periodically (once per second normally). On each round, - * all the potentially matching entries are in the hash slot that we are - * looking at. - */ -static void -bw_meter_process() -{ - uint32_t loops; - int i; - struct timeval now, process_endtime; - - microtime(&now); - if (V_last_tv_sec == now.tv_sec) - return; /* nothing to do */ - - loops = now.tv_sec - V_last_tv_sec; - V_last_tv_sec = now.tv_sec; - if (loops > BW_METER_BUCKETS) - loops = BW_METER_BUCKETS; - - MFC_LOCK(); - /* - * Process all bins of bw_meter entries from the one after the last - * processed to the current one. On entry, i points to the last bucket - * visited, so we need to increment i at the beginning of the loop. - */ - for (i = (now.tv_sec - loops) % BW_METER_BUCKETS; loops > 0; loops--) { - struct bw_meter *x, *tmp_list; - - if (++i >= BW_METER_BUCKETS) - i = 0; - - /* Disconnect the list of bw_meter entries from the bin */ - tmp_list = V_bw_meter_timers[i]; - V_bw_meter_timers[i] = NULL; - - /* Process the list of bw_meter entries */ - while (tmp_list != NULL) { - x = tmp_list; - tmp_list = tmp_list->bm_time_next; - - /* Test if the time interval is over */ - process_endtime = x->bm_start_time; - BW_TIMEVALADD(&process_endtime, &x->bm_threshold.b_time); - if (BW_TIMEVALCMP(&process_endtime, &now, >)) { - /* Not yet: reschedule, but don't reset */ - int time_hash; - - BW_METER_TIMEHASH(x, time_hash); - if (time_hash == i && process_endtime.tv_sec == now.tv_sec) { - /* - * XXX: somehow the bin processing is a bit ahead of time. - * Put the entry in the next bin. - */ - if (++time_hash >= BW_METER_BUCKETS) - time_hash = 0; - } - x->bm_time_next = V_bw_meter_timers[time_hash]; - V_bw_meter_timers[time_hash] = x; - x->bm_time_hash = time_hash; - - continue; - } - - /* - * Test if we should deliver an upcall - */ - if (((x->bm_flags & BW_METER_UNIT_PACKETS) && - (x->bm_measured.b_packets <= x->bm_threshold.b_packets)) || - ((x->bm_flags & BW_METER_UNIT_BYTES) && - (x->bm_measured.b_bytes <= x->bm_threshold.b_bytes))) { - /* Prepare an upcall for delivery */ - bw_meter_prepare_upcall(x, &now); - } - - /* - * Reschedule for next processing - */ - schedule_bw_meter(x, &now); - } - } - - /* Send all upcalls that are pending delivery */ - bw_upcalls_send(); - - MFC_UNLOCK(); -} - /* * A periodic function for sending all upcalls that are pending delivery */ @@ -2297,23 +2132,6 @@ expire_bw_upcalls_send(void *arg) CURVNET_RESTORE(); } -/* - * A periodic function for periodic scanning of the multicast forwarding - * table for processing all "<=" bw_meter entries. - */ -static void -expire_bw_meter_process(void *arg) -{ - CURVNET_SET((struct vnet *) arg); - - if (V_mrt_api_config & MRT_MFC_BW_UPCALL) - bw_meter_process(); - - callout_reset(&V_bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, - curvnet); - CURVNET_RESTORE(); -} - /* * End of bandwidth monitoring code */ @@ -2835,14 +2653,11 @@ vnet_mroute_init(const void *unused __unused) V_viftable = mallocarray(MAXVIFS, sizeof(*V_viftable), M_MRTABLE, M_WAITOK|M_ZERO); - V_bw_meter_timers = mallocarray(BW_METER_BUCKETS, - sizeof(*V_bw_meter_timers), M_MRTABLE, M_WAITOK|M_ZERO); V_bw_upcalls = mallocarray(BW_UPCALLS_MAX, sizeof(*V_bw_upcalls), M_MRTABLE, M_WAITOK|M_ZERO); callout_init(&V_expire_upcalls_ch, 1); callout_init(&V_bw_upcalls_ch, 1); - callout_init(&V_bw_meter_ch, 1); } VNET_SYSINIT(vnet_mroute_init, SI_SUB_PROTO_MC, SI_ORDER_ANY, vnet_mroute_init, @@ -2853,7 +2668,6 @@ vnet_mroute_uninit(const void *unused __unused) { free(V_bw_upcalls, M_MRTABLE); - free(V_bw_meter_timers, M_MRTABLE); free(V_viftable, M_MRTABLE); free(V_nexpire, M_MRTABLE); V_nexpire = NULL; diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h index 6ef99c0172f3..2895ecc964d3 100644 --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -266,7 +266,7 @@ struct vif { u_long v_bytes_out; /* # bytes out on interface */ }; -#ifdef _KERNEL +#if defined(_KERNEL) || defined (_NETSTAT) /* * The kernel's multicast forwarding cache entry structure */ @@ -283,7 +283,10 @@ struct mfc { struct timeval mfc_last_assert; /* last time I sent an assert*/ uint8_t mfc_flags[MAXVIFS]; /* the MRT_MFC_FLAGS_* flags */ struct in_addr mfc_rp; /* the RP address */ - struct bw_meter *mfc_bw_meter; /* list of bandwidth meters */ + struct bw_meter *mfc_bw_meter_leq; /* list of bandwidth meters + for Lower-or-EQual case */ + struct bw_meter *mfc_bw_meter_geq; /* list of bandwidth meters + for Greater-or-EQual case */ u_long mfc_nstall; /* # of packets awaiting mfc */ TAILQ_HEAD(, rtdetq) mfc_stall; /* q of packets awaiting mfc */ }; @@ -327,7 +330,6 @@ struct rtdetq { struct bw_meter { struct bw_meter *bm_mfc_next; /* next bw meter (same mfc) */ struct bw_meter *bm_time_next; /* next bw meter (same time) */ - uint32_t bm_time_hash; /* the time hash value */ struct mfc *bm_mfc; /* the corresponding mfc */ uint32_t bm_flags; /* misc flags (see below) */ #define BW_METER_UNIT_PACKETS (1 << 0) /* threshold (in packets) */ @@ -344,6 +346,10 @@ struct bw_meter { struct bw_data bm_threshold; /* the upcall threshold */ struct bw_data bm_measured; /* the measured bw */ struct timeval bm_start_time; /* abs. time */ +#ifdef _KERNEL + struct callout bm_meter_callout; /* Periodic callout */ + void* arg; /* custom argument */ +#endif }; #ifdef _KERNEL diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 04b7ead03b7b..a7ce983d13a2 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -62,9 +62,9 @@ __FBSDID("$FreeBSD$"); #include #include -#define _KERNEL 1 +#define _NETSTAT 1 #include -#undef _KERNEL +#undef _NETSTAT_ #include #include @@ -213,7 +213,16 @@ print_mfc(struct mfc *m, int maxvif, int *banner_printed) * XXX We break the rules and try to use KVM to read the * bandwidth meters, they are not retrievable via sysctl yet. */ - bwm = m->mfc_bw_meter; + bwm = m->mfc_bw_meter_leq; + while (bwm != NULL) { + error = kread((u_long)bwm, (char *)&bw_meter, + sizeof(bw_meter)); + if (error) + break; + print_bw_meter(&bw_meter, &bw_banner_printed); + bwm = bw_meter.bm_mfc_next; + } + bwm = m->mfc_bw_meter_geq; while (bwm != NULL) { error = kread((u_long)bwm, (char *)&bw_meter, sizeof(bw_meter)); From owner-dev-commits-src-main@freebsd.org Fri May 21 06:01:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA7E5651C29; Fri, 21 May 2021 06:01: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 4FmbbW4W2jz4dDD; Fri, 21 May 2021 06:01: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 82FED422A; Fri, 21 May 2021 06:01: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 14L61xv2002793; Fri, 21 May 2021 06:01:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L61xQE002792; Fri, 21 May 2021 06:01:59 GMT (envelope-from git) Date: Fri, 21 May 2021 06:01:59 GMT Message-Id: <202105210601.14L61xQE002792@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: eedbbec3fd62 - main - ip_mroute: remove unused declarations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eedbbec3fd624aca13649351ca1526036d10d855 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 06:01:59 -0000 The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=eedbbec3fd624aca13649351ca1526036d10d855 commit eedbbec3fd624aca13649351ca1526036d10d855 Author: Wojciech Macek AuthorDate: 2021-05-21 06:01:26 +0000 Commit: Wojciech Macek CommitDate: 2021-05-21 06:01:26 +0000 ip_mroute: remove unused declarations fix build for non-x86 targets --- sys/netinet/ip_mroute.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 0cb980b7247e..5414b0e3da0e 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -126,9 +126,6 @@ __FBSDID("$FreeBSD$"); #define VIFI_INVALID ((vifi_t) -1) -VNET_DEFINE_STATIC(uint32_t, last_tv_sec); /* last time we processed this */ -#define V_last_tv_sec VNET(last_tv_sec) - static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast forwarding cache"); /* @@ -310,7 +307,6 @@ static int add_bw_upcall(struct bw_upcall *); static int add_mfc(struct mfcctl2 *); static int add_vif(struct vifctl *); static void bw_meter_prepare_upcall(struct bw_meter *, struct timeval *); -static void bw_meter_process(void); static void bw_meter_geq_receive_packet(struct bw_meter *, int, struct timeval *); static void bw_upcalls_send(void); @@ -338,13 +334,11 @@ static int pim_register_send_rp(struct ip *, struct vif *, struct mbuf *, struct mfc *); static int pim_register_send_upcall(struct ip *, struct vif *, struct mbuf *, struct mfc *); -static void schedule_bw_meter(struct bw_meter *, struct timeval *); static void send_packet(struct vif *, struct mbuf *); static int set_api_config(uint32_t *); static int set_assert(int); static int socket_send(struct socket *, struct mbuf *, struct sockaddr_in *); -static void unschedule_bw_meter(struct bw_meter *); /* * Kernel multicast forwarding API capabilities and setup. From owner-dev-commits-src-main@freebsd.org Fri May 21 06:26:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 39DAC651E34; Fri, 21 May 2021 06:26: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 4Fmc7g1168z4ngS; Fri, 21 May 2021 06:26: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 06CD648DF; Fri, 21 May 2021 06:26: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 14L6QM3M028852; Fri, 21 May 2021 06:26:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L6QMSF028851; Fri, 21 May 2021 06:26:22 GMT (envelope-from git) Date: Fri, 21 May 2021 06:26:22 GMT Message-Id: <202105210626.14L6QMSF028851@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 95c19e1d6561 - main - linux: refactor bsd_to_linux_regset() out of linux_ptrace.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 95c19e1d65619624db4a7a21afc1685f122a05c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 06:26:23 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=95c19e1d65619624db4a7a21afc1685f122a05c1 commit 95c19e1d65619624db4a7a21afc1685f122a05c1 Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 06:22:25 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 06:26:07 +0000 linux: refactor bsd_to_linux_regset() out of linux_ptrace.c This will be used for Linux coredump support. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30365 --- sys/amd64/linux/linux.h | 36 +++++++++++++++++++++++++++++ sys/amd64/linux/linux_ptrace.c | 46 ++++++------------------------------- sys/amd64/linux32/linux.h | 26 +++++++++++++++++++++ sys/amd64/linux32/linux32_machdep.c | 24 +++++++++++++++++++ 4 files changed, 93 insertions(+), 39 deletions(-) diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h index dc4986817d11..4e27fd51a72d 100644 --- a/sys/amd64/linux/linux.h +++ b/sys/amd64/linux/linux.h @@ -446,4 +446,40 @@ struct linux_robust_list_head { l_uintptr_t pending_list; }; +/* This corresponds to 'struct user_regs_struct' in Linux. */ +struct linux_pt_regset { + l_ulong r15; + l_ulong r14; + l_ulong r13; + l_ulong r12; + l_ulong rbp; + l_ulong rbx; + l_ulong r11; + l_ulong r10; + l_ulong r9; + l_ulong r8; + l_ulong rax; + l_ulong rcx; + l_ulong rdx; + l_ulong rsi; + l_ulong rdi; + l_ulong orig_rax; + l_ulong rip; + l_ulong cs; + l_ulong eflags; + l_ulong rsp; + l_ulong ss; + l_ulong fs_base; + l_ulong gs_base; + l_ulong ds; + l_ulong es; + l_ulong fs; + l_ulong gs; +}; + +struct reg; + +void bsd_to_linux_regset(struct reg *b_reg, + struct linux_pt_regset *l_regset); + #endif /* !_AMD64_LINUX_H_ */ diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 43ecd8892e0f..32d736d49095 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -173,36 +173,6 @@ struct linux_pt_reg { l_ulong ss; }; -struct linux_pt_regset { - l_ulong r15; - l_ulong r14; - l_ulong r13; - l_ulong r12; - l_ulong rbp; - l_ulong rbx; - l_ulong r11; - l_ulong r10; - l_ulong r9; - l_ulong r8; - l_ulong rax; - l_ulong rcx; - l_ulong rdx; - l_ulong rsi; - l_ulong rdi; - l_ulong orig_rax; - l_ulong rip; - l_ulong cs; - l_ulong eflags; - l_ulong rsp; - l_ulong ss; - l_ulong fs_base; - l_ulong gs_base; - l_ulong ds; - l_ulong es; - l_ulong fs; - l_ulong gs; -}; - /* * Translate amd64 ptrace registers between Linux and FreeBSD formats. * The translation is pretty straighforward, for all registers but @@ -235,9 +205,8 @@ map_regs_to_linux(struct reg *b_reg, struct linux_pt_reg *l_reg) l_reg->ss = b_reg->r_ss; } -static void -map_regs_to_linux_regset(struct reg *b_reg, unsigned long fs_base, - unsigned long gs_base, struct linux_pt_regset *l_regset) +void +bsd_to_linux_regset(struct reg *b_reg, struct linux_pt_regset *l_regset) { l_regset->r15 = b_reg->r_r15; @@ -261,8 +230,8 @@ map_regs_to_linux_regset(struct reg *b_reg, unsigned long fs_base, l_regset->eflags = b_reg->r_rflags; l_regset->rsp = b_reg->r_rsp; l_regset->ss = b_reg->r_ss; - l_regset->fs_base = fs_base; - l_regset->gs_base = gs_base; + l_regset->fs_base = 0; + l_regset->gs_base = 0; l_regset->ds = b_reg->r_ds; l_regset->es = b_reg->r_es; l_regset->fs = b_reg->r_fs; @@ -477,7 +446,6 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) struct linux_pt_regset l_regset; struct iovec iov; struct pcb *pcb; - unsigned long fsbase, gsbase; size_t len; int error; @@ -494,10 +462,10 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) pcb = td->td_pcb; if (td == curthread) update_pcb_bases(pcb); - fsbase = pcb->pcb_fsbase; - gsbase = pcb->pcb_gsbase; - map_regs_to_linux_regset(&b_reg, fsbase, gsbase, &l_regset); + bsd_to_linux_regset(&b_reg, &l_regset); + l_regset.fs_base = pcb->pcb_fsbase; + l_regset.gs_base = pcb->pcb_gsbase; error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo)); if (error != 0) { diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 244daba4b5c0..286b9b52801c 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -630,4 +630,30 @@ struct linux_robust_list_head { l_uintptr_t pending_list; }; +/* This corresponds to 'struct user_regs_struct32' in Linux. */ +struct linux_pt_regset32 { + l_uint ebx; + l_uint ecx; + l_uint edx; + l_uint esi; + l_uint edi; + l_uint ebp; + l_uint eax; + l_uint ds; + l_uint es; + l_uint fs; + l_uint gs; + l_uint orig_eax; + l_uint eip; + l_uint cs; + l_uint eflags; + l_uint esp; + l_uint ss; +}; + +struct reg32; + +void bsd_to_linux_regset32(struct reg32 *b_reg, + struct linux_pt_regset32 *l_regset); + #endif /* !_AMD64_LINUX_H_ */ diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index 8ae82f3df8ca..880cccbb2328 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -721,6 +722,29 @@ linux_set_thread_area(struct thread *td, return (0); } +void +bsd_to_linux_regset32(struct reg32 *b_reg, struct linux_pt_regset32 *l_regset) +{ + + l_regset->ebx = b_reg->r_ebx; + l_regset->ecx = b_reg->r_ecx; + l_regset->edx = b_reg->r_edx; + l_regset->esi = b_reg->r_esi; + l_regset->edi = b_reg->r_edi; + l_regset->ebp = b_reg->r_ebp; + l_regset->eax = b_reg->r_eax; + l_regset->ds = b_reg->r_ds; + l_regset->es = b_reg->r_es; + l_regset->fs = b_reg->r_fs; + l_regset->gs = b_reg->r_gs; + l_regset->orig_eax = b_reg->r_eax; + l_regset->eip = b_reg->r_eip; + l_regset->cs = b_reg->r_cs; + l_regset->eflags = b_reg->r_eflags; + l_regset->esp = b_reg->r_esp; + l_regset->ss = b_reg->r_ss; +} + int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval); int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval); DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *)) From owner-dev-commits-src-main@freebsd.org Fri May 21 06:38:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8603652551; Fri, 21 May 2021 06:38: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 4FmcPg5nLwz4sS5; Fri, 21 May 2021 06:38: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 AEBD2476B; Fri, 21 May 2021 06:38: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 14L6cVAN043266; Fri, 21 May 2021 06:38:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L6cVh3043265; Fri, 21 May 2021 06:38:31 GMT (envelope-from git) Date: Fri, 21 May 2021 06:38:31 GMT Message-Id: <202105210638.14L6cVh3043265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: d39aac796bd2 - main - pms(4): clear CCBs allocated on the stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d39aac796bd20692919223b1bbec6ce6b2779e1a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 06:38:31 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=d39aac796bd20692919223b1bbec6ce6b2779e1a commit d39aac796bd20692919223b1bbec6ce6b2779e1a Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 06:28:46 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 06:29:23 +0000 pms(4): clear CCBs allocated on the stack Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30300 --- sys/dev/pms/freebsd/driver/ini/src/agtiapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c b/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c index a2b20c9e9264..a4efec572864 100644 --- a/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c +++ b/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c @@ -470,6 +470,7 @@ int agtiapi_getCardInfo ( struct agtiapi_softc *pCard, void agtiapi_adjust_queue_depth(struct cam_path *path, bit32 QueueDepth) { struct ccb_relsim crs; + memset(&crs, 0, sizeof(crs)); xpt_setup_ccb(&crs.ccb_h, path, 5); crs.ccb_h.func_code = XPT_REL_SIMQ; crs.ccb_h.flags = CAM_DEV_QFREEZE; @@ -929,6 +930,7 @@ static int agtiapi_attach( device_t devx ) return( EIO ); } pmsc->path = ccb->ccb_h.path; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, pmsc->path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_FOUND_DEVICE; @@ -6545,6 +6547,7 @@ int agtiapi_ReleaseHBA( device_t dev ) if (pCard->sim != NULL) { mtx_lock(&thisCardInst->pmIOLock); + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, pCard->path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = 0; From owner-dev-commits-src-main@freebsd.org Fri May 21 06:58:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C4401652777; Fri, 21 May 2021 06:58: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 4Fmcrc59L4z50Th; Fri, 21 May 2021 06:58: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 933D54D95; Fri, 21 May 2021 06:58: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 14L6wOeF070554; Fri, 21 May 2021 06:58:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L6wOP6070553; Fri, 21 May 2021 06:58:24 GMT (envelope-from git) Date: Fri, 21 May 2021 06:58:24 GMT Message-Id: <202105210658.14L6wOP6070553@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 7608b98c4394 - main - mpr, mps: clear CCBs allocated on the stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7608b98c4394590840a53d2b38b908582253de32 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 06:58:24 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=7608b98c4394590840a53d2b38b908582253de32 commit 7608b98c4394590840a53d2b38b908582253de32 Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 06:42:08 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 06:42:13 +0000 mpr, mps: clear CCBs allocated on the stack Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30301 --- sys/dev/mpr/mpr_sas.c | 1 + sys/dev/mps/mps_sas.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c index a60881553f01..7c6bc110069a 100644 --- a/sys/dev/mpr/mpr_sas.c +++ b/sys/dev/mpr/mpr_sas.c @@ -3358,6 +3358,7 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path, } bzero(&rcap_buf, sizeof(rcap_buf)); + bzero(&cdai, sizeof(cdai)); xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL); cdai.ccb_h.func_code = XPT_DEV_ADVINFO; cdai.ccb_h.flags = CAM_DIR_IN; diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c index 97160a40ce08..e961b3fd826c 100644 --- a/sys/dev/mps/mps_sas.c +++ b/sys/dev/mps/mps_sas.c @@ -3204,6 +3204,7 @@ mpssas_async(void *callback_arg, uint32_t code, struct cam_path *path, } bzero(&rcap_buf, sizeof(rcap_buf)); + bzero(&cdai, sizeof(cdai)); xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL); cdai.ccb_h.func_code = XPT_DEV_ADVINFO; cdai.ccb_h.flags = CAM_DIR_IN; From owner-dev-commits-src-main@freebsd.org Fri May 21 07:03:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC494652D2F; Fri, 21 May 2021 07:03:53 +0000 (UTC) (envelope-from se@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmcyx49gQz53r3; Fri, 21 May 2021 07:03:53 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MBP-449.fritz.box (p200300cd5f135c00cd477658b2baa9e2.dip0.t-ipconnect.de [IPv6:2003:cd:5f13:5c00:cd47:7658:b2ba:a9e2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id DF82A1AF3; Fri, 21 May 2021 07:03:50 +0000 (UTC) (envelope-from se@freebsd.org) To: Joe Clarke , Benjamin Kaduk , Zhenlei Huang Cc: "Rodney W. Grimes" , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> From: Stefan Esser Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses Message-ID: <1c001c3f-191e-c761-0eb4-ff78171af580@freebsd.org> Date: Fri, 21 May 2021 09:03:46 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="j1LGn9wI3ZymfDQKB09AngNlOVIbFtVyC" X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 07:03:53 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --j1LGn9wI3ZymfDQKB09AngNlOVIbFtVyC Content-Type: multipart/mixed; boundary="DF8bNBci5TbMCjIAIqDsY7evhLh1k4PBa"; protected-headers="v1" From: Stefan Esser To: Joe Clarke , Benjamin Kaduk , Zhenlei Huang Cc: "Rodney W. Grimes" , Lutz Donnerhacke , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Message-ID: <1c001c3f-191e-c761-0eb4-ff78171af580@freebsd.org> Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> In-Reply-To: <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> --DF8bNBci5TbMCjIAIqDsY7evhLh1k4PBa Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Am 20.05.21 um 15:07 schrieb Joe Clarke: > On 5/19/21 22:39, Benjamin Kaduk wrote: >> Sorry, RFCs themselves do not change -- one of the distinctive feature= s of >> RFCs is precisely that they are immutable once published. >> The sentiment that what the current RFC for a given topic is, can chan= ge, is >> something that I can agree with, but that's not quite what was being >> discussed. >=20 > Agreed, which is why I say the reference still has value and one can us= e > it as a basis to follow the errata and newer docs. That said, I've > expressed my desire to leave the reference in, and I'll leave it at > that. I didn't think this would be that controversial. And, adding to that: if somebody works on a code fragment with reference to an RFC that has been replaced by a newer one known by the committer, then updating that reference might be considered a service for future readers of that code ... Regards, STefan --DF8bNBci5TbMCjIAIqDsY7evhLh1k4PBa-- --j1LGn9wI3ZymfDQKB09AngNlOVIbFtVyC Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEo3HqZZwL7MgrcVMTR+u171r99UQFAmCnW1MFAwAAAAAACgkQR+u171r99UT6 DAf/TAe2xt6ykdkb2BJ9ErhKYUt0J0GT6CgAt056HGa4Cebe5WtXc6QmLJCo3bYFJ++kfcRlN8HN jgRFjSWqNZ88vj6WCfDDKBnkifG7R3yzKSFJPOSMhBcC9JwkQGJPxzNF9poxHkD2hN0iDdP8OSuh pdjG2OCS5EABrXwrtInDOMsEnVcY9manGuZV66RPF2Qpw3nNEkqo3ubGCJLhMqY/tRvVEZ4KVOr7 /xXJ5d21Vmcz6i3EGwZ5wsoTkVc1XJs/n9OUjXc9Zl1hL22CL2yiVmUYQ96k3Rh9Fh9UGoubatEm w+J3gAa6KOP3Wom+TTCiltaMI7dIQdg8idZkhjD12w== =vVOq -----END PGP SIGNATURE----- --j1LGn9wI3ZymfDQKB09AngNlOVIbFtVyC-- From owner-dev-commits-src-main@freebsd.org Fri May 21 07:09:34 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7D5D2652DA1; Fri, 21 May 2021 07:09:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmd5V365Bz55Cb; Fri, 21 May 2021 07:09:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4F8624AF8; Fri, 21 May 2021 07:09:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14L79YIa084908; Fri, 21 May 2021 07:09:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L79YKu084907; Fri, 21 May 2021 07:09:34 GMT (envelope-from git) Date: Fri, 21 May 2021 07:09:34 GMT Message-Id: <202105210709.14L79YKu084907@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: de992eed7818 - main - mpt: clear CCBs allocated on the stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: de992eed7818d49c027cdecabdfb8224a24bcac0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 07:09:34 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=de992eed7818d49c027cdecabdfb8224a24bcac0 commit de992eed7818d49c027cdecabdfb8224a24bcac0 Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 06:58:49 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 06:59:02 +0000 mpt: clear CCBs allocated on the stack Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30302 --- sys/dev/mpt/mpt_cam.c | 1 + sys/dev/mpt/mpt_raid.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index 64776d673674..54bdc22759fa 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -2448,6 +2448,7 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req, "XPT_REL_SIMQ"); break; } + memset(&crs, 0, sizeof(crs)); xpt_setup_ccb(&crs.ccb_h, tmppath, 5); crs.ccb_h.func_code = XPT_REL_SIMQ; crs.ccb_h.flags = CAM_DEV_QFREEZE; diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index 28667d85cf4d..603c2b42a370 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -296,6 +296,7 @@ mpt_raid_attach(struct mpt_softc *mpt) goto cleanup; } + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, mpt->path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_FOUND_DEVICE; @@ -336,6 +337,7 @@ mpt_raid_detach(struct mpt_softc *mpt) handler.reply_handler = mpt_raid_reply_handler; mpt_deregister_handler(mpt, MPT_HANDLER_REPLY, handler, raid_handler_id); + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, mpt->path, /*priority*/5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = 0; @@ -1071,6 +1073,7 @@ mpt_adjust_queue_depth(struct mpt_softc *mpt, struct mpt_raid_volume *mpt_vol, { struct ccb_relsim crs; + memset(&crs, 0, sizeof(crs)); xpt_setup_ccb(&crs.ccb_h, path, /*priority*/5); crs.ccb_h.func_code = XPT_REL_SIMQ; crs.ccb_h.flags = CAM_DEV_QFREEZE; From owner-dev-commits-src-main@freebsd.org Fri May 21 07:21:02 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0B1C65321B; Fri, 21 May 2021 07:21: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 4FmdLk4f1wz3CFk; Fri, 21 May 2021 07:21: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 86FA250B3; Fri, 21 May 2021 07:21: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 14L7L270010174; Fri, 21 May 2021 07:21:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L7L21L010173; Fri, 21 May 2021 07:21:02 GMT (envelope-from git) Date: Fri, 21 May 2021 07:21:02 GMT Message-Id: <202105210721.14L7L21L010173@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: b9353e0b44a3 - main - isci: clear CCBs allocated on the stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9353e0b44a360dc8d45b640514aa8276b991289 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 07:21:02 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=b9353e0b44a360dc8d45b640514aa8276b991289 commit b9353e0b44a360dc8d45b640514aa8276b991289 Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 07:10:15 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 07:10:22 +0000 isci: clear CCBs allocated on the stack Reviewed By: gallatin, imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30303 --- sys/dev/isci/isci_io_request.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/isci/isci_io_request.c b/sys/dev/isci/isci_io_request.c index 711f5757ee5e..8d8d84b5b855 100644 --- a/sys/dev/isci/isci_io_request.c +++ b/sys/dev/isci/isci_io_request.c @@ -186,6 +186,7 @@ isci_io_request_complete(SCI_CONTROLLER_HANDLE_T scif_controller, cam_sim_path(isci_controller->sim), isci_remote_device->index, 0); + memset(&ccb_relsim, 0, sizeof(ccb_relsim)); xpt_setup_ccb(&ccb_relsim.ccb_h, path, 5); ccb_relsim.ccb_h.func_code = XPT_REL_SIMQ; ccb_relsim.ccb_h.flags = CAM_DEV_QFREEZE; From owner-dev-commits-src-main@freebsd.org Fri May 21 07:47:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B4566533B3; Fri, 21 May 2021 07:47: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 4FmdxX0K8dz3QYd; Fri, 21 May 2021 07:47: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 E6FB5524C; Fri, 21 May 2021 07:47: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 14L7lhl6037990; Fri, 21 May 2021 07:47:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L7lhmi037989; Fri, 21 May 2021 07:47:43 GMT (envelope-from git) Date: Fri, 21 May 2021 07:47:43 GMT Message-Id: <202105210747.14L7lhmi037989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 45f57ce1224b - main - arcmsr: clear CCB allocated on the stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45f57ce1224b5fdf05c0c68aee4d134436e0efba Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 07:47:44 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=45f57ce1224b5fdf05c0c68aee4d134436e0efba commit 45f57ce1224b5fdf05c0c68aee4d134436e0efba Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 07:21:45 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 07:22:13 +0000 arcmsr: clear CCB allocated on the stack Reviewed By: delphij, imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30304 --- sys/dev/arcmsr/arcmsr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c index f7f913de89af..31d12f0ffd40 100644 --- a/sys/dev/arcmsr/arcmsr.c +++ b/sys/dev/arcmsr/arcmsr.c @@ -4957,6 +4957,7 @@ irqx: /* **************************************************** */ + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, acb->ppath, /*priority*/5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_FOUND_DEVICE|AC_LOST_DEVICE; From owner-dev-commits-src-main@freebsd.org Fri May 21 07:57:06 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7AAD653A91; Fri, 21 May 2021 07:57: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 4Fmf8L4kFzz3m3r; Fri, 21 May 2021 07:57: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 7E1D855C7; Fri, 21 May 2021 07:57: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 14L7v6pZ051819; Fri, 21 May 2021 07:57:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L7v6MU051818; Fri, 21 May 2021 07:57:06 GMT (envelope-from git) Date: Fri, 21 May 2021 07:57:06 GMT Message-Id: <202105210757.14L7v6MU051818@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 8dc96b74edb8 - main - cam: clear on-stack CCBs in last few drivers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8dc96b74edb844bb621afeba38fe4af104b13120 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 07:57:07 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=8dc96b74edb844bb621afeba38fe4af104b13120 commit 8dc96b74edb844bb621afeba38fe4af104b13120 Author: Edward Tomasz Napierala AuthorDate: 2021-05-21 07:48:27 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-21 07:53:59 +0000 cam: clear on-stack CCBs in last few drivers This changes ahc(4), ahd(4), hptiop(4), hptnr(4), hptrr(4), and ps3cdrom(4). Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30305 --- sys/dev/aic7xxx/aic79xx_osm.c | 1 + sys/dev/aic7xxx/aic7xxx_osm.c | 1 + sys/dev/hpt27xx/hpt27xx_osm_bsd.c | 1 + sys/dev/hptiop/hptiop.c | 2 ++ sys/dev/hptnr/hptnr_osm_bsd.c | 1 + sys/dev/hptrr/hptrr_osm_bsd.c | 1 + sys/powerpc/ps3/ps3cdrom.c | 1 + 7 files changed, 8 insertions(+) diff --git a/sys/dev/aic7xxx/aic79xx_osm.c b/sys/dev/aic7xxx/aic79xx_osm.c index 31750eced9c5..16d39f43a2cc 100644 --- a/sys/dev/aic7xxx/aic79xx_osm.c +++ b/sys/dev/aic7xxx/aic79xx_osm.c @@ -267,6 +267,7 @@ ahd_attach(struct ahd_softc *ahd) goto fail; } + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, path, /*priority*/5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE; diff --git a/sys/dev/aic7xxx/aic7xxx_osm.c b/sys/dev/aic7xxx/aic7xxx_osm.c index 81059a281fba..de679ec210a1 100644 --- a/sys/dev/aic7xxx/aic7xxx_osm.c +++ b/sys/dev/aic7xxx/aic7xxx_osm.c @@ -215,6 +215,7 @@ ahc_attach(struct ahc_softc *ahc) goto fail; } + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, path, /*priority*/5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE; diff --git a/sys/dev/hpt27xx/hpt27xx_osm_bsd.c b/sys/dev/hpt27xx/hpt27xx_osm_bsd.c index aa7c14e68d88..9a5a27482fab 100644 --- a/sys/dev/hpt27xx/hpt27xx_osm_bsd.c +++ b/sys/dev/hpt27xx/hpt27xx_osm_bsd.c @@ -1252,6 +1252,7 @@ static void hpt_final_init(void *dummy) return ; } + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, vbus_ext->path, /*priority*/5); ccb.ccb_h.func_code = XPT_SASYNC_CB; ccb.event_enable = AC_LOST_DEVICE; diff --git a/sys/dev/hptiop/hptiop.c b/sys/dev/hptiop/hptiop.c index 50d26231a91c..c5ac59f31df5 100644 --- a/sys/dev/hptiop/hptiop.c +++ b/sys/dev/hptiop/hptiop.c @@ -2046,6 +2046,7 @@ static int hptiop_attach(device_t dev) goto free_hba_path; } + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, hba->path, /*priority*/5); ccb.ccb_h.func_code = XPT_SASYNC_CB; ccb.event_enable = (AC_FOUND_DEVICE | AC_LOST_DEVICE); @@ -2797,6 +2798,7 @@ static void hptiop_release_resource(struct hpt_iop_hba *hba) if (hba->path) { struct ccb_setasync ccb; + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, hba->path, /*priority*/5); ccb.ccb_h.func_code = XPT_SASYNC_CB; ccb.event_enable = 0; diff --git a/sys/dev/hptnr/hptnr_osm_bsd.c b/sys/dev/hptnr/hptnr_osm_bsd.c index 8afd3e22d2e8..2fe5c43d8b09 100644 --- a/sys/dev/hptnr/hptnr_osm_bsd.c +++ b/sys/dev/hptnr/hptnr_osm_bsd.c @@ -1438,6 +1438,7 @@ static void hpt_final_init(void *dummy) } hpt_unlock_vbus(vbus_ext); + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, vbus_ext->path, /*priority*/5); ccb.ccb_h.func_code = XPT_SASYNC_CB; ccb.event_enable = AC_LOST_DEVICE; diff --git a/sys/dev/hptrr/hptrr_osm_bsd.c b/sys/dev/hptrr/hptrr_osm_bsd.c index 3fc13f65a984..5dc9680e5cc8 100644 --- a/sys/dev/hptrr/hptrr_osm_bsd.c +++ b/sys/dev/hptrr/hptrr_osm_bsd.c @@ -1086,6 +1086,7 @@ static void hpt_final_init(void *dummy) } hpt_unlock_vbus(vbus_ext); + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, vbus_ext->path, /*priority*/5); ccb.ccb_h.func_code = XPT_SASYNC_CB; ccb.event_enable = AC_LOST_DEVICE; diff --git a/sys/powerpc/ps3/ps3cdrom.c b/sys/powerpc/ps3/ps3cdrom.c index 776f52d4db7b..2f9b193e9af4 100644 --- a/sys/powerpc/ps3/ps3cdrom.c +++ b/sys/powerpc/ps3/ps3cdrom.c @@ -262,6 +262,7 @@ ps3cdrom_attach(device_t dev) goto fail_unregister_xpt_bus; } + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->sc_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE; From owner-dev-commits-src-main@freebsd.org Fri May 21 08:31:36 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D0A63654635; Fri, 21 May 2021 08:31: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 4Fmfw85JDKz4WQB; Fri, 21 May 2021 08:31: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 9DBD96129; Fri, 21 May 2021 08:31: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 14L8VajN000642; Fri, 21 May 2021 08:31:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L8Va9P000641; Fri, 21 May 2021 08:31:36 GMT (envelope-from git) Date: Fri, 21 May 2021 08:31:36 GMT Message-Id: <202105210831.14L8Va9P000641@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 500eb6dd8040 - main - tcp: Fix sending of TCP segments with IP level options MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 500eb6dd80404ea512e31a8f795c73cb802c9c64 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 08:31:36 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=500eb6dd80404ea512e31a8f795c73cb802c9c64 commit 500eb6dd80404ea512e31a8f795c73cb802c9c64 Author: Michael Tuexen AuthorDate: 2021-05-21 07:45:00 +0000 Commit: Michael Tuexen CommitDate: 2021-05-21 07:49:45 +0000 tcp: Fix sending of TCP segments with IP level options When bringing in TCP over UDP support in https://cgit.FreeBSD.org/src/commit/?id=9e644c23000c2f5028b235f6263d17ffb24d3605, the length of IP level options was considered when locating the transport header. This was incorrect and is fixed by this patch. X-MFC with: https://cgit.FreeBSD.org/src/commit/?id=9e644c23000c2f5028b235f6263d17ffb24d3605 MFC after: 3 days Reviewed by: markj, rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D30358 --- sys/netinet/tcp_output.c | 4 ++-- sys/netinet/tcp_stacks/bbr.c | 4 ++-- sys/netinet/tcp_stacks/rack.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 20b9c0371122..93c376f81f1a 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1154,7 +1154,7 @@ send: if (isipv6) { ip6 = mtod(m, struct ip6_hdr *); if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip6 + ipoptlen + sizeof(struct ip6_hdr)); + udp = (struct udphdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip6_hdr); @@ -1172,7 +1172,7 @@ send: ipov = (struct ipovly *)ip; #endif if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip + ipoptlen + sizeof(struct ip)); + udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip); diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index af6c9462c8e0..22762d21c289 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -13354,7 +13354,7 @@ send: if (isipv6) { ip6 = mtod(m, struct ip6_hdr *); if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip6 + ipoptlen + sizeof(struct ip6_hdr)); + udp = (struct udphdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip6_hdr); @@ -13372,7 +13372,7 @@ send: ipov = (struct ipovly *)ip; #endif if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip + ipoptlen + sizeof(struct ip)); + udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip); diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index c4f3be02dd29..73b47745cbac 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -17658,7 +17658,7 @@ send: if (isipv6) { ip6 = mtod(m, struct ip6_hdr *); if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip6 + ipoptlen + sizeof(struct ip6_hdr)); + udp = (struct udphdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip6_hdr); @@ -17675,7 +17675,7 @@ send: ipov = (struct ipovly *)ip; #endif if (tp->t_port) { - udp = (struct udphdr *)((caddr_t)ip + ipoptlen + sizeof(struct ip)); + udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip)); udp->uh_sport = htons(V_tcp_udp_tunneling_port); udp->uh_dport = tp->t_port; ulen = hdrlen + len - sizeof(struct ip); From owner-dev-commits-src-main@freebsd.org Fri May 21 08:40:05 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 508BD654678; Fri, 21 May 2021 08:40:05 +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 4Fmg5x0gVdz4Z9q; Fri, 21 May 2021 08:40:04 +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 14L8dqon025351 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 21 May 2021 10:39:53 +0200 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 14L8dqMc022913; Fri, 21 May 2021 10:39:52 +0200 Date: Fri, 21 May 2021 10:39:52 +0200 From: Lutz Donnerhacke To: Stefan Esser Cc: Joe Clarke , Benjamin Kaduk , Zhenlei Huang , "Rodney W. Grimes" , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 3d846e48227e - main - Do not forward datagrams originated by link-local addresses Message-ID: <20210521083952.GA22854@belenus.iks-jena.de> References: <202105182101.14IL1Gki054229@gitrepo.freebsd.org> <20210519055407.GA9715@belenus.iks-jena.de> <10b475c5-0100-2567-4e92-73b168b97e3f@marcuscom.com> <1DD8ABB9-94B1-4B44-8003-25432A91D520@gmail.com> <5cee6177-8b75-382e-cd3a-403397de0190@marcuscom.com> <1c001c3f-191e-c761-0eb4-ff78171af580@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c001c3f-191e-c761-0eb4-ff78171af580@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: 4Fmg5x0gVdz4Z9q X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 08:40:05 -0000 On Fri, May 21, 2021 at 09:03:46AM +0200, Stefan Esser wrote: > Am 20.05.21 um 15:07 schrieb Joe Clarke: > > On 5/19/21 22:39, Benjamin Kaduk wrote: > >> Sorry, RFCs themselves do not change -- one of the distinctive features of > >> RFCs is precisely that they are immutable once published. > >> The sentiment that what the current RFC for a given topic is, can change, is > >> something that I can agree with, but that's not quite what was being > >> discussed. > > > > Agreed, which is why I say the reference still has value and one can use > > it as a basis to follow the errata and newer docs. That said, I've > > expressed my desire to leave the reference in, and I'll leave it at > > that. I didn't think this would be that controversial. > > And, adding to that: if somebody works on a code fragment with reference > to an RFC that has been replaced by a newer one known by the committer, > then updating that reference might be considered a service for future > readers of that code ... May I point you all to https://reviews.freebsd.org/D30374 and ask for comment there? From owner-dev-commits-src-main@freebsd.org Fri May 21 09:08:42 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F5C86554B4; Fri, 21 May 2021 09:08: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 4Fmgkx5Jkdz4nTB; Fri, 21 May 2021 09:08: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 9E1CA6840; Fri, 21 May 2021 09:08: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 14L98fXA045093; Fri, 21 May 2021 09:08:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L98fTa045092; Fri, 21 May 2021 09:08:41 GMT (envelope-from git) Date: Fri, 21 May 2021 09:08:41 GMT Message-Id: <202105210908.14L98fTa045092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 032bf749fd44 - main - [tcp] Keep socket buffer locked until upcall MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 032bf749fd44ac5ff20aab2c3d8e3c05491778ea Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:08:42 -0000 The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=032bf749fd44ac5ff20aab2c3d8e3c05491778ea commit 032bf749fd44ac5ff20aab2c3d8e3c05491778ea Author: Richard Scheffenegger AuthorDate: 2021-05-21 09:00:53 +0000 Commit: Richard Scheffenegger CommitDate: 2021-05-21 09:07:51 +0000 [tcp] Keep socket buffer locked until upcall r367492 would unlock the socket buffer before eventually calling the upcall. This leads to problematic interaction with NFS kernel server/client components (MP threads) accessing the socket buffer with potentially not correctly updated state. Reported by: rmacklem Reviewed By: tuexen, #transport Tested by: rmacklem, otis MFC after: 2 weeks Sponsored By: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29690 --- sys/netinet/tcp_input.c | 38 ++++++++++++++------------------ sys/netinet/tcp_reass.c | 2 -- sys/netinet/tcp_stacks/bbr.c | 20 ++++++++--------- sys/netinet/tcp_stacks/rack.c | 20 ++++++++--------- sys/netinet/tcp_stacks/rack_bbr_common.c | 1 - sys/netinet/tcp_var.h | 2 +- 6 files changed, 37 insertions(+), 46 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 49db8cc63cb3..18ef52959c15 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1509,18 +1509,17 @@ tcp_handle_wakeup(struct tcpcb *tp, struct socket *so) * the TIME_WAIT state before coming here, we need * to check if the socket is still connected. */ - if ((so->so_state & SS_ISCONNECTED) == 0) + if (tp == NULL) { return; + } + if (so == NULL) { + return; + } INP_LOCK_ASSERT(tp->t_inpcb); if (tp->t_flags & TF_WAKESOR) { tp->t_flags &= ~TF_WAKESOR; - SOCKBUF_UNLOCK_ASSERT(&so->so_rcv); - sorwakeup(so); - } - if (tp->t_flags & TF_WAKESOW) { - tp->t_flags &= ~TF_WAKESOW; - SOCKBUF_UNLOCK_ASSERT(&so->so_snd); - sowwakeup(so); + SOCKBUF_LOCK_ASSERT(&so->so_rcv); + sorwakeup_locked(so); } } @@ -1898,7 +1897,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, else if (!tcp_timer_active(tp, TT_PERSIST)) tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur); - tp->t_flags |= TF_WAKESOW; + sowwakeup(so); if (sbavail(&so->so_snd)) (void) tp->t_fb->tfb_tcp_output(tp); goto check_delack; @@ -1963,8 +1962,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, m_adj(m, drop_hdrlen); /* delayed header drop */ sbappendstream_locked(&so->so_rcv, m, 0); } - SOCKBUF_UNLOCK(&so->so_rcv); - tp->t_flags |= TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); if (DELAY_ACK(tp, tlen)) { tp->t_flags |= TF_DELACK; } else { @@ -2502,9 +2501,11 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, * If segment contains data or ACK, will call tcp_reass() * later; if not, do so now to pass queued data to user. */ - if (tlen == 0 && (thflags & TH_FIN) == 0) + if (tlen == 0 && (thflags & TH_FIN) == 0) { (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); + tcp_handle_wakeup(tp, so); + } tp->snd_wl1 = th->th_seq - 1; /* FALLTHROUGH */ @@ -2959,8 +2960,8 @@ process_ACK: tp->snd_wnd = 0; ourfinisacked = 0; } - SOCKBUF_UNLOCK(&so->so_snd); - tp->t_flags |= TF_WAKESOW; + /* NB: sowwakeup_locked() does an implicit unlock. */ + sowwakeup_locked(so); m_freem(mfree); /* Detect una wraparound. */ if (!IN_RECOVERY(tp->t_flags) && @@ -3181,7 +3182,6 @@ dodata: /* XXX */ m_freem(m); else sbappendstream_locked(&so->so_rcv, m, 0); - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; } else { /* @@ -3227,6 +3227,7 @@ dodata: /* XXX */ save_start + tlen); } } + tcp_handle_wakeup(tp, so); #if 0 /* * Note the amount of data that peer has sent into @@ -3250,9 +3251,8 @@ dodata: /* XXX */ */ if (thflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { - socantrcvmore(so); /* The socket upcall is handled by socantrcvmore. */ - tp->t_flags &= ~TF_WAKESOR; + socantrcvmore(so); /* * If connection is half-synchronized * (ie NEEDSYN flag on) then delay ACK, @@ -3316,7 +3316,6 @@ check_delack: tp->t_flags &= ~TF_DELACK; tcp_timer_activate(tp, TT_DELACK, tcp_delacktime); } - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); return; @@ -3350,7 +3349,6 @@ dropafterack: TCP_PROBE3(debug__input, tp, th, m); tp->t_flags |= TF_ACKNOW; (void) tp->t_fb->tfb_tcp_output(tp); - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); m_freem(m); return; @@ -3358,7 +3356,6 @@ dropafterack: dropwithreset: if (tp != NULL) { tcp_dropwithreset(m, th, tp, tlen, rstreason); - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); @@ -3375,7 +3372,6 @@ drop: #endif TCP_PROBE3(debug__input, tp, th, m); if (tp != NULL) { - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); } m_freem(m); diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 310d7d540507..8e24e7412473 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -959,7 +959,6 @@ new_entry: } else { sbappendstream_locked(&so->so_rcv, m, 0); } - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; return (flags); } @@ -1108,7 +1107,6 @@ present: #ifdef TCP_REASS_LOGGING tcp_reass_log_dump(tp); #endif - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; return (flags); } diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 22762d21c289..dd4cbfd7dc53 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -7825,8 +7825,8 @@ bbr_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so, acked_amount = min(acked, (int)sbavail(&so->so_snd)); tp->snd_wnd -= acked_amount; mfree = sbcut_locked(&so->so_snd, acked_amount); - SOCKBUF_UNLOCK(&so->so_snd); - tp->t_flags |= TF_WAKESOW; + /* NB: sowwakeup_locked() does an implicit unlock. */ + sowwakeup_locked(so); m_freem(mfree); if (SEQ_GT(th->th_ack, tp->snd_una)) { bbr_collapse_rtt(tp, bbr, TCP_REXMTVAL(tp)); @@ -8302,7 +8302,6 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, appended = #endif sbappendstream_locked(&so->so_rcv, m, 0); - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && appended != mcnt) @@ -8353,6 +8352,7 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, save_start + tlen); } } + tcp_handle_wakeup(tp, so); } else { m_freem(m); thflags &= ~TH_FIN; @@ -8364,9 +8364,8 @@ bbr_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, */ if (thflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { - socantrcvmore(so); /* The socket upcall is handled by socantrcvmore. */ - tp->t_flags &= ~TF_WAKESOR; + socantrcvmore(so); /* * If connection is half-synchronized (ie NEEDSYN * flag on) then delay ACK, so it may be piggybacked @@ -8557,8 +8556,8 @@ bbr_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so, sbappendstream_locked(&so->so_rcv, m, 0); ctf_calc_rwin(so, tp); } - SOCKBUF_UNLOCK(&so->so_rcv); - tp->t_flags |= TF_WAKESOR; + /* NB: sorwakeup_locked() does an implicit unlock. */ + sorwakeup_locked(so); #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && mcnt != appended) counter_fo_release(so->so_rcv.sb_shlim, mcnt - appended); @@ -8749,7 +8748,7 @@ bbr_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so, &tcp_savetcp, 0); #endif /* Wake up the socket if we have room to write more */ - tp->t_flags |= TF_WAKESOW; + sowwakeup(so); if (tp->snd_una == tp->snd_max) { /* Nothing left outstanding */ bbr_log_progress_event(bbr, tp, ticks, PROGRESS_CLEAR, __LINE__); @@ -9157,9 +9156,11 @@ bbr_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, * If segment contains data or ACK, will call tcp_reass() later; if * not, do so now to pass queued data to user. */ - if (tlen == 0 && (thflags & TH_FIN) == 0) + if (tlen == 0 && (thflags & TH_FIN) == 0) { (void)tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); + tcp_handle_wakeup(tp, so); + } tp->snd_wl1 = th->th_seq - 1; if (bbr_process_ack(m, th, so, tp, to, tiwin, tlen, &ourfinisacked, thflags, &ret_val)) { return (ret_val); @@ -11711,7 +11712,6 @@ bbr_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, retval = bbr_do_segment_nounlock(m, th, so, tp, drop_hdrlen, tlen, iptos, 0, &tv); if (retval == 0) { - tcp_handle_wakeup(tp, so); INP_WUNLOCK(tp->t_inpcb); } } diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 73b47745cbac..efab90a2e5bd 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -9857,8 +9857,8 @@ rack_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so, if (acked_amount && sbavail(&so->so_snd)) rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); - SOCKBUF_UNLOCK(&so->so_snd); - tp->t_flags |= TF_WAKESOW; + /* NB: sowwakeup_locked() does an implicit unlock. */ + sowwakeup_locked(so); m_freem(mfree); if (SEQ_GT(tp->snd_una, tp->snd_recover)) tp->snd_recover = tp->snd_una; @@ -10208,7 +10208,6 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, sbappendstream_locked(&so->so_rcv, m, 0); rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && appended != mcnt) @@ -10265,6 +10264,7 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, save_start + tlen); } } + tcp_handle_wakeup(tp, so); } else { m_freem(m); thflags &= ~TH_FIN; @@ -10276,9 +10276,8 @@ rack_process_data(struct mbuf *m, struct tcphdr *th, struct socket *so, */ if (thflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { - socantrcvmore(so); /* The socket upcall is handled by socantrcvmore. */ - tp->t_flags &= ~TF_WAKESOR; + socantrcvmore(so); /* * If connection is half-synchronized (ie NEEDSYN * flag on) then delay ACK, so it may be piggybacked @@ -10471,7 +10470,6 @@ rack_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so, ctf_calc_rwin(so, tp); } rack_log_wakeup(tp,rack, &so->so_rcv, tlen, 1); - SOCKBUF_UNLOCK(&so->so_rcv); tp->t_flags |= TF_WAKESOR; #ifdef NETFLIX_SB_LIMITS if (so->so_rcv.sb_shlim && mcnt != appended) @@ -10631,8 +10629,7 @@ rack_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so, rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); /* Wake up the socket if we have room to write more */ rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); - SOCKBUF_UNLOCK(&so->so_snd); - tp->t_flags |= TF_WAKESOW; + sowwakeup(so); m_freem(mfree); tp->t_rxtshift = 0; RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), @@ -11070,9 +11067,11 @@ rack_do_syn_recv(struct mbuf *m, struct tcphdr *th, struct socket *so, * If segment contains data or ACK, will call tcp_reass() later; if * not, do so now to pass queued data to user. */ - if (tlen == 0 && (thflags & TH_FIN) == 0) + if (tlen == 0 && (thflags & TH_FIN) == 0) { (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); + tcp_handle_wakeup(tp, so); + } tp->snd_wl1 = th->th_seq - 1; /* For syn-recv we need to possibly update the rtt */ if ((to->to_flags & TOF_TS) != 0 && to->to_tsecr) { @@ -13155,8 +13154,7 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); /* Wake up the socket if we have room to write more */ rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); - SOCKBUF_UNLOCK(&so->so_snd); - tp->t_flags |= TF_WAKESOW; + sowwakeup(so); m_freem(mfree); } /* update progress */ diff --git a/sys/netinet/tcp_stacks/rack_bbr_common.c b/sys/netinet/tcp_stacks/rack_bbr_common.c index 6475a1a01c26..501d29ac48da 100644 --- a/sys/netinet/tcp_stacks/rack_bbr_common.c +++ b/sys/netinet/tcp_stacks/rack_bbr_common.c @@ -533,7 +533,6 @@ ctf_do_queued_segments(struct socket *so, struct tcpcb *tp, int have_pkt) /* We lost the tcpcb (maybe a RST came in)? */ return(1); } - tcp_handle_wakeup(tp, so); } return (0); } diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index b80746b1ede4..1742b3b1c514 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -408,7 +408,7 @@ TAILQ_HEAD(tcp_funchead, tcp_function); #define TF_FORCEDATA 0x00800000 /* force out a byte */ #define TF_TSO 0x01000000 /* TSO enabled on this connection */ #define TF_TOE 0x02000000 /* this connection is offloaded */ -#define TF_WAKESOW 0x04000000 /* wake up send socket */ +#define TF_UNUSED0 0x04000000 /* unused */ #define TF_UNUSED1 0x08000000 /* unused */ #define TF_LRD 0x10000000 /* Lost Retransmission Detection */ #define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */ From owner-dev-commits-src-main@freebsd.org Fri May 21 09:25:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73E43655457; Fri, 21 May 2021 09:25: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 4Fmh6P2vZSz4vvP; Fri, 21 May 2021 09:25: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 4801F6B72; Fri, 21 May 2021 09:25: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 14L9PXM3070753; Fri, 21 May 2021 09:25:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L9PXkO070752; Fri, 21 May 2021 09:25:33 GMT (envelope-from git) Date: Fri, 21 May 2021 09:25:33 GMT Message-Id: <202105210925.14L9PXkO070752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 209d4919c527 - main - Make sure all tasklets are drained before unloading the LinuxKPI. Else use-after-free may happen. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 209d4919c5270fe9e3c1d809cf91355d222dc2f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:25:33 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=209d4919c5270fe9e3c1d809cf91355d222dc2f3 commit 209d4919c5270fe9e3c1d809cf91355d222dc2f3 Author: Hans Petter Selasky AuthorDate: 2021-05-21 06:52:59 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 09:21:32 +0000 Make sure all tasklets are drained before unloading the LinuxKPI. Else use-after-free may happen. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/compat/linuxkpi/common/src/linux_tasklet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_tasklet.c b/sys/compat/linuxkpi/common/src/linux_tasklet.c index 9a4c01737466..26e7bb75cf19 100644 --- a/sys/compat/linuxkpi/common/src/linux_tasklet.c +++ b/sys/compat/linuxkpi/common/src/linux_tasklet.c @@ -128,6 +128,8 @@ tasklet_subsystem_uninit(void *arg __unused) struct tasklet_worker *tw; int i; + taskqgroup_drain_all(qgroup_softirq); + CPU_FOREACH(i) { if (CPU_ABSENT(i)) continue; From owner-dev-commits-src-main@freebsd.org Fri May 21 09:25:34 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2980655459; Fri, 21 May 2021 09:25:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmh6Q3swZz4vq7; Fri, 21 May 2021 09:25:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 611DD6D1C; Fri, 21 May 2021 09:25:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14L9PYU5070774; Fri, 21 May 2021 09:25:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L9PY9c070773; Fri, 21 May 2021 09:25:34 GMT (envelope-from git) Date: Fri, 21 May 2021 09:25:34 GMT Message-Id: <202105210925.14L9PY9c070773@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: cc9bb7a9b863 - main - Rework for-loop in EPOCH(9) to reduce indentation level. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc9bb7a9b863c018a069a71392fa9baea98b5fdb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:25:34 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=cc9bb7a9b863c018a069a71392fa9baea98b5fdb commit cc9bb7a9b863c018a069a71392fa9baea98b5fdb Author: Hans Petter Selasky AuthorDate: 2021-05-21 08:20:34 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 09:21:32 +0000 Rework for-loop in EPOCH(9) to reduce indentation level. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/kern/subr_epoch.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index 48567f97dcfa..210cf78d55f0 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -219,12 +219,14 @@ epoch_trace_enter(struct thread *td, epoch_t epoch, epoch_tracker_t et, { epoch_tracker_t iet; - SLIST_FOREACH(iet, &td->td_epochs, et_tlink) - if (iet->et_epoch == epoch) - epoch_trace_report("Recursively entering epoch %s " - "at %s:%d, previously entered at %s:%d\n", - epoch->e_name, file, line, - iet->et_file, iet->et_line); + SLIST_FOREACH(iet, &td->td_epochs, et_tlink) { + if (iet->et_epoch != epoch) + continue; + epoch_trace_report("Recursively entering epoch %s " + "at %s:%d, previously entered at %s:%d\n", + epoch->e_name, file, line, + iet->et_file, iet->et_line); + } et->et_epoch = epoch; et->et_file = file; et->et_line = line; From owner-dev-commits-src-main@freebsd.org Fri May 21 09:25:35 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C615E655920; Fri, 21 May 2021 09:25: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 4Fmh6R55tZz4vq9; Fri, 21 May 2021 09:25: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 8E7C266DC; Fri, 21 May 2021 09:25: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 14L9PZlL070799; Fri, 21 May 2021 09:25:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L9PZPU070798; Fri, 21 May 2021 09:25:35 GMT (envelope-from git) Date: Fri, 21 May 2021 09:25:35 GMT Message-Id: <202105210925.14L9PZPU070798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: f33168351b38 - main - Properly define EPOCH(9) function macro. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f33168351b3804664f5e82a409d9f956df2802f3 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:25:35 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=f33168351b3804664f5e82a409d9f956df2802f3 commit f33168351b3804664f5e82a409d9f956df2802f3 Author: Hans Petter Selasky AuthorDate: 2021-05-21 08:22:13 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 09:21:32 +0000 Properly define EPOCH(9) function macro. No functional change intended. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/kern/subr_epoch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index 210cf78d55f0..c5e4b78d8b79 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -870,7 +870,7 @@ epoch_assert_nocpu(epoch_t epoch, struct thread *td) } } #else -#define epoch_assert_nocpu(e, td) +#define epoch_assert_nocpu(e, td) do {} while (0) #endif int From owner-dev-commits-src-main@freebsd.org Fri May 21 09:25:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3762F6555DD; Fri, 21 May 2021 09:25: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 4Fmh6S5nWWz3Brv; Fri, 21 May 2021 09:25:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A08066C40; Fri, 21 May 2021 09:25:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14L9Pa8b070820; Fri, 21 May 2021 09:25:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L9PahQ070819; Fri, 21 May 2021 09:25:36 GMT (envelope-from git) Date: Fri, 21 May 2021 09:25:36 GMT Message-Id: <202105210925.14L9PahQ070819@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: c82c200622b5 - main - Accessing the epoch structure should happen after the INIT_CHECK(). Else the epoch pointer may be NULL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c82c200622b5380b8346de29879222538653f663 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:25:37 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=c82c200622b5380b8346de29879222538653f663 commit c82c200622b5380b8346de29879222538653f663 Author: Hans Petter Selasky AuthorDate: 2021-05-21 09:06:27 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 09:21:32 +0000 Accessing the epoch structure should happen after the INIT_CHECK(). Else the epoch pointer may be NULL. MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/kern/subr_epoch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index c5e4b78d8b79..798dbdc4360e 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -442,13 +442,14 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et EPOCH_FILE_LINE) struct thread *td; MPASS(cold || epoch != NULL); - MPASS(epoch->e_flags & EPOCH_PREEMPT); td = curthread; MPASS((vm_offset_t)et >= td->td_kstack && (vm_offset_t)et + sizeof(struct epoch_tracker) <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE); INIT_CHECK(epoch); + MPASS(epoch->e_flags & EPOCH_PREEMPT); + #ifdef EPOCH_TRACE epoch_trace_enter(td, epoch, et, file, line); #endif From owner-dev-commits-src-main@freebsd.org Fri May 21 09:49:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 428FC656019; Fri, 21 May 2021 09:49:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmhfQ1MW4z3Nbj; Fri, 21 May 2021 09:49:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D2326ED6; Fri, 21 May 2021 09:49:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14L9nnsw097502; Fri, 21 May 2021 09:49:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14L9nnoE097501; Fri, 21 May 2021 09:49:49 GMT (envelope-from git) Date: Fri, 21 May 2021 09:49:49 GMT Message-Id: <202105210949.14L9nnoE097501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: c1fbb54f4b10 - main - test/libalias: Tests for outgoing NAT MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1fbb54f4b100d576da7ab065d1887a21f691936 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 09:49:50 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=c1fbb54f4b100d576da7ab065d1887a21f691936 commit c1fbb54f4b100d576da7ab065d1887a21f691936 Author: Lutz Donnerhacke AuthorDate: 2021-05-17 21:49:31 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-21 09:45:52 +0000 test/libalias: Tests for outgoing NAT Testing LibAliasOut functionality. This concentrates the typical use case of initiating data transfers from the inside. Provide a exhaustive test for the data structure in order to check for performance improvements. Reviewed by: kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30335 --- tests/sys/netinet/libalias/1_instance.c | 11 +- tests/sys/netinet/libalias/2_natout.c | 381 ++++++++++++++++++++++++++++++++ tests/sys/netinet/libalias/Makefile | 8 +- tests/sys/netinet/libalias/util.c | 74 +++++++ tests/sys/netinet/libalias/util.h | 29 +++ 5 files changed, 490 insertions(+), 13 deletions(-) diff --git a/tests/sys/netinet/libalias/1_instance.c b/tests/sys/netinet/libalias/1_instance.c index e9137eb99d50..d2f20011c520 100644 --- a/tests/sys/netinet/libalias/1_instance.c +++ b/tests/sys/netinet/libalias/1_instance.c @@ -3,16 +3,7 @@ #include #include -static int randcmp(const void *a, const void *b) { - int res, r = rand(); - - (void)a; - (void)b; - res = (r/4 < RAND_MAX/9) ? 1 - : (r/5 < RAND_MAX/9) ? 0 - : -1; - return (res); -} +#include "util.h" ATF_TC(2_destroynull); ATF_TC_HEAD(2_destroynull, env) diff --git a/tests/sys/netinet/libalias/2_natout.c b/tests/sys/netinet/libalias/2_natout.c new file mode 100644 index 000000000000..9eb9148f8377 --- /dev/null +++ b/tests/sys/netinet/libalias/2_natout.c @@ -0,0 +1,381 @@ +#include +#include +#include +#include + +#include "util.h" + +/* common ip ranges */ +static struct in_addr masq = { htonl(0x01020304) }; +static struct in_addr pub = { htonl(0x0102dead) }; +static struct in_addr prv1 = { htonl(0x0a00dead) }; +static struct in_addr prv2 = { htonl(0xac10dead) }; +static struct in_addr prv3 = { htonl(0xc0a8dead) }; +static struct in_addr cgn = { htonl(0x6440dead) }; +static struct in_addr ext = { htonl(0x12345678) }; + +#define NAT_CHECK(pip, src, msq) do { \ + int res; \ + int len = ntohs(pip->ip_len); \ + struct in_addr dst = pip->ip_dst; \ + pip->ip_src = src; \ + res = LibAliasOut(la, pip, len); \ + ATF_CHECK_MSG(res == PKT_ALIAS_OK, \ + ">%d< not met PKT_ALIAS_OK", res); \ + ATF_CHECK(addr_eq(msq, pip->ip_src)); \ + ATF_CHECK(addr_eq(dst, pip->ip_dst)); \ +} while(0) + +#define NAT_FAIL(pip, src, dst) do { \ + int res; \ + int len = ntohs(pip->ip_len); \ + pip->ip_src = src; \ + pip->ip_dst = dst; \ + res = LibAliasOut(la, pip, len); \ + ATF_CHECK_MSG(res != PKT_ALIAS_OK), \ + ">%d< not met !PKT_ALIAS_OK", res); \ + ATF_CHECK(addr_eq(src, pip->ip_src)); \ + ATF_CHECK(addr_eq(dst, pip->ip_dst)); \ +} while(0) + +#define UNNAT_CHECK(pip, src, dst, rel) do { \ + int res; \ + int len = ntohs(pip->ip_len); \ + pip->ip_src = src; \ + pip->ip_dst = dst; \ + res = LibAliasIn(la, pip, len); \ + ATF_CHECK_MSG(res == PKT_ALIAS_OK, \ + ">%d< not met PKT_ALIAS_OK", res); \ + ATF_CHECK(addr_eq(src, pip->ip_src)); \ + ATF_CHECK(addr_eq(rel, pip->ip_dst)); \ +} while(0) + +#define UNNAT_FAIL(pip, src, dst) do { \ + int res; \ + int len = ntohs(pip->ip_len); \ + pip->ip_src = src; \ + pip->ip_dst = dst; \ + res = LibAliasIn(la, pip, len); \ + ATF_CHECK_MSG(res != PKT_ALIAS_OK, \ + ">%d< not met !PKT_ALIAS_OK", res); \ + ATF_CHECK(addr_eq(src, pip->ip_src)); \ + ATF_CHECK(addr_eq(dst, pip->ip_dst)); \ +} while(0) + +ATF_TC_WITHOUT_HEAD(1_simplemasq); +ATF_TC_BODY(1_simplemasq, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *pip; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, 0, ~0); + + pip = ip_packet(prv1, ext, 254, 64); + NAT_CHECK(pip, prv1, masq); + NAT_CHECK(pip, prv2, masq); + NAT_CHECK(pip, prv3, masq); + NAT_CHECK(pip, cgn, masq); + NAT_CHECK(pip, pub, masq); + + free(pip); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(2_unregistered); +ATF_TC_BODY(2_unregistered, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *pip; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, PKT_ALIAS_UNREGISTERED_ONLY, ~0); + + pip = ip_packet(prv1, ext, 254, 64); + NAT_CHECK(pip, prv1, masq); + NAT_CHECK(pip, prv2, masq); + NAT_CHECK(pip, prv3, masq); + NAT_CHECK(pip, cgn, cgn); + NAT_CHECK(pip, pub, pub); + + /* + * State is only for new connections + * Because they are now active, + * the mode setting should be ignored + */ + LibAliasSetMode(la, 0, PKT_ALIAS_UNREGISTERED_ONLY); + NAT_CHECK(pip, prv1, masq); + NAT_CHECK(pip, prv2, masq); + NAT_CHECK(pip, prv3, masq); + NAT_CHECK(pip, cgn, cgn); + NAT_CHECK(pip, pub, pub); + + free(pip); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(3_cgn); +ATF_TC_BODY(3_cgn, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *pip; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, PKT_ALIAS_UNREGISTERED_CGN, ~0); + + pip = ip_packet(prv1, ext, 254, 64); + NAT_CHECK(pip, prv1, masq); + NAT_CHECK(pip, prv2, masq); + NAT_CHECK(pip, prv3, masq); + NAT_CHECK(pip, cgn, masq); + NAT_CHECK(pip, pub, pub); + + /* + * State is only for new connections + * Because they are now active, + * the mode setting should be ignored + */ + LibAliasSetMode(la, 0, PKT_ALIAS_UNREGISTERED_CGN); + NAT_CHECK(pip, prv1, masq); + NAT_CHECK(pip, prv2, masq); + NAT_CHECK(pip, prv3, masq); + NAT_CHECK(pip, cgn, masq); + NAT_CHECK(pip, pub, pub); + + free(pip); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(4_udp); +ATF_TC_BODY(4_udp, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *po, *pi; + struct udphdr *ui, *uo; + uint16_t sport = 0x1234; + uint16_t dport = 0x5678; + uint16_t aport; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, 0, ~0); + + /* Query from prv1 */ + po = ip_packet(prv1, ext, 0, 64); + uo = set_udp(po, sport, dport); + NAT_CHECK(po, prv1, masq); + ATF_CHECK(uo->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(po->ip_dst, ext)); + aport = ntohs(uo->uh_sport); + /* should use a different external port */ + ATF_CHECK(aport != sport); + + /* Response */ + pi = ip_packet(po->ip_dst, po->ip_src, 0, 64); + ui = set_udp(pi, ntohs(uo->uh_dport), ntohs(uo->uh_sport)); + UNNAT_CHECK(pi, ext, masq, prv1); + ATF_CHECK(ui->uh_sport == htons(dport)); + ATF_CHECK(ui->uh_dport == htons(sport)); + + /* Query from different source with same ports */ + uo = set_udp(po, sport, dport); + NAT_CHECK(po, prv2, masq); + ATF_CHECK(uo->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(po->ip_dst, ext)); + /* should use a different external port */ + ATF_CHECK(uo->uh_sport != htons(aport)); + + /* Response to prv2 */ + ui->uh_dport = uo->uh_sport; + UNNAT_CHECK(pi, ext, masq, prv2); + ATF_CHECK(ui->uh_sport == htons(dport)); + ATF_CHECK(ui->uh_dport == htons(sport)); + + /* Response to prv1 again */ + ui->uh_dport = htons(aport); + UNNAT_CHECK(pi, ext, masq, prv1); + ATF_CHECK(ui->uh_sport == htons(dport)); + ATF_CHECK(ui->uh_dport == htons(sport)); + + free(pi); + free(po); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(5_sameport); +ATF_TC_BODY(5_sameport, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *p; + struct udphdr *u; + uint16_t sport = 0x1234; + uint16_t dport = 0x5678; + uint16_t aport; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, PKT_ALIAS_SAME_PORTS, ~0); + + /* Query from prv1 */ + p = ip_packet(prv1, ext, 0, 64); + u = set_udp(p, sport, dport); + NAT_CHECK(p, prv1, masq); + ATF_CHECK(u->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(p->ip_dst, ext)); + aport = ntohs(u->uh_sport); + /* should use the same external port */ + ATF_CHECK(aport == sport); + + /* Query from different source with same ports */ + u = set_udp(p, sport, dport); + NAT_CHECK(p, prv2, masq); + ATF_CHECK(u->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(p->ip_dst, ext)); + /* should use a different external port */ + ATF_CHECK(u->uh_sport != htons(aport)); + + free(p); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(6_cleartable); +ATF_TC_BODY(6_cleartable, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *po, *pi; + struct udphdr *ui, *uo; + uint16_t sport = 0x1234; + uint16_t dport = 0x5678; + uint16_t aport; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, PKT_ALIAS_RESET_ON_ADDR_CHANGE, ~0); + LibAliasSetMode(la, PKT_ALIAS_SAME_PORTS, PKT_ALIAS_SAME_PORTS); + LibAliasSetMode(la, PKT_ALIAS_DENY_INCOMING, PKT_ALIAS_DENY_INCOMING); + + /* Query from prv1 */ + po = ip_packet(prv1, ext, 0, 64); + uo = set_udp(po, sport, dport); + NAT_CHECK(po, prv1, masq); + ATF_CHECK(uo->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(po->ip_dst, ext)); + aport = ntohs(uo->uh_sport); + /* should use the same external port */ + ATF_CHECK(aport == sport); + + /* Response */ + pi = ip_packet(po->ip_dst, po->ip_src, 0, 64); + ui = set_udp(pi, ntohs(uo->uh_dport), ntohs(uo->uh_sport)); + UNNAT_CHECK(pi, ext, masq, prv1); + ATF_CHECK(ui->uh_sport == htons(dport)); + ATF_CHECK(ui->uh_dport == htons(sport)); + + /* clear table by keeping the address */ + LibAliasSetAddress(la, ext); + LibAliasSetAddress(la, masq); + + /* Response to prv1 again -> DENY_INCOMING */ + ui->uh_dport = htons(aport); + UNNAT_FAIL(pi, ext, masq); + + /* Query from different source with same ports */ + uo = set_udp(po, sport, dport); + NAT_CHECK(po, prv2, masq); + ATF_CHECK(uo->uh_dport == htons(dport)); + ATF_CHECK(addr_eq(po->ip_dst, ext)); + /* should use the same external port, because it's free */ + ATF_CHECK(uo->uh_sport == htons(aport)); + + /* Response to prv2 */ + ui->uh_dport = uo->uh_sport; + UNNAT_CHECK(pi, ext, masq, prv2); + ATF_CHECK(ui->uh_sport == htons(dport)); + ATF_CHECK(ui->uh_dport == htons(sport)); + + free(pi); + free(po); + LibAliasUninit(la); +} + +ATF_TC_WITHOUT_HEAD(7_stress); +ATF_TC_BODY(7_stress, dummy) +{ + struct libalias *la = LibAliasInit(NULL); + struct ip *p; + struct udphdr *u; + struct { + struct in_addr src, dst; + uint16_t sport, dport, aport; + } *batch; + size_t const batch_size = 12000; + size_t const rounds = 25; + size_t i, j; + + ATF_REQUIRE(la != NULL); + LibAliasSetAddress(la, masq); + + p = ip_packet(prv1, ext, 0, 64); + u = set_udp(p, 0, 0); + + batch = calloc(batch_size, sizeof(*batch)); + ATF_REQUIRE(batch != NULL); + for (j = 0; j < rounds; j++) { + for (i = 0; i < batch_size; i++) { + struct in_addr s, d; + switch (i&3) { + case 0: s = prv1; d = ext; break; + case 1: s = prv2; d = pub; break; + case 2: s = prv3; d = ext; break; + case 3: s = cgn; d = pub; break; + } + s.s_addr &= htonl(0xffff0000); + d.s_addr &= htonl(0xffff0000); + batch[i].src.s_addr = s.s_addr | htonl(rand_range(0, 0xffff)); + batch[i].dst.s_addr = d.s_addr | htonl(rand_range(0, 0xffff)); + batch[i].sport = rand_range(1000, 60000); + batch[i].dport = rand_range(1000, 60000); + } + + for (i = 0; i < batch_size; i++) { + p->ip_dst = batch[i].dst; + u = set_udp(p, batch[i].sport, batch[i].dport); + NAT_CHECK(p, batch[i].src, masq); + ATF_CHECK(u->uh_dport == htons(batch[i].dport)); + ATF_CHECK(addr_eq(p->ip_dst, batch[i].dst)); + batch[i].aport = htons(u->uh_sport); + } + + qsort(batch, batch_size, sizeof(*batch), randcmp); + + for (i = 0; i < batch_size; i++) { + u = set_udp(p, batch[i].dport, batch[i].aport); + UNNAT_CHECK(p, batch[i].dst, masq, batch[i].src); + ATF_CHECK(u->uh_dport == htons(batch[i].sport)); + ATF_CHECK(u->uh_sport == htons(batch[i].dport)); + } + } + + free(batch); + free(p); + LibAliasUninit(la); +} + +ATF_TP_ADD_TCS(natout) +{ + /* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */ + srand(0x0b61); + + ATF_TP_ADD_TC(natout, 1_simplemasq); + ATF_TP_ADD_TC(natout, 2_unregistered); + ATF_TP_ADD_TC(natout, 3_cgn); + ATF_TP_ADD_TC(natout, 4_udp); + ATF_TP_ADD_TC(natout, 5_sameport); + ATF_TP_ADD_TC(natout, 6_cleartable); + ATF_TP_ADD_TC(natout, 7_stress); + + return atf_no_error(); +} diff --git a/tests/sys/netinet/libalias/Makefile b/tests/sys/netinet/libalias/Makefile index 3b2a3b144298..79922d7d4b13 100644 --- a/tests/sys/netinet/libalias/Makefile +++ b/tests/sys/netinet/libalias/Makefile @@ -1,16 +1,18 @@ # $FreeBSD$ -.include - PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netinet/libalias BINDIR= ${TESTSDIR} -ATF_TESTS_C+= 1_instance +ATF_TESTS_C+= 1_instance \ + 2_natout \ LIBADD+= alias +SRCS.1_instance=1_instance.c util.c +SRCS.2_natout= 2_natout.c util.c + .include # diff --git a/tests/sys/netinet/libalias/util.c b/tests/sys/netinet/libalias/util.c new file mode 100644 index 000000000000..e0e5e08eb23e --- /dev/null +++ b/tests/sys/netinet/libalias/util.c @@ -0,0 +1,74 @@ +#include +#include +#include + +#include + +#include "util.h" + +int +randcmp(const void *a, const void *b) +{ + int res, r = rand(); + + (void)a; + (void)b; + res = (r/4 < RAND_MAX/9) ? 1 + : (r/5 < RAND_MAX/9) ? 0 + : -1; + return (res); +} + +void +hexdump(void *p, size_t len) +{ + size_t i; + unsigned char *c = p; + + for (i = 0; i < len; i++) { + printf(" %02x", c[i]); + switch (i & 0xf) { + case 0xf: printf("\n"); break; + case 0x7: printf(" "); break; + default: break; + } + } + if ((i & 0xf) != 0x0) + printf("\n"); +} + +struct ip * +ip_packet(struct in_addr src, struct in_addr dst, u_char protocol, size_t len) +{ + struct ip * p; + + ATF_REQUIRE(len >= 64 && len <= IP_MAXPACKET); + + p = calloc(1, len); + ATF_REQUIRE(p != NULL); + + p->ip_v = IPVERSION; + p->ip_hl = sizeof(*p)/4; + p->ip_len = htons(len); + p->ip_ttl = IPDEFTTL; + p->ip_src = src; + p->ip_dst = dst; + p->ip_p = protocol; + ATF_REQUIRE(p->ip_hl == 5); + + return (p); +} + +struct udphdr * +set_udp(struct ip *p, u_short sport, u_short dport) { + uint32_t *up = (void *)p; + struct udphdr *u = (void *)&(up[p->ip_hl]); + int payload = ntohs(p->ip_len) - 4*p->ip_hl; + + ATF_REQUIRE(payload >= (int)sizeof(*u)); + p->ip_p = IPPROTO_UDP; + u->uh_sport = htons(sport); + u->uh_dport = htons(dport); + u->uh_ulen = htons(payload); + return (u); +} diff --git a/tests/sys/netinet/libalias/util.h b/tests/sys/netinet/libalias/util.h new file mode 100644 index 000000000000..5edbadb2f64a --- /dev/null +++ b/tests/sys/netinet/libalias/util.h @@ -0,0 +1,29 @@ +#include + +#include +#include +#include + +#ifndef _UTIL_H +#define _UTIL_H + +int randcmp(const void *a, const void *b); +void hexdump(void *p, size_t len); +struct ip * ip_packet(struct in_addr src, struct in_addr dst, u_char protocol, size_t len); +struct udphdr * set_udp(struct ip *p, u_short sport, u_short dport); + +inline int +addr_eq(struct in_addr a, struct in_addr b) +{ + return a.s_addr == b.s_addr; +} + +#define a2h(a) ntohl(a.s_addr) + +inline int +rand_range(int min, int max) +{ + return min + rand()%(max - min); +} + +#endif /* _UTIL_H */ From owner-dev-commits-src-main@freebsd.org Fri May 21 11:21:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A1BA6576B0; Fri, 21 May 2021 11:21: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 4Fmkgx2wp0z4mHC; Fri, 21 May 2021 11:21: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 4C23E7FEB; Fri, 21 May 2021 11:21: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 14LBLHB2026835; Fri, 21 May 2021 11:21:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LBLHI2026834; Fri, 21 May 2021 11:21:17 GMT (envelope-from git) Date: Fri, 21 May 2021 11:21:17 GMT Message-Id: <202105211121.14LBLHI2026834@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: b764a426534f - main - There is a window where threads are removed from the process list and where the thread destructor is invoked. Catch that window by waiting for all task_struct allocations to be returned before freeing the UMA zone in the LinuxKPI. Else UMA may fail to release the zone due to concurrent access and panic: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b764a426534f2f5f86d6625288c74dafdbc94d2b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 11:21:17 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=b764a426534f2f5f86d6625288c74dafdbc94d2b commit b764a426534f2f5f86d6625288c74dafdbc94d2b Author: Hans Petter Selasky AuthorDate: 2021-05-21 11:17:42 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 11:18:41 +0000 There is a window where threads are removed from the process list and where the thread destructor is invoked. Catch that window by waiting for all task_struct allocations to be returned before freeing the UMA zone in the LinuxKPI. Else UMA may fail to release the zone due to concurrent access and panic: panic() - Bad link element prev->next != elm zone_release() bucket_drain() bucket_free() zone_dtor() zone_free_item() uma_zdestroy() linux_current_uninit() This failure can be triggered by loading and unloading the LinuxKPI module in a loop: while true do kldload linuxkpi kldunload linuxkpi done Discussed with: kib@ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/compat/linuxkpi/common/src/linux_current.c | 35 ++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c index 9bae7ee92e49..51e396081c04 100644 --- a/sys/compat/linuxkpi/common/src/linux_current.c +++ b/sys/compat/linuxkpi/common/src/linux_current.c @@ -45,6 +45,7 @@ extern u_int first_msi_irq, num_msi_irqs; static eventhandler_tag linuxkpi_thread_dtor_tag; +static atomic_t linux_current_allocs; static uma_zone_t linux_current_zone; static uma_zone_t linux_mm_zone; @@ -146,6 +147,10 @@ linux_alloc_current(struct thread *td, int flags) /* free mm_struct pointer, if any */ uma_zfree(linux_mm_zone, mm); + /* keep track of number of allocations */ + if (atomic_add_return(1, &linux_current_allocs) == INT_MAX) + panic("linux_alloc_current: Refcount too high!"); + return (0); } @@ -173,6 +178,10 @@ linux_free_current(struct task_struct *ts) { mmput(ts->mm); uma_zfree(linux_current_zone, ts); + + /* keep track of number of allocations */ + if (atomic_sub_return(1, &linux_current_allocs) < 0) + panic("linux_free_current: Negative refcount!"); } static void @@ -271,10 +280,6 @@ SYSCTL_INT(_compat_linuxkpi, OID_AUTO, task_struct_reserve, static void linux_current_init(void *arg __unused) { - lkpi_alloc_current = linux_alloc_current; - linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, - linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); - TUNABLE_INT_FETCH("compat.linuxkpi.task_struct_reserve", &lkpi_task_resrv); if (lkpi_task_resrv == 0) { @@ -298,6 +303,12 @@ linux_current_init(void *arg __unused) UMA_ALIGN_PTR, 0); uma_zone_reserve(linux_mm_zone, lkpi_task_resrv); uma_prealloc(linux_mm_zone, lkpi_task_resrv); + + atomic_thread_fence_seq_cst(); + + lkpi_alloc_current = linux_alloc_current; + linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, + linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); } SYSINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_init, NULL); @@ -309,6 +320,10 @@ linux_current_uninit(void *arg __unused) struct task_struct *ts; struct thread *td; + lkpi_alloc_current = linux_alloc_current_noop; + + atomic_thread_fence_seq_cst(); + sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); @@ -321,8 +336,18 @@ linux_current_uninit(void *arg __unused) PROC_UNLOCK(p); } sx_sunlock(&allproc_lock); + + /* + * There is a window where threads are removed from the + * process list and where the thread destructor is invoked. + * Catch that window by waiting for all task_struct + * allocations to be returned before freeing the UMA zone. + */ + while (atomic_read(&linux_current_allocs) != 0) + pause("W", 1); + EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag); - lkpi_alloc_current = linux_alloc_current_noop; + uma_zdestroy(linux_current_zone); uma_zdestroy(linux_mm_zone); } From owner-dev-commits-src-main@freebsd.org Fri May 21 11:51:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 51922657E30; Fri, 21 May 2021 11:51:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmlMD69fKz3J9l; Fri, 21 May 2021 11:51:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 14LBpcrV087325 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 21 May 2021 14:51:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 14LBpcrV087325 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 14LBpcZa087324; Fri, 21 May 2021 14:51:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 21 May 2021 14:51:38 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: b764a426534f - main - There is a window where threads are removed from the process list and where the thread destructor is invoked. Catch that window by waiting for all task_struct allocations to be returned before freeing the UMA zone in the LinuxKPI. Else UMA may fail to release the zone due to concurrent access and panic: Message-ID: References: <202105211121.14LBLHI2026834@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105211121.14LBLHI2026834@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4FmlMD69fKz3J9l 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 11:51:53 -0000 On Fri, May 21, 2021 at 11:21:17AM +0000, Hans Petter Selasky wrote: > The branch main has been updated by hselasky: > > URL: https://cgit.FreeBSD.org/src/commit/?id=b764a426534f2f5f86d6625288c74dafdbc94d2b > > commit b764a426534f2f5f86d6625288c74dafdbc94d2b > Author: Hans Petter Selasky > AuthorDate: 2021-05-21 11:17:42 +0000 > Commit: Hans Petter Selasky > CommitDate: 2021-05-21 11:18:41 +0000 > > There is a window where threads are removed from the process list and where > the thread destructor is invoked. Catch that window by waiting for all > task_struct allocations to be returned before freeing the UMA zone in the > LinuxKPI. Else UMA may fail to release the zone due to concurrent access > and panic: > > panic() - Bad link element prev->next != elm > zone_release() > bucket_drain() > bucket_free() > zone_dtor() > zone_free_item() > uma_zdestroy() > linux_current_uninit() > > This failure can be triggered by loading and unloading the LinuxKPI module > in a loop: > > while true > do > kldload linuxkpi > kldunload linuxkpi > done > > Discussed with: kib@ No, it was not discussed, with me. It contains parts of my half-done patches. And I disagree with what the global counting you added there, both on principle and on implementation. > MFC after: 1 week > Sponsored by: Mellanox Technologies // NVIDIA Networking > --- > sys/compat/linuxkpi/common/src/linux_current.c | 35 ++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 5 deletions(-) > > diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c > index 9bae7ee92e49..51e396081c04 100644 > --- a/sys/compat/linuxkpi/common/src/linux_current.c > +++ b/sys/compat/linuxkpi/common/src/linux_current.c > @@ -45,6 +45,7 @@ extern u_int first_msi_irq, num_msi_irqs; > > static eventhandler_tag linuxkpi_thread_dtor_tag; > > +static atomic_t linux_current_allocs; > static uma_zone_t linux_current_zone; > static uma_zone_t linux_mm_zone; > > @@ -146,6 +147,10 @@ linux_alloc_current(struct thread *td, int flags) > /* free mm_struct pointer, if any */ > uma_zfree(linux_mm_zone, mm); > > + /* keep track of number of allocations */ > + if (atomic_add_return(1, &linux_current_allocs) == INT_MAX) > + panic("linux_alloc_current: Refcount too high!"); > + > return (0); > } > > @@ -173,6 +178,10 @@ linux_free_current(struct task_struct *ts) > { > mmput(ts->mm); > uma_zfree(linux_current_zone, ts); > + > + /* keep track of number of allocations */ > + if (atomic_sub_return(1, &linux_current_allocs) < 0) > + panic("linux_free_current: Negative refcount!"); > } > > static void > @@ -271,10 +280,6 @@ SYSCTL_INT(_compat_linuxkpi, OID_AUTO, task_struct_reserve, > static void > linux_current_init(void *arg __unused) > { > - lkpi_alloc_current = linux_alloc_current; > - linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, > - linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); > - > TUNABLE_INT_FETCH("compat.linuxkpi.task_struct_reserve", > &lkpi_task_resrv); > if (lkpi_task_resrv == 0) { > @@ -298,6 +303,12 @@ linux_current_init(void *arg __unused) > UMA_ALIGN_PTR, 0); > uma_zone_reserve(linux_mm_zone, lkpi_task_resrv); > uma_prealloc(linux_mm_zone, lkpi_task_resrv); > + > + atomic_thread_fence_seq_cst(); > + > + lkpi_alloc_current = linux_alloc_current; > + linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, > + linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); > } > SYSINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, > linux_current_init, NULL); > @@ -309,6 +320,10 @@ linux_current_uninit(void *arg __unused) > struct task_struct *ts; > struct thread *td; > > + lkpi_alloc_current = linux_alloc_current_noop; > + > + atomic_thread_fence_seq_cst(); > + > sx_slock(&allproc_lock); > FOREACH_PROC_IN_SYSTEM(p) { > PROC_LOCK(p); > @@ -321,8 +336,18 @@ linux_current_uninit(void *arg __unused) > PROC_UNLOCK(p); > } > sx_sunlock(&allproc_lock); > + > + /* > + * There is a window where threads are removed from the > + * process list and where the thread destructor is invoked. > + * Catch that window by waiting for all task_struct > + * allocations to be returned before freeing the UMA zone. > + */ > + while (atomic_read(&linux_current_allocs) != 0) > + pause("W", 1); > + > EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag); > - lkpi_alloc_current = linux_alloc_current_noop; > + > uma_zdestroy(linux_current_zone); > uma_zdestroy(linux_mm_zone); > } From owner-dev-commits-src-main@freebsd.org Fri May 21 12:35:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3A2C631423; Fri, 21 May 2021 12:35:40 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmmKm2H5qz3tGw; Fri, 21 May 2021 12:35:39 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id D52A3260100; Fri, 21 May 2021 14:35:37 +0200 (CEST) Subject: Re: git: b764a426534f - main - There is a window where threads are removed from the process list and where the thread destructor is invoked. Catch that window by waiting for all task_struct allocations to be returned before freeing the UMA zone in the LinuxKPI. Else UMA may fail to release the zone due to concurrent access and panic: To: Konstantin Belousov Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202105211121.14LBLHI2026834@gitrepo.freebsd.org> From: Hans Petter Selasky Message-ID: <909153c4-695b-ebc9-419d-ce3d3da38dcc@selasky.org> Date: Fri, 21 May 2021 14:34:17 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FmmKm2H5qz3tGw 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 12:35:40 -0000 On 5/21/21 1:51 PM, Konstantin Belousov wrote: > On Fri, May 21, 2021 at 11:21:17AM +0000, Hans Petter Selasky wrote: >> The branch main has been updated by hselasky: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=b764a426534f2f5f86d6625288c74dafdbc94d2b >> >> commit b764a426534f2f5f86d6625288c74dafdbc94d2b >> Author: Hans Petter Selasky >> AuthorDate: 2021-05-21 11:17:42 +0000 >> Commit: Hans Petter Selasky >> CommitDate: 2021-05-21 11:18:41 +0000 >> >> There is a window where threads are removed from the process list and where >> the thread destructor is invoked. Catch that window by waiting for all >> task_struct allocations to be returned before freeing the UMA zone in the >> LinuxKPI. Else UMA may fail to release the zone due to concurrent access >> and panic: >> >> panic() - Bad link element prev->next != elm >> zone_release() >> bucket_drain() >> bucket_free() >> zone_dtor() >> zone_free_item() >> uma_zdestroy() >> linux_current_uninit() >> >> This failure can be triggered by loading and unloading the LinuxKPI module >> in a loop: >> >> while true >> do >> kldload linuxkpi >> kldunload linuxkpi >> done >> >> Discussed with: kib@ > No, it was not discussed, with me. > It contains parts of my half-done patches. > And I disagree with what the global counting you added there, both on > principle and on implementation. Let's discuss this off-list. There are not that many choices from what I can see. --HPS From owner-dev-commits-src-main@freebsd.org Fri May 21 13:01:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DF1D63190B; Fri, 21 May 2021 13:01: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 4Fmmvt1bBwz4ZcY; Fri, 21 May 2021 13:01: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 1E2EE11477; Fri, 21 May 2021 13:01: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 14LD1k6f061293; Fri, 21 May 2021 13:01:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LD1kTd061292; Fri, 21 May 2021 13:01:46 GMT (envelope-from git) Date: Fri, 21 May 2021 13:01:46 GMT Message-Id: <202105211301.14LD1kTd061292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 4eac63af23dd - main - Fix for use-after-free by if_ioctl() calls from user-space in USB drivers by detaching the ifnet before the miibus. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4eac63af23ddafc2b1dfb2aad2896f4513c37cdd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:01:46 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=4eac63af23ddafc2b1dfb2aad2896f4513c37cdd commit 4eac63af23ddafc2b1dfb2aad2896f4513c37cdd Author: Hans Petter Selasky AuthorDate: 2021-01-12 17:51:09 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-21 12:59:19 +0000 Fix for use-after-free by if_ioctl() calls from user-space in USB drivers by detaching the ifnet before the miibus. PR: 252608 Suggested by: jhb@ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/net/uhso.c | 2 +- sys/dev/usb/net/usb_ethernet.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c index c72fa8d7a36b..4ff5fcc075d3 100644 --- a/sys/dev/usb/net/uhso.c +++ b/sys/dev/usb/net/uhso.c @@ -691,10 +691,10 @@ uhso_detach(device_t self) free_unr(uhso_ifnet_unit, sc->sc_ifp->if_dunit); mtx_lock(&sc->sc_mtx); uhso_if_stop(sc); + mtx_unlock(&sc->sc_mtx); bpfdetach(sc->sc_ifp); if_detach(sc->sc_ifp); if_free(sc->sc_ifp); - mtx_unlock(&sc->sc_mtx); usbd_transfer_unsetup(sc->sc_if_xfer, UHSO_IFNET_MAX); } diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index e1eb2c247b5a..33659049f970 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -319,6 +319,12 @@ uether_ifdetach(struct usb_ether *ue) /* drain any callouts */ usb_callout_drain(&ue->ue_watchdog); + /* + * Detach ethernet first to stop miibus calls from + * user-space: + */ + ether_ifdetach(ifp); + /* detach miibus */ if (ue->ue_miibus != NULL) { mtx_lock(&Giant); /* device_xxx() depends on this */ @@ -326,9 +332,6 @@ uether_ifdetach(struct usb_ether *ue) mtx_unlock(&Giant); } - /* detach ethernet */ - ether_ifdetach(ifp); - /* free interface instance */ if_free(ifp); From owner-dev-commits-src-main@freebsd.org Fri May 21 13:34:49 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 630B46326A3; Fri, 21 May 2021 13:34: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 4Fmnf12MlPz4qHm; Fri, 21 May 2021 13:34: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 3979311FC7; Fri, 21 May 2021 13:34: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 14LDYnbS004274; Fri, 21 May 2021 13:34:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LDYnkB004273; Fri, 21 May 2021 13:34:49 GMT (envelope-from git) Date: Fri, 21 May 2021 13:34:49 GMT Message-Id: <202105211334.14LDYnkB004273@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: 4a27bf128b10 - main - usr.bin/elfctl: Allow for cross-endian operations. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a27bf128b108d90412190c06a54ebac36a8ca2e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:34:49 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=4a27bf128b108d90412190c06a54ebac36a8ca2e commit 4a27bf128b108d90412190c06a54ebac36a8ca2e Author: Marcin Wojtas AuthorDate: 2021-05-21 09:19:31 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-21 13:32:04 +0000 usr.bin/elfctl: Allow for cross-endian operations. Detect if host endian is different than target endian and swap byte order of ELF note fields instead of failing. Submitted by: Dawid Gorecki Reviewed by: imp Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D29550 --- usr.bin/elfctl/elfctl.c | 55 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index bcdd1be394a9..41660fc4acd5 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -52,10 +52,10 @@ __FBSDID("$FreeBSD$"); static bool convert_to_feature_val(char *, uint32_t *); -static bool edit_file_features(Elf *, int, int, char *); -static bool get_file_features(Elf *, int, int, uint32_t *, uint64_t *); +static bool edit_file_features(Elf *, int, int, char *, bool); +static bool get_file_features(Elf *, int, int, uint32_t *, uint64_t *, bool); static void print_features(void); -static bool print_file_features(Elf *, int, int, char *); +static bool print_file_features(Elf *, int, int, char *, bool); static void usage(void); struct ControlFeatures { @@ -81,9 +81,11 @@ static struct option long_opts[] = { }; #if BYTE_ORDER == LITTLE_ENDIAN -#define SUPPORTED_ENDIAN ELFDATA2LSB +#define HOST_ENDIAN ELFDATA2LSB +#define SWAP_ENDIAN ELFDATA2MSB #else -#define SUPPORTED_ENDIAN ELFDATA2MSB +#define HOST_ENDIAN ELFDATA2MSB +#define SWAP_ENDIAN ELFDATA2LSB #endif static bool iflag; @@ -96,7 +98,7 @@ main(int argc, char **argv) Elf_Kind kind; int ch, fd, retval; char *features; - bool editfeatures, lflag; + bool editfeatures, lflag, endian_swap; lflag = 0; editfeatures = false; @@ -165,24 +167,25 @@ main(int argc, char **argv) retval = 1; goto fail; } - /* - * XXX need to support cross-endian operation, but for now - * exit on error rather than misbehaving. - */ - if (ehdr.e_ident[EI_DATA] != SUPPORTED_ENDIAN) { - warnx("file endianness must match host"); + + if (ehdr.e_ident[EI_DATA] == HOST_ENDIAN) { + endian_swap = false; + } else if (ehdr.e_ident[EI_DATA] == SWAP_ENDIAN) { + endian_swap = true; + } else { + warnx("file endianness unknown"); retval = 1; goto fail; } if (!editfeatures) { if (!print_file_features(elf, ehdr.e_phnum, fd, - argv[0])) { + argv[0], endian_swap)) { retval = 1; goto fail; } } else if (!edit_file_features(elf, ehdr.e_phnum, fd, - features)) { + features, endian_swap)) { retval = 1; goto fail; } @@ -286,12 +289,13 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) } static bool -edit_file_features(Elf *elf, int phcount, int fd, char *val) +edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap) { uint32_t features; uint64_t off; - if (!get_file_features(elf, phcount, fd, &features, &off)) { + if (!get_file_features(elf, phcount, fd, &features, &off, + endian_swap)) { warnx("NT_FREEBSD_FEATURE_CTL note not found"); return (false); } @@ -299,6 +303,9 @@ edit_file_features(Elf *elf, int phcount, int fd, char *val) if (!convert_to_feature_val(val, &features)) return (false); + if (endian_swap) + features = bswap32(features); + if (lseek(fd, off, SEEK_SET) == -1 || write(fd, &features, sizeof(features)) < (ssize_t)sizeof(features)) { @@ -320,12 +327,14 @@ print_features(void) } static bool -print_file_features(Elf *elf, int phcount, int fd, char *filename) +print_file_features(Elf *elf, int phcount, int fd, char *filename, + bool endian_swap) { uint32_t features; unsigned long i; - if (!get_file_features(elf, phcount, fd, &features, NULL)) { + if (!get_file_features(elf, phcount, fd, &features, NULL, + endian_swap)) { return (false); } @@ -344,7 +353,7 @@ print_file_features(Elf *elf, int phcount, int fd, char *filename) static bool get_file_features(Elf *elf, int phcount, int fd, uint32_t *features, - uint64_t *off) + uint64_t *off, bool endian_swap) { GElf_Phdr phdr; Elf_Note note; @@ -379,6 +388,12 @@ get_file_features(Elf *elf, int phcount, int fd, uint32_t *features, } read_total += sizeof(note); + if (endian_swap) { + note.n_namesz = bswap32(note.n_namesz); + note.n_descsz = bswap32(note.n_descsz); + note.n_type = bswap32(note.n_type); + } + /* * XXX: Name and descriptor are 4 byte aligned, however, * the size given doesn't include the padding. @@ -430,6 +445,8 @@ get_file_features(Elf *elf, int phcount, int fd, uint32_t *features, free(name); return (false); } + if (endian_swap) + *features = bswap32(*features); if (off != NULL) *off = phdr.p_offset + read_total; free(name); From owner-dev-commits-src-main@freebsd.org Fri May 21 13:34:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA6A263262A; Fri, 21 May 2021 13:34: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 4Fmnf24CKtz4qNJ; Fri, 21 May 2021 13:34: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 6A0AE124C3; Fri, 21 May 2021 13:34: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 14LDYoMf004295; Fri, 21 May 2021 13:34:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LDYo6F004294; Fri, 21 May 2021 13:34:50 GMT (envelope-from git) Date: Fri, 21 May 2021 13:34:50 GMT Message-Id: <202105211334.14LDYo6F004294@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: 7c8d38112da7 - main - Add afterbuild target to bsd.prog.mk. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7c8d38112da7bddb5ebd93cb9613acfb16456dc1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:34:51 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=7c8d38112da7bddb5ebd93cb9613acfb16456dc1 commit 7c8d38112da7bddb5ebd93cb9613acfb16456dc1 Author: Marcin Wojtas AuthorDate: 2021-05-21 09:23:42 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-21 13:32:29 +0000 Add afterbuild target to bsd.prog.mk. Afterbuild target allows to perform operations on fully built binary. This is needed to allow for ELF feature flags modification during world build. Submitted by: Dawid Gorecki Reviewed by: imp Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D29551 --- share/mk/bsd.prog.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 44a774957cfb..89eddb24abb0 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -232,7 +232,12 @@ MAN1= ${MAN} .if defined(_SKIP_BUILD) all: .else +.if target(afterbuild) +.ORDER: ${PROG} afterbuild +all: ${PROG} ${SCRIPTS} afterbuild +.else all: ${PROG} ${SCRIPTS} +.endif .if ${MK_MAN} != "no" all: all-man .endif From owner-dev-commits-src-main@freebsd.org Fri May 21 13:34:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B39E863262D; Fri, 21 May 2021 13:34: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 4Fmnf34M5zz4qTy; Fri, 21 May 2021 13:34: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 748FF1232A; Fri, 21 May 2021 13:34: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 14LDYp6Y004323; Fri, 21 May 2021 13:34:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LDYpx8004322; Fri, 21 May 2021 13:34:51 GMT (envelope-from git) Date: Fri, 21 May 2021 13:34:51 GMT Message-Id: <202105211334.14LDYpx8004322@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: c6081dea597a - main - Add elfctl to toolchain. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6081dea597a475e4bbcc8588ece03ae78b58978 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:34:51 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=c6081dea597a475e4bbcc8588ece03ae78b58978 commit c6081dea597a475e4bbcc8588ece03ae78b58978 Author: Marcin Wojtas AuthorDate: 2021-05-21 09:27:27 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-21 13:32:42 +0000 Add elfctl to toolchain. Add elfctl program to toolchain to allow modifying ELF feature flags during system build. Submitted by: Dawid Gorecki Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D29552 --- Makefile.inc1 | 8 +++++--- share/mk/sys.mk | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 5ae1ec72c279..5fd1fe81c2e7 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -199,7 +199,7 @@ MK_SYSTEM_LINKER= no .if defined(CROSS_TOOLCHAIN_PREFIX) CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX} .endif -XBINUTILS= AS AR LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN +XBINUTILS= AS AR ELFCTL LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN .for BINUTIL in ${XBINUTILS} .if defined(CROSS_BINUTILS_PREFIX) && \ exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}}) @@ -794,8 +794,8 @@ HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \ CPP="${XCPP} ${XCFLAGS}" \ - AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \ - NM=${XNM} OBJCOPY="${XOBJCOPY}" \ + AS="${XAS}" AR="${XAR}" ELFCTL="${XELFCTL}" LD="${XLD}" \ + LLVM_LINK="${XLLVM_LINK}" NM=${XNM} OBJCOPY="${XOBJCOPY}" \ RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \ SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}" @@ -2600,6 +2600,7 @@ _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \ .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no" _elftctools= lib/libelftc \ lib/libpe \ + usr.bin/elfctl \ usr.bin/objcopy \ usr.bin/nm \ usr.bin/size \ @@ -2613,6 +2614,7 @@ _elftctools+= usr.bin/addr2line # the target (for at least crunchide). _elftctools= lib/libelftc \ lib/libpe \ + usr.bin/elfctl \ usr.bin/objcopy .endif diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 8f456b28593a..89ac2c549656 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -210,6 +210,8 @@ ECHODIR ?= true .endif .endif +ELFCTL ?= elfctl + .if ${.MAKEFLAGS:M-N} # bmake -N is supposed to skip executing anything but it does not skip # exeucting '+' commands. The '+' feature is used where .MAKE From owner-dev-commits-src-main@freebsd.org Fri May 21 13:34:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 40407632916; Fri, 21 May 2021 13:34: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 4Fmnf503STz4qYp; Fri, 21 May 2021 13:34: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 9394A122D4; Fri, 21 May 2021 13:34: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 14LDYqRo004344; Fri, 21 May 2021 13:34:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LDYqoa004343; Fri, 21 May 2021 13:34:52 GMT (envelope-from git) Date: Fri, 21 May 2021 13:34:52 GMT Message-Id: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: af949c590bd8 - main - Disable stack gap for ntpd during build. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af949c590bd8a00a5973b5875d7e0fa6832ea64a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:34:53 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=af949c590bd8a00a5973b5875d7e0fa6832ea64a commit af949c590bd8a00a5973b5875d7e0fa6832ea64a Author: Marcin Wojtas AuthorDate: 2021-05-21 09:29:22 +0000 Commit: Marcin Wojtas CommitDate: 2021-05-21 13:33:06 +0000 Disable stack gap for ntpd during build. When starting, ntpd calls setrlimit(2) to limit maximum size of its stack. The stack limit chosen by ntpd is 200K, so when stack gap is enabled, the stack gap is larger than this limit, which results in ntpd crashing. Submitted by: Dawid Gorecki Reviewed by: cy, imp Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D29553 --- usr.sbin/ntp/ntpd/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.sbin/ntp/ntpd/Makefile b/usr.sbin/ntp/ntpd/Makefile index 2d8a8b9d2a2d..b9c3a05547d4 100644 --- a/usr.sbin/ntp/ntpd/Makefile +++ b/usr.sbin/ntp/ntpd/Makefile @@ -56,4 +56,7 @@ CLEANFILES+= .version version.c version.c: sh -e ${.CURDIR:H}/scripts/mkver ntpd +afterbuild: + ${ELFCTL} -e +noaslrstkgap ${PROG} + .include From owner-dev-commits-src-main@freebsd.org Fri May 21 13:37:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B7EF632B94 for ; Fri, 21 May 2021 13:37:17 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmnhr3GXgz4rYx for ; Fri, 21 May 2021 13:37:16 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qv1-xf32.google.com with SMTP id w9so10344432qvi.13 for ; Fri, 21 May 2021 06:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CSoPBpu6oONP8gXYJUsYdlHqkhvGXRkgBywH0KGxGMQ=; b=Y4BidaudvW2l0mrPoLk+yjbL2OYtV7t5WYOKFd3rWtmlVUOZ+9q2pp2zq6IuDpL/ZH ZZ6+P1pux5AfEqWgEnN3LxxziPvPJ0eaiTqJ13i4/FUMLFYRyQt0Q0NTKerqX59m9Uc+ J1y1fZro3LtVeLa6UIw/Om5A7qj+79EiwFFceKiTdZgbf7Vrb5ktFj1tGKGOozWDXD7R CUO+264ukfZBf7le8ucdLi6+J+Vq3PKWeR+9bjjfSFxEKZgkYsPgn5Etcy8JDJrQG2oy 7cdMp8XWetx6uxEUy3kWt+wAj0Rivu9uBBOhI26MCq0lA78cde+ahkoyFUPMf0+XsiRn yt8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CSoPBpu6oONP8gXYJUsYdlHqkhvGXRkgBywH0KGxGMQ=; b=RLZAET6SM/3jpKKV6XQVW0wi+OyDMRJy3CJiRr7P/2pzaK19Oas0rYL0gOanDi9AFh xRArkUCRQbe3bSWDRA2/rfMQnXqvJj6+jFKJGSstz5DrgyTPkfKctJkQwIDeEMg6/TDd yP7NG5zWWqBoY0YCwwdZQSIgB8n2n9b5JXY4WAsvIAx1YggQ51GeuEgyvr7/rTYZ6Jba ctCb3qVU1noIaM7SwC4Dq6VclnIveSZaIIO1liFpPZiAC6lHYiSu19MH+ZKBlIGfBJJC Nh/GsF2mf2il4u0L+zUUMuiJ6euR1OlJyUE/dkAAQkFfwFHWNJsoLd9C6yGIHyXYkvIp 5+pw== X-Gm-Message-State: AOAM5312p8wzl5BSPgI9MoajQIevxWnYjOqYl8BNxzmSnDHXvxlDDVH8 QZ30eznlZ2h1ydm4CXzFhjzlKA== X-Google-Smtp-Source: ABdhPJxXQBJVtFYhSr8HzvASkaRKKRX6ZgwMbP50yzWjtEh+7ioqkJveFeYNWHVjiCgfJDv1RNXkQQ== X-Received: by 2002:a05:6214:1921:: with SMTP id es1mr13072594qvb.0.1621604235529; Fri, 21 May 2021 06:37:15 -0700 (PDT) Received: from mutt-hbsd (pool-100-16-224-136.bltmmd.fios.verizon.net. [100.16.224.136]) by smtp.gmail.com with ESMTPSA id o5sm4588447qtl.85.2021.05.21.06.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 06:37:14 -0700 (PDT) Date: Fri, 21 May 2021 09:37:14 -0400 From: Shawn Webb To: Marcin Wojtas Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. Message-ID: <20210521133714.g5qpcs5wd4q27tya@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 14.0-CURRENT-HBSD FreeBSD 14.0-CURRENT-HBSD X-PGP-Key: https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/blob/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="acbqqhcrzins2o5s" Content-Disposition: inline In-Reply-To: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4Fmnhr3GXgz4rYx 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:37:17 -0000 --acbqqhcrzins2o5s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 21, 2021 at 01:34:52PM +0000, Marcin Wojtas wrote: > The branch main has been updated by mw: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b5875d= 7e0fa6832ea64a >=20 > commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > Author: Marcin Wojtas > AuthorDate: 2021-05-21 09:29:22 +0000 > Commit: Marcin Wojtas > CommitDate: 2021-05-21 13:33:06 +0000 >=20 > Disable stack gap for ntpd during build. > =20 > When starting, ntpd calls setrlimit(2) to limit maximum size of its > stack. The stack limit chosen by ntpd is 200K, so when stack gap > is enabled, the stack gap is larger than this limit, which results > in ntpd crashing. Would it make sense to update the stack limit enforcement code to take the stack gap into account? I haven't looked at HardenedBSD's stack randomization for a while, but if memory serves correctly, we made that change. Thanks, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --acbqqhcrzins2o5s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmCnt4cACgkQ/y5nonf4 4frnvBAApuiHsM1JvQ91oeMnrPWi6Z2vg7mPf8Hdi1UO1MoYHWzKuVvFahVix+w+ YTFVmQl4XO1aHNRb6IFC5uq1VBBFSSCCDNBJJFWqG73ZVjr0ezPQMBTVMVKs65G1 UhA9s719/90O3AcnGstwJ9iTPs7+HcWAie3doCjJaxDDrjTSI+mIuoOcN3mG/vj9 iZ8dwuxbsk1TvYtNzqRlx4hz+ZdcePIEEx46jMLn4zOnTa1c/ae54r+Y+D0J4+cB JJqutQoN+z8PVGBujJs/bgtt7kIVNxuq1HtQS4J/bLqgRaQcghvxNkYhUStkA28x ZOPD55X6UwZswr3i7SH0Dbq6uuyd0opEsPfdqQ6EmWbaCf0gxd6IPvr6VFO7nga5 D74hHuEKUqTsOyPs8PK8mm3nnRPJDlC7GzIFAmj8CiEbdXTXsIWtxt+U3Xa6gcEv Qti3zFUdp8Q4oaN52rkeyegiYBeCNEkeWjM+lEtJBBOWhFVlkcRslVtyEfE5McmY aZoLuE3528rU9AFNt4dS1XuTdkUTtZqVyDTml4ismTybkmvYxRPnSAhiVg2sT3iY 5gOxuzyk+pTKcS59it8AjiHGvsVIjsuxNM885ZJQ+4ojtD3LvRg88+Bx6czXcInG WaUj9GjIJ3oO9y2RrKSSLNT0LpM0bub1IxIPpwTyivDIf5RyHx8= =OVVc -----END PGP SIGNATURE----- --acbqqhcrzins2o5s-- From owner-dev-commits-src-main@freebsd.org Fri May 21 13:39:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD041632C89 for ; Fri, 21 May 2021 13:39:09 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmnl14FFMz4smH for ; Fri, 21 May 2021 13:39:09 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f53.google.com with SMTP id c14so19339594wrx.3 for ; Fri, 21 May 2021 06:39:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FnoP9vPOrJrN0+KwakORUxztPyvBEpTFp5LQ0FUQhtQ=; b=e8PdDo86Qv5Lnphi4wF4AdmL1QhBowOkS2ilRpgwVZTr6/E1dGPAm0OQpJ1lD/D0VU Sa99TS2HQEN2UIQJROvdSKTDk2rKNU9rycsD6qg3XtPOJLS0Be6aJIN1oY+8Y1ds+lmz bkOufX/UC5Ms4E8431oTSnrpgsID2bBhHQPWxkKHPNwvog+NECETdaG0CnSS+llDPklf l3wwsQr7nxrvBQgMehQlYXYoEMhtGreDJNJmpoF2QuorFn8EUmNnPv3zuUjGUHktLqwQ 7geF3ga8Mi0aFBcaLD+PuNsMExR2q2+vhmdkf++bqv6NJWexrj7x9jfPpFtQOQ0Oy8e5 eYAg== X-Gm-Message-State: AOAM531MU6rhg+FmGX+QbCD19+3/eHGGWD++UpVXHm2mhiEBp6ORVlv5 mBqG89edu34tZ/qxgKeokt/bXA== X-Google-Smtp-Source: ABdhPJxtlWSkV2K+oceijHqYVqObayuU45CPygfcd1M5CK9+UFWSP6zTqOJWovqMuDWi9EA3lCZYfQ== X-Received: by 2002:a5d:59a4:: with SMTP id p4mr10024247wrr.248.1621604347960; Fri, 21 May 2021 06:39:07 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id c12sm2341000wrr.90.2021.05.21.06.39.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 May 2021 06:39:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. From: Jessica Clarke In-Reply-To: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> Date: Fri, 21 May 2021 14:39:06 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> To: Marcin Wojtas X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4Fmnl14FFMz4smH 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 13:39:09 -0000 On 21 May 2021, at 14:34, Marcin Wojtas wrote: >=20 > The branch main has been updated by mw: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b5875d7e0fa6= 832ea64a >=20 > commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > Author: Marcin Wojtas > AuthorDate: 2021-05-21 09:29:22 +0000 > Commit: Marcin Wojtas > CommitDate: 2021-05-21 13:33:06 +0000 >=20 > Disable stack gap for ntpd during build. >=20 > When starting, ntpd calls setrlimit(2) to limit maximum size of its > stack. The stack limit chosen by ntpd is 200K, so when stack gap > is enabled, the stack gap is larger than this limit, which results > in ntpd crashing. Isn=E2=80=99t the bug that the unusable gap counts as usage? Jess From owner-dev-commits-src-main@freebsd.org Fri May 21 14:11:38 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBE1A633755 for ; Fri, 21 May 2021 14:11:38 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmpSV4TQQz3QKr for ; Fri, 21 May 2021 14:11:38 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-qk1-x731.google.com with SMTP id i5so12582386qkf.12 for ; Fri, 21 May 2021 07:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=RhDjwBklaIBDR8oby7gettn6bdTQ5xD+H7vR/fEk7ns=; b=U/EXKUXZUtcuScw/yBlhiZIBQVEQxKb5vaLwF4abTqhoVIHYi9Ll2b/4q0R1crMuQc qH0EkAufY09a3S4/oEX9xP1WIpMLsZz1P1fScDoi4J3N4DXbGCemoYaI0nl7ctPNCmtb 2iBlk1Knjgd+Poe7GI3ZLvxnAWWXZnmQCpXuwWQ40rMWlGwP0CtNlWepBPBgrmb1cErn Pf2SYXeery35Lk75vBGROGZOeRuudR6Y6EbxCrb/o2YxGhvgs812ddRqmlmHAa6XaAtR djLu7fLVK1KuobJj5zNVaaNkEItLlKb/lJMUtez811SlY8l00LKb/wxc/qbPt3HV05hR RtGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=RhDjwBklaIBDR8oby7gettn6bdTQ5xD+H7vR/fEk7ns=; b=Je46kSc5uckKhVfmY6tHjRPu2mHHncUp/mgQBbt52SWLYG5V/RNWj9oiM14qqrrYfq ABuSJNLPffGuCKBmWnZlq0e28JtlumlPDHjJMfLGPtv2YwSlJv0Y8Jx1kgx7wcntzZdw U0nIdhjhMd2unNeV3/zD5OmIzY6yBpvo/FhkPaWLieyT72VTMdGkxFaZixGFXFNEUsu8 tOZpvwOFaG6XCxWaPEU8nkzWPmzsQ56q0eMqHidXXXI4iWhmCNWd1GCwwVT7rwfZj6fx u5ETcOQlVP/YeFkZpbQi9C+c8UeafziGHaRWjGFdQUpM65+b8LYDPy2n8zM6yzlt3nsK Mz/Q== X-Gm-Message-State: AOAM530eUhNL63wDPX1Kc1DCpwOkCy7csuy134GRI0ChlA6xI93CCDIo 1101TiljtcjIhIinhWwQe9pNBS8uXeYflGO+9V0/4w== X-Google-Smtp-Source: ABdhPJyqnEWijB/41rLoJSltLnpTA1rch/rGkbRU8jjdiIw8x7Ywb67/c9/+oaaKD9XLK/ULsLwNarq21tz9H4bgbPg= X-Received: by 2002:a05:620a:2a0f:: with SMTP id o15mr12118873qkp.295.1621606297698; Fri, 21 May 2021 07:11:37 -0700 (PDT) MIME-Version: 1.0 References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> In-Reply-To: <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> From: Marcin Wojtas Date: Fri, 21 May 2021 16:11:25 +0200 Message-ID: Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. To: Jessica Clarke , shawn.webb@hardenedbsd.org Cc: Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4FmpSV4TQQz3QKr 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:11:38 -0000 Hi Jess pt., 21 maj 2021 o 15:39 Jessica Clarke napisa=C5=82(a= ): > > On 21 May 2021, at 14:34, Marcin Wojtas wrote: > > > > The branch main has been updated by mw: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b587= 5d7e0fa6832ea64a > > > > commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > > Author: Marcin Wojtas > > AuthorDate: 2021-05-21 09:29:22 +0000 > > Commit: Marcin Wojtas > > CommitDate: 2021-05-21 13:33:06 +0000 > > > > Disable stack gap for ntpd during build. > > > > When starting, ntpd calls setrlimit(2) to limit maximum size of its > > stack. The stack limit chosen by ntpd is 200K, so when stack gap > > is enabled, the stack gap is larger than this limit, which results > > in ntpd crashing. > > Isn=E2=80=99t the bug that the unusable gap counts as usage? > > Jess > An alternative solution was submitted (https://reviews.freebsd.org/D29832), so that to extend the limit for ntpd, but eventually it was recommended to simple disable the stack gap for it until it's fixed upstream (see the last comment in the linked revision). Best regards, Marcin From owner-dev-commits-src-main@freebsd.org Fri May 21 14:15:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1525F6339A8 for ; Fri, 21 May 2021 14:15:46 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmpYF4xfJz3QYN for ; Fri, 21 May 2021 14:15:45 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f43.google.com with SMTP id x7so1632482wrt.12 for ; Fri, 21 May 2021 07:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ppNB69zkX8u8jBuNS1pCw/RXEsO2qqqDhDzxpvlnEDo=; b=obyBSuhe0WyvQNS6At5oI2FgQL6clRkHjB6znewAaQDRGY15dtC8tqiQ/4AaQDDPsU hDT9uYvnPaErsaiap2T5LHiwtLv5tyfp1ZLQTk2uoqVdArZ+nxvFDLM/QBezLuhh2ZC0 aWdhmRIPVVdDW4TLdBt3+x6WqcbEWNgpaj9iTrVFteo8Yb3ca/+wyUNdivuvAc0Bn7lw zt35lpg+a3e+lU1FbK8rodeFQ0r1O9GK7f8FdAzojdzOzxwTUZyw1zm21W7sYrhVmKwW p0WI/K6bHlRsHAdyUHzMYLEYaMNqVndZmxAQmUgDNPYIoqo9yxb+sdashxmLZSGPsaYm flWg== X-Gm-Message-State: AOAM531PLoBpM47YKjWMDhsUUsa7P7P3wl2ppfqFXcQoxztEICLTiE85 4dHiYETWIqWdIipq7sdaQqH6oA== X-Google-Smtp-Source: ABdhPJygD1b5xtLY/rqAmPGxcMIp+QlkHLJa9OvQd3sqWfsL4T/2jxv2aqprzFUBZKhDTza0q4bqVA== X-Received: by 2002:a5d:6803:: with SMTP id w3mr9838122wru.285.1621606544666; Fri, 21 May 2021 07:15:44 -0700 (PDT) Received: from [192.168.150.48] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id y2sm2325256wrl.92.2021.05.21.07.15.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 May 2021 07:15:44 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. From: Jessica Clarke In-Reply-To: Date: Fri, 21 May 2021 15:15:43 +0100 Cc: shawn.webb@hardenedbsd.org, Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> To: Marcin Wojtas X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FmpYF4xfJz3QYN 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:15:46 -0000 > On 21 May 2021, at 15:11, Marcin Wojtas wrote: >=20 > Hi Jess >=20 > pt., 21 maj 2021 o 15:39 Jessica Clarke = napisa=C5=82(a): >>=20 >> On 21 May 2021, at 14:34, Marcin Wojtas wrote: >>>=20 >>> The branch main has been updated by mw: >>>=20 >>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b5875d7e0fa6= 832ea64a >>>=20 >>> commit af949c590bd8a00a5973b5875d7e0fa6832ea64a >>> Author: Marcin Wojtas >>> AuthorDate: 2021-05-21 09:29:22 +0000 >>> Commit: Marcin Wojtas >>> CommitDate: 2021-05-21 13:33:06 +0000 >>>=20 >>> Disable stack gap for ntpd during build. >>>=20 >>> When starting, ntpd calls setrlimit(2) to limit maximum size of = its >>> stack. The stack limit chosen by ntpd is 200K, so when stack gap >>> is enabled, the stack gap is larger than this limit, which results >>> in ntpd crashing. >>=20 >> Isn=E2=80=99t the bug that the unusable gap counts as usage? >>=20 >> Jess >>=20 >=20 > An alternative solution was submitted > (https://reviews.freebsd.org/D29832), so that to extend the limit for > ntpd, but eventually it was recommended to simple disable the stack > gap for it until it's fixed upstream (see the last comment in the > linked revision). That=E2=80=99s my point, there is nothing to =E2=80=9Cfix=E2=80=9D = upstream. NTPD uses less than 200K of stack, thus it is perfectly reasonable for it to set its limit to = that. The fact that FreeBSD decides to count an arbitrary, non-deterministic = amount of additional unusable virtual address space towards that limit is not its = fault, but a bug in FreeBSD that needs to be fixed as it=E2=80=99s entirely = unreasonable for applications to have to account for that. Jess From owner-dev-commits-src-main@freebsd.org Fri May 21 14:17:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 331EE633B4F for ; Fri, 21 May 2021 14:17:47 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmpbb09l6z3hcZ for ; Fri, 21 May 2021 14:17:46 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk1-x72b.google.com with SMTP id q10so19848009qkc.5 for ; Fri, 21 May 2021 07:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=v8f56cGYfUTiFhL3KQjhHcq07x9plt72zDvEsui2CFs=; b=HfK7c/CZCMqzdET1wT+48pSJZVnfQgT5wvzilqR54BC893v7j1NDhPlL0og9l4t9WF 4l3uK7dTEYwG1pUMaARV3tfupDTnP7f5kkS6Tqx+1ltMWlEo5VElfj7QBwy3zciEC7wH KBd7f2mxY1M+YI3BtR/RISUNNxLN34s4wCSLugjck1MzoglopZLVgQYF54/T1IzhRx6y FJFSKbN7v0B8dA20A95gNUO1MMwJxrS4pzPacNdjazVrSA+96Z4KTFB4B19TN8YVPJ/n yKSUm1/iKTdN4rgRP+hRtBkaVcYFqjU0cmn8TPO9mbUDpP3mryPoQoloun/OqRdbhOsP TWow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=v8f56cGYfUTiFhL3KQjhHcq07x9plt72zDvEsui2CFs=; b=aP+YWQa0rcp2VaTqOYjjaqOMUjTp2cYwhL724534P31fgN43l0apaRMefQfvCbRMBG WZ2K/P1kTFLqE/HAFoiv4Wed+kQ2qLAD2BzfoD9CHw7Tk5gahn5IBJWM57GzfviHZF04 BvvfOorGiRZ5yz7BzCbnQa23UTELM+pdFPJE0yr/+9zhC0hIT/CjLr0Mu/HpbHtXnHEz Cy1DDhDvDYbracB0Muwa/0Gc4lxgIU/fzXLspEDZj0yj6DtgJrg9a02gF/oKBRevxr6j LUslk0kbTNej8jefKrXQaKiIGdemUMxRm6ZKSWOJ89utgp3cWrMqhbZ+Na3InOX76tG4 Qo3Q== X-Gm-Message-State: AOAM532nz/uHPk0Yh8Y8xLT+mAvydvMsO0Lv8TnDHU2bHgj8lzyD1wtx rs//AebSBDkIutqEIPKcJhPAag== X-Google-Smtp-Source: ABdhPJzy9omNkr6fQ/qF9QTr56wLpPPi0RvzRNGfoUw1B8u43bHXIHoGj6cwGjfvogtUdjGtCVP69A== X-Received: by 2002:a37:4697:: with SMTP id t145mr12495233qka.188.1621606666257; Fri, 21 May 2021 07:17:46 -0700 (PDT) Received: from mutt-hbsd (pool-100-16-224-136.bltmmd.fios.verizon.net. [100.16.224.136]) by smtp.gmail.com with ESMTPSA id q13sm5008168qkn.10.2021.05.21.07.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 07:17:45 -0700 (PDT) Date: Fri, 21 May 2021 10:17:44 -0400 From: Shawn Webb To: Jessica Clarke Cc: Marcin Wojtas , Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. Message-ID: <20210521141744.pszt7s6l65h6jgtm@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 14.0-CURRENT-HBSD FreeBSD 14.0-CURRENT-HBSD X-PGP-Key: https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/blob/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ensr6kx62mdtqzwo" Content-Disposition: inline In-Reply-To: <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> X-Rspamd-Queue-Id: 4Fmpbb09l6z3hcZ 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:17:47 -0000 --ensr6kx62mdtqzwo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 21, 2021 at 03:15:43PM +0100, Jessica Clarke wrote: > > On 21 May 2021, at 15:11, Marcin Wojtas wrote: > >=20 > > Hi Jess > >=20 > > pt., 21 maj 2021 o 15:39 Jessica Clarke napisa=C5= =82(a): > >>=20 > >> On 21 May 2021, at 14:34, Marcin Wojtas wrote: > >>>=20 > >>> The branch main has been updated by mw: > >>>=20 > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b5= 875d7e0fa6832ea64a > >>>=20 > >>> commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > >>> Author: Marcin Wojtas > >>> AuthorDate: 2021-05-21 09:29:22 +0000 > >>> Commit: Marcin Wojtas > >>> CommitDate: 2021-05-21 13:33:06 +0000 > >>>=20 > >>> Disable stack gap for ntpd during build. > >>>=20 > >>> When starting, ntpd calls setrlimit(2) to limit maximum size of its > >>> stack. The stack limit chosen by ntpd is 200K, so when stack gap > >>> is enabled, the stack gap is larger than this limit, which results > >>> in ntpd crashing. > >>=20 > >> Isn=E2=80=99t the bug that the unusable gap counts as usage? > >>=20 > >> Jess > >>=20 > >=20 > > An alternative solution was submitted > > (https://reviews.freebsd.org/D29832), so that to extend the limit for > > ntpd, but eventually it was recommended to simple disable the stack > > gap for it until it's fixed upstream (see the last comment in the > > linked revision). >=20 > That=E2=80=99s my point, there is nothing to =E2=80=9Cfix=E2=80=9D upstre= am. NTPD uses less than 200K > of stack, thus it is perfectly reasonable for it to set its limit to that= =2E The > fact that FreeBSD decides to count an arbitrary, non-deterministic amount= of > additional unusable virtual address space towards that limit is not its f= ault, > but a bug in FreeBSD that needs to be fixed as it=E2=80=99s entirely unre= asonable for > applications to have to account for that. Also: Disabling randomization of any part of the address space makes randomization other parts of the address space moot. Toggling ASLR should be all-or-nothing. Especially true for randomizing the stack. Thanks, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A= 4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc --ensr6kx62mdtqzwo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAmCnwQYACgkQ/y5nonf4 4fp3cQ//Vph+hclAo5YCOAElLn/5LTAEvw0pLVk3jzsNvavVOKHOABt9sEd07LVC TFlcManAZFHUs2KWTKRkZGwtp/xpUD/R/jfg8biP16aZGmGc/rD2n5B4jTPxSz2j hcD4h0jmNkhNxOR1KOsioKXUw0vEYs7qHhe07KaeIyA1RlM17typ570DBW+zB5ws u1PGx3Va89wsaV5SZkKjNZsjJMkGEElVY6ryF8YNCwEHpix8WbwIc070OHdDJ043 i7Xw2JTk8GUOfRralDtdOW/uoZd56Ci9qxsXs8Xl6cAtHkglO/L277FU4RHfwVcm iIHPbxgZEGl0007MdyglgjaDxTfR8KXP1Z7RKkvz4WIlWlhl3d2QcOq9zoXhWyWF +iSzDe+tweDfgi+71fzX7oSn/u1lSWJbJGVVHwkxQha7IXGnPa3fDt1maSXaxZSh IOFnIc7FM9uVyqfoFtUtbhkGvjPwR0rUOK2+qaXUQ5FuGkzYMJ8qA2Xflwu91Dzz OxzOLbNsYkvPT2xnp+huasvvmTKQNeHYigF+yGEO+mBEBZA0tbbjyCgZF25RI0u1 PeeiHZl/1GG1Kz8TlKU35JJjdb+zyF3Kp1OZWtZo9o5WChHvle4pGb5CNE+Li01k ZWspFA2LRe53GJQ+KHkYMndfuJyj/SK/NqDCz6C0fruPloy8ze8= =DGeC -----END PGP SIGNATURE----- --ensr6kx62mdtqzwo-- From owner-dev-commits-src-main@freebsd.org Fri May 21 14:43:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9514634504; Fri, 21 May 2021 14:43:31 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmq9H12xfz3w7S; Fri, 21 May 2021 14:43:30 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.66.148.124]) by shaw.ca with ESMTPA id k6N3l4ZxxiLmnk6N5lAWYc; Fri, 21 May 2021 08:43:29 -0600 X-Authority-Analysis: v=2.4 cv=W+Nb6Tak c=1 sm=1 tr=0 ts=60a7c711 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=8nJEP1OIZ-IA:10 a=5FLXtPjwQuUA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=Gai371H0N15RG5sVgL4A:9 a=wPNLvfGTeEIA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 465BDA01; Fri, 21 May 2021 07:43:25 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 14LEhO0e099047; Fri, 21 May 2021 07:43:25 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202105211443.14LEhO0e099047@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Marcin Wojtas cc: Jessica Clarke , shawn.webb@hardenedbsd.org, Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. In-reply-to: References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> Comments: In-reply-to Marcin Wojtas message dated "Fri, 21 May 2021 16:11:25 +0200." Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 21 May 2021 07:43:24 -0700 X-CMAE-Envelope: MS4xfCn6psuItIPV0g+P+/I1oYNYBtBppOQPS2TwASh9XC5AiXRNbAuxv0Mw2uBb1QgQ2p93nBkDXN7+/rnhQadCgyPMXJy0phr4r1G6gX0lhsn2x+e6Fg22 PWd3sXI+yzGhxB7ED5FRPvMf6JTgQYixAAEznEgUw1K8pOB/DRFYVwadCbAit4d8wN0Xt9SufETDz73lYXqUgF7P4nY6WWV0hVb0alXwEXZaH2a5pvbwn8ix FcufhegnoEtESnAteiOk+wYN4vcgoKIjTJsrhI5UcjwCJs8FcTwQ5bLvpsv3UzYxskfxDVkXIxSXPeVz4ivxB5jmMienxKBtGq4Tq7rjCrP9F32HZWSD+vfy 2HizAQCEnTtFjId/Uw6X//IsMfV6LNsGGRiJg3we8lXMn91woEX1ZNwT7a/iw6Fq4UXq8lrI X-Rspamd-Queue-Id: 4Fmq9H12xfz3w7S 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:43:31 -0000 In message , Marcin Wojtas writes: > Hi Jess > > pt., 21 maj 2021 o 15:39 Jessica Clarke napisał(a): > > > > On 21 May 2021, at 14:34, Marcin Wojtas wrote: > > > > > > The branch main has been updated by mw: > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=af949c590bd8a00a5973b5875d7e > 0fa6832ea64a > > > > > > commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > > > Author: Marcin Wojtas > > > AuthorDate: 2021-05-21 09:29:22 +0000 > > > Commit: Marcin Wojtas > > > CommitDate: 2021-05-21 13:33:06 +0000 > > > > > > Disable stack gap for ntpd during build. > > > > > > When starting, ntpd calls setrlimit(2) to limit maximum size of its > > > stack. The stack limit chosen by ntpd is 200K, so when stack gap > > > is enabled, the stack gap is larger than this limit, which results > > > in ntpd crashing. > > > > Isn’t the bug that the unusable gap counts as usage? > > > > Jess > > > > An alternative solution was submitted > (https://reviews.freebsd.org/D29832), so that to extend the limit for > ntpd, but eventually it was recommended to simple disable the stack > gap for it until it's fixed upstream (see the last comment in the > linked revision). D29832 doesn't work. D29832 addressed the *already solved* stack gap issue in ntpd. The problem people failed to realize was that it wasn't stack gap but PIE. Enabling PIE regardless of the stack gap sysctl setting always resulted in the error. Ultimately a sledgehammer approach was the only way to address it. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-main@freebsd.org Fri May 21 14:46:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ACB3D6344A2; Fri, 21 May 2021 14:46:12 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmqDN1LBsz4S4s; Fri, 21 May 2021 14:46:11 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.66.148.124]) by shaw.ca with ESMTPA id k6Phl4avriLmnk6PilAX5H; Fri, 21 May 2021 08:46:10 -0600 X-Authority-Analysis: v=2.4 cv=W+Nb6Tak c=1 sm=1 tr=0 ts=60a7c7b3 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=8nJEP1OIZ-IA:10 a=5FLXtPjwQuUA:10 a=6I5d2MoRAAAA:8 a=oCJs8q-oAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=c9e1ACnJ86l144AVqQ8A:9 a=wPNLvfGTeEIA:10 a=IjZwj45LgO3ly-622nXo:22 a=qUF70SbvcHBaGhGVny9j:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 1DFC9A08; Fri, 21 May 2021 07:46:09 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 14LEk8kZ009266; Fri, 21 May 2021 07:46:08 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202105211446.14LEk8kZ009266@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Jessica Clarke cc: Marcin Wojtas , shawn.webb@hardenedbsd.org, Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. In-reply-to: <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> Comments: In-reply-to Jessica Clarke message dated "Fri, 21 May 2021 15:15:43 +0100." Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 21 May 2021 07:46:08 -0700 X-CMAE-Envelope: MS4xfPABxL12k0lLku+u3r6gRPOld04lO+I9IJyc/NvtPipNO3O5C4T30UocazY7qgC63U4IGNLi/CKtRCt4jbj/P/NuIEJKfCVpN0FSq013bazM5QELojZx nIO8HU9NPQROc8fx0vEcaNDmJQwvCzji1v3iWgY3Ei0I+6PdYVhOfh7Jb5tD0DfZsyUI1bk8M8ywBx7b1XgeFa46IisM1ZRXtOG291edrQpuCmmpsGyFKlUi soPXCz1vAxPZfcXk1iR1HQt5dNhknkIHY13qK5EQBCO+FeU71zMKH2qbTIymqwop+o7rRiu86JAqeVW2lwfRv7T530c1EheGgo0sl4ydD/BtbbWuWnREcXFc +GrlmK5LpCQvS7JeF+zlssQ48vkZlS+U5TsoFYlImB2q3Aj4CBoNfJGSfKfa1MBfKQVRWdyk X-Rspamd-Queue-Id: 4FmqDN1LBsz4S4s 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:46:12 -0000 In message <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org>, Jessica Clarke w rites: > > On 21 May 2021, at 15:11, Marcin Wojtas wrote: > > > > Hi Jess > > > > pt., 21 maj 2021 o 15:39 Jessica Clarke napisał(a): > >> > >> On 21 May 2021, at 14:34, Marcin Wojtas wrote: > >>> > >>> The branch main has been updated by mw: > >>> > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=af949c590bd8a00a5973b5875d7e > 0fa6832ea64a > >>> > >>> commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > >>> Author: Marcin Wojtas > >>> AuthorDate: 2021-05-21 09:29:22 +0000 > >>> Commit: Marcin Wojtas > >>> CommitDate: 2021-05-21 13:33:06 +0000 > >>> > >>> Disable stack gap for ntpd during build. > >>> > >>> When starting, ntpd calls setrlimit(2) to limit maximum size of its > >>> stack. The stack limit chosen by ntpd is 200K, so when stack gap > >>> is enabled, the stack gap is larger than this limit, which results > >>> in ntpd crashing. > >> > >> Isn’t the bug that the unusable gap counts as usage? > >> > >> Jess > >> > > > > An alternative solution was submitted > > (https://reviews.freebsd.org/D29832), so that to extend the limit for > > ntpd, but eventually it was recommended to simple disable the stack > > gap for it until it's fixed upstream (see the last comment in the > > linked revision). > > That’s my point, there is nothing to “fix” upstream. NTPD uses less tha > n 200K > of stack, thus it is perfectly reasonable for it to set its limit to that. Th > e > fact that FreeBSD decides to count an arbitrary, non-deterministic amount of > additional unusable virtual address space towards that limit is not its fault > , > but a bug in FreeBSD that needs to be fixed as it’s entirely unreasonable f > or > applications to have to account for that. This latest problem is not stack gap. It is PIE. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-main@freebsd.org Fri May 21 14:52:15 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E99C96348A0; Fri, 21 May 2021 14: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 4FmqMM61d8z4TWY; Fri, 21 May 2021 14:52:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96DB613323; Fri, 21 May 2021 14: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 14LEqF1G010615; Fri, 21 May 2021 14:52:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LEqFjZ010614; Fri, 21 May 2021 14:52:15 GMT (envelope-from git) Date: Fri, 21 May 2021 14:52:15 GMT Message-Id: <202105211452.14LEqFjZ010614@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 788401188f95 - main - scsi(4): fix "NMVe" typo MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 788401188f950001cd9796cdcea9a7e5f92050ab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:52:16 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=788401188f950001cd9796cdcea9a7e5f92050ab commit 788401188f950001cd9796cdcea9a7e5f92050ab Author: Mitchell Horne AuthorDate: 2021-05-21 14:50:15 +0000 Commit: Mitchell Horne CommitDate: 2021-05-21 14:51:45 +0000 scsi(4): fix "NMVe" typo --- share/man/man4/scsi.4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/scsi.4 b/share/man/man4/scsi.4 index b2ed3a7eb5e5..d3f92fd6b8bb 100644 --- a/share/man/man4/scsi.4 +++ b/share/man/man4/scsi.4 @@ -56,7 +56,7 @@ subsystem provides a uniform and modular system for the implementation of drivers to control various .Tn SCSI , .Tn ATA , -.Tn NMVe , +.Tn NVMe , and .Tn MMC / SD devices, and to utilize different From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37D616364EB; Fri, 21 May 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 4FmryN0hZSz3JBr; Fri, 21 May 2021 16:04: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 F197414375; Fri, 21 May 2021 16:04: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 14LG4BVe005026; Fri, 21 May 2021 16:04:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4BWs005025; Fri, 21 May 2021 16:04:11 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:11 GMT Message-Id: <202105211604.14LG4BWs005025@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: af2253f61c43 - main - mmccam: Add two new XPT for MMC and use them in mmc_sim and sdhci MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af2253f61c43a7608cdf6995701c1dc361320064 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:12 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=af2253f61c43a7608cdf6995701c1dc361320064 commit af2253f61c43a7608cdf6995701c1dc361320064 Author: Emmanuel Vadot AuthorDate: 2021-04-29 15:48:49 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:34:05 +0000 mmccam: Add two new XPT for MMC and use them in mmc_sim and sdhci For the discovery phase of SD/eMMC we need to do some transaction in a async way. The classic CAM XPT_{GET,SET}_TRAN_SETTING cannot be used in a async way. This also allow us to split the discovery phase into a more complete state machine and we don't mtx_sleep with a random number to wait for completion of the tasks. For mmc_sim we now do the SET_TRAN_SETTING in a taskqueue so we can call the needed function for regulators/clocks without the cam lock(s). This part is still needed to be done for sdhci. We also now save the host OCR in the discovery phase as it wasn't done before and only worked because the same ccb was reused. Reviewed by: imp, kibab, bz Differential Revision: https://reviews.freebsd.org/D30038 --- sys/cam/cam_ccb.h | 3 ++ sys/cam/cam_xpt.c | 2 + sys/cam/mmc/mmc_sim.c | 45 ++++++++++++++++++++- sys/cam/mmc/mmc_sim.h | 4 ++ sys/cam/mmc/mmc_xpt.c | 109 ++++++++++++++++++++++++++++++++++++++------------ sys/dev/sdhci/sdhci.c | 2 + 6 files changed, 137 insertions(+), 28 deletions(-) diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h index 2545e40e192d..3a01cde1a442 100644 --- a/sys/cam/cam_ccb.h +++ b/sys/cam/cam_ccb.h @@ -253,6 +253,9 @@ typedef enum { XPT_REPROBE_LUN = 0x38 | XPT_FC_QUEUED | XPT_FC_USER_CCB, /* Query device capacity and notify GEOM */ + XPT_MMC_SET_TRAN_SETTINGS = 0x40 | XPT_FC_DEV_QUEUED, + XPT_MMC_GET_TRAN_SETTINGS = 0x41 | XPT_FC_DEV_QUEUED, + /* Vendor Unique codes: 0x80->0x8F */ XPT_VUNIQUE = 0x80 } xpt_opcode; diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 33361cfb68a5..91bac149c061 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -2702,6 +2702,8 @@ xpt_action_default(union ccb *start_ccb) case XPT_NVME_IO: case XPT_NVME_ADMIN: case XPT_MMC_IO: + case XPT_MMC_GET_TRAN_SETTINGS: + case XPT_MMC_SET_TRAN_SETTINGS: case XPT_RESET_DEV: case XPT_ENG_EXEC: case XPT_SMP_IO: diff --git a/sys/cam/mmc/mmc_sim.c b/sys/cam/mmc/mmc_sim.c index 03269a0b3d4d..1500e3f6f1cd 100644 --- a/sys/cam/mmc/mmc_sim.c +++ b/sys/cam/mmc/mmc_sim.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2020 Emmanuel Vadot + * Copyright (c) 2020-2021 Emmanuel Vadot * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -50,6 +50,30 @@ mmc_cam_default_poll(struct cam_sim *sim) return; } +static void +mmc_sim_task(void *arg, int pending) +{ + struct mmc_sim *mmc_sim; + struct ccb_trans_settings *cts; + int rv; + + mmc_sim = arg; + + if (mmc_sim->ccb == NULL) + return; + + cts = &mmc_sim->ccb->cts; + rv = MMC_SIM_SET_TRAN_SETTINGS(mmc_sim->dev, &cts->proto_specific.mmc); + if (rv != 0) + mmc_sim->ccb->ccb_h.status = CAM_REQ_INVALID; + else + mmc_sim->ccb->ccb_h.status = CAM_REQ_CMP; + + xpt_done(mmc_sim->ccb); + mmc_sim->ccb = NULL; +} + + static void mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) { @@ -67,6 +91,12 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) mtx_assert(&mmc_sim->mtx, MA_OWNED); + if (mmc_sim->ccb != NULL) { + ccb->ccb_h.status = CAM_BUSY; + xpt_done(ccb); + return; + } + switch (ccb->ccb_h.func_code) { case XPT_PATH_INQ: rv = MMC_SIM_GET_TRAN_SETTINGS(mmc_sim->dev, &mmc); @@ -78,6 +108,7 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) } break; case XPT_GET_TRAN_SETTINGS: + case XPT_MMC_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; @@ -105,6 +136,15 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) ccb->ccb_h.status = CAM_REQ_CMP; break; } + case XPT_MMC_SET_TRAN_SETTINGS: + { + ccb->ccb_h.status = CAM_SIM_QUEUED; + mmc_sim->ccb = ccb; + taskqueue_enqueue(taskqueue_thread, &mmc_sim->sim_task); + return; + /* NOTREACHED */ + break; + } case XPT_RESET_BUS: ccb->ccb_h.status = CAM_REQ_CMP; break; @@ -112,7 +152,7 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb) { rv = MMC_SIM_CAM_REQUEST(mmc_sim->dev, ccb); if (rv != 0) - ccb->ccb_h.status = CAM_REQ_INPROG; + ccb->ccb_h.status = CAM_SIM_QUEUED; else ccb->ccb_h.status = CAM_REQ_INVALID; return; @@ -163,6 +203,7 @@ mmc_cam_sim_alloc(device_t dev, const char *name, struct mmc_sim *mmc_sim) } mtx_unlock(&mmc_sim->mtx); + TASK_INIT(&mmc_sim->sim_task, 0, mmc_sim_task, mmc_sim); return (0); diff --git a/sys/cam/mmc/mmc_sim.h b/sys/cam/mmc/mmc_sim.h index 629144656e51..2b1159a9758e 100644 --- a/sys/cam/mmc/mmc_sim.h +++ b/sys/cam/mmc/mmc_sim.h @@ -28,12 +28,16 @@ #ifndef __MMC_SIM_H__ #define __MMC_SIM_H__ +#include + struct mmc_sim { struct mmc_cam_sim_softc *sc; struct mtx mtx; struct cam_devq *devq; struct cam_sim *sim; device_t dev; + struct task sim_task; + union ccb *ccb; }; int mmc_cam_sim_alloc(device_t dev, const char *name, struct mmc_sim *mmc_sim); diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c index 847fd7cdb412..6b2fecdab0fb 100644 --- a/sys/cam/mmc/mmc_xpt.c +++ b/sys/cam/mmc/mmc_xpt.c @@ -90,6 +90,12 @@ static void mmc_proto_debug_out(union ccb *ccb); typedef enum { PROBE_RESET, PROBE_IDENTIFY, + PROBE_POWER_OFF, + PROBE_GET_HOST_OCR, + PROBE_RESET_BUS, + PROBE_SET_ID_FREQ, + PROBE_SET_CS, + PROBE_GO_IDLE_STATE, PROBE_SDIO_RESET, PROBE_SEND_IF_COND, PROBE_SDIO_INIT, @@ -107,6 +113,12 @@ typedef enum { static char *probe_action_text[] = { "PROBE_RESET", "PROBE_IDENTIFY", + "PROBE_POWER_OFF", + "PROBE_GET_HOST_OCR", + "PROBE_RESET_BUS", + "PROBE_SET_ID_FREQ", + "PROBE_SET_CS", + "PROBE_GO_IDLE_STATE", "PROBE_SDIO_RESET", "PROBE_SEND_IF_COND", "PROBE_SDIO_INIT", @@ -165,6 +177,7 @@ typedef struct { probe_action action; int restart; union ccb saved_ccb; + uint32_t host_ocr; uint32_t flags; #define PROBE_FLAG_ACMD_SENT 0x1 /* CMD55 is sent, card expects ACMD */ #define PROBE_FLAG_HOST_CAN_DO_18V 0x2 /* Host can do 1.8V signaling */ @@ -584,7 +597,6 @@ mmcprobe_start(struct cam_periph *periph, union ccb *start_ccb) mmcprobe_softc *softc; struct cam_path *path; struct ccb_mmcio *mmcio; - struct mtx *p_mtx = cam_periph_mtx(periph); struct ccb_trans_settings_mmc *cts; CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("mmcprobe_start\n")); @@ -612,25 +624,29 @@ mmcprobe_start(struct cam_periph *periph, union ccb *start_ccb) case PROBE_IDENTIFY: xpt_path_inq(&start_ccb->cpi, periph->path); CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("Start with PROBE_IDENTIFY\n")); - init_standard_ccb(start_ccb, XPT_GET_TRAN_SETTINGS); - xpt_action(start_ccb); - if (cts->ios.power_mode != power_off) { - init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); - cts->ios.power_mode = power_off; - cts->ios_valid = MMC_PM; - xpt_action(start_ccb); - mtx_sleep(periph, p_mtx, 0, "mmcios", 100); - } - /* mmc_power_up */ - /* Get the host OCR */ - init_standard_ccb(start_ccb, XPT_GET_TRAN_SETTINGS); - xpt_action(start_ccb); + init_standard_ccb(start_ccb, XPT_MMC_GET_TRAN_SETTINGS); + break; + + case PROBE_POWER_OFF: + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("power off the card\n")); + init_standard_ccb(start_ccb, XPT_MMC_SET_TRAN_SETTINGS); + cts->ios.power_mode = power_off; + cts->ios_valid = MMC_PM; + break; + + case PROBE_GET_HOST_OCR: + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("get the host ocr\n")); + init_standard_ccb(start_ccb, XPT_MMC_GET_TRAN_SETTINGS); + break; + case PROBE_RESET_BUS: + { uint32_t host_caps = cts->host_caps; if (host_caps & MMC_CAP_SIGNALING_180) softc->flags |= PROBE_FLAG_HOST_CAN_DO_18V; - uint32_t hv = mmc_highest_voltage(cts->host_ocr); - init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); + uint32_t hv = mmc_highest_voltage(softc->host_ocr); + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("reseting the bus\n")); + init_standard_ccb(start_ccb, XPT_MMC_SET_TRAN_SETTINGS); cts->ios.vdd = hv; cts->ios.bus_mode = opendrain; cts->ios.chip_select = cs_dontcare; @@ -639,25 +655,26 @@ mmcprobe_start(struct cam_periph *periph, union ccb *start_ccb) cts->ios.clock = 0; cts->ios_valid = MMC_VDD | MMC_PM | MMC_BM | MMC_CS | MMC_BW | MMC_CLK; - xpt_action(start_ccb); - mtx_sleep(periph, p_mtx, 0, "mmcios", 100); + break; + } - init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); + case PROBE_SET_ID_FREQ: + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("setting the ID freq\n")); + init_standard_ccb(start_ccb, XPT_MMC_SET_TRAN_SETTINGS); cts->ios.power_mode = power_on; cts->ios.clock = CARD_ID_FREQUENCY; cts->ios.timing = bus_timing_normal; cts->ios_valid = MMC_PM | MMC_CLK | MMC_BT; - xpt_action(start_ccb); - mtx_sleep(periph, p_mtx, 0, "mmcios", 100); - /* End for mmc_power_on */ + break; + case PROBE_SET_CS: /* Begin mmc_idle_cards() */ - init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); + init_standard_ccb(start_ccb, XPT_MMC_SET_TRAN_SETTINGS); cts->ios.chip_select = cs_high; cts->ios_valid = MMC_CS; - xpt_action(start_ccb); - mtx_sleep(periph, p_mtx, 0, "mmcios", 1); + break; + case PROBE_GO_IDLE_STATE: CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("Send first XPT_MMC_IO\n")); init_standard_ccb(start_ccb, XPT_MMC_IO); mmcio->cmd.opcode = MMC_GO_IDLE_STATE; /* CMD 0 */ @@ -668,6 +685,7 @@ mmcprobe_start(struct cam_periph *periph, union ccb *start_ccb) /* XXX Reset I/O portion as well */ break; + case PROBE_SDIO_RESET: CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("Start with PROBE_SDIO_RESET\n")); @@ -805,7 +823,7 @@ mmcprobe_done(struct cam_periph *periph, union ccb *done_ccb) struct ccb_mmcio *mmcio; u_int32_t priority; - CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("mmcprobe_done\n")); + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("mmcprobe_done\n")); softc = (mmcprobe_softc *)periph->softc; path = done_ccb->ccb_h.path; priority = done_ccb->ccb_h.pinfo.priority; @@ -816,6 +834,45 @@ mmcprobe_done(struct cam_periph *periph, union ccb *done_ccb) case PROBE_IDENTIFY: { CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_RESET\n")); + PROBE_SET_ACTION(softc, PROBE_POWER_OFF); + break; + } + case PROBE_POWER_OFF: + { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_POWER_OFF\n")); + PROBE_SET_ACTION(softc, PROBE_GET_HOST_OCR); + break; + } + case PROBE_GET_HOST_OCR: + { + struct ccb_trans_settings_mmc *cts; + cts = &done_ccb->cts.proto_specific.mmc; + softc->host_ocr = cts->host_ocr; + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_GET_HOST_OCR (Got OCR=%x\n", softc->host_ocr)); + PROBE_SET_ACTION(softc, PROBE_RESET_BUS); + break; + } + case PROBE_RESET_BUS: + { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_RESET_BUS\n")); + PROBE_SET_ACTION(softc, PROBE_SET_ID_FREQ); + break; + } + case PROBE_SET_ID_FREQ: + { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_SET_ID_FREQ\n")); + PROBE_SET_ACTION(softc, PROBE_SET_CS); + break; + } + case PROBE_SET_CS: + { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_SET_CS\n")); + PROBE_SET_ACTION(softc, PROBE_GO_IDLE_STATE); + break; + } + case PROBE_GO_IDLE_STATE: + { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("done with PROBE_GO_IDLE_STATE\n")); mmcio = &done_ccb->mmcio; err = mmcio->cmd.error; diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index 91474cabd2d3..0441320d4b35 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -2537,6 +2537,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) mmc_path_inq(&ccb->cpi, "Deglitch Networks", sim, maxphys); break; + case XPT_MMC_GET_TRAN_SETTINGS: case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; @@ -2571,6 +2572,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) ccb->ccb_h.status = CAM_REQ_CMP; break; } + case XPT_MMC_SET_TRAN_SETTINGS: case XPT_SET_TRAN_SETTINGS: if (sdhci_debug > 1) slot_printf(slot, "Got XPT_SET_TRAN_SETTINGS\n"); From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56F0B63627C; Fri, 21 May 2021 16:04: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 4FmryP1VCGz3JKq; Fri, 21 May 2021 16:04: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 17A8E1454B; Fri, 21 May 2021 16:04: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 14LG4Cow005047; Fri, 21 May 2021 16:04:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4Ci0005046; Fri, 21 May 2021 16:04:12 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:12 GMT Message-Id: <202105211604.14LG4Ci0005046@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: bc1bb80564ee - main - arm64: rockchip: gpio: Give friendlier name to gpio MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc1bb80564eef66cef1a7b9791af87ae019aa71d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:13 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=bc1bb80564eef66cef1a7b9791af87ae019aa71d commit bc1bb80564eef66cef1a7b9791af87ae019aa71d Author: Emmanuel Vadot AuthorDate: 2021-05-16 12:47:16 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:35:43 +0000 arm64: rockchip: gpio: Give friendlier name to gpio By default name the gpio P This make it easier to find the gpio when reading schematics or DTS. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30287 --- sys/arm64/rockchip/rk_gpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/arm64/rockchip/rk_gpio.c b/sys/arm64/rockchip/rk_gpio.c index aa44a6bc9e09..d3623b2302ec 100644 --- a/sys/arm64/rockchip/rk_gpio.c +++ b/sys/arm64/rockchip/rk_gpio.c @@ -209,14 +209,17 @@ static int rk_gpio_pin_getname(device_t dev, uint32_t pin, char *name) { struct rk_gpio_softc *sc; + uint32_t bank; sc = device_get_softc(dev); if (pin >= 32) return (EINVAL); + bank = pin / 8; + pin = pin - (bank * 8); RK_GPIO_LOCK(sc); - snprintf(name, GPIOMAXNAME, "gpio%d", pin); + snprintf(name, GPIOMAXNAME, "P%c%d", bank + 'A', pin); RK_GPIO_UNLOCK(sc); return (0); From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9349F63670A; Fri, 21 May 2021 16:04: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 4FmryQ2J3yz3JKv; Fri, 21 May 2021 16:04: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 3243514602; Fri, 21 May 2021 16:04: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 14LG4EQ9005068; Fri, 21 May 2021 16:04:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4EdR005067; Fri, 21 May 2021 16:04:14 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:14 GMT Message-Id: <202105211604.14LG4EdR005067@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 5b2a81f58dc7 - main - mmc: Add mmc-pwrseq driver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b2a81f58dc722ca76065536f07ba47efd98dc63 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:14 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=5b2a81f58dc722ca76065536f07ba47efd98dc63 commit 5b2a81f58dc722ca76065536f07ba47efd98dc63 Author: Emmanuel Vadot AuthorDate: 2021-05-16 12:48:56 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:36:20 +0000 mmc: Add mmc-pwrseq driver This driver is used to power up sdio card or eMMC. It handle the reset-gpio, clocks and needed delays for powerup/powerdown. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30288 --- sys/conf/files | 2 + sys/dev/mmc/mmc_pwrseq.c | 194 ++++++++++++++++++++++++++++++++++++++++++++ sys/dev/mmc/mmc_pwrseq_if.m | 38 +++++++++ 3 files changed, 234 insertions(+) diff --git a/sys/conf/files b/sys/conf/files index 22083169bfc7..70cdd9f68dc6 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2476,6 +2476,8 @@ dev/mmc/mmcbr_if.m standard dev/mmc/mmcbus_if.m standard dev/mmc/mmcsd.c optional mmcsd !mmccam dev/mmc/mmc_fdt_helpers.c optional mmc fdt | mmccam fdt +dev/mmc/mmc_pwrseq.c optional mmc fdt | mmccam fdt +dev/mmc/mmc_pwrseq_if.m optional mmc fdt | mmccam fdt dev/mmcnull/mmcnull.c optional mmcnull dev/mpr/mpr.c optional mpr dev/mpr/mpr_config.c optional mpr diff --git a/sys/dev/mmc/mmc_pwrseq.c b/sys/dev/mmc/mmc_pwrseq.c new file mode 100644 index 000000000000..d4ccf814fe53 --- /dev/null +++ b/sys/dev/mmc/mmc_pwrseq.c @@ -0,0 +1,194 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright 2021 Emmanuel Vadot + * + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "mmc_pwrseq_if.h" + +enum pwrseq_type { + PWRSEQ_SIMPLE = 1, + PWRSEQ_EMMC, +}; + +static struct ofw_compat_data compat_data[] = { + { "mmc-pwrseq-simple", PWRSEQ_SIMPLE }, + { "mmc-pwrseq-emmc", PWRSEQ_EMMC }, + { NULL, 0 } +}; + +struct mmc_pwrseq_softc { + enum pwrseq_type type; + clk_t ext_clock; + struct gpiobus_pin *reset_gpio; + + uint32_t post_power_on_delay_ms; + uint32_t power_off_delay_us; +}; + +static int +mmc_pwrseq_probe(device_t dev) +{ + enum pwrseq_type type; + + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (ENXIO); + + type = (enum pwrseq_type)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + switch (type) { + case PWRSEQ_SIMPLE: + device_set_desc(dev, "MMC Simple Power sequence"); + break; + case PWRSEQ_EMMC: + device_set_desc(dev, "MMC eMMC Power sequence"); + break; + } + return (BUS_PROBE_DEFAULT); +} + +static int +mmc_pwrseq_attach(device_t dev) +{ + struct mmc_pwrseq_softc *sc; + phandle_t node; + int rv; + + sc = device_get_softc(dev); + sc->type = (enum pwrseq_type)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + node = ofw_bus_get_node(dev); + + if (sc->type == PWRSEQ_SIMPLE) { + if (OF_hasprop(node, "clocks")) { + rv = clk_get_by_ofw_name(dev, 0, "ext_clock", &sc->ext_clock); + if (rv != 0) { + device_printf(dev, + "Node have a clocks property but no clocks named \"ext_clock\"\n"); + return (ENXIO); + } + } + OF_getencprop(node, "post-power-on-delay-ms", &sc->post_power_on_delay_ms, sizeof(uint32_t)); + OF_getencprop(node, "power-off-delay-us", &sc->power_off_delay_us, sizeof(uint32_t)); + } + + if (OF_hasprop(node, "reset-gpios")) { + if (gpio_pin_get_by_ofw_property(dev, node, "reset-gpios", + &sc->reset_gpio) != 0) { + device_printf(dev, "Cannot get the reset-gpios\n"); + return (ENXIO); + } + gpio_pin_setflags(sc->reset_gpio, GPIO_PIN_OUTPUT); + gpio_pin_set_active(sc->reset_gpio, true); + } + + OF_device_register_xref(OF_xref_from_node(node), dev); + return (0); +} + +static int +mmc_pwrseq_detach(device_t dev) +{ + + return (EBUSY); +} + +static int +mmv_pwrseq_set_power(device_t dev, bool power_on) +{ + struct mmc_pwrseq_softc *sc; + int rv; + + sc = device_get_softc(dev); + + if (power_on) { + if (sc->ext_clock) { + rv = clk_enable(sc->ext_clock); + if (rv != 0) + return (rv); + } + + if (sc->reset_gpio) { + rv = gpio_pin_set_active(sc->reset_gpio, false); + if (rv != 0) + return (rv); + } + + if (sc->post_power_on_delay_ms) + DELAY(sc->post_power_on_delay_ms * 1000); + } else { + if (sc->reset_gpio) { + rv = gpio_pin_set_active(sc->reset_gpio, true); + if (rv != 0) + return (rv); + } + + if (sc->ext_clock) { + rv = clk_stop(sc->ext_clock); + if (rv != 0) + return (rv); + } + if (sc->power_off_delay_us) + DELAY(sc->power_off_delay_us); + } + + return (0); +} + +static device_method_t mmc_pwrseq_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mmc_pwrseq_probe), + DEVMETHOD(device_attach, mmc_pwrseq_attach), + DEVMETHOD(device_detach, mmc_pwrseq_detach), + + DEVMETHOD(mmc_pwrseq_set_power, mmv_pwrseq_set_power), + DEVMETHOD_END +}; + +static driver_t mmc_pwrseq_driver = { + "mmc_pwrseq", + mmc_pwrseq_methods, + sizeof(struct mmc_pwrseq_softc), +}; + +static devclass_t mmc_pwrseq_devclass; + +EARLY_DRIVER_MODULE(mmc_pwrseq, simplebus, mmc_pwrseq_driver, mmc_pwrseq_devclass, 0, 0, + BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); +MODULE_VERSION(mmc_pwrseq, 1); +SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/dev/mmc/mmc_pwrseq_if.m b/sys/dev/mmc/mmc_pwrseq_if.m new file mode 100644 index 000000000000..e94b44052c20 --- /dev/null +++ b/sys/dev/mmc/mmc_pwrseq_if.m @@ -0,0 +1,38 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2021 Emmanuel Vadot +# +# 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. +# +# $FreeBSD$ +# + +INTERFACE mmc_pwrseq; + +# +# Power up/down the card +# +METHOD int set_power { + device_t bus; + bool power_on; +}; From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:15 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DAB136364EF; Fri, 21 May 2021 16:04: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 4FmryR3pX8z3JNS; Fri, 21 May 2021 16:04: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 5B6B514603; Fri, 21 May 2021 16:04: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 14LG4FNh005089; Fri, 21 May 2021 16:04:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4F4q005088; Fri, 21 May 2021 16:04:15 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:15 GMT Message-Id: <202105211604.14LG4F4q005088@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: b0387990a784 - main - mmc_fdt_helpers: Parse the optional pwrseq element. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b0387990a784050ef3a14ea49cb513b5eb737844 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:16 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=b0387990a784050ef3a14ea49cb513b5eb737844 commit b0387990a784050ef3a14ea49cb513b5eb737844 Author: Emmanuel Vadot AuthorDate: 2021-05-16 12:50:10 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:36:58 +0000 mmc_fdt_helpers: Parse the optional pwrseq element. If a sd/emmc node have a pwrseq property parse it and get the corresponding driver. This can later be used to powerup/powerdown the SDIO card or eMMC. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30289 --- sys/dev/mmc/mmc_fdt_helpers.c | 8 ++++++++ sys/dev/mmc/mmc_fdt_helpers.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/sys/dev/mmc/mmc_fdt_helpers.c b/sys/dev/mmc/mmc_fdt_helpers.c index 7dff3851883b..e544f3c4ac08 100644 --- a/sys/dev/mmc/mmc_fdt_helpers.c +++ b/sys/dev/mmc/mmc_fdt_helpers.c @@ -100,6 +100,7 @@ mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_fdt_helper *helper, struct mmc_host *host) { uint32_t bus_width; + phandle_t pwrseq_xref; if (node <= 0) node = ofw_bus_get_node(dev); @@ -181,6 +182,13 @@ mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_fdt_helper *helper, host->caps |= MMC_CAP_SIGNALING_330; #endif + if (OF_hasprop(node, "mmc-pwrseq")) { + if (OF_getencprop(node, "mmc-pwrseq", &pwrseq_xref, sizeof(pwrseq_xref)) == -1) { + device_printf(dev, "Cannot get the pwrseq_xref property\n"); + return (ENXIO); + } + helper->mmc_pwrseq = OF_device_from_xref(pwrseq_xref); + } return (0); } diff --git a/sys/dev/mmc/mmc_fdt_helpers.h b/sys/dev/mmc/mmc_fdt_helpers.h index 73ec324d6b9f..c6e2175690ee 100644 --- a/sys/dev/mmc/mmc_fdt_helpers.h +++ b/sys/dev/mmc/mmc_fdt_helpers.h @@ -63,6 +63,8 @@ struct mmc_fdt_helper { regulator_t vmmc_supply; regulator_t vqmmc_supply; #endif + + device_t mmc_pwrseq; }; typedef void (*mmc_fdt_cd_handler)(device_t dev, bool present); From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 91D4763627E; Fri, 21 May 2021 16:04: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 4FmryT1LbYz3JTl; Fri, 21 May 2021 16:04: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 7D6C414585; Fri, 21 May 2021 16:04: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 14LG4G86005110; Fri, 21 May 2021 16:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4GII005109; Fri, 21 May 2021 16:04:16 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:16 GMT Message-Id: <202105211604.14LG4GII005109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 182717da8880 - main - arm64: allwinner: axp81x: Add support for regnode_status MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 182717da888023a8d0d1a66d579b5a5429b8681d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:17 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=182717da888023a8d0d1a66d579b5a5429b8681d commit 182717da888023a8d0d1a66d579b5a5429b8681d Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:14:47 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:37:37 +0000 arm64: allwinner: axp81x: Add support for regnode_status This method is used to know if a regulator is enabled or not. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30290 --- sys/arm/allwinner/axp81x.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/arm/allwinner/axp81x.c b/sys/arm/allwinner/axp81x.c index 85971a7773c4..df083ec49e32 100644 --- a/sys/arm/allwinner/axp81x.c +++ b/sys/arm/allwinner/axp81x.c @@ -850,6 +850,22 @@ axp8xx_regnode_voltage_to_reg(struct axp8xx_reg_sc *sc, int min_uvolt, return (0); } +static int +axp8xx_regnode_status(struct regnode *regnode, int *status) +{ + struct axp8xx_reg_sc *sc; + uint8_t val; + + sc = regnode_get_softc(regnode); + + *status = 0; + axp8xx_read(sc->base_dev, sc->def->enable_reg, &val, 1); + if (val & sc->def->enable_mask) + *status = REGULATOR_STATUS_ENABLED; + + return (0); +} + static int axp8xx_regnode_set_voltage(struct regnode *regnode, int min_uvolt, int max_uvolt, int *udelay) @@ -899,6 +915,7 @@ static regnode_method_t axp8xx_regnode_methods[] = { /* Regulator interface */ REGNODEMETHOD(regnode_init, axp8xx_regnode_init), REGNODEMETHOD(regnode_enable, axp8xx_regnode_enable), + REGNODEMETHOD(regnode_status, axp8xx_regnode_status), REGNODEMETHOD(regnode_set_voltage, axp8xx_regnode_set_voltage), REGNODEMETHOD(regnode_get_voltage, axp8xx_regnode_get_voltage), REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage), From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:18 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 274526364F7; Fri, 21 May 2021 16:04: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 4FmryT623Xz3JWg; Fri, 21 May 2021 16:04: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 98F7B1454C; Fri, 21 May 2021 16:04: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 14LG4HrS005138; Fri, 21 May 2021 16:04:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4HsE005137; Fri, 21 May 2021 16:04:17 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:17 GMT Message-Id: <202105211604.14LG4HsE005137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 03d4e8bb6592 - main - mmc_fdt_helper: Add mmc_fdt_set_power MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03d4e8bb6592fefab7b17f1d163adba4e35a12c2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:18 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=03d4e8bb6592fefab7b17f1d163adba4e35a12c2 commit 03d4e8bb6592fefab7b17f1d163adba4e35a12c2 Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:18:46 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:38:05 +0000 mmc_fdt_helper: Add mmc_fdt_set_power This helper can be used to enable/disable the regulator and starting the power sequence of sd/sdio/eMMC cards. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30291 --- sys/dev/mmc/mmc_fdt_helpers.c | 42 ++++++++++++++++++++++++++++++++++++++++++ sys/dev/mmc/mmc_fdt_helpers.h | 1 + 2 files changed, 43 insertions(+) diff --git a/sys/dev/mmc/mmc_fdt_helpers.c b/sys/dev/mmc/mmc_fdt_helpers.c index e544f3c4ac08..4e8a1730d240 100644 --- a/sys/dev/mmc/mmc_fdt_helpers.c +++ b/sys/dev/mmc/mmc_fdt_helpers.c @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#include "mmc_pwrseq_if.h" + static inline void mmc_fdt_parse_sd_speed(phandle_t node, struct mmc_host *host) { @@ -423,3 +425,43 @@ mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper *helper) return (pinstate ^ (helper->props & MMC_PROP_WP_INVERTED)); } + +void +mmc_fdt_set_power(struct mmc_fdt_helper *helper, enum mmc_power_mode power_mode) +{ + int reg_status; + int rv; + + switch (power_mode) { + case power_on: + break; + case power_off: + if (helper->vmmc_supply) { + rv = regulator_status(helper->vmmc_supply, ®_status); + if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) + regulator_disable(helper->vmmc_supply); + } + if (helper->vqmmc_supply) { + rv = regulator_status(helper->vqmmc_supply, ®_status); + if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) + regulator_disable(helper->vqmmc_supply); + } + if (helper->mmc_pwrseq) + MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, false); + break; + case power_up: + if (helper->vmmc_supply) { + rv = regulator_status(helper->vmmc_supply, ®_status); + if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) + regulator_enable(helper->vmmc_supply); + } + if (helper->vqmmc_supply) { + rv = regulator_status(helper->vqmmc_supply, ®_status); + if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) + regulator_enable(helper->vqmmc_supply); + } + if (helper->mmc_pwrseq) + MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, true); + break; + } +} diff --git a/sys/dev/mmc/mmc_fdt_helpers.h b/sys/dev/mmc/mmc_fdt_helpers.h index c6e2175690ee..e6d6f3fbfd84 100644 --- a/sys/dev/mmc/mmc_fdt_helpers.h +++ b/sys/dev/mmc/mmc_fdt_helpers.h @@ -74,5 +74,6 @@ int mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct mmc_fdt_helper *help void mmc_fdt_gpio_teardown(struct mmc_fdt_helper *helper); bool mmc_fdt_gpio_get_present(struct mmc_fdt_helper *helper); bool mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper *helper); +void mmc_fdt_set_power(struct mmc_fdt_helper *helper, enum mmc_power_mode power_mode); #endif From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2C7F2636629; Fri, 21 May 2021 16:04: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 4FmryV6l4xz3JWn; Fri, 21 May 2021 16:04: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 B3C4114376; Fri, 21 May 2021 16:04: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 14LG4I9A005159; Fri, 21 May 2021 16:04:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4IAo005158; Fri, 21 May 2021 16:04:18 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:18 GMT Message-Id: <202105211604.14LG4IAo005158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: ce41765c21ac - main - mmc: dwmmc: Call mmc_fdt_set_power MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ce41765c21ac56a37c60a0e8cd227ee3396740cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:19 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=ce41765c21ac56a37c60a0e8cd227ee3396740cc commit ce41765c21ac56a37c60a0e8cd227ee3396740cc Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:20:42 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:38:35 +0000 mmc: dwmmc: Call mmc_fdt_set_power This allow us to powerup/down the card and enabling/disabling the regulators if any. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30292 --- sys/dev/mmc/host/dwmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c index f28d842bd801..145b7fe17f09 100644 --- a/sys/dev/mmc/host/dwmmc.c +++ b/sys/dev/mmc/host/dwmmc.c @@ -892,6 +892,8 @@ dwmmc_update_ios(device_t brdev, device_t reqdev) dprintf("Setting up clk %u bus_width %d, timming: %d\n", ios->clock, ios->bus_width, ios->timing); + mmc_fdt_set_power(&sc->mmc_helper, ios->power_mode); + if (ios->bus_width == bus_width_8) WRITE4(sc, SDMMC_CTYPE, SDMMC_CTYPE_8BIT); else if (ios->bus_width == bus_width_4) From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 919DB6366B6; Fri, 21 May 2021 16:04: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 4FmryX23DHz3JcQ; Fri, 21 May 2021 16:04: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 DE066144FA; Fri, 21 May 2021 16:04: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 14LG4Jqh005180; Fri, 21 May 2021 16:04:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4J7O005179; Fri, 21 May 2021 16:04:19 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:19 GMT Message-Id: <202105211604.14LG4J7O005179@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: f52072b06da7 - main - extres: regulator: Fix regulator_status for already enable regulators MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f52072b06da761c05dcb636dd1a02dea7214174a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:20 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=f52072b06da761c05dcb636dd1a02dea7214174a commit f52072b06da761c05dcb636dd1a02dea7214174a Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:21:43 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:39:07 +0000 extres: regulator: Fix regulator_status for already enable regulators If a regulator hasn't been enable by a driver but is enabled in hardware (most likely enabled by U-Boot), regulator_status will returns that it is enabled and so any call to regulator_disable will panic as it wasn't enabled by one of our drivers. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30293 --- sys/dev/extres/regulator/regulator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/extres/regulator/regulator.c b/sys/dev/extres/regulator/regulator.c index 63b7d116f416..eab79e9dfbc3 100644 --- a/sys/dev/extres/regulator/regulator.c +++ b/sys/dev/extres/regulator/regulator.c @@ -985,6 +985,10 @@ regulator_status(regulator_t reg, int *status) KASSERT(regnode->ref_cnt > 0, ("Attempt to access unreferenced regulator: %s\n", regnode->name)); + if (reg->enable_cnt == 0) { + *status = 0; + return (0); + } REG_TOPO_SLOCK(); rv = regnode_status(regnode, status); REG_TOPO_UNLOCK(); From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:22 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7D5B636575; Fri, 21 May 2021 16:04: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 4FmryZ1lw8z3JZ6; Fri, 21 May 2021 16:04: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 0D415144FB; Fri, 21 May 2021 16:04: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 14LG4KF3005201; Fri, 21 May 2021 16:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4Klp005200; Fri, 21 May 2021 16:04:20 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:20 GMT Message-Id: <202105211604.14LG4Klp005200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 115e71a45714 - main - arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 115e71a4571459e69001b5017ec19532e9d60e1b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:22 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=115e71a4571459e69001b5017ec19532e9d60e1b commit 115e71a4571459e69001b5017ec19532e9d60e1b Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:24:31 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:39:47 +0000 arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30294 --- sys/arm/allwinner/aw_mmc.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c index f63b41f9b73c..0b3f19aea55f 100644 --- a/sys/arm/allwinner/aw_mmc.c +++ b/sys/arm/allwinner/aw_mmc.c @@ -1285,6 +1285,8 @@ aw_mmc_update_ios(device_t bus, device_t child) struct mmc_ios *ios; unsigned int clock; uint32_t reg, div = 1; + int reg_status; + int rv; sc = device_get_softc(bus); @@ -1310,10 +1312,16 @@ aw_mmc_update_ios(device_t bus, device_t child) if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD)) device_printf(sc->aw_dev, "Powering down sd/mmc\n"); - if (sc->mmc_helper.vmmc_supply) - regulator_disable(sc->mmc_helper.vmmc_supply); - if (sc->mmc_helper.vqmmc_supply) - regulator_disable(sc->mmc_helper.vqmmc_supply); + if (sc->mmc_helper.vmmc_supply) { + rv = regulator_status(sc->mmc_helper.vmmc_supply, ®_status); + if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) + regulator_disable(sc->mmc_helper.vmmc_supply); + } + if (sc->mmc_helper.vqmmc_supply) { + rv = regulator_status(sc->mmc_helper.vqmmc_supply, ®_status); + if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) + regulator_disable(sc->mmc_helper.vqmmc_supply); + } aw_mmc_reset(sc); break; @@ -1321,10 +1329,16 @@ aw_mmc_update_ios(device_t bus, device_t child) if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD)) device_printf(sc->aw_dev, "Powering up sd/mmc\n"); - if (sc->mmc_helper.vmmc_supply) - regulator_enable(sc->mmc_helper.vmmc_supply); - if (sc->mmc_helper.vqmmc_supply) - regulator_enable(sc->mmc_helper.vqmmc_supply); + if (sc->mmc_helper.vmmc_supply) { + rv = regulator_status(sc->mmc_helper.vmmc_supply, ®_status); + if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) + regulator_enable(sc->mmc_helper.vmmc_supply); + } + if (sc->mmc_helper.vqmmc_supply) { + rv = regulator_status(sc->mmc_helper.vqmmc_supply, ®_status); + if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) + regulator_enable(sc->mmc_helper.vqmmc_supply); + } aw_mmc_init(sc); break; }; From owner-dev-commits-src-main@freebsd.org Fri May 21 16:04:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5712D636727; Fri, 21 May 2021 16:04:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmryd2xSPz3JVB; Fri, 21 May 2021 16:04: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 355F01454D; Fri, 21 May 2021 16:04: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 14LG4M2X005222; Fri, 21 May 2021 16:04:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4MqJ005221; Fri, 21 May 2021 16:04:22 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:22 GMT Message-Id: <202105211604.14LG4MqJ005221@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: c99d887ca8c4 - main - dwmmc: Add bus_generic_add_child in the methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c99d887ca8c420297d2db335ce56075eb12443aa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:26 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=c99d887ca8c420297d2db335ce56075eb12443aa commit c99d887ca8c420297d2db335ce56075eb12443aa Author: Emmanuel Vadot AuthorDate: 2021-05-16 15:07:50 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:40:14 +0000 dwmmc: Add bus_generic_add_child in the methods Otherwise sdiob cannot add it's children. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30295 --- sys/dev/mmc/host/dwmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c index 145b7fe17f09..b0e13719928a 100644 --- a/sys/dev/mmc/host/dwmmc.c +++ b/sys/dev/mmc/host/dwmmc.c @@ -1558,6 +1558,8 @@ static device_method_t dwmmc_methods[] = { DEVMETHOD(mmc_sim_get_tran_settings, dwmmc_get_tran_settings), DEVMETHOD(mmc_sim_set_tran_settings, dwmmc_set_tran_settings), DEVMETHOD(mmc_sim_cam_request, dwmmc_cam_request), + + DEVMETHOD(bus_add_child, bus_generic_add_child), #endif DEVMETHOD_END From owner-dev-commits-src-main@freebsd.org Fri May 21 16:42:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D9F1063706D for ; Fri, 21 May 2021 16:42:45 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmsps0xPtz3rRp for ; Fri, 21 May 2021 16:42:45 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-qt1-x829.google.com with SMTP id t20so15725976qtx.8 for ; Fri, 21 May 2021 09:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xL4+f1eDR9mvoxSgmtHNM8ZxvRYze4yry2BPswOFyFo=; b=avFkGPt6IoclB8Cn3+IZWCEEpJOnNXazjQd72+/mIwH2SZ/93zqeVxyLq+TAl3B3Im Qu8S/DHTU5bj9DQVKUr0ztnG8F6uieIJQ2Kto6bD+2T5cH+bcu6ZtthsRQK4nR9Rcb1d vJZdBnqbNytPewOA4BbAOWiotRvda78vnhexFlsi6www6zLMGXVd09aW9mD3u4BT5FrH Xt+fYvvp5z/YSrCKNlwzq+JUWRKqdx43cYNoM5PHg3AEyw9bEOK5/is2BBt0z1qDh2hz rrRbK+dzlA+dgO4Ju3ONOvGvNci3RRmIYghrx6xT1SsKY+hT7ZhUyn7x3mDVECG+dAyB 9GbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xL4+f1eDR9mvoxSgmtHNM8ZxvRYze4yry2BPswOFyFo=; b=b/uFHu8KaBoLBHj8yG+iHhYzIcTlOXmjKcHqki66lDxwqtasZxGRFTi6yqZPsO7hkB 2+tlNZN/a/+LHC1Wabd3f0NdOlZcVLwnqkF2L7ej9MJPHIfTjZVCH4GzfSOQUTkfO7zO 7nbVFR0Lm86dISD6BfYMJllZEC6+R4hc2Pc9alned6OHiuO+HcfSrPVbZdqs2LdsGrHr qxyY7VV/lZNb4qo38C0x5y39C2HPnX8Pjpj6GIU7WlP8rQmPKQkk4cG11WiYpzK8QxjQ MtC9pUofPzSr1JmN0nsFzYp1A70Oel0n4u+NOotklgOtFoNesdfWpoVJfmJaxKI1vp76 8rdQ== X-Gm-Message-State: AOAM531aWGZwbOOW5/w76ep+at1D8epBLNPZ36kp6HUp9E/Zz6ZFr4GF vnnHuf//Z4PZdXHHg4/zsfToIW4Zp6QmOmnAIv8P7A== X-Google-Smtp-Source: ABdhPJxFPOxWW9DA7BniEnhfPdPIEu0Ms8IaF/0vnYHxx4y+mBo/qlV0p1rrzlqPKUVCiKnWkq3n+NYzqs3BRVAx2G4= X-Received: by 2002:a05:622a:202:: with SMTP id b2mr11988511qtx.343.1621615363785; Fri, 21 May 2021 09:42:43 -0700 (PDT) MIME-Version: 1.0 References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> <202105211446.14LEk8kZ009266@slippy.cwsent.com> In-Reply-To: <202105211446.14LEk8kZ009266@slippy.cwsent.com> From: Marcin Wojtas Date: Fri, 21 May 2021 18:42:31 +0200 Message-ID: Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. To: Cy Schubert Cc: Jessica Clarke , shawn.webb@hardenedbsd.org, Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" , =?UTF-8?Q?Dawid_G=C3=B3recki?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4Fmsps0xPtz3rRp X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=avFkGPt6; dmarc=none; spf=none (mx1.freebsd.org: domain of mw@semihalf.com has no SPF policy when checking 2607:f8b0:4864:20::829) smtp.mailfrom=mw@semihalf.com X-Spamd-Result: default: False [-3.26 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[semihalf-com.20150623.gappssmtp.com:s=20150623]; FREEFALL_USER(0.00)[mw]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-0.96)[-0.963]; RCVD_TLS_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-main@freebsd.org]; DMARC_NA(0.00)[semihalf.com]; NEURAL_HAM_LONG(-1.00)[-1.000]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::829:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[semihalf-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::829:from]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::829:from]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-main] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:42:46 -0000 Hi Cy, pt., 21 maj 2021 o 16:46 Cy Schubert napisa=C5= =82(a): > > In message <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org>, Jessica > Clarke w > rites: > > > On 21 May 2021, at 15:11, Marcin Wojtas wrote: > > > > > > Hi Jess > > > > > > pt., 21 maj 2021 o 15:39 Jessica Clarke napisa= =C5=82(a): > > >> > > >> On 21 May 2021, at 14:34, Marcin Wojtas wrote: > > >>> > > >>> The branch main has been updated by mw: > > >>> > > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973= b5875d7e > > 0fa6832ea64a > > >>> > > >>> commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > > >>> Author: Marcin Wojtas > > >>> AuthorDate: 2021-05-21 09:29:22 +0000 > > >>> Commit: Marcin Wojtas > > >>> CommitDate: 2021-05-21 13:33:06 +0000 > > >>> > > >>> Disable stack gap for ntpd during build. > > >>> > > >>> When starting, ntpd calls setrlimit(2) to limit maximum size of i= ts > > >>> stack. The stack limit chosen by ntpd is 200K, so when stack gap > > >>> is enabled, the stack gap is larger than this limit, which result= s > > >>> in ntpd crashing. > > >> > > >> Isn=E2=80=99t the bug that the unusable gap counts as usage? > > >> > > >> Jess > > >> > > > > > > An alternative solution was submitted > > > (https://reviews.freebsd.org/D29832), so that to extend the limit for > > > ntpd, but eventually it was recommended to simple disable the stack > > > gap for it until it's fixed upstream (see the last comment in the > > > linked revision). > > > > That=E2=80=99s my point, there is nothing to =E2=80=9Cfix=E2=80=9D upst= ream. NTPD uses less tha > > n 200K > > of stack, thus it is perfectly reasonable for it to set its limit to th= at. Th > > e > > fact that FreeBSD decides to count an arbitrary, non-deterministic amou= nt of > > additional unusable virtual address space towards that limit is not its= fault > > , > > but a bug in FreeBSD that needs to be fixed as it=E2=80=99s entirely un= reasonable f > > or > > applications to have to account for that. > > This latest problem is not stack gap. It is PIE. > I have to disagree. ntpd does not start because of stack gap, not PIE, even though it may seem like PIE causes this. This is due to the fact that stack gap is disabled if PIE is disabled. Because of that value of sysctl kern.elf64.aslr.stack_gap does not matter when kern.elf64.aslr.pie_enable is set to 0. When pie_enabled is set to 1 and stack gap is enabled, then ntpd fails to start, but when pie_enabled is set to 1 and stack_gap is set to 0, then ntpd starts without any issue. We verified this on FreeBSD-CURRENT snapshot from 2021-05-20. The fact that this is a stack gap issue can be verified using following procedure: 1. Install FreeBSD-CURRENT snapshot from 2021-05-20 using default configuration. 2. On a newly installed system start ntpd. With default configuration it should start successfully. 3. Set sysctl kern.elf64.aslr.pie_enable=3D1 and start ntpd. This time ntpd should fail. An entry indicating that ntpd was killed because of signal 11 should be visible in /var/log/messages. 4. Set sysctl kern.elf64.aslr.stack_gap=3D0 and start ntpd once again. This time ntpd should start even though pie_enable is set to 1. Exact log from the boot it was tested: root@freebsd-ntpd-test:~ # sysctl -a | grep aslr kern.elf32.aslr.stack_gap: 3 kern.elf32.aslr.honor_sbrk: 1 kern.elf32.aslr.pie_enable: 0 kern.elf32.aslr.enable: 0 kern.elf64.aslr.stack_gap: 3 kern.elf64.aslr.honor_sbrk: 1 kern.elf64.aslr.pie_enable: 0 kern.elf64.aslr.enable: 0 vm.aslr_restarts: 0 root@freebsd-ntpd-test:~ # ntpd root@freebsd-ntpd-test:~ # ps aux | grep ntpd root 826 0.0 0.2 22060 6960 - Ss 17:38 0:00.01 ntpd root 828 0.0 0.1 12976 2416 0 S+ 17:38 0:00.00 grep ntpd root@freebsd-ntpd-test:~ # killall ntpd root@freebsd-ntpd-test:~ # ps aux | grep ntpd root 831 0.0 0.1 12976 2416 0 S+ 17:38 0:00.00 grep ntpd root@freebsd-ntpd-test:~ # sysctl kern.elf64.aslr.pie_enable=3D1 kern.elf64.aslr.pie_enable: 0 -> 1 root@freebsd-ntpd-test:~ # ntpd root@freebsd-ntpd-test:~ # ps aux | grep ntpd root 836 0.0 0.1 14128 2452 0 S+ 17:39 0:00.00 grep ntpd root@freebsd-ntpd-test:~ # cat /var/log/messages | tail May 21 17:38:25 freebsd-ntpd-test ntpd[826]: ntpd exiting on signal 15 (Terminated) May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ntpd 4.2.8p15-a (1): Starting May 21 17:39:14 freebsd-ntpd-test ntpd[833]: Command line: ntpd May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ---------------------------------------------------- May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ntp-4 is maintained by Network Time Foundation, May 21 17:39:14 freebsd-ntpd-test ntpd[833]: Inc. (NTF), a non-profit 501(c)(3) public-benefit May 21 17:39:14 freebsd-ntpd-test ntpd[833]: corporation. Support and training for ntp-4 are May 21 17:39:14 freebsd-ntpd-test ntpd[833]: available at https://www.nwtime.org/support May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ---------------------------------------------------- May 21 17:39:14 freebsd-ntpd-test kernel: pid 834 (ntpd), jid 0, uid 0: exited on signal 11 (core dumped) root@freebsd-ntpd-test:~ # sysctl kern.elf64.aslr.stack_gap=3D0 kern.elf64.aslr.stack_gap: 3 -> 0 root@freebsd-ntpd-test:~ # sysctl -a | grep aslr kern.elf32.aslr.stack_gap: 3 kern.elf32.aslr.honor_sbrk: 1 kern.elf32.aslr.pie_enable: 0 kern.elf32.aslr.enable: 0 kern.elf64.aslr.stack_gap: 0 kern.elf64.aslr.honor_sbrk: 1 kern.elf64.aslr.pie_enable: 1 kern.elf64.aslr.enable: 0 vm.aslr_restarts: 1 root@freebsd-ntpd-test:~ # ntpd root@freebsd-ntpd-test:~ # ps aux | grep ntpd root 845 0.0 0.2 22060 6924 - Ss 17:40 0:00.01 ntpd root 847 0.0 0.1 12976 2440 0 S+ 17:40 0:00.00 grep ntpd root@freebsd-ntpd-test:~ # cat /var/log/messages | tail May 21 17:39:14 freebsd-ntpd-test kernel: pid 834 (ntpd), jid 0, uid 0: exited on signal 11 (core dumped) May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ntpd 4.2.8p15-a (1): Starting May 21 17:40:52 freebsd-ntpd-test ntpd[844]: Command line: ntpd May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ---------------------------------------------------- May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ntp-4 is maintained by Network Time Foundation, May 21 17:40:52 freebsd-ntpd-test ntpd[844]: Inc. (NTF), a non-profit 501(c)(3) public-benefit May 21 17:40:52 freebsd-ntpd-test ntpd[844]: corporation. Support and training for ntp-4 are May 21 17:40:52 freebsd-ntpd-test ntpd[844]: available at https://www.nwtime.org/support May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ---------------------------------------------------- May 21 17:40:52 freebsd-ntpd-test ntpd[845]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): stat failed: No such file or directory root@freebsd-ntpd-test:~ # killall ntpd Best regards, Marcin From owner-dev-commits-src-main@freebsd.org Fri May 21 16:51:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66D9B6376A9; Fri, 21 May 2021 16:51: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 4Fmt1R1Qgwz3vhW; Fri, 21 May 2021 16:51: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 141FA15017; Fri, 21 May 2021 16:51: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 14LGpsHc070316; Fri, 21 May 2021 16:51:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LGpstI070315; Fri, 21 May 2021 16:51:54 GMT (envelope-from git) Date: Fri, 21 May 2021 16:51:54 GMT Message-Id: <202105211651.14LGpstI070315@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a19e14ca2d36 - main - ldconfig(8): update manpage to reality MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a19e14ca2d36aa9d5bd392881abd85bf9e2e89ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:51:55 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a19e14ca2d36aa9d5bd392881abd85bf9e2e89ad commit a19e14ca2d36aa9d5bd392881abd85bf9e2e89ad Author: Konstantin Belousov AuthorDate: 2021-05-15 05:12:35 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-21 16:51:18 +0000 ldconfig(8): update manpage to reality ELF ldconfig only maintains the search list, there is no hints Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30272 --- sbin/ldconfig/ldconfig.8 | 114 +++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 67 deletions(-) diff --git a/sbin/ldconfig/ldconfig.8 b/sbin/ldconfig/ldconfig.8 index 9a1463be1ad4..63e2271b7cd5 100644 --- a/sbin/ldconfig/ldconfig.8 +++ b/sbin/ldconfig/ldconfig.8 @@ -1,6 +1,11 @@ .\" .\" Copyright (c) 1993 Paul Kranenburg .\" All rights reserved. +.\" Copyright (c) 2021 The FreeBSD Foundation, Inc. +.\" +.\" Portions of this documentation were written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -29,36 +34,40 @@ .\" .\" $FreeBSD$ .\" -.Dd December 31, 2020 +.Dd May 15, 2021 .Dt LDCONFIG 8 .Os .Sh NAME .Nm ldconfig -.Nd configure the shared library cache +.Nd configure the dynamic linker search path for shared libraries .Sh SYNOPSIS .Nm .Op Fl 32 -.Op Fl elf .Op Fl Rimrsv .Op Fl f Ar hints_file .Op Ar directory | Ar .Sh DESCRIPTION -The .Nm -utility is used to prepare a set of -.Dq hints -for use by the dynamic linker -to facilitate quick lookup of shared libraries available in multiple -directories. -It scans a set of built-in system directories and any +utility is used to configure the set of paths used by the dynamic linker +.Xr ld-elf.so.1 1 +when searching for shared libraries. +The dynamic linker looks for libraries in a set of built-in system directories +and any directories specified in the hints file. +This obviates the need for storing search paths within the executable, +see the +.Fl rpath +option for the static linker +.Xr ld 1 . +.Pp +The hints file is maintained by +.Nm . +The .Ar directories -specified on the command line (in the given order) looking for -shared libraries and stores the results in a system file to forestall -the overhead that would otherwise result from the directory search -operations the dynamic linker would have to perform to load the -required shared libraries. +list to be stored in the hints file is supplied on the command line. .Pp -Alternatively, +Alternatively to the +.Ar directories +list on the command line, .Ar files may be specified; these are expected to contain directories to scan for shared libraries. @@ -67,9 +76,6 @@ line. Blank lines and lines starting with the comment character .Ql \&# are ignored. -Filenames must conform to the -.Pa lib*.so.[0-9] -pattern in order to be added to the hints file. .Pp For security reasons, directories which are world or group-writable or which are not owned by root produce warning messages and are skipped, unless @@ -77,16 +83,10 @@ the .Fl i option is present. .Pp -The shared libraries which are found will be automatically available for loading -if needed by the program being prepared for execution. -This obviates the need -for storing search paths within the executable. -.Pp The .Ev LD_LIBRARY_PATH -environment variable can be used to override the use of -directories (or the order thereof) from the cache or to specify additional -directories where shared libraries might be found. +environment variable can be used to specify additional +shared library search directories. .Ev LD_LIBRARY_PATH is a .Sq \&: @@ -99,10 +99,6 @@ equivalent of the switch of .Xr ld 1 . .Pp -The -.Nm -utility is typically run as part of the boot sequence. -.Pp The following options are recognized by .Nm : .Bl -tag -width indent @@ -112,12 +108,10 @@ on 64-bit systems that support running 32-bit binaries. .It Fl elf Ignored for backwards compatibility. .It Fl R -Rescan the previously configured directories. -This opens the previous hints -file and fetches the directory list from the header. -Any additional pathnames -on the command line are also processed. -This is the default action when no parameters are given. +Appends pathnames on the command line to the directory list from +the hints file. +.Pp +This is the default action when no options are given. .It Fl f Ar hints_file Read and/or update the specified hints file, instead of the standard file. This option is provided primarily for testing. @@ -125,19 +119,15 @@ This option is provided primarily for testing. Run in insecure mode. The security checks will not be performed. .It Fl m -Instead of replacing the contents of the hints file -with those found in the directories specified, -.Dq merge -in new entries. -Directories recorded in the hints file by previous runs of -.Nm -are also rescanned for new shared libraries. +Instead of replacing the list of the directories to search with the +directories specified on the command line, merge existing list +with the specified directories, and write the result to the hints file. .It Fl r -List the current contents of the hints file +List the current list of the directories from the hints file on the standard output. The hints file is not modified. -The list of -directories stored in the hints file is included. +.Pp +Scan and print all libraries found on the directories list. .It Fl s Do not scan the built-in system directory .Pq Dq /usr/lib @@ -151,40 +141,31 @@ space of .Ev set-user-Id programs. Whenever such a program is run by any user except the owner of the program, -the dynamic linker -will only load shared libraries from the hints -file. +the dynamic linker will only load shared libraries from paths found in +the hints file. In particular, the .Ev LD_LIBRARY_PATH is not used to search for libraries. -Thus, the role of +Thus, .Nm -is dual. -In addition to building a set of hints for quick lookup, it also serves to -specify the trusted collection of directories from which shared objects can -be safely loaded. +serves to specify the trusted collection of directories from which +shared objects can be safely loaded. .Sh FILES .Bl -tag -width /var/run/ld-elf.so.hintsxxx -compact -.It Pa /var/run/ld.so.hints -Standard hints file for the a.out dynamic linker. .It Pa /var/run/ld-elf.so.hints Standard hints file for the ELF dynamic linker. -.It Pa /etc/ld.so.conf -Conventional configuration file containing directory names for -invocations with -.Fl aout . .It Pa /etc/ld-elf.so.conf Conventional configuration file containing directory names for invocations with .Fl elf . .It Pa /var/run/ld-elf32.so.hints -.It Pa /var/run/ld32.so.hints Conventional configuration files containing directory names for invocations with .Fl 32 . .El .Sh SEE ALSO .Xr ld 1 , +.Xr ld-elf.so.1 , .Xr link 5 .Sh HISTORY A @@ -192,8 +173,7 @@ A utility first appeared in SunOS 4.0, it appeared in its current form in .Fx 1.1 . -.Sh BUGS -Some security checks (for example, verifying root ownership of -added directories) are not performed when -.Fl aout -is specified. +.Pp +The name 'hints file' is historic from the times when the file also contained +hints to the dynamic linker. +This functionality is not provided for ELF. From owner-dev-commits-src-main@freebsd.org Fri May 21 17:28:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA9B0638501; Fri, 21 May 2021 17:28:25 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (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 4FmtqY499Wz4h07; Fri, 21 May 2021 17:28:25 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 7E5013C0199; Fri, 21 May 2021 17:28:24 +0000 (UTC) Date: Fri, 21 May 2021 17:28:24 +0000 From: Brooks Davis To: Marcin Wojtas Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. Message-ID: <20210521172824.GI60173@spindle.one-eyed-alien.net> References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TeJTyD9hb8KJN2Jy" Content-Disposition: inline In-Reply-To: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 4FmtqY499Wz4h07 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 17:28:25 -0000 --TeJTyD9hb8KJN2Jy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 21, 2021 at 01:34:52PM +0000, Marcin Wojtas wrote: > The branch main has been updated by mw: >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3Daf949c590bd8a00a5973b5875d= 7e0fa6832ea64a >=20 > commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > Author: Marcin Wojtas > AuthorDate: 2021-05-21 09:29:22 +0000 > Commit: Marcin Wojtas > CommitDate: 2021-05-21 13:33:06 +0000 >=20 > Disable stack gap for ntpd during build. > =20 > When starting, ntpd calls setrlimit(2) to limit maximum size of its > stack. The stack limit chosen by ntpd is 200K, so when stack gap > is enabled, the stack gap is larger than this limit, which results > in ntpd crashing. > =20 > Submitted by: Dawid Gorecki > Reviewed by: cy, imp > Obtained from: Semihalf > Sponsored by: Stormshield > Differential Revision: https://reviews.freebsd.org/D29553 > --- > usr.sbin/ntp/ntpd/Makefile | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/usr.sbin/ntp/ntpd/Makefile b/usr.sbin/ntp/ntpd/Makefile > index 2d8a8b9d2a2d..b9c3a05547d4 100644 > --- a/usr.sbin/ntp/ntpd/Makefile > +++ b/usr.sbin/ntp/ntpd/Makefile > @@ -56,4 +56,7 @@ CLEANFILES+=3D .version version.c > version.c: > sh -e ${.CURDIR:H}/scripts/mkver ntpd > =20 > +afterbuild: > + ${ELFCTL} -e +noaslrstkgap ${PROG} > + > .include This is going to run every build and touch the file each time. It should be done as part of the link target like CTFMERGE. elfctl should also probably be taught not to write to the file if nothing changes. -- Brooks --TeJTyD9hb8KJN2Jy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJgp+23AAoJEKzQXbSebgfAUDIH/2csbDpn+XDbQQN4QAi5g/Qw Rqaqv16SytPZHXgTfDqWn7GwZ4POMtbLOEuvmZGwFEY4zSDLprgsjMEHJrtIhhHc zhlWb1Ua7s/ARNMEsZEcIcHKz0hlkCMdWh7xaWkI4uleTvhR6Q1YteqO0NfUPukm fqozGY0/QSipJm4q/e0pQkO2d3bzlcWVpyC0MXlhAZ/HGn2Oz9VecuYvKtcO12Eb P4BDnwkIUtLNwCv/IcP809jWJ1PZoxysiqtScXTjGRpPfBRZBGereOMNhW0ooxBg wjgjgTO1O2Xkb9RvglLLSotb18MsmQwGnFnhkljTc2+MCvOKMvE4GL8wWP55wf4= =VHRt -----END PGP SIGNATURE----- --TeJTyD9hb8KJN2Jy-- From owner-dev-commits-src-main@freebsd.org Fri May 21 17:36:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6D67E6380F9; Fri, 21 May 2021 17:36: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 4Fmv0x2KMMz4lXD; Fri, 21 May 2021 17:36: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 3393F1557F; Fri, 21 May 2021 17:36: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 14LHaXKW023994; Fri, 21 May 2021 17:36:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LHaXQO023993; Fri, 21 May 2021 17:36:33 GMT (envelope-from git) Date: Fri, 21 May 2021 17:36:33 GMT Message-Id: <202105211736.14LHaXQO023993@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 80e645dcdb8d - main - mmc: Only build mmc_fdt_helper and mmc_pwrseq for arch that uses ext_resources MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80e645dcdb8df280cbbe978f96c49689170eca68 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 17:36:33 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=80e645dcdb8df280cbbe978f96c49689170eca68 commit 80e645dcdb8df280cbbe978f96c49689170eca68 Author: Emmanuel Vadot AuthorDate: 2021-05-21 17:35:20 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 17:35:20 +0000 mmc: Only build mmc_fdt_helper and mmc_pwrseq for arch that uses ext_resources This is now a needed requirement and fixes powerpc* build --- sys/conf/files | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 70cdd9f68dc6..9b67200b3c91 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2475,9 +2475,9 @@ dev/mmc/mmc.c optional mmc !mmccam dev/mmc/mmcbr_if.m standard dev/mmc/mmcbus_if.m standard dev/mmc/mmcsd.c optional mmcsd !mmccam -dev/mmc/mmc_fdt_helpers.c optional mmc fdt | mmccam fdt -dev/mmc/mmc_pwrseq.c optional mmc fdt | mmccam fdt -dev/mmc/mmc_pwrseq_if.m optional mmc fdt | mmccam fdt +dev/mmc/mmc_fdt_helpers.c optional ext_resources mmc fdt | ext_resources mmccam fdt +dev/mmc/mmc_pwrseq.c optional ext_resources mmc fdt | ext_resources mmccam fdt +dev/mmc/mmc_pwrseq_if.m optional ext_resources mmc fdt | ext_resources mmccam fdt dev/mmcnull/mmcnull.c optional mmcnull dev/mpr/mpr.c optional mpr dev/mpr/mpr_config.c optional mpr From owner-dev-commits-src-main@freebsd.org Fri May 21 17:53:57 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE34F638BE5; Fri, 21 May 2021 17:53:57 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmvP12DPkz4v8P; Fri, 21 May 2021 17:53:57 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.66.148.124]) by shaw.ca with ESMTPA id k9LNlIwztMrQqk9LOlAhas; Fri, 21 May 2021 11:53:55 -0600 X-Authority-Analysis: v=2.4 cv=Nv6yz+RJ c=1 sm=1 tr=0 ts=60a7f3b3 a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=8nJEP1OIZ-IA:10 a=5FLXtPjwQuUA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=oCJs8q-oAAAA:8 a=EkcXrb_YAAAA:8 a=ZEWdpI7IREN6c40-odoA:9 a=wPNLvfGTeEIA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 a=qUF70SbvcHBaGhGVny9j:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id F104E1E5; Fri, 21 May 2021 10:53:51 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 14LHrpAN004663; Fri, 21 May 2021 10:53:51 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202105211753.14LHrpAN004663@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Marcin Wojtas cc: Cy Schubert , Jessica Clarke , shawn.webb@hardenedbsd.org, Marcin Wojtas , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" , =?UTF-8?Q?Dawid_G=C3=B3recki?= Subject: Re: git: af949c590bd8 - main - Disable stack gap for ntpd during build. In-reply-to: References: <202105211334.14LDYqoa004343@gitrepo.freebsd.org> <04F25FD0-7863-4AC1-A257-EF0F1EB90659@freebsd.org> <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org> <202105211446.14LEk8kZ009266@slippy.cwsent.com> Comments: In-reply-to Marcin Wojtas message dated "Fri, 21 May 2021 18:42:31 +0200." Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 21 May 2021 10:53:51 -0700 X-CMAE-Envelope: MS4xfEgYXFa9V04gso1yKnFvwL1O9dbQnSXXmT7touAA2JRX63WY996JJfiguRBuN9sbkyjMMS7kqk84SvjqEYgH87VvnD5uTDg/FdtLkZC7AVo0xivojVC8 sHkeEIp8JDBhWLVGUOsja6v+vweRGFNIzPHYOYdQpI84GhYtYM3X5F8uhr+WleSmLjSmlm2zg3q4GFkfVfXNt2zGl9uzkFPaox5zM9jQLP4Hur7vlBxP81jD /SJHn4LrYRRYcew99l9pGAXAS/DD/8Kz4AAxiZIv0rTmF/ni7li5jVzzHAgW/k/4OqUCL5SOKOhjwWAElUKd71VjyaOx8uGDgcJWloty6AILHOq4neiGB5FK pFwG44PJ9y02f/DZ7QGtNqdqfvSTHNQ/bQxk4vnDSViVLSIanu2K2M80rBo7T+h5AdAy0bC5xzqZkNJU3S1URwFwA200tg== X-Rspamd-Queue-Id: 4FmvP12DPkz4v8P 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 17:53:57 -0000 In message , Marcin Wojtas writes: > Hi Cy, > > pt., 21 maj 2021 o 16:46 Cy Schubert napisał(a): > > > > In message <02078965-24BE-4F23-92D5-5E8E54A0C3E7@freebsd.org>, Jessica > > Clarke w > > rites: > > > > On 21 May 2021, at 15:11, Marcin Wojtas wrote: > > > > > > > > Hi Jess > > > > > > > > pt., 21 maj 2021 o 15:39 Jessica Clarke napisał(a > ): > > > >> > > > >> On 21 May 2021, at 14:34, Marcin Wojtas wrote: > > > >>> > > > >>> The branch main has been updated by mw: > > > >>> > > > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=af949c590bd8a00a5973b587 > 5d7e > > > 0fa6832ea64a > > > >>> > > > >>> commit af949c590bd8a00a5973b5875d7e0fa6832ea64a > > > >>> Author: Marcin Wojtas > > > >>> AuthorDate: 2021-05-21 09:29:22 +0000 > > > >>> Commit: Marcin Wojtas > > > >>> CommitDate: 2021-05-21 13:33:06 +0000 > > > >>> > > > >>> Disable stack gap for ntpd during build. > > > >>> > > > >>> When starting, ntpd calls setrlimit(2) to limit maximum size of its > > > >>> stack. The stack limit chosen by ntpd is 200K, so when stack gap > > > >>> is enabled, the stack gap is larger than this limit, which results > > > >>> in ntpd crashing. > > > >> > > > >> Isn’t the bug that the unusable gap counts as usage? > > > >> > > > >> Jess > > > >> > > > > > > > > An alternative solution was submitted > > > > (https://reviews.freebsd.org/D29832), so that to extend the limit for > > > > ntpd, but eventually it was recommended to simple disable the stack > > > > gap for it until it's fixed upstream (see the last comment in the > > > > linked revision). > > > > > > That’s my point, there is nothing to “fix” upstream. NTPD uses less > tha > > > n 200K > > > of stack, thus it is perfectly reasonable for it to set its limit to that > . Th > > > e > > > fact that FreeBSD decides to count an arbitrary, non-deterministic amount > of > > > additional unusable virtual address space towards that limit is not its f > ault > > > , > > > but a bug in FreeBSD that needs to be fixed as it’s entirely unreasonab > le f > > > or > > > applications to have to account for that. > > > > This latest problem is not stack gap. It is PIE. > > > > I have to disagree. We are talking cross purposes. Your examples later on in your email prove my point. > ntpd does not start because of stack gap, not PIE, even though it may > seem like PIE causes this. This is due to the fact that stack gap is > disabled if PIE is disabled. Because of that value of sysctl > kern.elf64.aslr.stack_gap does not matter when kern.elf64.aslr.pie_enable > is set to 0. When pie_enabled is set to 1 and stack gap is enabled, then > ntpd fails to start, but when pie_enabled is set to 1 and stack_gap > is set to 0, then ntpd starts without any issue. We verified this on > FreeBSD-CURRENT snapshot from 2021-05-20. I verified the PIE problem on a -CURRENT as of my comments in the review. Enabling stack gap and disabling PIE resolved the issue. The reason for stack gap is not a problem is that ntpd disables stack gap at line 441 of ntpd.c. Furthermore enabling stack gap and disabling PIE circumvents the problem. I tested this myself and left that note in the review. Enable stack gap and disable PIE: It works. But look at line 441 of ntpd.c to see stack gap disabled before ntpd forks itself. > > The fact that this is a stack gap issue can be verified using following > procedure: > 1. Install FreeBSD-CURRENT snapshot from 2021-05-20 using default > configuration. > 2. On a newly installed system start ntpd. With default configuration > it should start successfully. > 3. Set sysctl kern.elf64.aslr.pie_enable=1 and start ntpd. This time ntpd > should fail. An entry indicating that ntpd was killed because of signal > 11 should be visible in /var/log/messages. > 4. Set sysctl kern.elf64.aslr.stack_gap=0 and start ntpd once again. This > time ntpd should start even though pie_enable is set to 1. > > Exact log from the boot it was tested: > root@freebsd-ntpd-test:~ # sysctl -a | grep aslr > kern.elf32.aslr.stack_gap: 3 > kern.elf32.aslr.honor_sbrk: 1 > kern.elf32.aslr.pie_enable: 0 > kern.elf32.aslr.enable: 0 > kern.elf64.aslr.stack_gap: 3 > kern.elf64.aslr.honor_sbrk: 1 > kern.elf64.aslr.pie_enable: 0 > kern.elf64.aslr.enable: 0 > vm.aslr_restarts: 0 > root@freebsd-ntpd-test:~ # ntpd > root@freebsd-ntpd-test:~ # ps aux | grep ntpd > root 826 0.0 0.2 22060 6960 - Ss 17:38 0:00.01 ntpd > root 828 0.0 0.1 12976 2416 0 S+ 17:38 0:00.00 grep ntpd > root@freebsd-ntpd-test:~ # killall ntpd > root@freebsd-ntpd-test:~ # ps aux | grep ntpd > root 831 0.0 0.1 12976 2416 0 S+ 17:38 0:00.00 grep ntpd > root@freebsd-ntpd-test:~ # sysctl kern.elf64.aslr.pie_enable=1 > kern.elf64.aslr.pie_enable: 0 -> 1 This causes the problem. > root@freebsd-ntpd-test:~ # ntpd > root@freebsd-ntpd-test:~ # ps aux | grep ntpd > root 836 0.0 0.1 14128 2452 0 S+ 17:39 0:00.00 grep ntpd > root@freebsd-ntpd-test:~ # cat /var/log/messages | tail > May 21 17:38:25 freebsd-ntpd-test ntpd[826]: ntpd exiting on signal 15 > (Terminated) > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ntpd 4.2.8p15-a (1): Starting > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: Command line: ntpd > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: > ---------------------------------------------------- > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: ntp-4 is maintained by > Network Time Foundation, > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: Inc. (NTF), a non-profit > 501(c)(3) public-benefit > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: corporation. Support and > training for ntp-4 are > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: available at > https://www.nwtime.org/support > May 21 17:39:14 freebsd-ntpd-test ntpd[833]: > ---------------------------------------------------- > May 21 17:39:14 freebsd-ntpd-test kernel: pid 834 (ntpd), jid 0, uid > 0: exited on signal 11 (core dumped) > root@freebsd-ntpd-test:~ # sysctl kern.elf64.aslr.stack_gap=0 > kern.elf64.aslr.stack_gap: 3 -> 0 > root@freebsd-ntpd-test:~ # sysctl -a | grep aslr > kern.elf32.aslr.stack_gap: 3 > kern.elf32.aslr.honor_sbrk: 1 > kern.elf32.aslr.pie_enable: 0 > kern.elf32.aslr.enable: 0 > kern.elf64.aslr.stack_gap: 0 > kern.elf64.aslr.honor_sbrk: 1 > kern.elf64.aslr.pie_enable: 1 This is the problem. > kern.elf64.aslr.enable: 0 > vm.aslr_restarts: 1 > root@freebsd-ntpd-test:~ # ntpd > root@freebsd-ntpd-test:~ # ps aux | grep ntpd > root 845 0.0 0.2 22060 6924 - Ss 17:40 0:00.01 ntpd > root 847 0.0 0.1 12976 2440 0 S+ 17:40 0:00.00 grep ntpd > root@freebsd-ntpd-test:~ # cat /var/log/messages | tail > May 21 17:39:14 freebsd-ntpd-test kernel: pid 834 (ntpd), jid 0, uid > 0: exited on signal 11 (core dumped) > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ntpd 4.2.8p15-a (1): Starting > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: Command line: ntpd > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: > ---------------------------------------------------- > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: ntp-4 is maintained by > Network Time Foundation, > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: Inc. (NTF), a non-profit > 501(c)(3) public-benefit > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: corporation. Support and > training for ntp-4 are > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: available at > https://www.nwtime.org/support > May 21 17:40:52 freebsd-ntpd-test ntpd[844]: > ---------------------------------------------------- > May 21 17:40:52 freebsd-ntpd-test ntpd[845]: leapsecond file > ('/var/db/ntpd.leap-seconds.list'): stat failed: No such file or > directory > root@freebsd-ntpd-test:~ # killall ntpd > > Best regards, > Marcin Running on my firewall, which has had this same ASLR configuration for about a year. cwfw# sysctl kern.elf64.aslr kern.elf64.aslr.stack_gap: 3 kern.elf64.aslr.honor_sbrk: 1 kern.elf64.aslr.pie_enable: 0 kern.elf64.aslr.enable: 1 cwfw# ps auxww | grep ntpd ntpd 1499 0.0 0.1 22044 5776 - Ss 09:30 0:00.28 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g root 3032 0.0 0.0 13044 2384 0 S+ 10:49 0:00.00 grep ntpd cwfw# uptime 10:49AM up 1:20, 1 user, load averages: 1.06, 1.02, 0.97 cwfw# uname -a FreeBSD cwfw 14.0-CURRENT FreeBSD 14.0-CURRENT #151 komquats-n246804-af949c590bd8-dirty: Fri May 21 07:09:32 PDT 2021 root@cwsys:/export/obj/opt/src/git-src/amd64.amd64/sys/PROD2 amd64 cwfw# My laptop: slippy# sysctl kern.elf64.aslr kern.elf64.aslr.stack_gap: 3 kern.elf64.aslr.honor_sbrk: 1 kern.elf64.aslr.pie_enable: 0 kern.elf64.aslr.enable: 1 slippy# ps auxww | grep ntpd ntpd 2100 0.0 0.1 22036 8600 - Ss 09:35 0:00.27 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g root 4632 0.0 0.0 13040 2724 1 S+ 10:51 0:00.00 grep ntpd slippy# uptime 10:51AM up 1:17, 0 users, load averages: 0.11, 0.16, 0.16 slippy# uname -a FreeBSD slippy 14.0-CURRENT FreeBSD 14.0-CURRENT #155 komquats-n246804-af949c590bd8-dirty: Fri May 21 07:07:22 PDT 2021 root@cwsys:/export/obj/opt/src/git-src/amd64.amd64/sys/BREAK amd64 slippy# One of my poudriere machines: cwsys# sysctl kern.elf64.aslr kern.elf64.aslr.stack_gap: 3 kern.elf64.aslr.honor_sbrk: 1 kern.elf64.aslr.pie_enable: 0 kern.elf64.aslr.enable: 1 cwsys# ps auxww | grep ntpd ntpd 4039 0.0 0.1 22040 7340 - Ss 09:34 0:00.46 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g root 6385 0.0 0.0 13044 2712 2 S+ 10:52 0:00.01 grep ntpd cwsys# uptime 10:52AM up 1:19, 2 users, load averages: 0.26, 0.25, 0.24 cwsys# uname -a FreeBSD cwsys 14.0-CURRENT FreeBSD 14.0-CURRENT #155 komquats-n246804-af949c590bd8-dirty: Fri May 21 07:07:22 PDT 2021 root@cwsys:/export/obj/opt/src/git-src/amd64.amd64/sys/BREAK amd64 cwsys# Three examples of stack gap enabled and PIE disabled. When I enable PIE, ntpd fails. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-dev-commits-src-main@freebsd.org Fri May 21 18:50:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93A266398C0; Fri, 21 May 2021 18:50:59 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fmwfq3JGxz3pjR; Fri, 21 May 2021 18:50:59 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qt1-x82a.google.com with SMTP id m13so15998826qtk.13; Fri, 21 May 2021 11:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TOGmC3E9/OdBAAd6wXGZ/sTfMHJGtfGsSiuBncBhl9g=; b=e4K5Hxm/JwOunU6QioxjCV2Owm2bCs/aapPMpXOUjxSev+hBrMDYRldkiNuKg4UcfD iyvw9aq7TLgf3DI4VZ0otbq0PIWH6FzHjIxey6B6Xrl2A09Jz4QfgVR0YfvplOKbk4wF g9VelyLPf4VAcYhIBWyQFJ4fD47l/YGi3EAc2qjqdUbiy5nEFtHlcvLevtgiNjPxUwVv IgSzxGm7JIDtmJRFHXymuGxD5lgdyGsJVBCJDQOtaAVRfqN86gVlpPlYadufWXPcJm/2 Qeuhsnw6rrWSYmOj8PLErM6GFwc3xygqdkQ1W5b97l7Mxqhk8VIsswLEJVNV7NM6RlNq GI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=TOGmC3E9/OdBAAd6wXGZ/sTfMHJGtfGsSiuBncBhl9g=; b=fTzVMj6GlICVnl48U4DFWX7AJ0jumesgTJ/TcCgkndQf9xQI2fJD11o2neDww6x8uu o5qtMHeS8/q4ji+Llcxtq1B+mug1DUqIhgNwq9lKtTy2l+bQGDpHyey/r4J+6M5h/ruM t6gvFGDA/NtAn1WV8nzJp4kTpJN+snT8X1cdWrxIykHKA4DaUx7/BLSfTHAYiruOCRcs a//FArKJcgNAxGrKuca/CxRrxLhKgG20ZtB2tPb+t/jBDKJfQ5ZCBOfPK3a//kC2CySe +hidqPjDJmxDLNAT6xEUxnQ9yATCtT8+xd8p1G/44UXRE7cPo99jD4gsGihPQkWKOUoh hVcQ== X-Gm-Message-State: AOAM531A/zIh83a0EAhRfLpZMJqePR/BafQyiOvGcD5pA2j8cQgz38RD RMSIhX+WnGxaFMw8HexDq7zCN3YnWn8Tnw== X-Google-Smtp-Source: ABdhPJxS6f3vs16PHmGgQ74C2VY1YJ4k5AAx9sUJwOfoM/m48Mx49G/Um01Fn+PqGb5rAY5rYkugvw== X-Received: by 2002:a05:622a:202:: with SMTP id b2mr12583644qtx.343.1621623058335; Fri, 21 May 2021 11:50:58 -0700 (PDT) Received: from nuc ([142.126.172.178]) by smtp.gmail.com with ESMTPSA id c9sm5885463qke.8.2021.05.21.11.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 11:50:57 -0700 (PDT) Sender: Mark Johnston Date: Fri, 21 May 2021 14:50:57 -0400 From: Mark Johnston To: Richard Scheffenegger Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 032bf749fd44 - main - [tcp] Keep socket buffer locked until upcall Message-ID: References: <202105210908.14L98fTa045092@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105210908.14L98fTa045092@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4Fmwfq3JGxz3pjR 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-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 18:50:59 -0000 On Fri, May 21, 2021 at 09:08:41AM +0000, Richard Scheffenegger wrote: > The branch main has been updated by rscheff: > > URL: https://cgit.FreeBSD.org/src/commit/?id=032bf749fd44ac5ff20aab2c3d8e3c05491778ea > > commit 032bf749fd44ac5ff20aab2c3d8e3c05491778ea > Author: Richard Scheffenegger > AuthorDate: 2021-05-21 09:00:53 +0000 > Commit: Richard Scheffenegger > CommitDate: 2021-05-21 09:07:51 +0000 > > [tcp] Keep socket buffer locked until upcall > > r367492 would unlock the socket buffer before eventually calling the upcall. > This leads to problematic interaction with NFS kernel server/client components > (MP threads) accessing the socket buffer with potentially not correctly updated > state. The RACK change at least appears to have introduced a bug: https://syzkaller.appspot.com/bug?id=d7abacdaf60c556dbfa05f15f460cd7174e974ba https://syzkaller.appspot.com/bug?id=650a391473e34b753b280db1c9c97918d23c6cdb From owner-dev-commits-src-main@freebsd.org Fri May 21 19:40:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE07063A4FA; Fri, 21 May 2021 19: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 4Fmxlv5VpGz4g8l; Fri, 21 May 2021 19: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 966961731C; Fri, 21 May 2021 19:40: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 14LJeRqP091575; Fri, 21 May 2021 19:40:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LJeRaL091574; Fri, 21 May 2021 19:40:27 GMT (envelope-from git) Date: Fri, 21 May 2021 19:40:27 GMT Message-Id: <202105211940.14LJeRaL091574@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: fdbc86cf7978 - main - bhyve/snapshot: split up mutex/cond initialization from socket creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdbc86cf79784f56fab8115f2d565962e1111b2e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 19:40:27 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=fdbc86cf79784f56fab8115f2d565962e1111b2e commit fdbc86cf79784f56fab8115f2d565962e1111b2e Author: Robert Wing AuthorDate: 2021-05-15 19:58:21 +0000 Commit: Robert Wing CommitDate: 2021-05-21 19:23:06 +0000 bhyve/snapshot: split up mutex/cond initialization from socket creation Move initialization of the mutex/condition variables required by the save/restore feature to their own function. The unix domain socket that facilitates communication between bhyvectl and bhyve doesn't rely on these variables in order to be functional. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D30281 --- usr.sbin/bhyve/bhyverun.c | 3 +++ usr.sbin/bhyve/snapshot.c | 25 ++++++++++++++++--------- usr.sbin/bhyve/snapshot.h | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index d14219bbef65..acf0df6cc9bf 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -1540,6 +1540,9 @@ main(int argc, char *argv[]) if (restore_file != NULL) destroy_restore_state(&rstate); + /* initialize mutex/cond variables */ + init_snapshot(); + /* * checkpointing thread for communication with bhyvectl */ diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 019f4fdd6cb0..1a06c3e8d065 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -1493,6 +1493,22 @@ checkpoint_thread(void *param) return (NULL); } +void +init_snapshot(void) +{ + int err; + + err = pthread_mutex_init(&vcpu_lock, NULL); + if (err != 0) + errc(1, err, "checkpoint mutex init"); + err = pthread_cond_init(&vcpus_idle, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpus_idle)"); + err = pthread_cond_init(&vcpus_can_run, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpus_can_run)"); +} + /* * Create the listening socket for IPC with bhyvectl */ @@ -1508,15 +1524,6 @@ init_checkpoint_thread(struct vmctx *ctx) memset(&addr, 0, sizeof(addr)); - err = pthread_mutex_init(&vcpu_lock, NULL); - if (err != 0) - errc(1, err, "checkpoint mutex init"); - err = pthread_cond_init(&vcpus_idle, NULL); - if (err == 0) - err = pthread_cond_init(&vcpus_can_run, NULL); - if (err != 0) - errc(1, err, "checkpoint cv init"); - socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); if (socket_fd < 0) { EPRINTLN("Socket creation failed: %s", strerror(errno)); diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h index f28b56cf0a7f..3ffd42fbeabc 100644 --- a/usr.sbin/bhyve/snapshot.h +++ b/usr.sbin/bhyve/snapshot.h @@ -127,6 +127,7 @@ int vm_resume_user_devs(struct vmctx *ctx); int get_checkpoint_msg(int conn_fd, struct vmctx *ctx); void *checkpoint_thread(void *param); int init_checkpoint_thread(struct vmctx *ctx); +void init_snapshot(void); int load_restore_file(const char *filename, struct restore_state *rstate); From owner-dev-commits-src-main@freebsd.org Fri May 21 20:38:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA96063B7E9; Fri, 21 May 2021 20:38: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 4Fmz3149TNz3QZJ; Fri, 21 May 2021 20:38: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 76D7917F96; Fri, 21 May 2021 20:38: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 14LKcbCf062830; Fri, 21 May 2021 20:38:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LKcb3U062829; Fri, 21 May 2021 20:38:37 GMT (envelope-from git) Date: Fri, 21 May 2021 20:38:37 GMT Message-Id: <202105212038.14LKcb3U062829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: f190f9193bc1 - main - Fix fsck_ufs segfaults with gjournal (SU+J) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f190f9193bc10a8193c87e0a02fa91400e4eb159 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 20:38:37 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=f190f9193bc10a8193c87e0a02fa91400e4eb159 commit f190f9193bc10a8193c87e0a02fa91400e4eb159 Author: Kirk McKusick AuthorDate: 2021-05-21 20:41:40 +0000 Commit: Kirk McKusick CommitDate: 2021-05-21 20:42:37 +0000 Fix fsck_ufs segfaults with gjournal (SU+J) The segfault was being hit in ckfini() (sbin/fsck_ffs/fsutil.c) while attempting to traverse the buffer cache to flush dirty buffers. The tail queue used for the buffer cache was not initialized before dropping into gjournal_check(). Move the buffer initialization earlier so that it has been done before calling gjournal_check(). Reported by: crypt47, nvass Fix by: Robert Wing Tested by: Robert Wing PR: 255030 PR: 255979 MFC after: 3 days Sponsored by: Netflix --- sbin/fsck_ffs/main.c | 1 + sbin/fsck_ffs/setup.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 401ee10f9be3..642e321fdd35 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -272,6 +272,7 @@ checkfilesys(char *filesys) * exit status will cause a foreground check to be run. */ sblock_init(); + bufinit(); if (bkgrdcheck) { if ((fsreadfd = open(filesys, O_RDONLY)) < 0 || readsb(0) == 0) exit(3); /* Cannot read superblock */ diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 0ae7f1bbb28f..d69beff879e9 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -298,7 +298,6 @@ setup(char *dev) (uintmax_t)numdirs * sizeof(struct inoinfo *)); goto badsb; } - bufinit(); if (sblock.fs_flags & FS_DOSOFTDEP) usedsoftdep = 1; else From owner-dev-commits-src-main@freebsd.org Fri May 21 20:51:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 732C963B8BE; Fri, 21 May 2021 20:51: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 4FmzLB2p61z3m5c; Fri, 21 May 2021 20:51: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 482EF17FE2; Fri, 21 May 2021 20:51: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 14LKpk53087363; Fri, 21 May 2021 20:51:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LKpi7w087362; Fri, 21 May 2021 20:51:44 GMT (envelope-from git) Date: Fri, 21 May 2021 20:51:44 GMT Message-Id: <202105212051.14LKpi7w087362@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 6680e5a52f8a - main - import nvi 2.2.0-3bbdfe4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6680e5a52f8abf059bbbd3e0be66d9dce476cdf9 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 20:51:46 -0000 The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=6680e5a52f8abf059bbbd3e0be66d9dce476cdf9 commit 6680e5a52f8abf059bbbd3e0be66d9dce476cdf9 Merge: f190f9193bc1 8e6e1224184e Author: Baptiste Daroussin AuthorDate: 2021-05-21 20:50:50 +0000 Commit: Baptiste Daroussin CommitDate: 2021-05-21 20:51:21 +0000 import nvi 2.2.0-3bbdfe4 contrib/nvi/.gitignore | 5 + contrib/nvi/CMakeLists.txt | 38 +- contrib/nvi/cl/cl.h | 3 - contrib/nvi/cl/cl_read.c | 4 +- contrib/nvi/cl/extern.h | 31 -- contrib/nvi/common/common.h | 6 +- contrib/nvi/common/conv.h | 2 +- contrib/nvi/common/exf.c | 27 ++ contrib/nvi/common/extern.h | 131 ------- contrib/nvi/common/key.h | 6 +- contrib/nvi/common/options.h | 4 + contrib/nvi/common/recover.c | 12 + contrib/nvi/ex/ex.c | 3 +- contrib/nvi/ex/ex_cscope.c | 14 + contrib/nvi/ex/extern.h | 131 ------- contrib/nvi/man/vi.1 | 50 ++- contrib/nvi/vi/extern.h | 145 -------- contrib/nvi/vi/v_increment.c | 4 +- contrib/nvi/vi/vs_line.c | 2 +- usr.bin/vi/Makefile | 5 +- usr.bin/vi/config.h | 9 + {contrib/nvi => usr.bin/vi}/ex/version.h | 2 + {contrib/nvi/ex => usr.bin/vi}/ex_def.h | 0 usr.bin/vi/extern.h | 444 +++++++++++++++++++++++ {contrib/nvi/common => usr.bin/vi}/options_def.h | 0 25 files changed, 607 insertions(+), 471 deletions(-) diff --cc contrib/nvi/.gitignore index aac7860d7299,000000000000..2b79229e57e0 mode 100644,000000..100644 --- a/contrib/nvi/.gitignore +++ b/contrib/nvi/.gitignore @@@ -1,9 -1,0 +1,14 @@@ +*.swp +*~ +*.orig +*.core +extern.h +*_def.h +version.h +tags +build/ ++ ++# Ignore files by the GNU Global source code tagging system. ++/GPATH ++/GRTAGS ++/GTAGS diff --cc usr.bin/vi/Makefile index 993970fd3051,000000000000..5769a34c6d2e mode 100644,000000..100644 --- a/usr.bin/vi/Makefile +++ b/usr.bin/vi/Makefile @@@ -1,76 -1,0 +1,77 @@@ +# +# $FreeBSD$ +# + +.include + +PACKAGE= vi +SRCDIR= ${SRCTOP}/contrib/nvi +SUBDIR+= catalog + +WARNS?= 0 # some warn issues on 32 bit machines + +VI= nvi +EX= nex +VIEW= nview + +PROG= nvi + - CFLAGS+= -D__REGEX_PRIVATE ++CFLAGS+= -D__REGEX_PRIVATE -D_XOPEN_SOURCE_EXTENDED=1 + +LINKS= ${BINDIR}/${VI} ${BINDIR}/${EX} ${BINDIR}/${VI} ${BINDIR}/${VIEW} +LINKS+= ${BINDIR}/${VI} ${BINDIR}/vi ${BINDIR}/${EX} ${BINDIR}/ex +LINKS+= ${BINDIR}/${VI} ${BINDIR}/view + +MAN= ${SRCDIR}/man/vi.1 +MLINKS+=vi.1 ex.1 vi.1 view.1 +MLINKS+=vi.1 nex.1 vi.1 nview.1 vi.1 nvi.1 + +.PATH: ${SRCDIR}/common +.PATH: ${SRCDIR}/ex +.PATH: ${SRCDIR}/cl +.PATH: ${SRCDIR}/vi +.PATH: ${SRCDIR}/regex + - CFLAGS+=-I${.CURDIR} -I${SRCDIR} -I${SRCDIR}/regex ++CFLAGS+=-I${.CURDIR} -I${SRCDIR} -I${SRCDIR}/regex \ ++ -I${.CURDIR}/ex + +LIBADD= util ncursesw + +.if ${MK_ICONV} == "yes" && !defined(RESCUE) +CFLAGS+= -DUSE_ICONV -DICONV_TRADITIONAL +.endif + +CLEANFILES+=${EX} + +# Vi curses sources +SRCS+= cl_funcs.c cl_main.c cl_read.c cl_screen.c cl_term.c + +# General sources. +SRCS+= conv.c cut.c delete.c encoding.c exf.c key.c line.c log.c main.c mark.c msg.c options.c \ + options_f.c put.c recover.c screen.c search.c seq.c util.c + +# Ex source. +SRCS+= ex.c ex_abbrev.c ex_append.c ex_args.c ex_argv.c ex_at.c ex_bang.c \ + ex_cd.c ex_cmd.c ex_cscope.c ex_delete.c ex_display.c \ + ex_edit.c ex_equal.c ex_file.c ex_filter.c ex_global.c \ + ex_init.c ex_join.c ex_map.c ex_mark.c ex_mkexrc.c ex_move.c \ + ex_open.c ex_preserve.c ex_print.c ex_put.c ex_quit.c \ + ex_read.c ex_screen.c ex_script.c ex_set.c ex_shell.c \ + ex_shift.c ex_source.c ex_stop.c ex_subst.c ex_tag.c \ + ex_txt.c ex_undo.c ex_usage.c ex_util.c ex_version.c ex_visual.c \ + ex_write.c ex_yank.c ex_z.c + +# Vi source. +SRCS+= getc.c v_at.c v_ch.c v_cmd.c v_delete.c v_ex.c v_increment.c v_init.c \ + v_itxt.c v_left.c v_mark.c v_match.c v_paragraph.c v_put.c v_redraw.c \ + v_replace.c v_right.c v_screen.c v_scroll.c v_search.c v_section.c \ + v_sentence.c v_status.c v_txt.c v_ulcase.c v_undo.c \ + v_util.c v_word.c v_xchar.c v_yank.c v_z.c v_zexit.c vi.c + +# Vi screen source. +SRCS+= vs_line.c vs_msg.c vs_refresh.c vs_relative.c vs_smap.c vs_split.c + +# Wide char regex +SRCS+= regcomp.c regerror.c regexec.c regfree.c + +.include diff --cc usr.bin/vi/config.h index 85ffb2874b34,000000000000..2b4348870db4 mode 100644,000000..100644 --- a/usr.bin/vi/config.h +++ b/usr.bin/vi/config.h @@@ -1,19 -1,0 +1,28 @@@ +/* $FreeBSD$ */ + +/* Define when using wide characters */ +#define USE_WIDECHAR + +/* Define when iconv can be used */ +/* #undef USE_ICONV */ + +/* Define when the 2nd argument of iconv(3) is not const */ +/* #undef ICONV_TRADITIONAL */ + +/* Define if you have */ +#define HAVE_LIBUTIL_H + +/* Define if you have */ +#define HAVE_NCURSES_H + ++/* Define if you have */ ++/* #undef HAVE_NCURSESW_NCURSES_H */ ++ ++/* Define if you have */ ++/* #undef HAVE_PTY_H */ ++ +/* Define if you have */ +#define HAVE_TERM_H ++ ++/* Define if struct dirent has field d_namlen */ ++#define HAVE_DIRENT_D_NAMLEN diff --cc usr.bin/vi/ex/version.h index 742b145ebd3f,000000000000..f14fc879222e mode 100644,000000..100644 --- a/usr.bin/vi/ex/version.h +++ b/usr.bin/vi/ex/version.h @@@ -1,1 -1,0 +1,3 @@@ ++/* $FreeBSD$ */ ++ +#define VI_VERSION "2.2.0 (2020-08-01)" diff --cc usr.bin/vi/ex_def.h index 7afb7b19d677,000000000000..7afb7b19d677 mode 100644,000000..100644 --- a/usr.bin/vi/ex_def.h +++ b/usr.bin/vi/ex_def.h diff --cc usr.bin/vi/extern.h index 000000000000,000000000000..1252726d9d8b new file mode 100644 --- /dev/null +++ b/usr.bin/vi/extern.h @@@ -1,0 -1,0 +1,444 @@@ ++#ifdef CL_IN_EX /* cl.h */ ++int cl_waddstr(SCR *, const CHAR_T *, size_t); ++int cl_addstr(SCR *, const char *, size_t); ++int cl_attr(SCR *, scr_attr_t, int); ++int cl_baud(SCR *, u_long *); ++int cl_bell(SCR *); ++int cl_clrtoeol(SCR *); ++int cl_cursor(SCR *, size_t *, size_t *); ++int cl_deleteln(SCR *); ++int cl_discard(SCR *, SCR **); ++int cl_ex_adjust(SCR *, exadj_t); ++int cl_insertln(SCR *); ++int cl_keyval(SCR *, scr_keyval_t, CHAR_T *, int *); ++int cl_move(SCR *, size_t, size_t); ++int cl_refresh(SCR *, int); ++int cl_rename(SCR *, char *, int); ++void cl_setname(GS *, char *); ++int cl_split(SCR *, SCR *); ++int cl_suspend(SCR *, int *); ++void cl_usage(void); ++int sig_init(GS *, SCR *); ++int cl_event(SCR *, EVENT *, u_int32_t, int); ++int cl_screen(SCR *, u_int32_t); ++int cl_quit(GS *); ++int cl_getcap(SCR *, char *, char **); ++int cl_term_init(SCR *); ++int cl_term_end(GS *); ++int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t); ++int cl_optchange(SCR *, int, char *, u_long *); ++int cl_omesg(SCR *, CL_PRIVATE *, int); ++int cl_ssize(SCR *, int, size_t *, size_t *, int *); ++int cl_putchar(int); ++#endif ++#ifdef EXP /* ex.h */ ++int ex(SCR **); ++int ex_cmd(SCR *); ++int ex_range(SCR *, EXCMD *, int *); ++int ex_is_abbrev(CHAR_T *, size_t); ++int ex_is_unmap(CHAR_T *, size_t); ++void ex_badaddr ++ (SCR *, EXCMDLIST const *, enum badaddr, enum nresult); ++int ex_abbr(SCR *, EXCMD *); ++int ex_unabbr(SCR *, EXCMD *); ++int ex_append(SCR *, EXCMD *); ++int ex_change(SCR *, EXCMD *); ++int ex_insert(SCR *, EXCMD *); ++int ex_next(SCR *, EXCMD *); ++int ex_prev(SCR *, EXCMD *); ++int ex_rew(SCR *, EXCMD *); ++int ex_args(SCR *, EXCMD *); ++char **ex_buildargv(SCR *, EXCMD *, char *); ++int argv_init(SCR *, EXCMD *); ++int argv_exp0(SCR *, EXCMD *, CHAR_T *, size_t); ++int argv_exp1(SCR *, EXCMD *, CHAR_T *, size_t, int); ++int argv_exp2(SCR *, EXCMD *, CHAR_T *, size_t); ++int argv_exp3(SCR *, EXCMD *, CHAR_T *, size_t); ++int argv_flt_ex(SCR *, EXCMD *, CHAR_T *, size_t); ++int argv_free(SCR *); ++int argv_flt_path(SCR *, EXCMD *, CHAR_T *, size_t); ++CHAR_T *argv_esc(SCR *, EXCMD *, CHAR_T *, size_t); ++CHAR_T *argv_uesc(SCR *, EXCMD *, CHAR_T *, size_t); ++int ex_at(SCR *, EXCMD *); ++int ex_bang(SCR *, EXCMD *); ++int ex_cd(SCR *, EXCMD *); ++int ex_cscope(SCR *, EXCMD *); ++int cscope_end(SCR *); ++int cscope_display(SCR *); ++int cscope_search(SCR *, TAGQ *, TAG *); ++int ex_delete(SCR *, EXCMD *); ++int ex_display(SCR *, EXCMD *); ++int ex_edit(SCR *, EXCMD *); ++int ex_equal(SCR *, EXCMD *); ++int ex_file(SCR *, EXCMD *); ++int ex_filter(SCR *, ++ EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype); ++int ex_global(SCR *, EXCMD *); ++int ex_v(SCR *, EXCMD *); ++int ex_g_insdel(SCR *, lnop_t, recno_t); ++int ex_screen_copy(SCR *, SCR *); ++int ex_screen_end(SCR *); ++int ex_optchange(SCR *, int, char *, u_long *); ++int ex_exrc(SCR *); ++int ex_run_str(SCR *, char *, CHAR_T *, size_t, int, int); ++int ex_join(SCR *, EXCMD *); ++int ex_map(SCR *, EXCMD *); ++int ex_unmap(SCR *, EXCMD *); ++int ex_mark(SCR *, EXCMD *); ++int ex_mkexrc(SCR *, EXCMD *); ++int ex_copy(SCR *, EXCMD *); ++int ex_move(SCR *, EXCMD *); ++int ex_open(SCR *, EXCMD *); ++int ex_preserve(SCR *, EXCMD *); ++int ex_recover(SCR *, EXCMD *); ++int ex_list(SCR *, EXCMD *); ++int ex_number(SCR *, EXCMD *); ++int ex_pr(SCR *, EXCMD *); ++int ex_print(SCR *, EXCMD *, MARK *, MARK *, u_int32_t); ++int ex_ldisplay(SCR *, const CHAR_T *, size_t, size_t, u_int); ++int ex_scprint(SCR *, MARK *, MARK *); ++int ex_printf(SCR *, const char *, ...); ++int ex_puts(SCR *, const char *); ++int ex_fflush(SCR *sp); ++int ex_put(SCR *, EXCMD *); ++int ex_quit(SCR *, EXCMD *); ++int ex_read(SCR *, EXCMD *); ++int ex_readfp(SCR *, char *, FILE *, MARK *, recno_t *, int); ++int ex_bg(SCR *, EXCMD *); ++int ex_fg(SCR *, EXCMD *); ++int ex_resize(SCR *, EXCMD *); ++int ex_sdisplay(SCR *); ++int ex_script(SCR *, EXCMD *); ++int sscr_exec(SCR *, recno_t); ++int sscr_input(SCR *); ++int sscr_end(SCR *); ++int ex_set(SCR *, EXCMD *); ++int ex_shell(SCR *, EXCMD *); ++int ex_exec_proc(SCR *, EXCMD *, char *, const char *, int); ++int proc_wait(SCR *, long, const char *, int, int); ++int ex_shiftl(SCR *, EXCMD *); ++int ex_shiftr(SCR *, EXCMD *); ++int ex_retab(SCR *, EXCMD *); ++int ex_source(SCR *, EXCMD *); ++int ex_stop(SCR *, EXCMD *); ++int ex_s(SCR *, EXCMD *); ++int ex_subagain(SCR *, EXCMD *); ++int ex_subtilde(SCR *, EXCMD *); ++int re_compile(SCR *, ++ CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int); ++void re_error(SCR *, int, regex_t *); ++int ex_tag_first(SCR *, CHAR_T *); ++int ex_tag_push(SCR *, EXCMD *); ++int ex_tag_next(SCR *, EXCMD *); ++int ex_tag_prev(SCR *, EXCMD *); ++int ex_tag_nswitch(SCR *, TAG *, int); ++int ex_tag_Nswitch(SCR *, TAG *, int); ++int ex_tag_pop(SCR *, EXCMD *); ++int ex_tag_top(SCR *, EXCMD *); ++int ex_tag_display(SCR *); ++int ex_tag_copy(SCR *, SCR *); ++int tagq_free(SCR *, TAGQ *); ++int tagq_push(SCR*, TAGQ*, int, int ); ++void tag_msg(SCR *, tagmsg_t, char *); ++int ex_tagf_alloc(SCR *, char *); ++int ex_tag_free(SCR *); ++int ex_txt(SCR *, TEXTH *, ARG_CHAR_T, u_int32_t); ++int ex_undo(SCR *, EXCMD *); ++int ex_help(SCR *, EXCMD *); ++int ex_usage(SCR *, EXCMD *); ++int ex_viusage(SCR *, EXCMD *); ++void ex_cinit(SCR *, EXCMD *, int, int, recno_t, recno_t, int); ++int ex_getline(SCR *, FILE *, size_t *); ++int ex_ncheck(SCR *, int); ++int ex_init(SCR *); ++void ex_wemsg(SCR *, CHAR_T *, exm_t); ++void ex_emsg(SCR *, char *, exm_t); ++int ex_version(SCR *, EXCMD *); ++int ex_visual(SCR *, EXCMD *); ++int ex_wn(SCR *, EXCMD *); ++int ex_wq(SCR *, EXCMD *); ++int ex_write(SCR *, EXCMD *); ++int ex_xit(SCR *, EXCMD *); ++int ex_writefp(SCR *, ++ char *, FILE *, MARK *, MARK *, u_long *, u_long *, int); ++int ex_yank(SCR *, EXCMD *); ++int ex_z(SCR *, EXCMD *); ++#endif ++#ifdef V_ABS /* vi.h */ ++int cs_init(SCR *, VCS *); ++int cs_next(SCR *, VCS *); ++int cs_fspace(SCR *, VCS *); ++int cs_fblank(SCR *, VCS *); ++int cs_prev(SCR *, VCS *); ++int cs_bblank(SCR *, VCS *); ++int v_at(SCR *, VICMD *); ++int v_chrepeat(SCR *, VICMD *); ++int v_chrrepeat(SCR *, VICMD *); ++int v_cht(SCR *, VICMD *); ++int v_chf(SCR *, VICMD *); ++int v_chT(SCR *, VICMD *); ++int v_chF(SCR *, VICMD *); ++int v_delete(SCR *, VICMD *); ++int v_again(SCR *, VICMD *); ++int v_exmode(SCR *, VICMD *); ++int v_join(SCR *, VICMD *); ++int v_shiftl(SCR *, VICMD *); ++int v_shiftr(SCR *, VICMD *); ++int v_suspend(SCR *, VICMD *); ++int v_switch(SCR *, VICMD *); ++int v_tagpush(SCR *, VICMD *); ++int v_tagpop(SCR *, VICMD *); ++int v_filter(SCR *, VICMD *); ++int v_ex(SCR *, VICMD *); ++int v_ecl_exec(SCR *); ++int v_increment(SCR *, VICMD *); ++int v_screen_copy(SCR *, SCR *); ++int v_screen_end(SCR *); ++int v_optchange(SCR *, int, char *, u_long *); ++int v_iA(SCR *, VICMD *); ++int v_ia(SCR *, VICMD *); ++int v_iI(SCR *, VICMD *); ++int v_ii(SCR *, VICMD *); ++int v_iO(SCR *, VICMD *); ++int v_io(SCR *, VICMD *); ++int v_change(SCR *, VICMD *); ++int v_Replace(SCR *, VICMD *); ++int v_subst(SCR *, VICMD *); ++int v_left(SCR *, VICMD *); ++int v_cfirst(SCR *, VICMD *); ++int v_first(SCR *, VICMD *); ++int v_ncol(SCR *, VICMD *); ++int v_zero(SCR *, VICMD *); ++int v_mark(SCR *, VICMD *); ++int v_bmark(SCR *, VICMD *); ++int v_fmark(SCR *, VICMD *); ++int v_emark(SCR *, VICMD *); ++int v_match(SCR *, VICMD *); ++int v_buildmcs(SCR *, char *); ++int v_paragraphf(SCR *, VICMD *); ++int v_paragraphb(SCR *, VICMD *); ++int v_buildps(SCR *, char *, char *); ++int v_Put(SCR *, VICMD *); ++int v_put(SCR *, VICMD *); ++int v_redraw(SCR *, VICMD *); ++int v_replace(SCR *, VICMD *); ++int v_right(SCR *, VICMD *); ++int v_dollar(SCR *, VICMD *); ++int v_screen(SCR *, VICMD *); ++int v_lgoto(SCR *, VICMD *); ++int v_home(SCR *, VICMD *); ++int v_middle(SCR *, VICMD *); ++int v_bottom(SCR *, VICMD *); ++int v_up(SCR *, VICMD *); ++int v_cr(SCR *, VICMD *); ++int v_down(SCR *, VICMD *); ++int v_hpageup(SCR *, VICMD *); ++int v_hpagedown(SCR *, VICMD *); ++int v_pagedown(SCR *, VICMD *); ++int v_pageup(SCR *, VICMD *); ++int v_lineup(SCR *, VICMD *); ++int v_linedown(SCR *, VICMD *); ++int v_searchb(SCR *, VICMD *); ++int v_searchf(SCR *, VICMD *); ++int v_searchN(SCR *, VICMD *); ++int v_searchn(SCR *, VICMD *); ++int v_searchw(SCR *, VICMD *); ++int v_correct(SCR *, VICMD *, int); ++int v_sectionf(SCR *, VICMD *); ++int v_sectionb(SCR *, VICMD *); ++int v_sentencef(SCR *, VICMD *); ++int v_sentenceb(SCR *, VICMD *); ++int v_status(SCR *, VICMD *); ++int v_tcmd(SCR *, VICMD *, ARG_CHAR_T, u_int); ++int v_txt(SCR *, VICMD *, MARK *, ++ const CHAR_T *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t); ++int v_txt_auto(SCR *, recno_t, TEXT *, size_t, TEXT *); ++int v_ulcase(SCR *, VICMD *); ++int v_mulcase(SCR *, VICMD *); ++int v_Undo(SCR *, VICMD *); ++int v_undo(SCR *, VICMD *); ++void v_eof(SCR *, MARK *); ++void v_eol(SCR *, MARK *); ++void v_nomove(SCR *); ++void v_sof(SCR *, MARK *); ++void v_sol(SCR *); ++int v_isempty(CHAR_T *, size_t); ++void v_emsg(SCR *, char *, vim_t); ++int v_wordW(SCR *, VICMD *); ++int v_wordw(SCR *, VICMD *); ++int v_wordE(SCR *, VICMD *); ++int v_worde(SCR *, VICMD *); ++int v_wordB(SCR *, VICMD *); ++int v_wordb(SCR *, VICMD *); ++int v_xchar(SCR *, VICMD *); ++int v_Xchar(SCR *, VICMD *); ++int v_yank(SCR *, VICMD *); ++int v_z(SCR *, VICMD *); ++int vs_crel(SCR *, long); ++int v_zexit(SCR *, VICMD *); ++int vi(SCR **); ++int v_curword(SCR *); ++int vs_line(SCR *, SMAP *, size_t *, size_t *); ++int vs_number(SCR *); ++void vs_busy(SCR *, const char *, busy_t); ++void vs_home(SCR *); ++void vs_update(SCR *, const char *, const CHAR_T *); ++void vs_msg(SCR *, mtype_t, char *, size_t); ++int vs_ex_resolve(SCR *, int *); ++int vs_resolve(SCR *, SCR *, int); ++int vs_repaint(SCR *, EVENT *); ++int vs_refresh(SCR *, int); ++int vs_column(SCR *, size_t *); ++size_t vs_screens(SCR *, recno_t, size_t *); ++size_t vs_columns(SCR *, CHAR_T *, recno_t, size_t *, size_t *); ++size_t vs_rcm(SCR *, recno_t, int); ++size_t vs_colpos(SCR *, recno_t, size_t); ++int vs_change(SCR *, recno_t, lnop_t); ++int vs_sm_fill(SCR *, recno_t, pos_t); ++int vs_sm_scroll(SCR *, MARK *, recno_t, scroll_t); ++int vs_sm_1up(SCR *); ++int vs_sm_1down(SCR *); ++int vs_sm_next(SCR *, SMAP *, SMAP *); ++int vs_sm_prev(SCR *, SMAP *, SMAP *); ++int vs_sm_cursor(SCR *, SMAP **); ++int vs_sm_position(SCR *, MARK *, u_long, pos_t); ++recno_t vs_sm_nlines(SCR *, SMAP *, recno_t, size_t); ++int vs_split(SCR *, SCR *, int); ++int vs_vsplit(SCR *, SCR *); ++int vs_discard(SCR *, SCR **); ++int vs_fg(SCR *, SCR **, CHAR_T *, int); ++int vs_bg(SCR *); ++int vs_swap(SCR *, SCR **, char *); ++int vs_resize(SCR *, long, adj_t); ++#endif /* common.h */ ++char * codeset(void); ++void conv_init(SCR *, SCR *); ++int conv_enc(SCR *, int, char *); ++void conv_end(SCR *); ++int cut(SCR *, CHAR_T *, MARK *, MARK *, int); ++int cut_line(SCR *, recno_t, size_t, size_t, CB *); ++void cut_close(GS *); ++TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t); ++void text_lfree(TEXTH *); ++void text_free(TEXT *); ++int del(SCR *, MARK *, MARK *, int); ++int looks_utf8(const char *, size_t); ++int looks_utf16(const char *, size_t); ++int decode_utf8(const char *); ++int decode_utf16(const char *, int); ++FREF *file_add(SCR *, char *); ++int file_init(SCR *, FREF *, char *, int); ++int file_end(SCR *, EXF *, int); ++int file_write(SCR *, MARK *, MARK *, char *, int); ++int file_m1(SCR *, int, int); ++int file_m2(SCR *, int); ++int file_m3(SCR *, int); ++int file_aw(SCR *, int); ++void set_alt_name(SCR *, char *); ++lockr_t file_lock(SCR *, char *, int, int); ++int v_key_init(SCR *); ++void v_key_ilookup(SCR *); ++size_t v_key_len(SCR *, ARG_CHAR_T); ++char *v_key_name(SCR *, ARG_CHAR_T); ++e_key_t v_key_val(SCR *, ARG_CHAR_T); ++int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int); ++int v_event_get(SCR *, EVENT *, int, u_int32_t); ++void v_event_err(SCR *, EVENT *); ++int v_event_flush(SCR *, u_int); ++int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *); ++int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *); ++int db_delete(SCR *, recno_t); ++int db_append(SCR *, int, recno_t, CHAR_T *, size_t); ++int db_insert(SCR *, recno_t, CHAR_T *, size_t); ++int db_set(SCR *, recno_t, CHAR_T *, size_t); ++int db_exist(SCR *, recno_t); ++int db_last(SCR *, recno_t *); ++int db_rget(SCR *, recno_t, char **, size_t *); ++int db_rset(SCR *, recno_t, char *, size_t); ++void db_err(SCR *, recno_t); ++int log_init(SCR *, EXF *); ++int log_end(SCR *, EXF *); ++int log_cursor(SCR *); ++int log_line(SCR *, recno_t, u_int); ++int log_mark(SCR *, LMARK *); ++int log_backward(SCR *, MARK *); ++int log_setline(SCR *); ++int log_forward(SCR *, MARK *); ++int editor(GS *, int, char *[]); ++void v_end(GS *); ++int mark_init(SCR *, EXF *); ++int mark_end(SCR *, EXF *); ++int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t); ++int mark_set(SCR *, ARG_CHAR_T, MARK *, int); ++int mark_insdel(SCR *, lnop_t, recno_t); ++void msgq(SCR *, mtype_t, const char *, ...); ++void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *); ++void msgq_str(SCR *, mtype_t, const char *, const char *); ++void mod_rpt(SCR *); ++void msgq_status(SCR *, recno_t, u_int); ++int msg_open(SCR *, char *); ++void msg_close(GS *); ++const char *msg_cmsg(SCR *, cmsg_t, size_t *); ++const char *msg_cat(SCR *, const char *, size_t *); ++char *msg_print(SCR *, const char *, int *); ++int opts_init(SCR *, int *); ++int opts_set(SCR *, ARGS *[], char *); ++int o_set(SCR *, int, u_int, char *, u_long); ++int opts_empty(SCR *, int, int); ++void opts_dump(SCR *, enum optdisp); ++int opts_save(SCR *, FILE *); ++OPTLIST const *opts_search(CHAR_T *); ++void opts_nomatch(SCR *, CHAR_T *); ++int opts_copy(SCR *, SCR *); ++void opts_free(SCR *); ++int f_altwerase(SCR *, OPTION *, char *, u_long *); ++int f_columns(SCR *, OPTION *, char *, u_long *); ++int f_lines(SCR *, OPTION *, char *, u_long *); ++int f_lisp(SCR *, OPTION *, char *, u_long *); ++int f_msgcat(SCR *, OPTION *, char *, u_long *); ++int f_print(SCR *, OPTION *, char *, u_long *); ++int f_readonly(SCR *, OPTION *, char *, u_long *); ++int f_recompile(SCR *, OPTION *, char *, u_long *); ++int f_reformat(SCR *, OPTION *, char *, u_long *); ++int f_ttywerase(SCR *, OPTION *, char *, u_long *); ++int f_w300(SCR *, OPTION *, char *, u_long *); ++int f_w1200(SCR *, OPTION *, char *, u_long *); ++int f_w9600(SCR *, OPTION *, char *, u_long *); ++int f_window(SCR *, OPTION *, char *, u_long *); ++int f_encoding(SCR *, OPTION *, char *, u_long *); ++int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int); ++int rcv_tmp(SCR *, EXF *, char *); ++int rcv_init(SCR *); ++int rcv_sync(SCR *, u_int); ++int rcv_list(SCR *); ++int rcv_read(SCR *, FREF *); ++int screen_init(GS *, SCR *, SCR **); ++int screen_end(SCR *); ++SCR *screen_next(SCR *); ++int f_search(SCR *, ++ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); ++int b_search(SCR *, ++ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); ++void search_busy(SCR *, busy_t); ++int seq_set(SCR *, CHAR_T *, ++ size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int); ++int seq_delete(SCR *, CHAR_T *, size_t, seq_t); ++int seq_free(SEQ *); ++SEQ *seq_find ++ (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *); ++void seq_close(GS *); ++int seq_dump(SCR *, seq_t, int); ++int seq_save(SCR *, FILE *, char *, seq_t); ++int e_memcmp(CHAR_T *, EVENT *, size_t); ++void *binc(SCR *, void *, size_t *, size_t); ++int nonblank(SCR *, recno_t, size_t *); ++char *join(char *, char *); ++char *expanduser(char *); ++char *quote(char *); ++char *v_strdup(SCR *, const char *, size_t); ++CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t); ++enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int); ++enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int); ++void timepoint_steady(struct timespec *); ++void timepoint_system(struct timespec *); ++void TRACE(SCR *, const char *, ...); diff --cc usr.bin/vi/options_def.h index 54dd6c20c891,000000000000..54dd6c20c891 mode 100644,000000..100644 --- a/usr.bin/vi/options_def.h +++ b/usr.bin/vi/options_def.h From owner-dev-commits-src-main@freebsd.org Fri May 21 21:45:30 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 822E163C450; Fri, 21 May 2021 21:45: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 4Fn0XB2yv3z4gMZ; Fri, 21 May 2021 21:45: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 4DF5918ACA; Fri, 21 May 2021 21:45: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 14LLjU4r055449; Fri, 21 May 2021 21:45:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LLjUGX055448; Fri, 21 May 2021 21:45:30 GMT (envelope-from git) Date: Fri, 21 May 2021 21:45:30 GMT Message-Id: <202105212145.14LLjUGX055448@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7d2608a5d24e - main - tcp: Make error handling in tcp_usr_send() more consistent MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7d2608a5d24ec3534dad7f24191f12a8181ea206 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 21:45:30 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7d2608a5d24ec3534dad7f24191f12a8181ea206 commit 7d2608a5d24ec3534dad7f24191f12a8181ea206 Author: Mark Johnston AuthorDate: 2021-05-21 21:44:40 +0000 Commit: Mark Johnston CommitDate: 2021-05-21 21:45:18 +0000 tcp: Make error handling in tcp_usr_send() more consistent - Free the input mbuf in a single place instead of in every error path. - Handle PRUS_NOTREADY consistently. - Flush the socket's send buffer if an implicit connect fails. At that point the mbuf has already been enqueued but we don't want to keep it in the send buffer. Reviewed by: gallatin, tuexen Discussed with: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30349 --- sys/netinet/tcp_usrreq.c | 67 +++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 693cf553de44..37bedc0125c9 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -993,13 +993,6 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { if (control) m_freem(control); - - /* - * In case of PRUS_NOTREADY, tcp_usr_ready() is responsible - * for freeing memory. - */ - if ((flags & PRUS_NOTREADY) == 0) - m_freem(m); error = ECONNRESET; goto out; } @@ -1007,7 +1000,6 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, /* TCP doesn't do control messages (rights, creds, etc) */ if (control->m_len) { m_freem(control); - m_freem(m); error = EINVAL; goto out; } @@ -1015,13 +1007,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, control = NULL; } tp = intotcpcb(inp); - if (flags & PRUS_OOB) { - if ((error = tcp_pru_options_support(tp, PRUS_OOB)) != 0) { - if ((flags & PRUS_NOTREADY) == 0) - m_freem(m); - goto out; - } - } + if ((flags & PRUS_OOB) != 0 && + (error = tcp_pru_options_support(tp, PRUS_OOB)) != 0) + goto out; + TCPDEBUG1(); if (nam != NULL && tp->t_state < TCPS_SYN_SENT) { switch (nam->sa_family) { @@ -1029,30 +1018,24 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, case AF_INET: sinp = (struct sockaddr_in *)nam; if (sinp->sin_len != sizeof(struct sockaddr_in)) { - m_freem(m); error = EINVAL; goto out; } if ((inp->inp_vflag & INP_IPV6) != 0) { - m_freem(m); error = EAFNOSUPPORT; goto out; } if (IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) { - m_freem(m); error = EAFNOSUPPORT; goto out; } if (ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) { - m_freem(m); error = EACCES; goto out; } if ((error = prison_remote_ip4(td->td_ucred, - &sinp->sin_addr))) { - m_freem(m); + &sinp->sin_addr))) goto out; - } #ifdef INET6 isipv6 = 0; #endif @@ -1065,17 +1048,14 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, sin6 = (struct sockaddr_in6 *)nam; if (sin6->sin6_len != sizeof(*sin6)) { - m_freem(m); error = EINVAL; goto out; } if ((inp->inp_vflag & INP_IPV6PROTO) == 0) { - m_freem(m); error = EAFNOSUPPORT; goto out; } if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { - m_freem(m); error = EAFNOSUPPORT; goto out; } @@ -1083,12 +1063,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, #ifdef INET if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) { error = EINVAL; - m_freem(m); goto out; } if ((inp->inp_vflag & INP_IPV4) == 0) { error = EAFNOSUPPORT; - m_freem(m); goto out; } restoreflags = true; @@ -1098,23 +1076,18 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (IN_MULTICAST( ntohl(sinp->sin_addr.s_addr))) { error = EAFNOSUPPORT; - m_freem(m); goto out; } if ((error = prison_remote_ip4(td->td_ucred, - &sinp->sin_addr))) { - m_freem(m); + &sinp->sin_addr))) goto out; - } isipv6 = 0; #else /* !INET */ error = EAFNOSUPPORT; - m_freem(m); goto out; #endif /* INET */ } else { if ((inp->inp_vflag & INP_IPV6) == 0) { - m_freem(m); error = EAFNOSUPPORT; goto out; } @@ -1122,23 +1095,21 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, inp->inp_vflag &= ~INP_IPV4; inp->inp_inc.inc_flags |= INC_ISIPV6; if ((error = prison_remote_ip6(td->td_ucred, - &sin6->sin6_addr))) { - m_freem(m); + &sin6->sin6_addr))) goto out; - } isipv6 = 1; } break; } #endif /* INET6 */ default: - m_freem(m); error = EAFNOSUPPORT; goto out; } } if (!(flags & PRUS_OOB)) { sbappendstream(&so->so_snd, m, flags); + m = NULL; if (nam && tp->t_state < TCPS_SYN_SENT) { /* * Do implied connect if not yet connected, @@ -1164,8 +1135,11 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (error == 0 || inp->inp_lport != 0) restoreflags = false; - if (error) + if (error) { + /* m is freed if PRUS_NOTREADY is unset. */ + sbflush(&so->so_snd); goto out; + } if (IS_FASTOPEN(tp->t_flags)) tcp_fastopen_connect(tp); else { @@ -1206,7 +1180,6 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, SOCKBUF_LOCK(&so->so_snd); if (sbspace(&so->so_snd) < -512) { SOCKBUF_UNLOCK(&so->so_snd); - m_freem(m); error = ENOBUFS; goto out; } @@ -1220,6 +1193,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, */ sbappendstream_locked(&so->so_snd, m, flags); SOCKBUF_UNLOCK(&so->so_snd); + m = NULL; if (nam && tp->t_state < TCPS_SYN_SENT) { /* * Do implied connect if not yet connected, @@ -1251,13 +1225,16 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (error == 0 || inp->inp_lport != 0) restoreflags = false; - if (error) + if (error != 0) { + /* m is freed if PRUS_NOTREADY is unset. */ + sbflush(&so->so_snd); goto out; + } tp->snd_wnd = TTCP_CLIENT_SND_WND; tcp_mss(tp, -1); } tp->snd_up = tp->snd_una + sbavail(&so->so_snd); - if (!(flags & PRUS_NOTREADY)) { + if ((flags & PRUS_NOTREADY) == 0) { tp->t_flags |= TF_FORCEDATA; error = tp->t_fb->tfb_tcp_output(tp); tp->t_flags &= ~TF_FORCEDATA; @@ -1268,7 +1245,15 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, &inp->inp_socket->so_snd, TCP_LOG_USERSEND, error, 0, NULL, false); + out: + /* + * In case of PRUS_NOTREADY, the caller or tcp_usr_ready() is + * responsible for freeing memory. + */ + if (m != NULL && (flags & PRUS_NOTREADY) == 0) + m_freem(m); + /* * If the request was unsuccessful and we changed flags, * restore the original flags. From owner-dev-commits-src-main@freebsd.org Fri May 21 21:45:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D219363C4C5; Fri, 21 May 2021 21:45: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 4Fn0XC4hfZz4g5C; Fri, 21 May 2021 21:45: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 84E1718D35; Fri, 21 May 2021 21:45: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 14LLjVfE055476; Fri, 21 May 2021 21:45:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LLjVq5055475; Fri, 21 May 2021 21:45:31 GMT (envelope-from git) Date: Fri, 21 May 2021 21:45:31 GMT Message-Id: <202105212145.14LLjVq5055475@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 916c61a5ed37 - main - Fix handling of errors from pru_send(PRUS_NOTREADY) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 916c61a5ed37da8ecdedd3c5512813d8dcec9a24 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 21:45:31 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=916c61a5ed37da8ecdedd3c5512813d8dcec9a24 commit 916c61a5ed37da8ecdedd3c5512813d8dcec9a24 Author: Mark Johnston AuthorDate: 2021-05-21 21:44:46 +0000 Commit: Mark Johnston CommitDate: 2021-05-21 21:45:19 +0000 Fix handling of errors from pru_send(PRUS_NOTREADY) PRUS_NOTREADY indicates that the caller has not yet populated the chain with data, and so it is not ready for transmission. This is used by sendfile (for async I/O) and KTLS (for encryption). In particular, if pru_send returns an error, the caller is responsible for freeing the chain since other implicit references to the data buffers exist. For async sendfile, it happens that an error will only be returned if the connection was dropped, in which case tcp_usr_ready() will handle freeing the chain. But since KTLS can be used in conjunction with the regular socket I/O system calls, many more error cases - which do not result in the connection being dropped - are reachable. In these cases, KTLS was effectively assuming success. So: - Change sosend_generic() to free the mbuf chain if pru_send(PRUS_NOTREADY) fails. Nothing else owns a reference to the chain at that point. - Similarly, in vn_sendfile() change the !async I/O && KTLS case to free the chain. - If async I/O is still outstanding when pru_send fails in vn_sendfile(), set an error in the sfio structure so that the connection is aborted and the mbuf chain is freed. Reviewed by: gallatin, tuexen Discussed with: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30349 --- sys/kern/kern_sendfile.c | 12 ++++++++---- sys/kern/uipc_socket.c | 19 +++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 520b7c9c62d0..ac1072ca2406 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -1175,8 +1175,12 @@ prepend_header: if (tls != NULL && tls->mode == TCP_TLS_MODE_SW) { error = (*so->so_proto->pr_usrreqs->pru_send) (so, PRUS_NOTREADY, m, NULL, NULL, td); - soref(so); - ktls_enqueue(m, so, tls_enq_cnt); + if (error != 0) { + m_freem(m); + } else { + soref(so); + ktls_enqueue(m, so, tls_enq_cnt); + } } else #endif error = (*so->so_proto->pr_usrreqs->pru_send) @@ -1187,11 +1191,11 @@ prepend_header: soref(so); error = (*so->so_proto->pr_usrreqs->pru_send) (so, PRUS_NOTREADY, m, NULL, NULL, td); - sendfile_iodone(sfio, NULL, 0, 0); + sendfile_iodone(sfio, NULL, 0, error); } CURVNET_RESTORE(); - m = NULL; /* pru_send always consumes */ + m = NULL; if (error) goto done; sbytes += space + hdrlen; diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2a167eb68a22..0ca87bfc522a 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1767,18 +1767,13 @@ restart: #ifdef KERN_TLS if (tls != NULL && tls->mode == TCP_TLS_MODE_SW) { - /* - * Note that error is intentionally - * ignored. - * - * Like sendfile(), we rely on the - * completion routine (pru_ready()) - * to free the mbufs in the event that - * pru_send() encountered an error and - * did not append them to the sockbuf. - */ - soref(so); - ktls_enqueue(top, so, tls_enq_cnt); + if (error != 0) { + m_freem(top); + top = NULL; + } else { + soref(so); + ktls_enqueue(top, so, tls_enq_cnt); + } } #endif clen = 0; From owner-dev-commits-src-main@freebsd.org Fri May 21 22:16:04 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9356463CE66; Fri, 21 May 2021 22:16: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 4Fn1CS3cnGz4tbq; Fri, 21 May 2021 22:16: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 6039819252; Fri, 21 May 2021 22:16: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 14LMG4DC095928; Fri, 21 May 2021 22:16:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LMG4I5095927; Fri, 21 May 2021 22:16:04 GMT (envelope-from git) Date: Fri, 21 May 2021 22:16:04 GMT Message-Id: <202105212216.14LMG4I5095927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 39756885633f - main - rack: honor prior socket buffer lock when doing the upcall MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 39756885633fd9d9649b4cb0f0abf594bfeb8dbb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 22:16:04 -0000 The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=39756885633fd9d9649b4cb0f0abf594bfeb8dbb commit 39756885633fd9d9649b4cb0f0abf594bfeb8dbb Author: Richard Scheffenegger AuthorDate: 2021-05-21 22:08:56 +0000 Commit: Richard Scheffenegger CommitDate: 2021-05-21 22:09:59 +0000 rack: honor prior socket buffer lock when doing the upcall While partially reverting D24237 with D29690, due to introducing some unintended effects for in-kernel TCP consumers, the preexisting lock on the socket send buffer was not considered properly. Found by: markj MFC after: 2 weeks Reviewed By: tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D30390 --- sys/netinet/tcp_stacks/rack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index efab90a2e5bd..47f4c6835de9 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -10629,7 +10629,7 @@ rack_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so, rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); /* Wake up the socket if we have room to write more */ rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); - sowwakeup(so); + sowwakeup_locked(so); m_freem(mfree); tp->t_rxtshift = 0; RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), @@ -13154,7 +13154,7 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb rack_adjust_sendmap(rack, &so->so_snd, tp->snd_una); /* Wake up the socket if we have room to write more */ rack_log_wakeup(tp,rack, &so->so_snd, acked, 2); - sowwakeup(so); + sowwakeup_locked(so); m_freem(mfree); } /* update progress */ From owner-dev-commits-src-main@freebsd.org Sat May 22 01:44:33 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77AFB6409B1; Sat, 22 May 2021 01:44: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 4Fn5r12bHTz4dXP; Sat, 22 May 2021 01:44: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 40EA31C188; Sat, 22 May 2021 01:44: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 14M1iXNO074013; Sat, 22 May 2021 01:44:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M1iXww074012; Sat, 22 May 2021 01:44:33 GMT (envelope-from git) Date: Sat, 22 May 2021 01:44:33 GMT Message-Id: <202105220144.14M1iXww074012@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: 73e77cf90ba3 - main - Netmap: fix documentation for NR_REG_NIC_SW mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 73e77cf90ba35809adefcc6cd129da5ef15c8e9d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 01:44:33 -0000 The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=73e77cf90ba35809adefcc6cd129da5ef15c8e9d commit 73e77cf90ba35809adefcc6cd129da5ef15c8e9d Author: Allan Jude AuthorDate: 2021-05-17 23:07:53 +0000 Commit: Allan Jude CommitDate: 2021-05-22 01:44:23 +0000 Netmap: fix documentation for NR_REG_NIC_SW mode The correct character to add to the intername name is *, not + Reviewed by: vmaffione, bcr Sponsored By: Klara Inc. Differential Revision: https://reviews.freebsd.org/D30324 --- share/man/man4/netmap.4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/netmap.4 b/share/man/man4/netmap.4 index d247c44b0df8..732e3bfaeaab 100644 --- a/share/man/man4/netmap.4 +++ b/share/man/man4/netmap.4 @@ -655,7 +655,7 @@ In the example below, "netmap:foo" is any valid netmap port name. (default) all hardware ring pairs .It NR_REG_SW "netmap:foo^" the ``host rings'', connecting to the host stack. -.It NR_REG_NIC_SW "netmap:foo+" +.It NR_REG_NIC_SW "netmap:foo*" all hardware rings and the host rings .It NR_REG_ONE_NIC "netmap:foo-i" only the i-th hardware ring pair, where the number is in From owner-dev-commits-src-main@freebsd.org Sat May 22 01:56:29 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ED9BF6412E6; Sat, 22 May 2021 01:56: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 4Fn65n6Q9jz4jNv; Sat, 22 May 2021 01:56: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 C475D1C222; Sat, 22 May 2021 01:56: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 14M1uTYo088097; Sat, 22 May 2021 01:56:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M1uTFD088096; Sat, 22 May 2021 01:56:29 GMT (envelope-from git) Date: Sat, 22 May 2021 01:56:29 GMT Message-Id: <202105220156.14M1uTFD088096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: 20d684ecc9d7 - main - pkt-gen: Allow limiting received packets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 20d684ecc9d7d9128774f2e3c287058868f48bb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 01:56:30 -0000 The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=20d684ecc9d7d9128774f2e3c287058868f48bb0 commit 20d684ecc9d7d9128774f2e3c287058868f48bb0 Author: Allan Jude AuthorDate: 2021-05-17 23:04:08 +0000 Commit: Allan Jude CommitDate: 2021-05-22 01:55:29 +0000 pkt-gen: Allow limiting received packets Makes pkg-gen quit after having received N packets, the same way it already supports doing for sent packets. Reviewed by: vmaffione Sponsored by: Klara Inc. MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D30266 --- tools/tools/netmap/pkt-gen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index c958af3b9781..b24915e150a5 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -1816,6 +1816,7 @@ receiver_body(void *data) struct netmap_ring *rxring; int i; struct my_ctrs cur; + uint64_t n = targ->g->npackets / targ->g->nthreads; memset(&cur, 0, sizeof(cur)); @@ -1843,7 +1844,7 @@ receiver_body(void *data) /* main loop, exit after 1s silence */ clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); if (targ->g->dev_type == DEV_TAP) { - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) {) { char buf[MAX_BODYSIZE]; /* XXX should we poll ? */ i = read(targ->g->main_fd, buf, sizeof(buf)); @@ -1855,7 +1856,7 @@ receiver_body(void *data) } #ifndef NO_PCAP } else if (targ->g->dev_type == DEV_PCAP) { - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* XXX should we poll ? */ pcap_dispatch(targ->g->p, targ->g->burst, receive_pcap, (u_char *)&targ->ctr); @@ -1866,7 +1867,7 @@ receiver_body(void *data) int dump = targ->g->options & OPT_DUMP; nifp = targ->nmd->nifp; - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* Once we started to receive packets, wait at most 1 seconds before quitting. */ #ifdef BUSYWAIT From owner-dev-commits-src-main@freebsd.org Sat May 22 03:50:17 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE8C164339C; Sat, 22 May 2021 03:50: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 4Fn8d55jdbz4dpb; Sat, 22 May 2021 03:50: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 ACDB31D4E2; Sat, 22 May 2021 03:50: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 14M3oHpF041986; Sat, 22 May 2021 03:50:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M3oHUV041980; Sat, 22 May 2021 03:50:17 GMT (envelope-from git) Date: Sat, 22 May 2021 03:50:17 GMT Message-Id: <202105220350.14M3oHUV041980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: ffbb373c5a95 - main - cxgbe(4): Fix build warnings with NOINET kernels. 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/main X-Git-Reftype: branch X-Git-Commit: ffbb373c5a95c37be693330a76a093fbcf546440 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 03:50:17 -0000 The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=ffbb373c5a95c37be693330a76a093fbcf546440 commit ffbb373c5a95c37be693330a76a093fbcf546440 Author: Navdeep Parhar AuthorDate: 2021-05-22 03:42:04 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-22 03:42:04 +0000 cxgbe(4): Fix build warnings with NOINET kernels. MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26334 --- sys/dev/cxgbe/t4_sge.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 8a5dc6acc745..4b685129193e 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -333,7 +333,9 @@ static void drain_wrq_wr_list(struct adapter *, struct sge_wrq *); static int sysctl_bufsizes(SYSCTL_HANDLER_ARGS); #ifdef RATELIMIT +#if defined(INET) || defined(INET6) static inline u_int txpkt_eo_len16(u_int, u_int, u_int); +#endif static int ethofld_fw4_ack(struct sge_iq *, const struct rss_header *, struct mbuf *); #endif @@ -1497,12 +1499,14 @@ service_iq(struct sge_iq *iq, int budget) return (0); } +#if defined(INET) || defined(INET6) static inline int sort_before_lro(struct lro_ctrl *lro) { return (lro->lro_mbuf_max != 0); } +#endif static inline uint64_t last_flit_to_ns(struct adapter *sc, uint64_t lf) @@ -2311,6 +2315,7 @@ mbuf_eo_nsegs(struct mbuf *m) return (m->m_pkthdr.PH_loc.eight[1]); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_nsegs(struct mbuf *m, uint8_t nsegs) { @@ -2318,6 +2323,7 @@ set_mbuf_eo_nsegs(struct mbuf *m, uint8_t nsegs) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[1] = nsegs; } +#endif static inline int mbuf_eo_len16(struct mbuf *m) @@ -2331,6 +2337,7 @@ mbuf_eo_len16(struct mbuf *m) return (n); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_len16(struct mbuf *m, uint8_t len16) { @@ -2338,6 +2345,7 @@ set_mbuf_eo_len16(struct mbuf *m, uint8_t len16) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[2] = len16; } +#endif static inline int mbuf_eo_tsclk_tsoff(struct mbuf *m) @@ -2347,6 +2355,7 @@ mbuf_eo_tsclk_tsoff(struct mbuf *m) return (m->m_pkthdr.PH_loc.eight[3]); } +#if defined(INET) || defined(INET6) static inline void set_mbuf_eo_tsclk_tsoff(struct mbuf *m, uint8_t tsclk_tsoff) { @@ -2354,6 +2363,7 @@ set_mbuf_eo_tsclk_tsoff(struct mbuf *m, uint8_t tsclk_tsoff) M_ASSERTPKTHDR(m); m->m_pkthdr.PH_loc.eight[3] = tsclk_tsoff; } +#endif static inline int needs_eo(struct m_snd_tag *mst) @@ -2434,6 +2444,7 @@ needs_vxlan_tso(struct mbuf *m) (m->m_pkthdr.csum_flags & csum_flags) != CSUM_ENCAP_VXLAN); } +#if defined(INET) || defined(INET6) static inline bool needs_inner_tcp_csum(struct mbuf *m) { @@ -2443,6 +2454,7 @@ needs_inner_tcp_csum(struct mbuf *m) return (m->m_pkthdr.csum_flags & csum_flags); } +#endif static inline bool needs_l3_csum(struct mbuf *m) @@ -6421,6 +6433,7 @@ sysctl_bufsizes(SYSCTL_HANDLER_ARGS) } #ifdef RATELIMIT +#if defined(INET) || defined(INET6) /* * len16 for a txpkt WR with a GL. Includes the firmware work request header. */ @@ -6444,6 +6457,7 @@ txpkt_eo_len16(u_int nsegs, u_int immhdrs, u_int tso) done: return (howmany(n, 16)); } +#endif #define ETID_FLOWC_NPARAMS 6 #define ETID_FLOWC_LEN (roundup2((sizeof(struct fw_flowc_wr) + \ From owner-dev-commits-src-main@freebsd.org Sat May 22 09:06:54 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9678964889D; Sat, 22 May 2021 09:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FnHfQ3m7nz59Sb; Sat, 22 May 2021 09:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 65D6921AA9; Sat, 22 May 2021 09:06:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14M96saU059951; Sat, 22 May 2021 09:06:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M96spe059950; Sat, 22 May 2021 09:06:54 GMT (envelope-from git) Date: Sat, 22 May 2021 09:06:54 GMT Message-Id: <202105220906.14M96spe059950@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 33621dfc196e - main - Refactor core dumping code a bit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: trasz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 33621dfc196e317026aa8b9d916567598a1cedcb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 09:06:54 -0000 The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=33621dfc196e317026aa8b9d916567598a1cedcb commit 33621dfc196e317026aa8b9d916567598a1cedcb Author: Edward Tomasz Napierala AuthorDate: 2021-05-22 08:58:35 +0000 Commit: Edward Tomasz Napierala CommitDate: 2021-05-22 08:59:00 +0000 Refactor core dumping code a bit This makes it possible to use core_write(), core_output(), and sbuf_drain_core_output(), in Linux coredump code. Moving them out of imgact_elf.c is necessary because of the weird way it's being built. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30369 --- sys/kern/imgact_elf.c | 160 -------------------------------------------------- sys/kern/kern_exec.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ sys/sys/exec.h | 19 ++++++ 3 files changed, 166 insertions(+), 160 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 563629b747b5..15976d143988 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -106,8 +106,6 @@ SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW | CTLFLAG_MPSAFE, 0, ""); -#define CORE_BUF_SIZE (16 * 1024) - int __elfN(fallback_brand) = -1; SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, fallback_brand, CTLFLAG_RWTUN, &__elfN(fallback_brand), 0, @@ -1454,23 +1452,11 @@ struct note_info { TAILQ_HEAD(note_info_list, note_info); -/* Coredump output parameters. */ -struct coredump_params { - off_t offset; - struct ucred *active_cred; - struct ucred *file_cred; - struct thread *td; - struct vnode *vp; - struct compressor *comp; -}; - extern int compress_user_cores; extern int compress_user_cores_level; static void cb_put_phdr(vm_map_entry_t, void *); static void cb_size_segment(vm_map_entry_t, void *); -static int core_write(struct coredump_params *, const void *, size_t, off_t, - enum uio_seg, size_t *); static void each_dumpable_segment(struct thread *, segment_callback, void *, int); static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t, @@ -1480,7 +1466,6 @@ static void __elfN(prepare_notes)(struct thread *, struct note_info_list *, static void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int); static void __elfN(putnote)(struct note_info *, struct sbuf *); static size_t register_note(struct note_info_list *, int, outfunc_t, void *); -static int sbuf_drain_core_output(void *, const char *, int); static void __elfN(note_fpregset)(void *, struct sbuf *, size_t *); static void __elfN(note_prpsinfo)(void *, struct sbuf *, size_t *); @@ -1498,34 +1483,6 @@ static void note_procstat_rlimit(void *, struct sbuf *, size_t *); static void note_procstat_umask(void *, struct sbuf *, size_t *); static void note_procstat_vmmap(void *, struct sbuf *, size_t *); -/* - * Write out a core segment to the compression stream. - */ -static int -compress_chunk(struct coredump_params *p, char *base, char *buf, u_int len) -{ - u_int chunk_len; - int error; - - while (len > 0) { - chunk_len = MIN(len, CORE_BUF_SIZE); - - /* - * We can get EFAULT error here. - * In that case zero out the current chunk of the segment. - */ - error = copyin(base, buf, chunk_len); - if (error != 0) - bzero(buf, chunk_len); - error = compressor_write(p->comp, buf, chunk_len); - if (error != 0) - break; - base += chunk_len; - len -= chunk_len; - } - return (error); -} - static int core_compressed_write(void *base, size_t len, off_t offset, void *arg) { @@ -1534,123 +1491,6 @@ core_compressed_write(void *base, size_t len, off_t offset, void *arg) UIO_SYSSPACE, NULL)); } -static int -core_write(struct coredump_params *p, const void *base, size_t len, - off_t offset, enum uio_seg seg, size_t *resid) -{ - - return (vn_rdwr_inchunks(UIO_WRITE, p->vp, __DECONST(void *, base), - len, offset, seg, IO_UNIT | IO_DIRECT | IO_RANGELOCKED, - p->active_cred, p->file_cred, resid, p->td)); -} - -static int -core_output(char *base, size_t len, off_t offset, struct coredump_params *p, - void *tmpbuf) -{ - vm_map_t map; - struct mount *mp; - size_t resid, runlen; - int error; - bool success; - - KASSERT((uintptr_t)base % PAGE_SIZE == 0, - ("%s: user address %p is not page-aligned", __func__, base)); - - if (p->comp != NULL) - return (compress_chunk(p, base, tmpbuf, len)); - - map = &p->td->td_proc->p_vmspace->vm_map; - for (; len > 0; base += runlen, offset += runlen, len -= runlen) { - /* - * Attempt to page in all virtual pages in the range. If a - * virtual page is not backed by the pager, it is represented as - * a hole in the file. This can occur with zero-filled - * anonymous memory or truncated files, for example. - */ - for (runlen = 0; runlen < len; runlen += PAGE_SIZE) { - error = vm_fault(map, (uintptr_t)base + runlen, - VM_PROT_READ, VM_FAULT_NOFILL, NULL); - if (runlen == 0) - success = error == KERN_SUCCESS; - else if ((error == KERN_SUCCESS) != success) - break; - } - - if (success) { - error = core_write(p, base, runlen, offset, - UIO_USERSPACE, &resid); - if (error != 0) { - if (error != EFAULT) - break; - - /* - * EFAULT may be returned if the user mapping - * could not be accessed, e.g., because a mapped - * file has been truncated. Skip the page if no - * progress was made, to protect against a - * hypothetical scenario where vm_fault() was - * successful but core_write() returns EFAULT - * anyway. - */ - runlen -= resid; - if (runlen == 0) { - success = false; - runlen = PAGE_SIZE; - } - } - } - if (!success) { - error = vn_start_write(p->vp, &mp, V_WAIT); - if (error != 0) - break; - vn_lock(p->vp, LK_EXCLUSIVE | LK_RETRY); - error = vn_truncate_locked(p->vp, offset + runlen, - false, p->td->td_ucred); - VOP_UNLOCK(p->vp); - vn_finished_write(mp); - if (error != 0) - break; - } - } - return (error); -} - -/* - * Drain into a core file. - */ -static int -sbuf_drain_core_output(void *arg, const char *data, int len) -{ - struct coredump_params *p; - int error, locked; - - p = (struct coredump_params *)arg; - - /* - * Some kern_proc out routines that print to this sbuf may - * call us with the process lock held. Draining with the - * non-sleepable lock held is unsafe. The lock is needed for - * those routines when dumping a live process. In our case we - * can safely release the lock before draining and acquire - * again after. - */ - locked = PROC_LOCKED(p->td->td_proc); - if (locked) - PROC_UNLOCK(p->td->td_proc); - if (p->comp != NULL) - error = compressor_write(p->comp, __DECONST(char *, data), len); - else - error = core_write(p, __DECONST(void *, data), len, p->offset, - UIO_SYSSPACE, NULL); - if (locked) - PROC_LOCK(p->td->td_proc); - if (error != 0) - return (-error); - p->offset += len; - return (len); -} - int __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 22a050019ce0..04dedfa59c9b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1867,3 +1868,149 @@ exec_unregister(const struct execsw *execsw_arg) execsw = newexecsw; return (0); } + +/* + * Write out a core segment to the compression stream. + */ +static int +compress_chunk(struct coredump_params *p, char *base, char *buf, u_int len) +{ + u_int chunk_len; + int error; + + while (len > 0) { + chunk_len = MIN(len, CORE_BUF_SIZE); + + /* + * We can get EFAULT error here. + * In that case zero out the current chunk of the segment. + */ + error = copyin(base, buf, chunk_len); + if (error != 0) + bzero(buf, chunk_len); + error = compressor_write(p->comp, buf, chunk_len); + if (error != 0) + break; + base += chunk_len; + len -= chunk_len; + } + return (error); +} + +int +core_write(struct coredump_params *p, const void *base, size_t len, + off_t offset, enum uio_seg seg, size_t *resid) +{ + + return (vn_rdwr_inchunks(UIO_WRITE, p->vp, __DECONST(void *, base), + len, offset, seg, IO_UNIT | IO_DIRECT | IO_RANGELOCKED, + p->active_cred, p->file_cred, resid, p->td)); +} + +int +core_output(char *base, size_t len, off_t offset, struct coredump_params *p, + void *tmpbuf) +{ + vm_map_t map; + struct mount *mp; + size_t resid, runlen; + int error; + bool success; + + KASSERT((uintptr_t)base % PAGE_SIZE == 0, + ("%s: user address %p is not page-aligned", __func__, base)); + + if (p->comp != NULL) + return (compress_chunk(p, base, tmpbuf, len)); + + map = &p->td->td_proc->p_vmspace->vm_map; + for (; len > 0; base += runlen, offset += runlen, len -= runlen) { + /* + * Attempt to page in all virtual pages in the range. If a + * virtual page is not backed by the pager, it is represented as + * a hole in the file. This can occur with zero-filled + * anonymous memory or truncated files, for example. + */ + for (runlen = 0; runlen < len; runlen += PAGE_SIZE) { + error = vm_fault(map, (uintptr_t)base + runlen, + VM_PROT_READ, VM_FAULT_NOFILL, NULL); + if (runlen == 0) + success = error == KERN_SUCCESS; + else if ((error == KERN_SUCCESS) != success) + break; + } + + if (success) { + error = core_write(p, base, runlen, offset, + UIO_USERSPACE, &resid); + if (error != 0) { + if (error != EFAULT) + break; + + /* + * EFAULT may be returned if the user mapping + * could not be accessed, e.g., because a mapped + * file has been truncated. Skip the page if no + * progress was made, to protect against a + * hypothetical scenario where vm_fault() was + * successful but core_write() returns EFAULT + * anyway. + */ + runlen -= resid; + if (runlen == 0) { + success = false; + runlen = PAGE_SIZE; + } + } + } + if (!success) { + error = vn_start_write(p->vp, &mp, V_WAIT); + if (error != 0) + break; + vn_lock(p->vp, LK_EXCLUSIVE | LK_RETRY); + error = vn_truncate_locked(p->vp, offset + runlen, + false, p->td->td_ucred); + VOP_UNLOCK(p->vp); + vn_finished_write(mp); + if (error != 0) + break; + } + } + return (error); +} + +/* + * Drain into a core file. + */ +int +sbuf_drain_core_output(void *arg, const char *data, int len) +{ + struct coredump_params *p; + int error, locked; + + p = (struct coredump_params *)arg; + + /* + * Some kern_proc out routines that print to this sbuf may + * call us with the process lock held. Draining with the + * non-sleepable lock held is unsafe. The lock is needed for + * those routines when dumping a live process. In our case we + * can safely release the lock before draining and acquire + * again after. + */ + locked = PROC_LOCKED(p->td->td_proc); + if (locked) + PROC_UNLOCK(p->td->td_proc); + if (p->comp != NULL) + error = compressor_write(p->comp, __DECONST(char *, data), len); + else + error = core_write(p, __DECONST(void *, data), len, p->offset, + UIO_SYSSPACE, NULL); + if (locked) + PROC_LOCK(p->td->td_proc); + if (error != 0) + return (-error); + p->offset += len; + return (len); +} + diff --git a/sys/sys/exec.h b/sys/sys/exec.h index c7b3aa8b9550..39ebb7efee47 100644 --- a/sys/sys/exec.h +++ b/sys/sys/exec.h @@ -60,6 +60,16 @@ struct ps_strings { unsigned int ps_nenvstr; /* the number of environment strings */ }; +/* Coredump output parameters. */ +struct coredump_params { + off_t offset; + struct ucred *active_cred; + struct ucred *file_cred; + struct thread *td; + struct vnode *vp; + struct compressor *comp; +}; + struct image_params; struct execsw { @@ -84,6 +94,15 @@ void exec_unmap_first_page(struct image_params *); int exec_register(const struct execsw *); int exec_unregister(const struct execsw *); +enum uio_seg; + +#define CORE_BUF_SIZE (16 * 1024) + +int core_write(struct coredump_params *, const void *, size_t, off_t, + enum uio_seg, size_t *); +int core_output(char *, size_t, off_t, struct coredump_params *, void *); +int sbuf_drain_core_output(void *, const char *, int); + extern int coredump_pack_fileinfo; extern int coredump_pack_vmmapinfo; From owner-dev-commits-src-main@freebsd.org Sat May 22 09:31:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98AE6648F1C; Sat, 22 May 2021 09:31: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 4FnJBz3kXFz3Mt3; Sat, 22 May 2021 09:31: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 68C8321E78; Sat, 22 May 2021 09:31: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 14M9VdND095517; Sat, 22 May 2021 09:31:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M9Vdm2095516; Sat, 22 May 2021 09:31:39 GMT (envelope-from git) Date: Sat, 22 May 2021 09:31:39 GMT Message-Id: <202105220931.14M9Vdm2095516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d713bf79273a - main - vn_need_pageq_flush(): simplify MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d713bf79273ad928f591dee2f8a553487e515e9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 09:31:39 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d713bf79273ad928f591dee2f8a553487e515e9b commit d713bf79273ad928f591dee2f8a553487e515e9b Author: Konstantin Belousov AuthorDate: 2021-05-21 07:34:27 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 09:29:44 +0000 vn_need_pageq_flush(): simplify There is no need to own vnode interlock, since v_object is type stable and can only change to/from NULL, and no other checks in the function access fields protected by the interlock. Remove the need variable, the result of the test is directly usable as return value. Tested by: mav, pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/vfs_subr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 18c5b5b3b148..620d3e974397 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5184,14 +5184,10 @@ int vn_need_pageq_flush(struct vnode *vp) { struct vm_object *obj; - int need; - MPASS(mtx_owned(VI_MTX(vp))); - need = 0; - if ((obj = vp->v_object) != NULL && (vp->v_vflag & VV_NOSYNC) == 0 && - vm_object_mightbedirty(obj)) - need = 1; - return (need); + obj = vp->v_object; + return (obj != NULL && (vp->v_vflag & VV_NOSYNC) == 0 && + vm_object_mightbedirty(obj)); } /* From owner-dev-commits-src-main@freebsd.org Sat May 22 09:31:40 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D692E649129; Sat, 22 May 2021 09:31: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 4FnJC05C1zz3Mn3; Sat, 22 May 2021 09:31: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 900112235F; Sat, 22 May 2021 09:31: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 14M9VeAg095538; Sat, 22 May 2021 09:31:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14M9VewJ095537; Sat, 22 May 2021 09:31:40 GMT (envelope-from git) Date: Sat, 22 May 2021 09:31:40 GMT Message-Id: <202105220931.14M9VewJ095537@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 42881526d401 - main - nullfs: dirty v_object must imply the need for inactivation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 42881526d401e7a9c09241e392b7ffa18cfe11d6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 09:31:41 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=42881526d401e7a9c09241e392b7ffa18cfe11d6 commit 42881526d401e7a9c09241e392b7ffa18cfe11d6 Author: Konstantin Belousov AuthorDate: 2021-05-21 07:30:19 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 09:30:17 +0000 nullfs: dirty v_object must imply the need for inactivation Otherwise pages are cleaned some time later when the lower fs decides that it is time to do it. This mostly manifests itself as delayed mtime update, e.g. breaking make-like programs. Reported by: mav Tested by: mav, pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/fs/nullfs/null_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 5bf470897c08..aeebce4ed086 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -818,7 +818,7 @@ static int null_need_inactive(struct vop_need_inactive_args *ap) { - return (null_want_recycle(ap->a_vp)); + return (null_want_recycle(ap->a_vp) || vn_need_pageq_flush(ap->a_vp)); } /* From owner-dev-commits-src-main@freebsd.org Sat May 22 10:56:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D83A664ABE6; Sat, 22 May 2021 10:56: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 4FnL555RXfz4mXk; Sat, 22 May 2021 10:56: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 86A0D230F5; Sat, 22 May 2021 10:56: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 14MAufR6005378; Sat, 22 May 2021 10:56:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MAufEi005377; Sat, 22 May 2021 10:56:41 GMT (envelope-from git) Date: Sat, 22 May 2021 10:56:41 GMT Message-Id: <202105221056.14MAufEi005377@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: d6fd321ef60d - main - run(4): add support for ASUS USB-N14 wireless adaptor. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d6fd321ef60d43dce9f437187c94a7de2b91ab69 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 10:56:42 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=d6fd321ef60d43dce9f437187c94a7de2b91ab69 commit d6fd321ef60d43dce9f437187c94a7de2b91ab69 Author: Dmitry Chagin AuthorDate: 2021-05-22 10:52:12 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-22 10:52:12 +0000 run(4): add support for ASUS USB-N14 wireless adaptor. PR: 255759 Submitted by: john.lmurdoch at gmail.com MFC After: 1 week --- sys/dev/usb/usbdevs | 1 + sys/dev/usb/wlan/if_run.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index d92d98614b07..91a243e26bac 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1266,6 +1266,7 @@ product ASUS USBN66 0x17ad USB-N66 product ASUS USBN10NANO 0x17ba USB-N10 Nano product ASUS USBAC51 0x17d1 USB-AC51 product ASUS USBAC56 0x17d2 USB-AC56 +product ASUS USBN14 0x17e8 USB-N14 product ASUS A730W 0x4202 ASUS MyPal A730W product ASUS P535 0x420f ASUS P535 PDA product ASUS GMSC 0x422f ASUS Generic Mass Storage diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index dbbdc9bdcbd2..c7f0ae40f666 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -173,6 +173,7 @@ static const STRUCT_USB_HOST_ID run_devs[] = { RUN_DEV(ASUS, RT3070_1), RUN_DEV(ASUS, USBN66), RUN_DEV(ASUS, USB_N53), + RUN_DEV(ASUS, USBN14), RUN_DEV(ASUS2, USBN11), RUN_DEV(AZUREWAVE, RT2870_1), RUN_DEV(AZUREWAVE, RT2870_2), From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65CC664C9B6; Sat, 22 May 2021 12:16: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 4FnMsd2Nh1z4Rmg; Sat, 22 May 2021 12:16: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 3A1FC244DD; Sat, 22 May 2021 12:16: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 14MCGrKm011697; Sat, 22 May 2021 12:16:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGr8C011696; Sat, 22 May 2021 12:16:53 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:53 GMT Message-Id: <202105221216.14MCGr8C011696@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 70c05850e276 - main - kern_descrip.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/main X-Git-Reftype: branch X-Git-Commit: 70c05850e276624bb3eb928fa52160712909ec7b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:53 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=70c05850e276624bb3eb928fa52160712909ec7b commit 70c05850e276624bb3eb928fa52160712909ec7b Author: Konstantin Belousov AuthorDate: 2021-05-14 23:22:22 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:08 +0000 kern_descrip.c: Style Wrap too long lines. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_descrip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 30ac40ffe296..168bddda9c45 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -4405,17 +4405,20 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, /* working directory */ if (pwd->pwd_cdir != NULL) { vrefact(pwd->pwd_cdir); - export_vnode_to_sb(pwd->pwd_cdir, KF_FD_TYPE_CWD, FREAD, efbuf); + export_vnode_to_sb(pwd->pwd_cdir, KF_FD_TYPE_CWD, + FREAD, efbuf); } /* root directory */ if (pwd->pwd_rdir != NULL) { vrefact(pwd->pwd_rdir); - export_vnode_to_sb(pwd->pwd_rdir, KF_FD_TYPE_ROOT, FREAD, efbuf); + export_vnode_to_sb(pwd->pwd_rdir, KF_FD_TYPE_ROOT, + FREAD, efbuf); } /* jail directory */ if (pwd->pwd_jdir != NULL) { vrefact(pwd->pwd_jdir); - export_vnode_to_sb(pwd->pwd_jdir, KF_FD_TYPE_JAIL, FREAD, efbuf); + export_vnode_to_sb(pwd->pwd_jdir, KF_FD_TYPE_JAIL, + FREAD, efbuf); } } PWDDESC_XUNLOCK(pdp); From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:54 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9AB7164C842; Sat, 22 May 2021 12:16: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 4FnMsf3V0pz4Rvt; Sat, 22 May 2021 12:16: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 58DCF24178; Sat, 22 May 2021 12:16: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 14MCGsTw011718; Sat, 22 May 2021 12:16:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGsvi011717; Sat, 22 May 2021 12:16:54 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:54 GMT Message-Id: <202105221216.14MCGsvi011717@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9bb84c23e762 - main - accounting: explicitly mark the exiting thread as doing accounting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9bb84c23e762e7d1b6154ef4afdcc80662692e76 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:54 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9bb84c23e762e7d1b6154ef4afdcc80662692e76 commit 9bb84c23e762e7d1b6154ef4afdcc80662692e76 Author: Konstantin Belousov AuthorDate: 2021-05-13 23:48:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:08 +0000 accounting: explicitly mark the exiting thread as doing accounting and use the mark to stop applying file size limits on the write of the accounting record. This allows to remove hack to clear process limits in acct_process(), and avoids the bug with the clearing being ineffective because limits are also cached in the thread structure. Reported and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_acct.c | 26 +++++--------------------- sys/kern/vfs_vnops.c | 3 ++- sys/sys/proc.h | 1 + 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 675113c6b2ba..4c1efada10da 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -141,7 +141,6 @@ static int acct_configured; static int acct_suspended; static struct vnode *acct_vp; static struct ucred *acct_cred; -static struct plimit *acct_limit; static int acct_flags; static struct sx acct_sx; @@ -206,7 +205,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, i, replacing; + int error, flags, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -276,15 +275,6 @@ sys_acct(struct thread *td, struct acct_args *uap) return (error); } - /* - * Create our own plimit object without limits. It will be assigned - * to exiting processes. - */ - acct_limit = lim_alloc(); - for (i = 0; i < RLIM_NLIMITS; i++) - acct_limit->pl_rlimit[i].rlim_cur = - acct_limit->pl_rlimit[i].rlim_max = RLIM_INFINITY; - /* * Save the new accounting file vnode, and schedule the new * free space watcher. @@ -328,7 +318,6 @@ acct_disable(struct thread *td, int logging) sx_assert(&acct_sx, SX_XLOCKED); error = vn_close(acct_vp, acct_flags, acct_cred, td); crfree(acct_cred); - lim_free(acct_limit); acct_configured = 0; acct_vp = NULL; acct_cred = NULL; @@ -349,7 +338,6 @@ acct_process(struct thread *td) { struct acctv3 acct; struct timeval ut, st, tmp; - struct plimit *oldlim; struct proc *p; struct rusage ru; int t, ret; @@ -374,6 +362,7 @@ acct_process(struct thread *td) } p = td->td_proc; + td->td_pflags2 |= TDP2_ACCT; /* * Get process accounting information. @@ -426,20 +415,14 @@ acct_process(struct thread *td) /* (8) The boolean flags that tell how the process terminated, etc. */ acct.ac_flagx = p->p_acflag; + PROC_UNLOCK(p); + /* Setup ancillary structure fields. */ acct.ac_flagx |= ANVER; acct.ac_zero = 0; acct.ac_version = 3; acct.ac_len = acct.ac_len2 = sizeof(acct); - /* - * Eliminate rlimits (file size limit in particular). - */ - oldlim = p->p_limit; - p->p_limit = lim_hold(acct_limit); - PROC_UNLOCK(p); - lim_free(oldlim); - /* * Write the accounting information to the file. */ @@ -447,6 +430,7 @@ acct_process(struct thread *td) (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, acct_cred, NOCRED, NULL, td); sx_sunlock(&acct_sx); + td->td_pflags2 &= ~TDP2_ACCT; return (ret); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6bf798cd73c5..69da69da19d4 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2360,7 +2360,8 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) { - if (vp->v_type != VREG || td == NULL) + if (vp->v_type != VREG || td == NULL || + (td->td_pflags2 & TDP2_ACCT) != 0) return (0); if ((uoff_t)uio->uio_offset + uio->uio_resid > lim_cur(td, RLIMIT_FSIZE)) { diff --git a/sys/sys/proc.h b/sys/sys/proc.h index ebd396b4aebe..d957412424aa 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -528,6 +528,7 @@ do { \ #define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */ #define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */ +#define TDP2_ACCT 0x00000004 /* Doing accounting */ /* * Reasons that the current thread can not be run yet. From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:58 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9687764CB83; Sat, 22 May 2021 12:16: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 4FnMsk03mWz4S84; Sat, 22 May 2021 12:16: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 A79C3244DE; Sat, 22 May 2021 12:16: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 14MCGvqY011788; Sat, 22 May 2021 12:16:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGvs7011787; Sat, 22 May 2021 12:16:57 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:57 GMT Message-Id: <202105221216.14MCGvs7011787@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 02645b886bc6 - main - ktrace: use the limit of the trace initiator for file size limit on writes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02645b886bc62dfd8a998fd51d2e6c1bbca03ecb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:58 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=02645b886bc62dfd8a998fd51d2e6c1bbca03ecb commit 02645b886bc62dfd8a998fd51d2e6c1bbca03ecb Author: Konstantin Belousov AuthorDate: 2021-05-14 23:51:01 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:09 +0000 ktrace: use the limit of the trace initiator for file size limit on writes Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_ktrace.c | 6 ++++++ sys/kern/vfs_vnops.c | 18 ++++++++++-------- sys/sys/proc.h | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index c03eea4991a1..b686f2e2717a 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -148,6 +149,7 @@ static struct sx ktrace_sx; struct ktr_io_params { struct vnode *vp; struct ucred *cr; + off_t lim; u_int refs; }; @@ -465,6 +467,7 @@ ktr_io_params_alloc(struct thread *td, struct vnode *vp) res = malloc(sizeof(struct ktr_io_params), M_KTRACE, M_WAITOK); res->vp = vp; res->cr = crhold(td->td_ucred); + res->lim = lim_cur(td, RLIMIT_FSIZE); res->refs = 1; return (res); } @@ -1255,6 +1258,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) struct uio auio; struct iovec aiov[3]; struct mount *mp; + off_t lim; int datalen, buflen; int error; @@ -1282,6 +1286,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) vp = kiop->vp; cred = kiop->cr; + lim = kiop->lim; vrefact(vp); KASSERT(cred != NULL, ("ktr_writerequest: cred == NULL")); @@ -1319,6 +1324,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) vn_start_write(vp, &mp, V_WAIT); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + td->td_ktr_io_lim = lim; #ifdef MAC error = mac_vnode_check_write(cred, NOCRED, vp); if (error == 0) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 69da69da19d4..9c309c83f805 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2359,18 +2359,20 @@ int vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) { + off_t lim; if (vp->v_type != VREG || td == NULL || (td->td_pflags2 & TDP2_ACCT) != 0) return (0); - if ((uoff_t)uio->uio_offset + uio->uio_resid > - lim_cur(td, RLIMIT_FSIZE)) { - PROC_LOCK(td->td_proc); - kern_psignal(td->td_proc, SIGXFSZ); - PROC_UNLOCK(td->td_proc); - return (EFBIG); - } - return (0); + ktr_write = (td->td_pflags & TDP_INKTRACE) != 0; + lim = ktr_write ? td->td_ktr_io_lim : lim_cur(td, RLIMIT_FSIZE); + if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) + return (0); + + PROC_LOCK(td->td_proc); + kern_psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); + return (EFBIG); } int diff --git a/sys/sys/proc.h b/sys/sys/proc.h index c54d4399f948..926f0de14b84 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -378,6 +378,7 @@ struct thread { void *td_lkpi_task; /* LinuxKPI task struct pointer */ int td_pmcpend; void *td_coredump; /* (c) coredump request. */ + off_t td_ktr_io_lim; /* (k) limit for ktrace file size */ #ifdef EPOCH_TRACE SLIST_HEAD(, epoch_tracker) td_epochs; #endif From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:59 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 96D8664CB85; Sat, 22 May 2021 12:16: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 4FnMsl0cbBz4S1M; Sat, 22 May 2021 12:16: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 C43A22439E; Sat, 22 May 2021 12:16: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 14MCGwL0011809; Sat, 22 May 2021 12:16:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGw20011808; Sat, 22 May 2021 12:16:58 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:58 GMT Message-Id: <202105221216.14MCGw20011808@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ea2b64c24133 - main - ktrace: add a kern.ktrace.filesize_limit_signal knob MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ea2b64c2413355ac0d5fc6ff597342e9437a34d4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:59 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ea2b64c2413355ac0d5fc6ff597342e9437a34d4 commit ea2b64c2413355ac0d5fc6ff597342e9437a34d4 Author: Konstantin Belousov AuthorDate: 2021-05-18 16:05:39 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:09 +0000 ktrace: add a kern.ktrace.filesize_limit_signal knob When enabled, writes to ktrace.out that exceed the max file size limit cause SIGXFSZ as it should be, but note that the limit is taken from the process that initiated ktrace. When disabled, write is blocked, but signal is not send. Note that in either case ktrace for the affected process is stopped. Requested and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_ktrace.c | 10 ++++++++++ sys/kern/vfs_vnops.c | 10 +++++++--- sys/sys/ktrace.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index b686f2e2717a..8783600df6b1 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -142,6 +142,16 @@ u_int ktr_geniosize = PAGE_SIZE; SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RWTUN, &ktr_geniosize, 0, "Maximum size of genio event payload"); +/* + * Allow to not to send signal to traced process, in which context the + * ktr record is written. The limit is applied from the process that + * set up ktrace, so killing the traced process is not completely fair. + */ +int ktr_filesize_limit_signal = 0; +SYSCTL_INT(_kern_ktrace, OID_AUTO, filesize_limit_signal, CTLFLAG_RWTUN, + &ktr_filesize_limit_signal, 0, + "Send SIGXFSZ to the traced process when the log size limit is exceeded"); + static int print_message = 1; static struct mtx ktrace_mtx; static struct sx ktrace_sx; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 9c309c83f805..9e45d1820eec 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2360,6 +2361,7 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, struct thread *td) { off_t lim; + bool ktr_write; if (vp->v_type != VREG || td == NULL || (td->td_pflags2 & TDP2_ACCT) != 0) @@ -2369,9 +2371,11 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) return (0); - PROC_LOCK(td->td_proc); - kern_psignal(td->td_proc, SIGXFSZ); - PROC_UNLOCK(td->td_proc); + if (!ktr_write || ktr_filesize_limit_signal) { + PROC_LOCK(td->td_proc); + kern_psignal(td->td_proc, SIGXFSZ); + PROC_UNLOCK(td->td_proc); + } return (EFBIG); } diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index c4ab985722c0..50030d002f97 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -299,6 +299,7 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *, #define ktrstat_error(s, error) \ ktrstruct_error("stat", (s), sizeof(struct stat), error) extern u_int ktr_geniosize; +extern int ktr_filesize_limit_signal; #else #include From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B89A64C9BB; Sat, 22 May 2021 12:16: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 4FnMsg6Q8vz4Rvy; Sat, 22 May 2021 12:16: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 7075B2439D; Sat, 22 May 2021 12:16: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 14MCGt4Y011739; Sat, 22 May 2021 12:16:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGtbO011738; Sat, 22 May 2021 12:16:55 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:55 GMT Message-Id: <202105221216.14MCGtbO011738@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a6144f713cee - main - ktrace: do not stop tracing other processes if our cannot write to this 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/main X-Git-Reftype: branch X-Git-Commit: a6144f713cee8f522150b1398b225eedbf4cfef1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:56 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a6144f713cee8f522150b1398b225eedbf4cfef1 commit a6144f713cee8f522150b1398b225eedbf4cfef1 Author: Konstantin Belousov AuthorDate: 2021-05-15 00:10:05 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:08 +0000 ktrace: do not stop tracing other processes if our cannot write to this vnode Other processes might still be able to write, make the decision to stop based on the per-process situation. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_ktrace.c | 53 ++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 8728801acdf7..9916022961e9 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1190,7 +1190,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) struct uio auio; struct iovec aiov[3]; struct mount *mp; - int datalen, buflen, vrele_count; + int datalen, buflen; int error; /* @@ -1264,44 +1264,29 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) } /* - * If error encountered, give up tracing on this vnode. We defer - * all the vrele()'s on the vnode until after we are finished walking - * the various lists to avoid needlessly holding locks. - * NB: at this point we still hold the vnode reference that must - * not go away as we need the valid vnode to compare with. Thus let - * vrele_count start at 1 and the reference will be freed - * by the loop at the end after our last use of vp. - */ - log(LOG_NOTICE, "ktrace write failed, errno %d, tracing stopped\n", - error); - vrele_count = 1; - /* - * First, clear this vnode from being used by any processes in the - * system. - * XXX - If one process gets an EPERM writing to the vnode, should - * we really do this? Other processes might have suitable - * credentials for the operation. + * If error encountered, give up tracing on this vnode on this + * process. Other processes might still be suitable for + * writes to this vnode. */ + p = td->td_proc; + log(LOG_NOTICE, + "ktrace write failed, errno %d, tracing stopped for pid %d\n", + error, p->p_pid); cred = NULL; sx_slock(&allproc_lock); - FOREACH_PROC_IN_SYSTEM(p) { - PROC_LOCK(p); - if (p->p_tracevp == vp) { - mtx_lock(&ktrace_mtx); - ktr_freeproc(p, &cred, NULL); - mtx_unlock(&ktrace_mtx); - vrele_count++; - } - PROC_UNLOCK(p); - if (cred != NULL) { - crfree(cred); - cred = NULL; - } + PROC_LOCK(p); + mtx_lock(&ktrace_mtx); + if (p->p_tracevp == vp) + ktr_freeproc(p, &cred, NULL); + mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p); + if (cred != NULL) { + crfree(cred); + cred = NULL; } sx_sunlock(&allproc_lock); - - while (vrele_count-- > 0) - vrele(vp); + vrele(vp); + vrele(vp); } /* From owner-dev-commits-src-main@freebsd.org Sat May 22 12:17:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3B2164CB8E; Sat, 22 May 2021 12:17: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 4FnMsm0gSMz4SC4; Sat, 22 May 2021 12:17: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 EF90C244DF; Sat, 22 May 2021 12:16: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 14MCGxJ8011830; Sat, 22 May 2021 12:16:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGxZp011829; Sat, 22 May 2021 12:16:59 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:59 GMT Message-Id: <202105221216.14MCGxZp011829@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f784da883fd5 - main - Move mnt_maxsymlinklen into appropriate fs mount data structures MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f784da883fd5a744fcaf4ccfc550ca497ea5d7a6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:17:00 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f784da883fd5a744fcaf4ccfc550ca497ea5d7a6 commit f784da883fd5a744fcaf4ccfc550ca497ea5d7a6 Author: Konstantin Belousov AuthorDate: 2021-05-18 01:42:03 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:09 +0000 Move mnt_maxsymlinklen into appropriate fs mount data structures Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week X-MFC-Note: struct mount layout Differential revision: https://reviews.freebsd.org/D30325 --- sys/fs/cd9660/cd9660_vfsops.c | 1 - sys/fs/ext2fs/ext2_inode.c | 2 +- sys/fs/ext2fs/ext2_vfsops.c | 2 +- sys/fs/ext2fs/ext2_vnops.c | 7 ++++--- sys/fs/ext2fs/ext2fs.h | 1 + sys/kern/vfs_subr.c | 2 -- sys/sys/mount.h | 1 - sys/ufs/ffs/ffs_inode.c | 2 +- sys/ufs/ffs/ffs_vfsops.c | 4 ++-- sys/ufs/ffs/ffs_vnops.c | 2 +- sys/ufs/ufs/ufs_dirhash.c | 1 - sys/ufs/ufs/ufs_lookup.c | 8 ++------ sys/ufs/ufs/ufs_vnops.c | 14 +++++++------- sys/ufs/ufs/ufsmount.h | 5 +++++ 14 files changed, 25 insertions(+), 27 deletions(-) diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 21d3c3e13a8f..5d475bec93b8 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -378,7 +378,6 @@ iso_mountfs(devvp, mp) mp->mnt_data = isomp; mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; - mp->mnt_maxsymlinklen = 0; MNT_ILOCK(mp); if (isverified) mp->mnt_flag |= MNT_VERIFIED; diff --git a/sys/fs/ext2fs/ext2_inode.c b/sys/fs/ext2fs/ext2_inode.c index 1412017b4b3c..b27c0b0ec4ec 100644 --- a/sys/fs/ext2fs/ext2_inode.c +++ b/sys/fs/ext2fs/ext2_inode.c @@ -562,7 +562,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred, ip = VTOI(vp); if (vp->v_type == VLNK && - ip->i_size < vp->v_mount->mnt_maxsymlinklen) { + ip->i_size < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) { #ifdef INVARIANTS if (length != 0) panic("ext2_truncate: partial truncate of symlink"); diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 43cfdf3a1a0b..d15fed3d2913 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -924,6 +924,7 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) */ e2fs_maxcontig = MAX(1, maxphys / ump->um_e2fs->e2fs_bsize); ump->um_e2fs->e2fs_contigsumsize = MIN(e2fs_maxcontig, EXT2_MAXCONTIG); + ump->um_e2fs->e2fs_maxsymlinklen = EXT2_MAXSYMLINKLEN; if (ump->um_e2fs->e2fs_contigsumsize > 0) { size = ump->um_e2fs->e2fs_gcount * sizeof(int32_t); ump->um_e2fs->e2fs_maxcluster = malloc(size, M_EXT2MNT, M_WAITOK); @@ -957,7 +958,6 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) mp->mnt_data = ump; mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; - mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; MNT_IUNLOCK(mp); diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 2721aa535b40..367d48ab68f1 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -1533,7 +1533,7 @@ ext2_symlink(struct vop_symlink_args *ap) return (error); vp = *vpp; len = strlen(ap->a_target); - if (len < vp->v_mount->mnt_maxsymlinklen) { + if (len < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) { ip = VTOI(vp); bcopy(ap->a_target, (char *)ip->i_shortlink, len); ip->i_size = len; @@ -1558,7 +1558,7 @@ ext2_readlink(struct vop_readlink_args *ap) int isize; isize = ip->i_size; - if (isize < vp->v_mount->mnt_maxsymlinklen) { + if (isize < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) { uiomove((char *)ip->i_shortlink, isize, ap->a_uio); return (0); } @@ -2075,7 +2075,8 @@ ext2_read(struct vop_read_args *ap) panic("%s: mode", "ext2_read"); if (vp->v_type == VLNK) { - if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen) + if ((int)ip->i_size < + VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) panic("%s: short symlink", "ext2_read"); } else if (vp->v_type != VREG && vp->v_type != VDIR) panic("%s: type %d", "ext2_read", vp->v_type); diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h index b11ccc0b5b5a..1761f31454fd 100644 --- a/sys/fs/ext2fs/ext2fs.h +++ b/sys/fs/ext2fs/ext2fs.h @@ -184,6 +184,7 @@ struct m_ext2fs { struct csum *e2fs_clustersum; /* cluster summary in each cyl group */ int32_t e2fs_uhash; /* 3 if hash should be signed, 0 if not */ uint32_t e2fs_csum_seed; /* sb checksum seed */ + uint64_t e2fs_maxsymlinklen; /* max size of short symlink */ }; /* cluster summary information */ diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 620d3e974397..979cccf0e0dc 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4464,8 +4464,6 @@ DB_SHOW_COMMAND(mount, db_show_mount) mp->mnt_lazyvnodelistsize); db_printf(" mnt_writeopcount = %d (with %d in the struct)\n", vfs_mount_fetch_counter(mp, MNT_COUNT_WRITEOPCOUNT), mp->mnt_writeopcount); - db_printf(" mnt_maxsymlinklen = %jd\n", - (uintmax_t)mp->mnt_maxsymlinklen); db_printf(" mnt_iosize_max = %d\n", mp->mnt_iosize_max); db_printf(" mnt_hashseed = %u\n", mp->mnt_hashseed); db_printf(" mnt_lockref = %d (with %d in the struct)\n", diff --git a/sys/sys/mount.h b/sys/sys/mount.h index f341370ecd86..a1d4bfd15ddb 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -224,7 +224,6 @@ struct mount { int mnt_writeopcount; /* (i) write syscalls pending */ struct vfsoptlist *mnt_opt; /* current mount options */ struct vfsoptlist *mnt_optnew; /* new options passed to fs */ - uint64_t mnt_maxsymlinklen; /* max size of short symlink */ struct statfs mnt_stat; /* cache of filesystem stats */ struct ucred *mnt_cred; /* credentials of mounter */ void * mnt_data; /* private data */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 8fe7f7ab97de..b3d41aa023f9 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -329,7 +329,7 @@ ffs_truncate(vp, length, flags, cred) } if ((flags & IO_NORMAL) == 0) return (0); - if (vp->v_type == VLNK && ip->i_size < vp->v_mount->mnt_maxsymlinklen) { + if (vp->v_type == VLNK && ip->i_size < ump->um_maxsymlinklen) { #ifdef INVARIANTS if (length != 0) panic("ffs_truncate: partial truncate of symlink"); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 321ed03f7f67..6b7407eb88f9 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -932,7 +932,7 @@ ffs_reload(struct mount *mp, struct thread *td, int flags) sblockloc = fs->fs_sblockloc; bcopy(newfs, fs, (u_int)fs->fs_sbsize); brelse(bp); - mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; + ump->um_maxsymlinklen = fs->fs_maxsymlinklen; ffs_oldfscompat_read(fs, VFSTOUFS(mp), sblockloc); UFS_LOCK(ump); if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) { @@ -1192,7 +1192,7 @@ ffs_mountfs(odevvp, mp, td) vfs_rel(nmp); vfs_getnewfsid(mp); } - mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen; + ump->um_maxsymlinklen = fs->fs_maxsymlinklen; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; MNT_IUNLOCK(mp); diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 05eb19c0ee13..a10afd86f8e6 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -675,7 +675,7 @@ ffs_read(ap) panic("ffs_read: mode"); if (vp->v_type == VLNK) { - if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen) + if ((int)ip->i_size < VFSTOUFS(vp->v_mount)->um_maxsymlinklen) panic("ffs_read: short symlink"); } else if (vp->v_type != VREG && vp->v_type != VDIR) panic("ffs_read: type %d", vp->v_type); diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c index d1e1bed0bde4..8981ffdfc269 100644 --- a/sys/ufs/ufs/ufs_dirhash.c +++ b/sys/ufs/ufs/ufs_dirhash.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #define WRAPINCR(val, limit) (((val) + 1 == (limit)) ? 0 : ((val) + 1)) #define WRAPDECR(val, limit) (((val) == 0) ? ((limit) - 1) : ((val) - 1)) -#define OFSFMT(vp) ((vp)->v_mount->mnt_maxsymlinklen <= 0) #define BLKFREE2IDX(n) ((n) > DH_NFSTATS ? DH_NFSTATS : (n)) static MALLOC_DEFINE(M_DIRHASH, "ufs_dirhash", "UFS directory hash tables"); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 0509185c4663..b7bf4eb6c86c 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -76,9 +76,6 @@ static int dirchk = 0; SYSCTL_INT(_debug, OID_AUTO, dircheck, CTLFLAG_RW, &dirchk, 0, ""); -/* true if old FS format...*/ -#define OFSFMT(vp) ((vp)->v_mount->mnt_maxsymlinklen <= 0) - static int ufs_delete_denied(struct vnode *vdp, struct vnode *tdp, struct ucred *cred, struct thread *td) @@ -440,8 +437,7 @@ foundentry: * reclen in ndp->ni_ufs area, and release * directory buffer. */ - if (vdp->v_mount->mnt_maxsymlinklen > 0 && - ep->d_type == DT_WHT) { + if (!OFSFMT(vdp) && ep->d_type == DT_WHT) { slotstatus = FOUND; slotoffset = i_offset; slotsize = ep->d_reclen; @@ -854,7 +850,7 @@ ufs_makedirentry(ip, cnp, newdirp) bcopy(cnp->cn_nameptr, newdirp->d_name, namelen); - if (ITOV(ip)->v_mount->mnt_maxsymlinklen > 0) + if (!OFSFMT(ITOV(ip))) newdirp->d_type = IFTODT(ip->i_mode); else { newdirp->d_type = 0; diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 70bf1a1d9036..ef288a32e815 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1155,7 +1155,7 @@ ufs_whiteout(ap) switch (ap->a_flags) { case LOOKUP: /* 4.4 format directories support whiteout operations */ - if (dvp->v_mount->mnt_maxsymlinklen > 0) + if (!OFSFMT(dvp)) return (0); return (EOPNOTSUPP); @@ -1164,7 +1164,7 @@ ufs_whiteout(ap) #ifdef INVARIANTS if ((cnp->cn_flags & SAVENAME) == 0) panic("ufs_whiteout: missing name"); - if (dvp->v_mount->mnt_maxsymlinklen <= 0) + if (OFSFMT(dvp)) panic("ufs_whiteout: old format filesystem"); #endif @@ -1178,7 +1178,7 @@ ufs_whiteout(ap) case DELETE: /* remove an existing directory whiteout */ #ifdef INVARIANTS - if (dvp->v_mount->mnt_maxsymlinklen <= 0) + if (OFSFMT(dvp)) panic("ufs_whiteout: old format filesystem"); #endif @@ -2083,7 +2083,7 @@ ufs_mkdir(ap) /* * Initialize directory with "." and ".." from static template. */ - if (dvp->v_mount->mnt_maxsymlinklen > 0) + if (!OFSFMT(dvp)) dtp = &mastertemplate; else dtp = (struct dirtemplate *)&omastertemplate; @@ -2287,7 +2287,7 @@ ufs_symlink(ap) return (error); vp = *vpp; len = strlen(ap->a_target); - if (len < vp->v_mount->mnt_maxsymlinklen) { + if (len < VFSTOUFS(vp->v_mount)->um_maxsymlinklen) { ip = VTOI(vp); bcopy(ap->a_target, SHORTLINK(ip), len); ip->i_size = len; @@ -2377,7 +2377,7 @@ ufs_readdir(ap) } #if BYTE_ORDER == LITTLE_ENDIAN /* Old filesystem format. */ - if (vp->v_mount->mnt_maxsymlinklen <= 0) { + if (OFSFMT(vp)) { dstdp.d_namlen = dp->d_type; dstdp.d_type = dp->d_namlen; } else @@ -2458,7 +2458,7 @@ ufs_readlink(ap) doff_t isize; isize = ip->i_size; - if (isize < vp->v_mount->mnt_maxsymlinklen) + if (isize < VFSTOUFS(vp->v_mount)->um_maxsymlinklen) return (uiomove(SHORTLINK(ip), isize, ap->a_uio)); return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred)); } diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 0dfcecb178af..6071faec795c 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -100,6 +100,8 @@ struct ufsmount { u_long um_nindir; /* (c) indirect ptrs per blk */ u_long um_bptrtodb; /* (c) indir disk block ptr */ u_long um_seqinc; /* (c) inc between seq blocks */ + uint64_t um_maxsymlinklen; /* (c) max size of short + symlink */ struct mtx um_lock; /* (c) Protects ufsmount & fs */ pid_t um_fsckpid; /* (u) PID can do fsck sysctl */ struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */ @@ -194,4 +196,7 @@ struct ufsmount { #define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) #define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) +/* true if old FS format...*/ +#define OFSFMT(vp) (VFSTOUFS((vp)->v_mount)->um_maxsymlinklen <= 0) + #endif From owner-dev-commits-src-main@freebsd.org Sat May 22 12:16:56 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E9A3164C7DD; Sat, 22 May 2021 12:16: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 4FnMsh54dFz4S7x; Sat, 22 May 2021 12:16: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 8EC83240CD; Sat, 22 May 2021 12:16: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 14MCGu9B011767; Sat, 22 May 2021 12:16:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCGuCZ011765; Sat, 22 May 2021 12:16:56 GMT (envelope-from git) Date: Sat, 22 May 2021 12:16:56 GMT Message-Id: <202105221216.14MCGuCZ011765@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1762f674ccb5 - main - ktrace: pack all ktrace parameters into allocated structure ktr_io_params MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1762f674ccb571e6b03c009906dd1af3c6343f9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:16:57 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1762f674ccb571e6b03c009906dd1af3c6343f9b commit 1762f674ccb571e6b03c009906dd1af3c6343f9b Author: Konstantin Belousov AuthorDate: 2021-05-14 23:22:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 12:16:08 +0000 ktrace: pack all ktrace parameters into allocated structure ktr_io_params Ref-count the ktr_io_params structure instead of vnode/cred. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30257 --- sys/kern/kern_descrip.c | 6 +- sys/kern/kern_exec.c | 16 ++-- sys/kern/kern_ktrace.c | 234 ++++++++++++++++++++++++++++++------------------ sys/kern/kern_proc.c | 5 +- sys/kern/kern_thread.c | 12 +-- sys/sys/ktrace.h | 6 +- sys/sys/proc.h | 3 +- 7 files changed, 170 insertions(+), 112 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 168bddda9c45..09eb0770bcda 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -79,9 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef KTRACE #include -#endif #include @@ -4363,9 +4361,7 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, PROC_LOCK_ASSERT(p, MA_OWNED); /* ktrace vnode */ - tracevp = p->p_tracevp; - if (tracevp != NULL) - vrefact(tracevp); + tracevp = ktr_get_tracevp(p, true); /* text vnode */ textvp = p->p_textvp; if (textvp != NULL) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 04dedfa59c9b..d9b9e1ae122b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -374,8 +374,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, struct pargs *oldargs = NULL, *newargs = NULL; struct sigacts *oldsigacts = NULL, *newsigacts = NULL; #ifdef KTRACE - struct vnode *tracevp = NULL; - struct ucred *tracecred = NULL; + struct ktr_io_params *kiop; #endif struct vnode *oldtextvp = NULL, *newtextvp; int credential_changing; @@ -391,6 +390,7 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, static const char fexecv_proc_title[] = "(fexecv)"; imgp = &image_params; + kiop = NULL; /* * Lock the process and set the P_INEXEC flag to indicate that @@ -780,11 +780,10 @@ interpret: * we do not regain any tracing during a possible block. */ setsugid(p); + kiop = NULL; #ifdef KTRACE - if (p->p_tracecred != NULL && - priv_check_cred(p->p_tracecred, PRIV_DEBUG_DIFFCRED)) - ktrprocexec(p, &tracecred, &tracevp); + kiop = ktrprocexec(p); #endif /* * Close any file descriptors 0..2 that reference procfs, @@ -939,12 +938,7 @@ exec_fail: */ if (oldtextvp != NULL) vrele(oldtextvp); -#ifdef KTRACE - if (tracevp != NULL) - vrele(tracevp); - if (tracecred != NULL) - crfree(tracecred); -#endif + ktr_io_params_free(kiop); pargs_drop(oldargs); pargs_drop(newargs); if (oldsigacts != NULL) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 9916022961e9..c03eea4991a1 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -145,20 +145,27 @@ static int print_message = 1; static struct mtx ktrace_mtx; static struct sx ktrace_sx; +struct ktr_io_params { + struct vnode *vp; + struct ucred *cr; + u_int refs; +}; + static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); -static void ktr_freeproc(struct proc *p, struct ucred **uc, - struct vnode **vp); +static struct ktr_io_params *ktr_freeproc(struct proc *p); static void ktr_freerequest(struct ktr_request *req); static void ktr_freerequest_locked(struct ktr_request *req); static void ktr_writerequest(struct thread *td, struct ktr_request *req); static int ktrcanset(struct thread *,struct proc *); -static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); -static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); +static int ktrsetchildren(struct thread *, struct proc *, int, int, + struct ktr_io_params *); +static int ktrops(struct thread *, struct proc *, int, int, + struct ktr_io_params *); static void ktrprocctor_entered(struct thread *, struct proc *); /* @@ -421,28 +428,85 @@ ktr_freerequest_locked(struct ktr_request *req) STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); } +static void +ktr_io_params_ref(struct ktr_io_params *kiop) +{ + mtx_assert(&ktrace_mtx, MA_OWNED); + kiop->refs++; +} + +static struct ktr_io_params * +ktr_io_params_rele(struct ktr_io_params *kiop) +{ + mtx_assert(&ktrace_mtx, MA_OWNED); + if (kiop == NULL) + return (NULL); + KASSERT(kiop->refs > 0, ("kiop ref == 0 %p", kiop)); + return (--(kiop->refs) == 0 ? kiop : NULL); +} + +void +ktr_io_params_free(struct ktr_io_params *kiop) +{ + if (kiop == NULL) + return; + + MPASS(kiop->refs == 0); + vn_close(kiop->vp, FWRITE, kiop->cr, curthread); + crfree(kiop->cr); + free(kiop, M_KTRACE); +} + +static struct ktr_io_params * +ktr_io_params_alloc(struct thread *td, struct vnode *vp) +{ + struct ktr_io_params *res; + + res = malloc(sizeof(struct ktr_io_params), M_KTRACE, M_WAITOK); + res->vp = vp; + res->cr = crhold(td->td_ucred); + res->refs = 1; + return (res); +} + /* * Disable tracing for a process and release all associated resources. * The caller is responsible for releasing a reference on the returned * vnode and credentials. */ -static void -ktr_freeproc(struct proc *p, struct ucred **uc, struct vnode **vp) +static struct ktr_io_params * +ktr_freeproc(struct proc *p) { + struct ktr_io_params *kiop; struct ktr_request *req; PROC_LOCK_ASSERT(p, MA_OWNED); mtx_assert(&ktrace_mtx, MA_OWNED); - *uc = p->p_tracecred; - p->p_tracecred = NULL; - if (vp != NULL) - *vp = p->p_tracevp; - p->p_tracevp = NULL; + kiop = ktr_io_params_rele(p->p_ktrioparms); + p->p_ktrioparms = NULL; p->p_traceflag = 0; while ((req = STAILQ_FIRST(&p->p_ktr)) != NULL) { STAILQ_REMOVE_HEAD(&p->p_ktr, ktr_list); ktr_freerequest_locked(req); } + return (kiop); +} + +struct vnode * +ktr_get_tracevp(struct proc *p, bool ref) +{ + struct vnode *vp; + + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (p->p_ktrioparms != NULL) { + vp = p->p_ktrioparms->vp; + if (ref) + vrefact(vp); + } else { + vp = NULL; + } + return (vp); } void @@ -501,14 +565,21 @@ ktrsysret(int code, int error, register_t retval) * * XXX: We toss any pending asynchronous records. */ -void -ktrprocexec(struct proc *p, struct ucred **uc, struct vnode **vp) +struct ktr_io_params * +ktrprocexec(struct proc *p) { + struct ktr_io_params *kiop; PROC_LOCK_ASSERT(p, MA_OWNED); + + kiop = p->p_ktrioparms; + if (kiop == NULL || priv_check_cred(kiop->cr, PRIV_DEBUG_DIFFCRED)) + return (NULL); + mtx_lock(&ktrace_mtx); - ktr_freeproc(p, uc, vp); + kiop = ktr_freeproc(p); mtx_unlock(&ktrace_mtx); + return (kiop); } /* @@ -520,8 +591,7 @@ ktrprocexit(struct thread *td) { struct ktr_request *req; struct proc *p; - struct ucred *cred; - struct vnode *vp; + struct ktr_io_params *kiop; p = td->td_proc; if (p->p_traceflag == 0) @@ -536,13 +606,10 @@ ktrprocexit(struct thread *td) sx_xunlock(&ktrace_sx); PROC_LOCK(p); mtx_lock(&ktrace_mtx); - ktr_freeproc(p, &cred, &vp); + kiop = ktr_freeproc(p); mtx_unlock(&ktrace_mtx); PROC_UNLOCK(p); - if (vp != NULL) - vrele(vp); - if (cred != NULL) - crfree(cred); + ktr_io_params_free(kiop); ktrace_exit(td); } @@ -583,7 +650,7 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - MPASS(p2->p_tracevp == NULL); + MPASS(p2->p_ktrioparms == NULL); MPASS(p2->p_traceflag == 0); if (p1->p_traceflag == 0) @@ -593,12 +660,8 @@ ktrprocfork(struct proc *p1, struct proc *p2) mtx_lock(&ktrace_mtx); if (p1->p_traceflag & KTRFAC_INHERIT) { p2->p_traceflag = p1->p_traceflag; - if ((p2->p_tracevp = p1->p_tracevp) != NULL) { - VREF(p2->p_tracevp); - KASSERT(p1->p_tracecred != NULL, - ("ktrace vnode with no cred")); - p2->p_tracecred = crhold(p1->p_tracecred); - } + if ((p2->p_ktrioparms = p1->p_ktrioparms) != NULL) + p1->p_ktrioparms->refs++; } mtx_unlock(&ktrace_mtx); PROC_UNLOCK(p1); @@ -932,7 +995,7 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) int nfound, ret = 0; int flags, error = 0; struct nameidata nd; - struct ucred *cred; + struct ktr_io_params *kiop, *old_kiop; /* * Need something to (un)trace. @@ -940,6 +1003,7 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) if (ops != KTROP_CLEARFILE && facs == 0) return (EINVAL); + kiop = NULL; ktrace_enter(td); if (ops != KTROP_CLEAR) { /* @@ -960,34 +1024,34 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) ktrace_exit(td); return (EACCES); } + kiop = ktr_io_params_alloc(td, vp); } /* * Clear all uses of the tracefile. */ if (ops == KTROP_CLEARFILE) { - int vrele_count; - - vrele_count = 0; +restart: sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { + old_kiop = NULL; PROC_LOCK(p); - if (p->p_tracevp == vp) { + if (p->p_ktrioparms != NULL && + p->p_ktrioparms->vp == vp) { if (ktrcanset(td, p)) { mtx_lock(&ktrace_mtx); - ktr_freeproc(p, &cred, NULL); + old_kiop = ktr_freeproc(p); mtx_unlock(&ktrace_mtx); - vrele_count++; - crfree(cred); } else error = EPERM; } PROC_UNLOCK(p); + if (old_kiop != NULL) { + sx_sunlock(&allproc_lock); + ktr_io_params_free(old_kiop); + goto restart; + } } sx_sunlock(&allproc_lock); - if (vrele_count > 0) { - while (vrele_count-- > 0) - vrele(vp); - } goto done; } /* @@ -1019,9 +1083,9 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) } nfound++; if (descend) - ret |= ktrsetchildren(td, p, ops, facs, vp); + ret |= ktrsetchildren(td, p, ops, facs, kiop); else - ret |= ktrops(td, p, ops, facs, vp); + ret |= ktrops(td, p, ops, facs, kiop); } if (nfound == 0) { sx_sunlock(&proctree_lock); @@ -1044,16 +1108,20 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) goto done; } if (descend) - ret |= ktrsetchildren(td, p, ops, facs, vp); + ret |= ktrsetchildren(td, p, ops, facs, kiop); else - ret |= ktrops(td, p, ops, facs, vp); + ret |= ktrops(td, p, ops, facs, kiop); } sx_sunlock(&proctree_lock); if (!ret) error = EPERM; done: - if (vp != NULL) - (void) vn_close(vp, FWRITE, td->td_ucred, td); + if (kiop != NULL) { + mtx_lock(&ktrace_mtx); + kiop = ktr_io_params_rele(kiop); + mtx_unlock(&ktrace_mtx); + ktr_io_params_free(kiop); + } ktrace_exit(td); return (error); #else /* !KTRACE */ @@ -1097,10 +1165,10 @@ sys_utrace(struct thread *td, struct utrace_args *uap) #ifdef KTRACE static int -ktrops(struct thread *td, struct proc *p, int ops, int facs, struct vnode *vp) +ktrops(struct thread *td, struct proc *p, int ops, int facs, + struct ktr_io_params *new_kiop) { - struct vnode *tracevp = NULL; - struct ucred *tracecred = NULL; + struct ktr_io_params *old_kiop; PROC_LOCK_ASSERT(p, MA_OWNED); if (!ktrcanset(td, p)) { @@ -1112,19 +1180,18 @@ ktrops(struct thread *td, struct proc *p, int ops, int facs, struct vnode *vp) PROC_UNLOCK(p); return (1); } + old_kiop = NULL; mtx_lock(&ktrace_mtx); if (ops == KTROP_SET) { - if (p->p_tracevp != vp) { - /* - * if trace file already in use, relinquish below - */ - tracevp = p->p_tracevp; - VREF(vp); - p->p_tracevp = vp; + if (p->p_ktrioparms != NULL && + p->p_ktrioparms->vp != new_kiop->vp) { + /* if trace file already in use, relinquish below */ + old_kiop = ktr_io_params_rele(p->p_ktrioparms); + p->p_ktrioparms = NULL; } - if (p->p_tracecred != td->td_ucred) { - tracecred = p->p_tracecred; - p->p_tracecred = crhold(td->td_ucred); + if (p->p_ktrioparms == NULL) { + p->p_ktrioparms = new_kiop; + ktr_io_params_ref(new_kiop); } p->p_traceflag |= facs; if (priv_check(td, PRIV_KTRACE) == 0) @@ -1133,23 +1200,20 @@ ktrops(struct thread *td, struct proc *p, int ops, int facs, struct vnode *vp) /* KTROP_CLEAR */ if (((p->p_traceflag &= ~facs) & KTRFAC_MASK) == 0) /* no more tracing */ - ktr_freeproc(p, &tracecred, &tracevp); + old_kiop = ktr_freeproc(p); } mtx_unlock(&ktrace_mtx); if ((p->p_traceflag & KTRFAC_MASK) != 0) ktrprocctor_entered(td, p); PROC_UNLOCK(p); - if (tracevp != NULL) - vrele(tracevp); - if (tracecred != NULL) - crfree(tracecred); + ktr_io_params_free(old_kiop); return (1); } static int ktrsetchildren(struct thread *td, struct proc *top, int ops, int facs, - struct vnode *vp) + struct ktr_io_params *new_kiop) { struct proc *p; int ret = 0; @@ -1158,7 +1222,7 @@ ktrsetchildren(struct thread *td, struct proc *top, int ops, int facs, PROC_LOCK_ASSERT(p, MA_OWNED); sx_assert(&proctree_lock, SX_LOCKED); for (;;) { - ret |= ktrops(td, p, ops, facs, vp); + ret |= ktrops(td, p, ops, facs, new_kiop); /* * If this process has children, descend to them next, * otherwise do any siblings, and if done with this level, @@ -1183,6 +1247,7 @@ ktrsetchildren(struct thread *td, struct proc *top, int ops, int facs, static void ktr_writerequest(struct thread *td, struct ktr_request *req) { + struct ktr_io_params *kiop; struct ktr_header *kth; struct vnode *vp; struct proc *p; @@ -1193,6 +1258,8 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) int datalen, buflen; int error; + p = td->td_proc; + /* * We hold the vnode and credential for use in I/O in case ktrace is * disabled on the process as we write out the request. @@ -1201,20 +1268,22 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) * the vnode has been closed. */ mtx_lock(&ktrace_mtx); - vp = td->td_proc->p_tracevp; - cred = td->td_proc->p_tracecred; + + kiop = p->p_ktrioparms; /* - * If vp is NULL, the vp has been cleared out from under this - * request, so just drop it. Make sure the credential and vnode are - * in sync: we should have both or neither. + * If kiop is NULL, it has been cleared out from under this + * request, so just drop it. */ - if (vp == NULL) { - KASSERT(cred == NULL, ("ktr_writerequest: cred != NULL")); + if (kiop == NULL) { mtx_unlock(&ktrace_mtx); return; } - VREF(vp); + + vp = kiop->vp; + cred = kiop->cr; + + vrefact(vp); KASSERT(cred != NULL, ("ktr_writerequest: cred == NULL")); crhold(cred); mtx_unlock(&ktrace_mtx); @@ -1258,7 +1327,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) VOP_UNLOCK(vp); vn_finished_write(mp); crfree(cred); - if (!error) { + if (error == 0) { vrele(vp); return; } @@ -1268,24 +1337,17 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) * process. Other processes might still be suitable for * writes to this vnode. */ - p = td->td_proc; log(LOG_NOTICE, "ktrace write failed, errno %d, tracing stopped for pid %d\n", error, p->p_pid); - cred = NULL; - sx_slock(&allproc_lock); + PROC_LOCK(p); mtx_lock(&ktrace_mtx); - if (p->p_tracevp == vp) - ktr_freeproc(p, &cred, NULL); + if (p->p_ktrioparms != NULL && p->p_ktrioparms->vp == vp) + kiop = ktr_freeproc(p); mtx_unlock(&ktrace_mtx); PROC_UNLOCK(p); - if (cred != NULL) { - crfree(cred); - cred = NULL; - } - sx_sunlock(&allproc_lock); - vrele(vp); + ktr_io_params_free(kiop); vrele(vp); } diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 33f168836370..ec732e8db060 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -75,6 +75,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef KTRACE +#include +#endif #ifdef DDB #include @@ -1058,7 +1061,7 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_args = p->p_args; kp->ki_textvp = p->p_textvp; #ifdef KTRACE - kp->ki_tracep = p->p_tracevp; + kp->ki_tracep = ktr_get_tracevp(p, false); kp->ki_traceflag = p->p_traceflag; #endif kp->ki_fd = p->p_fd; diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index d5549baa6ad5..a52d6e75fd03 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -96,11 +96,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0xb8, "struct proc KBI p_flag"); _Static_assert(offsetof(struct proc, p_pid) == 0xc4, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x3c0, +_Static_assert(offsetof(struct proc, p_filemon) == 0x3b8, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x3d8, +_Static_assert(offsetof(struct proc, p_comm) == 0x3d0, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b0, "struct proc KBI p_emuldata"); #endif #ifdef __i386__ @@ -116,11 +116,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0x6c, "struct proc KBI p_flag"); _Static_assert(offsetof(struct proc, p_pid) == 0x78, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x26c, +_Static_assert(offsetof(struct proc, p_filemon) == 0x268, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x280, +_Static_assert(offsetof(struct proc, p_comm) == 0x27c, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x30c, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x308, "struct proc KBI p_emuldata"); #endif diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index a0b02f7d3ac5..c4ab985722c0 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -265,6 +265,10 @@ struct ktr_struct_array { #define KTRFAC_DROP 0x20000000 /* last event was dropped */ #ifdef _KERNEL +struct ktr_io_params; + +struct vnode *ktr_get_tracevp(struct proc *, bool); +void ktr_io_params_free(struct ktr_io_params *); void ktrnamei(char *); void ktrcsw(int, int, const char *); void ktrpsig(int, sig_t, sigset_t *, int); @@ -275,7 +279,7 @@ void ktrsyscall(int, int narg, register_t args[]); void ktrsysctl(int *name, u_int namelen); void ktrsysret(int, int, register_t); void ktrprocctor(struct proc *); -void ktrprocexec(struct proc *, struct ucred **, struct vnode **); +struct ktr_io_params *ktrprocexec(struct proc *); void ktrprocexit(struct thread *); void ktrprocfork(struct proc *, struct proc *); void ktruserret(struct thread *); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index d957412424aa..c54d4399f948 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -662,8 +662,7 @@ struct proc { int p_profthreads; /* (c) Num threads in addupc_task. */ volatile int p_exitthreads; /* (j) Number of threads exiting */ int p_traceflag; /* (o) Kernel trace points. */ - struct vnode *p_tracevp; /* (c + o) Trace to vnode. */ - struct ucred *p_tracecred; /* (o) Credentials to trace with. */ + struct ktr_io_params *p_ktrioparms; /* (c + o) Params for ktrace. */ struct vnode *p_textvp; /* (b) Vnode of executable. */ u_int p_lock; /* (c) Proclock (prevent swap) count. */ struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ From owner-dev-commits-src-main@freebsd.org Sat May 22 12:39:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC01964D385; Sat, 22 May 2021 12:39: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 4FnNN24xmpz4bnG; Sat, 22 May 2021 12:39: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 91F7124354; Sat, 22 May 2021 12:39: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 14MCdkjh038654; Sat, 22 May 2021 12:39:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MCdkfP038653; Sat, 22 May 2021 12:39:46 GMT (envelope-from git) Date: Sat, 22 May 2021 12:39:46 GMT Message-Id: <202105221239.14MCdkfP038653@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 8923ce630492 - main - tcp: Handle stack switch while processing socket options MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8923ce630492d21ec57c2637757bcc44da9970f8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 12:39:46 -0000 The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8923ce630492d21ec57c2637757bcc44da9970f8 commit 8923ce630492d21ec57c2637757bcc44da9970f8 Author: Michael Tuexen AuthorDate: 2021-05-22 12:35:09 +0000 Commit: Michael Tuexen CommitDate: 2021-05-22 12:39:36 +0000 tcp: Handle stack switch while processing socket options Handle the case where during socket option processing, the user switches a stack such that processing the stack specific socket option does not make sense anymore. Return an error in this case. MFC after: 1 week Reviewed by: markj Reported by: syzbot+a6e1d91f240ad5d72cd1@syzkaller.appspotmail.com Sponsored by: Netflix, Inc. Differential revision: https://reviews.freebsd.org/D30395 --- sys/netinet/tcp_stacks/bbr.c | 62 ++++++++++++++++++++++++------------------- sys/netinet/tcp_stacks/rack.c | 60 ++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index dd4cbfd7dc53..56691def6e1d 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -518,6 +518,10 @@ static void bbr_log_pacing_delay_calc(struct tcp_bbr *bbr, uint16_t gain, uint32_t len, uint32_t cts, uint32_t usecs, uint64_t bw, uint32_t override, int mod); +static int +bbr_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp, + struct tcpcb *tp); + static inline uint8_t bbr_state_val(struct tcp_bbr *bbr) { @@ -14197,6 +14201,33 @@ bbr_mtu_chg(struct tcpcb *tp) } } +static int +bbr_pru_options(struct tcpcb *tp, int flags) +{ + if (flags & PRUS_OOB) + return (EOPNOTSUPP); + return (0); +} + +struct tcp_function_block __tcp_bbr = { + .tfb_tcp_block_name = __XSTRING(STACKNAME), + .tfb_tcp_output = bbr_output, + .tfb_do_queued_segments = ctf_do_queued_segments, + .tfb_do_segment_nounlock = bbr_do_segment_nounlock, + .tfb_tcp_do_segment = bbr_do_segment, + .tfb_tcp_ctloutput = bbr_ctloutput, + .tfb_tcp_fb_init = bbr_init, + .tfb_tcp_fb_fini = bbr_fini, + .tfb_tcp_timer_stop_all = bbr_stopall, + .tfb_tcp_timer_activate = bbr_timer_activate, + .tfb_tcp_timer_active = bbr_timer_active, + .tfb_tcp_timer_stop = bbr_timer_stop, + .tfb_tcp_rexmit_tmr = bbr_remxt_tmr, + .tfb_tcp_handoff_ok = bbr_handoff_ok, + .tfb_tcp_mtu_chg = bbr_mtu_chg, + .tfb_pru_options = bbr_pru_options, +}; + /* * bbr_ctloutput() must drop the inpcb lock before performing copyin on * socket option arguments. When it re-acquires the lock after the copy, it @@ -14269,6 +14300,10 @@ bbr_set_sockopt(struct socket *so, struct sockopt *sopt, return (ECONNRESET); } tp = intotcpcb(inp); + if (tp->t_fb != &__tcp_bbr) { + INP_WUNLOCK(inp); + return (ENOPROTOOPT); + } bbr = (struct tcp_bbr *)tp->t_fb_ptr; switch (sopt->sopt_name) { case TCP_BBR_PACE_PER_SEC: @@ -14772,33 +14807,6 @@ out: return (error); } -static int -bbr_pru_options(struct tcpcb *tp, int flags) -{ - if (flags & PRUS_OOB) - return (EOPNOTSUPP); - return (0); -} - -struct tcp_function_block __tcp_bbr = { - .tfb_tcp_block_name = __XSTRING(STACKNAME), - .tfb_tcp_output = bbr_output, - .tfb_do_queued_segments = ctf_do_queued_segments, - .tfb_do_segment_nounlock = bbr_do_segment_nounlock, - .tfb_tcp_do_segment = bbr_do_segment, - .tfb_tcp_ctloutput = bbr_ctloutput, - .tfb_tcp_fb_init = bbr_init, - .tfb_tcp_fb_fini = bbr_fini, - .tfb_tcp_timer_stop_all = bbr_stopall, - .tfb_tcp_timer_activate = bbr_timer_activate, - .tfb_tcp_timer_active = bbr_timer_active, - .tfb_tcp_timer_stop = bbr_timer_stop, - .tfb_tcp_rexmit_tmr = bbr_remxt_tmr, - .tfb_tcp_handoff_ok = bbr_handoff_ok, - .tfb_tcp_mtu_chg = bbr_mtu_chg, - .tfb_pru_options = bbr_pru_options, -}; - static const char *bbr_stack_names[] = { __XSTRING(STACKNAME), #ifdef STACKALIAS diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 47f4c6835de9..2713554626e9 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -19407,6 +19407,34 @@ rack_apply_deferred_options(struct tcp_rack *rack) } } +static int +rack_pru_options(struct tcpcb *tp, int flags) +{ + if (flags & PRUS_OOB) + return (EOPNOTSUPP); + return (0); +} + +static struct tcp_function_block __tcp_rack = { + .tfb_tcp_block_name = __XSTRING(STACKNAME), + .tfb_tcp_output = rack_output, + .tfb_do_queued_segments = ctf_do_queued_segments, + .tfb_do_segment_nounlock = rack_do_segment_nounlock, + .tfb_tcp_do_segment = rack_do_segment, + .tfb_tcp_ctloutput = rack_ctloutput, + .tfb_tcp_fb_init = rack_init, + .tfb_tcp_fb_fini = rack_fini, + .tfb_tcp_timer_stop_all = rack_stopall, + .tfb_tcp_timer_activate = rack_timer_activate, + .tfb_tcp_timer_active = rack_timer_active, + .tfb_tcp_timer_stop = rack_timer_stop, + .tfb_tcp_rexmit_tmr = rack_remxt_tmr, + .tfb_tcp_handoff_ok = rack_handoff_ok, + .tfb_tcp_mtu_chg = rack_mtu_change, + .tfb_pru_options = rack_pru_options, + +}; + /* * rack_ctloutput() must drop the inpcb lock before performing copyin on * socket option arguments. When it re-acquires the lock after the copy, it @@ -19496,6 +19524,10 @@ rack_set_sockopt(struct socket *so, struct sockopt *sopt, INP_WUNLOCK(inp); return (ECONNRESET); } + if (tp->t_fb != &__tcp_rack) { + INP_WUNLOCK(inp); + return (ENOPROTOOPT); + } if (rack->defer_options && (rack->gp_ready == 0) && (sopt->sopt_name != TCP_DEFER_OPTIONS) && (sopt->sopt_name != TCP_RACK_PACING_BETA) && @@ -19832,34 +19864,6 @@ out: return (error); } -static int -rack_pru_options(struct tcpcb *tp, int flags) -{ - if (flags & PRUS_OOB) - return (EOPNOTSUPP); - return (0); -} - -static struct tcp_function_block __tcp_rack = { - .tfb_tcp_block_name = __XSTRING(STACKNAME), - .tfb_tcp_output = rack_output, - .tfb_do_queued_segments = ctf_do_queued_segments, - .tfb_do_segment_nounlock = rack_do_segment_nounlock, - .tfb_tcp_do_segment = rack_do_segment, - .tfb_tcp_ctloutput = rack_ctloutput, - .tfb_tcp_fb_init = rack_init, - .tfb_tcp_fb_fini = rack_fini, - .tfb_tcp_timer_stop_all = rack_stopall, - .tfb_tcp_timer_activate = rack_timer_activate, - .tfb_tcp_timer_active = rack_timer_active, - .tfb_tcp_timer_stop = rack_timer_stop, - .tfb_tcp_rexmit_tmr = rack_remxt_tmr, - .tfb_tcp_handoff_ok = rack_handoff_ok, - .tfb_tcp_mtu_chg = rack_mtu_change, - .tfb_pru_options = rack_pru_options, - -}; - static const char *rack_stack_names[] = { __XSTRING(STACKNAME), #ifdef STACKALIAS From owner-dev-commits-src-main@freebsd.org Sat May 22 13:37:14 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 27CA864E0E9; Sat, 22 May 2021 13:37: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 4FnPfL0SKNz3PZS; Sat, 22 May 2021 13:37: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 E5EAC255B8; Sat, 22 May 2021 13:37: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 14MDbDNl019162; Sat, 22 May 2021 13:37:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MDbD2e019161; Sat, 22 May 2021 13:37:13 GMT (envelope-from git) Date: Sat, 22 May 2021 13:37:13 GMT Message-Id: <202105221337.14MDbD2e019161@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e67ef6ce667d - main - libkvm: Fix build after removeal of p_tracevp MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e67ef6ce667d42a235a70914159048e10039145d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 13:37:14 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e67ef6ce667d42a235a70914159048e10039145d commit e67ef6ce667d42a235a70914159048e10039145d Author: Konstantin Belousov AuthorDate: 2021-05-22 12:43:57 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 13:36:54 +0000 libkvm: Fix build after removeal of p_tracevp Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libkvm/kvm_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index eed2f3de6075..5058e86a645b 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -218,7 +218,7 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p, /* kp->ki_kstack = proc.p_thread.td_kstack; XXXKSE */ kp->ki_args = proc.p_args; kp->ki_numthreads = proc.p_numthreads; - kp->ki_tracep = proc.p_tracevp; + kp->ki_tracep = NULL; /* XXXKIB do not expose ktr_io_params */ kp->ki_textvp = proc.p_textvp; kp->ki_fd = proc.p_fd; kp->ki_pd = proc.p_pd; From owner-dev-commits-src-main@freebsd.org Sat May 22 16:17:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B5AC63140A; Sat, 22 May 2021 16:17: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 4FnTCg2Xrnz4St2; Sat, 22 May 2021 16:17: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 3DFF9272DD; Sat, 22 May 2021 16:17: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 14MGHpL7031583; Sat, 22 May 2021 16:17:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MGHpbZ031582; Sat, 22 May 2021 16:17:51 GMT (envelope-from git) Date: Sat, 22 May 2021 16:17:51 GMT Message-Id: <202105221617.14MGHpbZ031582@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 5c7ef43e9625 - main - ktls.h: Guard includes behind _KERNEL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c7ef43e9625528da93b308a97aab0858f7eaec6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 16:17:51 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5c7ef43e9625528da93b308a97aab0858f7eaec6 commit 5c7ef43e9625528da93b308a97aab0858f7eaec6 Author: Mark Johnston AuthorDate: 2021-05-22 16:12:19 +0000 Commit: Mark Johnston CommitDate: 2021-05-22 16:12:19 +0000 ktls.h: Guard includes behind _KERNEL These are not needed when including ktls.h to get sockopt definitions. Reviewed by: gallatin, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30392 --- sys/sys/ktls.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/sys/ktls.h b/sys/sys/ktls.h index 3c43a23af04f..bf1e66fab027 100644 --- a/sys/sys/ktls.h +++ b/sys/sys/ktls.h @@ -29,8 +29,10 @@ #ifndef _SYS_KTLS_H_ #define _SYS_KTLS_H_ +#ifdef _KERNEL #include #include +#endif struct tls_record_layer { uint8_t tls_type; From owner-dev-commits-src-main@freebsd.org Sat May 22 16:17:50 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4844D631408; Sat, 22 May 2021 16:17: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 4FnTCf1bZLz4T1q; Sat, 22 May 2021 16:17: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 1DAD62751E; Sat, 22 May 2021 16:17: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 14MGHoIB031562; Sat, 22 May 2021 16:17:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MGHoYk031561; Sat, 22 May 2021 16:17:50 GMT (envelope-from git) Date: Sat, 22 May 2021 16:17:50 GMT Message-Id: <202105221617.14MGHoYk031561@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e4b16f2fb18b - main - ktrace: Avoid recursion in namei() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e4b16f2fb18bcb6ed2592a7b6983d5df04813a70 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 16:17:50 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e4b16f2fb18bcb6ed2592a7b6983d5df04813a70 commit e4b16f2fb18bcb6ed2592a7b6983d5df04813a70 Author: Mark Johnston AuthorDate: 2021-05-22 16:07:32 +0000 Commit: Mark Johnston CommitDate: 2021-05-22 16:07:32 +0000 ktrace: Avoid recursion in namei() sys_ktrace() calls namei(), which may call ktrnamei(). But sys_ktrace() also calls ktrace_enter() first, so if the caller is itself being traced, the assertion in ktrace_enter() is triggered. And, ktrnamei() does not check for recursion like most other ktrace ops do. Fix the bug by simply deferring the ktrace_enter() call. Also make the parameter to ktrnamei() const and convert to ANSI. Reported by: syzbot+d0a4de45e58d3c08af4b@syzkaller.appspotmail.com Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30340 --- sys/kern/kern_ktrace.c | 13 +++++-------- sys/sys/ktrace.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 8783600df6b1..875c079df3b9 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -698,8 +698,7 @@ ktruserret(struct thread *td) } void -ktrnamei(path) - char *path; +ktrnamei(const char *path) { struct ktr_request *req; int namelen; @@ -1017,7 +1016,6 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) return (EINVAL); kiop = NULL; - ktrace_enter(td); if (ops != KTROP_CLEAR) { /* * an operation which requires a file argument. @@ -1025,23 +1023,22 @@ sys_ktrace(struct thread *td, struct ktrace_args *uap) NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td); flags = FREAD | FWRITE | O_NOFOLLOW; error = vn_open(&nd, &flags, 0, NULL); - if (error) { - ktrace_exit(td); + if (error) return (error); - } NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; VOP_UNLOCK(vp); if (vp->v_type != VREG) { - (void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td); - ktrace_exit(td); + (void)vn_close(vp, FREAD|FWRITE, td->td_ucred, td); return (EACCES); } kiop = ktr_io_params_alloc(td, vp); } + /* * Clear all uses of the tracefile. */ + ktrace_enter(td); if (ops == KTROP_CLEARFILE) { restart: sx_slock(&allproc_lock); diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 50030d002f97..f1f9361f9f82 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -269,7 +269,7 @@ struct ktr_io_params; struct vnode *ktr_get_tracevp(struct proc *, bool); void ktr_io_params_free(struct ktr_io_params *); -void ktrnamei(char *); +void ktrnamei(const char *); void ktrcsw(int, int, const char *); void ktrpsig(int, sig_t, sigset_t *, int); void ktrfault(vm_offset_t, int); From owner-dev-commits-src-main@freebsd.org Sat May 22 16:17:52 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3377631483; Sat, 22 May 2021 16:17: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 4FnTCh4253z4SrG; Sat, 22 May 2021 16:17: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 68BE8274A7; Sat, 22 May 2021 16:17: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 14MGHqw8031604; Sat, 22 May 2021 16:17:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MGHqWo031603; Sat, 22 May 2021 16:17:52 GMT (envelope-from git) Date: Sat, 22 May 2021 16:17:52 GMT Message-Id: <202105221617.14MGHqWo031603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c235059bb7e6 - main - ktls.4: Remove an obsolete statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c235059bb7e600b7bb88234836102fa9911addc2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 16:17:52 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c235059bb7e600b7bb88234836102fa9911addc2 commit c235059bb7e600b7bb88234836102fa9911addc2 Author: Mark Johnston AuthorDate: 2021-05-22 16:12:30 +0000 Commit: Mark Johnston CommitDate: 2021-05-22 16:12:30 +0000 ktls.4: Remove an obsolete statement The default mb_use_ext_pgs value was toggled in commit 52cd25eb1aa. Reviewed by: jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30393 --- share/man/man4/ktls.4 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/share/man/man4/ktls.4 b/share/man/man4/ktls.4 index 648eeaedfa6a..9f01b1e8b1a5 100644 --- a/share/man/man4/ktls.4 +++ b/share/man/man4/ktls.4 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 8, 2021 +.Dd May 20, 2021 .Dt KTLS 4 .Os .Sh NAME @@ -131,12 +131,6 @@ application data (for example, handshake messages) or to send application data records with specific contents (for example, empty fragments). .Pp -TLS transmit requires the use of unmapped mbufs. -Unmapped mbufs are not enabled by default, but can be enabled by -setting the -.Va kern.ipc.mb_use_ext_pgs -sysctl node to 1. -.Pp The current TLS transmit mode of a socket can be queried via the .Dv TCP_TXTLS_MODE socket option. From owner-dev-commits-src-main@freebsd.org Sat May 22 18:44:00 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F28C6351B4; Sat, 22 May 2021 18:44: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 4FnXSJ053zz4gdk; Sat, 22 May 2021 18: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 D73F310F7; Sat, 22 May 2021 18:43: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 14MIhxpA033017; Sat, 22 May 2021 18:43:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MIhx5A033016; Sat, 22 May 2021 18:43:59 GMT (envelope-from git) Date: Sat, 22 May 2021 18:43:59 GMT Message-Id: <202105221843.14MIhx5A033016@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: cf74b2be533f - main - vfs: retire the now unused vnlru_free routine MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf74b2be533f0ed528a6f03af5fbd20d195dc61f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 18:44:00 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=cf74b2be533f0ed528a6f03af5fbd20d195dc61f commit cf74b2be533f0ed528a6f03af5fbd20d195dc61f Author: Mateusz Guzik AuthorDate: 2021-05-22 18:42:30 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 18:42:30 +0000 vfs: retire the now unused vnlru_free routine --- sys/kern/vfs_subr.c | 27 --------------------------- sys/sys/vnode.h | 1 - 2 files changed, 28 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 979cccf0e0dc..6a3cf2aa7505 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1349,33 +1349,6 @@ vnlru_free_vfsops(int count, struct vfsops *mnt_op, struct vnode *mvp) mtx_unlock(&vnode_list_mtx); } -/* - * Temporary binary compat, don't use. Call vnlru_free_vfsops instead. - */ -void -vnlru_free(int count, struct vfsops *mnt_op) -{ - struct vnode *mvp; - - if (count == 0) - return; - mtx_lock(&vnode_list_mtx); - mvp = vnode_list_free_marker; - if (vnlru_free_impl(count, mnt_op, mvp) == 0) { - /* - * It is possible the marker was moved over eligible vnodes by - * callers which filtered by different ops. If so, start from - * scratch. - */ - if (vnlru_read_freevnodes() > 0) { - TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist); - TAILQ_INSERT_HEAD(&vnode_list, mvp, v_vnodelist); - } - vnlru_free_impl(count, mnt_op, mvp); - } - mtx_unlock(&vnode_list_mtx); -} - struct vnode * vnlru_alloc_marker(void) { diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index f45824e3dc89..a61ef2611b0a 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -828,7 +828,6 @@ int vfs_write_suspend(struct mount *mp, int flags); int vfs_write_suspend_umnt(struct mount *mp); struct vnode *vnlru_alloc_marker(void); void vnlru_free_marker(struct vnode *); -void vnlru_free(int, struct vfsops *); void vnlru_free_vfsops(int, struct vfsops *, struct vnode *); int vop_stdbmap(struct vop_bmap_args *); int vop_stdfdatasync_buf(struct vop_fdatasync_args *); From owner-dev-commits-src-main@freebsd.org Sat May 22 19:26:04 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D2846359F1; Sat, 22 May 2021 19:26: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 4FnYNr0JSNz3H4H; Sat, 22 May 2021 19:26: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 E28B31DAA; Sat, 22 May 2021 19:26: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 14MJQ3uc087006; Sat, 22 May 2021 19:26:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MJQ3bW087005; Sat, 22 May 2021 19:26:03 GMT (envelope-from git) Date: Sat, 22 May 2021 19:26:03 GMT Message-Id: <202105221926.14MJQ3bW087005@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: 20123b25ee51 - main - fsck_ffs(8): fix divide by zero when debug messages are enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 20123b25ee51e9b122676a30d45c21a506bf1461 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 19:26:04 -0000 The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=20123b25ee51e9b122676a30d45c21a506bf1461 commit 20123b25ee51e9b122676a30d45c21a506bf1461 Author: Robert Wing AuthorDate: 2021-05-20 20:53:52 +0000 Commit: Robert Wing CommitDate: 2021-05-22 19:03:36 +0000 fsck_ffs(8): fix divide by zero when debug messages are enabled Only print buffer cache debug message when a cache lookup has been done. When running `fsck_ffs -d` on a gjournal'ed filesystem, it's possible that totalreads is greater than zero when no cache lookup has been done - causing a divide by zero. This commit fixes the following error: Floating point exception (core dumped) Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D30370 --- sbin/fsck_ffs/fsutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index b13ba4c54bde..db22ee5b20cf 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -576,7 +576,7 @@ ckfini(int markclean) rerun = 1; } } - if (debug && totalreads > 0) + if (debug && cachelookups > 0) printf("cache with %d buffers missed %d of %d (%d%%)\n", numbufs, cachereads, cachelookups, (int)(cachereads * 100 / cachelookups)); From owner-dev-commits-src-main@freebsd.org Sat May 22 19:28:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E78F8635CD4; Sat, 22 May 2021 19:28: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 4FnYRs62zkz3Jlr; Sat, 22 May 2021 19:28: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 B05681D1B; Sat, 22 May 2021 19:28: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 14MJSfB5087292; Sat, 22 May 2021 19:28:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MJSfFp087291; Sat, 22 May 2021 19:28:41 GMT (envelope-from git) Date: Sat, 22 May 2021 19:28:41 GMT Message-Id: <202105221928.14MJSfFp087291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: fca5cfd584d8 - main - lockprof: retire lock_prof_skipcount MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fca5cfd584d81ca291dbd898a8ff60c52d8c3c42 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 19:28:42 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=fca5cfd584d81ca291dbd898a8ff60c52d8c3c42 commit fca5cfd584d81ca291dbd898a8ff60c52d8c3c42 Author: Mateusz Guzik AuthorDate: 2021-05-18 19:05:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 19:28:37 +0000 lockprof: retire lock_prof_skipcount The implementation uses a global variable for *ALL* calls, defeating the point of sampling in the first place. Remove it as it clearly remains unused. --- sys/kern/subr_lock.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c index 1afaa19302ed..97b880b54ea2 100644 --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -278,7 +278,6 @@ static volatile int lock_prof_resetting; static int lock_prof_rejected; static int lock_prof_skipspin; -static int lock_prof_skipcount; #ifndef USE_CPU_NANOSECONDS uint64_t @@ -597,7 +596,6 @@ void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime, const char *file, int line) { - static int lock_prof_count; struct lock_profile_object *l; int spin; @@ -607,9 +605,6 @@ lock_profile_obtain_lock_success(struct lock_object *lo, int contested, /* don't reset the timer when/if recursing */ if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE)) return; - if (lock_prof_skipcount && - (++lock_prof_count % lock_prof_skipcount) != 0) - return; spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK) ? 1 : 0; if (spin && lock_prof_skipspin == 1) return; @@ -732,8 +727,6 @@ static SYSCTL_NODE(_debug_lock, OID_AUTO, prof, "lock profiling"); SYSCTL_INT(_debug_lock_prof, OID_AUTO, skipspin, CTLFLAG_RW, &lock_prof_skipspin, 0, "Skip profiling on spinlocks."); -SYSCTL_INT(_debug_lock_prof, OID_AUTO, skipcount, CTLFLAG_RW, - &lock_prof_skipcount, 0, "Sample approximately every N lock acquisitions."); SYSCTL_INT(_debug_lock_prof, OID_AUTO, rejected, CTLFLAG_RD, &lock_prof_rejected, 0, "Number of rejected profiling records"); SYSCTL_PROC(_debug_lock_prof, OID_AUTO, stats, From owner-dev-commits-src-main@freebsd.org Sat May 22 19:28:43 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 62E00636109; Sat, 22 May 2021 19:28: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 4FnYRt6v8Dz3JpN; Sat, 22 May 2021 19:28: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 C0CF31CBE; Sat, 22 May 2021 19:28: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 14MJSgKh087314; Sat, 22 May 2021 19:28:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MJSgEn087313; Sat, 22 May 2021 19:28:42 GMT (envelope-from git) Date: Sat, 22 May 2021 19:28:42 GMT Message-Id: <202105221928.14MJSgEn087313@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a0842e69aa5f - main - lockprof: add contested-only profiling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a0842e69aa5f86d61c072544b540ef21b2015211 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 19:28:43 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a0842e69aa5f86d61c072544b540ef21b2015211 commit a0842e69aa5f86d61c072544b540ef21b2015211 Author: Mateusz Guzik AuthorDate: 2021-05-18 19:07:19 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 19:28:37 +0000 lockprof: add contested-only profiling This allows tracking all wait times with much smaller runtime impact. For example when doing -j 104 buildkernel on tmpfs: no profiling: 2921.70s user 282.72s system 6598% cpu 48.562 total all acquires: 2926.87s user 350.53s system 6656% cpu 49.237 total contested only: 2919.64s user 290.31s system 6583% cpu 48.756 total --- sys/kern/subr_lock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c index 97b880b54ea2..9c433f683bac 100644 --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -272,6 +272,7 @@ DPCPU_DEFINE_STATIC(struct lock_prof_cpu, lp); #define LP_CPU(cpu) (DPCPU_ID_PTR((cpu), lp)) volatile int __read_mostly lock_prof_enable; +int __read_mostly lock_contested_only; static volatile int lock_prof_resetting; #define LPROF_SBUF_SIZE 256 @@ -605,6 +606,8 @@ lock_profile_obtain_lock_success(struct lock_object *lo, int contested, /* don't reset the timer when/if recursing */ if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE)) return; + if (lock_contested_only && !contested) + return; spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK) ? 1 : 0; if (spin && lock_prof_skipspin == 1) return; @@ -729,6 +732,8 @@ SYSCTL_INT(_debug_lock_prof, OID_AUTO, skipspin, CTLFLAG_RW, &lock_prof_skipspin, 0, "Skip profiling on spinlocks."); SYSCTL_INT(_debug_lock_prof, OID_AUTO, rejected, CTLFLAG_RD, &lock_prof_rejected, 0, "Number of rejected profiling records"); +SYSCTL_INT(_debug_lock_prof, OID_AUTO, contested_only, CTLFLAG_RW, + &lock_contested_only, 0, "Only profile contested acquires"); SYSCTL_PROC(_debug_lock_prof, OID_AUTO, stats, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, dump_lock_prof_stats, "A", From owner-dev-commits-src-main@freebsd.org Sat May 22 19:41:31 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3EA2363631B; Sat, 22 May 2021 19:41: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 4FnYkg1GMXz3QTn; Sat, 22 May 2021 19:41: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 13C74207F; Sat, 22 May 2021 19:41: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 14MJfUE5008730; Sat, 22 May 2021 19:41:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MJfUQ3008729; Sat, 22 May 2021 19:41:30 GMT (envelope-from git) Date: Sat, 22 May 2021 19:41:30 GMT Message-Id: <202105221941.14MJfUQ3008729@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 154f0ecc10ab - main - Fix tinderbox build after 1762f674ccb571e6 ktrace commit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 154f0ecc10abdd3c23d233bf85e292011a130583 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 19:41:31 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=154f0ecc10abdd3c23d233bf85e292011a130583 commit 154f0ecc10abdd3c23d233bf85e292011a130583 Author: Mateusz Guzik AuthorDate: 2021-05-22 19:37:53 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 19:41:19 +0000 Fix tinderbox build after 1762f674ccb571e6 ktrace commit. --- sys/kern/kern_exec.c | 6 ++++-- sys/kern/vfs_vnops.c | 2 ++ sys/sys/ktrace.h | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index d9b9e1ae122b..709c1b0ff28a 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -390,7 +390,9 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, static const char fexecv_proc_title[] = "(fexecv)"; imgp = &image_params; +#ifdef KTRACE kiop = NULL; +#endif /* * Lock the process and set the P_INEXEC flag to indicate that @@ -780,8 +782,6 @@ interpret: * we do not regain any tracing during a possible block. */ setsugid(p); - kiop = NULL; - #ifdef KTRACE kiop = ktrprocexec(p); #endif @@ -938,7 +938,9 @@ exec_fail: */ if (oldtextvp != NULL) vrele(oldtextvp); +#ifdef KTRACE ktr_io_params_free(kiop); +#endif pargs_drop(oldargs); pargs_drop(newargs); if (oldsigacts != NULL) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 9e45d1820eec..7f5275cf6b28 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2371,11 +2371,13 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) return (0); +#ifdef KTRACE if (!ktr_write || ktr_filesize_limit_signal) { PROC_LOCK(td->td_proc); kern_psignal(td->td_proc, SIGXFSZ); PROC_UNLOCK(td->td_proc); } +#endif return (EFBIG); } diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index f1f9361f9f82..5f8a782cd7e5 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -267,7 +267,16 @@ struct ktr_struct_array { #ifdef _KERNEL struct ktr_io_params; +#ifdef KTRACE struct vnode *ktr_get_tracevp(struct proc *, bool); +#else +static inline struct vnode * +ktr_get_tracevp(struct proc *p, bool ref) +{ + + return (NULL); +} +#endif void ktr_io_params_free(struct ktr_io_params *); void ktrnamei(const char *); void ktrcsw(int, int, const char *); From owner-dev-commits-src-main@freebsd.org Sat May 22 19:53:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 675E86366A7; Sat, 22 May 2021 19:53: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 4FnZ0q2Nlhz3kyN; Sat, 22 May 2021 19:53: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 39FEB2506; Sat, 22 May 2021 19:53: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 14MJrl2Q026359; Sat, 22 May 2021 19:53:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MJrlx7026358; Sat, 22 May 2021 19:53:47 GMT (envelope-from git) Date: Sat, 22 May 2021 19:53:47 GMT Message-Id: <202105221953.14MJrlx7026358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 48235c377f96 - main - Fix a braino in previous. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 48235c377f960050e9129aa847d7d73019561c82 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 19:53:47 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=48235c377f960050e9129aa847d7d73019561c82 commit 48235c377f960050e9129aa847d7d73019561c82 Author: Mateusz Guzik AuthorDate: 2021-05-22 19:48:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 19:53:40 +0000 Fix a braino in previous. Instead of trying to partially ifdef out ktrace handling, define the missing identifier to 0. Without this fix lack of ktrace in the kernel also means there is no SIGXFSZ signal delivery. --- sys/kern/vfs_vnops.c | 2 -- sys/sys/ktrace.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7f5275cf6b28..9e45d1820eec 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2371,13 +2371,11 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) return (0); -#ifdef KTRACE if (!ktr_write || ktr_filesize_limit_signal) { PROC_LOCK(td->td_proc); kern_psignal(td->td_proc, SIGXFSZ); PROC_UNLOCK(td->td_proc); } -#endif return (EFBIG); } diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 5f8a782cd7e5..283a95c36d6c 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -308,8 +308,12 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *, #define ktrstat_error(s, error) \ ktrstruct_error("stat", (s), sizeof(struct stat), error) extern u_int ktr_geniosize; +#ifdef KTRACE extern int ktr_filesize_limit_signal; #else +#define ktr_filesize_limit_signal 0 +#endif +#else #include From owner-dev-commits-src-main@freebsd.org Sat May 22 20:14:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1FA8F636CD3; Sat, 22 May 2021 20:14: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 4FnZSb0PTSz3tT4; Sat, 22 May 2021 20:14: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 DC25B23C7; Sat, 22 May 2021 20:14: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 14MKEMQi053219; Sat, 22 May 2021 20:14:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MKEM0W053218; Sat, 22 May 2021 20:14:22 GMT (envelope-from git) Date: Sat, 22 May 2021 20:14:22 GMT Message-Id: <202105222014.14MKEM0W053218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: fc369a353b5b - main - ktrace: fix a race between writes and close MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc369a353b5b5e0f8046687fcbd78a7cd9ad1810 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 20:14:23 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fc369a353b5b5e0f8046687fcbd78a7cd9ad1810 commit fc369a353b5b5e0f8046687fcbd78a7cd9ad1810 Author: Konstantin Belousov AuthorDate: 2021-05-22 12:40:00 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-22 20:14:13 +0000 ktrace: fix a race between writes and close It was possible that termination of ktrace session occured during some record write, in which case write occured after the close of the vnode. Use ktr_io_params refcounting to avoid this situation, by taking the reference on the structure instead of vnode. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30400 --- sys/kern/kern_ktrace.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 875c079df3b9..3a223215a60d 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1257,7 +1257,7 @@ ktrsetchildren(struct thread *td, struct proc *top, int ops, int facs, static void ktr_writerequest(struct thread *td, struct ktr_request *req) { - struct ktr_io_params *kiop; + struct ktr_io_params *kiop, *kiop1; struct ktr_header *kth; struct vnode *vp; struct proc *p; @@ -1272,14 +1272,10 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) p = td->td_proc; /* - * We hold the vnode and credential for use in I/O in case ktrace is + * We reference the kiop for use in I/O in case ktrace is * disabled on the process as we write out the request. - * - * XXXRW: This is not ideal: we could end up performing a write after - * the vnode has been closed. */ mtx_lock(&ktrace_mtx); - kiop = p->p_ktrioparms; /* @@ -1291,13 +1287,12 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) return; } + ktr_io_params_ref(kiop); vp = kiop->vp; cred = kiop->cr; lim = kiop->lim; - vrefact(vp); KASSERT(cred != NULL, ("ktr_writerequest: cred == NULL")); - crhold(cred); mtx_unlock(&ktrace_mtx); kth = &req->ktr_header; @@ -1339,9 +1334,11 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, cred); VOP_UNLOCK(vp); vn_finished_write(mp); - crfree(cred); if (error == 0) { - vrele(vp); + mtx_lock(&ktrace_mtx); + kiop = ktr_io_params_rele(kiop); + mtx_unlock(&ktrace_mtx); + ktr_io_params_free(kiop); return; } @@ -1354,12 +1351,15 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) "ktrace write failed, errno %d, tracing stopped for pid %d\n", error, p->p_pid); + kiop1 = NULL; PROC_LOCK(p); mtx_lock(&ktrace_mtx); if (p->p_ktrioparms != NULL && p->p_ktrioparms->vp == vp) - kiop = ktr_freeproc(p); + kiop1 = ktr_freeproc(p); + kiop = ktr_io_params_rele(kiop); mtx_unlock(&ktrace_mtx); PROC_UNLOCK(p); + ktr_io_params_free(kiop1); ktr_io_params_free(kiop); vrele(vp); } From owner-dev-commits-src-main@freebsd.org Sat May 22 20:18:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8054637085; Sat, 22 May 2021 20: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 4FnZYG5bVDz4Rr6; Sat, 22 May 2021 20: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 A2171290D; Sat, 22 May 2021 20: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 14MKIQeP053625; Sat, 22 May 2021 20: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 14MKIQI8053624; Sat, 22 May 2021 20:18:26 GMT (envelope-from git) Date: Sat, 22 May 2021 20:18:26 GMT Message-Id: <202105222018.14MKIQI8053624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e71d5c733170 - main - Fix limit testing after 1762f674ccb571e6 ktrace commit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e71d5c7331700504e58cf1a35dca529381723e02 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 20:18:26 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e71d5c7331700504e58cf1a35dca529381723e02 commit e71d5c7331700504e58cf1a35dca529381723e02 Author: Mateusz Guzik AuthorDate: 2021-05-22 20:12:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 20:18:21 +0000 Fix limit testing after 1762f674ccb571e6 ktrace commit. The previous: if ((uoff_t)uio->uio_offset + uio->uio_resid > lim) signal(....); was replaced with: if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) return; signal(....); Making (uoff_t)uio->uio_offset + uio->uio_resid == lim trip over the limit, when it did not previously. Unbreaks running 13.0 buildworld. --- sys/kern/vfs_vnops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 9e45d1820eec..34fcef1b7e1f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2368,7 +2368,7 @@ vn_rlimit_fsize(const struct vnode *vp, const struct uio *uio, return (0); ktr_write = (td->td_pflags & TDP_INKTRACE) != 0; lim = ktr_write ? td->td_ktr_io_lim : lim_cur(td, RLIMIT_FSIZE); - if ((uoff_t)uio->uio_offset + uio->uio_resid < lim) + if ((uoff_t)uio->uio_offset + uio->uio_resid <= lim) return (0); if (!ktr_write || ktr_filesize_limit_signal) { From owner-dev-commits-src-main@freebsd.org Sat May 22 21:05:41 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66A5A6379B4; Sat, 22 May 2021 21:05: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 4Fnbbn1FTwz4pdL; Sat, 22 May 2021 21:05: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 E98CB32AB; Sat, 22 May 2021 21:05: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 14ML5ef1021363; Sat, 22 May 2021 21:05:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14ML5eAK021362; Sat, 22 May 2021 21:05:40 GMT (envelope-from git) Date: Sat, 22 May 2021 21:05:40 GMT Message-Id: <202105222105.14ML5eAK021362@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 138f78e94bf8 - main - umtx: convert umtxq_lock to a macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 138f78e94bf83a8a92987d8be81f1e2c6c277cf8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 21:05:41 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=138f78e94bf83a8a92987d8be81f1e2c6c277cf8 commit 138f78e94bf83a8a92987d8be81f1e2c6c277cf8 Author: Mateusz Guzik AuthorDate: 2021-05-22 20:51:37 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-22 21:01:05 +0000 umtx: convert umtxq_lock to a macro Then LOCK_PROFILING starts reporting callers instead of the inline. --- sys/kern/kern_umtx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 784c10cb97ac..a1dca77fe991 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -272,7 +272,6 @@ static void umtx_shm_init(void); static void umtxq_sysinit(void *); static void umtxq_hash(struct umtx_key *key); static struct umtxq_chain *umtxq_getchain(struct umtx_key *key); -static void umtxq_lock(struct umtx_key *key); static void umtxq_unlock(struct umtx_key *key); static void umtxq_busy(struct umtx_key *key); static void umtxq_unbusy(struct umtx_key *key); @@ -501,15 +500,16 @@ umtxq_getchain(struct umtx_key *key) /* * Lock a chain. + * + * The code is a macro so that file/line information is taken from the caller. */ -static inline void -umtxq_lock(struct umtx_key *key) -{ - struct umtxq_chain *uc; - - uc = umtxq_getchain(key); - mtx_lock(&uc->uc_lock); -} +#define umtxq_lock(key) do { \ + struct umtx_key *_key = (key); \ + struct umtxq_chain *_uc; \ + \ + _uc = umtxq_getchain(_key); \ + mtx_lock(&_uc->uc_lock); \ +} while (0) /* * Unlock a chain. From owner-dev-commits-src-main@freebsd.org Sat May 22 21:50:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5AA5763811D; Sat, 22 May 2021 21:50: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 4FncZz1sbTz3hZH; Sat, 22 May 2021 21:50: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 28F083ABC; Sat, 22 May 2021 21:50: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 14MLo3Pm076009; Sat, 22 May 2021 21:50:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MLo3DS076006; Sat, 22 May 2021 21:50:03 GMT (envelope-from git) Date: Sat, 22 May 2021 21:50:03 GMT Message-Id: <202105222150.14MLo3DS076006@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 33c1bdfc3e09 - main - tests/libalias: Add perfomance test utility MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 33c1bdfc3e098862100bab7a8dc729d8c78ffa7c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 21:50:03 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=33c1bdfc3e098862100bab7a8dc729d8c78ffa7c commit 33c1bdfc3e098862100bab7a8dc729d8c78ffa7c Author: Lutz Donnerhacke AuthorDate: 2021-05-21 14:54:24 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-22 21:45:42 +0000 tests/libalias: Add perfomance test utility In order to compare upcoming changes for their effectivness, measure performance by counting opertions and the runtime of each operation over the time. Accumulate all tests in a single instance, so make it complicated over the time. If you wait long enough, you will notice the expiry of old flows. Reviewed by: kp (earlier version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30379 --- tests/sys/netinet/libalias/Makefile | 3 + tests/sys/netinet/libalias/perf.c | 198 ++++++++++++++++++++++++++++++++++++ tests/sys/netinet/libalias/util.c | 17 +++- 3 files changed, 213 insertions(+), 5 deletions(-) diff --git a/tests/sys/netinet/libalias/Makefile b/tests/sys/netinet/libalias/Makefile index 79922d7d4b13..6ee2fc0e0e1f 100644 --- a/tests/sys/netinet/libalias/Makefile +++ b/tests/sys/netinet/libalias/Makefile @@ -8,10 +8,13 @@ BINDIR= ${TESTSDIR} ATF_TESTS_C+= 1_instance \ 2_natout \ +PROGS+= perf + LIBADD+= alias SRCS.1_instance=1_instance.c util.c SRCS.2_natout= 2_natout.c util.c +SRCS.perf= perf.c util.c .include diff --git a/tests/sys/netinet/libalias/perf.c b/tests/sys/netinet/libalias/perf.c new file mode 100644 index 000000000000..ac4796cf9649 --- /dev/null +++ b/tests/sys/netinet/libalias/perf.c @@ -0,0 +1,198 @@ +#include +#include +#include +#include +#include "util.h" +#include + +/* common ip ranges */ +static struct in_addr masq = { htonl(0x01020304) }; +static struct in_addr prv = { htonl(0x0a000000) }; +static struct in_addr ext = { htonl(0x12000000) }; + +#define timevalcmp(tv, uv, cmp) \ + (((tv).tv_sec == (uv).tv_sec) \ + ? ((tv).tv_usec cmp (uv).tv_usec) \ + : ((tv).tv_sec cmp (uv).tv_sec)) + +#define timevaldiff(n, o) \ + (((n).tv_sec - (o).tv_sec)*1000000l + \ + ((n).tv_usec - (o).tv_usec)) + +int main(int argc, char ** argv) +{ + struct libalias *la; + struct timeval timeout; + struct ip *p; + struct udphdr *u; + struct { + struct in_addr src, dst; + uint16_t sport, dport, aport; + } *batch; + struct { + unsigned long ok, fail; + } nat, unnat, random, attack; + int max_seconds, batch_size, random_size, attack_length, round, cnt; + + if(argc != 5 || + 0 > (max_seconds = atoi(argv[1])) || + 0 >= (batch_size = atoi(argv[2])) || + 0 >= (random_size = atoi(argv[3])) || + 0 >= (attack_length = atoi(argv[4]))) { + printf("Usage: %s max_seconds batch_size random_size attack_length\n", argv[0]); + return 1; + } + if (NULL == (la = LibAliasInit(NULL))) { + perror("LibAliasInit"); + return -1; + } + + bzero(&nat, sizeof(nat)); + bzero(&unnat, sizeof(unnat)); + bzero(&random, sizeof(random)); + bzero(&attack, sizeof(attack)); + + LibAliasSetAddress(la, masq); + LibAliasSetMode(la, PKT_ALIAS_DENY_INCOMING, PKT_ALIAS_DENY_INCOMING); + + prv.s_addr &= htonl(0xffff0000); + ext.s_addr &= htonl(0xffff0000); + + p = ip_packet(prv, ext, 0, 64); + u = set_udp(p, 0, 0); + + if (NULL == (batch = calloc(batch_size, sizeof(*batch)))) { + perror("calloc(batch)"); + return -1; + } + + gettimeofday(&timeout, NULL); + timeout.tv_sec += max_seconds; + + printf("RND SEC NAT RND ATT UNA\n"); + for (round = 0; ; round++) { + int i, res; + struct timeval now, start; + + printf("%3d ", round+1); + + gettimeofday(&start, NULL); + printf("%3ld ", max_seconds - (timeout.tv_sec - start.tv_sec)); + for (cnt = i = 0; i < batch_size; i++, cnt++) { + batch[i].src.s_addr = prv.s_addr | htonl(rand_range(0, 0xffff)); + batch[i].dst.s_addr = ext.s_addr | htonl(rand_range(0, 0xffff)); + batch[i].sport = rand_range(1000, 60000); + batch[i].dport = rand_range(1000, 60000); + + p->ip_src = batch[i].src; + p->ip_dst = batch[i].dst; + u = set_udp(p, batch[i].sport, batch[i].dport); + + res = LibAliasOut(la, p, 64); + batch[i].aport = htons(u->uh_sport); + + if (res == PKT_ALIAS_OK && + u->uh_dport == htons(batch[i].dport) && + addr_eq(p->ip_dst, batch[i].dst) && + addr_eq(p->ip_src, masq)) + nat.ok++; + else + nat.fail++; + + gettimeofday(&now, NULL); + if(timevalcmp(now, timeout, >=)) + goto out; + } + if (cnt > 0) + printf("%3lu ", timevaldiff(now, start) / cnt); + + start = now; + for (cnt = i = 0; i < random_size; i++, cnt++) { + p->ip_src.s_addr = ext.s_addr & htonl(0xfff00000); + p->ip_src.s_addr |= htonl(rand_range(0, 0xffff)); + p->ip_dst = masq; + u = set_udp(p, rand_range(1, 0xffff), rand_range(1, 0xffff)); + + res = LibAliasIn(la, p, 64); + + if (res == PKT_ALIAS_OK) + random.ok++; + else + random.fail++; + + gettimeofday(&now, NULL); + if(timevalcmp(now, timeout, >=)) + goto out; + } + if (cnt > 0) + printf("%3lu ", timevaldiff(now, start) / cnt); + + start = now; + p->ip_src.s_addr = ext.s_addr & htonl(0xfff00000); + p->ip_src.s_addr |= htonl(rand_range(0, 0xffff)); + p->ip_dst = masq; + u = set_udp(p, rand_range(1, 0xffff), rand_range(1, 0xffff)); + for (cnt = i = 0; i < attack_length; i++, cnt++) { + res = LibAliasIn(la, p, 64); + + if (res == PKT_ALIAS_OK) + attack.ok++; + else + attack.fail++; + + gettimeofday(&now, NULL); + if(timevalcmp(now, timeout, >=)) + goto out; + } + if (cnt > 0) + printf("%3lu ", timevaldiff(now, start) / cnt); + + qsort(batch, batch_size, sizeof(*batch), randcmp); + + gettimeofday(&start, NULL); + for (cnt = i = 0; i < batch_size; i++, cnt++) { + p->ip_src = batch[i].dst; + p->ip_dst = masq; + u = set_udp(p, batch[i].dport, batch[i].aport); + + res = LibAliasIn(la, p, 64); + batch[i].aport = htons(u->uh_sport); + + if (res == PKT_ALIAS_OK && + u->uh_sport == htons(batch[i].dport) && + u->uh_dport == htons(batch[i].sport) && + addr_eq(p->ip_dst, batch[i].src) && + addr_eq(p->ip_src, batch[i].dst)) + unnat.ok++; + else + unnat.fail++; + + gettimeofday(&now, NULL); + if(timevalcmp(now, timeout, >=)) + goto out; + } + if (cnt > 0) + printf("%3lu\n", timevaldiff(now, start) / cnt); + } +out: + printf("\n\n"); + free(batch); + free(p); + LibAliasUninit(la); + + printf("Results\n"); + printf(" Rounds : %7u\n", round); + printf(" NAT ok : %7lu\n", nat.ok); + printf(" NAT fail: %7lu\n", nat.fail); + printf(" UNNAT ok : %7lu\n", unnat.ok); + printf(" UNNAT fail: %7lu\n", unnat.fail); + printf("RANDOM ok : %7lu\n", random.ok); + printf("RANDOM fail: %7lu\n", random.fail); + printf("ATTACK ok : %7lu\n", attack.ok); + printf("ATTACK fail: %7lu\n", attack.fail); + printf(" -------------------\n"); + printf(" Total: %7lu\n", + nat.ok + nat.fail + unnat.ok + unnat.fail + + random.ok + random.fail + attack.ok + attack.fail); + return (0); +} diff --git a/tests/sys/netinet/libalias/util.c b/tests/sys/netinet/libalias/util.c index e0e5e08eb23e..5e880752d261 100644 --- a/tests/sys/netinet/libalias/util.c +++ b/tests/sys/netinet/libalias/util.c @@ -1,4 +1,3 @@ -#include #include #include @@ -6,6 +5,14 @@ #include "util.h" +#define REQUIRE(x) do { \ + if (!(x)) { \ + fprintf(stderr, "Failed in %s %s:%d.\n",\ + __FUNCTION__, __FILE__, __LINE__); \ + exit(-1); \ + } \ +} while(0) + int randcmp(const void *a, const void *b) { @@ -42,10 +49,10 @@ ip_packet(struct in_addr src, struct in_addr dst, u_char protocol, size_t len) { struct ip * p; - ATF_REQUIRE(len >= 64 && len <= IP_MAXPACKET); + REQUIRE(len >= 64 && len <= IP_MAXPACKET); p = calloc(1, len); - ATF_REQUIRE(p != NULL); + REQUIRE(p != NULL); p->ip_v = IPVERSION; p->ip_hl = sizeof(*p)/4; @@ -54,7 +61,7 @@ ip_packet(struct in_addr src, struct in_addr dst, u_char protocol, size_t len) p->ip_src = src; p->ip_dst = dst; p->ip_p = protocol; - ATF_REQUIRE(p->ip_hl == 5); + REQUIRE(p->ip_hl == 5); return (p); } @@ -65,7 +72,7 @@ set_udp(struct ip *p, u_short sport, u_short dport) { struct udphdr *u = (void *)&(up[p->ip_hl]); int payload = ntohs(p->ip_len) - 4*p->ip_hl; - ATF_REQUIRE(payload >= (int)sizeof(*u)); + REQUIRE(payload >= (int)sizeof(*u)); p->ip_p = IPPROTO_UDP; u->uh_sport = htons(sport); u->uh_dport = htons(dport); From owner-dev-commits-src-main@freebsd.org Sat May 22 21:57:12 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 878A26384E2; Sat, 22 May 2021 21:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FnclD2fc2z3kv7; Sat, 22 May 2021 21:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BB983D8E; Sat, 22 May 2021 21:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14MLvCXK086894; Sat, 22 May 2021 21:57:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MLvCTG086893; Sat, 22 May 2021 21:57:12 GMT (envelope-from git) Date: Sat, 22 May 2021 21:57:12 GMT Message-Id: <202105222157.14MLvCTG086893@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 3f7e14ad9345 - main - nfscl: Add hash lists for the NFSv4 opens MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f7e14ad93454476bb11b4b8de5b41930d13312e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 21:57:12 -0000 The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3f7e14ad93454476bb11b4b8de5b41930d13312e commit 3f7e14ad93454476bb11b4b8de5b41930d13312e Author: Rick Macklem AuthorDate: 2021-05-22 21:51:38 +0000 Commit: Rick Macklem CommitDate: 2021-05-22 21:53:56 +0000 nfscl: Add hash lists for the NFSv4 opens A problem was reported via email, where a large (130000+) accumulation of NFSv4 opens on an NFSv4 mount caused significant lock contention on the mutex used to protect the client mount's open/lock state. Although the root cause for the accumulation of opens was not resolved, it is obvious that the NFSv4 client is not designed to handle 100000+ opens efficiently. When searching for an open, usually for a match by file handle, a linear search of all opens is done. This patch adds a table of hash lists for the opens, hashed on file handle. This table will be used by future commits to search for an open based on file handle more efficiently. MFC after: 2 weeks --- sys/fs/nfs/nfsclstate.h | 7 +++++++ sys/fs/nfsclient/nfs_clstate.c | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfsclstate.h b/sys/fs/nfs/nfsclstate.h index e17be74c5581..898a7de391dc 100644 --- a/sys/fs/nfs/nfsclstate.h +++ b/sys/fs/nfs/nfsclstate.h @@ -42,6 +42,7 @@ LIST_HEAD(nfsclhead, nfsclclient); LIST_HEAD(nfsclownerhead, nfsclowner); TAILQ_HEAD(nfscldeleghead, nfscldeleg); LIST_HEAD(nfscldeleghash, nfscldeleg); +LIST_HEAD(nfsclopenhash, nfsclopen); TAILQ_HEAD(nfscllayouthead, nfscllayout); LIST_HEAD(nfscllayouthash, nfscllayout); LIST_HEAD(nfsclflayouthead, nfsclflayout); @@ -50,6 +51,10 @@ LIST_HEAD(nfsclrecalllayouthead, nfsclrecalllayout); #define NFSCLDELEGHASHSIZE 256 #define NFSCLDELEGHASH(c, f, l) \ (&((c)->nfsc_deleghash[ncl_hash((f), (l)) % NFSCLDELEGHASHSIZE])) +#define NFSCLOPENHASHSIZE 256 +#define NFSCLOPENHASHFUNC(f, l) (ncl_hash((f), (l)) % NFSCLOPENHASHSIZE) +#define NFSCLOPENHASH(c, f, l) \ + (&((c)->nfsc_openhash[NFSCLOPENHASHFUNC((f), (l))])) #define NFSCLLAYOUTHASHSIZE 256 #define NFSCLLAYOUTHASH(c, f, l) \ (&((c)->nfsc_layouthash[ncl_hash((f), (l)) % NFSCLLAYOUTHASHSIZE])) @@ -104,6 +109,7 @@ struct nfsclclient { struct nfsclownerhead nfsc_owner; struct nfscldeleghead nfsc_deleg; struct nfscldeleghash nfsc_deleghash[NFSCLDELEGHASHSIZE]; + struct nfsclopenhash nfsc_openhash[NFSCLOPENHASHSIZE]; struct nfscllayouthead nfsc_layout; struct nfscllayouthash nfsc_layouthash[NFSCLLAYOUTHASHSIZE]; struct nfscldevinfohead nfsc_devinfo; @@ -183,6 +189,7 @@ struct nfscldeleg { */ struct nfsclopen { LIST_ENTRY(nfsclopen) nfso_list; + LIST_ENTRY(nfsclopen) nfso_hash; struct nfscllockownerhead nfso_lock; nfsv4stateid_t nfso_stateid; struct nfsclowner *nfso_own; diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 1ed3630ce6e7..a8eace2ffd0b 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -240,9 +240,11 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, */ nowp = malloc(sizeof (struct nfsclowner), M_NFSCLOWNER, M_WAITOK); - if (nfhp != NULL) + if (nfhp != NULL) { nop = malloc(sizeof (struct nfsclopen) + fhlen - 1, M_NFSCLOPEN, M_WAITOK); + nop->nfso_hash.le_prev = NULL; + } ret = nfscl_getcl(vp->v_mount, cred, p, 1, &clp); if (ret != 0) { free(nowp, M_NFSCLOWNER); @@ -412,6 +414,8 @@ nfscl_newopen(struct nfsclclient *clp, struct nfscldeleg *dp, dp->nfsdl_timestamp = NFSD_MONOSEC + 120; nfsstatsv1.cllocalopens++; } else { + LIST_INSERT_HEAD(NFSCLOPENHASH(clp, fhp, fhlen), + nop, nfso_hash); nfsstatsv1.clopens++; } LIST_INSERT_HEAD(&owp->nfsow_open, nop, nfso_list); @@ -837,6 +841,8 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, LIST_INIT(&clp->nfsc_devinfo); for (i = 0; i < NFSCLDELEGHASHSIZE; i++) LIST_INIT(&clp->nfsc_deleghash[i]); + for (i = 0; i < NFSCLOPENHASHSIZE; i++) + LIST_INIT(&clp->nfsc_openhash[i]); for (i = 0; i < NFSCLLAYOUTHASHSIZE; i++) LIST_INIT(&clp->nfsc_layouthash[i]); clp->nfsc_flags = NFSCLFLAGS_INITED; @@ -1475,6 +1481,8 @@ nfscl_freeopen(struct nfsclopen *op, int local) { LIST_REMOVE(op, nfso_list); + if (op->nfso_hash.le_prev != NULL) + LIST_REMOVE(op, nfso_hash); nfscl_freealllocks(&op->nfso_lock, local); free(op, M_NFSCLOPEN); if (local) @@ -1706,6 +1714,8 @@ nfscl_expireclient(struct nfsclclient *clp, struct nfsmount *nmp, LIST_REMOVE(op, nfso_list); op->nfso_own = towp; LIST_INSERT_HEAD(&towp->nfsow_open, op, nfso_list); + LIST_INSERT_HEAD(NFSCLOPENHASH(clp, op->nfso_fh, + op->nfso_fhlen), op, nfso_hash); nfsstatsv1.cllocalopens--; nfsstatsv1.clopens++; } @@ -1714,6 +1724,8 @@ nfscl_expireclient(struct nfsclclient *clp, struct nfsmount *nmp, LIST_REMOVE(owp, nfsow_list); owp->nfsow_clp = clp; LIST_INSERT_HEAD(&clp->nfsc_owner, owp, nfsow_list); + LIST_INSERT_HEAD(NFSCLOPENHASH(clp, op->nfso_fh, + op->nfso_fhlen), op, nfso_hash); nfsstatsv1.cllocalopenowners--; nfsstatsv1.clopenowners++; nfsstatsv1.cllocalopens--; @@ -4198,6 +4210,7 @@ nfscl_moveopen(vnode_t vp, struct nfsclclient *clp, struct nfsmount *nmp, np = VTONFS(vp); nop = malloc(sizeof (struct nfsclopen) + lop->nfso_fhlen - 1, M_NFSCLOPEN, M_WAITOK); + nop->nfso_hash.le_prev = NULL; newone = 0; nfscl_newopen(clp, NULL, &owp, NULL, &op, &nop, owp->nfsow_owner, lop->nfso_fh, lop->nfso_fhlen, cred, &newone); From owner-dev-commits-src-main@freebsd.org Sat May 22 22:02:21 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79D41638A0C; Sat, 22 May 2021 22:02: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 4Fncs92xRKz3mTj; Sat, 22 May 2021 22:02: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 4CA0E3AF3; Sat, 22 May 2021 22:02: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 14MM2LOF000528; Sat, 22 May 2021 22:02:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MM2LM3000527; Sat, 22 May 2021 22:02:21 GMT (envelope-from git) Date: Sat, 22 May 2021 22:02:21 GMT Message-Id: <202105222202.14MM2LM3000527@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 03b0505b8fe8 - main - ip_forward: Restore RFC reference MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03b0505b8fe848f33f2f38fe89dd5538908c847e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 22:02:21 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=03b0505b8fe848f33f2f38fe89dd5538908c847e commit 03b0505b8fe848f33f2f38fe89dd5538908c847e Author: Zhenlei Huang AuthorDate: 2021-05-22 21:53:52 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-22 22:01:37 +0000 ip_forward: Restore RFC reference Add RFC reference lost in 3d846e48227e2e78c1e7b35145f57353ffda56ba PR: 255388 Reviewed By: rgrimes, donner, karels, marcus, emaste MFC after: 27 days Differential Revision: https://reviews.freebsd.org/D30374 --- sys/netinet/ip_input.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 1139e3a5abfa..733cc2901879 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -740,7 +740,10 @@ passin: } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { MROUTER_RLOCK(); - /* Do not forward packets from IN_LINKLOCAL. */ + /* + * RFC 3927 2.7: Do not forward multicast packets from + * IN_LINKLOCAL. + */ if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { /* * If we are acting as a multicast router, all @@ -780,7 +783,7 @@ passin: goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) goto ours; - /* Do not forward packets to or from IN_LINKLOCAL. */ + /* RFC 3927 2.7: Do not forward packets to or from IN_LINKLOCAL. */ if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) || IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { IPSTAT_INC(ips_cantforward); From owner-dev-commits-src-main@freebsd.org Sat May 22 22:53:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 40EE963958F; Sat, 22 May 2021 22:53: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 4Fndzw19xGz4dTj; Sat, 22 May 2021 22:53: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 115DA4B7D; Sat, 22 May 2021 22:53: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 14MMrFA9066513; Sat, 22 May 2021 22:53:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MMrFlK066512; Sat, 22 May 2021 22:53:15 GMT (envelope-from git) Date: Sat, 22 May 2021 22:53:15 GMT Message-Id: <202105222253.14MMrFlK066512@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 114f4b17d5b6 - main - [ar71xx] During reset, don't spin, just keep trying MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 114f4b17d5b60a5d53ca98f08cc7e8d78c6984de Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 22:53:16 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=114f4b17d5b60a5d53ca98f08cc7e8d78c6984de commit 114f4b17d5b60a5d53ca98f08cc7e8d78c6984de Author: Adrian Chadd AuthorDate: 2021-04-19 05:48:13 +0000 Commit: Adrian Chadd CommitDate: 2021-05-22 22:53:00 +0000 [ar71xx] During reset, don't spin, just keep trying I've seen this fail from time to time and just hang during reset. Instead of it just hanging, just poke it again. I've not seen it fail in hundreds of test resets now. Tested: * AR9344 AP/STA configuration --- sys/mips/atheros/ar71xx_machdep.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/mips/atheros/ar71xx_machdep.c b/sys/mips/atheros/ar71xx_machdep.c index 2bb6d5845d16..72beec972de2 100644 --- a/sys/mips/atheros/ar71xx_machdep.c +++ b/sys/mips/atheros/ar71xx_machdep.c @@ -80,10 +80,13 @@ platform_cpu_init() void platform_reset(void) { - ar71xx_device_stop(RST_RESET_FULL_CHIP); - /* Wait for reset */ - while(1) - ; + while(1) { + printf("%s: resetting via AHB FULL_CHIP register...\n", __func__); + ar71xx_device_start(RST_RESET_FULL_CHIP); + DELAY(100 * 1000); + ar71xx_device_stop(RST_RESET_FULL_CHIP); + DELAY(1000 * 1000); + } } /* From owner-dev-commits-src-main@freebsd.org Sat May 22 23:34:01 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB80C6398D3; Sat, 22 May 2021 23:34: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 4Fnftx5q1zz3CNj; Sat, 22 May 2021 23:34: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 AFC7F550B; Sat, 22 May 2021 23:34: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 14MNY1pH020471; Sat, 22 May 2021 23:34:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MNY1W1020470; Sat, 22 May 2021 23:34:01 GMT (envelope-from git) Date: Sat, 22 May 2021 23:34:01 GMT Message-Id: <202105222334.14MNY1W1020470@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 1ca399682822 - main - [ath] Add ast_tsfoor to the sysctl statistics array. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1ca39968282266283251f2d3e4c27bcb67bb14f1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 23:34:02 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=1ca39968282266283251f2d3e4c27bcb67bb14f1 commit 1ca39968282266283251f2d3e4c27bcb67bb14f1 Author: Adrian Chadd AuthorDate: 2021-03-13 22:16:17 +0000 Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:16 +0000 [ath] Add ast_tsfoor to the sysctl statistics array. --- sys/dev/ath/if_ath_sysctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c index 3c873d3e8b34..de852158f991 100644 --- a/sys/dev/ath/if_ath_sysctl.c +++ b/sys/dev/ath/if_ath_sysctl.c @@ -1301,6 +1301,10 @@ ath_sysctl_stats_attach(struct ath_softc *sc) CTLFLAG_RD, &sc->sc_stats.ast_tx_ldpc, 0, "Number of LDPC frames transmitted"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tsfoor", + CTLFLAG_RD, &sc->sc_stats.ast_tsfoor, 0, + "Number of TSF out of range interrupts/resets"); + /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); From owner-dev-commits-src-main@freebsd.org Sat May 22 23:34:04 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 76315639D1F; Sat, 22 May 2021 23:34: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 4Fnfv016Nhz3CNr; Sat, 22 May 2021 23:34: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 00C3D550C; Sat, 22 May 2021 23:34: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 14MNY3Q9020520; Sat, 22 May 2021 23:34:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MNY3dE020519; Sat, 22 May 2021 23:34:03 GMT (envelope-from git) Date: Sat, 22 May 2021 23:34:03 GMT Message-Id: <202105222334.14MNY3dE020519@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: da7f6e67901b - main - [athstats] Add a tag to listen for beacon stuff MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da7f6e67901bddbeee47f8608334d1567ecdce4d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 23:34:04 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=da7f6e67901bddbeee47f8608334d1567ecdce4d commit da7f6e67901bddbeee47f8608334d1567ecdce4d Author: Adrian Chadd AuthorDate: 2021-03-31 19:37:47 +0000 Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:44 +0000 [athstats] Add a tag to listen for beacon stuff I'm debugging weird beacon issues and thus here we are. --- tools/tools/ath/athstats/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/tools/ath/athstats/main.c b/tools/tools/ath/athstats/main.c index 29e86365c83b..23bdb25981d5 100644 --- a/tools/tools/ath/athstats/main.c +++ b/tools/tools/ath/athstats/main.c @@ -65,6 +65,9 @@ static struct { { "tdma", "input,output,bexmit,tdmau,tdmadj,crcerr,phyerr,phytor,rssi,noise,rate" }, + { "beacon", + "bstuck,bmiss,bexmit,beacons,bmisscount,reset,ofdm,cck,input,output" + }, }; static const char * From owner-dev-commits-src-main@freebsd.org Sat May 22 23:34:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B73E639D99; Sat, 22 May 2021 23:34: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 4Fnfty6ykDz3ChJ; Sat, 22 May 2021 23:34: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 D23154FD0; Sat, 22 May 2021 23:34: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 14MNY2Gg020498; Sat, 22 May 2021 23:34:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MNY2Y4020497; Sat, 22 May 2021 23:34:02 GMT (envelope-from git) Date: Sat, 22 May 2021 23:34:02 GMT Message-Id: <202105222334.14MNY2Y4020497@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 079bd2e750ad - main - [athstats] Add some (but not all, sigh) missing statistics. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 079bd2e750adae17e0f13cc4e876249fd4c2016e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 23:34:03 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=079bd2e750adae17e0f13cc4e876249fd4c2016e commit 079bd2e750adae17e0f13cc4e876249fd4c2016e Author: Adrian Chadd AuthorDate: 2021-03-13 22:16:37 +0000 Commit: Adrian Chadd CommitDate: 2021-05-22 22:54:25 +0000 [athstats] Add some (but not all, sigh) missing statistics. This adds a few recent statistics, including TSFOOR that I just added to the driver. --- tools/tools/ath/athstats/athstats.c | 38 ++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c index 911526755ee4..34e95b7c3885 100644 --- a/tools/tools/ath/athstats/athstats.c +++ b/tools/tools/ath/athstats/athstats.c @@ -297,8 +297,23 @@ static const struct fmt athstats[] = { { 4, "txaggrfail", "TXAF", "A-MPDU sub-frame TX attempt failures" }, #define S_TX_AGGR_FAILALL AFTER(S_TX_AGGR_FAIL) { 7, "txaggrfailall", "TXAFALL", "A-MPDU TX frame failures" }, -#ifndef __linux__ -#define S_CABQ_XMIT AFTER(S_TX_AGGR_FAILALL) +#define S_TX_MCASTQ_OVERFLOW AFTER(S_TX_AGGR_FAILALL) + { 8, "txmcastqovf", "TXMCQOVF", "TX multicast queue overflow" }, +#define S_RX_KEYMISS AFTER(S_TX_MCASTQ_OVERFLOW) + { 4, "rxkeymiss", "RXKM", "RX crypto key miss" }, +#define S_TX_SWFILTERED AFTER(S_RX_KEYMISS) + { 7, "txswfilt", "TXSWFLT", "TX frames filtered by hw and retried" }, +#define S_TX_NODE_PSQ_OVERFLOW AFTER(S_TX_SWFILTERED) + { 8, "txpsqovf", "TXPSQOVF", "TX frames overflowed the power save queue" }, +#define S_TX_NODEQ_OVERFLOW AFTER(S_TX_NODE_PSQ_OVERFLOW) + { 8, "txnqovf", "TXNQOVF", "TX frames overflowed the node queue" }, +#define S_TX_LDPC AFTER(S_TX_NODEQ_OVERFLOW) + { 6, "txldpc", "TXLDPC", "TX frames transmitted with LDPC" }, +#define S_TX_STBC AFTER(S_TX_LDPC) + { 6, "txstbc", "TXSTBC", "TX frames transmitted with STBC" }, +#define S_TSFOOR AFTER(S_TX_STBC) + { 6, "tsfoor", "TSFOOR", "TSF overflow interrupt/restarts" }, +#define S_CABQ_XMIT AFTER(S_TSFOOR) { 7, "cabxmit", "cabxmit", "cabq frames transmitted" }, #define S_CABQ_BUSY AFTER(S_CABQ_XMIT) { 8, "cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, @@ -309,9 +324,6 @@ static const struct fmt athstats[] = { #define S_RX_BUSDMA AFTER(S_TX_BUSDMA) { 8, "rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, #define S_FF_TXOK AFTER(S_RX_BUSDMA) -#else -#define S_FF_TXOK AFTER(S_TX_AGGR_FAILALL) -#endif { 5, "fftxok", "fftxok", "fast frames xmit successfully" }, #define S_FF_TXERR AFTER(S_FF_TXOK) { 5, "fftxerr", "fftxerr", "fast frames not xmit due to error" }, @@ -770,6 +782,14 @@ ath_get_curstat(struct bsdstat *sf, int s, char b[], size_t bs) case S_TX_AGGR_OK: STAT(tx_aggr_ok); case S_TX_AGGR_FAIL: STAT(tx_aggr_fail); case S_TX_AGGR_FAILALL: STAT(tx_aggr_failall); + case S_TX_MCASTQ_OVERFLOW: STAT(tx_mcastq_overflow); + case S_RX_KEYMISS: STAT(rx_keymiss); + case S_TX_SWFILTERED: STAT(tx_swfiltered); + case S_TX_NODE_PSQ_OVERFLOW: STAT(tx_node_psq_overflow); + case S_TX_NODEQ_OVERFLOW: STAT(tx_nodeq_overflow); + case S_TX_LDPC: STAT(tx_ldpc); + case S_TX_STBC: STAT(tx_stbc); + case S_TSFOOR: STAT(tsfoor); } b[0] = '\0'; return 0; @@ -1015,6 +1035,14 @@ ath_get_totstat(struct bsdstat *sf, int s, char b[], size_t bs) case S_TX_AGGR_OK: STAT(tx_aggr_ok); case S_TX_AGGR_FAIL: STAT(tx_aggr_fail); case S_TX_AGGR_FAILALL: STAT(tx_aggr_failall); + case S_TX_MCASTQ_OVERFLOW: STAT(tx_mcastq_overflow); + case S_RX_KEYMISS: STAT(rx_keymiss); + case S_TX_SWFILTERED: STAT(tx_swfiltered); + case S_TX_NODE_PSQ_OVERFLOW: STAT(tx_node_psq_overflow); + case S_TX_NODEQ_OVERFLOW: STAT(tx_nodeq_overflow); + case S_TX_LDPC: STAT(tx_ldpc); + case S_TX_STBC: STAT(tx_stbc); + case S_TSFOOR: STAT(tsfoor); } b[0] = '\0'; return 0; From owner-dev-commits-src-main@freebsd.org Sat May 22 23:43:44 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A35E639ED3; Sat, 22 May 2021 23:43: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 4Fng676rtBz3GPB; Sat, 22 May 2021 23:43: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 D2C9B571F; Sat, 22 May 2021 23:43: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 14MNhhOt033851; Sat, 22 May 2021 23:43:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14MNhhGL033850; Sat, 22 May 2021 23:43:43 GMT (envelope-from git) Date: Sat, 22 May 2021 23:43:43 GMT Message-Id: <202105222343.14MNhhGL033850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: f858e9281c60 - main - [ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f858e9281c60d0730ab20ed94eef5c52e66795ee Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2021 23:43:44 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=f858e9281c60d0730ab20ed94eef5c52e66795ee commit f858e9281c60d0730ab20ed94eef5c52e66795ee Author: Adrian Chadd AuthorDate: 2021-05-22 23:39:16 +0000 Commit: Adrian Chadd CommitDate: 2021-05-22 23:39:16 +0000 [ath] Handle STA + AP beacon programming without stomping over HW AP beacon programming I've been using STA+AP modes at home for a couple years now and I've been finding and fixing a lot of weird corner cases. This is the eventual patchset I've landed on. * Don't force beacon resync in STA mode if we're using sw beacon tracking. This stops a variety of stomping issues when the STA VAP is reconfigured; the AP hardware beacons were being stomped on! * Use the first AP VAP to configure beacons on, rather than the first VAP. This prevents weird behaviour in ath_beacon_config() when the hardware is being reconfigured and the STA VAP was the first one created. * Ensure the beacon interval / timing programming is within the AR9300 HAL bounds by masking off any flags that may have been there before shifting the value up to 1/8 TUs rather than the 1 TU resolution the previous chips used. Now I don't get weird beacon reprogramming during startup, STA state changes and hardware recovery which showed up as HI-LARIOUS beacon configurations and STAs that would just disconnect from the AP very frequently. Tested: * AR9344/AR9380, STA and AP and STA+AP modes --- sys/dev/ath/if_ath.c | 34 ++++++++++++++++++++------------ sys/dev/ath/if_ath_beacon.c | 48 +++++++++++++++++++++++++++++++++++---------- sys/dev/ath/if_ath_rx.c | 1 + 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 698b8d1a2853..4bc5c31812e7 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -2450,13 +2450,15 @@ ath_bmiss_vap(struct ieee80211vap *vap) ath_power_setpower(sc, HAL_PM_AWAKE, 0); ath_power_restore_power_state(sc); ATH_UNLOCK(sc); + DPRINTF(sc, ATH_DEBUG_BEACON, "%s: forced awake; force syncbeacon=1\n", __func__); - - /* - * Attempt to force a beacon resync. - */ - sc->sc_syncbeacon = 1; + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + /* + * Attempt to force a beacon resync. + */ + sc->sc_syncbeacon = 1; + } ATH_VAP(vap)->av_bmiss(vap); } @@ -6061,19 +6063,25 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) * In that case, we may not receive an actual * beacon to update the beacon timer and thus we * won't get notified of the missing beacons. + * + * Also, don't do any of this if we're not running + * with hardware beacon support, as that'll interfere + * with an AP VAP. */ if (ostate != IEEE80211_S_RUN && ostate != IEEE80211_S_SLEEP) { - DPRINTF(sc, ATH_DEBUG_BEACON, - "%s: STA; syncbeacon=1\n", __func__); - sc->sc_syncbeacon = 1; + + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + DPRINTF(sc, ATH_DEBUG_BEACON, + "%s: STA; syncbeacon=1\n", __func__); + sc->sc_syncbeacon = 1; + if (csa_run_transition) + ath_beacon_config(sc, vap); + } /* Quiet time handling - ensure we resync */ memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); - if (csa_run_transition) - ath_beacon_config(sc, vap); - /* * PR: kern/175227 * @@ -6086,7 +6094,9 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) * timer fires (too often), leading to a STA * disassociation. */ - sc->sc_beacons = 1; + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { + sc->sc_beacons = 1; + } } break; case IEEE80211_M_MONITOR: diff --git a/sys/dev/ath/if_ath_beacon.c b/sys/dev/ath/if_ath_beacon.c index ac1244c5f8e7..6da36a176319 100644 --- a/sys/dev/ath/if_ath_beacon.c +++ b/sys/dev/ath/if_ath_beacon.c @@ -448,9 +448,11 @@ ath_beacon_proc(void *arg, int pending) * many consecutive beacons reset the device. */ if (ath_hal_numtxpending(ah, sc->sc_bhalq) != 0) { + sc->sc_bmisscount++; sc->sc_stats.ast_be_missed++; ath_beacon_miss(sc); + DPRINTF(sc, ATH_DEBUG_BEACON, "%s: missed %u consecutive beacons\n", __func__, sc->sc_bmisscount); @@ -935,15 +937,33 @@ ath_beacon_config(struct ath_softc *sc, struct ieee80211vap *vap) u_int32_t nexttbtt_u8, intval_u8; u_int64_t tsf, tsf_beacon; - if (vap == NULL) - vap = TAILQ_FIRST(&ic->ic_vaps); /* XXX */ /* - * Just ensure that we aren't being called when the last - * VAP is destroyed. + * Find the first VAP that we /can/ use a beacon configuration for. + * If it's a STA VAP then if it has SWBMISS set we should ignore it. + * + * Yes, ideally we'd not have a STA without SWBMISS followed by an + * AP STA, and yes this isn't ready for P2P/TSF2 logic on AR9300 and + * later chips. */ if (vap == NULL) { - device_printf(sc->sc_dev, "%s: called with no VAPs\n", - __func__); + IEEE80211_LOCK(ic); + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { + /* A STA VAP w/ SWBMISS set can't be used for beaconing */ + if ((vap->iv_opmode == IEEE80211_M_STA) && + ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) != 0)) + continue; + break; + } + IEEE80211_UNLOCK(ic); + } + + if (vap == NULL) { + device_printf(sc->sc_dev, "called with no valid vaps?\n"); + return; + } + + if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) != 0) { + device_printf(sc->sc_dev, "called on VAP with SWBMISS set?\n"); return; } @@ -1004,8 +1024,7 @@ ath_beacon_config(struct ath_softc *sc, struct ieee80211vap *vap) else nexttbtt = roundup(nexttbtt, intval); - DPRINTF(sc, ATH_DEBUG_BEACON, "%s: nexttbtt %u intval %u (%u)\n", - __func__, nexttbtt, intval, ni->ni_intval); + if (ic->ic_opmode == IEEE80211_M_STA && !sc->sc_swbmiss) { HAL_BEACON_STATE bs; int dtimperiod, dtimcount; @@ -1196,8 +1215,8 @@ ath_beacon_config(struct ath_softc *sc, struct ieee80211vap *vap) * nexttbtt and intval is TU/8. */ if (sc->sc_isedma) { - nexttbtt_u8 = (nexttbtt << 3); - intval_u8 = (intval << 3); + nexttbtt_u8 = (nexttbtt << 3) & HAL_BEACON_PERIOD_TU8; + intval_u8 = (intval << 3) & HAL_BEACON_PERIOD_TU8; if (intval & HAL_BEACON_ENA) intval_u8 |= HAL_BEACON_ENA; if (intval & HAL_BEACON_RESET_TSF) @@ -1216,6 +1235,15 @@ ath_beacon_config(struct ath_softc *sc, struct ieee80211vap *vap) } ieee80211_free_node(ni); + tsf = ath_hal_gettsf64(ah); + DPRINTF(sc, ATH_DEBUG_BEACON, + "%s: nexttbtt %u intval %u (%u), tsf64=%llu tsfbeacon=%llu delta=%lld\n", + __func__, nexttbtt, intval, ni->ni_intval, + (unsigned long long) tsf, + (unsigned long long) tsf_beacon, + (long long) tsf - + (long long) tsf_beacon); + ATH_LOCK(sc); ath_power_restore_power_state(sc); ATH_UNLOCK(sc); diff --git a/sys/dev/ath/if_ath_rx.c b/sys/dev/ath/if_ath_rx.c index 58da21f09638..588194a942db 100644 --- a/sys/dev/ath/if_ath_rx.c +++ b/sys/dev/ath/if_ath_rx.c @@ -463,6 +463,7 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, sc->sc_syncbeacon && (!sc->sc_swbmiss) && ni == vap->iv_bss && + ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) && (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP)) { DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=1; syncing\n", From owner-dev-commits-src-main@freebsd.org Sun May 23 04:25:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D497363F404; Sun, 23 May 2021 04:25: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 4FnnLx5fytz3smJ; Sun, 23 May 2021 04:25: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 AB89211485; Sun, 23 May 2021 04:25: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 14N4PDvM006220; Sun, 23 May 2021 04:25:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14N4PDXw006219; Sun, 23 May 2021 04:25:13 GMT (envelope-from git) Date: Sun, 23 May 2021 04:25:13 GMT Message-Id: <202105230425.14N4PDXw006219@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: c50346bcf5c5 - main - ath: bump the default node queue size to 128 frames, not 64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c50346bcf5c5ccd0ef65d273edea6143f66c999f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 04:25:13 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=c50346bcf5c5ccd0ef65d273edea6143f66c999f commit c50346bcf5c5ccd0ef65d273edea6143f66c999f Author: Adrian Chadd AuthorDate: 2021-05-23 04:23:00 +0000 Commit: Adrian Chadd CommitDate: 2021-05-23 04:23:00 +0000 ath: bump the default node queue size to 128 frames, not 64 It turns out that, silly adrian, setting it to 64 means only two AMPDU frames of 32 subframes each. Thus, whilst those are in-flight, any subsequent queues frames to that node get dropped. This ends up being pretty no bueno for performance if any receive is also going on at that point. Instead, set it to 128 for the time being to ensure that SOME frames get queued in the meantime. This results in some frames being immediately available in the software queue for transmit when the two existing A-MPDU frames have been completely sent, rather than the queue remaining empty until at least one is sent. It's not the best solution - I still think I'm scheduling receive far more often than giving time to schedule transmit work - but at least now I'm not starving the transmit side. Before this, a bidirectional iperf would show receive at ~ 150mbit/sec. but the transmit side at like 10kbit/sec. With it set to 128 it's now 150mbit/sec receive, and ~ 10mbit receive. It's better than 10kbit/sec, but still not as far as I'd like it to be. Tested: * AR9380/QCA934x (TL-WDR4300 AP), Macbook pro test STA + AR9380 test STA --- sys/dev/ath/if_ath.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 4bc5c31812e7..3675cfc78654 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -1083,9 +1083,16 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) /* * Default the maximum queue to 1/4'th the TX buffers, or - * 64, whichever is smaller. - */ - sc->sc_txq_node_maxdepth = MIN(64, ath_txbuf / 4); + * 128, whichever is smaller. + * + * Set it to 128 instead of the previous default (64) because + * at 64, two full A-MPDU subframes of 32 frames each is + * enough to treat this node queue as full and all subsequent + * traffic is dropped. Setting it to 128 means there'll + * hopefully be another 64 frames in the software queue + * to begin making A-MPDU frames out of. + */ + sc->sc_txq_node_maxdepth = MIN(128, ath_txbuf / 4); /* Enable CABQ by default */ sc->sc_cabq_enable = 1; From owner-dev-commits-src-main@freebsd.org Sun May 23 08:55:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 92C4E6433DC; Sun, 23 May 2021 08:55: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 4FnvMH3kDcz4g5s; Sun, 23 May 2021 08:55: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 67CE914ADA; Sun, 23 May 2021 08:55: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 14N8tte1063435; Sun, 23 May 2021 08:55:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14N8ttJM063434; Sun, 23 May 2021 08:55:55 GMT (envelope-from git) Date: Sun, 23 May 2021 08:55:55 GMT Message-Id: <202105230855.14N8ttJM063434@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: ef0f7ae934b0 - main - The old thread priority must be stored as part of the EPOCH(9) tracker. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ef0f7ae934b04a4f90e051d701ba539dd04e7d5b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 08:55:55 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=ef0f7ae934b04a4f90e051d701ba539dd04e7d5b commit ef0f7ae934b04a4f90e051d701ba539dd04e7d5b Author: Hans Petter Selasky AuthorDate: 2021-05-21 08:27:20 +0000 Commit: Hans Petter Selasky CommitDate: 2021-05-23 08:53:25 +0000 The old thread priority must be stored as part of the EPOCH(9) tracker. Else recursive use of EPOCH(9) may cause the wrong priority to be restored. Bump the __FreeBSD_version due to changing the thread and epoch tracker structure. Differential Revision: https://reviews.freebsd.org/D30375 Reviewed by: markj@ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/kern/subr_epoch.c | 6 +++--- sys/sys/epoch.h | 1 + sys/sys/param.h | 2 +- sys/sys/proc.h | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c index 798dbdc4360e..651fd8b419f0 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -457,7 +457,7 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et EPOCH_FILE_LINE) THREAD_NO_SLEEPING(); critical_enter(); sched_pin(); - td->td_pre_epoch_prio = td->td_priority; + et->et_old_priority = td->td_priority; er = epoch_currecord(epoch); /* Record-level tracking is reserved for non-preemptible epochs. */ MPASS(er->er_td == NULL); @@ -510,8 +510,8 @@ _epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et EPOCH_FILE_LINE) ck_epoch_end(&er->er_record, &et->et_section); TAILQ_REMOVE(&er->er_tdlist, et, et_link); er->er_gen++; - if (__predict_false(td->td_pre_epoch_prio != td->td_priority)) - epoch_adjust_prio(td, td->td_pre_epoch_prio); + if (__predict_false(et->et_old_priority != td->td_priority)) + epoch_adjust_prio(td, et->et_old_priority); critical_exit(); #ifdef EPOCH_TRACE epoch_trace_exit(td, epoch, et, file, line); diff --git a/sys/sys/epoch.h b/sys/sys/epoch.h index 25d2bb3dc6e3..85c791d3df6c 100644 --- a/sys/sys/epoch.h +++ b/sys/sys/epoch.h @@ -55,6 +55,7 @@ struct epoch_tracker { TAILQ_ENTRY(epoch_tracker) et_link; struct thread *et_td; ck_epoch_section_t et_section; + uint8_t et_old_priority; #ifdef EPOCH_TRACE struct epoch *et_epoch; SLIST_ENTRY(epoch_tracker) et_tlink; diff --git a/sys/sys/param.h b/sys/sys/param.h index 68808f3e2185..81971777e87b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400013 +#define __FreeBSD_version 1400014 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 926f0de14b84..8098bb9468ec 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -325,7 +325,6 @@ struct thread { u_char td_pri_class; /* (t) Scheduling class. */ u_char td_user_pri; /* (t) User pri from estcpu and nice. */ u_char td_base_user_pri; /* (t) Base user pri */ - u_char td_pre_epoch_prio; /* (k) User pri on entry to epoch */ uintptr_t td_rb_list; /* (k) Robust list head. */ uintptr_t td_rbp_list; /* (k) Robust priv list head. */ uintptr_t td_rb_inact; /* (k) Current in-action mutex loc. */ From owner-dev-commits-src-main@freebsd.org Sun May 23 12:46:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23F2F6476A5; Sun, 23 May 2021 12:46: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 4Fp0T80XWSz3kVJ; Sun, 23 May 2021 12:46: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 EEB4317B4A; Sun, 23 May 2021 12:46: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 14NCkJvU070197; Sun, 23 May 2021 12:46:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NCkJ2Q070196; Sun, 23 May 2021 12:46:19 GMT (envelope-from git) Date: Sun, 23 May 2021 12:46:19 GMT Message-Id: <202105231246.14NCkJ2Q070196@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: ccac04cae538 - main - test/libalias: Fix build errors on various platforms MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ccac04cae538a625cbce224e4005360fa85e1b9d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 12:46:20 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=ccac04cae538a625cbce224e4005360fa85e1b9d commit ccac04cae538a625cbce224e4005360fa85e1b9d Author: Lutz Donnerhacke AuthorDate: 2021-05-23 12:43:00 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-23 12:43:00 +0000 test/libalias: Fix build errors on various platforms struct timeval has an unspecified integral type, which needs to be canonfied before beeing usable by printf(3). --- tests/sys/netinet/libalias/perf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/sys/netinet/libalias/perf.c b/tests/sys/netinet/libalias/perf.c index ac4796cf9649..fadbb439774a 100644 --- a/tests/sys/netinet/libalias/perf.c +++ b/tests/sys/netinet/libalias/perf.c @@ -15,7 +15,7 @@ static struct in_addr ext = { htonl(0x12000000) }; ? ((tv).tv_usec cmp (uv).tv_usec) \ : ((tv).tv_sec cmp (uv).tv_sec)) -#define timevaldiff(n, o) \ +#define timevaldiff(n, o) (float) \ (((n).tv_sec - (o).tv_sec)*1000000l + \ ((n).tv_usec - (o).tv_usec)) @@ -69,7 +69,7 @@ int main(int argc, char ** argv) gettimeofday(&timeout, NULL); timeout.tv_sec += max_seconds; - printf("RND SEC NAT RND ATT UNA\n"); + printf("RND SECND NAT RND ATT UNA\n"); for (round = 0; ; round++) { int i, res; struct timeval now, start; @@ -77,7 +77,7 @@ int main(int argc, char ** argv) printf("%3d ", round+1); gettimeofday(&start, NULL); - printf("%3ld ", max_seconds - (timeout.tv_sec - start.tv_sec)); + printf("%5.1f ", max_seconds - timevaldiff(timeout, start)/1000000.0f); for (cnt = i = 0; i < batch_size; i++, cnt++) { batch[i].src.s_addr = prv.s_addr | htonl(rand_range(0, 0xffff)); batch[i].dst.s_addr = ext.s_addr | htonl(rand_range(0, 0xffff)); @@ -104,7 +104,7 @@ int main(int argc, char ** argv) goto out; } if (cnt > 0) - printf("%3lu ", timevaldiff(now, start) / cnt); + printf("%3.0f ", timevaldiff(now, start) / cnt); start = now; for (cnt = i = 0; i < random_size; i++, cnt++) { @@ -125,7 +125,7 @@ int main(int argc, char ** argv) goto out; } if (cnt > 0) - printf("%3lu ", timevaldiff(now, start) / cnt); + printf("%3.0f ", timevaldiff(now, start) / cnt); start = now; p->ip_src.s_addr = ext.s_addr & htonl(0xfff00000); @@ -145,7 +145,7 @@ int main(int argc, char ** argv) goto out; } if (cnt > 0) - printf("%3lu ", timevaldiff(now, start) / cnt); + printf("%3.0f ", timevaldiff(now, start) / cnt); qsort(batch, batch_size, sizeof(*batch), randcmp); @@ -172,7 +172,7 @@ int main(int argc, char ** argv) goto out; } if (cnt > 0) - printf("%3lu\n", timevaldiff(now, start) / cnt); + printf("%3.0f\n", timevaldiff(now, start) / cnt); } out: printf("\n\n"); From owner-dev-commits-src-main@freebsd.org Sun May 23 15:34:47 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3164264A019; Sun, 23 May 2021 15:34: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 4Fp4CW0ghrz4fy1; Sun, 23 May 2021 15:34: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 0057019CAA; Sun, 23 May 2021 15:34: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 14NFYktT098079; Sun, 23 May 2021 15:34:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NFYkOp098078; Sun, 23 May 2021 15:34:46 GMT (envelope-from git) Date: Sun, 23 May 2021 15:34:46 GMT Message-Id: <202105231534.14NFYkOp098078@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 43f5d5bf01fd - main - run(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43f5d5bf01fdf821e8037272c636a9be18323e00 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 15:34:47 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=43f5d5bf01fdf821e8037272c636a9be18323e00 commit 43f5d5bf01fdf821e8037272c636a9be18323e00 Author: Dmitry Chagin AuthorDate: 2021-05-23 13:35:31 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-23 13:35:31 +0000 run(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69. PR: 255759 MFC After: 2 weeks --- share/man/man4/run.4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/man/man4/run.4 b/share/man/man4/run.4 index b95a346f9697..ad314ff67011 100644 --- a/share/man/man4/run.4 +++ b/share/man/man4/run.4 @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 16, 2020 +.Dd May 23, 2021 .Dt RUN 4 .Os .Sh NAME @@ -125,6 +125,7 @@ driver supports the following wireless adapters: .It Airlink101 AWLL6090 .It ASUS USB-N11 .It ASUS USB-N13 ver. A1 +.It ASUS USB-N14 .It ASUS USB-N66 .It ASUS WL-160N .It Belkin F5D8051 ver 3000 From owner-dev-commits-src-main@freebsd.org Sun May 23 15:43:04 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5EE4B64A3F0; Sun, 23 May 2021 15:43: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 4Fp4P42BPQz4jqG; Sun, 23 May 2021 15:43: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 3214419D50; Sun, 23 May 2021 15:43: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 14NFh4UV011079; Sun, 23 May 2021 15:43:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NFh4Ek011078; Sun, 23 May 2021 15:43:04 GMT (envelope-from git) Date: Sun, 23 May 2021 15:43:04 GMT Message-Id: <202105231543.14NFh4Ek011078@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: b595729ccfde - main - rsu(4): add ASUS WL-167G V3 to the list of supported devices. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b595729ccfde8e5d5bac0acf9690de9d437a1afd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 15:43:04 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b595729ccfde8e5d5bac0acf9690de9d437a1afd commit b595729ccfde8e5d5bac0acf9690de9d437a1afd Author: Dmitry Chagin AuthorDate: 2021-05-23 15:42:29 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-23 15:42:29 +0000 rsu(4): add ASUS WL-167G V3 to the list of supported devices. MFC After: 2 weeks --- share/man/man4/rsu.4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/man/man4/rsu.4 b/share/man/man4/rsu.4 index 8e875400bc0b..1d38c4a1618d 100644 --- a/share/man/man4/rsu.4 +++ b/share/man/man4/rsu.4 @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd April 4, 2018 +.Dd May 23, 2021 .Dt RSU 4 .Os .Sh NAME @@ -115,6 +115,7 @@ wireless network adapters, including: .Pp .Bl -tag -width Ds -offset indent -compact .It ASUS USB-N10 +.It ASUS WL-167G V3 .It Belkin F7D1101 v1 .It D-Link DWA-131 A1 .It EDUP EP-MS150N(W) From owner-dev-commits-src-main@freebsd.org Sun May 23 17:47:16 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F6E464C25E; Sun, 23 May 2021 17:47: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 4Fp78N0h3gz4gjm; Sun, 23 May 2021 17:47: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 EF94A1B246; Sun, 23 May 2021 17:47: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 14NHlFEg069844; Sun, 23 May 2021 17:47:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NHlFSB069843; Sun, 23 May 2021 17:47:15 GMT (envelope-from git) Date: Sun, 23 May 2021 17:47:15 GMT Message-Id: <202105231747.14NHlFSB069843@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: eaf00819bcfa - main - Add support for Gemini Lake LPSS UARTs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eaf00819bcfa90ab7ac8af324826eb985197d8c8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 17:47:16 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=eaf00819bcfa90ab7ac8af324826eb985197d8c8 commit eaf00819bcfa90ab7ac8af324826eb985197d8c8 Author: Konstantin Belousov AuthorDate: 2021-05-23 16:38:54 +0000 Commit: Konstantin Belousov CommitDate: 2021-05-23 17:46:32 +0000 Add support for Gemini Lake LPSS UARTs. With this patch: % dmesg | grep -i uart uart2: mem 0xa1426000-0xa1426fff,0xa1425000-0xa1425fff irq 4 at device 24.0 on pci0 uart3: mem 0xa1424000-0xa1424fff,0xa1423000-0xa1423fff irq 5 at device 24.1 on pci0 uart4: mem 0xfea10000-0xfea10fff irq 6 at device 24.2 on pci0 uart5: mem 0xa1422000-0xa1422fff,0xa1421000-0xa1421fff irq 7 at device 24.3 on pci0 PR: 256101 Submitted by: Daniel Ponte MFC after: 1 week --- sys/dev/uart/uart_bus_pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/uart/uart_bus_pci.c b/sys/dev/uart/uart_bus_pci.c index 707b82dc078b..f7e9bd6ac401 100644 --- a/sys/dev/uart/uart_bus_pci.c +++ b/sys/dev/uart/uart_bus_pci.c @@ -145,6 +145,14 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x8086, 0x2a07, 0xffff, 0, "Intel AMT - PM965/GM965 KT Controller", 0x10 }, { 0x8086, 0x2a47, 0xffff, 0, "Mobile 4 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 }, +{ 0x8086, 0x31bc, 0xffff, 0, "Intel Gemini Lake SIO/LPSS UART 0", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x31be, 0xffff, 0, "Intel Gemini Lake SIO/LPSS UART 1", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x31c0, 0xffff, 0, "Intel Gemini Lake SIO/LPSS UART 2", 0x10, + 24 * DEFAULT_RCLK, 2 }, +{ 0x8086, 0x31ee, 0xffff, 0, "Intel Gemini Lake SIO/LPSS UART 3", 0x10, + 24 * DEFAULT_RCLK, 2 }, { 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller", 0x10 }, { 0x8086, 0x5abc, 0xffff, 0, "Intel Apollo Lake SIO/LPSS UART 0", 0x10, From owner-dev-commits-src-main@freebsd.org Sun May 23 17:56:45 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 65D7E64C693; Sun, 23 May 2021 17:56: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 4Fp7MK2RvHz4lWP; Sun, 23 May 2021 17:56: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 36AA01BB12; Sun, 23 May 2021 17:56: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 14NHujl7083405; Sun, 23 May 2021 17:56:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NHujEa083404; Sun, 23 May 2021 17:56:45 GMT (envelope-from git) Date: Sun, 23 May 2021 17:56:45 GMT Message-Id: <202105231756.14NHujEa083404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 6a467cc5e1f6 - main - lockprof: pass lock type as an argument instead of reading the spin flag MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6a467cc5e1f673a700f6229e63e9a98ed65264c8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 17:56:45 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=6a467cc5e1f673a700f6229e63e9a98ed65264c8 commit 6a467cc5e1f673a700f6229e63e9a98ed65264c8 Author: Mateusz Guzik AuthorDate: 2021-05-23 15:25:42 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-23 17:55:27 +0000 lockprof: pass lock type as an argument instead of reading the spin flag --- sys/kern/kern_lock.c | 10 +++++----- sys/kern/kern_mutex.c | 20 +++++++++++--------- sys/kern/kern_rwlock.c | 8 ++++---- sys/kern/kern_sx.c | 8 ++++---- sys/kern/sched_4bsd.c | 8 ++++---- sys/kern/subr_lock.c | 30 +++++++++++++++++++++++------- sys/sys/lock_profile.h | 16 ++++++++-------- sys/sys/lockstat.h | 28 ++++++++++++++++++++++------ sys/sys/mutex.h | 6 +++--- 9 files changed, 84 insertions(+), 50 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 5cefcf7a597b..bec49f29d162 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -639,7 +639,7 @@ lockmgr_slock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&lk->lock_object, + lock_profile_obtain_lock_failed(&lk->lock_object, false, &contested, &waittime); /* @@ -852,7 +852,7 @@ lockmgr_xlock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&lk->lock_object, + lock_profile_obtain_lock_failed(&lk->lock_object, false, &contested, &waittime); /* @@ -1442,7 +1442,7 @@ __lockmgr_args(struct lock *lk, u_int flags, struct lock_object *ilk, #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&lk->lock_object, + lock_profile_obtain_lock_failed(&lk->lock_object, false, &contested, &waittime); /* @@ -1589,7 +1589,7 @@ __lockmgr_args(struct lock *lk, u_int flags, struct lock_object *ilk, if (error == 0) { lock_profile_obtain_lock_success(&lk->lock_object, - contested, waittime, file, line); + false, contested, waittime, file, line); LOCK_LOG_LOCK("DRAIN", &lk->lock_object, 0, lk->lk_recurse, file, line); WITNESS_LOCK(&lk->lock_object, LOP_EXCLUSIVE | @@ -1635,7 +1635,7 @@ _lockmgr_disown(struct lock *lk, const char *file, int line) */ if (LK_HOLDER(lk->lk_lock) != tid) return; - lock_profile_release_lock(&lk->lock_object); + lock_profile_release_lock(&lk->lock_object, false); LOCKSTAT_RECORD1(lockmgr__disown, lk, LOCKSTAT_WRITER); LOCK_LOG_LOCK("XDISOWN", &lk->lock_object, 0, 0, file, line); WITNESS_UNLOCK(&lk->lock_object, LOP_EXCLUSIVE, file, line); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 0c384281f711..d9db69e2ac09 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -344,7 +344,7 @@ __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, if (!_mtx_obtain_lock_fetch(m, &v, tid)) _mtx_lock_spin(m, v, opts, file, line); else - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, + LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(spin__acquire, m, 0, 0, file, line); #else __mtx_lock_spin(m, curthread, opts, file, line); @@ -565,7 +565,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v) #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&m->lock_object, + lock_profile_obtain_lock_failed(&m->lock_object, false, &contested, &waittime); if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR4(KTR_LOCK, @@ -756,7 +756,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v) #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); + lock_profile_obtain_lock_failed(&m->lock_object, true, &contested, &waittime); for (;;) { if (v == MTX_UNOWNED) { @@ -792,7 +792,7 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v) LOCKSTAT_RECORD1(spin__spin, m, spin_time); out_lockstat: #endif - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, m, + LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(spin__acquire, m, contested, waittime, file, line); } #endif /* SMP */ @@ -912,7 +912,7 @@ retry: continue; } MPASS(v != tid); - lock_profile_obtain_lock_failed(&m->lock_object, + lock_profile_obtain_lock_failed(&m->lock_object, true, &contested, &waittime); /* Give interrupts a chance while we spin. */ spinlock_exit(); @@ -945,7 +945,7 @@ retry: #ifdef KDTRACE_HOOKS spin_time += lockstat_nsecs(&m->lock_object); #endif - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, m, contested, + LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(spin__acquire, m, contested, waittime, file, line); #ifdef KDTRACE_HOOKS if (lda.spin_cnt != 0) @@ -1183,12 +1183,14 @@ _mtx_destroy(volatile uintptr_t *c) MPASS((m->mtx_lock & (MTX_RECURSED|MTX_CONTESTED)) == 0); /* Perform the non-mtx related part of mtx_unlock_spin(). */ - if (LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin) + if (LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin) { + lock_profile_release_lock(&m->lock_object, true); spinlock_exit(); - else + } else { TD_LOCKS_DEC(curthread); + lock_profile_release_lock(&m->lock_object, false); + } - lock_profile_release_lock(&m->lock_object); /* Tell witness this isn't locked to make it happy. */ WITNESS_UNLOCK(&m->lock_object, LOP_EXCLUSIVE, __FILE__, __LINE__); diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index cf1af0ee7af9..f1c18f952f24 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -481,7 +481,7 @@ __rw_rlock_hard(struct rwlock *rw, struct thread *td, uintptr_t v #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&rw->lock_object, + lock_profile_obtain_lock_failed(&rw->lock_object, false, &contested, &waittime); for (;;) { @@ -681,7 +681,7 @@ __rw_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) !__rw_rlock_try(rw, td, &v, true LOCK_FILE_LINE_ARG))) __rw_rlock_hard(rw, td, v LOCK_FILE_LINE_ARG); else - lock_profile_obtain_lock_success(&rw->lock_object, 0, 0, + lock_profile_obtain_lock_success(&rw->lock_object, false, 0, 0, file, line); LOCK_LOG_LOCK("RLOCK", &rw->lock_object, 0, 0, file, line); @@ -856,7 +856,7 @@ _rw_runlock_cookie_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF) !__rw_runlock_try(rw, td, &v))) __rw_runlock_hard(rw, td, v LOCK_FILE_LINE_ARG); else - lock_profile_release_lock(&rw->lock_object); + lock_profile_release_lock(&rw->lock_object, false); TD_LOCKS_DEC(curthread); } @@ -975,7 +975,7 @@ __rw_wlock_hard(volatile uintptr_t *c, uintptr_t v LOCK_FILE_LINE_ARG_DEF) #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&rw->lock_object, + lock_profile_obtain_lock_failed(&rw->lock_object, false, &contested, &waittime); for (;;) { diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 3296bf50a290..ad1c1a0e8813 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -648,7 +648,7 @@ _sx_xlock_hard(struct sx *sx, uintptr_t x, int opts LOCK_FILE_LINE_ARG_DEF) #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&sx->lock_object, &contested, + lock_profile_obtain_lock_failed(&sx->lock_object, false, &contested, &waittime); #ifndef INVARIANTS @@ -1069,7 +1069,7 @@ _sx_slock_hard(struct sx *sx, int opts, uintptr_t x LOCK_FILE_LINE_ARG_DEF) #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&sx->lock_object, &contested, + lock_profile_obtain_lock_failed(&sx->lock_object, false, &contested, &waittime); #ifndef INVARIANTS @@ -1272,7 +1272,7 @@ _sx_slock_int(struct sx *sx, int opts LOCK_FILE_LINE_ARG_DEF) !__sx_slock_try(sx, td, &x, true LOCK_FILE_LINE_ARG))) error = _sx_slock_hard(sx, opts, x LOCK_FILE_LINE_ARG); else - lock_profile_obtain_lock_success(&sx->lock_object, 0, 0, + lock_profile_obtain_lock_success(&sx->lock_object, false, 0, 0, file, line); if (error == 0) { LOCK_LOG_LOCK("SLOCK", &sx->lock_object, 0, 0, file, line); @@ -1379,7 +1379,7 @@ _sx_sunlock_int(struct sx *sx LOCK_FILE_LINE_ARG_DEF) !_sx_sunlock_try(sx, td, &x))) _sx_sunlock_hard(sx, td, x LOCK_FILE_LINE_ARG); else - lock_profile_release_lock(&sx->lock_object); + lock_profile_release_lock(&sx->lock_object, false); TD_LOCKS_DEC(curthread); } diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 7ce9bd81704f..7e6123cdcf24 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1053,7 +1053,7 @@ sched_switch(struct thread *td, int flags) SDT_PROBE2(sched, , , off__cpu, newtd, newtd->td_proc); /* I feel sleepy */ - lock_profile_release_lock(&sched_lock.lock_object); + lock_profile_release_lock(&sched_lock.lock_object, true); #ifdef KDTRACE_HOOKS /* * If DTrace has set the active vtime enum to anything @@ -1065,7 +1065,7 @@ sched_switch(struct thread *td, int flags) #endif cpu_switch(td, newtd, tmtx); - lock_profile_obtain_lock_success(&sched_lock.lock_object, + lock_profile_obtain_lock_success(&sched_lock.lock_object, true, 0, 0, __FILE__, __LINE__); /* * Where am I? What year is it? @@ -1676,7 +1676,7 @@ sched_throw(struct thread *td) PCPU_SET(switchtime, cpu_ticks()); PCPU_SET(switchticks, ticks); } else { - lock_profile_release_lock(&sched_lock.lock_object); + lock_profile_release_lock(&sched_lock.lock_object, true); MPASS(td->td_lock == &sched_lock); td->td_lastcpu = td->td_oncpu; td->td_oncpu = NOCPU; @@ -1696,7 +1696,7 @@ sched_fork_exit(struct thread *td) */ td->td_oncpu = PCPU_GET(cpuid); sched_lock.mtx_lock = (uintptr_t)td; - lock_profile_obtain_lock_success(&sched_lock.lock_object, + lock_profile_obtain_lock_success(&sched_lock.lock_object, true, 0, 0, __FILE__, __LINE__); THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c index 9c433f683bac..ca2c6ad32f00 100644 --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -58,6 +58,12 @@ __FBSDID("$FreeBSD$"); #include +/* + * Uncomment to validate that spin argument to acquire/release routines matches + * the flag in the lock + */ +//#define LOCK_PROFILING_DEBUG_SPIN + SDT_PROVIDER_DEFINE(lock); SDT_PROBE_DEFINE1(lock, , , starvation, "u_int"); @@ -594,11 +600,17 @@ lock_profile_object_lookup(struct lock_object *lo, int spin, const char *file, } void -lock_profile_obtain_lock_success(struct lock_object *lo, int contested, - uint64_t waittime, const char *file, int line) +lock_profile_obtain_lock_success(struct lock_object *lo, bool spin, + int contested, uint64_t waittime, const char *file, int line) { struct lock_profile_object *l; - int spin; + +#ifdef LOCK_PROFILING_DEBUG_SPIN + bool is_spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK); + if ((spin && !is_spin) || (!spin && is_spin)) + printf("%s: lock %s spin mismatch (arg %d, flag %d)\n", __func__, + lo->lo_name, spin, is_spin); +#endif if (SCHEDULER_STOPPED()) return; @@ -608,7 +620,6 @@ lock_profile_obtain_lock_success(struct lock_object *lo, int contested, return; if (lock_contested_only && !contested) return; - spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK) ? 1 : 0; if (spin && lock_prof_skipspin == 1) return; critical_enter(); @@ -661,20 +672,25 @@ lock_profile_thread_exit(struct thread *td) } void -lock_profile_release_lock(struct lock_object *lo) +lock_profile_release_lock(struct lock_object *lo, bool spin) { struct lock_profile_object *l; struct lock_prof_type *type; struct lock_prof *lp; uint64_t curtime, holdtime; struct lpohead *head; - int spin; + +#ifdef LOCK_PROFILING_DEBUG_SPIN + bool is_spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK); + if ((spin && !is_spin) || (!spin && is_spin)) + printf("%s: lock %s spin mismatch (arg %d, flag %d)\n", __func__, + lo->lo_name, spin, is_spin); +#endif if (SCHEDULER_STOPPED()) return; if (lo->lo_flags & LO_NOPROFILE) return; - spin = (LOCK_CLASS(lo)->lc_flags & LC_SPINLOCK) ? 1 : 0; head = &curthread->td_lprof[spin]; if (LIST_FIRST(head) == NULL) return; diff --git a/sys/sys/lock_profile.h b/sys/sys/lock_profile.h index 2ace6ef56983..de1a95779254 100644 --- a/sys/sys/lock_profile.h +++ b/sys/sys/lock_profile.h @@ -46,14 +46,14 @@ u_int64_t nanoseconds(void); extern volatile int lock_prof_enable; -void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, - uint64_t waittime, const char *file, int line); -void lock_profile_release_lock(struct lock_object *lo); +void lock_profile_obtain_lock_success(struct lock_object *lo, bool spin, + int contested, uint64_t waittime, const char *file, int line); +void lock_profile_release_lock(struct lock_object *lo, bool spin); void lock_profile_thread_exit(struct thread *td); static inline void -lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, - uint64_t *waittime) +lock_profile_obtain_lock_failed(struct lock_object *lo, bool spin, + int *contested, uint64_t *waittime) { if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE) || *contested) return; @@ -63,9 +63,9 @@ lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, #else /* !LOCK_PROFILING */ -#define lock_profile_release_lock(lo) (void)0 -#define lock_profile_obtain_lock_failed(lo, contested, waittime) (void)0 -#define lock_profile_obtain_lock_success(lo, contested, waittime, file, line) (void)0 +#define lock_profile_release_lock(lo, spin) (void)0 +#define lock_profile_obtain_lock_failed(lo, spin, contested, waittime) (void)0 +#define lock_profile_obtain_lock_success(lo, spin, contested, waittime, file, line) (void)0 #define lock_profile_thread_exit(td) (void)0 #endif /* !LOCK_PROFILING */ diff --git a/sys/sys/lockstat.h b/sys/sys/lockstat.h index 6a5f79a2f152..76bd97dbafa5 100644 --- a/sys/sys/lockstat.h +++ b/sys/sys/lockstat.h @@ -97,22 +97,32 @@ extern volatile bool lockstat_enabled; SDT_PROBE5(lockstat, , , probe, lp, arg1, arg2, arg3, arg4) #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ - lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ + lock_profile_obtain_lock_success(&(lp)->lock_object, false, c, wt, f, l); \ + LOCKSTAT_RECORD0(probe, lp); \ +} while (0) + +#define LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ + lock_profile_obtain_lock_success(&(lp)->lock_object, true, c, wt, f, l); \ LOCKSTAT_RECORD0(probe, lp); \ } while (0) #define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) do { \ - lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ + lock_profile_obtain_lock_success(&(lp)->lock_object, false, c, wt, f, l); \ LOCKSTAT_RECORD1(probe, lp, a); \ } while (0) #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \ - lock_profile_release_lock(&(lp)->lock_object); \ + lock_profile_release_lock(&(lp)->lock_object, false); \ + LOCKSTAT_RECORD0(probe, lp); \ +} while (0) + +#define LOCKSTAT_PROFILE_RELEASE_SPIN_LOCK(probe, lp) do { \ + lock_profile_release_lock(&(lp)->lock_object, true); \ LOCKSTAT_RECORD0(probe, lp); \ } while (0) #define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) do { \ - lock_profile_release_lock(&(lp)->lock_object); \ + lock_profile_release_lock(&(lp)->lock_object, false); \ LOCKSTAT_RECORD1(probe, lp, a); \ } while (0) @@ -130,13 +140,19 @@ uint64_t lockstat_nsecs(struct lock_object *); #define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \ - lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l) + lock_profile_obtain_lock_success(&(lp)->lock_object, false, c, wt, f, l) + +#define LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \ + lock_profile_obtain_lock_success(&(lp)->lock_object, true, c, wt, f, l) #define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) \ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \ - lock_profile_release_lock(&(lp)->lock_object) + lock_profile_release_lock(&(lp)->lock_object, false) + +#define LOCKSTAT_PROFILE_RELEASE_SPIN_LOCK(probe, lp) \ + lock_profile_release_lock(&(lp)->lock_object, true) #define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) \ LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 35257ce97038..f35cdd7413a6 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -270,7 +270,7 @@ void _thread_lock(struct thread *); spinlock_exit(); \ _ret = 0; \ } else { \ - LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \ + LOCKSTAT_PROFILE_OBTAIN_SPIN_LOCK_SUCCESS(spin__acquire, \ mp, 0, 0, file, line); \ _ret = 1; \ } \ @@ -328,7 +328,7 @@ void _thread_lock(struct thread *); if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ - LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \ + LOCKSTAT_PROFILE_RELEASE_SPIN_LOCK(spin__release, mp); \ _mtx_release_lock_quick((mp)); \ } \ spinlock_exit(); \ @@ -338,7 +338,7 @@ void _thread_lock(struct thread *); if (mtx_recursed((mp))) \ (mp)->mtx_recurse--; \ else { \ - LOCKSTAT_PROFILE_RELEASE_LOCK(spin__release, mp); \ + LOCKSTAT_PROFILE_RELEASE_SPIN_LOCK(spin__release, mp); \ (mp)->mtx_lock = MTX_UNOWNED; \ } \ spinlock_exit(); \ From owner-dev-commits-src-main@freebsd.org Sun May 23 17:56:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B805664C5C3; Sun, 23 May 2021 17:56: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 4Fp7ML388Pz4lk9; Sun, 23 May 2021 17:56: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 51EC01B937; Sun, 23 May 2021 17:56: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 14NHukkg083426; Sun, 23 May 2021 17:56:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NHukce083425; Sun, 23 May 2021 17:56:46 GMT (envelope-from git) Date: Sun, 23 May 2021 17:56:46 GMT Message-Id: <202105231756.14NHukce083425@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: e2ab16b1a6c0 - main - lockprof: move panic check after inspecting the state MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2ab16b1a6c0f556299df21be54f04652ba7169d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 17:56:47 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e2ab16b1a6c0f556299df21be54f04652ba7169d commit e2ab16b1a6c0f556299df21be54f04652ba7169d Author: Mateusz Guzik AuthorDate: 2021-05-23 16:04:31 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-23 17:55:27 +0000 lockprof: move panic check after inspecting the state --- sys/kern/subr_lock.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c index ca2c6ad32f00..9bea021baac4 100644 --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -612,9 +612,6 @@ lock_profile_obtain_lock_success(struct lock_object *lo, bool spin, lo->lo_name, spin, is_spin); #endif - if (SCHEDULER_STOPPED()) - return; - /* don't reset the timer when/if recursing */ if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE)) return; @@ -622,6 +619,10 @@ lock_profile_obtain_lock_success(struct lock_object *lo, bool spin, return; if (spin && lock_prof_skipspin == 1) return; + + if (SCHEDULER_STOPPED()) + return; + critical_enter(); /* Recheck enabled now that we're in a critical section. */ if (lock_prof_enable == 0) @@ -687,13 +688,13 @@ lock_profile_release_lock(struct lock_object *lo, bool spin) lo->lo_name, spin, is_spin); #endif - if (SCHEDULER_STOPPED()) - return; if (lo->lo_flags & LO_NOPROFILE) return; head = &curthread->td_lprof[spin]; if (LIST_FIRST(head) == NULL) return; + if (SCHEDULER_STOPPED()) + return; critical_enter(); /* Recheck enabled now that we're in a critical section. */ if (lock_prof_enable == 0 && lock_prof_resetting == 1) From owner-dev-commits-src-main@freebsd.org Sun May 23 18:02:13 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C8B6764C92D; Sun, 23 May 2021 18:02:13 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fp7Tc6V1Cz4pPm; Sun, 23 May 2021 18:02:12 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x134.google.com with SMTP id b26so21217251lfq.4; Sun, 23 May 2021 11:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=i4nInJsvvtzIScoKLHgOqm9N6qfDyNOnP7kEzDfoZeU=; b=UkYXrpeTKUUN1vhOmtQCxIN0RHGEa1Osydn63otPHC9Qx6Obqa2ri3Aq2um3NMxPET 6dcvN69UTSk4fhnF74Y4t6gUMDgmv56Ey4XTG7/fcx2wlZ4D7OcKt9QyNg6b4bkHHqiL svUGS+oRcjngPOE6LQuIkE2AwzqPy7lddL+jRfXV/b3W1z6d6e6bsv/nyThB1782YGIQ F0e7ADtgBTMjRSShFQARsCpaMDJJHgxj0D/wyL0AIqSUc6Dd0vJW0lHGVY0n7V+HSP8p RFaimbR/nlbmdnNL47DZFybpn5iU1keQ4uaqqJawb4aB5lUP/izeEIEuIfX0ZY6JyE56 MuXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=i4nInJsvvtzIScoKLHgOqm9N6qfDyNOnP7kEzDfoZeU=; b=Lk6C6ZoxC2TBUulljmT2WA4xWNwGAy8Fbr8CuynoXhpCIIfnpac93GNXvJH9S7mcnl M/ZGhr6MFJ/gFxCc3kODTL/MrHKHnIKIh9CG3nTVf4AtuOzuPu5Zhd5ga7sDKKRyfE/r cZwho1vtaSJ9wgcivmGzaaAKCBMlCc2UPSqcYDD1yDgYXn/gIE5gZVv0to1IPhAflB7l V+64F3Xu38ziRKxkuddbCJ6d5+SAm3YT4l0kfqqW+neGpbqHcIx2Ia+xGzDQoE3xluj7 2chgIgCXf8Ra6g5OgTlxRHikIq9Ca4sUi09igUlJKzeZd4L8B1HhMVPMYEVeIbnnv7DS CFfQ== X-Gm-Message-State: AOAM531HEQoJmmaJiIWM3ItNf4GDGvLNt0t4mk5CW7IuiqGoh6gEFqr+ lDPhQoZldq+MGSjmWbzbM+WCEOAhUP5oJgOLmh7IRGsZ X-Google-Smtp-Source: ABdhPJyXFNg+Jb9VKSJs8rZC+toJS/iDW5+z8yakjsHMfhVAGFngnYCSYKpT51303TYopS73gZmTPVurfLZ/VWzddKg= X-Received: by 2002:ac2:592b:: with SMTP id v11mr8579675lfi.296.1621792930888; Sun, 23 May 2021 11:02:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:9746:0:0:0:0:0 with HTTP; Sun, 23 May 2021 11:02:10 -0700 (PDT) In-Reply-To: <202105211604.14LG4EdR005067@gitrepo.freebsd.org> References: <202105211604.14LG4EdR005067@gitrepo.freebsd.org> From: Mateusz Guzik Date: Sun, 23 May 2021 20:02:10 +0200 Message-ID: Subject: Re: git: 5b2a81f58dc7 - main - mmc: Add mmc-pwrseq driver To: Emmanuel Vadot Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Fp7Tc6V1Cz4pPm X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=UkYXrpeT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::134 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::134:from]; TO_DN_SOME(0.00)[]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::134:from:127.0.2.255]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::134:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 18:02:13 -0000 This breaks tinderbox, for example buildkernel TARGET_ARCH=armv6 KERNCONF=RPI-B MODULES_OVERRIDE="": ld: error: undefined symbol: mmc_fdt_parse >>> referenced by bcm2835_sdhci.c:320 (/usr/src/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c:320) >>> bcm2835_sdhci.o:(bcm_sdhci_attach) ld: error: undefined symbol: mmc_fdt_parse >>> referenced by bcm2835_sdhci.c:320 (/usr/src/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c:320) >>> bcm2835_sdhci.o:(bcm_sdhci_attach) On 5/21/21, Emmanuel Vadot wrote: > The branch main has been updated by manu: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=5b2a81f58dc722ca76065536f07ba47efd98dc63 > > commit 5b2a81f58dc722ca76065536f07ba47efd98dc63 > Author: Emmanuel Vadot > AuthorDate: 2021-05-16 12:48:56 +0000 > Commit: Emmanuel Vadot > CommitDate: 2021-05-21 15:36:20 +0000 > > mmc: Add mmc-pwrseq driver > > This driver is used to power up sdio card or eMMC. > It handle the reset-gpio, clocks and needed delays for > powerup/powerdown. > > Sponsored by: Diablotin Systems > Differential Revision: https://reviews.freebsd.org/D30288 > --- > sys/conf/files | 2 + > sys/dev/mmc/mmc_pwrseq.c | 194 > ++++++++++++++++++++++++++++++++++++++++++++ > sys/dev/mmc/mmc_pwrseq_if.m | 38 +++++++++ > 3 files changed, 234 insertions(+) > > diff --git a/sys/conf/files b/sys/conf/files > index 22083169bfc7..70cdd9f68dc6 100644 > --- a/sys/conf/files > +++ b/sys/conf/files > @@ -2476,6 +2476,8 @@ dev/mmc/mmcbr_if.m standard > dev/mmc/mmcbus_if.m standard > dev/mmc/mmcsd.c optional mmcsd !mmccam > dev/mmc/mmc_fdt_helpers.c optional mmc fdt | mmccam fdt > +dev/mmc/mmc_pwrseq.c optional mmc fdt | mmccam fdt > +dev/mmc/mmc_pwrseq_if.m optional mmc fdt | mmccam fdt > dev/mmcnull/mmcnull.c optional mmcnull > dev/mpr/mpr.c optional mpr > dev/mpr/mpr_config.c optional mpr > diff --git a/sys/dev/mmc/mmc_pwrseq.c b/sys/dev/mmc/mmc_pwrseq.c > new file mode 100644 > index 000000000000..d4ccf814fe53 > --- /dev/null > +++ b/sys/dev/mmc/mmc_pwrseq.c > @@ -0,0 +1,194 @@ > +/* > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright 2021 Emmanuel Vadot > + * > + * 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. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > + > +#include "mmc_pwrseq_if.h" > + > +enum pwrseq_type { > + PWRSEQ_SIMPLE = 1, > + PWRSEQ_EMMC, > +}; > + > +static struct ofw_compat_data compat_data[] = { > + { "mmc-pwrseq-simple", PWRSEQ_SIMPLE }, > + { "mmc-pwrseq-emmc", PWRSEQ_EMMC }, > + { NULL, 0 } > +}; > + > +struct mmc_pwrseq_softc { > + enum pwrseq_type type; > + clk_t ext_clock; > + struct gpiobus_pin *reset_gpio; > + > + uint32_t post_power_on_delay_ms; > + uint32_t power_off_delay_us; > +}; > + > +static int > +mmc_pwrseq_probe(device_t dev) > +{ > + enum pwrseq_type type; > + > + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) > + return (ENXIO); > + > + type = (enum pwrseq_type)ofw_bus_search_compatible(dev, > compat_data)->ocd_data; > + switch (type) { > + case PWRSEQ_SIMPLE: > + device_set_desc(dev, "MMC Simple Power sequence"); > + break; > + case PWRSEQ_EMMC: > + device_set_desc(dev, "MMC eMMC Power sequence"); > + break; > + } > + return (BUS_PROBE_DEFAULT); > +} > + > +static int > +mmc_pwrseq_attach(device_t dev) > +{ > + struct mmc_pwrseq_softc *sc; > + phandle_t node; > + int rv; > + > + sc = device_get_softc(dev); > + sc->type = (enum pwrseq_type)ofw_bus_search_compatible(dev, > compat_data)->ocd_data; > + node = ofw_bus_get_node(dev); > + > + if (sc->type == PWRSEQ_SIMPLE) { > + if (OF_hasprop(node, "clocks")) { > + rv = clk_get_by_ofw_name(dev, 0, "ext_clock", &sc->ext_clock); > + if (rv != 0) { > + device_printf(dev, > + "Node have a clocks property but no clocks named > \"ext_clock\"\n"); > + return (ENXIO); > + } > + } > + OF_getencprop(node, "post-power-on-delay-ms", > &sc->post_power_on_delay_ms, sizeof(uint32_t)); > + OF_getencprop(node, "power-off-delay-us", &sc->power_off_delay_us, > sizeof(uint32_t)); > + } > + > + if (OF_hasprop(node, "reset-gpios")) { > + if (gpio_pin_get_by_ofw_property(dev, node, "reset-gpios", > + &sc->reset_gpio) != 0) { > + device_printf(dev, "Cannot get the reset-gpios\n"); > + return (ENXIO); > + } > + gpio_pin_setflags(sc->reset_gpio, GPIO_PIN_OUTPUT); > + gpio_pin_set_active(sc->reset_gpio, true); > + } > + > + OF_device_register_xref(OF_xref_from_node(node), dev); > + return (0); > +} > + > +static int > +mmc_pwrseq_detach(device_t dev) > +{ > + > + return (EBUSY); > +} > + > +static int > +mmv_pwrseq_set_power(device_t dev, bool power_on) > +{ > + struct mmc_pwrseq_softc *sc; > + int rv; > + > + sc = device_get_softc(dev); > + > + if (power_on) { > + if (sc->ext_clock) { > + rv = clk_enable(sc->ext_clock); > + if (rv != 0) > + return (rv); > + } > + > + if (sc->reset_gpio) { > + rv = gpio_pin_set_active(sc->reset_gpio, false); > + if (rv != 0) > + return (rv); > + } > + > + if (sc->post_power_on_delay_ms) > + DELAY(sc->post_power_on_delay_ms * 1000); > + } else { > + if (sc->reset_gpio) { > + rv = gpio_pin_set_active(sc->reset_gpio, true); > + if (rv != 0) > + return (rv); > + } > + > + if (sc->ext_clock) { > + rv = clk_stop(sc->ext_clock); > + if (rv != 0) > + return (rv); > + } > + if (sc->power_off_delay_us) > + DELAY(sc->power_off_delay_us); > + } > + > + return (0); > +} > + > +static device_method_t mmc_pwrseq_methods[] = { > + /* Device interface */ > + DEVMETHOD(device_probe, mmc_pwrseq_probe), > + DEVMETHOD(device_attach, mmc_pwrseq_attach), > + DEVMETHOD(device_detach, mmc_pwrseq_detach), > + > + DEVMETHOD(mmc_pwrseq_set_power, mmv_pwrseq_set_power), > + DEVMETHOD_END > +}; > + > +static driver_t mmc_pwrseq_driver = { > + "mmc_pwrseq", > + mmc_pwrseq_methods, > + sizeof(struct mmc_pwrseq_softc), > +}; > + > +static devclass_t mmc_pwrseq_devclass; > + > +EARLY_DRIVER_MODULE(mmc_pwrseq, simplebus, mmc_pwrseq_driver, > mmc_pwrseq_devclass, 0, 0, > + BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); > +MODULE_VERSION(mmc_pwrseq, 1); > +SIMPLEBUS_PNP_INFO(compat_data); > diff --git a/sys/dev/mmc/mmc_pwrseq_if.m b/sys/dev/mmc/mmc_pwrseq_if.m > new file mode 100644 > index 000000000000..e94b44052c20 > --- /dev/null > +++ b/sys/dev/mmc/mmc_pwrseq_if.m > @@ -0,0 +1,38 @@ > +#- > +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD > +# > +# Copyright (c) 2021 Emmanuel Vadot > +# > +# 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. > +# > +# $FreeBSD$ > +# > + > +INTERFACE mmc_pwrseq; > + > +# > +# Power up/down the card > +# > +METHOD int set_power { > + device_t bus; > + bool power_on; > +}; > -- Mateusz Guzik From owner-dev-commits-src-main@freebsd.org Sun May 23 18:13:53 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D857864C977; Sun, 23 May 2021 18:13: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 4Fp7l55cnYz4t6F; Sun, 23 May 2021 18:13: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 A9B541C001; Sun, 23 May 2021 18:13: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 14NIDr35009999; Sun, 23 May 2021 18:13:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NIDrqp009998; Sun, 23 May 2021 18:13:53 GMT (envelope-from git) Date: Sun, 23 May 2021 18:13:53 GMT Message-Id: <202105231813.14NIDrqp009998@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 6f6cd1e8e8aa - main - ktrace: Remove vrele() at the end of ktr_writerequest() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6f6cd1e8e8aa3a48b35598992f1b6c21003d35cd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 18:13:54 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6f6cd1e8e8aa3a48b35598992f1b6c21003d35cd commit 6f6cd1e8e8aa3a48b35598992f1b6c21003d35cd Author: Mark Johnston AuthorDate: 2021-05-23 17:20:05 +0000 Commit: Mark Johnston CommitDate: 2021-05-23 18:13:01 +0000 ktrace: Remove vrele() at the end of ktr_writerequest() As of commit fc369a353 we no longer ref the vnode when writing a record. Drop the corresponding vrele() call in the error case. Fixes: fc369a353 ("ktrace: fix a race between writes and close") Reported by: syzbot+9b96ea7a5ff8917d3fe4@syzkaller.appspotmail.com Reported by: syzbot+6120ebbb354cd52e5107@syzkaller.appspotmail.com Reviewed by: kib MFC after: 6 days Differential Revision: https://reviews.freebsd.org/D30404 --- sys/kern/kern_ktrace.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 3a223215a60d..9059a75f571c 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1361,7 +1361,6 @@ ktr_writerequest(struct thread *td, struct ktr_request *req) PROC_UNLOCK(p); ktr_io_params_free(kiop1); ktr_io_params_free(kiop); - vrele(vp); } /* From owner-dev-commits-src-main@freebsd.org Sun May 23 18:32:03 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC45964CD42; Sun, 23 May 2021 18:32: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 4Fp8835rTpz3KH2; Sun, 23 May 2021 18:32: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 B02761C32C; Sun, 23 May 2021 18:32: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 14NIW3f5036483; Sun, 23 May 2021 18:32:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NIW3ag036482; Sun, 23 May 2021 18:32:03 GMT (envelope-from git) Date: Sun, 23 May 2021 18:32:03 GMT Message-Id: <202105231832.14NIW3ag036482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 8746bc918734 - main - run(4): add support for DLINK DWA-130 rev F1 wireless adaptor. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8746bc91873430d977b09bcc3fbd4d1b417a5a57 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 18:32:03 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=8746bc91873430d977b09bcc3fbd4d1b417a5a57 commit 8746bc91873430d977b09bcc3fbd4d1b417a5a57 Author: Dmitry Chagin AuthorDate: 2021-05-23 18:31:51 +0000 Commit: Dmitry Chagin CommitDate: 2021-05-23 18:31:51 +0000 run(4): add support for DLINK DWA-130 rev F1 wireless adaptor. PR: 256092 Submitted by: Francois Briere MFC After: 2 weeks --- share/man/man4/run.4 | 1 + sys/dev/usb/usbdevs | 1 + sys/dev/usb/wlan/if_run.c | 1 + 3 files changed, 3 insertions(+) diff --git a/share/man/man4/run.4 b/share/man/man4/run.4 index ad314ff67011..0cea7beada77 100644 --- a/share/man/man4/run.4 +++ b/share/man/man4/run.4 @@ -145,6 +145,7 @@ driver supports the following wireless adapters: .It Corega CG-WLUSB300AGN .It Corega CG-WLUSB300GNM .It D-Link DWA-130 rev B1 +.It D-Link DWA-130 rev F1 .It D-Link DWA-140 rev B1, B2, B3, \&D1 .It D-Link DWA-160 rev B2 .It D-Link DWA-162 diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 91a243e26bac..5613719a2c8b 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1736,6 +1736,7 @@ product DLINK DWA160B2 0x3c1a DWA-160 rev B2 product DLINK DWA127 0x3c1b DWA-127 Wireless Adapter product DLINK DWA162 0x3c1f DWA-162 Wireless Adapter product DLINK DWA140D1 0x3c20 DWA-140 rev D1 +product DLINK DWA130F1 0x3c25 DWA-130 rev F1 product DLINK DSB650C 0x4000 10Mbps Ethernet product DLINK DSB650TX1 0x4001 10/100 Ethernet product DLINK DSB650TX 0x4002 10/100 Ethernet diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index c7f0ae40f666..52933a4812dc 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -215,6 +215,7 @@ static const STRUCT_USB_HOST_ID run_devs[] = { RUN_DEV(DLINK, DWA140B3), RUN_DEV(DLINK, DWA160B2), RUN_DEV(DLINK, DWA140D1), + RUN_DEV(DLINK, DWA130F1), RUN_DEV(DLINK, DWA162), RUN_DEV(DLINK2, DWA130), RUN_DEV(DLINK2, RT2870_1), From owner-dev-commits-src-main@freebsd.org Sun May 23 19:37:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5796C64DC70; Sun, 23 May 2021 19:37: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 4Fp9bN24Byz4d8l; Sun, 23 May 2021 19:37: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 2FE9A1CEBC; Sun, 23 May 2021 19:37: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 14NJbKsV016484; Sun, 23 May 2021 19:37:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NJbKHL016483; Sun, 23 May 2021 19:37:20 GMT (envelope-from git) Date: Sun, 23 May 2021 19:37:20 GMT Message-Id: <202105231937.14NJbKHL016483@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: a269183875f6 - main - vfs: elide vnode locking when it is only needed for audit if possible MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a269183875f6d5141c81277d41b552871e2171e5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 19:37:20 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a269183875f6d5141c81277d41b552871e2171e5 commit a269183875f6d5141c81277d41b552871e2171e5 Author: Mateusz Guzik AuthorDate: 2021-05-23 19:28:26 +0000 Commit: Mateusz Guzik CommitDate: 2021-05-23 19:37:16 +0000 vfs: elide vnode locking when it is only needed for audit if possible --- sys/kern/vfs_syscalls.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 32e4c8688762..55780b0474ee 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2802,9 +2802,11 @@ sys_fchflags(struct thread *td, struct fchflags_args *uap) if (error != 0) return (error); #ifdef AUDIT - vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); - AUDIT_ARG_VNODE1(fp->f_vnode); - VOP_UNLOCK(fp->f_vnode); + if (AUDITING_TD(td)) { + vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); + AUDIT_ARG_VNODE1(fp->f_vnode); + VOP_UNLOCK(fp->f_vnode); + } #endif error = setfflags(td, fp->f_vnode, uap->flags); fdrop(fp, td); @@ -3303,9 +3305,11 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr, if (error != 0) return (error); #ifdef AUDIT - vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); - AUDIT_ARG_VNODE1(fp->f_vnode); - VOP_UNLOCK(fp->f_vnode); + if (AUDITING_TD(td)) { + vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); + AUDIT_ARG_VNODE1(fp->f_vnode); + VOP_UNLOCK(fp->f_vnode); + } #endif error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL); fdrop(fp, td); @@ -3337,9 +3341,11 @@ kern_futimens(struct thread *td, int fd, struct timespec *tptr, if (error != 0) return (error); #ifdef AUDIT - vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); - AUDIT_ARG_VNODE1(fp->f_vnode); - VOP_UNLOCK(fp->f_vnode); + if (AUDITING_TD(td)) { + vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); + AUDIT_ARG_VNODE1(fp->f_vnode); + VOP_UNLOCK(fp->f_vnode); + } #endif error = setutimes(td, fp->f_vnode, ts, 2, flags & UTIMENS_NULL); fdrop(fp, td); From owner-dev-commits-src-main@freebsd.org Sun May 23 20:49:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 33E7F64F51B; Sun, 23 May 2021 20:49: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 4FpCBS0w6Xz3lNn; Sun, 23 May 2021 20:49: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 0159B1DE05; Sun, 23 May 2021 20:49: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 14NKnJnv010050; Sun, 23 May 2021 20:49:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NKnJhb010049; Sun, 23 May 2021 20:49:19 GMT (envelope-from git) Date: Sun, 23 May 2021 20:49:19 GMT Message-Id: <202105232049.14NKnJhb010049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: a660948b7b2d - main - tests/libalias: Reduce stress MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a660948b7b2d875591aba3713620424c51330038 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 20:49:20 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=a660948b7b2d875591aba3713620424c51330038 commit a660948b7b2d875591aba3713620424c51330038 Author: Lutz Donnerhacke AuthorDate: 2021-05-23 20:41:26 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-23 20:48:28 +0000 tests/libalias: Reduce stress Due to the new, external performance test utility, the regular test suite can reduce the stress test to a fair amount of activity. MFC after: 1 week --- tests/sys/netinet/libalias/2_natout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/netinet/libalias/2_natout.c b/tests/sys/netinet/libalias/2_natout.c index 9eb9148f8377..513ff359b1d9 100644 --- a/tests/sys/netinet/libalias/2_natout.c +++ b/tests/sys/netinet/libalias/2_natout.c @@ -311,7 +311,7 @@ ATF_TC_BODY(7_stress, dummy) struct in_addr src, dst; uint16_t sport, dport, aport; } *batch; - size_t const batch_size = 12000; + size_t const batch_size = 1200; size_t const rounds = 25; size_t i, j; From owner-dev-commits-src-main@freebsd.org Sun May 23 22:44:10 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1EE265130E; Sun, 23 May 2021 22:44: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 4FpFky3C3xz3lvC; Sun, 23 May 2021 22:44: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 51AFF1F6AD; Sun, 23 May 2021 22:44: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 14NMiAhB068184; Sun, 23 May 2021 22:44:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NMiAni068183; Sun, 23 May 2021 22:44:10 GMT (envelope-from git) Date: Sun, 23 May 2021 22:44:10 GMT Message-Id: <202105232244.14NMiAni068183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 47791339f0cf - main - ums(4): Start USB xfers on opening of evdev node unconditionally. 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/main X-Git-Reftype: branch X-Git-Commit: 47791339f0cfe3282a6f64b5607047f7bca968ad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 22:44:10 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=47791339f0cfe3282a6f64b5607047f7bca968ad commit 47791339f0cfe3282a6f64b5607047f7bca968ad Author: Vladimir Kondratyev AuthorDate: 2021-05-23 22:41:17 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-05-23 22:41:17 +0000 ums(4): Start USB xfers on opening of evdev node unconditionally. This fixes inability to start USB xfers in a case when FIFO has been already open()-ed but no read() or poll() calls has been issued yet. MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D30343 --- sys/dev/usb/input/ums.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index b9533221ca8a..cce1831287e4 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -952,8 +952,8 @@ ums_ev_open(struct evdev_dev *evdev) if (sc->sc_fflags == 0) { ums_reset(sc); - ums_start_rx(sc); } + ums_start_rx(sc); return (0); } From owner-dev-commits-src-main@freebsd.org Sun May 23 22:44:10 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F22A16510CD; Sun, 23 May 2021 22:44:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FpFkx3F9jz3lgN; Sun, 23 May 2021 22:44: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 30DA91F88E; Sun, 23 May 2021 22:44: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 14NMi9WY068163; Sun, 23 May 2021 22:44:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NMi9K8068162; Sun, 23 May 2021 22:44:09 GMT (envelope-from git) Date: Sun, 23 May 2021 22:44:09 GMT Message-Id: <202105232244.14NMi9K8068162@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 05ab03a31798 - main - ums(4): Do not stop USB xfers on FIFO close when evdev is still active 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/main X-Git-Reftype: branch X-Git-Commit: 05ab03a31798d4cc96c22a8f30b1d9a0d7a3dd35 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 22:44:10 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=05ab03a31798d4cc96c22a8f30b1d9a0d7a3dd35 commit 05ab03a31798d4cc96c22a8f30b1d9a0d7a3dd35 Author: Vladimir Kondratyev AuthorDate: 2021-05-23 22:38:53 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-05-23 22:38:53 +0000 ums(4): Do not stop USB xfers on FIFO close when evdev is still active This fixes lose of evdev events after moused has been killed. While here use bitwise operations for UMS_EVDEV_OPENED flag. Reviewed by: hselasky MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D30342 --- sys/dev/usb/input/ums.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index 6b7c3d526ad0..b9533221ca8a 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -380,7 +380,7 @@ tr_setup: /* check if we can put more data into the FIFO */ if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) == 0) { #ifdef EVDEV_SUPPORT - if (sc->sc_evflags == 0) + if ((sc->sc_evflags & UMS_EVDEV_OPENED) == 0) break; #else break; @@ -858,7 +858,10 @@ ums_fifo_stop_read(struct usb_fifo *fifo) { struct ums_softc *sc = usb_fifo_softc(fifo); - ums_stop_rx(sc); +#ifdef EVDEV_SUPPORT + if ((sc->sc_evflags & UMS_EVDEV_OPENED) == 0) +#endif + ums_stop_rx(sc); } #if ((MOUSE_SYS_PACKETSIZE != 8) || \ @@ -945,7 +948,7 @@ ums_ev_open(struct evdev_dev *evdev) mtx_assert(&sc->sc_mtx, MA_OWNED); - sc->sc_evflags = UMS_EVDEV_OPENED; + sc->sc_evflags |= UMS_EVDEV_OPENED; if (sc->sc_fflags == 0) { ums_reset(sc); @@ -962,7 +965,7 @@ ums_ev_close(struct evdev_dev *evdev) mtx_assert(&sc->sc_mtx, MA_OWNED); - sc->sc_evflags = 0; + sc->sc_evflags &= ~UMS_EVDEV_OPENED; if (sc->sc_fflags == 0) ums_stop_rx(sc); @@ -984,7 +987,7 @@ ums_fifo_open(struct usb_fifo *fifo, int fflags) /* check for first open */ #ifdef EVDEV_SUPPORT - if (sc->sc_fflags == 0 && sc->sc_evflags == 0) + if (sc->sc_fflags == 0 && (sc->sc_evflags & UMS_EVDEV_OPENED) == 0) ums_reset(sc); #else if (sc->sc_fflags == 0) From owner-dev-commits-src-main@freebsd.org Sun May 23 23:08:55 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16FDA6515E8; Sun, 23 May 2021 23:08: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 4FpGHV736Hz4Qq7; Sun, 23 May 2021 23:08:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D629D1F8C3; Sun, 23 May 2021 23:08:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14NN8s3q096559; Sun, 23 May 2021 23:08:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14NN8s1A096558; Sun, 23 May 2021 23:08:54 GMT (envelope-from git) Date: Sun, 23 May 2021 23:08:54 GMT Message-Id: <202105232308.14NN8s1A096558@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: 24b98f288d11 - main - cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 24b98f288d11750f2cdfbfe360be1c92a9c2ee1d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 23:08:55 -0000 The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=24b98f288d11750f2cdfbfe360be1c92a9c2ee1d commit 24b98f288d11750f2cdfbfe360be1c92a9c2ee1d Author: Navdeep Parhar AuthorDate: 2021-05-23 21:58:29 +0000 Commit: Navdeep Parhar CommitDate: 2021-05-23 23:07:29 +0000 cxgbe(4): Overhaul CLIP (Compressed Local IPv6) table management. - Process the list of local IPs once instead of once per adapter. Add addresses from all VNETs to the driver's list but leave hardware updates for later when the global VNET/IFADDR list locks have been released. - Add address to the hardware table synchronously when a CLIP entry is requested for an address that's not already in there. - Provide ioctls that allow userspace tools to manage addresses in the CLIP table. - Add a knob (hw.cxgbe.clip_db_auto) that controls whether local IPs are automatically added to the CLIP table or not. MFC after: 2 weeks Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 16 +- sys/dev/cxgbe/crypto/t4_kern_tls.c | 4 +- sys/dev/cxgbe/t4_clip.c | 842 ++++++++++++++++++++++++++++--------- sys/dev/cxgbe/t4_clip.h | 15 +- sys/dev/cxgbe/t4_ioctl.h | 10 + sys/dev/cxgbe/t4_main.c | 37 ++ sys/dev/cxgbe/tom/t4_connect.c | 4 +- sys/dev/cxgbe/tom/t4_listen.c | 18 +- sys/dev/cxgbe/tom/t4_tom.c | 2 +- 9 files changed, 735 insertions(+), 213 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index b3b214ce3c96..27655ec2fe59 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,15 @@ MALLOC_DECLARE(M_CXGBE); #define CXGBE_UNIMPLEMENTED(s) \ panic("%s (%s, line %d) not implemented yet.", s, __FILE__, __LINE__) +/* + * Same as LIST_HEAD from queue.h. This is to avoid conflict with LinuxKPI's + * LIST_HEAD when building iw_cxgbe. + */ +#define CXGBE_LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + #ifndef SYSCTL_ADD_UQUAD #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD #define sysctl_handle_64 sysctl_handle_quad @@ -886,9 +896,11 @@ struct adapter { struct port_info *port[MAX_NPORTS]; uint8_t chan_map[MAX_NCHAN]; /* channel -> port */ - struct mtx clip_table_lock; - TAILQ_HEAD(, clip_entry) clip_table; + CXGBE_LIST_HEAD(, clip_entry) *clip_table; + TAILQ_HEAD(, clip_entry) clip_pending; /* these need hw update. */ + u_long clip_mask; int clip_gen; + struct timeout_task clip_task; void *tom_softc; /* (struct tom_data *) */ struct tom_tunables tt; diff --git a/sys/dev/cxgbe/crypto/t4_kern_tls.c b/sys/dev/cxgbe/crypto/t4_kern_tls.c index 957d0202fa3f..99d0d33cf128 100644 --- a/sys/dev/cxgbe/crypto/t4_kern_tls.c +++ b/sys/dev/cxgbe/crypto/t4_kern_tls.c @@ -379,7 +379,7 @@ send_ktls_act_open_req(struct adapter *sc, struct vi_info *vi, isipv6 = (inp->inp_vflag & INP_IPV6) != 0; if (isipv6) { - tlsp->ce = t4_hold_lip(sc, &inp->in6p_laddr, NULL); + tlsp->ce = t4_get_clip_entry(sc, &inp->in6p_laddr, true); if (tlsp->ce == NULL) return (ENOENT); } @@ -2333,7 +2333,7 @@ cxgbe_tls_tag_free(struct m_snd_tag *mst) if (tlsp->tid >= 0) release_tid(sc, tlsp->tid, tlsp->ctrlq); if (tlsp->ce) - t4_release_lip(sc, tlsp->ce); + t4_release_clip_entry(sc, tlsp->ce); if (tlsp->tx_key_addr >= 0) free_keyid(tlsp, tlsp->tx_key_addr); diff --git a/sys/dev/cxgbe/t4_clip.c b/sys/dev/cxgbe/t4_clip.c index ad26d212315e..18d78a9e830b 100644 --- a/sys/dev/cxgbe/t4_clip.c +++ b/sys/dev/cxgbe/t4_clip.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2012 Chelsio Communications, Inc. + * Copyright (c) 2012-2021 Chelsio Communications, Inc. * All rights reserved. * Written by: Navdeep Parhar * @@ -50,112 +50,345 @@ __FBSDID("$FreeBSD$"); #include "common/common.h" #include "t4_clip.h" +/* + * Code to deal with the Compressed Local IPv6 (CLIP) table in the ASIC. + * + * The driver maintains a global CLIP database (clip_db) of IPv6 addresses and a + * per-adapter CLIP table (sc->clip_table) with entries that point to an IPv6 in + * the clip_db. All access is protected by a single global lock (clip_db_lock). + * The correct lock order is clip lock before synchronized op. + * + * By default (hw.cxgbe.clip_db_auto=1) all local IPv6 addresses are added to + * the db. Addresses are also added on-demand when the driver allocates an + * entry for a filter, TOE tid, etc. krn_ref counts the number of times an + * address appears in the system. adp_ref counts the number of adapters that + * have that address in their CLIP table. If both are 0 then the entry is + * evicted from the db. Consumers of the CLIP table entry (filters, TOE tids) + * are tracked in ce->refcount. Driver ioctls let external consumers add/remove + * addresses from the CLIP table. + */ + #if defined(INET6) -static int add_lip(struct adapter *, struct in6_addr *); -static int delete_lip(struct adapter *, struct in6_addr *); -static struct clip_entry *search_lip(struct adapter *, struct in6_addr *); -static void update_clip(struct adapter *, void *); -static void t4_clip_task(void *, int); -static void update_clip_table(struct adapter *); +struct clip_db_entry { + LIST_ENTRY(clip_db_entry) link; /* clip_db hash linkage */ + struct in6_addr lip; + u_int krn_ref; /* # of times this IP6 appears in list of all IP6 */ + u_int adp_ref; /* # of adapters with this IP6 in their CLIP */ + u_int tmp_ref; /* Used only during refresh */ +}; + +struct clip_entry { + LIST_ENTRY(clip_entry) link; /* clip_table hash linkage */ + TAILQ_ENTRY(clip_entry) plink; /* clip_pending linkage */ + struct clip_db_entry *cde; + int16_t clip_idx; /* index in the hw table */ + bool pending; /* in clip_pending list */ + int refcount; +}; -static int in6_ifaddr_gen; static eventhandler_tag ifaddr_evhandler; -static struct timeout_task clip_task; +static struct mtx clip_db_lock; +static LIST_HEAD(, clip_db_entry) *clip_db; +static u_long clip_db_mask; +static int clip_db_gen; +static struct task clip_db_task; + +static int add_lip(struct adapter *, struct in6_addr *, int16_t *); +static int del_lip(struct adapter *, struct in6_addr *); +static void t4_clip_db_task(void *, int); +static void t4_clip_task(void *, int); +static void update_clip_db(void); +static int update_sw_clip_table(struct adapter *); +static int update_hw_clip_table(struct adapter *); +static void update_clip_table(struct adapter *, void *); +static int sysctl_clip_db(SYSCTL_HANDLER_ARGS); +static int sysctl_clip_db_auto(SYSCTL_HANDLER_ARGS); +static struct clip_db_entry *lookup_clip_db_entry(struct in6_addr *, bool); +static struct clip_entry *lookup_clip_entry(struct adapter *, struct in6_addr *, + bool); + +SYSCTL_PROC(_hw_cxgbe, OID_AUTO, clip_db, CTLTYPE_STRING | CTLFLAG_RD | + CTLFLAG_SKIP | CTLFLAG_MPSAFE, NULL, 0, sysctl_clip_db, "A", + "CLIP database"); + +int t4_clip_db_auto = 1; +SYSCTL_PROC(_hw_cxgbe, OID_AUTO, clip_db_auto, CTLTYPE_INT | CTLFLAG_RWTUN | + CTLFLAG_MPSAFE, NULL, 0, sysctl_clip_db_auto, "I", + "Add local IPs to CLIP db automatically (0 = no, 1 = yes)"); + +static inline uint32_t +clip_hashfn(struct in6_addr *addr) +{ + return (fnv_32_buf(addr, sizeof(*addr), FNV1_32_INIT) & clip_db_mask); +} + +static inline struct clip_db_entry * +alloc_clip_db_entry(struct in6_addr *in6) +{ + struct clip_db_entry *cde; + + cde = malloc(sizeof(*cde), M_CXGBE, M_NOWAIT | M_ZERO); + if (__predict_true(cde != NULL)) + memcpy(&cde->lip, in6, sizeof(cde->lip)); + + return (cde); +} + +static inline struct clip_entry * +alloc_clip_entry(struct clip_db_entry *cde) +{ + struct clip_entry *ce; + + mtx_assert(&clip_db_lock, MA_OWNED); + + ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT | M_ZERO); + if (__predict_true(ce != NULL)) { + ce->cde = cde; + cde->adp_ref++; + ce->clip_idx = -1; + } + + return (ce); +} + +/* + * Look up the IP6 address in the CLIP db. If add is set then an entry for the + * IP6 will be added to the db. + */ +static struct clip_db_entry * +lookup_clip_db_entry(struct in6_addr *in6, bool add) +{ + struct clip_db_entry *cde; + const int bucket = clip_hashfn(in6); + + mtx_assert(&clip_db_lock, MA_OWNED); + + LIST_FOREACH(cde, &clip_db[bucket], link) { + if (IN6_ARE_ADDR_EQUAL(&cde->lip, in6)) + return (cde); + } + + /* Not found. Create a new entry if requested. */ + if (add) { + cde = alloc_clip_db_entry(in6); + if (cde != NULL) + LIST_INSERT_HEAD(&clip_db[bucket], cde, link); + } + + return (cde); +} + +/* + * Look up the IP6 address in the CLIP db. If add is set then an entry for the + * IP6 will be added to the db. + */ +static struct clip_entry * +lookup_clip_entry(struct adapter *sc, struct in6_addr *in6, bool add) +{ + struct clip_db_entry *cde; + struct clip_entry *ce; + const int bucket = clip_hashfn(in6); + + mtx_assert(&clip_db_lock, MA_OWNED); + + cde = lookup_clip_db_entry(in6, add); + if (cde == NULL) + return (NULL); + + LIST_FOREACH(ce, &sc->clip_table[bucket], link) { + if (ce->cde == cde) + return (ce); + } + + /* Not found. Create a new entry if requested. */ + if (add) { + ce = alloc_clip_entry(cde); + if (ce != NULL) { + LIST_INSERT_HEAD(&sc->clip_table[bucket], ce, link); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, plink); + ce->pending = true; + } + } + + return (ce); +} static int -add_lip(struct adapter *sc, struct in6_addr *lip) +add_lip(struct adapter *sc, struct in6_addr *lip, int16_t *idx) { - struct fw_clip_cmd c; + struct fw_clip_cmd c; + int rc; ASSERT_SYNCHRONIZED_OP(sc); - mtx_assert(&sc->clip_table_lock, MA_OWNED); - memset(&c, 0, sizeof(c)); + memset(&c, 0, sizeof(c)); c.op_to_write = htonl(V_FW_CMD_OP(FW_CLIP_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE); - c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c)); - c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; - c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; + c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c)); + c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; + c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; - return (-t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c)); + rc = -t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c); + if (rc == 0 && idx != NULL) + *idx = G_FW_CLIP_CMD_INDEX(ntohl(c.alloc_to_len16)); + return (rc); } static int -delete_lip(struct adapter *sc, struct in6_addr *lip) +del_lip(struct adapter *sc, struct in6_addr *lip) { struct fw_clip_cmd c; ASSERT_SYNCHRONIZED_OP(sc); - mtx_assert(&sc->clip_table_lock, MA_OWNED); memset(&c, 0, sizeof(c)); c.op_to_write = htonl(V_FW_CMD_OP(FW_CLIP_CMD) | F_FW_CMD_REQUEST | F_FW_CMD_READ); - c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c)); - c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; - c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; + c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c)); + c.ip_hi = *(uint64_t *)&lip->s6_addr[0]; + c.ip_lo = *(uint64_t *)&lip->s6_addr[8]; return (-t4_wr_mbox_ns(sc, sc->mbox, &c, sizeof(c), &c)); } +#endif -static struct clip_entry * -search_lip(struct adapter *sc, struct in6_addr *lip) +struct clip_entry * +t4_get_clip_entry(struct adapter *sc, struct in6_addr *in6, bool add) { +#ifdef INET6 struct clip_entry *ce; + bool schedule = false; - mtx_assert(&sc->clip_table_lock, MA_OWNED); - - TAILQ_FOREACH(ce, &sc->clip_table, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) - return (ce); + mtx_lock(&clip_db_lock); + ce = lookup_clip_entry(sc, in6, add); + if (ce != NULL) { + MPASS(ce->cde->adp_ref > 0); + if (++ce->refcount == 1 && ce->pending && ce->clip_idx != -1) { + /* + * Valid entry that was waiting to be deleted. It is in + * use now so take it off the pending list. + */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; + } + if (ce->clip_idx == -1 && update_hw_clip_table(sc) != 0) + schedule = true; } + mtx_unlock(&clip_db_lock); + if (schedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, 0); + return (ce); +#else return (NULL); -} #endif +} -struct clip_entry * -t4_hold_lip(struct adapter *sc, struct in6_addr *lip, struct clip_entry *ce) +void +t4_hold_clip_entry(struct adapter *sc, struct clip_entry *ce) { - #ifdef INET6 - mtx_lock(&sc->clip_table_lock); - if (ce == NULL) - ce = search_lip(sc, lip); - if (ce != NULL) - ce->refcount++; - mtx_unlock(&sc->clip_table_lock); + MPASS(ce != NULL); + MPASS(ce->cde->adp_ref > 0); - return (ce); -#else - return (NULL); + mtx_lock(&clip_db_lock); + MPASS(ce->refcount > 0); /* Caller should already have a reference */ + ce->refcount++; + mtx_unlock(&clip_db_lock); #endif } +#ifdef INET6 +static void +release_clip_entry_locked(struct adapter *sc, struct clip_entry *ce) +{ + struct clip_db_entry *cde; + + mtx_assert(&clip_db_lock, MA_OWNED); + MPASS(ce->refcount > 0); + cde = ce->cde; + MPASS(cde->adp_ref > 0); + if (--ce->refcount == 0 && cde->krn_ref == 0) { + if (ce->clip_idx == -1) { + /* Was never written to the hardware. */ + MPASS(ce->pending); + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } + } else { + /* + * Valid entry is now unused, add to the pending list + * for deletion. Its refcount was 1 on entry so it + * can't already be pending. + */ + MPASS(!ce->pending); + TAILQ_INSERT_HEAD(&sc->clip_pending, ce, plink); + ce->pending = true; + } + } +} +#endif + void -t4_release_lip(struct adapter *sc, struct clip_entry *ce) +t4_release_clip_entry(struct adapter *sc, struct clip_entry *ce) { +#ifdef INET6 + MPASS(ce != NULL); + + mtx_lock(&clip_db_lock); + release_clip_entry_locked(sc, ce); + /* + * This isn't a manual release via the ioctl. No need to update the + * hw right now even if the release resulted in the entry being queued + * for deletion. + */ + mtx_unlock(&clip_db_lock); +#endif +} +int +t4_release_clip_addr(struct adapter *sc, struct in6_addr *in6) +{ + int rc = ENOTSUP; #ifdef INET6 - mtx_lock(&sc->clip_table_lock); - KASSERT(search_lip(sc, &ce->lip) == ce, - ("%s: CLIP entry %p p not in CLIP table.", __func__, ce)); - KASSERT(ce->refcount > 0, - ("%s: CLIP entry %p has refcount 0", __func__, ce)); - --ce->refcount; - mtx_unlock(&sc->clip_table_lock); + struct clip_entry *ce; + bool schedule = false; + + mtx_lock(&clip_db_lock); + ce = lookup_clip_entry(sc, in6, false); + if (ce == NULL) + rc = ENOENT; + else if (ce->refcount == 0) + rc = EIO; + else { + release_clip_entry_locked(sc, ce); + if (update_hw_clip_table(sc) != 0) + schedule = true; + rc = 0; + } + mtx_unlock(&clip_db_lock); + if (schedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, 0); #endif + return (rc); } #ifdef INET6 void t4_init_clip_table(struct adapter *sc) { - - mtx_init(&sc->clip_table_lock, "CLIP table lock", NULL, MTX_DEF); - TAILQ_INIT(&sc->clip_table); + TAILQ_INIT(&sc->clip_pending); + TIMEOUT_TASK_INIT(taskqueue_thread, &sc->clip_task, 0, t4_clip_task, sc); sc->clip_gen = -1; + sc->clip_table = hashinit(CLIP_HASH_SIZE, M_CXGBE, &sc->clip_mask); + /* Both the hashes must use the same bucket for the same key. */ + if (sc->clip_table != NULL) + MPASS(sc->clip_mask == clip_db_mask); /* * Don't bother forcing an update of the clip table when the * adapter is initialized. Before an interface can be used it @@ -164,194 +397,344 @@ t4_init_clip_table(struct adapter *sc) */ } +/* + * Returns true if any additions or deletions were made to the CLIP DB. + */ static void -update_clip(struct adapter *sc, void *arg __unused) +update_clip_db(void) { + VNET_ITERATOR_DECL(vnet_iter); + struct rm_priotracker in6_ifa_tracker; + struct in6_addr *in6, tin6; + struct in6_ifaddr *ia; + struct clip_db_entry *cde, *cde_tmp; + int i, addel; - if (begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4clip")) - return; + VNET_LIST_RLOCK(); + IN6_IFADDR_RLOCK(&in6_ifa_tracker); + mtx_lock(&clip_db_lock); + VNET_FOREACH(vnet_iter) { + CURVNET_SET_QUIET(vnet_iter); + CK_STAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { + if (ia->ia_ifp->if_flags & IFF_LOOPBACK) + continue; + in6 = &ia->ia_addr.sin6_addr; + KASSERT(!IN6_IS_ADDR_MULTICAST(in6), + ("%s: mcast address in in6_ifaddr list", __func__)); + if (IN6_IS_ADDR_LOOPBACK(in6)) + continue; - if (mtx_initialized(&sc->clip_table_lock) && !hw_off_limits(sc)) - update_clip_table(sc); + if (IN6_IS_SCOPE_EMBED(in6)) { + tin6 = *in6; + in6 = &tin6; + in6_clearscope(in6); + } + cde = lookup_clip_db_entry(in6, true); + if (cde == NULL) + continue; + cde->tmp_ref++; + } + CURVNET_RESTORE(); + } + + addel = 0; + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH_SAFE(cde, &clip_db[i], link, cde_tmp) { + if (cde->krn_ref == 0 && cde->tmp_ref > 0) { + addel++; /* IP6 addr added. */ + } else if (cde->krn_ref > 0 && cde->tmp_ref == 0) { + if (cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + continue; + } + addel++; /* IP6 addr deleted. */ + } + cde->krn_ref = cde->tmp_ref; + cde->tmp_ref = 0; + } + } + if (addel > 0) + clip_db_gen++; + mtx_unlock(&clip_db_lock); + IN6_IFADDR_RUNLOCK(&in6_ifa_tracker); + VNET_LIST_RUNLOCK(); - end_synchronized_op(sc, LOCK_HELD); } +/* + * Update the CLIP db and then update the CLIP tables on all the adapters. + */ static void -t4_clip_task(void *arg, int count) +t4_clip_db_task(void *arg, int count) { - - t4_iterate(update_clip, NULL); + update_clip_db(); + t4_iterate(update_clip_table, NULL); } -static void -update_clip_table(struct adapter *sc) +/* + * Refresh the sw CLIP table for this adapter from the global CLIP db. Entries + * that need to be added or deleted from the hardware CLIP table are placed on a + * pending list but the hardware is not touched. The pending list is something + * reasonable even if this fails so it's ok to apply that to the hardware. + */ +static int +update_sw_clip_table(struct adapter *sc) { - struct rm_priotracker in6_ifa_tracker; - struct in6_ifaddr *ia; - struct in6_addr *lip, tlip; - TAILQ_HEAD(, clip_entry) stale; + struct clip_db_entry *cde; struct clip_entry *ce, *ce_temp; - struct vi_info *vi; - int rc, gen, i, j; - uintptr_t last_vnet; - - ASSERT_SYNCHRONIZED_OP(sc); + int i; + bool found; - IN6_IFADDR_RLOCK(&in6_ifa_tracker); - mtx_lock(&sc->clip_table_lock); - - gen = atomic_load_acq_int(&in6_ifaddr_gen); - if (gen == sc->clip_gen) - goto done; - - TAILQ_INIT(&stale); - TAILQ_CONCAT(&stale, &sc->clip_table, link); + mtx_assert(&clip_db_lock, MA_OWNED); /* - * last_vnet optimizes the common cases where all if_vnet = NULL (no - * VIMAGE) or all if_vnet = vnet0. + * We are about to rebuild the pending list from scratch. Deletions are + * placed before additions because that's how we want to submit them to + * the hardware. */ - last_vnet = (uintptr_t)(-1); - for_each_port(sc, i) - for_each_vi(sc->port[i], j, vi) { - if (IS_DOOMED(vi)) - continue; - - if (last_vnet == (uintptr_t)vi->ifp->if_vnet) - continue; + TAILQ_INIT(&sc->clip_pending); - /* XXX: races with if_vmove */ - CURVNET_SET(vi->ifp->if_vnet); - CK_STAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { - lip = &ia->ia_addr.sin6_addr; - - KASSERT(!IN6_IS_ADDR_MULTICAST(lip), - ("%s: mcast address in in6_ifaddr list", __func__)); - - if (IN6_IS_ADDR_LOOPBACK(lip)) + /* + * Walk the sw CLIP table first. We want to reset every entry's pending + * status as we're rebuilding the pending list. + */ + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH_SAFE(ce, &sc->clip_table[i], link, ce_temp) { + cde = ce->cde; + MPASS(cde->adp_ref > 0); + if (ce->refcount != 0 || cde->krn_ref != 0) { + /* + * Entry should stay in the CLIP. + */ + + if (ce->clip_idx != -1) { + ce->pending = false; + } else { + /* Was never added, carry forward. */ + MPASS(ce->pending); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, + plink); + } continue; - if (IN6_IS_SCOPE_EMBED(lip)) { - /* Remove the embedded scope */ - tlip = *lip; - lip = &tlip; - in6_clearscope(lip); } - /* - * XXX: how to weed out the link local address for the - * loopback interface? It's fe80::1 usually (always?). - */ /* - * If it's in the main list then we already know it's - * not stale. + * Entry should be removed from the CLIP. */ - TAILQ_FOREACH(ce, &sc->clip_table, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) - goto next; - } - /* - * If it's in the stale list we should move it to the - * main list. - */ - TAILQ_FOREACH(ce, &stale, link) { - if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) { - TAILQ_REMOVE(&stale, ce, link); - TAILQ_INSERT_TAIL(&sc->clip_table, ce, - link); - goto next; + if (ce->clip_idx != -1) { + ce->pending = true; + TAILQ_INSERT_HEAD(&sc->clip_pending, ce, plink); + } else { + /* Was never added, free right now. */ + MPASS(ce->pending); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); } } + } + } + + for (i = 0; i <= clip_db_mask; i++) { + LIST_FOREACH(cde, &clip_db[i], link) { + if (cde->krn_ref == 0) + continue; - /* A new IP6 address; add it to the CLIP table */ - ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT); - memcpy(&ce->lip, lip, sizeof(ce->lip)); - ce->refcount = 0; - rc = add_lip(sc, lip); - if (rc == 0) - TAILQ_INSERT_TAIL(&sc->clip_table, ce, link); - else { - char ip[INET6_ADDRSTRLEN]; - - inet_ntop(AF_INET6, &ce->lip, &ip[0], - sizeof(ip)); - if (sc->flags & KERN_TLS_ON || - sc->active_ulds != 0) { - log(LOG_ERR, - "%s: could not add %s (%d)\n", - __func__, ip, rc); + found = false; + LIST_FOREACH(ce, &sc->clip_table[i], link) { + if (ce->cde == cde) { + found = true; + break; } - free(ce, M_CXGBE); } -next: - continue; + if (found) + continue; + ce = alloc_clip_entry(cde); + if (ce == NULL) + return (ENOMEM); + LIST_INSERT_HEAD(&sc->clip_table[i], ce, link); + TAILQ_INSERT_TAIL(&sc->clip_pending, ce, plink); + ce->pending = true; } - CURVNET_RESTORE(); - last_vnet = (uintptr_t)vi->ifp->if_vnet; } - /* - * Remove stale addresses (those no longer in V_in6_ifaddrhead) that are - * no longer referenced by the driver. - */ - TAILQ_FOREACH_SAFE(ce, &stale, link, ce_temp) { - if (ce->refcount == 0) { - rc = delete_lip(sc, &ce->lip); - if (rc == 0) { - TAILQ_REMOVE(&stale, ce, link); + sc->clip_gen = clip_db_gen; + return (0); +} + +static int +update_hw_clip_table(struct adapter *sc) +{ + struct clip_db_entry *cde; + struct clip_entry *ce; + int rc; + char ip[INET6_ADDRSTRLEN]; + + mtx_assert(&clip_db_lock, MA_OWNED); + rc = begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4clip"); + if (rc != 0) + return (rc); + if (hw_off_limits(sc)) + goto done; /* with rc = 0, we don't want to reschedule. */ + while (!TAILQ_EMPTY(&sc->clip_pending)) { + ce = TAILQ_FIRST(&sc->clip_pending); + MPASS(ce->pending); + cde = ce->cde; + MPASS(cde->adp_ref > 0); + + if (ce->clip_idx == -1) { + /* + * Entry was queued for addition to the HW CLIP. + */ + + if (ce->refcount == 0 && cde->krn_ref == 0) { + /* No need to add to HW CLIP. */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } } else { - char ip[INET6_ADDRSTRLEN]; + /* Add to the HW CLIP. */ + rc = add_lip(sc, &cde->lip, &ce->clip_idx); + if (rc == FW_ENOMEM) { + /* CLIP full, no point in retrying. */ + rc = 0; + goto done; + } + if (rc != 0) { + inet_ntop(AF_INET6, &cde->lip, &ip[0], + sizeof(ip)); + CH_ERR(sc, "add_lip(%s) failed: %d\n", + ip, rc); + goto done; + } + MPASS(ce->clip_idx != -1); + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; + } + } else { + /* + * Entry was queued for deletion from the HW CLIP. + */ - inet_ntop(AF_INET6, &ce->lip, &ip[0], - sizeof(ip)); - log(LOG_ERR, "%s: could not delete %s (%d)\n", - __func__, ip, rc); + if (ce->refcount == 0 && cde->krn_ref == 0) { + /* + * Delete from the HW CLIP. Delete should never + * fail so we always log an error. But if the + * failure is that the entry wasn't found in the + * CLIP then we carry on as if it was deleted. + */ + rc = del_lip(sc, &cde->lip); + if (rc != 0) + CH_ERR(sc, "del_lip(%s) failed: %d\n", + ip, rc); + if (rc == FW_EPROTO) + rc = 0; + if (rc != 0) + goto done; + + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + LIST_REMOVE(ce, link); + free(ce, M_CXGBE); + if (--cde->adp_ref == 0) { + LIST_REMOVE(cde, link); + free(cde, M_CXGBE); + } + } else { + /* No need to delete from HW CLIP. */ + TAILQ_REMOVE(&sc->clip_pending, ce, plink); + ce->pending = false; } } } - /* The ones that are still referenced need to stay in the CLIP table */ - TAILQ_CONCAT(&sc->clip_table, &stale, link); - - sc->clip_gen = gen; done: - mtx_unlock(&sc->clip_table_lock); - IN6_IFADDR_RUNLOCK(&in6_ifa_tracker); + end_synchronized_op(sc, LOCK_HELD); + return (rc); +} + +static void +update_clip_table(struct adapter *sc, void *arg __unused) +{ + bool reschedule; + + if (sc->clip_table == NULL) + return; + + reschedule = false; + mtx_lock(&clip_db_lock); + if (sc->clip_gen != clip_db_gen && update_sw_clip_table(sc) != 0) + reschedule = true; + if (!TAILQ_EMPTY(&sc->clip_pending) && update_hw_clip_table(sc) != 0) + reschedule = true; + mtx_unlock(&clip_db_lock); + if (reschedule) + taskqueue_enqueue_timeout(taskqueue_thread, &sc->clip_task, + -hz / 4); +} + +/* + * Update the CLIP table of the specified adapter. + */ +static void +t4_clip_task(void *sc, int count) +{ + update_clip_table(sc, NULL); } void t4_destroy_clip_table(struct adapter *sc) { struct clip_entry *ce, *ce_temp; - - if (mtx_initialized(&sc->clip_table_lock)) { - mtx_lock(&sc->clip_table_lock); - TAILQ_FOREACH_SAFE(ce, &sc->clip_table, link, ce_temp) { - KASSERT(ce->refcount == 0, - ("%s: CLIP entry %p still in use (%d)", __func__, - ce, ce->refcount)); - TAILQ_REMOVE(&sc->clip_table, ce, link); + int i; + + mtx_lock(&clip_db_lock); + if (sc->clip_table == NULL) + goto done; /* CLIP was never initialized. */ + for (i = 0; i <= sc->clip_mask; i++) { + LIST_FOREACH_SAFE(ce, &sc->clip_table[i], link, ce_temp) { + MPASS(ce->refcount == 0); + MPASS(ce->cde->adp_ref > 0); #if 0 - delete_lip(sc, &ce->lip); + del_lip(sc, &ce->lip); #endif + LIST_REMOVE(ce, link); + if (--ce->cde->adp_ref == 0 && ce->cde->krn_ref == 0) { + LIST_REMOVE(ce->cde, link); + free(ce->cde, M_CXGBE); + } free(ce, M_CXGBE); } - mtx_unlock(&sc->clip_table_lock); - mtx_destroy(&sc->clip_table_lock); } + hashdestroy(&sc->clip_table, M_CXGBE, sc->clip_mask); + sc->clip_table = NULL; +done: + mtx_unlock(&clip_db_lock); } static void t4_ifaddr_event(void *arg __unused, struct ifnet *ifp, struct ifaddr *ifa, int event) { + struct in6_addr *in6; + if (t4_clip_db_auto == 0) + return; /* Automatic updates not allowed. */ if (ifa->ifa_addr->sa_family != AF_INET6) return; + if (ifp->if_flags & IFF_LOOPBACK) + return; + in6 = &((struct in6_ifaddr *)ifa)->ia_addr.sin6_addr; + if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_MULTICAST(in6)) + return; - atomic_add_rel_int(&in6_ifaddr_gen, 1); - taskqueue_enqueue_timeout(taskqueue_thread, &clip_task, -hz / 4); + taskqueue_enqueue(taskqueue_thread, &clip_db_task); } *** 336 LINES SKIPPED ***