From owner-svn-src-stable-11@freebsd.org Sun Jun 10 22:26:18 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D611D101177B; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8355C7BC3F; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 645AE12E91; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5AMQH29098739; Sun, 10 Jun 2018 22:26:17 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5AMQFgJ098732; Sun, 10 Jun 2018 22:26:15 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201806102226.w5AMQFgJ098732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 10 Jun 2018 22:26:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334935 - in stable/11/stand: common i386/libi386 libsa uboot/lib userboot/userboot zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/stand: common i386/libi386 libsa uboot/lib userboot/userboot zfs X-SVN-Commit-Revision: 334935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2018 22:26:18 -0000 Author: ian Date: Sun Jun 10 22:26:15 2018 New Revision: 334935 URL: https://svnweb.freebsd.org/changeset/base/334935 Log: MFC r334656, r334665, r334695 r334656: Add vsnprintf() to libsa. Alpha-sort the printf prototypes in stand.h. r334665: Make the v*printf() functions in libsa return int instead of void. This makes them compatible with the C standard signatures, avoiding spurious mismatch errors in the places where the oddball requirements of standalone code end up putting two declarations of the same function in play. r334695: Remove comments and assertions that are no longer valid after r330809. r330809 replaced duplication of devdesc struct fields with an embedded copy of the devdesc struct, to avoid fragility. That means all the scattered comments indicating that structs must match are no longer valid. Likewise asserts that attempted to mitigate some of the old fragility. Reviewed by: imp@ Modified: stable/11/stand/common/disk.h stable/11/stand/i386/libi386/biosdisk.c stable/11/stand/i386/libi386/libi386.h stable/11/stand/libsa/printf.c stable/11/stand/libsa/stand.h stable/11/stand/uboot/lib/libuboot.h stable/11/stand/userboot/userboot/main.c stable/11/stand/zfs/libzfs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/common/disk.h ============================================================================== --- stable/11/stand/common/disk.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/common/disk.h Sun Jun 10 22:26:15 2018 (r334935) @@ -81,9 +81,8 @@ #ifndef _DISK_H #define _DISK_H -/* Note: Must match the 'struct devdesc' in stand.h */ struct disk_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ int d_slice; int d_partition; uint64_t d_offset; Modified: stable/11/stand/i386/libi386/biosdisk.c ============================================================================== --- stable/11/stand/i386/libi386/biosdisk.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/i386/libi386/biosdisk.c Sun Jun 10 22:26:15 2018 (r334935) @@ -78,8 +78,6 @@ struct ptable { #include "geliboot.c" #endif /* LOADER_GELI_SUPPORT */ -CTASSERT(sizeof(struct i386_devdesc) >= sizeof(struct disk_devdesc)); - #define BIOS_NUMDRIVES 0x475 #define BIOSDISK_SECSIZE 512 #define BUFSIZE (1 * BIOSDISK_SECSIZE) Modified: stable/11/stand/i386/libi386/libi386.h ============================================================================== --- stable/11/stand/i386/libi386/libi386.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/i386/libi386/libi386.h Sun Jun 10 22:26:15 2018 (r334935) @@ -29,11 +29,9 @@ /* * i386 fully-qualified device descriptor. - * Note, this must match struct zfs_devdesc for zfs support. */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct i386_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ union { struct Modified: stable/11/stand/libsa/printf.c ============================================================================== --- stable/11/stand/libsa/printf.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/libsa/printf.c Sun Jun 10 22:26:15 2018 (r334935) @@ -80,11 +80,11 @@ printf(const char *fmt, ...) return retval; } -void +int vprintf(const char *fmt, va_list ap) { - kvprintf(fmt, putchar_wrapper, NULL, 10, ap); + return (kvprintf(fmt, putchar_wrapper, NULL, 10, ap)); } int @@ -140,13 +140,32 @@ snprintf(char *buf, size_t size, const char *cfmt, ... return retval; } -void +int +vsnprintf(char *buf, size_t size, const char *cfmt, va_list ap) +{ + struct print_buf arg; + int retval; + + arg.buf = buf; + arg.size = size; + + retval = kvprintf(cfmt, &snprint_func, &arg, 10, ap); + + if (arg.size >= 1) + *(arg.buf)++ = 0; + + return (retval); +} + +int vsprintf(char *buf, const char *cfmt, va_list ap) { int retval; retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap); buf[retval] = '\0'; + + return (retval); } /* Modified: stable/11/stand/libsa/stand.h ============================================================================== --- stable/11/stand/libsa/stand.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/libsa/stand.h Sun Jun 10 22:26:15 2018 (r334935) @@ -268,10 +268,11 @@ extern void *reallocf(void *ptr, size_t size); extern void mallocstats(void); extern int printf(const char *fmt, ...) __printflike(1, 2); -extern void vprintf(const char *fmt, __va_list); extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3); extern int snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4); -extern void vsprintf(char *buf, const char *cfmt, __va_list); +extern int vprintf(const char *fmt, __va_list); +extern int vsprintf(char *buf, const char *cfmt, __va_list); +extern int vsnprintf(char *buf, size_t size, const char *cfmt, __va_list); extern void twiddle(u_int callerdiv); extern void twiddle_divisor(u_int globaldiv); Modified: stable/11/stand/uboot/lib/libuboot.h ============================================================================== --- stable/11/stand/uboot/lib/libuboot.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/uboot/lib/libuboot.h Sun Jun 10 22:26:15 2018 (r334935) @@ -27,9 +27,8 @@ * $FreeBSD$ */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct uboot_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ union { struct { int slice; Modified: stable/11/stand/userboot/userboot/main.c ============================================================================== --- stable/11/stand/userboot/userboot/main.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/userboot/userboot/main.c Sun Jun 10 22:26:15 2018 (r334935) @@ -159,7 +159,6 @@ extract_currdev(void) //bzero(&dev, sizeof(dev)); #if defined(USERBOOT_ZFS_SUPPORT) - CTASSERT(sizeof(struct disk_devdesc) >= sizeof(struct zfs_devdesc)); if (userboot_zfs_found) { struct zfs_devdesc zdev; Modified: stable/11/stand/zfs/libzfs.h ============================================================================== --- stable/11/stand/zfs/libzfs.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/zfs/libzfs.h Sun Jun 10 22:26:15 2018 (r334935) @@ -33,12 +33,9 @@ /* * ZFS fully-qualified device descriptor. - * Arch-specific device descriptors should be binary compatible with this - * structure if they are to support ZFS. */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct zfs_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ uint64_t pool_guid; uint64_t root_guid; }; From owner-svn-src-stable-11@freebsd.org Mon Jun 11 15:43:29 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5711D1012121; Mon, 11 Jun 2018 15:43:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DBD556BEAA; Mon, 11 Jun 2018 15:43:28 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BD1461D730; Mon, 11 Jun 2018 15:43:28 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BFhSeQ028306; Mon, 11 Jun 2018 15:43:28 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BFhSHZ028305; Mon, 11 Jun 2018 15:43:28 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201806111543.w5BFhSHZ028305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 11 Jun 2018 15:43:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334954 - stable/11/sys/arm64/include X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/arm64/include X-SVN-Commit-Revision: 334954 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 15:43:29 -0000 Author: markj Date: Mon Jun 11 15:43:28 2018 New Revision: 334954 URL: https://svnweb.freebsd.org/changeset/base/334954 Log: MFC r334101: Add GET_STACK_USAGE() for arm64. Modified: stable/11/sys/arm64/include/proc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm64/include/proc.h ============================================================================== --- stable/11/sys/arm64/include/proc.h Mon Jun 11 15:42:29 2018 (r334953) +++ stable/11/sys/arm64/include/proc.h Mon Jun 11 15:43:28 2018 (r334954) @@ -53,4 +53,18 @@ struct syscall_args { int narg; }; +#ifdef _KERNEL + +#include + +#define GET_STACK_USAGE(total, used) do { \ + struct thread *td = curthread; \ + (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \ + (used) = (char *)td->td_kstack + \ + td->td_kstack_pages * PAGE_SIZE - \ + (char *)&td; \ +} while (0) + +#endif + #endif /* !_MACHINE_PROC_H_ */ From owner-svn-src-stable-11@freebsd.org Mon Jun 11 15:44:03 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E32AE101226D; Mon, 11 Jun 2018 15:44:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 90E186C009; Mon, 11 Jun 2018 15:44:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 72BEB1D731; Mon, 11 Jun 2018 15:44:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BFi2Nx028409; Mon, 11 Jun 2018 15:44:02 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BFi2NW028408; Mon, 11 Jun 2018 15:44:02 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201806111544.w5BFi2NW028408@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 11 Jun 2018 15:44:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334955 - stable/11/lib/libc/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/lib/libc/sys X-SVN-Commit-Revision: 334955 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 15:44:03 -0000 Author: markj Date: Mon Jun 11 15:44:02 2018 New Revision: 334955 URL: https://svnweb.freebsd.org/changeset/base/334955 Log: MFC r334504: Remove an inaccuracy from mincore.2. Modified: stable/11/lib/libc/sys/mincore.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/mincore.2 ============================================================================== --- stable/11/lib/libc/sys/mincore.2 Mon Jun 11 15:43:28 2018 (r334954) +++ stable/11/lib/libc/sys/mincore.2 Mon Jun 11 15:44:02 2018 (r334955) @@ -28,7 +28,7 @@ .\" @(#)mincore.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd January 17, 2003 +.Dd June 1, 2018 .Dt MINCORE 2 .Os .Sh NAME @@ -73,7 +73,9 @@ Page has been referenced. .It Dv MINCORE_MODIFIED_OTHER Page has been modified. .It Dv MINCORE_SUPER -Page is part of a "super" page. (only i386 & amd64) +Page is part of a large +.Pq Dq super +page. .El .Pp The information returned by From owner-svn-src-stable-11@freebsd.org Mon Jun 11 15:44:54 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADB2E101243E; Mon, 11 Jun 2018 15:44:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FA246C16C; Mon, 11 Jun 2018 15:44:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 40D251D732; Mon, 11 Jun 2018 15:44:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BFisB3028504; Mon, 11 Jun 2018 15:44:54 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BFirNF028502; Mon, 11 Jun 2018 15:44:53 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201806111544.w5BFirNF028502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 11 Jun 2018 15:44:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334956 - in stable/11/lib/libc: aarch64 riscv X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/lib/libc: aarch64 riscv X-SVN-Commit-Revision: 334956 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 15:44:54 -0000 Author: markj Date: Mon Jun 11 15:44:53 2018 New Revision: 334956 URL: https://svnweb.freebsd.org/changeset/base/334956 Log: MFC r334505: Don't export _end on arm64 and riscv. Modified: stable/11/lib/libc/aarch64/Symbol.map stable/11/lib/libc/riscv/Symbol.map Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/aarch64/Symbol.map ============================================================================== --- stable/11/lib/libc/aarch64/Symbol.map Mon Jun 11 15:44:02 2018 (r334955) +++ stable/11/lib/libc/aarch64/Symbol.map Mon Jun 11 15:44:53 2018 (r334956) @@ -33,6 +33,5 @@ FBSD_1.0 { FBSDprivate_1.0 { _set_tp; - _end; __makecontext; }; Modified: stable/11/lib/libc/riscv/Symbol.map ============================================================================== --- stable/11/lib/libc/riscv/Symbol.map Mon Jun 11 15:44:02 2018 (r334955) +++ stable/11/lib/libc/riscv/Symbol.map Mon Jun 11 15:44:53 2018 (r334956) @@ -33,6 +33,5 @@ FBSD_1.0 { FBSDprivate_1.0 { _set_tp; - _end; __makecontext; }; From owner-svn-src-stable-11@freebsd.org Mon Jun 11 17:22:29 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5DA6101DD86; Mon, 11 Jun 2018 17:22:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8FB32720D2; Mon, 11 Jun 2018 17:22:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7235C1E77F; Mon, 11 Jun 2018 17:22:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BHMSJQ080021; Mon, 11 Jun 2018 17:22:28 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BHMSYQ080020; Mon, 11 Jun 2018 17:22:28 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201806111722.w5BHMSYQ080020@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 11 Jun 2018 17:22:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334963 - in stable: 10/release 11/release X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: in stable: 10/release 11/release X-SVN-Commit-Revision: 334963 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 17:22:29 -0000 Author: gjb Date: Mon Jun 11 17:22:27 2018 New Revision: 334963 URL: https://svnweb.freebsd.org/changeset/base/334963 Log: MFC r333374: Use vYYYYMMDD in the timestamp suffix for Google Compute Engine snapshot images for consistency with other OSes. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/Makefile.gce Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/release/Makefile.gce Directory Properties: stable/10/ (props changed) Modified: stable/11/release/Makefile.gce ============================================================================== --- stable/11/release/Makefile.gce Mon Jun 11 17:10:19 2018 (r334962) +++ stable/11/release/Makefile.gce Mon Jun 11 17:22:27 2018 (r334963) @@ -24,7 +24,8 @@ GCE_FAMILY= ${TYPE:tl}-${REVISION:S,.,-,} .endif .if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT" || ${BRANCH} == "PRERELEASE" -SNAPSHOT_DATE!= date +-%Y-%m-%d +_SNAPSHOT_DATE!= date +%Y%m%d +SNAPSHOT_DATE= -v${_SNAPSHOT_DATE} GCE_FAMILY_SUFX= -snap .endif From owner-svn-src-stable-11@freebsd.org Wed Jun 13 07:14:36 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56321100CAA1; Wed, 13 Jun 2018 07:14:36 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0A34C7084D; Wed, 13 Jun 2018 07:14:36 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DF688163A7; Wed, 13 Jun 2018 07:14:35 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5D7EZSl043257; Wed, 13 Jun 2018 07:14:35 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5D7EZV2043252; Wed, 13 Jun 2018 07:14:35 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201806130714.w5D7EZV2043252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 13 Jun 2018 07:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335031 - in stable/11/sys: netinet netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/11/sys: netinet netinet6 X-SVN-Commit-Revision: 335031 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 07:14:36 -0000 Author: ae Date: Wed Jun 13 07:14:34 2018 New Revision: 335031 URL: https://svnweb.freebsd.org/changeset/base/335031 Log: MFC r334324: Remove empty encap_init() function. Modified: stable/11/sys/netinet/in_proto.c stable/11/sys/netinet/ip_encap.c stable/11/sys/netinet/ip_encap.h stable/11/sys/netinet6/in6_proto.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/in_proto.c ============================================================================== --- stable/11/sys/netinet/in_proto.c Wed Jun 13 07:02:58 2018 (r335030) +++ stable/11/sys/netinet/in_proto.c Wed Jun 13 07:14:34 2018 (r335031) @@ -225,7 +225,6 @@ struct protosw inetsw[] = { .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, .pr_ctloutput = rip_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip_usrreqs }, { @@ -235,7 +234,6 @@ struct protosw inetsw[] = { .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, .pr_ctloutput = rip_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip_usrreqs }, { @@ -245,7 +243,6 @@ struct protosw inetsw[] = { .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, .pr_ctloutput = rip_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip_usrreqs }, { @@ -255,7 +252,6 @@ struct protosw inetsw[] = { .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, .pr_ctloutput = rip_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip_usrreqs }, # ifdef INET6 @@ -266,7 +262,6 @@ struct protosw inetsw[] = { .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, .pr_ctloutput = rip_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip_usrreqs }, #endif Modified: stable/11/sys/netinet/ip_encap.c ============================================================================== --- stable/11/sys/netinet/ip_encap.c Wed Jun 13 07:02:58 2018 (r335030) +++ stable/11/sys/netinet/ip_encap.c Wed Jun 13 07:14:34 2018 (r335031) @@ -106,15 +106,6 @@ static struct mtx encapmtx; MTX_SYSINIT(encapmtx, &encapmtx, "encapmtx", MTX_DEF); static LIST_HEAD(, encaptab) encaptab = LIST_HEAD_INITIALIZER(encaptab); -/* - * We currently keey encap_init() for source code compatibility reasons -- - * it's referenced by KAME pieces in netinet6. - */ -void -encap_init(void) -{ -} - #ifdef INET int encap4_input(struct mbuf **mp, int *offp, int proto) Modified: stable/11/sys/netinet/ip_encap.h ============================================================================== --- stable/11/sys/netinet/ip_encap.h Wed Jun 13 07:02:58 2018 (r335030) +++ stable/11/sys/netinet/ip_encap.h Wed Jun 13 07:14:34 2018 (r335031) @@ -48,7 +48,6 @@ struct encaptab { void *arg; /* passed via m->m_pkthdr.aux */ }; -void encap_init(void); int encap4_input(struct mbuf **, int *, int); int encap6_input(struct mbuf **, int *, int); const struct encaptab *encap_attach(int, int, const struct sockaddr *, Modified: stable/11/sys/netinet6/in6_proto.c ============================================================================== --- stable/11/sys/netinet6/in6_proto.c Wed Jun 13 07:02:58 2018 (r335030) +++ stable/11/sys/netinet6/in6_proto.c Wed Jun 13 07:14:34 2018 (r335031) @@ -280,7 +280,6 @@ struct protosw inet6sw[] = { .pr_input = encap6_input, .pr_output = rip6_output, .pr_ctloutput = rip6_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip6_usrreqs }, #endif /* INET */ @@ -292,7 +291,6 @@ struct protosw inet6sw[] = { .pr_input = encap6_input, .pr_output = rip6_output, .pr_ctloutput = rip6_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip6_usrreqs }, { @@ -303,7 +301,6 @@ struct protosw inet6sw[] = { .pr_input = encap6_input, .pr_output = rip6_output, .pr_ctloutput = rip6_ctloutput, - .pr_init = encap_init, .pr_usrreqs = &rip6_usrreqs }, { From owner-svn-src-stable-11@freebsd.org Wed Jun 13 07:16:02 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 176D3100CC16; Wed, 13 Jun 2018 07:16:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BDB93709B4; Wed, 13 Jun 2018 07:16:01 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F519163A9; Wed, 13 Jun 2018 07:16:01 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5D7G1xc043376; Wed, 13 Jun 2018 07:16:01 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5D7G1Lj043375; Wed, 13 Jun 2018 07:16:01 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201806130716.w5D7G1Lj043375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 13 Jun 2018 07:16:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335032 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 335032 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 07:16:02 -0000 Author: ae Date: Wed Jun 13 07:16:01 2018 New Revision: 335032 URL: https://svnweb.freebsd.org/changeset/base/335032 Log: MFC r334707: Use m_copyback() function to write delayed checksum when it isn't located in the first mbuf of the chain. Modified: stable/11/sys/netinet6/ip6_output.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/ip6_output.c ============================================================================== --- stable/11/sys/netinet6/ip6_output.c Wed Jun 13 07:14:34 2018 (r335031) +++ stable/11/sys/netinet6/ip6_output.c Wed Jun 13 07:16:01 2018 (r335032) @@ -200,18 +200,10 @@ in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_sho csum = 0xffff; offset += m->m_pkthdr.csum_data; /* checksum offset */ - if (offset + sizeof(u_short) > m->m_len) { - printf("%s: delayed m_pullup, m->len: %d plen %u off %u " - "csum_flags=%b\n", __func__, m->m_len, plen, offset, - (int)m->m_pkthdr.csum_flags, CSUM_BITS); - /* - * XXX this should not happen, but if it does, the correct - * behavior may be to insert the checksum in the appropriate - * next mbuf in the chain. - */ - return; - } - *(u_short *)(m->m_data + offset) = csum; + if (offset + sizeof(csum) > m->m_len) + m_copyback(m, offset, sizeof(csum), (caddr_t)&csum); + else + *(u_short *)mtodo(m, offset) = csum; } int From owner-svn-src-stable-11@freebsd.org Wed Jun 13 07:17:11 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63EA2100CDB6; Wed, 13 Jun 2018 07:17:11 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9D12470B23; Wed, 13 Jun 2018 07:17:10 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C90C163AA; Wed, 13 Jun 2018 07:17:10 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5D7HAOV043477; Wed, 13 Jun 2018 07:17:10 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5D7HAac043476; Wed, 13 Jun 2018 07:17:10 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201806130717.w5D7HAac043476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 13 Jun 2018 07:17:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335033 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 335033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 07:17:11 -0000 Author: ae Date: Wed Jun 13 07:17:10 2018 New Revision: 335033 URL: https://svnweb.freebsd.org/changeset/base/335033 Log: MFC r334875: Explicitly change the link state when we assingn an address. Since we are setting IFF_UP flag on SIOCSIFADDR, it is possible, that after this link state information still not initialized properly. This leads to problems with routing, since now interface has IFCAP_LINKSTATE capability and a route is considered as working only when interface's link state is in LINK_STATE_UP (see RT_LINK_IS_UP() macro). Modified: stable/11/sys/net/if_loop.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if_loop.c ============================================================================== --- stable/11/sys/net/if_loop.c Wed Jun 13 07:16:01 2018 (r335032) +++ stable/11/sys/net/if_loop.c Wed Jun 13 07:17:10 2018 (r335033) @@ -373,6 +373,7 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFADDR: ifp->if_flags |= IFF_UP; ifp->if_drv_flags |= IFF_DRV_RUNNING; + if_link_state_change(ifp, LINK_STATE_UP); /* * Everything else is done at a higher level. */ From owner-svn-src-stable-11@freebsd.org Wed Jun 13 13:15:06 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 694731009E3D; Wed, 13 Jun 2018 13:15:06 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1CD92822CB; Wed, 13 Jun 2018 13:15:06 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F19C819EA2; Wed, 13 Jun 2018 13:15:05 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DDF57H029591; Wed, 13 Jun 2018 13:15:05 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DDF40n029586; Wed, 13 Jun 2018 13:15:04 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201806131315.w5DDF40n029586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Wed, 13 Jun 2018 13:15:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335058 - in stable/11: etc/rc.d sbin/pfctl X-SVN-Group: stable-11 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in stable/11: etc/rc.d sbin/pfctl X-SVN-Commit-Revision: 335058 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 13:15:06 -0000 Author: kp Date: Wed Jun 13 13:15:04 2018 New Revision: 335058 URL: https://svnweb.freebsd.org/changeset/base/335058 Log: MFC r334726: pf: Return non-zero from 'status' if pf is not enabled In the pf rc.d script the output of `/etc/rc.d/pf status` or `/etc/rc.d/pf onestatus` always provided an exit status of zero. This made it fiddly to programmatically determine if pf was running or not. Return a non-zero status if the pf module is not loaded, extend pfctl to have an option to return an error status if pf is not enabled. PR: 228632 Submitted by: James Park-Watt Modified: stable/11/etc/rc.d/pf stable/11/sbin/pfctl/pfctl.8 stable/11/sbin/pfctl/pfctl.c stable/11/sbin/pfctl/pfctl_parser.c stable/11/sbin/pfctl/pfctl_parser.h Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/rc.d/pf ============================================================================== --- stable/11/etc/rc.d/pf Wed Jun 13 12:44:45 2018 (r335057) +++ stable/11/etc/rc.d/pf Wed Jun 13 13:15:04 2018 (r335058) @@ -66,8 +66,10 @@ pf_status() { if ! [ -c /dev/pf ] ; then echo "pf.ko is not loaded" + return 1 else $pf_program -s info + $pf_program -s Running >/dev/null fi } Modified: stable/11/sbin/pfctl/pfctl.8 ============================================================================== --- stable/11/sbin/pfctl/pfctl.8 Wed Jun 13 12:44:45 2018 (r335057) +++ stable/11/sbin/pfctl/pfctl.8 Wed Jun 13 13:15:04 2018 (r335058) @@ -412,6 +412,8 @@ Show filter information (statistics and counters). When used together with .Fl v , source tracking statistics are also shown. +.It Fl s Cm Running +Show the running status and provide a non-zero exit status when disabled. .It Fl s Cm labels Show per-rule statistics (label, evaluations, packets total, bytes total, packets in, bytes in, packets out, bytes out, state creations) of Modified: stable/11/sbin/pfctl/pfctl.c ============================================================================== --- stable/11/sbin/pfctl/pfctl.c Wed Jun 13 12:44:45 2018 (r335057) +++ stable/11/sbin/pfctl/pfctl.c Wed Jun 13 13:15:04 2018 (r335058) @@ -96,6 +96,7 @@ int pfctl_show_nat(int, int, char *); int pfctl_show_src_nodes(int, int); int pfctl_show_states(int, const char *, int); int pfctl_show_status(int, int); +int pfctl_show_running(int); int pfctl_show_timeouts(int, int); int pfctl_show_limits(int, int); void pfctl_debug(int, u_int32_t, int); @@ -217,7 +218,7 @@ static const char *clearopt_list[] = { static const char *showopt_list[] = { "nat", "queue", "rules", "Anchors", "Sources", "states", "info", "Interfaces", "labels", "timeouts", "memory", "Tables", "osfp", - "all", NULL + "Running", "all", NULL }; static const char *tblcmdopt_list[] = { @@ -1155,6 +1156,20 @@ pfctl_show_status(int dev, int opts) } int +pfctl_show_running(int dev) +{ + struct pf_status status; + + if (ioctl(dev, DIOCGETSTATUS, &status)) { + warn("DIOCGETSTATUS"); + return (-1); + } + + print_running(&status); + return (!status.running); +} + +int pfctl_show_timeouts(int dev, int opts) { struct pfioc_tm pt; @@ -2271,6 +2286,9 @@ main(int argc, char *argv[]) break; case 'i': pfctl_show_status(dev, opts); + break; + case 'R': + error = pfctl_show_running(dev); break; case 't': pfctl_show_timeouts(dev, opts); Modified: stable/11/sbin/pfctl/pfctl_parser.c ============================================================================== --- stable/11/sbin/pfctl/pfctl_parser.c Wed Jun 13 12:44:45 2018 (r335057) +++ stable/11/sbin/pfctl/pfctl_parser.c Wed Jun 13 13:15:04 2018 (r335058) @@ -615,6 +615,12 @@ print_status(struct pf_status *s, int opts) } void +print_running(struct pf_status *status) +{ + printf("%s\n", status->running ? "Enabled" : "Disabled"); +} + +void print_src_node(struct pf_src_node *sn, int opts) { struct pf_addr_wrap aw; Modified: stable/11/sbin/pfctl/pfctl_parser.h ============================================================================== --- stable/11/sbin/pfctl/pfctl_parser.h Wed Jun 13 12:44:45 2018 (r335057) +++ stable/11/sbin/pfctl/pfctl_parser.h Wed Jun 13 13:15:04 2018 (r335058) @@ -257,6 +257,7 @@ void print_src_node(struct pf_src_node *, int); void print_rule(struct pf_rule *, const char *, int, int); void print_tabledef(const char *, int, int, struct node_tinithead *); void print_status(struct pf_status *, int); +void print_running(struct pf_status *); int eval_pfaltq(struct pfctl *, struct pf_altq *, struct node_queue_bw *, struct node_queue_opt *); From owner-svn-src-stable-11@freebsd.org Wed Jun 13 13:41:25 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BDCF100C2D9; Wed, 13 Jun 2018 13:41:25 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB9F383AB6; Wed, 13 Jun 2018 13:41:24 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B46F1A209; Wed, 13 Jun 2018 13:41:24 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DDfOhU043993; Wed, 13 Jun 2018 13:41:24 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DDfN7T043988; Wed, 13 Jun 2018 13:41:23 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201806131341.w5DDfN7T043988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 13 Jun 2018 13:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335059 - in stable/11: usr.bin/wall usr.sbin/syslogd X-SVN-Group: stable-11 X-SVN-Commit-Author: ed X-SVN-Commit-Paths: in stable/11: usr.bin/wall usr.sbin/syslogd X-SVN-Commit-Revision: 335059 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 13:41:25 -0000 Author: ed Date: Wed Jun 13 13:41:23 2018 New Revision: 335059 URL: https://svnweb.freebsd.org/changeset/base/335059 Log: MFC r309925, r309931, r309933, r310035, r310278, r310310, r310311, r310323, r310349, r310350, r310351, r310352, r310383, r310384, r310385, r310386, r310393, r310453, r310456, r310494, r310504, r310528, r310890, r310893, r310974, r311918, r312921, r313357, r314563, r314585, r314642, r315322, r315618, r315620, r315622, r315643, r316951, r316973, r326338, r326339, r326573, r331270, r332099, r332110, r332111, r332118, r332165, r332510 and r332511. This commit brings syslogd(8) in sync with the copy in HEAD. The key improvement of this change is that it adds support for RFC 5424 log ingestion and exposition (enabled by passing in -O rfc5424). This allows for saner logging in environments with multiple time zones. The list of changes to merge back were obtained by running: svn mergeinfo --show-revs eligible \ ^/head/usr.sbin/syslogd ^/stable/11/usr.sbin/syslogd Of the commits listed, r314436, r325188 and r326025 were excluded, as they affect a significant number of unrelated files (SPDX and 4-clause license renumbering). Due to the large number of directly committed changes on this branch, I had no choice but to perform the merge as follows: svn merge --accept=theirs-full -c ^/head . This would, however, cause some unrelated changes, such as undoing the r333356 (MFC of r332877) and still adding the SPDX tag to syslogd.c. These have been reverted manually. Requested by: Dave Cottlehuber Thanks to: dim@ for sharing his insight on hackers@ Modified: stable/11/usr.bin/wall/ttymsg.c stable/11/usr.bin/wall/ttymsg.h stable/11/usr.sbin/syslogd/Makefile stable/11/usr.sbin/syslogd/syslogd.8 stable/11/usr.sbin/syslogd/syslogd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/wall/ttymsg.c ============================================================================== --- stable/11/usr.bin/wall/ttymsg.c Wed Jun 13 13:15:04 2018 (r335058) +++ stable/11/usr.bin/wall/ttymsg.c Wed Jun 13 13:41:23 2018 (r335059) @@ -59,7 +59,7 @@ static const char sccsid[] = "@(#)ttymsg.c 8.2 (Berkel const char * ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) { - struct iovec localiov[7]; + struct iovec localiov[TTYMSG_IOV_MAX]; ssize_t left, wret; int cnt, fd; char device[MAXNAMLEN] = _PATH_DEV; Modified: stable/11/usr.bin/wall/ttymsg.h ============================================================================== --- stable/11/usr.bin/wall/ttymsg.h Wed Jun 13 13:15:04 2018 (r335058) +++ stable/11/usr.bin/wall/ttymsg.h Wed Jun 13 13:41:23 2018 (r335059) @@ -1,3 +1,5 @@ /* $FreeBSD$ */ +#define TTYMSG_IOV_MAX 32 + const char *ttymsg(struct iovec *, int, const char *, int); Modified: stable/11/usr.sbin/syslogd/Makefile ============================================================================== --- stable/11/usr.sbin/syslogd/Makefile Wed Jun 13 13:15:04 2018 (r335058) +++ stable/11/usr.sbin/syslogd/Makefile Wed Jun 13 13:41:23 2018 (r335059) @@ -11,8 +11,9 @@ SRCS= syslogd.c ttymsg.c LIBADD= util -WARNS?= 3 - +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif Modified: stable/11/usr.sbin/syslogd/syslogd.8 ============================================================================== --- stable/11/usr.sbin/syslogd/syslogd.8 Wed Jun 13 13:15:04 2018 (r335058) +++ stable/11/usr.sbin/syslogd/syslogd.8 Wed Jun 13 13:41:23 2018 (r335059) @@ -28,7 +28,7 @@ .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd June 16, 2015 +.Dd April 15, 2018 .Dt SYSLOGD 8 .Os .Sh NAME @@ -36,18 +36,22 @@ .Nd log systems messages .Sh SYNOPSIS .Nm -.Op Fl 468ACcdFkNnosTuv +.Op Fl 468ACcdFHkNnosTuv .Op Fl a Ar allowed_peer .Op Fl b Ar bind_address .Op Fl f Ar config_file -.Op Fl l Oo Ar mode : Oc Ns Ar path +.Op Fl l Oo Ar mode Ns \&: Oc Ns Ar path .Op Fl m Ar mark_interval +.Op Fl O Ar format .Op Fl P Ar pid_file .Op Fl p Ar log_socket +.Op Fl S Ar logpriv_socket .Sh DESCRIPTION The .Nm -utility reads and logs messages to the system console, log files, other +utility reads and logs messages to the system console, +log files, +other machines and/or users as specified by its configuration file. .Pp The options are as follows: @@ -63,7 +67,8 @@ to use IPv6 addresses only. .It Fl 8 Tells .Nm -not to interfere with 8-bit data. Normally +not to interfere with 8-bit data. +Normally .Nm will replace C1 control characters .Pq ISO 8859 and Unicode characters @@ -98,21 +103,23 @@ options may be specified. The .Ar allowed_peer option may be any of the following: -.Bl -tag -width "ipaddr/masklen[:service]XX" +.Bl -tag -width "ipaddr[/prefixlen][:service]XX" .It Xo .Sm off .Ar ipaddr -.No / Ar masklen -.Op : Ar service +.Op / Ar masklen +.Op \&: Ar service +.Pp +.Ar ipaddr +.Op / Ar prefixlen +.Op \&: Ar service .Sm on .Xc Accept datagrams from +.Ar ipaddr , .Ar ipaddr -(in the usual dotted quad notation) with -.Ar masklen -bits being taken into account when doing the address comparison. -.Ar ipaddr -can be also IPv6 address by enclosing the address with +can be specified as an IPv4 address or as an IPv6 +address enclosed with .Ql \&[ and .Ql \&] . @@ -125,7 +132,7 @@ A .Ar service of .Ql \&* -allows packets being sent from any UDP port. +accepts UDP packets from any source port. The default .Ar service is @@ -136,16 +143,18 @@ is IPv4 address, a missing .Ar masklen will be substituted by the historic class A or class B netmasks if .Ar ipaddr -belongs into the address range of class A or B, respectively, or -by 24 otherwise. +belongs into the address range of class A or B, +respectively, +or by 24 otherwise. If .Ar ipaddr -is IPv6 address, a missing +is IPv6 address, +a missing .Ar masklen will be substituted by 128. .It Xo .Sm off -.Ar domainname Op : Ar service +.Ar domainname Op \&: Ar service .Sm on .Xc Accept datagrams where the reverse address lookup yields @@ -154,16 +163,9 @@ for the sender address. The meaning of .Ar service is as explained above. -.It Xo -.Sm off -.No * Ar domainname Op : Ar service -.Sm on -.Xc -Same as before, except that any source host whose name -.Em ends -in .Ar domainname -will get permission. +can contain special characters of a shell-style pattern such as +.Ql Li \&* . .El .Pp The @@ -174,13 +176,13 @@ option is also specified. .It Xo .Fl b .Sm off -.Ar bind_address Op : Ar service +.Ar bind_address Op \&: Ar service .Sm on .Xc .It Xo .Fl b .Sm off -.Li : Ar service +.Li \&: Ar service .Sm on .Xc Bind to a specific address and/or port. @@ -197,35 +199,40 @@ is This option can be specified multiple times to bind to multiple addresses and/or ports. .It Fl C -Create log files that do not exist (permission is set to -.Li 0600 ) . +Create log files that do not exist +.Pq permission is set to Ql Li 0600 . .It Fl c Disable the compression of repeated instances of the same line into a single line of the form .Dq Li "last message repeated N times" when the output is a pipe to another program. -If specified twice, disable this compression in all cases. +If specified twice, +disable this compression in all cases. .It Fl d Put .Nm into debugging mode. This is probably only of use to developers working on .Nm . -.It Fl f +.It Fl f Ar config_file Specify the pathname of an alternate configuration file; the default is .Pa /etc/syslog.conf . .It Fl F Run .Nm -in the foreground, rather than going into daemon mode. This is useful if -some other process uses +in the foreground, +rather than going into daemon mode. +This is useful if some other process uses .Xr fork 2 and .Xr exec 3 to run .Nm , and wants to monitor when and how it exits. +.It Fl H +When logging remote messages use hostname from the message (if supplied) +instead of using address from which the message was received. .It Fl k Disable the translation of messages received with facility @@ -236,68 +243,107 @@ Usually the .Dq kern facility is reserved for messages read directly from .Pa /dev/klog . -.It Fl m +.It Fl m Ar mark_interval Select the number of minutes between .Dq mark -messages; the default is 20 minutes. +messages; +the default is 20 minutes. .It Fl N -Disable binding on UDP sockets. RFC 3164 recommends that outgoing -syslogd messages should originate from the privileged port, this -option +Disable binding on UDP sockets. +RFC 3164 recommends that outgoing +.Nm +messages should originate from the privileged port, +this option .Em disables -the recommended behavior. This option inherits +the recommended behavior. +This option inherits .Fl s . .It Fl n -Disable dns query for every request. +Disable DNS query for every request. +.It Fl O Ar format +Select the output format of generated log messages. +The values +.Ar bsd +and +.Ar rfc3164 +are used to generate RFC 3164 log messages. +The values +.Ar syslog +and +.Ar rfc5424 +are used to generate RFC 5424 log messages, +having RFC 3339 timestamps with microsecond precision. +The default is to generate RFC 3164 log messages. .It Fl o Prefix kernel messages with the full kernel boot file as determined by .Xr getbootfile 3 . Without this, the kernel message prefix is always .Dq Li kernel: . -.It Fl p +.It Fl p Ar log_socket Specify the pathname of an alternate log socket to be used instead; the default is .Pa /var/run/log . -.It Fl P +When a single +.Fl p +option is specified, +the default pathname is replaced with the specified one. +When two or more +.Fl p +options are specified, +the remaining pathnames are treated as additional log sockets. +.It Fl P Ar pid_file Specify an alternative file in which to store the process ID. The default is .Pa /var/run/syslog.pid . -.It Fl S +.It Fl S Ar logpriv_socket Specify the pathname of an alternate log socket for privileged -applications to be used instead; the default is +applications to be used instead; +the default is .Pa /var/run/logpriv . -.It Fl l +When a single +.Fl S +option is specified, +the default pathname is replaced with the specified one. +When two or more +.Fl S +options are specified, +the remaining pathnames are treated as additional log sockets. +.It Fl l Oo Ar mode Ns \&: Oc Ns Ar path Specify a location where .Nm should place an additional log socket. The primary use for this is to place additional log sockets in .Pa /var/run/log of various chroot filespaces. -File permissions for socket can be specified in octal representation -before socket name, delimited with a colon. -Path to socket location must be absolute. +File permissions for socket can be specified in octal representation in +.Ar mode , +delimited with a colon. +The socket location must be specified as an absolute pathname in +.Ar path . .It Fl s Operate in secure mode. Do not log messages from remote machines. -If -specified twice, no network socket will be opened at all, which also -disables logging to remote machines. +If specified twice, +no network socket will be opened at all, +which also disables logging to remote machines. .It Fl T Always use the local time and date for messages received from the network, instead of the timestamp field supplied in the message by the remote host. -This is useful if some of the originating hosts can't keep time properly +This is useful if some of the originating hosts cannot keep time properly or are unable to generate a correct timestamp. .It Fl u Unique priority logging. Only log messages at the specified priority. -Without this option, messages at the stated priority or higher are logged. +Without this option, +messages at the stated priority or higher are logged. This option changes the default comparison from .Dq => to .Dq = . .It Fl v Verbose logging. -If specified once, the numeric facility and priority are +If specified once, +the numeric facility and priority are logged with each locally-written message. If specified more than once, the names of the facility and priority are logged with each locally-written @@ -324,7 +370,7 @@ from an Internet domain socket specified in .Pa /etc/services , and from the special device .Pa /dev/klog -(to read kernel messages). +.Pq to read kernel messages . .Pp The .Nm @@ -339,8 +385,10 @@ This can be used to kill or reconfigure The message sent to .Nm should consist of a single line. -The message can contain a priority code, which should be a preceding -decimal number in angle braces, for example, +The message can contain a priority code, +which should be a preceding +decimal number in angle braces, +for example, .Sq Aq 5 . This priority code should map into the priorities defined in the include file @@ -348,9 +396,10 @@ include file .Pp For security reasons, .Nm -will not append to log files that do not exist (unless -.Fl C -option is specified); +will not append to log files that do not exist +.Po unless Fl C +option is specified +.Pc ; therefore, they must be created manually before running .Nm . .Pp @@ -399,23 +448,23 @@ options are extensions. .Sh BUGS The ability to log messages received in UDP packets is equivalent to -an unauthenticated remote disk-filling service, and should probably be -disabled by default. +an unauthenticated remote disk-filling service, +and should probably be disabled by default. Some sort of .No inter- Ns Nm syslogd authentication mechanism ought to be worked out. -To prevent the worst -abuse, use of the +To prevent the worst abuse, +use of the .Fl a option is therefore highly recommended. .Pp The .Fl a -matching algorithm does not pretend to be very efficient; use of numeric -IP addresses is faster than domain name comparison. -Since the allowed -peer list is being walked linearly, peer groups where frequent messages -are being anticipated from should be put early into the +matching algorithm does not pretend to be very efficient; +use of numeric IP addresses is faster than domain name comparison. +Since the allowed peer list is being walked linearly, +peer groups where frequent messages are being anticipated +from should be put early into the .Fl a list. .Pp Modified: stable/11/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/11/usr.sbin/syslogd/syslogd.c Wed Jun 13 13:15:04 2018 (r335058) +++ stable/11/usr.sbin/syslogd/syslogd.c Wed Jun 13 13:41:23 2018 (r335059) @@ -26,6 +26,33 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/ + * Author: Ed Schouten + * + * 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. + */ #ifndef lint static const char copyright[] = @@ -69,8 +96,7 @@ __FBSDID("$FreeBSD$"); */ /* Maximum number of characters in time of last occurrence */ -#define MAXDATELEN 16 -#define MAXLINE 1024 /* maximum line length */ +#define MAXLINE 2048 /* maximum line length */ #define MAXSVLINE MAXLINE /* maximum saved line length */ #define DEFUPRI (LOG_USER|LOG_NOTICE) #define DEFSPRI (LOG_KERN|LOG_CRIT) @@ -90,21 +116,25 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#if defined(INET) || defined(INET6) #include -#include #include +#endif +#include #include #include #include #include #include +#include #include #include +#include #include #include +#include #include #include #include @@ -118,54 +148,69 @@ __FBSDID("$FreeBSD$"); #define SYSLOG_NAMES #include -const char *ConfFile = _PATH_LOGCONF; -const char *PidFile = _PATH_LOGPID; -const char ctty[] = _PATH_CONSOLE; -static const char include_str[] = "include"; -static const char include_ext[] = ".conf"; +static const char *ConfFile = _PATH_LOGCONF; +static const char *PidFile = _PATH_LOGPID; +static const char ctty[] = _PATH_CONSOLE; +static const char include_str[] = "include"; +static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf #define MAXUNAMES 20 /* maximum number of user names */ +#define sstosa(ss) ((struct sockaddr *)(ss)) +#ifdef INET +#define sstosin(ss) ((struct sockaddr_in *)(void *)(ss)) +#define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) +#endif +#ifdef INET6 +#define sstosin6(ss) ((struct sockaddr_in6 *)(void *)(ss)) +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) +#define s6_addr32 __u6_addr.__u6_addr32 +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) +#endif /* - * List of hosts for binding. + * List of peers and sockets for binding. */ -static STAILQ_HEAD(, host) hqueue; -struct host { - char *name; - STAILQ_ENTRY(host) next; +struct peer { + const char *pe_name; + const char *pe_serv; + mode_t pe_mode; + STAILQ_ENTRY(peer) next; }; +static STAILQ_HEAD(, peer) pqueue = STAILQ_HEAD_INITIALIZER(pqueue); -/* - * Unix sockets. - * We have two default sockets, one with 666 permissions, - * and one for privileged programs. - */ -struct funix { - int s; - const char *name; - mode_t mode; - STAILQ_ENTRY(funix) next; +struct socklist { + struct sockaddr_storage sl_ss; + int sl_socket; + struct peer *sl_peer; + int (*sl_recv)(struct socklist *); + STAILQ_ENTRY(socklist) next; }; -struct funix funix_secure = { -1, _PATH_LOG_PRIV, S_IRUSR | S_IWUSR, - { NULL } }; -struct funix funix_default = { -1, _PATH_LOG, DEFFILEMODE, - { &funix_secure } }; +static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); -STAILQ_HEAD(, funix) funixes = { &funix_default, - &(funix_secure.next.stqe_next) }; - /* * Flags to logmsg(). */ #define IGN_CONS 0x001 /* don't print on console */ #define SYNC_FILE 0x002 /* do fsync on file after printing */ -#define ADDDATE 0x004 /* add a date to the message */ #define MARK 0x008 /* this message is a mark */ -#define ISKERNEL 0x010 /* kernel generated message */ +/* Timestamps of log entries. */ +struct logtime { + struct tm tm; + suseconds_t usec; +}; + +/* Traditional syslog timestamp format. */ +#define RFC3164_DATELEN 15 +#define RFC3164_DATEFMT "%b %e %H:%M:%S" + /* * This structure represents the files that will have log * copies printed. @@ -174,7 +219,7 @@ STAILQ_HEAD(, funix) funixes = { &funix_default, */ struct filed { - struct filed *f_next; /* next in linked list */ + STAILQ_ENTRY(filed) next; /* next in linked list */ short f_type; /* entry type, see below */ short f_file; /* file descriptor */ time_t f_time; /* time this was last written */ @@ -198,11 +243,16 @@ struct filed { pid_t f_pid; } f_pipe; } f_un; +#define fu_uname f_un.f_uname +#define fu_forw_hname f_un.f_forw.f_hname +#define fu_forw_addr f_un.f_forw.f_addr +#define fu_fname f_un.f_fname +#define fu_pipe_pname f_un.f_pipe.f_pname +#define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ - char f_lasttime[MAXDATELEN]; /* time of last occurrence */ - char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ + struct logtime f_lasttime; /* time of last occurrence */ int f_prevpri; /* pri of f_prevline */ - int f_prevlen; /* length of f_prevline */ + size_t f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ u_int f_repeatcount; /* number of "repeated" msgs */ int f_flags; /* file-specific flags */ @@ -213,15 +263,13 @@ struct filed { /* * Queue of about-to-be dead processes we should watch out for. */ - -TAILQ_HEAD(stailhead, deadq_entry) deadq_head; -struct stailhead *deadq_headp; - struct deadq_entry { pid_t dq_pid; int dq_timeout; TAILQ_ENTRY(deadq_entry) dq_entries; }; +static TAILQ_HEAD(, deadq_entry) deadq_head = + TAILQ_HEAD_INITIALIZER(deadq_head); /* * The timeout to apply to processes waiting on the dead queue. Unit @@ -231,9 +279,6 @@ struct deadq_entry { #define DQ_TIMO_INIT 2 -typedef struct deadq_entry *dq_t; - - /* * Struct to hold records of network addresses that are allowed to log * to us. @@ -251,7 +296,9 @@ struct allowedpeer { #define a_addr u.numeric.addr #define a_mask u.numeric.mask #define a_name u.name + STAILQ_ENTRY(allowedpeer) next; }; +static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); /* @@ -259,12 +306,13 @@ struct allowedpeer { * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ -#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) +static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ +#define MAXREPEAT (nitems(repeatinterval) - 1) #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) -#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ - (f)->f_repeatcount = MAXREPEAT; \ - } +#define BACKOFF(f) do { \ + if (++(f)->f_repeatcount > MAXREPEAT) \ + (f)->f_repeatcount = MAXREPEAT; \ + } while (0) /* values for f_type */ #define F_UNUSED 0 /* unused entry */ @@ -276,12 +324,13 @@ int repeatinterval[] = { 30, 120, 600 }; /* # of secs #define F_WALL 6 /* everyone logged on */ #define F_PIPE 7 /* pipe to program */ -const char *TypeNames[8] = { +static const char *TypeNames[] = { "UNUSED", "FILE", "TTY", "CONSOLE", "FORW", "USERS", "WALL", "PIPE" }; -static struct filed *Files; /* Log files that we write to */ +static STAILQ_HEAD(, filed) fhead = + STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */ static struct filed consfile; /* Console */ static int Debug; /* debug flag */ @@ -289,8 +338,6 @@ static int Foreground = 0; /* Run in foreground, inste static int resolve = 1; /* resolve hostname */ static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ static const char *LocalDomain; /* our local domain name */ -static int *finet; /* Internet datagram sockets */ -static int fklog = -1; /* /dev/klog */ static int Initialized; /* set when we have initialized ourselves */ static int MarkInterval = 20 * 60; /* interval between marks in seconds */ static int MarkSeq; /* mark sequence number */ @@ -309,9 +356,8 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used static char bootfile[MAXLINE+1]; /* booted kernel file */ -struct allowedpeer *AllowedPeers; /* List of allowed peers */ -static int NumAllowed; /* Number of entries in AllowedPeers */ static int RemoteAddDate; /* Always set the date on remote messages */ +static int RemoteHostname; /* Log remote hostname from the message */ static int UniquePriority; /* Only log specified priority? */ static int LogFacPri; /* Put facility and priority in log message: */ @@ -319,39 +365,53 @@ static int LogFacPri; /* Put facility and priority in static int KeepKernFac; /* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; +static int sigpipe[2]; /* Pipe to catch a signal during select(). */ +static bool RFC3164OutputFormat = true; /* Use legacy format by default. */ -volatile sig_atomic_t MarkSet, WantDie; +static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild; +struct iovlist; + static int allowaddr(char *); -static void cfline(const char *, struct filed *, - const char *, const char *); +static int addfile(struct filed *); +static int addpeer(struct peer *); +static int addsock(struct sockaddr *, socklen_t, struct socklist *); +static struct filed *cfline(const char *, const char *, const char *); static const char *cvthname(struct sockaddr *); static void deadq_enter(pid_t, const char *); -static int deadq_remove(pid_t); +static int deadq_remove(struct deadq_entry *); +static int deadq_removebypid(pid_t); static int decode(const char *, const CODE *); static void die(int) __dead2; static void dodie(int); static void dofsync(void); static void domark(int); -static void fprintlog(struct filed *, int, const char *); -static int *socksetup(int, char *); +static void fprintlog_first(struct filed *, const char *, const char *, + const char *, const char *, const char *, const char *, int); +static void fprintlog_write(struct filed *, struct iovlist *, int); +static void fprintlog_successive(struct filed *, int); static void init(int); static void logerror(const char *); -static void logmsg(int, const char *, const char *, int); +static void logmsg(int, const struct logtime *, const char *, const char *, + const char *, const char *, const char *, const char *, int); static void log_deadchild(pid_t, int, const char *); static void markit(void); +static int socksetup(struct peer *); +static int socklist_recv_file(struct socklist *); +static int socklist_recv_sock(struct socklist *); +static int socklist_recv_signal(struct socklist *); +static void sighandler(int); static int skip_message(const char *, const char *, int); -static void printline(const char *, char *, int); +static void parsemsg(const char *, char *); static void printsys(char *); static int p_open(const char *, pid_t *); -static void readklog(void); static void reapchild(int); static const char *ttymsg_check(struct iovec *, int, char *, int); static void usage(void); static int validate(struct sockaddr *, const char *); static void unmapped(struct sockaddr *); static void wallmsg(struct filed *, struct iovec *, const int iovlen); -static int waitdaemon(int, int, int); +static int waitdaemon(int); static void timedout(int); static void increase_rcvbuf(int); @@ -364,11 +424,11 @@ close_filed(struct filed *f) switch (f->f_type) { case F_FORW: - if (f->f_un.f_forw.f_addr) { - freeaddrinfo(f->f_un.f_forw.f_addr); - f->f_un.f_forw.f_addr = NULL; - } - /*FALLTHROUGH*/ + if (f->f_un.f_forw.f_addr) { + freeaddrinfo(f->f_un.f_forw.f_addr); + f->f_un.f_forw.f_addr = NULL; + } + /* FALLTHROUGH */ case F_FILE: case F_TTY: @@ -376,41 +436,79 @@ close_filed(struct filed *f) f->f_type = F_UNUSED; break; case F_PIPE: - f->f_un.f_pipe.f_pid = 0; + f->fu_pipe_pid = 0; break; } (void)close(f->f_file); f->f_file = -1; } +static int +addfile(struct filed *f0) +{ + struct filed *f; + + f = calloc(1, sizeof(*f)); + if (f == NULL) + err(1, "malloc failed"); + *f = *f0; + STAILQ_INSERT_TAIL(&fhead, f, next); + + return (0); +} + +static int +addpeer(struct peer *pe0) +{ + struct peer *pe; + + pe = calloc(1, sizeof(*pe)); + if (pe == NULL) + err(1, "malloc failed"); + *pe = *pe0; + STAILQ_INSERT_TAIL(&pqueue, pe, next); + + return (0); +} + +static int +addsock(struct sockaddr *sa, socklen_t sa_len, struct socklist *sl0) +{ + struct socklist *sl; + + sl = calloc(1, sizeof(*sl)); + if (sl == NULL) + err(1, "malloc failed"); + *sl = *sl0; + if (sa != NULL && sa_len > 0) + memcpy(&sl->sl_ss, sa, sa_len); + STAILQ_INSERT_TAIL(&shead, sl, next); + + return (0); +} + int main(int argc, char *argv[]) { - int ch, i, fdsrmax = 0, l; - struct sockaddr_un sunx, fromunix; - struct sockaddr_storage frominet; + int ch, i, s, fdsrmax = 0, bflag = 0, pflag = 0, Sflag = 0; fd_set *fdsr = NULL; - char line[MAXLINE + 1]; - const char *hname; struct timeval tv, *tvp; - struct sigaction sact; - struct host *host; - struct funix *fx, *fx1; - sigset_t mask; + struct peer *pe; + struct socklist *sl; pid_t ppid = 1, spid; - socklen_t len; + char *p; if (madvise(NULL, 0, MADV_PROTECT) != 0) dprintf("madvise() failed: %s\n", strerror(errno)); - STAILQ_INIT(&hqueue); - - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:m:nNoO:p:P:sS:Tuv")) != -1) switch (ch) { +#ifdef INET case '4': family = PF_INET; break; +#endif #ifdef INET6 case '6': family = PF_INET6; @@ -427,13 +525,31 @@ main(int argc, char *argv[]) usage(); break; case 'b': - { - if ((host = malloc(sizeof(struct host))) == NULL) - err(1, "malloc failed"); - host->name = optarg; - STAILQ_INSERT_TAIL(&hqueue, host, next); + bflag = 1; + p = strchr(optarg, ']'); + if (p != NULL) + p = strchr(p + 1, ':'); + else { + p = strchr(optarg, ':'); + if (p != NULL && strchr(p + 1, ':') != NULL) + p = NULL; /* backward compatibility */ + } + if (p == NULL) { + /* A hostname or filename only. */ + addpeer(&(struct peer){ + .pe_name = optarg, + .pe_serv = "syslog" + }); + } else { + /* The case of "name:service". */ + *p++ = '\0'; + addpeer(&(struct peer){ + .pe_serv = p, + .pe_name = (strlen(optarg) == 0) ? + NULL : optarg, + }); + } break; - } case 'c': no_compress++; break; @@ -449,19 +565,32 @@ main(int argc, char *argv[]) case 'F': /* run in foreground instead of daemon */ Foreground++; break; + case 'H': + RemoteHostname = 1; + break; case 'k': /* keep remote kern fac */ KeepKernFac = 1; break; case 'l': + case 'p': + case 'S': { long perml; mode_t mode; char *name, *ep; - if (optarg[0] == '/') { + if (ch == 'l') mode = DEFFILEMODE; + else if (ch == 'p') { + mode = DEFFILEMODE; + pflag = 1; + } else { + mode = S_IRUSR | S_IWUSR; + Sflag = 1; + } + if (optarg[0] == '/') name = optarg; - } else if ((name = strchr(optarg, ':')) != NULL) { + else if ((name = strchr(optarg, ':')) != NULL) { *name++ = '\0'; if (name[0] != '/') errx(1, "socket name must be absolute " @@ -476,17 +605,13 @@ main(int argc, char *argv[]) } else errx(1, "invalid mode %s, exiting", optarg); - } else /* doesn't begin with '/', and no ':' */ - errx(1, "can't parse path %s", optarg); - - if (strlen(name) >= sizeof(sunx.sun_path)) - errx(1, "%s path too long, exiting", name); - if ((fx = malloc(sizeof(struct funix))) == NULL) - err(1, "malloc failed"); - fx->s = -1; - fx->name = name; - fx->mode = mode; - STAILQ_INSERT_TAIL(&funixes, fx, next); + } else + errx(1, "invalid filename %s, exiting", + optarg); + addpeer(&(struct peer){ + .pe_name = name, + .pe_mode = mode + }); break; } case 'm': /* mark interval */ @@ -499,25 +624,25 @@ main(int argc, char *argv[]) case 'n': resolve = 0; break; + case 'O': + if (strcmp(optarg, "bsd") == 0 || + strcmp(optarg, "rfc3164") == 0) + RFC3164OutputFormat = true; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Wed Jun 13 13:57:36 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26449100DD26; Wed, 13 Jun 2018 13:57:36 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.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 0414884911; Wed, 13 Jun 2018 13:57:34 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w5DDvQm1039746; Wed, 13 Jun 2018 06:57:26 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w5DDvQw8039745; Wed, 13 Jun 2018 06:57:26 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201806131357.w5DDvQw8039745@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r335059 - in stable/11: usr.bin/wall usr.sbin/syslogd In-Reply-To: <201806131341.w5DDfN7T043988@repo.freebsd.org> To: Ed Schouten Date: Wed, 13 Jun 2018 06:57:26 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@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-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 13:57:36 -0000 > Author: ed > Date: Wed Jun 13 13:41:23 2018 > New Revision: 335059 > URL: https://svnweb.freebsd.org/changeset/base/335059 > > Log: > MFC r309925, r309931, r309933, r310035, r310278, r310310, r310311, > r310323, r310349, r310350, r310351, r310352, r310383, r310384, > r310385, r310386, r310393, r310453, r310456, r310494, r310504, > r310528, r310890, r310893, r310974, r311918, r312921, r313357, > r314563, r314585, r314642, r315322, r315618, r315620, r315622, > r315643, r316951, r316973, r326338, r326339, r326573, r331270, > r332099, r332110, r332111, r332118, r332165, r332510 and r332511. > > This commit brings syslogd(8) in sync with the copy in HEAD. The key > improvement of this change is that it adds support for RFC 5424 log > ingestion and exposition (enabled by passing in -O rfc5424). This allows > for saner logging in environments with multiple time zones. > > The list of changes to merge back were obtained by running: > > svn mergeinfo --show-revs eligible \ > ^/head/usr.sbin/syslogd ^/stable/11/usr.sbin/syslogd > > Of the commits listed, r314436, r325188 and r326025 were excluded, as > they affect a significant number of unrelated files (SPDX and 4-clause > license renumbering). Due to the large number of directly committed Thank you very much for avoiding the SPDX area! I have pending clean up in stable/11 around those. > changes on this branch, I had no choice but to perform the merge as > follows: > > svn merge --accept=theirs-full -c ^/head . > > This would, however, cause some unrelated changes, such as undoing the > r333356 (MFC of r332877) and still adding the SPDX tag to syslogd.c. > These have been reverted manually. > > Requested by: Dave Cottlehuber > Thanks to: dim@ for sharing his insight on hackers@ > > Modified: > stable/11/usr.bin/wall/ttymsg.c > stable/11/usr.bin/wall/ttymsg.h I see no mention of any changes to wall in the commit, was this intentional? The changes don't seem to be related to syslogd directly. > stable/11/usr.sbin/syslogd/Makefile > stable/11/usr.sbin/syslogd/syslogd.8 > stable/11/usr.sbin/syslogd/syslogd.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/usr.bin/wall/ttymsg.c > ============================================================================== > --- stable/11/usr.bin/wall/ttymsg.c Wed Jun 13 13:15:04 2018 (r335058) > +++ stable/11/usr.bin/wall/ttymsg.c Wed Jun 13 13:41:23 2018 (r335059) > @@ -59,7 +59,7 @@ static const char sccsid[] = "@(#)ttymsg.c 8.2 (Berkel > const char * > ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout) > { > - struct iovec localiov[7]; > + struct iovec localiov[TTYMSG_IOV_MAX]; > ssize_t left, wret; > int cnt, fd; > char device[MAXNAMLEN] = _PATH_DEV; > > Modified: stable/11/usr.bin/wall/ttymsg.h > ============================================================================== > --- stable/11/usr.bin/wall/ttymsg.h Wed Jun 13 13:15:04 2018 (r335058) > +++ stable/11/usr.bin/wall/ttymsg.h Wed Jun 13 13:41:23 2018 (r335059) > @@ -1,3 +1,5 @@ > /* $FreeBSD$ */ > > +#define TTYMSG_IOV_MAX 32 > + > const char *ttymsg(struct iovec *, int, const char *, int); > > Modified: stable/11/usr.sbin/syslogd/Makefile > ============================================================================== > --- stable/11/usr.sbin/syslogd/Makefile Wed Jun 13 13:15:04 2018 (r335058) > +++ stable/11/usr.sbin/syslogd/Makefile Wed Jun 13 13:41:23 2018 (r335059) > @@ -11,8 +11,9 @@ SRCS= syslogd.c ttymsg.c > > LIBADD= util > > -WARNS?= 3 > - > +.if ${MK_INET_SUPPORT} != "no" > +CFLAGS+= -DINET > +.endif > .if ${MK_INET6_SUPPORT} != "no" > CFLAGS+= -DINET6 > .endif > > Modified: stable/11/usr.sbin/syslogd/syslogd.8 > ============================================================================== > --- stable/11/usr.sbin/syslogd/syslogd.8 Wed Jun 13 13:15:04 2018 (r335058) > +++ stable/11/usr.sbin/syslogd/syslogd.8 Wed Jun 13 13:41:23 2018 (r335059) > @@ -28,7 +28,7 @@ > .\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93 > .\" $FreeBSD$ > .\" > -.Dd June 16, 2015 > +.Dd April 15, 2018 > .Dt SYSLOGD 8 > .Os > .Sh NAME > @@ -36,18 +36,22 @@ > .Nd log systems messages > .Sh SYNOPSIS > .Nm > -.Op Fl 468ACcdFkNnosTuv > +.Op Fl 468ACcdFHkNnosTuv > .Op Fl a Ar allowed_peer > .Op Fl b Ar bind_address > .Op Fl f Ar config_file > -.Op Fl l Oo Ar mode : Oc Ns Ar path > +.Op Fl l Oo Ar mode Ns \&: Oc Ns Ar path > .Op Fl m Ar mark_interval > +.Op Fl O Ar format > .Op Fl P Ar pid_file > .Op Fl p Ar log_socket > +.Op Fl S Ar logpriv_socket > .Sh DESCRIPTION > The > .Nm > -utility reads and logs messages to the system console, log files, other > +utility reads and logs messages to the system console, > +log files, > +other > machines and/or users as specified by its configuration file. > .Pp > The options are as follows: > @@ -63,7 +67,8 @@ to use IPv6 addresses only. > .It Fl 8 > Tells > .Nm > -not to interfere with 8-bit data. Normally > +not to interfere with 8-bit data. > +Normally > .Nm > will replace C1 control characters > .Pq ISO 8859 and Unicode characters > @@ -98,21 +103,23 @@ options may be specified. > The > .Ar allowed_peer > option may be any of the following: > -.Bl -tag -width "ipaddr/masklen[:service]XX" > +.Bl -tag -width "ipaddr[/prefixlen][:service]XX" > .It Xo > .Sm off > .Ar ipaddr > -.No / Ar masklen > -.Op : Ar service > +.Op / Ar masklen > +.Op \&: Ar service > +.Pp > +.Ar ipaddr > +.Op / Ar prefixlen > +.Op \&: Ar service > .Sm on > .Xc > Accept datagrams from > +.Ar ipaddr , > .Ar ipaddr > -(in the usual dotted quad notation) with > -.Ar masklen > -bits being taken into account when doing the address comparison. > -.Ar ipaddr > -can be also IPv6 address by enclosing the address with > +can be specified as an IPv4 address or as an IPv6 > +address enclosed with > .Ql \&[ > and > .Ql \&] . > @@ -125,7 +132,7 @@ A > .Ar service > of > .Ql \&* > -allows packets being sent from any UDP port. > +accepts UDP packets from any source port. > The default > .Ar service > is > @@ -136,16 +143,18 @@ is IPv4 address, a missing > .Ar masklen > will be substituted by the historic class A or class B netmasks if > .Ar ipaddr > -belongs into the address range of class A or B, respectively, or > -by 24 otherwise. > +belongs into the address range of class A or B, > +respectively, > +or by 24 otherwise. > If > .Ar ipaddr > -is IPv6 address, a missing > +is IPv6 address, > +a missing > .Ar masklen > will be substituted by 128. > .It Xo > .Sm off > -.Ar domainname Op : Ar service > +.Ar domainname Op \&: Ar service > .Sm on > .Xc > Accept datagrams where the reverse address lookup yields > @@ -154,16 +163,9 @@ for the sender address. > The meaning of > .Ar service > is as explained above. > -.It Xo > -.Sm off > -.No * Ar domainname Op : Ar service > -.Sm on > -.Xc > -Same as before, except that any source host whose name > -.Em ends > -in > .Ar domainname > -will get permission. > +can contain special characters of a shell-style pattern such as > +.Ql Li \&* . > .El > .Pp > The > @@ -174,13 +176,13 @@ option is also specified. > .It Xo > .Fl b > .Sm off > -.Ar bind_address Op : Ar service > +.Ar bind_address Op \&: Ar service > .Sm on > .Xc > .It Xo > .Fl b > .Sm off > -.Li : Ar service > +.Li \&: Ar service > .Sm on > .Xc > Bind to a specific address and/or port. > @@ -197,35 +199,40 @@ is > This option can be specified multiple times to bind to > multiple addresses and/or ports. > .It Fl C > -Create log files that do not exist (permission is set to > -.Li 0600 ) . > +Create log files that do not exist > +.Pq permission is set to Ql Li 0600 . > .It Fl c > Disable the compression of repeated instances of the same line > into a single line of the form > .Dq Li "last message repeated N times" > when the output is a pipe to another program. > -If specified twice, disable this compression in all cases. > +If specified twice, > +disable this compression in all cases. > .It Fl d > Put > .Nm > into debugging mode. > This is probably only of use to developers working on > .Nm . > -.It Fl f > +.It Fl f Ar config_file > Specify the pathname of an alternate configuration file; > the default is > .Pa /etc/syslog.conf . > .It Fl F > Run > .Nm > -in the foreground, rather than going into daemon mode. This is useful if > -some other process uses > +in the foreground, > +rather than going into daemon mode. > +This is useful if some other process uses > .Xr fork 2 > and > .Xr exec 3 > to run > .Nm , > and wants to monitor when and how it exits. > +.It Fl H > +When logging remote messages use hostname from the message (if supplied) > +instead of using address from which the message was received. > .It Fl k > Disable the translation of > messages received with facility > @@ -236,68 +243,107 @@ Usually the > .Dq kern > facility is reserved for messages read directly from > .Pa /dev/klog . > -.It Fl m > +.It Fl m Ar mark_interval > Select the number of minutes between > .Dq mark > -messages; the default is 20 minutes. > +messages; > +the default is 20 minutes. > .It Fl N > -Disable binding on UDP sockets. RFC 3164 recommends that outgoing > -syslogd messages should originate from the privileged port, this > -option > +Disable binding on UDP sockets. > +RFC 3164 recommends that outgoing > +.Nm > +messages should originate from the privileged port, > +this option > .Em disables > -the recommended behavior. This option inherits > +the recommended behavior. > +This option inherits > .Fl s . > .It Fl n > -Disable dns query for every request. > +Disable DNS query for every request. > +.It Fl O Ar format > +Select the output format of generated log messages. > +The values > +.Ar bsd > +and > +.Ar rfc3164 > +are used to generate RFC 3164 log messages. > +The values > +.Ar syslog > +and > +.Ar rfc5424 > +are used to generate RFC 5424 log messages, > +having RFC 3339 timestamps with microsecond precision. > +The default is to generate RFC 3164 log messages. > .It Fl o > Prefix kernel messages with the full kernel boot file as determined by > .Xr getbootfile 3 . > Without this, the kernel message prefix is always > .Dq Li kernel: . > -.It Fl p > +.It Fl p Ar log_socket > Specify the pathname of an alternate log socket to be used instead; > the default is > .Pa /var/run/log . > -.It Fl P > +When a single > +.Fl p > +option is specified, > +the default pathname is replaced with the specified one. > +When two or more > +.Fl p > +options are specified, > +the remaining pathnames are treated as additional log sockets. > +.It Fl P Ar pid_file > Specify an alternative file in which to store the process ID. > The default is > .Pa /var/run/syslog.pid . > -.It Fl S > +.It Fl S Ar logpriv_socket > Specify the pathname of an alternate log socket for privileged > -applications to be used instead; the default is > +applications to be used instead; > +the default is > .Pa /var/run/logpriv . > -.It Fl l > +When a single > +.Fl S > +option is specified, > +the default pathname is replaced with the specified one. > +When two or more > +.Fl S > +options are specified, > +the remaining pathnames are treated as additional log sockets. > +.It Fl l Oo Ar mode Ns \&: Oc Ns Ar path > Specify a location where > .Nm > should place an additional log socket. > The primary use for this is to place additional log sockets in > .Pa /var/run/log > of various chroot filespaces. > -File permissions for socket can be specified in octal representation > -before socket name, delimited with a colon. > -Path to socket location must be absolute. > +File permissions for socket can be specified in octal representation in > +.Ar mode , > +delimited with a colon. > +The socket location must be specified as an absolute pathname in > +.Ar path . > .It Fl s > Operate in secure mode. > Do not log messages from remote machines. > -If > -specified twice, no network socket will be opened at all, which also > -disables logging to remote machines. > +If specified twice, > +no network socket will be opened at all, > +which also disables logging to remote machines. > .It Fl T > Always use the local time and date for messages received from the network, > instead of the timestamp field supplied in the message by the remote host. > -This is useful if some of the originating hosts can't keep time properly > +This is useful if some of the originating hosts cannot keep time properly > or are unable to generate a correct timestamp. > .It Fl u > Unique priority logging. > Only log messages at the specified priority. > -Without this option, messages at the stated priority or higher are logged. > +Without this option, > +messages at the stated priority or higher are logged. > This option changes the default comparison from > .Dq => > to > .Dq = . > .It Fl v > Verbose logging. > -If specified once, the numeric facility and priority are > +If specified once, > +the numeric facility and priority are > logged with each locally-written message. > If specified more than once, > the names of the facility and priority are logged with each locally-written > @@ -324,7 +370,7 @@ from an Internet domain socket specified in > .Pa /etc/services , > and from the special device > .Pa /dev/klog > -(to read kernel messages). > +.Pq to read kernel messages . > .Pp > The > .Nm > @@ -339,8 +385,10 @@ This can be used to kill or reconfigure > The message sent to > .Nm > should consist of a single line. > -The message can contain a priority code, which should be a preceding > -decimal number in angle braces, for example, > +The message can contain a priority code, > +which should be a preceding > +decimal number in angle braces, > +for example, > .Sq Aq 5 . > This priority code should map into the priorities defined in the > include file > @@ -348,9 +396,10 @@ include file > .Pp > For security reasons, > .Nm > -will not append to log files that do not exist (unless > -.Fl C > -option is specified); > +will not append to log files that do not exist > +.Po unless Fl C > +option is specified > +.Pc ; > therefore, they must be created manually before running > .Nm . > .Pp > @@ -399,23 +448,23 @@ options are > extensions. > .Sh BUGS > The ability to log messages received in UDP packets is equivalent to > -an unauthenticated remote disk-filling service, and should probably be > -disabled by default. > +an unauthenticated remote disk-filling service, > +and should probably be disabled by default. > Some sort of > .No inter- Ns Nm syslogd > authentication mechanism ought to be worked out. > -To prevent the worst > -abuse, use of the > +To prevent the worst abuse, > +use of the > .Fl a > option is therefore highly recommended. > .Pp > The > .Fl a > -matching algorithm does not pretend to be very efficient; use of numeric > -IP addresses is faster than domain name comparison. > -Since the allowed > -peer list is being walked linearly, peer groups where frequent messages > -are being anticipated from should be put early into the > +matching algorithm does not pretend to be very efficient; > +use of numeric IP addresses is faster than domain name comparison. > +Since the allowed peer list is being walked linearly, > +peer groups where frequent messages are being anticipated > +from should be put early into the > .Fl a > list. > .Pp > > Modified: stable/11/usr.sbin/syslogd/syslogd.c > ============================================================================== > --- stable/11/usr.sbin/syslogd/syslogd.c Wed Jun 13 13:15:04 2018 (r335058) > +++ stable/11/usr.sbin/syslogd/syslogd.c Wed Jun 13 13:41:23 2018 (r335059) > @@ -26,6 +26,33 @@ > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > */ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/ > + * Author: Ed Schouten > + * > + * 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. > + */ > > #ifndef lint > static const char copyright[] = > @@ -69,8 +96,7 @@ __FBSDID("$FreeBSD$"); > */ > > /* Maximum number of characters in time of last occurrence */ > -#define MAXDATELEN 16 > -#define MAXLINE 1024 /* maximum line length */ > +#define MAXLINE 2048 /* maximum line length */ > #define MAXSVLINE MAXLINE /* maximum saved line length */ > #define DEFUPRI (LOG_USER|LOG_NOTICE) > #define DEFSPRI (LOG_KERN|LOG_CRIT) > @@ -90,21 +116,25 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > -#include > > +#if defined(INET) || defined(INET6) > #include > -#include > #include > +#endif > > +#include > #include > #include > #include > #include > #include > +#include > #include > #include > +#include > #include > #include > +#include > #include > #include > #include > @@ -118,54 +148,69 @@ __FBSDID("$FreeBSD$"); > #define SYSLOG_NAMES > #include > > -const char *ConfFile = _PATH_LOGCONF; > -const char *PidFile = _PATH_LOGPID; > -const char ctty[] = _PATH_CONSOLE; > -static const char include_str[] = "include"; > -static const char include_ext[] = ".conf"; > +static const char *ConfFile = _PATH_LOGCONF; > +static const char *PidFile = _PATH_LOGPID; > +static const char ctty[] = _PATH_CONSOLE; > +static const char include_str[] = "include"; > +static const char include_ext[] = ".conf"; > > #define dprintf if (Debug) printf > > #define MAXUNAMES 20 /* maximum number of user names */ > > +#define sstosa(ss) ((struct sockaddr *)(ss)) > +#ifdef INET > +#define sstosin(ss) ((struct sockaddr_in *)(void *)(ss)) > +#define satosin(sa) ((struct sockaddr_in *)(void *)(sa)) > +#endif > +#ifdef INET6 > +#define sstosin6(ss) ((struct sockaddr_in6 *)(void *)(ss)) > +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)(sa)) > +#define s6_addr32 __u6_addr.__u6_addr32 > +#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ > + (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \ > + (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \ > + (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \ > + (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 ) > +#endif > /* > - * List of hosts for binding. > + * List of peers and sockets for binding. > */ > -static STAILQ_HEAD(, host) hqueue; > -struct host { > - char *name; > - STAILQ_ENTRY(host) next; > +struct peer { > + const char *pe_name; > + const char *pe_serv; > + mode_t pe_mode; > + STAILQ_ENTRY(peer) next; > }; > +static STAILQ_HEAD(, peer) pqueue = STAILQ_HEAD_INITIALIZER(pqueue); > > -/* > - * Unix sockets. > - * We have two default sockets, one with 666 permissions, > - * and one for privileged programs. > - */ > -struct funix { > - int s; > - const char *name; > - mode_t mode; > - STAILQ_ENTRY(funix) next; > +struct socklist { > + struct sockaddr_storage sl_ss; > + int sl_socket; > + struct peer *sl_peer; > + int (*sl_recv)(struct socklist *); > + STAILQ_ENTRY(socklist) next; > }; > -struct funix funix_secure = { -1, _PATH_LOG_PRIV, S_IRUSR | S_IWUSR, > - { NULL } }; > -struct funix funix_default = { -1, _PATH_LOG, DEFFILEMODE, > - { &funix_secure } }; > +static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INITIALIZER(shead); > > -STAILQ_HEAD(, funix) funixes = { &funix_default, > - &(funix_secure.next.stqe_next) }; > - > /* > * Flags to logmsg(). > */ > > #define IGN_CONS 0x001 /* don't print on console */ > #define SYNC_FILE 0x002 /* do fsync on file after printing */ > -#define ADDDATE 0x004 /* add a date to the message */ > #define MARK 0x008 /* this message is a mark */ > -#define ISKERNEL 0x010 /* kernel generated message */ > > +/* Timestamps of log entries. */ > +struct logtime { > + struct tm tm; > + suseconds_t usec; > +}; > + > +/* Traditional syslog timestamp format. */ > +#define RFC3164_DATELEN 15 > +#define RFC3164_DATEFMT "%b %e %H:%M:%S" > + > /* > * This structure represents the files that will have log > * copies printed. > @@ -174,7 +219,7 @@ STAILQ_HEAD(, funix) funixes = { &funix_default, > */ > > struct filed { > - struct filed *f_next; /* next in linked list */ > + STAILQ_ENTRY(filed) next; /* next in linked list */ > short f_type; /* entry type, see below */ > short f_file; /* file descriptor */ > time_t f_time; /* time this was last written */ > @@ -198,11 +243,16 @@ struct filed { > pid_t f_pid; > } f_pipe; > } f_un; > +#define fu_uname f_un.f_uname > +#define fu_forw_hname f_un.f_forw.f_hname > +#define fu_forw_addr f_un.f_forw.f_addr > +#define fu_fname f_un.f_fname > +#define fu_pipe_pname f_un.f_pipe.f_pname > +#define fu_pipe_pid f_un.f_pipe.f_pid > char f_prevline[MAXSVLINE]; /* last message logged */ > - char f_lasttime[MAXDATELEN]; /* time of last occurrence */ > - char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ > + struct logtime f_lasttime; /* time of last occurrence */ > int f_prevpri; /* pri of f_prevline */ > - int f_prevlen; /* length of f_prevline */ > + size_t f_prevlen; /* length of f_prevline */ > int f_prevcount; /* repetition cnt of prevline */ > u_int f_repeatcount; /* number of "repeated" msgs */ > int f_flags; /* file-specific flags */ > @@ -213,15 +263,13 @@ struct filed { > /* > * Queue of about-to-be dead processes we should watch out for. > */ > - > -TAILQ_HEAD(stailhead, deadq_entry) deadq_head; > -struct stailhead *deadq_headp; > - > struct deadq_entry { > pid_t dq_pid; > int dq_timeout; > TAILQ_ENTRY(deadq_entry) dq_entries; > }; > +static TAILQ_HEAD(, deadq_entry) deadq_head = > + TAILQ_HEAD_INITIALIZER(deadq_head); > > /* > * The timeout to apply to processes waiting on the dead queue. Unit > @@ -231,9 +279,6 @@ struct deadq_entry { > > #define DQ_TIMO_INIT 2 > > -typedef struct deadq_entry *dq_t; > - > - > /* > * Struct to hold records of network addresses that are allowed to log > * to us. > @@ -251,7 +296,9 @@ struct allowedpeer { > #define a_addr u.numeric.addr > #define a_mask u.numeric.mask > #define a_name u.name > + STAILQ_ENTRY(allowedpeer) next; > }; > +static STAILQ_HEAD(, allowedpeer) aphead = STAILQ_HEAD_INITIALIZER(aphead); > > > /* > @@ -259,12 +306,13 @@ struct allowedpeer { > * in seconds after previous message is logged. After each flush, > * we move to the next interval until we reach the largest. > */ > -int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ > -#define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) > +static int repeatinterval[] = { 30, 120, 600 }; /* # of secs before flush */ > +#define MAXREPEAT (nitems(repeatinterval) - 1) > #define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount]) > -#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \ > - (f)->f_repeatcount = MAXREPEAT; \ > - } > +#define BACKOFF(f) do { \ > + if (++(f)->f_repeatcount > MAXREPEAT) \ > + (f)->f_repeatcount = MAXREPEAT; \ > + } while (0) > > /* values for f_type */ > #define F_UNUSED 0 /* unused entry */ > @@ -276,12 +324,13 @@ int repeatinterval[] = { 30, 120, 600 }; /* # of secs > #define F_WALL 6 /* everyone logged on */ > #define F_PIPE 7 /* pipe to program */ > > -const char *TypeNames[8] = { > +static const char *TypeNames[] = { > "UNUSED", "FILE", "TTY", "CONSOLE", > "FORW", "USERS", "WALL", "PIPE" > }; > > -static struct filed *Files; /* Log files that we write to */ > +static STAILQ_HEAD(, filed) fhead = > + STAILQ_HEAD_INITIALIZER(fhead); /* Log files that we write to */ > static struct filed consfile; /* Console */ > > static int Debug; /* debug flag */ > @@ -289,8 +338,6 @@ static int Foreground = 0; /* Run in foreground, inste > static int resolve = 1; /* resolve hostname */ > static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ > static const char *LocalDomain; /* our local domain name */ > -static int *finet; /* Internet datagram sockets */ > -static int fklog = -1; /* /dev/klog */ > static int Initialized; /* set when we have initialized ourselves */ > static int MarkInterval = 20 * 60; /* interval between marks in seconds */ > static int MarkSeq; /* mark sequence number */ > @@ -309,9 +356,8 @@ static int logflags = O_WRONLY|O_APPEND; /* flags used > > static char bootfile[MAXLINE+1]; /* booted kernel file */ > > -struct allowedpeer *AllowedPeers; /* List of allowed peers */ > -static int NumAllowed; /* Number of entries in AllowedPeers */ > static int RemoteAddDate; /* Always set the date on remote messages */ > +static int RemoteHostname; /* Log remote hostname from the message */ > > static int UniquePriority; /* Only log specified priority? */ > static int LogFacPri; /* Put facility and priority in log message: */ > @@ -319,39 +365,53 @@ static int LogFacPri; /* Put facility and priority in > static int KeepKernFac; /* Keep remotely logged kernel facility */ > static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ > static struct pidfh *pfh; > +static int sigpipe[2]; /* Pipe to catch a signal during select(). */ > +static bool RFC3164OutputFormat = true; /* Use legacy format by default. */ > > -volatile sig_atomic_t MarkSet, WantDie; > +static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild; > > +struct iovlist; > + > static int allowaddr(char *); > -static void cfline(const char *, struct filed *, > - const char *, const char *); > +static int addfile(struct filed *); > +static int addpeer(struct peer *); > +static int addsock(struct sockaddr *, socklen_t, struct socklist *); > +static struct filed *cfline(const char *, const char *, const char *); > static const char *cvthname(struct sockaddr *); > static void deadq_enter(pid_t, const char *); > -static int deadq_remove(pid_t); > +static int deadq_remove(struct deadq_entry *); > +static int deadq_removebypid(pid_t); > static int decode(const char *, const CODE *); > static void die(int) __dead2; > static void dodie(int); > static void dofsync(void); > static void domark(int); > -static void fprintlog(struct filed *, int, const char *); > -static int *socksetup(int, char *); > +static void fprintlog_first(struct filed *, const char *, const char *, > + const char *, const char *, const char *, const char *, int); > +static void fprintlog_write(struct filed *, struct iovlist *, int); > +static void fprintlog_successive(struct filed *, int); > static void init(int); > static void logerror(const char *); > -static void logmsg(int, const char *, const char *, int); > +static void logmsg(int, const struct logtime *, const char *, const char *, > + const char *, const char *, const char *, const char *, int); > static void log_deadchild(pid_t, int, const char *); > static void markit(void); > +static int socksetup(struct peer *); > +static int socklist_recv_file(struct socklist *); > +static int socklist_recv_sock(struct socklist *); > +static int socklist_recv_signal(struct socklist *); > +static void sighandler(int); > static int skip_message(const char *, const char *, int); > -static void printline(const char *, char *, int); > +static void parsemsg(const char *, char *); > static void printsys(char *); > static int p_open(const char *, pid_t *); > -static void readklog(void); > static void reapchild(int); > static const char *ttymsg_check(struct iovec *, int, char *, int); > static void usage(void); > static int validate(struct sockaddr *, const char *); > static void unmapped(struct sockaddr *); > static void wallmsg(struct filed *, struct iovec *, const int iovlen); > -static int waitdaemon(int, int, int); > +static int waitdaemon(int); > static void timedout(int); > static void increase_rcvbuf(int); > > @@ -364,11 +424,11 @@ close_filed(struct filed *f) > > switch (f->f_type) { > case F_FORW: > - if (f->f_un.f_forw.f_addr) { > - freeaddrinfo(f->f_un.f_forw.f_addr); > - f->f_un.f_forw.f_addr = NULL; > - } > - /*FALLTHROUGH*/ > + if (f->f_un.f_forw.f_addr) { > + freeaddrinfo(f->f_un.f_forw.f_addr); > + f->f_un.f_forw.f_addr = NULL; > + } > + /* FALLTHROUGH */ > > case F_FILE: > case F_TTY: > @@ -376,41 +436,79 @@ close_filed(struct filed *f) > f->f_type = F_UNUSED; > break; > case F_PIPE: > - f->f_un.f_pipe.f_pid = 0; > + f->fu_pipe_pid = 0; > break; > } > (void)close(f->f_file); > f->f_file = -1; > } > > +static int > +addfile(struct filed *f0) > +{ > + struct filed *f; > + > + f = calloc(1, sizeof(*f)); > + if (f == NULL) > + err(1, "malloc failed"); > + *f = *f0; > + STAILQ_INSERT_TAIL(&fhead, f, next); > + > + return (0); > +} > + > +static int > +addpeer(struct peer *pe0) > +{ > + struct peer *pe; > + > + pe = calloc(1, sizeof(*pe)); > + if (pe == NULL) > + err(1, "malloc failed"); > + *pe = *pe0; > + STAILQ_INSERT_TAIL(&pqueue, pe, next); > + > + return (0); > +} > + > +static int > +addsock(struct sockaddr *sa, socklen_t sa_len, struct socklist *sl0) > +{ > + struct socklist *sl; > + > + sl = calloc(1, sizeof(*sl)); > + if (sl == NULL) > + err(1, "malloc failed"); > + *sl = *sl0; > + if (sa != NULL && sa_len > 0) > + memcpy(&sl->sl_ss, sa, sa_len); > + STAILQ_INSERT_TAIL(&shead, sl, next); > + > + return (0); > +} > + > int > main(int argc, char *argv[]) > { > - int ch, i, fdsrmax = 0, l; > - struct sockaddr_un sunx, fromunix; > - struct sockaddr_storage frominet; > + int ch, i, s, fdsrmax = 0, bflag = 0, pflag = 0, Sflag = 0; > fd_set *fdsr = NULL; > - char line[MAXLINE + 1]; > - const char *hname; > struct timeval tv, *tvp; > - struct sigaction sact; > - struct host *host; > - struct funix *fx, *fx1; > - sigset_t mask; > + struct peer *pe; > + struct socklist *sl; > pid_t ppid = 1, spid; > - socklen_t len; > + char *p; > > if (madvise(NULL, 0, MADV_PROTECT) != 0) > dprintf("madvise() failed: %s\n", strerror(errno)); > > - STAILQ_INIT(&hqueue); > - > - while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) > + while ((ch = getopt(argc, argv, "468Aa:b:cCdf:FHkl:m:nNoO:p:P:sS:Tuv")) > != -1) > switch (ch) { > +#ifdef INET > case '4': > family = PF_INET; > break; > +#endif > #ifdef INET6 > case '6': > family = PF_INET6; > @@ -427,13 +525,31 @@ main(int argc, char *argv[]) > usage(); > break; > case 'b': > - { > - if ((host = malloc(sizeof(struct host))) == NULL) > - err(1, "malloc failed"); > - host->name = optarg; > - STAILQ_INSERT_TAIL(&hqueue, host, next); > + bflag = 1; > + p = strchr(optarg, ']'); > + if (p != NULL) > + p = strchr(p + 1, ':'); > + else { > + p = strchr(optarg, ':'); > + if (p != NULL && strchr(p + 1, ':') != NULL) > + p = NULL; /* backward compatibility */ > + } > + if (p == NULL) { > + /* A hostname or filename only. */ > + addpeer(&(struct peer){ > + .pe_name = optarg, > + .pe_serv = "syslog" > + }); > + } else { > + /* The case of "name:service". */ > + *p++ = '\0'; > + addpeer(&(struct peer){ > + .pe_serv = p, > + .pe_name = (strlen(optarg) == 0) ? > + NULL : optarg, > + }); > + } > break; > - } > case 'c': > no_compress++; > break; > @@ -449,19 +565,32 @@ main(int argc, char *argv[]) > case 'F': /* run in foreground instead of daemon */ > Foreground++; > break; > + case 'H': > + RemoteHostname = 1; > + break; > case 'k': /* keep remote kern fac */ > KeepKernFac = 1; > break; > case 'l': > + case 'p': > + case 'S': > { > long perml; > mode_t mode; > char *name, *ep; > > - if (optarg[0] == '/') { > + if (ch == 'l') > mode = DEFFILEMODE; > + else if (ch == 'p') { > + mode = DEFFILEMODE; > + pflag = 1; > + } else { > + mode = S_IRUSR | S_IWUSR; > + Sflag = 1; > + } > + if (optarg[0] == '/') > name = optarg; > - } else if ((name = strchr(optarg, ':')) != NULL) { > + else if ((name = strchr(optarg, ':')) != NULL) { > *name++ = '\0'; > if (name[0] != '/') > errx(1, "socket name must be absolute " > @@ -476,17 +605,13 @@ main(int argc, char *argv[]) > } else > errx(1, "invalid mode %s, exiting", > optarg); > - } else /* doesn't begin with '/', and no ':' */ > - errx(1, "can't parse path %s", optarg); > - > - if (strlen(name) >= sizeof(sunx.sun_path)) > - errx(1, "%s path too long, exiting", name); > - if ((fx = malloc(sizeof(struct funix))) == NULL) > - err(1, "malloc failed"); > - fx->s = -1; > - fx->name = name; > - fx->mode = mode; > - STAILQ_INSERT_TAIL(&funixes, fx, next); > + } else > + errx(1, "invalid filename %s, exiting", > + optarg); > + addpeer(&(struct peer){ > + .pe_name = name, > + .pe_mode = mode > + }); > break; > } > case 'm': /* mark interval */ > @@ -499,25 +624,25 @@ main(int argc, char *argv[]) > case 'n': > resolve = 0; > break; > + case 'O': > + if (strcmp(optarg, "bsd") == 0 || > + strcmp(optarg, "rfc3164") == 0) > + RFC3164OutputFormat = true; > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable-11@freebsd.org Wed Jun 13 14:02:28 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AA96100E4E0 for ; Wed, 13 Jun 2018 14:02:28 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E4E2D84EFD for ; Wed, 13 Jun 2018 14:02:27 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-wm0-x233.google.com with SMTP id e16-v6so4961180wmd.0 for ; Wed, 13 Jun 2018 07:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5LgAEY+ZXO/KMtNqci4vDfTMFgPVaBpitZ5AZmqg0WI=; b=EURyqtz7DHKlscT8wz6vuzd3NCkNhpcAKYFkxBItHVJktkIr5jZLDsuRhUDyI2+MWM 5SZaXxCzYxc4Dm9GuTxbDd8EeeseC4VRiIlJuFdhPI76ogbKiyFTid7csNDXa9REA8HA qs72OKCfF6NzMCbh9NE+4ugM1Qsa1wS/DuAFTCaCqnM9LuKa1KKGIMN3ScmdsOH7VBOv 72eaeqmnYsU6VtuKx5oNCTm4v12oM00Prc1sQlIlg1wiC6DCm5y6BGQt46btG9MhnV1T Ko0dfROXkhmsPNWSW+ezO9dVEEOTD44Qs02YNj2SEyTnwtxCqptoCWP1IYEysg9Dr7dH 8VQw== 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=5LgAEY+ZXO/KMtNqci4vDfTMFgPVaBpitZ5AZmqg0WI=; b=oSuDsNxVt8ri1FC6wRxfpGy/L12Rgy/nrANYIPYyF66M0qsmH8i5pX+kqWuI9FujqR BUjsjf4R6WfEzskoALwnpH6G1qa2Mic4SElM38WKYBuJDcXRQztL5dZz/SkByeNSnLMx 2AsAj3IXNQCl9EK27VfH+LFhGyVsRWI1b3WyZR8ZrNmKMkXjbBk84d44Xc977dv7Wh7/ y+BMUibgEvYT3umZxs7DTw1GwdG62+J03a/n3KQrRyaM09yY7bymdLnFTuZsjYarHrEk E010ReOJ8d6hkxfKXKS+/47l4d4IrmmTIBAG2vVP9sFK2udrnbSpZuRi0m4T8L7if2M6 4E6A== X-Gm-Message-State: APt69E3RNT6FxkybtLACTiL4hZLcWlTFz6DbOJGDcb3mlrLqN4svd0jF O+CCqrcORy+vvPUaVsAasNzXabyKFnWq7GroftLJhg== X-Google-Smtp-Source: ADUXVKJxSPjVM+CQg/au0ST1mAqlzNt7SZsXhkdGnS9db8VHyZn7rGg9VLHE6gUo2sI3f5LV8ZoJ63Z1dfAFdiCFOVA= X-Received: by 2002:a50:863d:: with SMTP id o58-v6mr4266720edo.243.1528898546870; Wed, 13 Jun 2018 07:02:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:8e0d:0:0:0:0:0 with HTTP; Wed, 13 Jun 2018 07:01:56 -0700 (PDT) In-Reply-To: <201806131357.w5DDvQw8039745@pdx.rh.CN85.dnsmgr.net> References: <201806131341.w5DDfN7T043988@repo.freebsd.org> <201806131357.w5DDvQw8039745@pdx.rh.CN85.dnsmgr.net> From: Ed Schouten Date: Wed, 13 Jun 2018 16:01:56 +0200 Message-ID: Subject: Re: svn commit: r335059 - in stable/11: usr.bin/wall usr.sbin/syslogd To: rgrimes@freebsd.org Cc: Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 14:02:28 -0000 Hi Rodney, 2018-06-13 15:57 GMT+02:00 Rodney W. Grimes : >> Modified: >> stable/11/usr.bin/wall/ttymsg.c >> stable/11/usr.bin/wall/ttymsg.h > > I see no mention of any changes to wall in the commit, > was this intentional? The changes don't seem to be > related to syslogd directly. Good question. syslogd(8) reuses some code from wall(8) to write syslog messages to terminals if configured to do so. In one of the RFC 5424 support commits, I had to adjust this shared code slightly (increase a limit). As the changes to wall(8) were committed together with the syslogd(8) changes, I also had to merge them back in one go. In other words, this is intentional. :-) -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands From owner-svn-src-stable-11@freebsd.org Wed Jun 13 14:16:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3D354100F50F; Wed, 13 Jun 2018 14:16:45 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.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 B30718594B; Wed, 13 Jun 2018 14:16:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w5DEGgrj039815; Wed, 13 Jun 2018 07:16:42 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w5DEGgwm039814; Wed, 13 Jun 2018 07:16:42 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201806131416.w5DEGgwm039814@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r335059 - in stable/11: usr.bin/wall usr.sbin/syslogd In-Reply-To: To: Ed Schouten Date: Wed, 13 Jun 2018 07:16:42 -0700 (PDT) CC: rgrimes@freebsd.org, Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@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-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 14:16:45 -0000 > Hi Rodney, > > 2018-06-13 15:57 GMT+02:00 Rodney W. Grimes : > >> Modified: > >> stable/11/usr.bin/wall/ttymsg.c > >> stable/11/usr.bin/wall/ttymsg.h > > > > I see no mention of any changes to wall in the commit, > > was this intentional? The changes don't seem to be > > related to syslogd directly. > > Good question. syslogd(8) reuses some code from wall(8) to write > syslog messages to terminals if configured to do so. In one of the RFC > 5424 support commits, I had to adjust this shared code slightly > (increase a limit). As the changes to wall(8) were committed together > with the syslogd(8) changes, I also had to merge them back in one go. > > In other words, this is intentional. :-) Thank you for the details. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable-11@freebsd.org Wed Jun 13 20:33:53 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9687C1013030; Wed, 13 Jun 2018 20:33:53 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1974E7A0D0; Wed, 13 Jun 2018 20:33:53 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF2381E77C; Wed, 13 Jun 2018 20:33:52 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DKXqBV055620; Wed, 13 Jun 2018 20:33:52 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DKXqXs055619; Wed, 13 Jun 2018 20:33:52 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201806132033.w5DKXqXs055619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 13 Jun 2018 20:33:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335087 - stable/11/sys/dev/si X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/11/sys/dev/si X-SVN-Commit-Revision: 335087 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 20:33:54 -0000 Author: dim Date: Wed Jun 13 20:33:52 2018 New Revision: 335087 URL: https://svnweb.freebsd.org/changeset/base/335087 Log: Fix build of si with base gcc on i386 Casting from rman_res_t to a pointer results in "cast to pointer from integer of different size" warnings with base gcc on i386, so use intermediate casts to uintptr_t to suppress these. Direct commit to stable/11, since si(4) has been removed from head. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D15752 Modified: stable/11/sys/dev/si/si_isa.c stable/11/sys/dev/si/si_pci.c Modified: stable/11/sys/dev/si/si_isa.c ============================================================================== --- stable/11/sys/dev/si/si_isa.c Wed Jun 13 20:25:36 2018 (r335086) +++ stable/11/sys/dev/si/si_isa.c Wed Jun 13 20:33:52 2018 (r335087) @@ -65,7 +65,7 @@ si_isa_probe(device_t dev) device_printf(dev, "cannot allocate memory resource\n"); return ENXIO; } - paddr = (caddr_t)rman_get_start(sc->sc_mem_res);/* physical */ + paddr = (caddr_t)(uintptr_t)rman_get_start(sc->sc_mem_res);/* physical */ maddr = rman_get_virtual(sc->sc_mem_res); /* in kvm */ DPRINT((0, DBG_AUTOBOOT, "si%d: probe at virtual=0x%x physical=0x%x\n", @@ -279,7 +279,7 @@ si_isa_attach(device_t dev) device_printf(dev, "couldn't map memory\n"); goto fail; } - sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res); + sc->sc_paddr = (caddr_t)(uintptr_t)rman_get_start(sc->sc_mem_res); sc->sc_maddr = rman_get_virtual(sc->sc_mem_res); sc->sc_irq_rid = 0; Modified: stable/11/sys/dev/si/si_pci.c ============================================================================== --- stable/11/sys/dev/si/si_pci.c Wed Jun 13 20:25:36 2018 (r335086) +++ stable/11/sys/dev/si/si_pci.c Wed Jun 13 20:33:52 2018 (r335087) @@ -86,7 +86,7 @@ si_pci_attach(device_t dev) device_printf(dev, "couldn't map memory\n"); goto fail; } - sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res); + sc->sc_paddr = (caddr_t)(uintptr_t)rman_get_start(sc->sc_mem_res); sc->sc_maddr = rman_get_virtual(sc->sc_mem_res); sc->sc_irq_rid = 0; From owner-svn-src-stable-11@freebsd.org Wed Jun 13 20:35:57 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F22710134CA; Wed, 13 Jun 2018 20:35:57 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 502417A2FD; Wed, 13 Jun 2018 20:35:57 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 16ECE1E783; Wed, 13 Jun 2018 20:35:57 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DKZuKC055783; Wed, 13 Jun 2018 20:35:56 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DKZuua055780; Wed, 13 Jun 2018 20:35:56 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201806132035.w5DKZuua055780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 13 Jun 2018 20:35:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335088 - in stable/11: . tools/build/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable/11: . tools/build/mk X-SVN-Commit-Revision: 335088 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 20:35:58 -0000 Author: dim Date: Wed Jun 13 20:35:56 2018 New Revision: 335088 URL: https://svnweb.freebsd.org/changeset/base/335088 Log: MFC r334886: Add missed libc++ entries to (Optional)ObsoleteFiles.inc Some of these were removed during the libc++ 5.0.0 import, others were added in the libc++ 6.0.0 import. Modified: stable/11/ObsoleteFiles.inc stable/11/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/ObsoleteFiles.inc ============================================================================== --- stable/11/ObsoleteFiles.inc Wed Jun 13 20:33:52 2018 (r335087) +++ stable/11/ObsoleteFiles.inc Wed Jun 13 20:35:56 2018 (r335088) @@ -38,6 +38,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20180613: obsolete libc++ files missed from the 5.0.0 import +OLD_FILES+=usr/include/c++/v1/__refstring +OLD_FILES+=usr/include/c++/v1/__undef_min_max +OLD_FILES+=usr/include/c++/v1/tr1/__refstring +OLD_FILES+=usr/include/c++/v1/tr1/__undef_min_max # 20180513: remove DTrace scripts made obsolete by dwatch(1) OLD_FILES+=usr/share/dtrace/watch_execve OLD_FILES+=usr/share/dtrace/watch_kill Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/11/tools/build/mk/OptionalObsoleteFiles.inc Wed Jun 13 20:33:52 2018 (r335087) +++ stable/11/tools/build/mk/OptionalObsoleteFiles.inc Wed Jun 13 20:35:56 2018 (r335088) @@ -4499,7 +4499,6 @@ OLD_FILES+=usr/include/c++/v1/__libcpp_version OLD_FILES+=usr/include/c++/v1/__locale OLD_FILES+=usr/include/c++/v1/__mutex_base OLD_FILES+=usr/include/c++/v1/__nullptr -OLD_FILES+=usr/include/c++/v1/__refstring OLD_FILES+=usr/include/c++/v1/__split_buffer OLD_FILES+=usr/include/c++/v1/__sso_allocator OLD_FILES+=usr/include/c++/v1/__std_stream @@ -4552,6 +4551,7 @@ OLD_FILES+=usr/include/c++/v1/experimental/__memory OLD_FILES+=usr/include/c++/v1/experimental/algorithm OLD_FILES+=usr/include/c++/v1/experimental/any OLD_FILES+=usr/include/c++/v1/experimental/chrono +OLD_FILES+=usr/include/c++/v1/experimental/coroutine OLD_FILES+=usr/include/c++/v1/experimental/deque OLD_FILES+=usr/include/c++/v1/experimental/dynarray OLD_FILES+=usr/include/c++/v1/experimental/filesystem @@ -4561,6 +4561,7 @@ OLD_FILES+=usr/include/c++/v1/experimental/iterator OLD_FILES+=usr/include/c++/v1/experimental/list OLD_FILES+=usr/include/c++/v1/experimental/map OLD_FILES+=usr/include/c++/v1/experimental/memory_resource +OLD_FILES+=usr/include/c++/v1/experimental/numeric OLD_FILES+=usr/include/c++/v1/experimental/optional OLD_FILES+=usr/include/c++/v1/experimental/propagate_const OLD_FILES+=usr/include/c++/v1/experimental/ratio @@ -4642,7 +4643,6 @@ OLD_FILES+=usr/include/c++/v1/tr1/__libcpp_version OLD_FILES+=usr/include/c++/v1/tr1/__locale OLD_FILES+=usr/include/c++/v1/tr1/__mutex_base OLD_FILES+=usr/include/c++/v1/tr1/__nullptr -OLD_FILES+=usr/include/c++/v1/tr1/__refstring OLD_FILES+=usr/include/c++/v1/tr1/__split_buffer OLD_FILES+=usr/include/c++/v1/tr1/__sso_allocator OLD_FILES+=usr/include/c++/v1/tr1/__std_stream @@ -4650,7 +4650,7 @@ OLD_FILES+=usr/include/c++/v1/tr1/__string OLD_FILES+=usr/include/c++/v1/tr1/__threading_support OLD_FILES+=usr/include/c++/v1/tr1/__tree OLD_FILES+=usr/include/c++/v1/tr1/__tuple -OLD_FILES+=usr/include/c++/v1/tr1/__undef_min_max +OLD_FILES+=usr/include/c++/v1/tr1/__undef_macros OLD_FILES+=usr/include/c++/v1/tr1/algorithm OLD_FILES+=usr/include/c++/v1/tr1/any OLD_FILES+=usr/include/c++/v1/tr1/array From owner-svn-src-stable-11@freebsd.org Wed Jun 13 21:10:34 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1C5A10176FA; Wed, 13 Jun 2018 21:10:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6F9E67C6B7; Wed, 13 Jun 2018 21:10:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 50E0E1EC72; Wed, 13 Jun 2018 21:10:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DLAYlL072269; Wed, 13 Jun 2018 21:10:34 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DLAYmd072268; Wed, 13 Jun 2018 21:10:34 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201806132110.w5DLAYmd072268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 13 Jun 2018 21:10:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335090 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 335090 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 21:10:35 -0000 Author: kib Date: Wed Jun 13 21:10:33 2018 New Revision: 335090 URL: https://svnweb.freebsd.org/changeset/base/335090 Log: MFC r335072: Enable eager FPU context switch by default on amd64. Security: CVE-2018-3665 Modified: stable/11/sys/amd64/amd64/cpu_switch.S stable/11/sys/amd64/amd64/fpu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/cpu_switch.S ============================================================================== --- stable/11/sys/amd64/amd64/cpu_switch.S Wed Jun 13 21:10:23 2018 (r335089) +++ stable/11/sys/amd64/amd64/cpu_switch.S Wed Jun 13 21:10:33 2018 (r335090) @@ -128,10 +128,10 @@ done_store_dr: /* have we used fp, and need a save? */ cmpq %rdi,PCPU(FPCURTHREAD) - jne 3f + jne 2f movq PCB_SAVEFPU(%r8),%r8 clts - cmpl $0,use_xsave + cmpl $0,use_xsave(%rip) jne 1f fxsave (%r8) jmp 2f @@ -143,12 +143,7 @@ ctx_switch_xsave: /* This is patched to xsaveopt if supported, see fpuinit_bsp1() */ xsave (%r8) movq %rcx,%rdx -2: smsw %ax - orb $CR0_TS,%al - lmsw %ax - xorl %eax,%eax - movq %rax,PCPU(FPCURTHREAD) -3: +2: /* Save is done. Now fire up new thread. Leave old vmspace. */ movq %rsi,%r12 movq %rdi,%r13 @@ -235,6 +230,8 @@ done_load_dr: movq PCB_RBX(%r8),%rbx movq PCB_RIP(%r8),%rax movq %rax,(%rsp) + movq PCPU(CURTHREAD),%rdi + call fpu_activate_sw ret /* Modified: stable/11/sys/amd64/amd64/fpu.c ============================================================================== --- stable/11/sys/amd64/amd64/fpu.c Wed Jun 13 21:10:23 2018 (r335089) +++ stable/11/sys/amd64/amd64/fpu.c Wed Jun 13 21:10:33 2018 (r335090) @@ -139,6 +139,11 @@ static void fpu_clean_state(void); SYSCTL_INT(_hw, HW_FLOATINGPT, floatingpoint, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, 1, "Floating point instructions executed in hardware"); +int lazy_fpu_switch = 0; +SYSCTL_INT(_hw, OID_AUTO, lazy_fpu_switch, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + &lazy_fpu_switch, 0, + "Lazily load FPU context after context switch"); + int use_xsave; /* non-static for cpu_switch.S */ uint64_t xsave_mask; /* the same */ static uma_zone_t fpu_save_area_zone; @@ -204,6 +209,7 @@ fpuinit_bsp1(void) u_int cp[4]; uint64_t xsave_mask_user; + TUNABLE_INT_FETCH("hw.lazy_fpu_switch", &lazy_fpu_switch); if ((cpu_feature2 & CPUID2_XSAVE) != 0) { use_xsave = 1; TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); @@ -612,6 +618,45 @@ fputrap_sse(void) return (fpetable[(mxcsr & (~mxcsr >> 7)) & 0x3f]); } +static void +restore_fpu_curthread(struct thread *td) +{ + struct pcb *pcb; + + /* + * Record new context early in case frstor causes a trap. + */ + PCPU_SET(fpcurthread, td); + + stop_emulating(); + fpu_clean_state(); + pcb = td->td_pcb; + + if ((pcb->pcb_flags & PCB_FPUINITDONE) == 0) { + /* + * This is the first time this thread has used the FPU or + * the PCB doesn't contain a clean FPU state. Explicitly + * load an initial state. + * + * We prefer to restore the state from the actual save + * area in PCB instead of directly loading from + * fpu_initialstate, to ignite the XSAVEOPT + * tracking engine. + */ + bcopy(fpu_initialstate, pcb->pcb_save, + cpu_max_ext_state_size); + fpurestore(pcb->pcb_save); + if (pcb->pcb_initial_fpucw != __INITIAL_FPUCW__) + fldcw(pcb->pcb_initial_fpucw); + if (PCB_USER_FPU(pcb)) + set_pcb_flags(pcb, PCB_FPUINITDONE | + PCB_USERFPUINITDONE); + else + set_pcb_flags(pcb, PCB_FPUINITDONE); + } else + fpurestore(pcb->pcb_save); +} + /* * Device Not Available (DNA, #NM) exception handler. * @@ -622,7 +667,9 @@ fputrap_sse(void) void fpudna(void) { + struct thread *td; + td = curthread; /* * This handler is entered with interrupts enabled, so context * switches may occur before critical_enter() is executed. If @@ -636,7 +683,7 @@ fpudna(void) KASSERT((curpcb->pcb_flags & PCB_FPUNOSAVE) == 0, ("fpudna while in fpu_kern_enter(FPU_KERN_NOCTX)")); - if (PCPU_GET(fpcurthread) == curthread) { + if (PCPU_GET(fpcurthread) == td) { printf("fpudna: fpcurthread == curthread\n"); stop_emulating(); critical_exit(); @@ -645,40 +692,24 @@ fpudna(void) if (PCPU_GET(fpcurthread) != NULL) { panic("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", PCPU_GET(fpcurthread), PCPU_GET(fpcurthread)->td_tid, - curthread, curthread->td_tid); + td, td->td_tid); } - stop_emulating(); - /* - * Record new context early in case frstor causes a trap. - */ - PCPU_SET(fpcurthread, curthread); + restore_fpu_curthread(td); + critical_exit(); +} - fpu_clean_state(); +void fpu_activate_sw(struct thread *td); /* Called from the context switch */ +void +fpu_activate_sw(struct thread *td) +{ - if ((curpcb->pcb_flags & PCB_FPUINITDONE) == 0) { - /* - * This is the first time this thread has used the FPU or - * the PCB doesn't contain a clean FPU state. Explicitly - * load an initial state. - * - * We prefer to restore the state from the actual save - * area in PCB instead of directly loading from - * fpu_initialstate, to ignite the XSAVEOPT - * tracking engine. - */ - bcopy(fpu_initialstate, curpcb->pcb_save, - cpu_max_ext_state_size); - fpurestore(curpcb->pcb_save); - if (curpcb->pcb_initial_fpucw != __INITIAL_FPUCW__) - fldcw(curpcb->pcb_initial_fpucw); - if (PCB_USER_FPU(curpcb)) - set_pcb_flags(curpcb, - PCB_FPUINITDONE | PCB_USERFPUINITDONE); - else - set_pcb_flags(curpcb, PCB_FPUINITDONE); - } else - fpurestore(curpcb->pcb_save); - critical_exit(); + if (lazy_fpu_switch || (td->td_pflags & TDP_KTHREAD) != 0 || + !PCB_USER_FPU(td->td_pcb)) { + PCPU_SET(fpcurthread, NULL); + start_emulating(); + } else if (PCPU_GET(fpcurthread) != td) { + restore_fpu_curthread(td); + } } void From owner-svn-src-stable-11@freebsd.org Thu Jun 14 14:45:09 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24091100A3AA; Thu, 14 Jun 2018 14:45:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA2676DD0B; Thu, 14 Jun 2018 14:45:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7DC51CD8; Thu, 14 Jun 2018 14:45:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EEj8Vs015167; Thu, 14 Jun 2018 14:45:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EEj8gf015166; Thu, 14 Jun 2018 14:45:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141445.w5EEj8gf015166@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 14:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335137 - stable/11/sys/dev/advansys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/advansys X-SVN-Commit-Revision: 335137 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 14:45:09 -0000 Author: mav Date: Thu Jun 14 14:45:08 2018 New Revision: 335137 URL: https://svnweb.freebsd.org/changeset/base/335137 Log: MFC r311350 (by rpokala): Fix whitespace in handling of XPT_PATH_INQ in adw(4). Came across this while doing some other minor CAM cleanup. Whitespace-only change, so not bothering w/ a review. Modified: stable/11/sys/dev/advansys/adwcam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/advansys/adwcam.c ============================================================================== --- stable/11/sys/dev/advansys/adwcam.c Thu Jun 14 13:42:58 2018 (r335136) +++ stable/11/sys/dev/advansys/adwcam.c Thu Jun 14 14:45:08 2018 (r335137) @@ -712,10 +712,10 @@ adw_action(struct cam_sim *sim, union ccb *ccb) strlcpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; From owner-svn-src-stable-11@freebsd.org Thu Jun 14 14:46:23 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00923100A52B; Thu, 14 Jun 2018 14:46:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A625C6DE7B; Thu, 14 Jun 2018 14:46:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 865F01CD9; Thu, 14 Jun 2018 14:46:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EEkMg4015293; Thu, 14 Jun 2018 14:46:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EEkKeA015282; Thu, 14 Jun 2018 14:46:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141446.w5EEkKeA015282@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 14:46:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335138 - in stable/11/sys/dev: aha ahb aic ciss dpt firewire mly ncr nvme twa X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys/dev: aha ahb aic ciss dpt firewire mly ncr nvme twa X-SVN-Commit-Revision: 335138 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 14:46:23 -0000 Author: mav Date: Thu Jun 14 14:46:20 2018 New Revision: 335138 URL: https://svnweb.freebsd.org/changeset/base/335138 Log: MFC r311351 (by rpokala): In the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in several more drivers. Modified: stable/11/sys/dev/aha/aha.c stable/11/sys/dev/ahb/ahb.c stable/11/sys/dev/aic/aic.c stable/11/sys/dev/ciss/ciss.c stable/11/sys/dev/dpt/dpt_scsi.c stable/11/sys/dev/firewire/sbp.c stable/11/sys/dev/mly/mly.c stable/11/sys/dev/ncr/ncr.c stable/11/sys/dev/nvme/nvme_sim.c stable/11/sys/dev/twa/tw_osl_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/aha/aha.c ============================================================================== --- stable/11/sys/dev/aha/aha.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/aha/aha.c Thu Jun 14 14:46:20 2018 (r335138) @@ -947,10 +947,10 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; Modified: stable/11/sys/dev/ahb/ahb.c ============================================================================== --- stable/11/sys/dev/ahb/ahb.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/ahb/ahb.c Thu Jun 14 14:46:20 2018 (r335138) @@ -1182,10 +1182,10 @@ ahbaction(struct cam_sim *sim, union ccb *ccb) strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; Modified: stable/11/sys/dev/aic/aic.c ============================================================================== --- stable/11/sys/dev/aic/aic.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/aic/aic.c Thu Jun 14 14:46:20 2018 (r335138) @@ -280,7 +280,7 @@ aic_action(struct cam_sim *sim, union ccb *ccb) cpi->max_lun = 7; cpi->initiator_id = aic->initiator; cpi->bus_id = cam_sim_bus(sim); - cpi->base_transfer_speed = 3300; + cpi->base_transfer_speed = 3300; strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); Modified: stable/11/sys/dev/ciss/ciss.c ============================================================================== --- stable/11/sys/dev/ciss/ciss.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/ciss/ciss.c Thu Jun 14 14:46:20 2018 (r335138) @@ -3027,10 +3027,10 @@ ciss_cam_action(struct cam_sim *sim, union ccb *ccb) cpi->max_lun = 0; /* 'logical drive' channel only */ cpi->initiator_id = sc->ciss_cfg->max_logical_supported; strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strlcpy(cpi->hba_vid, "CISS", HBA_IDLEN); - strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); - cpi->unit_number = cam_sim_unit(sim); - cpi->bus_id = cam_sim_bus(sim); + strlcpy(cpi->hba_vid, "CISS", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + cpi->unit_number = cam_sim_unit(sim); + cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/dpt/dpt_scsi.c ============================================================================== --- stable/11/sys/dev/dpt/dpt_scsi.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/dpt/dpt_scsi.c Thu Jun 14 14:46:20 2018 (r335138) @@ -1031,10 +1031,10 @@ dpt_action(struct cam_sim *sim, union ccb *ccb) strlcpy(cpi->hba_vid, "DPT", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; Modified: stable/11/sys/dev/firewire/sbp.c ============================================================================== --- stable/11/sys/dev/firewire/sbp.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/firewire/sbp.c Thu Jun 14 14:46:20 2018 (r335138) @@ -2512,10 +2512,10 @@ END_DEBUG strlcpy(cpi->hba_vid, "SBP", HBA_IDLEN); strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; - cpi->transport = XPORT_SPI; /* XX should have a FireWire */ - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; /* XX should have a FireWire */ + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/11/sys/dev/mly/mly.c ============================================================================== --- stable/11/sys/dev/mly/mly.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/mly/mly.c Thu Jun 14 14:46:20 2018 (r335138) @@ -2110,10 +2110,10 @@ mly_cam_action(struct cam_sim *sim, union ccb *ccb) cpi->max_lun = MLY_MAX_LUNS - 1; cpi->initiator_id = sc->mly_controllerparam->initiator_id; strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strlcpy(cpi->hba_vid, "Mylex", HBA_IDLEN); - strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); - cpi->unit_number = cam_sim_unit(sim); - cpi->bus_id = cam_sim_bus(sim); + strlcpy(cpi->hba_vid, "Mylex", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + cpi->unit_number = cam_sim_unit(sim); + cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/ncr/ncr.c ============================================================================== --- stable/11/sys/dev/ncr/ncr.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/ncr/ncr.c Thu Jun 14 14:46:20 2018 (r335138) @@ -4347,10 +4347,10 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) strlcpy(cpi->hba_vid, "Symbios", HBA_IDLEN); strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_SPI; - cpi->transport_version = 2; - cpi->protocol = PROTO_SCSI; - cpi->protocol_version = SCSI_REV_2; + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:46:20 2018 (r335138) @@ -196,10 +196,10 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) strncpy(cpi->hba_vid, "NVMe", HBA_IDLEN); strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); - cpi->transport = XPORT_NVME; /* XXX XPORT_PCIE ? */ - cpi->transport_version = 1; /* XXX Get PCIe spec ? */ - cpi->protocol = PROTO_NVME; - cpi->protocol_version = NVME_REV_1; /* Groks all 1.x NVMe cards */ + cpi->transport = XPORT_NVME; /* XXX XPORT_PCIE ? */ + cpi->transport_version = 1; /* XXX Get PCIe spec ? */ + cpi->protocol = PROTO_NVME; + cpi->protocol_version = NVME_REV_1; /* Groks all 1.x NVMe cards */ cpi->xport_specific.nvme.nsid = ns->id; cpi->xport_specific.nvme.domain = pci_get_domain(dev); cpi->xport_specific.nvme.bus = pci_get_bus(dev); Modified: stable/11/sys/dev/twa/tw_osl_cam.c ============================================================================== --- stable/11/sys/dev/twa/tw_osl_cam.c Thu Jun 14 14:45:08 2018 (r335137) +++ stable/11/sys/dev/twa/tw_osl_cam.c Thu Jun 14 14:46:20 2018 (r335138) @@ -427,11 +427,11 @@ twa_action(struct cam_sim *sim, union ccb *ccb) strlcpy(path_inq->sim_vid, "FreeBSD", SIM_IDLEN); strlcpy(path_inq->hba_vid, "3ware", HBA_IDLEN); strlcpy(path_inq->dev_name, cam_sim_name(sim), DEV_IDLEN); - path_inq->transport = XPORT_SPI; - path_inq->transport_version = 2; - path_inq->protocol = PROTO_SCSI; - path_inq->protocol_version = SCSI_REV_2; - path_inq->maxio = TW_CL_MAX_IO_SIZE; + path_inq->transport = XPORT_SPI; + path_inq->transport_version = 2; + path_inq->protocol = PROTO_SCSI; + path_inq->protocol_version = SCSI_REV_2; + path_inq->maxio = TW_CL_MAX_IO_SIZE; ccb_h->status = CAM_REQ_CMP; xpt_done(ccb); break; From owner-svn-src-stable-11@freebsd.org Thu Jun 14 14:50:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C991B100AA07; Thu, 14 Jun 2018 14:50:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7EA8E6E0E8; Thu, 14 Jun 2018 14:50:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 609161CEC; Thu, 14 Jun 2018 14:50:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EEoVD8015576; Thu, 14 Jun 2018 14:50:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EEoVn9015575; Thu, 14 Jun 2018 14:50:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141450.w5EEoVn9015575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 14:50:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335139 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335139 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 14:50:32 -0000 Author: mav Date: Thu Jun 14 14:50:30 2018 New Revision: 335139 URL: https://svnweb.freebsd.org/changeset/base/335139 Log: MFC r313954 (by imp): Remove obsolete comment after prior rev. Modified: stable/11/sys/dev/nvme/nvme_sim.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:46:20 2018 (r335138) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:50:30 2018 (r335139) @@ -153,14 +153,6 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) */ /*FALLTHROUGH*/ case XPT_ABORT: /* Abort the specified CCB */ - case XPT_EN_LUN: /* Enable LUN as a target */ - case XPT_TARGET_IO: /* Execute target I/O request */ - case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */ - case XPT_CONT_TARGET_IO: /* Continue Host Target I/O Connection*/ - /* - * Only target mode generates these, and only for SCSI. They are - * all invalid/unsupported for NVMe. - */ ccb->ccb_h.status = CAM_REQ_INVALID; break; case XPT_SET_TRAN_SETTINGS: From owner-svn-src-stable-11@freebsd.org Thu Jun 14 14:58:52 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5B904100B5BB; Thu, 14 Jun 2018 14:58:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0842A6E9CF; Thu, 14 Jun 2018 14:58:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D991E1E84; Thu, 14 Jun 2018 14:58:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EEwpeU021015; Thu, 14 Jun 2018 14:58:51 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EEwpVj021014; Thu, 14 Jun 2018 14:58:51 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141458.w5EEwpVj021014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 14:58:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335142 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335142 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 14:58:52 -0000 Author: mav Date: Thu Jun 14 14:58:51 2018 New Revision: 335142 URL: https://svnweb.freebsd.org/changeset/base/335142 Log: MFC r328089 (by imp): Move setting of CAM_SIM_QUEUED to before we actually submit it to the hardware. Setting it after is racy, and we can lose the race on a heavily loaded system. Modified: stable/11/sys/dev/nvme/nvme_sim.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:53:24 2018 (r335141) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 14:58:51 2018 (r335142) @@ -76,6 +76,7 @@ nvme_sim_nvmeio_done(void *ccb_arg, const struct nvme_ * it means. Make our best guess, though for the status code. */ memcpy(&ccb->nvmeio.cpl, cpl, sizeof(*cpl)); + ccb->ccb_h.status &= ~CAM_SIM_QUEUED; if (nvme_completion_is_error(cpl)) { ccb->ccb_h.status = CAM_REQ_CMP_ERR; xpt_done(ccb); @@ -114,6 +115,7 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb) xpt_done(ccb); return; } + ccb->ccb_h.status |= CAM_SIM_QUEUED; memcpy(&req->cmd, &ccb->nvmeio.cmd, sizeof(ccb->nvmeio.cmd)); @@ -121,8 +123,6 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb) nvme_ctrlr_submit_io_request(ctrlr, req); else nvme_ctrlr_submit_admin_request(ctrlr, req); - - ccb->ccb_h.status |= CAM_SIM_QUEUED; } static void From owner-svn-src-stable-11@freebsd.org Thu Jun 14 15:02:28 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B86AB100BB44; Thu, 14 Jun 2018 15:02:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 69AAB6EF11; Thu, 14 Jun 2018 15:02:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4AFD32018; Thu, 14 Jun 2018 15:02:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EF2SDN025628; Thu, 14 Jun 2018 15:02:28 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EF2Stc025627; Thu, 14 Jun 2018 15:02:28 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141502.w5EF2Stc025627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 15:02:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335143 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335143 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 15:02:28 -0000 Author: mav Date: Thu Jun 14 15:02:27 2018 New Revision: 335143 URL: https://svnweb.freebsd.org/changeset/base/335143 Log: MFC r330953 (by imp): Don't make the namespace devices eternal. We'll need to delete namespaces soon, so go ahead and stop making these devices eternal. It doesn't help much, and will be getting in the way soon. Modified: stable/11/sys/dev/nvme/nvme_ns.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_ns.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ns.c Thu Jun 14 14:58:51 2018 (r335142) +++ stable/11/sys/dev/nvme/nvme_ns.c Thu Jun 14 15:02:27 2018 (r335143) @@ -562,21 +562,9 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t */ unit = device_get_unit(ctrlr->dev) * NVME_MAX_NAMESPACES + ns->id - 1; -/* - * MAKEDEV_ETERNAL was added in r210923, for cdevs that will never - * be destroyed. This avoids refcounting on the cdev object. - * That should be OK case here, as long as we're not supporting PCIe - * surprise removal nor namespace deletion. - */ -#ifdef MAKEDEV_ETERNAL_KLD - ns->cdev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &nvme_ns_cdevsw, unit, - NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d", - device_get_unit(ctrlr->dev), ns->id); -#else ns->cdev = make_dev_credf(0, &nvme_ns_cdevsw, unit, NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d", device_get_unit(ctrlr->dev), ns->id); -#endif #ifdef NVME_UNMAPPED_BIO_SUPPORT ns->cdev->si_flags |= SI_UNMAPPED; #endif From owner-svn-src-stable-11@freebsd.org Thu Jun 14 16:19:06 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6A8A1010FB9; Thu, 14 Jun 2018 16:19:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C3B77248F; Thu, 14 Jun 2018 16:19:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3EBFC2B82; Thu, 14 Jun 2018 16:19:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EGJ6fC062467; Thu, 14 Jun 2018 16:19:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EGJ6SK062466; Thu, 14 Jun 2018 16:19:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141619.w5EGJ6SK062466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 16:19:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335149 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335149 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 16:19:06 -0000 Author: mav Date: Thu Jun 14 16:19:05 2018 New Revision: 335149 URL: https://svnweb.freebsd.org/changeset/base/335149 Log: MFC r330954, r330955 (by imp): When tearing down a queue pair, also delete the queue entries. The NVME standard has required in section 7.2.6, since at least 1.1, that a clean shutdown is signalled by deleting the subission and the completion queues before setting the shutdown bit in CC. The 1.0 standard, apparently, did not and many of the early Intel cards didn't care. Some newer cards care, at least one whose beta firmware can scramble the card on an unclean shutdown. Linux has done this for some time. To make it possible to move forward with an evaluation of this pre-release card with wonky firmware, delete the queues on the card when we delete the qpair structures. Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 16:11:50 2018 (r335148) +++ stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 16:19:05 2018 (r335149) @@ -493,6 +493,34 @@ nvme_ctrlr_create_qpairs(struct nvme_controller *ctrlr } static int +nvme_ctrlr_destroy_qpair(struct nvme_controller *ctrlr, struct nvme_qpair *qpair) +{ + struct nvme_completion_poll_status status; + + status.done = 0; + nvme_ctrlr_cmd_delete_io_sq(ctrlr, qpair, + nvme_completion_poll_cb, &status); + while (!atomic_load_acq_int(&status.done)) + pause("nvme", 1); + if (nvme_completion_is_error(&status.cpl)) { + nvme_printf(ctrlr, "nvme_destroy_io_sq failed!\n"); + return (ENXIO); + } + + status.done = 0; + nvme_ctrlr_cmd_delete_io_cq(ctrlr, qpair, + nvme_completion_poll_cb, &status); + while (!atomic_load_acq_int(&status.done)) + pause("nvme", 1); + if (nvme_completion_is_error(&status.cpl)) { + nvme_printf(ctrlr, "nvme_destroy_io_cq failed!\n"); + return (ENXIO); + } + + return (0); +} + +static int nvme_ctrlr_construct_namespaces(struct nvme_controller *ctrlr) { struct nvme_namespace *ns; @@ -1216,6 +1244,7 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev destroy_dev(ctrlr->cdev); for (i = 0; i < ctrlr->num_io_queues; i++) { + nvme_ctrlr_destroy_qpair(ctrlr, &ctrlr->ioq[i]); nvme_io_qpair_destroy(&ctrlr->ioq[i]); } From owner-svn-src-stable-11@freebsd.org Thu Jun 14 16:51:40 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0E61101362E; Thu, 14 Jun 2018 16:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 56BE2740F2; Thu, 14 Jun 2018 16:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37CA43217; Thu, 14 Jun 2018 16:51:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EGpeb2079328; Thu, 14 Jun 2018 16:51:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EGpdWU079326; Thu, 14 Jun 2018 16:51:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141651.w5EGpdWU079326@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 16:51:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335150 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335150 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 16:51:40 -0000 Author: mav Date: Thu Jun 14 16:51:39 2018 New Revision: 335150 URL: https://svnweb.freebsd.org/changeset/base/335150 Log: MFC r331046 (by imp): Try polling the qpairs on timeout. On some systems, we're getting timeouts when we use multiple queues on drives that work perfectly well on other systems. On a hunch, Jim Harris suggested I poll the completion queue when we get a timeout. This patch polls the completion queue if no fatal status was indicated. If it had pending I/O, we complete that request and return. Otherwise, if aborts are enabled and no fatal status, we abort the command and return. Otherwise we reset the card. This may clear up the problem, or we may see it result in lots of timeouts and a performance problem. Either way, we'll know the next step. We may also need to pay attention to the fatal status bit of the controller. Modified: stable/11/sys/dev/nvme/nvme_private.h stable/11/sys/dev/nvme/nvme_qpair.c Modified: stable/11/sys/dev/nvme/nvme_private.h ============================================================================== --- stable/11/sys/dev/nvme/nvme_private.h Thu Jun 14 16:19:05 2018 (r335149) +++ stable/11/sys/dev/nvme/nvme_private.h Thu Jun 14 16:51:39 2018 (r335150) @@ -424,7 +424,7 @@ int nvme_qpair_construct(struct nvme_qpair *qpair, uin struct nvme_controller *ctrlr); void nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr); -void nvme_qpair_process_completions(struct nvme_qpair *qpair); +bool nvme_qpair_process_completions(struct nvme_qpair *qpair); void nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req); void nvme_qpair_reset(struct nvme_qpair *qpair); Modified: stable/11/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_qpair.c Thu Jun 14 16:19:05 2018 (r335149) +++ stable/11/sys/dev/nvme/nvme_qpair.c Thu Jun 14 16:51:39 2018 (r335150) @@ -389,11 +389,12 @@ nvme_qpair_manual_complete_request(struct nvme_qpair * nvme_free_request(req); } -void +bool nvme_qpair_process_completions(struct nvme_qpair *qpair) { struct nvme_tracker *tr; struct nvme_completion *cpl; + int done = 0; qpair->num_intr_handler_calls++; @@ -404,7 +405,7 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai * associated with this interrupt will get retried when the * reset is complete. */ - return; + return (false); while (1) { cpl = &qpair->cpl[qpair->cq_head]; @@ -417,6 +418,7 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai if (tr != NULL) { nvme_qpair_complete_tracker(qpair, tr, cpl, TRUE); qpair->sq_head = cpl->sqhd; + done++; } else { nvme_printf(qpair->ctrlr, "cpl does not map to outstanding cmd\n"); @@ -432,6 +434,7 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai nvme_mmio_write_4(qpair->ctrlr, doorbell[qpair->id].cq_hdbl, qpair->cq_head); } + return (done != 0); } static void @@ -685,18 +688,29 @@ nvme_timeout(void *arg) struct nvme_controller *ctrlr = qpair->ctrlr; union csts_register csts; - /* Read csts to get value of cfs - controller fatal status. */ + /* + * Read csts to get value of cfs - controller fatal status. + * If no fatal status, try to call the completion routine, and + * if completes transactions, report a missed interrupt and + * return (this may need to be rate limited). Otherwise, if + * aborts are enabled and the controller is not reporting + * fatal status, abort the command. Otherwise, just reset the + * controller and hope for the best. + */ csts.raw = nvme_mmio_read_4(ctrlr, csts); - + if (csts.bits.cfs == 0 && nvme_qpair_process_completions(qpair)) { + nvme_printf(ctrlr, "Missing interrupt\n"); + return; + } if (ctrlr->enable_aborts && csts.bits.cfs == 0) { - /* - * If aborts are enabled, only use them if the controller is - * not reporting fatal status. - */ + nvme_printf(ctrlr, "Aborting command due to a timeout.\n"); nvme_ctrlr_cmd_abort(ctrlr, tr->cid, qpair->id, nvme_abort_complete, tr); - } else + } else { + nvme_printf(ctrlr, "Resetting controller due to a timeout%s.\n", + csts.bits.cfs ? " and fatal error status" : ""); nvme_ctrlr_reset(ctrlr); + } } void From owner-svn-src-stable-11@freebsd.org Thu Jun 14 16:58:04 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF8C91013F0B; Thu, 14 Jun 2018 16:58:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 62AF6745EF; Thu, 14 Jun 2018 16:58:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3EB73325B; Thu, 14 Jun 2018 16:58:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EGw4Gj082583; Thu, 14 Jun 2018 16:58:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EGw4D9082582; Thu, 14 Jun 2018 16:58:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141658.w5EGw4D9082582@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 16:58:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335151 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335151 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 16:58:04 -0000 Author: mav Date: Thu Jun 14 16:58:03 2018 New Revision: 335151 URL: https://svnweb.freebsd.org/changeset/base/335151 Log: MFC r332897 (by imp), r333123: Migrate to make_dev_s interface to populate /dev/nvmeX entries Modified: stable/11/sys/dev/nvme/nvme_ns.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_ns.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ns.c Thu Jun 14 16:51:39 2018 (r335150) +++ stable/11/sys/dev/nvme/nvme_ns.c Thu Jun 14 16:58:03 2018 (r335151) @@ -479,7 +479,9 @@ int nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, struct nvme_controller *ctrlr) { + struct make_dev_args md_args; struct nvme_completion_poll_status status; + int res; int unit; ns->ctrlr = ctrlr; @@ -562,15 +564,19 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t */ unit = device_get_unit(ctrlr->dev) * NVME_MAX_NAMESPACES + ns->id - 1; - ns->cdev = make_dev_credf(0, &nvme_ns_cdevsw, unit, - NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d", + make_dev_args_init(&md_args); + md_args.mda_devsw = &nvme_ns_cdevsw; + md_args.mda_unit = unit; + md_args.mda_mode = 0600; + md_args.mda_si_drv1 = ns; + res = make_dev_s(&md_args, &ns->cdev, "nvme%dns%d", device_get_unit(ctrlr->dev), ns->id); + if (res != 0) + return (ENXIO); + #ifdef NVME_UNMAPPED_BIO_SUPPORT ns->cdev->si_flags |= SI_UNMAPPED; #endif - - if (ns->cdev != NULL) - ns->cdev->si_drv1 = ns; return (0); } From owner-svn-src-stable-11@freebsd.org Thu Jun 14 17:02:59 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 292DB1014532; Thu, 14 Jun 2018 17:02:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D065374C70; Thu, 14 Jun 2018 17:02:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B1D8F33F0; Thu, 14 Jun 2018 17:02:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EH2wNH087273; Thu, 14 Jun 2018 17:02:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EH2whq087272; Thu, 14 Jun 2018 17:02:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141702.w5EH2whq087272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 17:02:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335152 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335152 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 17:02:59 -0000 Author: mav Date: Thu Jun 14 17:02:58 2018 New Revision: 335152 URL: https://svnweb.freebsd.org/changeset/base/335152 Log: MFC r333127: Fix use-after-free in nvme_qpair_destroy(). dma_tag_payload should not be destroyed before payload_dma_map, and seems it should be used there instead of dma_tag to match creation. Modified: stable/11/sys/dev/nvme/nvme_qpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_qpair.c Thu Jun 14 16:58:03 2018 (r335151) +++ stable/11/sys/dev/nvme/nvme_qpair.c Thu Jun 14 17:02:58 2018 (r335152) @@ -606,21 +606,22 @@ nvme_qpair_destroy(struct nvme_qpair *qpair) qpair->queuemem_map); } - if (qpair->dma_tag) - bus_dma_tag_destroy(qpair->dma_tag); - - if (qpair->dma_tag_payload) - bus_dma_tag_destroy(qpair->dma_tag_payload); - if (qpair->act_tr) free(qpair->act_tr, M_NVME); while (!TAILQ_EMPTY(&qpair->free_tr)) { tr = TAILQ_FIRST(&qpair->free_tr); TAILQ_REMOVE(&qpair->free_tr, tr, tailq); - bus_dmamap_destroy(qpair->dma_tag, tr->payload_dma_map); + bus_dmamap_destroy(qpair->dma_tag_payload, + tr->payload_dma_map); free(tr, M_NVME); } + + if (qpair->dma_tag) + bus_dma_tag_destroy(qpair->dma_tag); + + if (qpair->dma_tag_payload) + bus_dma_tag_destroy(qpair->dma_tag_payload); } static void From owner-svn-src-stable-11@freebsd.org Thu Jun 14 17:06:20 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4EB221014897; Thu, 14 Jun 2018 17:06:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF49574EA9; Thu, 14 Jun 2018 17:06:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCB5033F6; Thu, 14 Jun 2018 17:06:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EH6J9l087479; Thu, 14 Jun 2018 17:06:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EH6JSj087478; Thu, 14 Jun 2018 17:06:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141706.w5EH6JSj087478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 17:06:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335153 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335153 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 17:06:20 -0000 Author: mav Date: Thu Jun 14 17:06:19 2018 New Revision: 335153 URL: https://svnweb.freebsd.org/changeset/base/335153 Log: MFC r333130: Improve nvme(4) attach/detach sequences. This change allows clean device detach on attach failures and driver unload, while previous code tried to talk to already shut down controller, or even accessed resources failed to allocate. Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 17:02:58 2018 (r335152) +++ stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 17:06:19 2018 (r335153) @@ -1151,6 +1151,7 @@ nvme_ctrlr_setup_interrupts(struct nvme_controller *ct int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) { + struct make_dev_args md_args; union cap_lo_register cap_lo; union cap_hi_register cap_hi; int status, timeout_period; @@ -1196,14 +1197,6 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de if (nvme_ctrlr_construct_admin_qpair(ctrlr) != 0) return (ENXIO); - ctrlr->cdev = make_dev(&nvme_ctrlr_cdevsw, device_get_unit(dev), - UID_ROOT, GID_WHEEL, 0600, "nvme%d", device_get_unit(dev)); - - if (ctrlr->cdev == NULL) - return (ENXIO); - - ctrlr->cdev->si_drv1 = (void *)ctrlr; - ctrlr->taskqueue = taskqueue_create("nvme_taskq", M_WAITOK, taskqueue_thread_enqueue, &ctrlr->taskqueue); taskqueue_start_threads(&ctrlr->taskqueue, 1, PI_DISK, "nvme taskq"); @@ -1212,11 +1205,22 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de ctrlr->is_initialized = 0; ctrlr->notification_sent = 0; TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr); - TASK_INIT(&ctrlr->fail_req_task, 0, nvme_ctrlr_fail_req_task, ctrlr); STAILQ_INIT(&ctrlr->fail_req); ctrlr->is_failed = FALSE; + make_dev_args_init(&md_args); + md_args.mda_devsw = &nvme_ctrlr_cdevsw; + md_args.mda_uid = UID_ROOT; + md_args.mda_gid = GID_WHEEL; + md_args.mda_mode = 0600; + md_args.mda_unit = device_get_unit(dev); + md_args.mda_si_drv1 = (void *)ctrlr; + status = make_dev_s(&md_args, &ctrlr->cdev, "nvme%d", + device_get_unit(dev)); + if (status != 0) + return (ENXIO); + return (0); } @@ -1225,18 +1229,9 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev { int i; - /* - * Notify the controller of a shutdown, even though this is due to - * a driver unload, not a system shutdown (this path is not invoked - * during shutdown). This ensures the controller receives a - * shutdown notification in case the system is shutdown before - * reloading the driver. - */ - nvme_ctrlr_shutdown(ctrlr); + if (ctrlr->resource == NULL) + goto nores; - nvme_ctrlr_disable(ctrlr); - taskqueue_free(ctrlr->taskqueue); - for (i = 0; i < NVME_MAX_NAMESPACES; i++) nvme_ns_destruct(&ctrlr->ns[i]); @@ -1247,21 +1242,24 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev nvme_ctrlr_destroy_qpair(ctrlr, &ctrlr->ioq[i]); nvme_io_qpair_destroy(&ctrlr->ioq[i]); } - free(ctrlr->ioq, M_NVME); nvme_admin_qpair_destroy(&ctrlr->adminq); - if (ctrlr->resource != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - ctrlr->resource_id, ctrlr->resource); - } + /* + * Notify the controller of a shutdown, even though this is due to + * a driver unload, not a system shutdown (this path is not invoked + * during shutdown). This ensures the controller receives a + * shutdown notification in case the system is shutdown before + * reloading the driver. + */ + nvme_ctrlr_shutdown(ctrlr); - if (ctrlr->bar4_resource != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - ctrlr->bar4_resource_id, ctrlr->bar4_resource); - } + nvme_ctrlr_disable(ctrlr); + if (ctrlr->taskqueue) + taskqueue_free(ctrlr->taskqueue); + if (ctrlr->tag) bus_teardown_intr(ctrlr->dev, ctrlr->res, ctrlr->tag); @@ -1271,6 +1269,17 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev if (ctrlr->msix_enabled) pci_release_msi(dev); + + if (ctrlr->bar4_resource != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + ctrlr->bar4_resource_id, ctrlr->bar4_resource); + } + + bus_release_resource(dev, SYS_RES_MEMORY, + ctrlr->resource_id, ctrlr->resource); + +nores: + mtx_destroy(&ctrlr->lock); } void From owner-svn-src-stable-11@freebsd.org Thu Jun 14 17:09:35 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 153B51014CAB; Thu, 14 Jun 2018 17:09:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D33E75224; Thu, 14 Jun 2018 17:09:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1EE7833FF; Thu, 14 Jun 2018 17:09:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EH9Y3m087722; Thu, 14 Jun 2018 17:09:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EH9Xk3087721; Thu, 14 Jun 2018 17:09:33 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141709.w5EH9Xk3087721@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 17:09:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335155 - stable/11/sys/dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/nvme X-SVN-Commit-Revision: 335155 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 17:09:35 -0000 Author: mav Date: Thu Jun 14 17:09:33 2018 New Revision: 335155 URL: https://svnweb.freebsd.org/changeset/base/335155 Log: MFC r333180: Fix LOR between controller and queue locks. Admin pass-through requests took controller lock before the queue lock, but in case of request submission to a failed controller controller lock was taken after the queue lock. Fix that by reducing the lock scopes and switching to mtx_pool locks to track pass-through request completion. Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 17:08:44 2018 (r335154) +++ stable/11/sys/dev/nvme/nvme_ctrlr.c Thu Jun 14 17:09:33 2018 (r335155) @@ -228,11 +228,12 @@ nvme_ctrlr_fail_req_task(void *arg, int pending) struct nvme_request *req; mtx_lock(&ctrlr->lock); - while (!STAILQ_EMPTY(&ctrlr->fail_req)) { - req = STAILQ_FIRST(&ctrlr->fail_req); + while ((req = STAILQ_FIRST(&ctrlr->fail_req)) != NULL) { STAILQ_REMOVE_HEAD(&ctrlr->fail_req, stailq); + mtx_unlock(&ctrlr->lock); nvme_qpair_manual_complete_request(req->qpair, req, NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, TRUE); + mtx_lock(&ctrlr->lock); } mtx_unlock(&ctrlr->lock); } @@ -933,15 +934,17 @@ static void nvme_pt_done(void *arg, const struct nvme_completion *cpl) { struct nvme_pt_command *pt = arg; + struct mtx *mtx = pt->driver_lock; bzero(&pt->cpl, sizeof(pt->cpl)); pt->cpl.cdw0 = cpl->cdw0; pt->cpl.status = cpl->status; pt->cpl.status.p = 0; - mtx_lock(pt->driver_lock); + mtx_lock(mtx); + pt->driver_lock = NULL; wakeup(pt); - mtx_unlock(pt->driver_lock); + mtx_unlock(mtx); } int @@ -1009,12 +1012,7 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr req->cmd.nsid = nsid; - if (is_admin_cmd) - mtx = &ctrlr->lock; - else - mtx = &ctrlr->ns[nsid-1].lock; - - mtx_lock(mtx); + mtx = mtx_pool_find(mtxpool_sleep, pt); pt->driver_lock = mtx; if (is_admin_cmd) @@ -1022,10 +1020,10 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr else nvme_ctrlr_submit_io_request(ctrlr, req); - mtx_sleep(pt, mtx, PRIBIO, "nvme_pt", 0); + mtx_lock(mtx); + while (pt->driver_lock != NULL) + mtx_sleep(pt, mtx, PRIBIO, "nvme_pt", 0); mtx_unlock(mtx); - - pt->driver_lock = NULL; err: if (buf != NULL) { From owner-svn-src-stable-11@freebsd.org Thu Jun 14 18:18:56 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FCE1101A83A; Thu, 14 Jun 2018 18:18:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 539817921D; Thu, 14 Jun 2018 18:18:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 34CB343F9; Thu, 14 Jun 2018 18:18:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EIIu5r024800; Thu, 14 Jun 2018 18:18:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EIItpZ024794; Thu, 14 Jun 2018 18:18:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141818.w5EIItpZ024794@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 18:18:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335166 - in stable/11/sys: cam cam/nvme dev/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys: cam cam/nvme dev/nvme X-SVN-Commit-Revision: 335166 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 18:18:56 -0000 Author: mav Date: Thu Jun 14 18:18:55 2018 New Revision: 335166 URL: https://svnweb.freebsd.org/changeset/base/335166 Log: MFC r325794, r325838 (by imp): Provide link speed data in XPT_GET_TRAN_SETTINGS. Provide full version information for that and XPT_PATH_INQ. Provide macros to encode/decode major/minor versions. Read the link speed and lane count to compute the base_transfer_speed for XPT_PATH_INQ. Modified: stable/11/sys/cam/cam_ccb.h stable/11/sys/cam/nvme/nvme_all.h stable/11/sys/cam/nvme/nvme_xpt.c stable/11/sys/dev/nvme/nvme.h stable/11/sys/dev/nvme/nvme_sim.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_ccb.h ============================================================================== --- stable/11/sys/cam/cam_ccb.h Thu Jun 14 17:50:29 2018 (r335165) +++ stable/11/sys/cam/cam_ccb.h Thu Jun 14 18:18:55 2018 (r335166) @@ -1003,11 +1003,15 @@ struct ccb_trans_settings_nvme u_int valid; /* Which fields to honor */ #define CTS_NVME_VALID_SPEC 0x01 #define CTS_NVME_VALID_CAPS 0x02 - u_int spec_major; /* Major version of spec supported */ - u_int spec_minor; /* Minor verison of spec supported */ - u_int spec_tiny; /* Tiny version of spec supported */ - u_int max_xfer; /* Max transfer size (0 -> unlimited */ - u_int caps; +#define CTS_NVME_VALID_LINK 0x04 + uint32_t spec; /* NVMe spec implemented -- same as vs register */ + uint32_t max_xfer; /* Max transfer size (0 -> unlimited */ + uint32_t caps; + uint8_t lanes; /* Number of PCIe lanes */ + uint8_t speed; /* PCIe generation for each lane */ + uint8_t max_lanes; /* Number of PCIe lanes */ + uint8_t max_speed; /* PCIe generation for each lane */ + u_int pad; /* Padding to keep ABI */ }; /* Get/Set transfer rate/width/disconnection/tag queueing settings */ Modified: stable/11/sys/cam/nvme/nvme_all.h ============================================================================== --- stable/11/sys/cam/nvme/nvme_all.h Thu Jun 14 17:50:29 2018 (r335165) +++ stable/11/sys/cam/nvme/nvme_all.h Thu Jun 14 18:18:55 2018 (r335166) @@ -33,8 +33,6 @@ struct ccb_nvmeio; -#define NVME_REV_1 1 /* Supports NVMe 1.2 or earlier */ - void nvme_ns_cmd(struct ccb_nvmeio *nvmeio, uint8_t cmd, uint32_t nsid, uint32_t cdw10, uint32_t cdw11, uint32_t cdw12, uint32_t cdw13, uint32_t cdw14, uint32_t cdw15); Modified: stable/11/sys/cam/nvme/nvme_xpt.c ============================================================================== --- stable/11/sys/cam/nvme/nvme_xpt.c Thu Jun 14 17:50:29 2018 (r335165) +++ stable/11/sys/cam/nvme/nvme_xpt.c Thu Jun 14 18:18:55 2018 (r335166) @@ -639,12 +639,14 @@ nvme_announce_periph(struct cam_periph *periph) static void nvme_proto_announce(struct cam_ed *device) { + nvme_print_ident(device->nvme_cdata, device->nvme_data); } static void nvme_proto_denounce(struct cam_ed *device) { + nvme_print_ident(device->nvme_cdata, device->nvme_data); } Modified: stable/11/sys/dev/nvme/nvme.h ============================================================================== --- stable/11/sys/dev/nvme/nvme.h Thu Jun 14 17:50:29 2018 (r335165) +++ stable/11/sys/dev/nvme/nvme.h Thu Jun 14 18:18:55 2018 (r335166) @@ -42,6 +42,13 @@ #define NVME_BIO_TEST _IOWR('n', 101, struct nvme_io_test) /* + * Macros to deal with NVME revisions, as defined VS register + */ +#define NVME_REV(x, y) (((x) << 16) | ((y) << 8)) +#define NVME_MAJOR(r) (((r) >> 16) & 0xffff) +#define NVME_MINOR(r) (((r) >> 8) & 0xff) + +/* * Use to mark a command to apply to all namespaces, or to retrieve global * log pages. */ Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 17:50:29 2018 (r335165) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Jun 14 18:18:55 2018 (r335166) @@ -125,6 +125,24 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb) nvme_ctrlr_submit_admin_request(ctrlr, req); } +static uint32_t +nvme_link_kBps(struct nvme_controller *ctrlr) +{ + uint32_t speed, lanes, link[] = { 1, 250000, 500000, 985000, 1970000 }; + uint32_t status; + + status = pcie_read_config(ctrlr->dev, PCIER_LINK_STA, 2); + speed = status & PCIEM_LINK_STA_SPEED; + lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4; + /* + * Failsafe on link speed indicator. If it is insane report the number of + * lanes as the speed. Not 100% accurate, but may be diagnostic. + */ + if (speed >= nitems(link)) + speed = 0; + return link[speed] * lanes; +} + static void nvme_sim_action(struct cam_sim *sim, union ccb *ccb) { @@ -183,15 +201,15 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) cpi->maxio = nvme_ns_get_max_io_xfer_size(ns); cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); - cpi->base_transfer_speed = 4000000; /* 4 GB/s 4 lanes pcie 3 */ + cpi->base_transfer_speed = nvme_link_kBps(ctrlr); strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); strncpy(cpi->hba_vid, "NVMe", HBA_IDLEN); strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_NVME; /* XXX XPORT_PCIE ? */ - cpi->transport_version = 1; /* XXX Get PCIe spec ? */ + cpi->transport_version = nvme_mmio_read_4(ctrlr, vs); cpi->protocol = PROTO_NVME; - cpi->protocol_version = NVME_REV_1; /* Groks all 1.x NVMe cards */ + cpi->protocol_version = nvme_mmio_read_4(ctrlr, vs); cpi->xport_specific.nvme.nsid = ns->id; cpi->xport_specific.nvme.domain = pci_get_domain(dev); cpi->xport_specific.nvme.bus = pci_get_bus(dev); @@ -206,20 +224,27 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb) struct ccb_trans_settings *cts; struct ccb_trans_settings_nvme *nvmep; struct ccb_trans_settings_nvme *nvmex; + device_t dev; + uint32_t status, caps; + dev = ctrlr->dev; cts = &ccb->cts; nvmex = &cts->xport_specific.nvme; nvmep = &cts->proto_specific.nvme; - nvmex->valid = CTS_NVME_VALID_SPEC; - nvmex->spec_major = 1; /* XXX read from card */ - nvmex->spec_minor = 2; - nvmex->spec_tiny = 0; + status = pcie_read_config(dev, PCIER_LINK_STA, 2); + caps = pcie_read_config(dev, PCIER_LINK_CAP, 2); + nvmex->valid = CTS_NVME_VALID_SPEC | CTS_NVME_VALID_LINK; + nvmex->spec = nvme_mmio_read_4(ctrlr, vs); + nvmex->speed = status & PCIEM_LINK_STA_SPEED; + nvmex->lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4; + nvmex->max_speed = caps & PCIEM_LINK_CAP_MAX_SPEED; + nvmex->max_lanes = (caps & PCIEM_LINK_CAP_MAX_WIDTH) >> 4; - nvmep->valid = CTS_NVME_VALID_SPEC; - nvmep->spec_major = 1; /* XXX read from card */ - nvmep->spec_minor = 2; - nvmep->spec_tiny = 0; + /* XXX these should be something else maybe ? */ + nvmep->valid = 1; + nvmep->spec = nvmex->spec; + cts->transport = XPORT_NVME; cts->protocol = PROTO_NVME; cts->ccb_h.status = CAM_REQ_CMP; From owner-svn-src-stable-11@freebsd.org Thu Jun 14 18:33:10 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1595101B86D; Thu, 14 Jun 2018 18:33:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E22D79E18; Thu, 14 Jun 2018 18:33:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 51D554754; Thu, 14 Jun 2018 18:33:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EIXA9f034927; Thu, 14 Jun 2018 18:33:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EIXAdU034926; Thu, 14 Jun 2018 18:33:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201806141833.w5EIXAdU034926@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Jun 2018 18:33:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335167 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 335167 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 18:33:11 -0000 Author: mav Date: Thu Jun 14 18:33:09 2018 New Revision: 335167 URL: https://svnweb.freebsd.org/changeset/base/335167 Log: Record MFC r331046 mergeinfo, missed in r335150. Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Thu Jun 14 18:50:51 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49D80101CABF; Thu, 14 Jun 2018 18:50:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3A767B1D9; Thu, 14 Jun 2018 18:50:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D4C0F4A1D; Thu, 14 Jun 2018 18:50:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5EIoo35040812; Thu, 14 Jun 2018 18:50:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5EIooIK040809; Thu, 14 Jun 2018 18:50:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201806141850.w5EIooIK040809@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 14 Jun 2018 18:50:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335169 - in stable/11/sys: amd64/amd64 i386/i386 i386/isa X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 i386/i386 i386/isa X-SVN-Commit-Revision: 335169 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 18:50:51 -0000 Author: kib Date: Thu Jun 14 18:50:49 2018 New Revision: 335169 URL: https://svnweb.freebsd.org/changeset/base/335169 Log: MFC r335089: Enable eager FPU context switch on i386. CVE: CVE-2018-3665 MFC r335131 Remove printf() in #NM handler. MFC r335132: Reorganize code flow in fpudna()/npxdna(). Early MFC approved by: re (gjb) Modified: stable/11/sys/amd64/amd64/fpu.c stable/11/sys/i386/i386/swtch.s stable/11/sys/i386/isa/npx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/fpu.c ============================================================================== --- stable/11/sys/amd64/amd64/fpu.c Thu Jun 14 18:34:02 2018 (r335168) +++ stable/11/sys/amd64/amd64/fpu.c Thu Jun 14 18:50:49 2018 (r335169) @@ -683,18 +683,23 @@ fpudna(void) KASSERT((curpcb->pcb_flags & PCB_FPUNOSAVE) == 0, ("fpudna while in fpu_kern_enter(FPU_KERN_NOCTX)")); - if (PCPU_GET(fpcurthread) == td) { - printf("fpudna: fpcurthread == curthread\n"); + if (__predict_false(PCPU_GET(fpcurthread) == td)) { + /* + * Some virtual machines seems to set %cr0.TS at + * arbitrary moments. Silently clear the TS bit + * regardless of the eager/lazy FPU context switch + * mode. + */ stop_emulating(); - critical_exit(); - return; + } else { + if (__predict_false(PCPU_GET(fpcurthread) != NULL)) { + panic( + "fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", + PCPU_GET(fpcurthread), + PCPU_GET(fpcurthread)->td_tid, td, td->td_tid); + } + restore_fpu_curthread(td); } - if (PCPU_GET(fpcurthread) != NULL) { - panic("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", - PCPU_GET(fpcurthread), PCPU_GET(fpcurthread)->td_tid, - td, td->td_tid); - } - restore_fpu_curthread(td); critical_exit(); } Modified: stable/11/sys/i386/i386/swtch.s ============================================================================== --- stable/11/sys/i386/i386/swtch.s Thu Jun 14 18:34:02 2018 (r335168) +++ stable/11/sys/i386/i386/swtch.s Thu Jun 14 18:50:49 2018 (r335169) @@ -296,6 +296,12 @@ sw1: cpu_switch_load_gs: mov PCB_GS(%edx),%gs + pushl %edx + pushl PCPU(CURTHREAD) + call npxswitch + popl %edx + popl %edx + /* Test if debug registers should be restored. */ testl $PCB_DBREGS,PCB_FLAGS(%edx) jz 1f Modified: stable/11/sys/i386/isa/npx.c ============================================================================== --- stable/11/sys/i386/isa/npx.c Thu Jun 14 18:34:02 2018 (r335168) +++ stable/11/sys/i386/isa/npx.c Thu Jun 14 18:50:49 2018 (r335169) @@ -191,6 +191,11 @@ int hw_float; SYSCTL_INT(_hw, HW_FLOATINGPT, floatingpoint, CTLFLAG_RD, &hw_float, 0, "Floating point instructions executed in hardware"); +int lazy_fpu_switch = 0; +SYSCTL_INT(_hw, OID_AUTO, lazy_fpu_switch, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + &lazy_fpu_switch, 0, + "Lazily load FPU context after context switch"); + int use_xsave; uint64_t xsave_mask; static uma_zone_t fpu_save_area_zone; @@ -327,6 +332,7 @@ npxinit_bsp1(void) u_int cp[4]; uint64_t xsave_mask_user; + TUNABLE_INT_FETCH("hw.lazy_fpu_switch", &lazy_fpu_switch); if (cpu_fxsr && (cpu_feature2 & CPUID2_XSAVE) != 0) { use_xsave = 1; TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); @@ -785,47 +791,20 @@ npxtrap_sse(void) return (fpetable[(mxcsr & (~mxcsr >> 7)) & 0x3f]); } -/* - * Implement device not available (DNA) exception - * - * It would be better to switch FP context here (if curthread != fpcurthread) - * and not necessarily for every context switch, but it is too hard to - * access foreign pcb's. - */ - -static int err_count = 0; - -int -npxdna(void) +static void +restore_npx_curthread(struct thread *td, struct pcb *pcb) { - if (!hw_float) - return (0); - critical_enter(); - if (PCPU_GET(fpcurthread) == curthread) { - printf("npxdna: fpcurthread == curthread %d times\n", - ++err_count); - stop_emulating(); - critical_exit(); - return (1); - } - if (PCPU_GET(fpcurthread) != NULL) { - printf("npxdna: fpcurthread = %p (%d), curthread = %p (%d)\n", - PCPU_GET(fpcurthread), - PCPU_GET(fpcurthread)->td_proc->p_pid, - curthread, curthread->td_proc->p_pid); - panic("npxdna"); - } - stop_emulating(); /* * Record new context early in case frstor causes a trap. */ - PCPU_SET(fpcurthread, curthread); + PCPU_SET(fpcurthread, td); + stop_emulating(); if (cpu_fxsr) fpu_clean_state(); - if ((curpcb->pcb_flags & PCB_NPXINITDONE) == 0) { + if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) { /* * This is the first time this thread has used the FPU or * the PCB doesn't contain a clean FPU state. Explicitly @@ -836,18 +815,54 @@ npxdna(void) * npx_initialstate, to ignite the XSAVEOPT * tracking engine. */ - bcopy(npx_initialstate, curpcb->pcb_save, cpu_max_ext_state_size); - fpurstor(curpcb->pcb_save); - if (curpcb->pcb_initial_npxcw != __INITIAL_NPXCW__) - fldcw(curpcb->pcb_initial_npxcw); - curpcb->pcb_flags |= PCB_NPXINITDONE; - if (PCB_USER_FPU(curpcb)) - curpcb->pcb_flags |= PCB_NPXUSERINITDONE; + bcopy(npx_initialstate, pcb->pcb_save, cpu_max_ext_state_size); + fpurstor(pcb->pcb_save); + if (pcb->pcb_initial_npxcw != __INITIAL_NPXCW__) + fldcw(pcb->pcb_initial_npxcw); + pcb->pcb_flags |= PCB_NPXINITDONE; + if (PCB_USER_FPU(pcb)) + pcb->pcb_flags |= PCB_NPXUSERINITDONE; } else { - fpurstor(curpcb->pcb_save); + fpurstor(pcb->pcb_save); } - critical_exit(); +} +/* + * Implement device not available (DNA) exception + * + * It would be better to switch FP context here (if curthread != fpcurthread) + * and not necessarily for every context switch, but it is too hard to + * access foreign pcb's. + */ +int +npxdna(void) +{ + struct thread *td; + + if (!hw_float) + return (0); + td = curthread; + critical_enter(); + if (__predict_false(PCPU_GET(fpcurthread) == td)) { + /* + * Some virtual machines seems to set %cr0.TS at + * arbitrary moments. Silently clear the TS bit + * regardless of the eager/lazy FPU context switch + * mode. + */ + stop_emulating(); + } else { + if (__predict_false(PCPU_GET(fpcurthread) != NULL)) { + printf( + "npxdna: fpcurthread = %p (%d), curthread = %p (%d)\n", + PCPU_GET(fpcurthread), + PCPU_GET(fpcurthread)->td_proc->p_pid, + td, td->td_proc->p_pid); + panic("npxdna"); + } + restore_npx_curthread(td, td->td_pcb); + } + critical_exit(); return (1); } @@ -869,8 +884,20 @@ npxsave(addr) xsaveopt((char *)addr, xsave_mask); else fpusave(addr); - start_emulating(); - PCPU_SET(fpcurthread, NULL); +} + +void npxswitch(struct thread *td, struct pcb *pcb); +void +npxswitch(struct thread *td, struct pcb *pcb) +{ + + if (lazy_fpu_switch || (td->td_pflags & TDP_KTHREAD) != 0 || + !PCB_USER_FPU(pcb)) { + start_emulating(); + PCPU_SET(fpcurthread, NULL); + } else if (PCPU_GET(fpcurthread) != td) { + restore_npx_curthread(td, pcb); + } } /* From owner-svn-src-stable-11@freebsd.org Fri Jun 15 08:59:26 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 033A5100C29F; Fri, 15 Jun 2018 08:59:26 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AAC2081B64; Fri, 15 Jun 2018 08:59:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 87B3F153B7; Fri, 15 Jun 2018 08:59:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5F8xPE1077807; Fri, 15 Jun 2018 08:59:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5F8xP6U077806; Fri, 15 Jun 2018 08:59:25 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201806150859.w5F8xP6U077806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 15 Jun 2018 08:59:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335191 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 335191 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 08:59:26 -0000 Author: markj Date: Fri Jun 15 08:59:24 2018 New Revision: 335191 URL: https://svnweb.freebsd.org/changeset/base/335191 Log: MFC r334506: Avoid completing I/O when dumping core after a panic. Modified: stable/11/sys/kern/vfs_bio.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_bio.c ============================================================================== --- stable/11/sys/kern/vfs_bio.c Fri Jun 15 08:36:21 2018 (r335190) +++ stable/11/sys/kern/vfs_bio.c Fri Jun 15 08:59:24 2018 (r335191) @@ -3942,6 +3942,8 @@ allocbuf(struct buf *bp, int size) extern int inflight_transient_maps; +static struct bio_queue nondump_bios; + void biodone(struct bio *bp) { @@ -3949,6 +3951,17 @@ biodone(struct bio *bp) void (*done)(struct bio *); vm_offset_t start, end; + + /* + * Avoid completing I/O when dumping after a panic since that may + * result in a deadlock in the filesystem or pager code. Note that + * this doesn't affect dumps that were started manually since we aim + * to keep the system usable after it has been resumed. + */ + if (__predict_false(dumping && SCHEDULER_STOPPED())) { + TAILQ_INSERT_HEAD(&nondump_bios, bp, bio_queue); + return; + } if ((bp->bio_flags & BIO_TRANSIENT_MAPPING) != 0) { bp->bio_flags &= ~BIO_TRANSIENT_MAPPING; bp->bio_flags |= BIO_UNMAPPED; From owner-svn-src-stable-11@freebsd.org Fri Jun 15 15:02:00 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82A1D100DC90; Fri, 15 Jun 2018 15:02:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 37E8D726EA; Fri, 15 Jun 2018 15:02:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AA9F18F5A; Fri, 15 Jun 2018 15:02:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5FF1xKT067588; Fri, 15 Jun 2018 15:01:59 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5FF1x8Y067587; Fri, 15 Jun 2018 15:01:59 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201806151501.w5FF1x8Y067587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 15 Jun 2018 15:01:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335202 - stable/11/lib/libmagic X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/lib/libmagic X-SVN-Commit-Revision: 335202 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 15:02:00 -0000 Author: bdrewery Date: Fri Jun 15 15:01:59 2018 New Revision: 335202 URL: https://svnweb.freebsd.org/changeset/base/335202 Log: MFC r330702: LIB32: Avoid linking in unneeded (and invalid lib32) libz for libmagic build tool. Modified: stable/11/lib/libmagic/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libmagic/Makefile ============================================================================== --- stable/11/lib/libmagic/Makefile Fri Jun 15 14:41:51 2018 (r335201) +++ stable/11/lib/libmagic/Makefile Fri Jun 15 15:01:59 2018 (r335202) @@ -8,7 +8,9 @@ CONTRDIR= ${SRCTOP}/contrib/file LIB= magic SHLIB_MAJOR= 4 +.if !make(build-tools) LIBADD= z +.endif MAN= libmagic.3 magic.5 SRCS= apprentice.c apptype.c ascmagic.c cdf.c cdf_time.c compress.c \ From owner-svn-src-stable-11@freebsd.org Fri Jun 15 15:05:01 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A1AB100DF26; Fri, 15 Jun 2018 15:05:01 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E39AF7299F; Fri, 15 Jun 2018 15:05:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C617318F89; Fri, 15 Jun 2018 15:05:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5FF50E9070861; Fri, 15 Jun 2018 15:05:00 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5FF50mS070860; Fri, 15 Jun 2018 15:05:00 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201806151505.w5FF50mS070860@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 15 Jun 2018 15:05:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335203 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 335203 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 15:05:01 -0000 Author: bdrewery Date: Fri Jun 15 15:05:00 2018 New Revision: 335203 URL: https://svnweb.freebsd.org/changeset/base/335203 Log: MFC r334791,r334811: r334791: Stop using head(1) which is not available in installworld. r334811: Use simpler sed invocation. Modified: stable/11/share/mk/bsd.linker.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/bsd.linker.mk ============================================================================== --- stable/11/share/mk/bsd.linker.mk Fri Jun 15 15:01:59 2018 (r335202) +++ stable/11/share/mk/bsd.linker.mk Fri Jun 15 15:05:00 2018 (r335203) @@ -49,7 +49,7 @@ ${var}= ${${var}.${${X_}_ld_hash}} .if ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD}) .if !defined(${X_}LINKER_TYPE) || !defined(${X_}LINKER_VERSION) -_ld_version!= (${${ld}} --version || echo none) | head -n 1 +_ld_version!= (${${ld}} --version || echo none) | sed -n 1p .if ${_ld_version} == "none" .warning Unable to determine linker type from ${ld}=${${ld}} .endif From owner-svn-src-stable-11@freebsd.org Fri Jun 15 15:10:22 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 201E5100E295; Fri, 15 Jun 2018 15:10:22 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C9A6572C04; Fri, 15 Jun 2018 15:10:21 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AA96B18F93; Fri, 15 Jun 2018 15:10:21 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5FFALmr071176; Fri, 15 Jun 2018 15:10:21 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5FFALr8071175; Fri, 15 Jun 2018 15:10:21 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201806151510.w5FFALr8071175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 15 Jun 2018 15:10:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335204 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 335204 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 15:10:22 -0000 Author: bdrewery Date: Fri Jun 15 15:10:21 2018 New Revision: 335204 URL: https://svnweb.freebsd.org/changeset/base/335204 Log: MFC r325560: META_MODE: Bmake 20171028 in r325340 simplifies the meta filename. Modified: stable/11/share/mk/bsd.dep.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/bsd.dep.mk ============================================================================== --- stable/11/share/mk/bsd.dep.mk Fri Jun 15 15:05:00 2018 (r335203) +++ stable/11/share/mk/bsd.dep.mk Fri Jun 15 15:10:21 2018 (r335204) @@ -226,10 +226,14 @@ afterdepend: beforedepend # mimicing what bmake's meta_name() does and adding in the full path # as well to ensure that the expected meta file is read. .if ${__obj:M*/*} +.if ${MAKE_VERSION} < 20171028 _meta_obj= ${.OBJDIR:C,/,_,g}_${__obj:C,/,_,g}.meta .else +_meta_obj= ${__obj:C,/,_,g}.meta +.endif # ${MAKE_VERSION} < 20171028 +.else _meta_obj= ${__obj}.meta -.endif +.endif # ${__obj:M*/*} _dep_obj= ${DEPENDFILE}.${__obj:${DEPEND_FILTER}} .if (defined(_meta_filemon) && !exists(${.OBJDIR}/${_meta_obj})) || \ (!defined(_meta_filemon) && !exists(${.OBJDIR}/${_dep_obj})) From owner-svn-src-stable-11@freebsd.org Sat Jun 16 09:32:06 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 220B11010421; Sat, 16 Jun 2018 09:32:06 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C88927B6DD; Sat, 16 Jun 2018 09:32:05 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A9BF0248CB; Sat, 16 Jun 2018 09:32:05 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5G9W5Jm040540; Sat, 16 Jun 2018 09:32:05 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5G9W5Fv040539; Sat, 16 Jun 2018 09:32:05 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201806160932.w5G9W5Fv040539@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 16 Jun 2018 09:32:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335251 - stable/11/sys/netpfil/pf X-SVN-Group: stable-11 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/11/sys/netpfil/pf X-SVN-Commit-Revision: 335251 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2018 09:32:06 -0000 Author: kp Date: Sat Jun 16 09:32:05 2018 New Revision: 335251 URL: https://svnweb.freebsd.org/changeset/base/335251 Log: MFC r334876: pf: Fix deadlock with route-to If a locally generated packet is routed (with route-to/reply-to/dup-to) out of a different interface it's passed through the firewall again. This meant we lost the inp pointer and if we required the pointer (e.g. for user ID matching) we'd deadlock trying to acquire an inp lock we've already got. Pass the inp pointer along with pf_route()/pf_route6(). PR: 228782 Modified: stable/11/sys/netpfil/pf/pf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf.c ============================================================================== --- stable/11/sys/netpfil/pf/pf.c Sat Jun 16 08:26:23 2018 (r335250) +++ stable/11/sys/netpfil/pf/pf.c Sat Jun 16 09:32:05 2018 (r335251) @@ -290,14 +290,14 @@ static void pf_mtag_free(struct m_tag *); #ifdef INET static void pf_route(struct mbuf **, struct pf_rule *, int, struct ifnet *, struct pf_state *, - struct pf_pdesc *); + struct pf_pdesc *, struct inpcb *); #endif /* INET */ #ifdef INET6 static void pf_change_a6(struct pf_addr *, u_int16_t *, struct pf_addr *, u_int8_t); static void pf_route6(struct mbuf **, struct pf_rule *, int, struct ifnet *, struct pf_state *, - struct pf_pdesc *); + struct pf_pdesc *, struct inpcb *); #endif /* INET6 */ int in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len); @@ -5428,7 +5428,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, stru #ifdef INET static void pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, - struct pf_state *s, struct pf_pdesc *pd) + struct pf_state *s, struct pf_pdesc *pd, struct inpcb *inp) { struct mbuf *m0, *m1; struct sockaddr_in dst; @@ -5513,7 +5513,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, goto bad; if (oifp != ifp) { - if (pf_test(PF_OUT, 0, ifp, &m0, NULL) != PF_PASS) + if (pf_test(PF_OUT, 0, ifp, &m0, inp) != PF_PASS) goto bad; else if (m0 == NULL) goto done; @@ -5606,7 +5606,7 @@ bad: #ifdef INET6 static void pf_route6(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, - struct pf_state *s, struct pf_pdesc *pd) + struct pf_state *s, struct pf_pdesc *pd, struct inpcb *inp) { struct mbuf *m0; struct sockaddr_in6 dst; @@ -5685,7 +5685,7 @@ pf_route6(struct mbuf **m, struct pf_rule *r, int dir, goto bad; if (oifp != ifp) { - if (pf_test6(PF_OUT, PFIL_FWD, ifp, &m0, NULL) != PF_PASS) + if (pf_test6(PF_OUT, PFIL_FWD, ifp, &m0, inp) != PF_PASS) goto bad; else if (m0 == NULL) goto done; @@ -6248,7 +6248,7 @@ done: default: /* pf_route() returns unlocked. */ if (r->rt) { - pf_route(m0, r, dir, kif->pfik_ifp, s, &pd); + pf_route(m0, r, dir, kif->pfik_ifp, s, &pd, inp); return (action); } break; @@ -6644,7 +6644,7 @@ done: default: /* pf_route6() returns unlocked. */ if (r->rt) { - pf_route6(m0, r, dir, kif->pfik_ifp, s, &pd); + pf_route6(m0, r, dir, kif->pfik_ifp, s, &pd, inp); return (action); } break;