From owner-svn-src-stable-11@freebsd.org Sun Jul 15 13:50: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 23DE6103FD72; Sun, 15 Jul 2018 13:50:02 +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 C88AF88CF4; Sun, 15 Jul 2018 13:50:01 +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 A4F3F6C05; Sun, 15 Jul 2018 13:50:01 +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 w6FDo1CA075983; Sun, 15 Jul 2018 13:50:01 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6FDo1Dq075982; Sun, 15 Jul 2018 13:50:01 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201807151350.w6FDo1Dq075982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sun, 15 Jul 2018 13:50: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: r336304 - stable/11/usr.sbin/syslogd X-SVN-Group: stable-11 X-SVN-Commit-Author: ed X-SVN-Commit-Paths: stable/11/usr.sbin/syslogd X-SVN-Commit-Revision: 336304 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.27 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, 15 Jul 2018 13:50:02 -0000 Author: ed Date: Sun Jul 15 13:50:01 2018 New Revision: 336304 URL: https://svnweb.freebsd.org/changeset/base/336304 Log: MFC r336060: Allow the use of slashes in process names of RFC 3164 formatted messages. Tools such as Postfix use slashes in process names for hierarchy (postfix/qmgr). By allowing these slashes, syslogd is able to extract the process name and process ID nicely, so that they can be stored in RFC 5424 message fields. Modified: stable/11/usr.sbin/syslogd/syslogd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/11/usr.sbin/syslogd/syslogd.c Sun Jul 15 09:14:30 2018 (r336303) +++ stable/11/usr.sbin/syslogd/syslogd.c Sun Jul 15 13:50:01 2018 (r336304) @@ -1118,7 +1118,7 @@ parsemsg_rfc3164_app_name_procid(char **msg, const cha "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" - "_-"); + "_-/"); if (app_name_length == 0) goto bad; m += app_name_length; From owner-svn-src-stable-11@freebsd.org Sun Jul 15 15:28:24 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 AA20C1043209; Sun, 15 Jul 2018 15:28:24 +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 51A9D8BD19; Sun, 15 Jul 2018 15:28:24 +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 32E0D7BDC; Sun, 15 Jul 2018 15:28:24 +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 w6FFSOCv027672; Sun, 15 Jul 2018 15:28:24 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6FFSNVr027670; Sun, 15 Jul 2018 15:28:23 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807151528.w6FFSNVr027670@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 15 Jul 2018 15:28: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: r336305 - stable/11/lib/msun/src X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/lib/msun/src X-SVN-Commit-Revision: 336305 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.27 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, 15 Jul 2018 15:28:24 -0000 Author: markj Date: Sun Jul 15 15:28:23 2018 New Revision: 336305 URL: https://svnweb.freebsd.org/changeset/base/336305 Log: MFC r336090: Reduce diff between msun/src/e_pow.c and msun/src/e_powf.c. PR: 229420 Modified: stable/11/lib/msun/src/e_pow.c stable/11/lib/msun/src/e_powf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/msun/src/e_pow.c ============================================================================== --- stable/11/lib/msun/src/e_pow.c Sun Jul 15 13:50:01 2018 (r336304) +++ stable/11/lib/msun/src/e_pow.c Sun Jul 15 15:28:23 2018 (r336305) @@ -65,6 +65,9 @@ bp[] = {1.0, 1.5,}, dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ zero = 0.0, +half = 0.5, +qrtr = 0.25, +thrd = 3.3333333333333331e-01, /* 0x3fd55555, 0x55555555 */ one = 1.0, two = 2.0, two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ @@ -197,7 +200,7 @@ __ieee754_pow(double x, double y) /* now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4 */ t = ax-one; /* t has 20 trailing zeros */ - w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); + w = (t*t)*(half-t*(thrd-t*qrtr)); u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ v = t*ivln2_l-w*ivln2; t1 = u+v; @@ -234,9 +237,9 @@ __ieee754_pow(double x, double y) r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); r += s_l*(s_h+ss); s2 = s_h*s_h; - t_h = 3.0+s2+r; + t_h = 3+s2+r; SET_LOW_WORD(t_h,0); - t_l = r-((t_h-3.0)-s2); + t_l = r-((t_h-3)-s2); /* u+v = ss*(1+...) */ u = s_h*t_h; v = s_l*t_h+t_l*ss; @@ -247,7 +250,7 @@ __ieee754_pow(double x, double y) z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l*p_h+p_l*cp+dp_l[k]; /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (double)n; + t = n; t1 = (((z_h+z_l)+dp_h[k])+t); SET_LOW_WORD(t1,0); t2 = z_l-(((t1-t)-dp_h[k])-z_h); Modified: stable/11/lib/msun/src/e_powf.c ============================================================================== --- stable/11/lib/msun/src/e_powf.c Sun Jul 15 13:50:01 2018 (r336304) +++ stable/11/lib/msun/src/e_powf.c Sun Jul 15 15:28:23 2018 (r336305) @@ -24,6 +24,9 @@ bp[] = {1.0, 1.5,}, dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ zero = 0.0, +half = 0.5, +qrtr = 0.25, +thrd = 3.33333343e-01, /* 0x3eaaaaab */ one = 1.0, two = 2.0, two24 = 16777216.0, /* 0x4b800000 */ @@ -138,7 +141,7 @@ __ieee754_powf(float x, float y) /* now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4 */ t = ax-1; /* t has 20 trailing zeros */ - w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25)); + w = (t*t)*(half-t*(thrd-t*qrtr)); u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ v = t*ivln2_l-w*ivln2; t1 = u+v; @@ -177,10 +180,10 @@ __ieee754_powf(float x, float y) r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); r += s_l*(s_h+s); s2 = s_h*s_h; - t_h = (float)3.0+s2+r; + t_h = 3+s2+r; GET_FLOAT_WORD(is,t_h); SET_FLOAT_WORD(t_h,is&0xfffff000); - t_l = r-((t_h-(float)3.0)-s2); + t_l = r-((t_h-3)-s2); /* u+v = s*(1+...) */ u = s_h*t_h; v = s_l*t_h+t_l*s; @@ -192,7 +195,7 @@ __ieee754_powf(float x, float y) z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l*p_h+p_l*cp+dp_l[k]; /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (float)n; + t = n; t1 = (((z_h+z_l)+dp_h[k])+t); GET_FLOAT_WORD(is,t1); SET_FLOAT_WORD(t1,is&0xfffff000); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 00:20: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 066581031787; Mon, 16 Jul 2018 00:20:20 +0000 (UTC) (envelope-from pfg@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 A2F5F76C5E; Mon, 16 Jul 2018 00:20:19 +0000 (UTC) (envelope-from pfg@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 7B11C151C3; Mon, 16 Jul 2018 00:20:19 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6G0KJVE097912; Mon, 16 Jul 2018 00:20:19 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G0KJMP097911; Mon, 16 Jul 2018 00:20:19 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201807160020.w6G0KJMP097911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 16 Jul 2018 00:20: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: r336322 - stable/11/lib/libiconv_modules/mapper_std X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/lib/libiconv_modules/mapper_std X-SVN-Commit-Revision: 336322 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.27 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, 16 Jul 2018 00:20:20 -0000 Author: pfg Date: Mon Jul 16 00:20:18 2018 New Revision: 336322 URL: https://svnweb.freebsd.org/changeset/base/336322 Log: MFC r336115; libiconv: correct undefined behavior. Detected on NetBSD: # nm /usr/lib/libc.so|grep sanit /public/src.git/lib/libc/citrus/modules/citrus_mapper_std.c:173:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Obtained from: NetBSD (CVS Rev. 1.11) Modified: stable/11/lib/libiconv_modules/mapper_std/citrus_mapper_std.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libiconv_modules/mapper_std/citrus_mapper_std.c ============================================================================== --- stable/11/lib/libiconv_modules/mapper_std/citrus_mapper_std.c Sun Jul 15 22:18:31 2018 (r336321) +++ stable/11/lib/libiconv_modules/mapper_std/citrus_mapper_std.c Mon Jul 16 00:20:18 2018 (r336322) @@ -1,5 +1,5 @@ /* $FreeBSD$ */ -/* $NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $ */ +/* $NetBSD: citrus_mapper_std.c,v 1.11 2018/06/11 18:03:38 kamil Exp $ */ /*- * Copyright (c)2003, 2006 Citrus Project, @@ -159,7 +159,7 @@ rowcol_parse_variable_compat(struct _citrus_mapper_std rc->rc_dst_invalid = be32toh(rcx->rcx_dst_invalid); rc->rc_dst_unit_bits = be32toh(rcx->rcx_dst_unit_bits); m = be32toh(rcx->rcx_src_col_bits); - n = 1 << (m - 1); + n = 1U << (m - 1); n |= n - 1; rc->rc_src_rowcol_bits = m; rc->rc_src_rowcol_mask = n; From owner-svn-src-stable-11@freebsd.org Mon Jul 16 00:23: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 C06A71031B08; Mon, 16 Jul 2018 00:23:10 +0000 (UTC) (envelope-from pfg@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 6D876770B2; Mon, 16 Jul 2018 00:23:10 +0000 (UTC) (envelope-from pfg@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 349981534C; Mon, 16 Jul 2018 00:23:10 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6G0N9lI002822; Mon, 16 Jul 2018 00:23:09 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G0N91L002821; Mon, 16 Jul 2018 00:23:09 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201807160023.w6G0N91L002821@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 16 Jul 2018 00:23:09 +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: r336323 - stable/11/usr.bin/gzip X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/usr.bin/gzip X-SVN-Commit-Revision: 336323 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.27 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, 16 Jul 2018 00:23:11 -0000 Author: pfg Date: Mon Jul 16 00:23:09 2018 New Revision: 336323 URL: https://svnweb.freebsd.org/changeset/base/336323 Log: MFC r336113: gzip: fix for undefined behavior. Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined: # progress -zf ./games.tgz tar -xp -C "./" -f - /public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of 251 by 24 places cannot be represented in type 'int' 100% |****************************************************************************************************************| 44500 KiB 119.69 MiB/s 00:00 ETA Refactor the following code into something that is more clear and fix signed integer shift, by casting all buf[] elements to (unsigned int): unsigned char buf[8]; uint32_t usize; [...] else { usize = buf[4] | buf[5] << 8 | buf[6] << 16 | buf[7] << 24; [...] New version: usize = buf[4]; usize |= (unsigned int)buf[5] << 8; usize |= (unsigned int)buf[6] << 16; usize |= (unsigned int)buf[7] << 24; Only the "<< 24" part needs explicit cast, but for consistency make the integer promotion explicit and clear to a code reader. Sponsored by Obtained from: NetBSD (CVS rev. 1.113) Modified: stable/11/usr.bin/gzip/gzip.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/gzip/gzip.c ============================================================================== --- stable/11/usr.bin/gzip/gzip.c Mon Jul 16 00:20:18 2018 (r336322) +++ stable/11/usr.bin/gzip/gzip.c Mon Jul 16 00:23:09 2018 (r336323) @@ -1,4 +1,4 @@ -/* $NetBSD: gzip.c,v 1.112 2017/08/23 13:04:17 christos Exp $ */ +/* $NetBSD: gzip.c,v 1.113 2018/06/12 00:42:17 kamil Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -2170,12 +2170,16 @@ print_list(int fd, off_t out, const char *outfile, tim maybe_warnx("read of uncompressed size"); else { - usize = buf[4] | buf[5] << 8 | - buf[6] << 16 | buf[7] << 24; + usize = buf[4]; + usize |= (unsigned int)buf[5] << 8; + usize |= (unsigned int)buf[6] << 16; + usize |= (unsigned int)buf[7] << 24; in = (off_t)usize; #ifndef SMALL - crc = buf[0] | buf[1] << 8 | - buf[2] << 16 | buf[3] << 24; + crc = buf[0]; + crc |= (unsigned int)buf[1] << 8; + crc |= (unsigned int)buf[2] << 16; + crc |= (unsigned int)buf[3] << 24; #endif } } From owner-svn-src-stable-11@freebsd.org Mon Jul 16 02:49: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 838211038D16; Mon, 16 Jul 2018 02:49:00 +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 374177B2B2; Mon, 16 Jul 2018 02:49:00 +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 180021698A; Mon, 16 Jul 2018 02:49:00 +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 w6G2mxe4073746; Mon, 16 Jul 2018 02:48:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G2mx3j073745; Mon, 16 Jul 2018 02:48:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201807160248.w6G2mx3j073745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 16 Jul 2018 02:48: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: r336327 - stable/11/stand/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/stand/zfs X-SVN-Commit-Revision: 336327 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.27 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, 16 Jul 2018 02:49:00 -0000 Author: mav Date: Mon Jul 16 02:48:59 2018 New Revision: 336327 URL: https://svnweb.freebsd.org/changeset/base/336327 Log: MFC r335874: Cut currdev dev and path fields for ZFS on the last colon. Previously the code cut those fields on second colon, that prevented boot from boot environments with colon in their names. This change moves the limitation from dev field to path, which is empty by default. Modified: stable/11/stand/zfs/zfs.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/zfs/zfs.c ============================================================================== --- stable/11/stand/zfs/zfs.c Mon Jul 16 01:34:45 2018 (r336326) +++ stable/11/stand/zfs/zfs.c Mon Jul 16 02:48:59 2018 (r336327) @@ -660,7 +660,7 @@ zfs_parsedev(struct zfs_devdesc *dev, const char *devs if (*np != ':') return (EINVAL); np++; - end = strchr(np, ':'); + end = strrchr(np, ':'); if (end == NULL) return (EINVAL); sep = strchr(np, '/'); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 03:59:42 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 2C70B103C215; Mon, 16 Jul 2018 03:59:42 +0000 (UTC) (envelope-from delphij@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 D00597D6C9; Mon, 16 Jul 2018 03:59:41 +0000 (UTC) (envelope-from delphij@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 B101017597; Mon, 16 Jul 2018 03:59:41 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6G3xfMP010470; Mon, 16 Jul 2018 03:59:41 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G3xeDb010466; Mon, 16 Jul 2018 03:59:40 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201807160359.w6G3xeDb010466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 16 Jul 2018 03:59:40 +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: r336328 - stable/11/sbin/newfs_msdos X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/sbin/newfs_msdos X-SVN-Commit-Revision: 336328 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.27 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, 16 Jul 2018 03:59:42 -0000 Author: delphij Date: Mon Jul 16 03:59:40 2018 New Revision: 336328 URL: https://svnweb.freebsd.org/changeset/base/336328 Log: MFC r318355,318366: add -T (timestamp) option for reproducible builds Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c stable/11/sbin/newfs_msdos/mkfs_msdos.h stable/11/sbin/newfs_msdos/newfs_msdos.8 stable/11/sbin/newfs_msdos/newfs_msdos.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- stable/11/sbin/newfs_msdos/mkfs_msdos.c Mon Jul 16 02:48:59 2018 (r336327) +++ stable/11/sbin/newfs_msdos/mkfs_msdos.c Mon Jul 16 03:59:40 2018 (r336328) @@ -573,9 +573,17 @@ mkfs_msdos(const char *fname, const char *dtype, const } print_bpb(&bpb); if (!o.no_create) { - gettimeofday(&tv, NULL); - now = tv.tv_sec; - tm = localtime(&now); + if (o.timestamp_set) { + tv.tv_sec = now = o.timestamp; + tv.tv_usec = 0; + tm = gmtime(&now); + } else { + gettimeofday(&tv, NULL); + now = tv.tv_sec; + tm = localtime(&now); + } + + if (!(img = malloc(bpb.bpbBytesPerSec))) { warn(NULL); goto done; Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.h ============================================================================== --- stable/11/sbin/newfs_msdos/mkfs_msdos.h Mon Jul 16 02:48:59 2018 (r336327) +++ stable/11/sbin/newfs_msdos/mkfs_msdos.h Mon Jul 16 03:59:40 2018 (r336328) @@ -42,6 +42,7 @@ AOPT('L', const char *, volume_label, -1, "Volume Labe AOPT('N', bool, no_create, -2, "Don't create filesystem, print params only") \ AOPT('O', const char *, OEM_string, -1, "OEM string") \ AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \ +AOPT('T', time_t, timestamp, 0, "Timestamp") \ AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \ AOPT('b', uint32_t, block_size, 1, "Block size") \ AOPT('c', uint8_t, sectors_per_cluster, 1, "Sectors per cluster") \ @@ -61,6 +62,7 @@ struct msdos_options { #define AOPT(_opt, _type, _name, _min, _desc) _type _name; ALLOPTS #undef AOPT + uint32_t timestamp_set:1; uint32_t volume_id_set:1; uint32_t media_descriptor_set:1; uint32_t hidden_sectors_set:1; Modified: stable/11/sbin/newfs_msdos/newfs_msdos.8 ============================================================================== --- stable/11/sbin/newfs_msdos/newfs_msdos.8 Mon Jul 16 02:48:59 2018 (r336327) +++ stable/11/sbin/newfs_msdos/newfs_msdos.8 Mon Jul 16 03:59:40 2018 (r336328) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 9, 2015 +.Dd May 16, 2017 .Dt NEWFS_MSDOS 8 .Os .Sh NAME @@ -38,10 +38,11 @@ .Op Fl B Ar boot .Op Fl C Ar create-size .Op Fl F Ar FAT-type -.Op Fl I Ar VolumeId +.Op Fl I Ar VolumeID .Op Fl L Ar label .Op Fl O Ar OEM .Op Fl S Ar sector-size +.Op Fl T Ar timestamp .Op Fl a Ar FAT-size .Op Fl b Ar block-size .Op Fl c Ar cluster-size @@ -117,6 +118,14 @@ The default is Number of bytes per sector. Acceptable values are powers of 2 in the range 512 through 32768, inclusive. +.It Fl T Ar timestamp +Create the filesystem as though the current time is +.Ar timestamp . +The default filesystem volume ID is derived from the time. +.Ar timestamp +can be a pathname (where the timestamp is derived from +that file) or an integer value interpreted +as the number of seconds since the Epoch. .It Fl a Ar FAT-size Number of sectors per FAT. .It Fl b Ar block-size @@ -163,7 +172,7 @@ File system size. Number of sectors per track. .El .Sh NOTES -If some parameters (e.g. size, number of sectors, etc.) are not specified +If some parameters (e.g., size, number of sectors, etc.) are not specified through options or disktype, the program tries to generate them automatically. In particular, the size is determined as the device or file size minus the offset specified with the Modified: stable/11/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/11/sbin/newfs_msdos/newfs_msdos.c Mon Jul 16 02:48:59 2018 (r336327) +++ stable/11/sbin/newfs_msdos/newfs_msdos.c Mon Jul 16 03:59:40 2018 (r336328) @@ -33,7 +33,7 @@ static const char rcsid[] = #endif /* not lint */ #include - +#include #include #include #include @@ -53,13 +53,30 @@ static u_int argtou(const char *, u_int, u_int, const static off_t argtooff(const char *, const char *); static void usage(void); +static time_t +get_tstamp(const char *b) +{ + struct stat st; + char *eb; + long long l; + + if (stat(b, &st) != -1) + return (time_t)st.st_mtime; + + errno = 0; + l = strtoll(b, &eb, 0); + if (b == eb || *eb || errno) + errx(EXIT_FAILURE, "Can't parse timestamp '%s'", b); + return (time_t)l; +} + /* * Construct a FAT12, FAT16, or FAT32 file system. */ int main(int argc, char *argv[]) { - static const char opts[] = "@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:u:"; + static const char opts[] = "@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:"; struct msdos_options o; const char *fname, *dtype; char buf[MAXPATHLEN]; @@ -143,6 +160,10 @@ main(int argc, char *argv[]) break; case 's': o.size = argto4(optarg, 1, "file system size"); + break; + case 'T': + o.timestamp_set = 1; + o.timestamp = get_tstamp(optarg); break; case 'u': o.sectors_per_track = argto2(optarg, 1, "sectors/track"); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 04:06: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 8D695103C672; Mon, 16 Jul 2018 04:06:36 +0000 (UTC) (envelope-from delphij@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 37F3D7DBDD; Mon, 16 Jul 2018 04:06:36 +0000 (UTC) (envelope-from delphij@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 0F3651774F; Mon, 16 Jul 2018 04:06:36 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6G46ZeS015437; Mon, 16 Jul 2018 04:06:35 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G46ZDJ015432; Mon, 16 Jul 2018 04:06:35 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201807160406.w6G46ZDJ015432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 16 Jul 2018 04:06: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: r336329 - stable/11/sbin/newfs_msdos X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/sbin/newfs_msdos X-SVN-Commit-Revision: 336329 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.27 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, 16 Jul 2018 04:06:36 -0000 Author: delphij Date: Mon Jul 16 04:06:34 2018 New Revision: 336329 URL: https://svnweb.freebsd.org/changeset/base/336329 Log: MFC r335189: Added option to cluster-align the start of the root directory. Obtained from: Android Obtained from: https://android.googlesource.com/platform/system/core/+/052f27562154d175267999106bd6bf18fc8c363e Obtained from: https://android.googlesource.com/platform/system/core/+/8218b6aae9cd4a19fa074a8a8203fe9275b35447 Differential Revision: https://reviews.freebsd.org/D15672 Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c stable/11/sbin/newfs_msdos/mkfs_msdos.h stable/11/sbin/newfs_msdos/newfs_msdos.8 stable/11/sbin/newfs_msdos/newfs_msdos.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- stable/11/sbin/newfs_msdos/mkfs_msdos.c Mon Jul 16 03:59:40 2018 (r336328) +++ stable/11/sbin/newfs_msdos/mkfs_msdos.c Mon Jul 16 04:06:34 2018 (r336329) @@ -242,6 +242,8 @@ mkfs_msdos(const char *fname, const char *dtype, const ssize_t n; time_t now; u_int fat, bss, rds, cls, dir, lsn, x, x1, x2; + u_int extra_res, alignment, saved_x, attempts=0; + bool set_res, set_spf, set_spc; int fd, fd1, rv; struct msdos_options o = *op; @@ -492,50 +494,83 @@ mkfs_msdos(const char *fname, const char *dtype, const if (bpb.bpbBackup != MAXU16 && x <= bpb.bpbBackup) x = bpb.bpbBackup + 1; } - if (!bpb.bpbResSectors) - bpb.bpbResSectors = fat == 32 ? - MAX(x, MAX(16384 / bpb.bpbBytesPerSec, 4)) : x; - else if (bpb.bpbResSectors < x) { - warnx("too few reserved sectors (need %d have %d)", x, - bpb.bpbResSectors); - goto done; - } - if (fat != 32 && !bpb.bpbRootDirEnts) - bpb.bpbRootDirEnts = DEFRDE; - rds = howmany(bpb.bpbRootDirEnts, bpb.bpbBytesPerSec / sizeof(struct de)); - if (!bpb.bpbSecPerClust) - for (bpb.bpbSecPerClust = howmany(fat == 16 ? DEFBLK16 : - DEFBLK, bpb.bpbBytesPerSec); - bpb.bpbSecPerClust < MAXSPC && - bpb.bpbResSectors + - howmany((RESFTE + maxcls(fat)) * (fat / BPN), - bpb.bpbBytesPerSec * NPB) * - bpb.bpbFATs + - rds + - (u_int64_t) (maxcls(fat) + 1) * - bpb.bpbSecPerClust <= bpb.bpbHugeSectors; - bpb.bpbSecPerClust <<= 1) - continue; - if (fat != 32 && bpb.bpbBigFATsecs > MAXU16) { - warnx("too many sectors/FAT for FAT12/16"); - goto done; - } - x1 = bpb.bpbResSectors + rds; - x = bpb.bpbBigFATsecs ? bpb.bpbBigFATsecs : 1; - if (x1 + (u_int64_t)x * bpb.bpbFATs > bpb.bpbHugeSectors) { - warnx("meta data exceeds file system size"); - goto done; - } - x1 += x * bpb.bpbFATs; - x = (u_int64_t)(bpb.bpbHugeSectors - x1) * bpb.bpbBytesPerSec * NPB / - (bpb.bpbSecPerClust * bpb.bpbBytesPerSec * NPB + fat / - BPN * bpb.bpbFATs); - x2 = howmany((RESFTE + MIN(x, maxcls(fat))) * (fat / BPN), - bpb.bpbBytesPerSec * NPB); - if (!bpb.bpbBigFATsecs) { - bpb.bpbBigFATsecs = x2; - x1 += (bpb.bpbBigFATsecs - 1) * bpb.bpbFATs; - } + + extra_res = 0; + alignment = 0; + set_res = (bpb.bpbResSectors == 0); + set_spf = (bpb.bpbBigFATsecs == 0); + set_spc = (bpb.bpbSecPerClust == 0); + saved_x = x; + + /* + * Attempt to align the root directory to cluster if o.align is set. + * This is done by padding with reserved blocks. Note that this can + * cause other factors to change, which can in turn change the alignment. + * This should take at most 2 iterations, as increasing the reserved + * amount may cause the FAT size to decrease by 1, requiring another + * bpbFATs reserved blocks. If bpbSecPerClust changes, it will + * be half of its previous size, and thus will not throw off alignment. + */ + do { + x = saved_x; + if (set_res) + bpb.bpbResSectors = ((fat == 32) ? + MAX(x, MAX(16384 / bpb.bpbBytesPerSec, 4)) : x) + extra_res; + else if (bpb.bpbResSectors < x) { + warnx("too few reserved sectors (need %d have %d)", x, + bpb.bpbResSectors); + goto done; + } + if (fat != 32 && !bpb.bpbRootDirEnts) + bpb.bpbRootDirEnts = DEFRDE; + rds = howmany(bpb.bpbRootDirEnts, + bpb.bpbBytesPerSec / sizeof(struct de)); + if (set_spc) { + for (bpb.bpbSecPerClust = howmany(fat == 16 ? DEFBLK16 : + DEFBLK, bpb.bpbBytesPerSec); + bpb.bpbSecPerClust < MAXSPC && (bpb.bpbResSectors + + howmany((RESFTE + maxcls(fat)) * (fat / BPN), + bpb.bpbBytesPerSec * NPB) * bpb.bpbFATs + + rds + + (u_int64_t) (maxcls(fat) + 1) * bpb.bpbSecPerClust) <= + bpb.bpbHugeSectors; + bpb.bpbSecPerClust <<= 1) + continue; + + } + if (fat != 32 && bpb.bpbBigFATsecs > MAXU16) { + warnx("too many sectors/FAT for FAT12/16"); + goto done; + } + x1 = bpb.bpbResSectors + rds; + x = bpb.bpbBigFATsecs ? bpb.bpbBigFATsecs : 1; + if (x1 + (u_int64_t)x * bpb.bpbFATs > bpb.bpbHugeSectors) { + warnx("meta data exceeds file system size"); + goto done; + } + x1 += x * bpb.bpbFATs; + x = (u_int64_t)(bpb.bpbHugeSectors - x1) * bpb.bpbBytesPerSec * NPB / + (bpb.bpbSecPerClust * bpb.bpbBytesPerSec * NPB + + fat / BPN * bpb.bpbFATs); + x2 = howmany((RESFTE + MIN(x, maxcls(fat))) * (fat / BPN), + bpb.bpbBytesPerSec * NPB); + if (set_spf) { + if (bpb.bpbBigFATsecs == 0) + bpb.bpbBigFATsecs = x2; + x1 += (bpb.bpbBigFATsecs - 1) * bpb.bpbFATs; + } + if (set_res) { + /* attempt to align root directory */ + alignment = (bpb.bpbResSectors + bpb.bpbBigFATsecs * bpb.bpbFATs) % + bpb.bpbSecPerClust; + if (o.align) + extra_res += bpb.bpbSecPerClust - alignment; + } + attempts++; + } while (o.align && alignment != 0 && attempts < 2); + if (o.align && alignment != 0) + warnx("warning: Alignment failed."); + cls = (bpb.bpbHugeSectors - x1) / bpb.bpbSecPerClust; x = (u_int64_t)bpb.bpbBigFATsecs * bpb.bpbBytesPerSec * NPB / (fat / BPN) - RESFTE; Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.h ============================================================================== --- stable/11/sbin/newfs_msdos/mkfs_msdos.h Mon Jul 16 03:59:40 2018 (r336328) +++ stable/11/sbin/newfs_msdos/mkfs_msdos.h Mon Jul 16 04:06:34 2018 (r336329) @@ -34,6 +34,7 @@ #include #define ALLOPTS \ AOPT('@', off_t, offset, 0, "Offset in device") \ +AOPT('A', bool, align, -2, "Attempt to cluster align root directory") \ AOPT('B', const char *, bootstrap, -1, "Bootstrap file") \ AOPT('C', off_t, create_size, 0, "Create file") \ AOPT('F', uint8_t, fat_type, 12, "FAT type (12, 16, or 32)") \ @@ -61,7 +62,7 @@ AOPT('u', uint16_t, sectors_per_track, 1, "Sectors per struct msdos_options { #define AOPT(_opt, _type, _name, _min, _desc) _type _name; ALLOPTS -#undef AOPT +#undef AOPT uint32_t timestamp_set:1; uint32_t volume_id_set:1; uint32_t media_descriptor_set:1; Modified: stable/11/sbin/newfs_msdos/newfs_msdos.8 ============================================================================== --- stable/11/sbin/newfs_msdos/newfs_msdos.8 Mon Jul 16 03:59:40 2018 (r336328) +++ stable/11/sbin/newfs_msdos/newfs_msdos.8 Mon Jul 16 04:06:34 2018 (r336329) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 16, 2017 +.Dd June 14, 2018 .Dt NEWFS_MSDOS 8 .Os .Sh NAME @@ -35,6 +35,7 @@ .Nm .Op Fl N .Op Fl @ Ar offset +.Op Fl A .Op Fl B Ar boot .Op Fl C Ar create-size .Op Fl F Ar FAT-type @@ -91,6 +92,8 @@ Build the filesystem at the specified offset in bytes A suffix s, k, m, g (lower or upper case) appended to the offset specifies that the number is in sectors, kilobytes, megabytes or gigabytes, respectively. +.It Fl A +Attempt to cluster align root directory, useful for SD card. .It Fl B Ar boot Get bootstrap from file. .It Fl C Ar create-size Modified: stable/11/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/11/sbin/newfs_msdos/newfs_msdos.c Mon Jul 16 03:59:40 2018 (r336328) +++ stable/11/sbin/newfs_msdos/newfs_msdos.c Mon Jul 16 04:06:34 2018 (r336329) @@ -76,7 +76,7 @@ get_tstamp(const char *b) int main(int argc, char *argv[]) { - static const char opts[] = "@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:"; + static const char opts[] = "@:NAB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:"; struct msdos_options o; const char *fname, *dtype; char buf[MAXPATHLEN]; @@ -92,6 +92,9 @@ main(int argc, char *argv[]) case 'N': o.no_create = 1; break; + case 'A': + o.align = true; + break; case 'B': o.bootstrap = optarg; break; @@ -175,6 +178,10 @@ main(int argc, char *argv[]) argv += optind; if (argc < 1 || argc > 2) usage(); + if (o.align) { + if (o.hidden_sectors_set) + errx(1, "align (-A) is incompatible with -r"); + } fname = *argv++; if (!o.create_size && !strchr(fname, '/')) { snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 05:33:19 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 136C3103F235; Mon, 16 Jul 2018 05:33:19 +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 B4B4980D74; Mon, 16 Jul 2018 05:33:18 +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 95E071861C; Mon, 16 Jul 2018 05:33:18 +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 w6G5XIva060894; Mon, 16 Jul 2018 05:33:18 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G5XIaH060893; Mon, 16 Jul 2018 05:33:18 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201807160533.w6G5XIaH060893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 16 Jul 2018 05:33:18 +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: r336330 - stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD X-SVN-Commit-Revision: 336330 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.27 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, 16 Jul 2018 05:33:19 -0000 Author: dim Date: Mon Jul 16 05:33:18 2018 New Revision: 336330 URL: https://svnweb.freebsd.org/changeset/base/336330 Log: MFC r332965 (by emaste): lldb: remove assertion that target_arch is FreeBSD The target is not necessarily a FreeBSD binary - for example, it may be a Linux binary running under the linuxulator. Basic ptrace (live) debugging already worked in this case, except for the assertion. Sponsored by: Turing Robotic Industries Inc. Modified: stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp ============================================================================== --- stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Mon Jul 16 04:06:34 2018 (r336329) +++ stable/11/contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Mon Jul 16 05:33:18 2018 (r336330) @@ -169,7 +169,6 @@ lldb::RegisterContextSP FreeBSDThread::GetRegisterCont RegisterInfoInterface *reg_interface = NULL; const ArchSpec &target_arch = GetProcess()->GetTarget().GetArchitecture(); - assert(target_arch.GetTriple().getOS() == llvm::Triple::FreeBSD); switch (target_arch.GetMachine()) { case llvm::Triple::aarch64: reg_interface = new RegisterInfoPOSIX_arm64(target_arch); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 05:35: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 A7BBB103F3AF; Mon, 16 Jul 2018 05:35:40 +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 5320C80F4A; Mon, 16 Jul 2018 05:35:40 +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 15AF71861D; Mon, 16 Jul 2018 05:35:40 +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 w6G5ZdJI061076; Mon, 16 Jul 2018 05:35:39 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G5ZdQ1061075; Mon, 16 Jul 2018 05:35:39 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201807160535.w6G5ZdQ1061075@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 16 Jul 2018 05:35: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: r336331 - in stable/11: contrib/llvm/tools/lld/ELF lib/clang/include/lld/Common X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable/11: contrib/llvm/tools/lld/ELF lib/clang/include/lld/Common X-SVN-Commit-Revision: 336331 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.27 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, 16 Jul 2018 05:35:40 -0000 Author: dim Date: Mon Jul 16 05:35:39 2018 New Revision: 336331 URL: https://svnweb.freebsd.org/changeset/base/336331 Log: MFC r333401 (by emaste): lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC A non-alloc note section should not have a PT_NOTE program header. Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell emits a .debug-ghc-link-info note section (as the name suggests, it contains link info) as a SHT_NOTE section without SHF_ALLOC set. For this case ld.bfd does not emit a PT_NOTE segment for .debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0 and FreeBSD's rtld segfaulted when trying to parse a note at address 0. LLVM PR: https://llvm.org/pr37361 LLVM review: https://reviews.llvm.org/D46623 PR: 226872 Reviewed by: dim Sponsored by: The FreeBSD Foundation Modified: stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp stable/11/lib/clang/include/lld/Common/Version.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp ============================================================================== --- stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp Mon Jul 16 05:33:18 2018 (r336330) +++ stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp Mon Jul 16 05:35:39 2018 (r336331) @@ -1708,7 +1708,7 @@ template std::vector Writer< // Create one PT_NOTE per a group of contiguous .note sections. PhdrEntry *Note = nullptr; for (OutputSection *Sec : OutputSections) { - if (Sec->Type == SHT_NOTE) { + if (Sec->Type == SHT_NOTE && (Sec->Flags & SHF_ALLOC)) { if (!Note || Sec->LMAExpr) Note = AddHdr(PT_NOTE, PF_R); Note->add(Sec); Modified: stable/11/lib/clang/include/lld/Common/Version.inc ============================================================================== --- stable/11/lib/clang/include/lld/Common/Version.inc Mon Jul 16 05:33:18 2018 (r336330) +++ stable/11/lib/clang/include/lld/Common/Version.inc Mon Jul 16 05:35:39 2018 (r336331) @@ -7,4 +7,4 @@ #define LLD_REPOSITORY_STRING "FreeBSD" // - -#define LLD_REVISION_STRING "326565-1100002" +#define LLD_REVISION_STRING "326565-1100003" From owner-svn-src-stable-11@freebsd.org Mon Jul 16 05:36:42 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 D934C103F4A6; Mon, 16 Jul 2018 05:36:42 +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 8D5CD810BB; Mon, 16 Jul 2018 05:36:42 +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 6E4361861F; Mon, 16 Jul 2018 05:36:42 +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 w6G5agSM061196; Mon, 16 Jul 2018 05:36:42 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6G5agvI061195; Mon, 16 Jul 2018 05:36:42 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201807160536.w6G5agvI061195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 16 Jul 2018 05:36:42 +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: r336332 - stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains X-SVN-Commit-Revision: 336332 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.27 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, 16 Jul 2018 05:36:43 -0000 Author: dim Date: Mon Jul 16 05:36:42 2018 New Revision: 336332 URL: https://svnweb.freebsd.org/changeset/base/336332 Log: MFC r336227: Pull in r336008 from upstream clang trunk: Request init/fini array on FreeBSD 12 and later Summary: It seems a bad idea to change the default in the middle of a release branch due to possible changes in global ctor / dtor ordering between .ctors and .init_array. With FreeBSD 11.0's release imminent lets change the default now for FreeBSD 12 (the current development stream) and later. FreeBSD rtld has supported .init_array / .fini_array for many years. As of Jan 1 2017 all supported FreeBSD releases and branches will have support. Reviewers: dim, brooks, arichardson Reviewed By: dim, brooks, arichardson Subscribers: bsdjhb, krytarowski, emaste, cfe-commits Differential Revision: https://reviews.llvm.org/D24867 Requested by: jhb Modified: stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp ============================================================================== --- stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp Mon Jul 16 05:35:39 2018 (r336331) +++ stable/11/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp Mon Jul 16 05:36:42 2018 (r336332) @@ -2375,6 +2375,8 @@ void Generic_ELF::addClangTargetOptions(const ArgList bool UseInitArrayDefault = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be || + (getTriple().getOS() == llvm::Triple::FreeBSD && + getTriple().getOSMajorVersion() >= 12) || (getTriple().getOS() == llvm::Triple::Linux && ((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) || getTriple().isAndroid())) || From owner-svn-src-stable-11@freebsd.org Mon Jul 16 10:32:12 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 21D861049C27; Mon, 16 Jul 2018 10:32:12 +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 C49D18A5D5; Mon, 16 Jul 2018 10:32:11 +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 A5DA81B54F; Mon, 16 Jul 2018 10:32:11 +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 w6GAWBCv011333; Mon, 16 Jul 2018 10:32:11 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GAWBnH011332; Mon, 16 Jul 2018 10:32:11 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201807161032.w6GAWBnH011332@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 16 Jul 2018 10:32:11 +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: r336334 - stable/11/sys/netipsec X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netipsec X-SVN-Commit-Revision: 336334 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.27 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, 16 Jul 2018 10:32:12 -0000 Author: ae Date: Mon Jul 16 10:32:11 2018 New Revision: 336334 URL: https://svnweb.freebsd.org/changeset/base/336334 Log: MFC r335795,335796: Make debug output produced by `setkey -x` command a more human readable. Add text names of SADB message types and extension headers to the output. Obtained from: Yandex LLC Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D16036 Modified: stable/11/sys/netipsec/key_debug.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netipsec/key_debug.c ============================================================================== --- stable/11/sys/netipsec/key_debug.c Mon Jul 16 05:46:50 2018 (r336333) +++ stable/11/sys/netipsec/key_debug.c Mon Jul 16 10:32:11 2018 (r336334) @@ -83,6 +83,85 @@ static void kdebug_sadb_x_natt(struct sadb_ext *); /* NOTE: host byte order */ +static const char* +kdebug_sadb_type(uint8_t type) +{ +#define SADB_NAME(n) case SADB_ ## n: return (#n) + + switch (type) { + SADB_NAME(RESERVED); + SADB_NAME(GETSPI); + SADB_NAME(UPDATE); + SADB_NAME(ADD); + SADB_NAME(DELETE); + SADB_NAME(GET); + SADB_NAME(ACQUIRE); + SADB_NAME(REGISTER); + SADB_NAME(EXPIRE); + SADB_NAME(FLUSH); + SADB_NAME(DUMP); + SADB_NAME(X_PROMISC); + SADB_NAME(X_PCHANGE); + SADB_NAME(X_SPDUPDATE); + SADB_NAME(X_SPDADD); + SADB_NAME(X_SPDDELETE); + SADB_NAME(X_SPDGET); + SADB_NAME(X_SPDACQUIRE); + SADB_NAME(X_SPDDUMP); + SADB_NAME(X_SPDFLUSH); + SADB_NAME(X_SPDSETIDX); + SADB_NAME(X_SPDEXPIRE); + SADB_NAME(X_SPDDELETE2); + default: + return ("UNKNOWN"); + } +#undef SADB_NAME +} + +static const char* +kdebug_sadb_exttype(uint16_t type) +{ +#define EXT_NAME(n) case SADB_EXT_ ## n: return (#n) +#define X_NAME(n) case SADB_X_EXT_ ## n: return (#n) + + switch (type) { + EXT_NAME(RESERVED); + EXT_NAME(SA); + EXT_NAME(LIFETIME_CURRENT); + EXT_NAME(LIFETIME_HARD); + EXT_NAME(LIFETIME_SOFT); + EXT_NAME(ADDRESS_SRC); + EXT_NAME(ADDRESS_DST); + EXT_NAME(ADDRESS_PROXY); + EXT_NAME(KEY_AUTH); + EXT_NAME(KEY_ENCRYPT); + EXT_NAME(IDENTITY_SRC); + EXT_NAME(IDENTITY_DST); + EXT_NAME(SENSITIVITY); + EXT_NAME(PROPOSAL); + EXT_NAME(SUPPORTED_AUTH); + EXT_NAME(SUPPORTED_ENCRYPT); + EXT_NAME(SPIRANGE); + X_NAME(KMPRIVATE); + X_NAME(POLICY); + X_NAME(SA2); + X_NAME(NAT_T_TYPE); + X_NAME(NAT_T_SPORT); + X_NAME(NAT_T_DPORT); + X_NAME(NAT_T_OAI); + X_NAME(NAT_T_OAR); + X_NAME(NAT_T_FRAG); + X_NAME(SA_REPLAY); + X_NAME(NEW_ADDRESS_SRC); + X_NAME(NEW_ADDRESS_DST); + default: + return ("UNKNOWN"); + }; +#undef EXT_NAME +#undef X_NAME +} + + /* %%%: about struct sadb_msg */ void kdebug_sadb(struct sadb_msg *base) @@ -94,8 +173,9 @@ kdebug_sadb(struct sadb_msg *base) if (base == NULL) panic("%s: NULL pointer was passed.\n", __func__); - printf("sadb_msg{ version=%u type=%u errno=%u satype=%u\n", + printf("sadb_msg{ version=%u type=%u(%s) errno=%u satype=%u\n", base->sadb_msg_version, base->sadb_msg_type, + kdebug_sadb_type(base->sadb_msg_type), base->sadb_msg_errno, base->sadb_msg_satype); printf(" len=%u reserved=%u seq=%u pid=%u\n", base->sadb_msg_len, base->sadb_msg_reserved, @@ -105,8 +185,9 @@ kdebug_sadb(struct sadb_msg *base) ext = (struct sadb_ext *)((caddr_t)base + sizeof(struct sadb_msg)); while (tlen > 0) { - printf("sadb_ext{ len=%u type=%u }\n", - ext->sadb_ext_len, ext->sadb_ext_type); + printf("sadb_ext{ len=%u type=%u(%s) }\n", + ext->sadb_ext_len, ext->sadb_ext_type, + kdebug_sadb_exttype(ext->sadb_ext_type)); if (ext->sadb_ext_len == 0) { printf("%s: invalid ext_len=0 was passed.\n", __func__); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 13:21:50 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 2A3FB102788C; Mon, 16 Jul 2018 13:21:50 +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 CBDBB70F7C; Mon, 16 Jul 2018 13:21:49 +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 AD1CB1D185; Mon, 16 Jul 2018 13:21:49 +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 w6GDLnk9098669; Mon, 16 Jul 2018 13:21:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GDLntY098668; Mon, 16 Jul 2018 13:21:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807161321.w6GDLntY098668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 16 Jul 2018 13:21:49 +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: r336338 - stable/11/usr.sbin/cpucontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/usr.sbin/cpucontrol X-SVN-Commit-Revision: 336338 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.27 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, 16 Jul 2018 13:21:50 -0000 Author: markj Date: Mon Jul 16 13:21:49 2018 New Revision: 336338 URL: https://svnweb.freebsd.org/changeset/base/336338 Log: MFC r336257, r336258, r336263: Use the MSR name. Modified: stable/11/usr.sbin/cpucontrol/amd10h.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cpucontrol/amd10h.c ============================================================================== --- stable/11/usr.sbin/cpucontrol/amd10h.c Mon Jul 16 13:14:53 2018 (r336337) +++ stable/11/usr.sbin/cpucontrol/amd10h.c Mon Jul 16 13:21:49 2018 (r336338) @@ -129,7 +129,7 @@ amd10h_update(const char *dev, const char *path) } signature = idargs.data[0]; - msrargs.msr = 0x0000008b; + msrargs.msr = MSR_BIOS_SIGN; error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); if (error < 0) { WARN(0, "ioctl(%s)", dev); @@ -285,7 +285,7 @@ amd10h_update(const char *dev, const char *path) fprintf(stderr, "done.\n"); } - msrargs.msr = 0x0000008b; + msrargs.msr = MSR_BIOS_SIGN; error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); if (error < 0) { WARN(0, "ioctl(%s)", dev); From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:17:24 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 7E8881029C1D; Mon, 16 Jul 2018 14:17:24 +0000 (UTC) (envelope-from brooks@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 3122A72D26; Mon, 16 Jul 2018 14:17:24 +0000 (UTC) (envelope-from brooks@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 1262B1D9E5; Mon, 16 Jul 2018 14:17:24 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEHNIN026752; Mon, 16 Jul 2018 14:17:23 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEHNId026751; Mon, 16 Jul 2018 14:17:23 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201807161417.w6GEHNId026751@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 16 Jul 2018 14:17: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: r336340 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 336340 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.27 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, 16 Jul 2018 14:17:24 -0000 Author: brooks Date: Mon Jul 16 14:17:23 2018 New Revision: 336340 URL: https://svnweb.freebsd.org/changeset/base/336340 Log: MFC r336238: Round down the location of execpathp to slightly improve copyout speed. In practice, this moves the padding from below the canary to above execpathp has no impact on stack consumption. Submitted by: Wuyang-Chung (via github pull request #159) Modified: stable/11/sys/kern/kern_exec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_exec.c ============================================================================== --- stable/11/sys/kern/kern_exec.c Mon Jul 16 13:38:16 2018 (r336339) +++ stable/11/sys/kern/kern_exec.c Mon Jul 16 14:17:23 2018 (r336340) @@ -1507,6 +1507,7 @@ exec_copyout_strings(struct image_params *imgp) */ if (execpath_len != 0) { destp -= execpath_len; + destp = rounddown2(destp, sizeof(void *)); imgp->execpathp = destp; copyout(imgp->execpath, (void *)destp, execpath_len); } From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:32: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 F23EB102A3B3; Mon, 16 Jul 2018 14:32:25 +0000 (UTC) (envelope-from kevans@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 A5E2273665; Mon, 16 Jul 2018 14:32:25 +0000 (UTC) (envelope-from kevans@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 6CBED1DD21; Mon, 16 Jul 2018 14:32:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEWPPN036552; Mon, 16 Jul 2018 14:32:25 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEWPuJ036551; Mon, 16 Jul 2018 14:32:25 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161432.w6GEWPuJ036551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 14:32: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: r336341 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 336341 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.27 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, 16 Jul 2018 14:32:26 -0000 Author: kevans Date: Mon Jul 16 14:32:25 2018 New Revision: 336341 URL: https://svnweb.freebsd.org/changeset/base/336341 Log: Record-only MFC of r335995, r335997; latter reverts the former Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:34: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 AA107102A6F8; Mon, 16 Jul 2018 14:34:26 +0000 (UTC) (envelope-from kevans@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 5DA48738CB; Mon, 16 Jul 2018 14:34:26 +0000 (UTC) (envelope-from kevans@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 252DA1DD2D; Mon, 16 Jul 2018 14:34:26 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEYQ2Q036709; Mon, 16 Jul 2018 14:34:26 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEYQt8036708; Mon, 16 Jul 2018 14:34:26 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161434.w6GEYQt8036708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 14:34:26 +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: r336342 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 336342 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.27 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, 16 Jul 2018 14:34:26 -0000 Author: kevans Date: Mon Jul 16 14:34:25 2018 New Revision: 336342 URL: https://svnweb.freebsd.org/changeset/base/336342 Log: Record-only MFC r336011-r336013 r336013 reverts the previous two commits, which broke the build due to poor testing form. Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:38: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 0D944102A9C7; Mon, 16 Jul 2018 14:38:59 +0000 (UTC) (envelope-from kevans@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 AB39173C03; Mon, 16 Jul 2018 14:38:58 +0000 (UTC) (envelope-from kevans@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 8A3C51DD37; Mon, 16 Jul 2018 14:38:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEcwMS037252; Mon, 16 Jul 2018 14:38:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEcv4D037248; Mon, 16 Jul 2018 14:38:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161438.w6GEcv4D037248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 14:38:57 +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: r336343 - stable/11/usr.sbin/config X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.sbin/config X-SVN-Commit-Revision: 336343 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.27 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, 16 Jul 2018 14:38:59 -0000 Author: kevans Date: Mon Jul 16 14:38:57 2018 New Revision: 336343 URL: https://svnweb.freebsd.org/changeset/base/336343 Log: MFC r335652-r335654 r335652: config(8): Make 'env' files consistent with other file-accepting options Previously, only one 'env' file could be specified. Later 'env' directives would overwrite earlier 'env' directives. This is inconsistent with every other file-accepting directives which process files in order, including hints. A caveat applies to both hints and env that isn't mentioned: they're concatenated in the order of appearance, so they're not actually applied in the way one might think by supplying: hints x hints y Hints in x will take precedence over same-name hints in y due to how the kernel processes them, stopping at the first line that matches the hint we're searching for. Future work will flip the order of concatenation so that later files may still properly override earlier files. In practice, this likely doesn't matter at all due to the nature of the beast. r335653: config(8): Flip the order of concatenation for `hints` and `env` As previously noted, kernel's processing of these means that the first appearance of a hint/variable wins. Flipping the order of concatenation means that later variables override earlier variables, as expected when one does: hints x hints y Where perhaps x is: hint.aw_sid.0.disable=1 and y is: hint.aw_sid.0.disable=0 The expectation would be that a later appearing variable would override an earlier appearing variable, such as with `device`/`nodevice`, device.hints, and other similarly structured data files. r335654: config(8): part of patch disappeared, don't close ifp at the end Modified: stable/11/usr.sbin/config/config.5 stable/11/usr.sbin/config/config.h stable/11/usr.sbin/config/config.y stable/11/usr.sbin/config/mkmakefile.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/config/config.5 ============================================================================== --- stable/11/usr.sbin/config/config.5 Mon Jul 16 14:34:25 2018 (r336342) +++ stable/11/usr.sbin/config/config.5 Mon Jul 16 14:38:57 2018 (r336343) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 22, 2018 +.Dd June 26, 2018 .Dt CONFIG 5 .Os .Sh NAME @@ -124,6 +124,19 @@ the compiled-in environment instead, unless the boot e This directive is useful for setting kernel tunables in embedded environments that do not start from .Xr loader 8 . +.Pp +All +.Ic env +and +.Ic envvar +directives will be processed and added to the static environment in reversed +order of appearance so that later specified variables properly override earlier +specified variables. +Note that within +.Ar filename , +the first appearance of a given variable will be the first one seen by the +kernel, effectively shadowing any later appearances of the same variable within +.Ar filename . .\" -------- ENVVAR -------- .Pp .It Ic envvar Ar setting @@ -133,11 +146,14 @@ compiled-in environment. must be of the form .Dq Va name=value . Optional quotes are supported in both name and value. -All environment variables specified with -.Ic envvar -will be set after any +.Pp +All .Ic env -files are included. +and +.Ic envvar +directives will be processed and added to the static environment in reversed +order of appearance so that later specified variables properly override earlier +specified variables. .\" -------- FILES -------- .Pp .It Ic files Ar filename @@ -164,7 +180,9 @@ The file must conform to the syntax specified by .Xr device.hints 5 . Multiple hints lines are allowed. -The resulting hints will be the files concatenated in the order of appearance. +The resulting hints will be the files concatenated in reverse order of +appearance so that hints in later files properly override hints in earlier +files. .\" -------- IDENT -------- .Pp .It Ic ident Ar name Modified: stable/11/usr.sbin/config/config.h ============================================================================== --- stable/11/usr.sbin/config/config.h Mon Jul 16 14:34:25 2018 (r336342) +++ stable/11/usr.sbin/config/config.h Mon Jul 16 14:38:57 2018 (r336343) @@ -35,6 +35,7 @@ */ #include #include +#include #include #include @@ -139,6 +140,7 @@ SLIST_HEAD(, opt_list) otab; struct envvar { char *env_str; + bool env_is_file; STAILQ_ENTRY(envvar) envvar_next; }; @@ -172,7 +174,6 @@ SLIST_HEAD(, includepath) includepath; #define OPT_AUTOGEN "CONFIG_AUTOGENERATED" extern char *ident; -extern char *env; extern char kernconfstr[]; extern int do_trace; extern int envmode; Modified: stable/11/usr.sbin/config/config.y ============================================================================== --- stable/11/usr.sbin/config/config.y Mon Jul 16 14:34:25 2018 (r336342) +++ stable/11/usr.sbin/config/config.y Mon Jul 16 14:38:57 2018 (r336343) @@ -80,7 +80,6 @@ struct device_head dtab; char *ident; -char *env; int envmode; int hintmode; int yyline; @@ -97,6 +96,7 @@ int yywrap(void); static void newdev(char *name); static void newfile(char *name); +static void newenvvar(char *name, bool is_file); static void rmdev_schedule(struct device_head *dh, char *name); static void newopt(struct opt_head *list, char *name, char *value, int append); static void rmopt_schedule(struct opt_head *list, char *name); @@ -189,20 +189,8 @@ Config_spec: | MAXUSERS NUMBER { maxusers = $2; } | PROFILE NUMBER { profiling = $2; } | - ENV ID { - env = $2; - envmode = 1; - } | - ENVVAR ENVLINE { - struct envvar *envvar; - - envvar = (struct envvar *)calloc(1, sizeof (struct envvar)); - if (envvar == NULL) - err(EXIT_FAILURE, "calloc"); - envvar->env_str = $2; - STAILQ_INSERT_TAIL(&envvars, envvar, envvar_next); - envmode = 1; - } | + ENV ID { newenvvar($2, true); } | + ENVVAR ENVLINE { newenvvar($2, false); } | HINTS ID { struct hint *hint; @@ -210,7 +198,7 @@ Config_spec: if (hint == NULL) err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; - STAILQ_INSERT_TAIL(&hints, hint, hint_next); + STAILQ_INSERT_HEAD(&hints, hint, hint_next); hintmode = 1; } @@ -359,7 +347,21 @@ newfile(char *name) nl->f_name = name; STAILQ_INSERT_TAIL(&fntab, nl, f_next); } - + +static void +newenvvar(char *name, bool is_file) +{ + struct envvar *envvar; + + envvar = (struct envvar *)calloc(1, sizeof (struct envvar)); + if (envvar == NULL) + err(EXIT_FAILURE, "calloc"); + envvar->env_str = name; + envvar->env_is_file = is_file; + STAILQ_INSERT_HEAD(&envvars, envvar, envvar_next); + envmode = 1; +} + /* * Find a device in the list of devices. */ Modified: stable/11/usr.sbin/config/mkmakefile.c ============================================================================== --- stable/11/usr.sbin/config/mkmakefile.c Mon Jul 16 14:34:25 2018 (r336342) +++ stable/11/usr.sbin/config/mkmakefile.c Mon Jul 16 14:38:57 2018 (r336343) @@ -304,13 +304,6 @@ makeenv(void) char line[BUFSIZ], result[BUFSIZ], *linep; struct envvar *envvar; - if (env) { - ifp = fopen(env, "r"); - if (ifp == NULL) - err(1, "%s", env); - } else { - ifp = NULL; - } ofp = fopen(path("env.c.new"), "w"); if (ofp == NULL) err(1, "%s", path("env.c.new")); @@ -319,25 +312,28 @@ makeenv(void) fprintf(ofp, "\n"); fprintf(ofp, "int envmode = %d;\n", envmode); fprintf(ofp, "char static_env[] = {\n"); - if (ifp) { - while (fgets(line, BUFSIZ, ifp) != NULL) { - sanitize_envline(result, line); - /* anything left? */ + STAILQ_FOREACH(envvar, &envvars, envvar_next) { + if (envvar->env_is_file) { + ifp = fopen(envvar->env_str, "r"); + if (ifp == NULL) + err(1, "%s", envvar->env_str); + while (fgets(line, BUFSIZ, ifp) != NULL) { + sanitize_envline(result, line); + /* anything left? */ + if (*result == '\0') + continue; + fprintf(ofp, "\"%s\\0\"\n", result); + } + fclose(ifp); + } else { + linep = envvar->env_str; + sanitize_envline(result, linep); if (*result == '\0') continue; fprintf(ofp, "\"%s\\0\"\n", result); } } - STAILQ_FOREACH(envvar, &envvars, envvar_next) { - linep = envvar->env_str; - sanitize_envline(result, linep); - if (*result == '\0') - continue; - fprintf(ofp, "\"%s\\0\"\n", result); - } fprintf(ofp, "\"\\0\"\n};\n"); - if (ifp) - fclose(ifp); fclose(ofp); moveifchanged(path("env.c.new"), path("env.c")); } From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:42:46 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 51BB4102AD24; Mon, 16 Jul 2018 14:42:46 +0000 (UTC) (envelope-from kevans@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 06B1C740BE; Mon, 16 Jul 2018 14:42:46 +0000 (UTC) (envelope-from kevans@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 DBE6F1DEC8; Mon, 16 Jul 2018 14:42:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEgj49042059; Mon, 16 Jul 2018 14:42:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEgjmN042058; Mon, 16 Jul 2018 14:42:45 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161442.w6GEgjmN042058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 14:42:45 +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: r336344 - stable/11/sbin/ifconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sbin/ifconfig X-SVN-Commit-Revision: 336344 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.27 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, 16 Jul 2018 14:42:46 -0000 Author: kevans Date: Mon Jul 16 14:42:45 2018 New Revision: 336344 URL: https://svnweb.freebsd.org/changeset/base/336344 Log: MFC r335757: ifconfig(8): Attempt to render non-printable sequences w/ UTF-8 Environment Currently ifconfig(8) only prints the hex representation of ssid names with non-ASCII characters. Many modern terminals are able to properly render non-ASCII characters. This change checks if the terminal charmap is UTF-8, and if so, will render the characters, rather than the hex value. This behavior is circumvented by running ifconfig(8) in a non-UTF8 locale; e.g. C or POSIX. It was pointed out by kp@ during the review that APs have the option to broadcast whether their SSIDs may be interpreted as UTF-8. Ideally, we would honor this and only attempt this behavior if it's so-broadcasted by the AP. However, a sample survey showed that hostapd will advertise this if indicated in config but it doesn't seem to be so common in the AP market, so this would be effectively useless as we'll rarely know if the SSID should be renderable as UTF-8. Despite this, it was decided to be OK with this anyways- there's a straightforward path to doing it the right way based on advertisement by AP if we need to go that route, and one can revert to old behavior easily enough at runtime if we get it wrong. Modified: stable/11/sbin/ifconfig/ifieee80211.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ifconfig/ifieee80211.c ============================================================================== --- stable/11/sbin/ifconfig/ifieee80211.c Mon Jul 16 14:38:57 2018 (r336343) +++ stable/11/sbin/ifconfig/ifieee80211.c Mon Jul 16 14:42:45 2018 (r336344) @@ -90,6 +90,8 @@ #include #include #include /* NB: for offsetof */ +#include +#include #include "ifconfig.h" @@ -5131,16 +5133,21 @@ print_string(const u_int8_t *buf, int len) { int i; int hasspc; + int utf8; i = 0; hasspc = 0; + + setlocale(LC_CTYPE, ""); + utf8 = strncmp("UTF-8", nl_langinfo(CODESET), 5) == 0; + for (; i < len; i++) { - if (!isprint(buf[i]) && buf[i] != '\0') + if (!isprint(buf[i]) && buf[i] != '\0' && !utf8) break; if (isspace(buf[i])) hasspc++; } - if (i == len) { + if (i == len || utf8) { if (hasspc || len == 0 || buf[0] == '\0') printf("\"%.*s\"", len, buf); else From owner-svn-src-stable-11@freebsd.org Mon Jul 16 14:56: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 84670102B991; Mon, 16 Jul 2018 14:56:31 +0000 (UTC) (envelope-from kevans@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 2F77B74C0E; Mon, 16 Jul 2018 14:56:31 +0000 (UTC) (envelope-from kevans@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 107DC1E06F; Mon, 16 Jul 2018 14:56:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GEuVmp047625; Mon, 16 Jul 2018 14:56:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GEuUbf047621; Mon, 16 Jul 2018 14:56:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161456.w6GEuUbf047621@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 14:56:30 +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: r336345 - in stable/11: lib/libnv lib/libnv/tests sys/conf sys/contrib/libnv X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: lib/libnv lib/libnv/tests sys/conf sys/contrib/libnv X-SVN-Commit-Revision: 336345 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.27 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, 16 Jul 2018 14:56:31 -0000 Author: kevans Date: Mon Jul 16 14:56:30 2018 New Revision: 336345 URL: https://svnweb.freebsd.org/changeset/base/336345 Log: MFC r304908-r304909 r304908: Add cnv API. cnv API is a set of functions for managing name/value pairs by cookie. The cookie can be obtained by nvlist_next(), nvlist_get_parent() or nvlist_get_pararr() function. This patch also includes unit tests. Submitted by: Adam Starak r304909: Fix style issue in the cnv API. Remove unused arguments in a macro. Remove unused typedef. Added: stable/11/lib/libnv/tests/cnv_tests.cc - copied unchanged from r304909, head/lib/libnv/tests/cnv_tests.cc stable/11/sys/contrib/libnv/cnvlist.c - copied unchanged from r304909, head/sys/contrib/libnv/cnvlist.c Modified: stable/11/lib/libnv/Makefile stable/11/lib/libnv/tests/Makefile stable/11/sys/conf/files stable/11/sys/contrib/libnv/nvlist.c stable/11/sys/contrib/libnv/nvlist_impl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libnv/Makefile ============================================================================== --- stable/11/lib/libnv/Makefile Mon Jul 16 14:42:45 2018 (r336344) +++ stable/11/lib/libnv/Makefile Mon Jul 16 14:56:30 2018 (r336345) @@ -11,7 +11,8 @@ SHLIB_MAJOR= 0 .PATH: ${SRCTOP}/sys/contrib/libnv ${SRCTOP}/sys/sys CFLAGS+=-I${SRCTOP}/sys -I${.CURDIR} -SRCS= dnvlist.c +SRCS= cnvlist.c +SRCS+= dnvlist.c SRCS+= msgio.c SRCS+= nvlist.c SRCS+= nvpair.c Modified: stable/11/lib/libnv/tests/Makefile ============================================================================== --- stable/11/lib/libnv/tests/Makefile Mon Jul 16 14:42:45 2018 (r336344) +++ stable/11/lib/libnv/tests/Makefile Mon Jul 16 14:56:30 2018 (r336345) @@ -1,6 +1,7 @@ # $FreeBSD$ ATF_TESTS_CXX= \ + cnv_tests \ dnv_tests \ nv_array_tests \ nv_tests \ Copied: stable/11/lib/libnv/tests/cnv_tests.cc (from r304909, head/lib/libnv/tests/cnv_tests.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/lib/libnv/tests/cnv_tests.cc Mon Jul 16 14:56:30 2018 (r336345, copy of r304909, head/lib/libnv/tests/cnv_tests.cc) @@ -0,0 +1,1508 @@ +/*- + * Copyright (c) 2016 Adam Starak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include + +#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF) + +/* ATF cnvlist_get tests. */ + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_bool); +ATF_TEST_CASE_BODY(cnvlist_get_bool) +{ + nvlist_t *nvl; + const char *key; + bool value; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = true; + + nvlist_add_bool(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_BOOL); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_bool(nvl, key)); + + ATF_REQUIRE_EQ(cnvlist_get_bool(cookie), value); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_number); +ATF_TEST_CASE_BODY(cnvlist_get_number) +{ + nvlist_t *nvl; + const char *key; + uint64_t value; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = 420; + + nvlist_add_number(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_number(nvl, key)); + + ATF_REQUIRE_EQ(cnvlist_get_number(cookie), value); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_string); +ATF_TEST_CASE_BODY(cnvlist_get_string) +{ + nvlist_t *nvl; + const char *key; + const char *value; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = "text"; + + nvlist_add_string(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_STRING); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_string(nvl, key)); + + ATF_REQUIRE_EQ(strcmp(cnvlist_get_string(cookie), value), 0); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_nvlist); +ATF_TEST_CASE_BODY(cnvlist_get_nvlist) +{ + nvlist_t *nvl, *value; + const nvlist_t *result; + const char *key, *subkey; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + value = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + key = "name"; + subkey = "subname"; + cookie = NULL; + + /* Add null to 'value' nvlist. */ + nvlist_add_null(value, subkey); + ATF_REQUIRE_EQ(strcmp(subkey, nvlist_next(value, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(value), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(value)); + ATF_REQUIRE(nvlist_exists(value, subkey)); + ATF_REQUIRE(nvlist_exists_null(value, subkey)); + ATF_REQUIRE_EQ(nvlist_next(value, &type, &cookie), + static_cast(NULL)); + + /* Add 'value' nvlist. */ + cookie = NULL; + nvlist_add_nvlist(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_nvlist(nvl, key)); + + /* + * Assuming nvlist_get_nvlist() is correct check if cnvlist returns + * the same pointer. + */ + result = cnvlist_get_nvlist(cookie); + ATF_REQUIRE_EQ(result, nvlist_get_nvlist(nvl, key)); + ATF_REQUIRE(result != value); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + /* Validate data inside nvlist. */ + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(subkey, nvlist_next(result, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(result), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(result)); + ATF_REQUIRE(nvlist_exists(result, subkey)); + ATF_REQUIRE(nvlist_exists_null(result, subkey)); + ATF_REQUIRE_EQ(nvlist_next(result, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); + nvlist_destroy(value); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_descriptor); +ATF_TEST_CASE_BODY(cnvlist_get_descriptor) +{ + nvlist_t *nvl; + const char *key; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_descriptor(nvl, key, STDERR_FILENO); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_DESCRIPTOR); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_descriptor(nvl, key)); + + ATF_REQUIRE_EQ(fd_is_valid(cnvlist_get_descriptor(cookie)), 1); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_binary); +ATF_TEST_CASE_BODY(cnvlist_get_binary) +{ + nvlist_t *nvl; + const char *key; + void *in_binary; + const void *out_binary; + void *cookie; + int type; + size_t in_size, out_size; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + in_size = 13; + + in_binary = malloc(in_size); + ATF_REQUIRE(in_binary != NULL); + memset(in_binary, 0xa5, in_size); + + nvlist_add_binary(nvl, key, in_binary, in_size); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_BINARY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_binary(nvl, key)); + + out_binary = cnvlist_get_binary(cookie, &out_size); + ATF_REQUIRE_EQ(out_size, in_size); + ATF_REQUIRE_EQ(memcmp(in_binary, out_binary, out_size), 0); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +/* ATF cnvlist_get array tests. */ + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_bool_array); +ATF_TEST_CASE_BODY(cnvlist_get_bool_array) +{ + nvlist_t *nvl; + bool in_array[16]; + const bool *out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + for (i = 0; i < 16; i++) + in_array[i] = (i % 2 == 0); + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_bool_array(nvl, key, in_array, 16); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_BOOL_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_bool_array(nvl, key)); + + out_array = cnvlist_get_bool_array(cookie, &nitems); + ATF_REQUIRE_EQ(nitems, 16); + ATF_REQUIRE(out_array != NULL); + for (i = 0; i < 16; i++) + ATF_REQUIRE_EQ(out_array[i], in_array[i]); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_number_array); +ATF_TEST_CASE_BODY(cnvlist_get_number_array) +{ + nvlist_t *nvl; + uint64_t in_array[16]; + const uint64_t *out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + for (i = 0; i < 16; i++) + in_array[i] = i; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_number_array(nvl, key, in_array, 16); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_number_array(nvl, key)); + + out_array = cnvlist_get_number_array(cookie, &nitems); + ATF_REQUIRE(out_array != NULL); + ATF_REQUIRE_EQ(nitems, 16); + for (i = 0; i < 16; i++) + ATF_REQUIRE_EQ(out_array[i], in_array[i]); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_string_array); +ATF_TEST_CASE_BODY(cnvlist_get_string_array) +{ + nvlist_t *nvl; + const char *in_array[4] = {"inequality", "sucks", ".", ""}; + const char * const *out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_string_array(nvl, key, in_array, 4); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_STRING_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_string_array(nvl, key)); + + out_array = cnvlist_get_string_array(cookie, &nitems); + ATF_REQUIRE_EQ(nitems, 4); + ATF_REQUIRE(out_array != NULL); + for (i = 0; i < 4; i++) { + ATF_REQUIRE(out_array[i] != NULL); + ATF_REQUIRE_EQ(strcmp(out_array[i], in_array[i]), 0); + } + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_nvlist_array); +ATF_TEST_CASE_BODY(cnvlist_get_nvlist_array) +{ + nvlist_t *nvl; + nvlist_t *in_array[6]; + const nvlist_t * const *out_array; + const nvlist_t * const *out_result; + void *cookie; + const char *key; + const char *subkeys; + int type, i; + size_t nitems; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + subkeys = "123456"; + for (i = 0; i < 6; i++) { + in_array[i] = nvlist_create(0); + ATF_REQUIRE(in_array[i] != NULL); + ATF_REQUIRE_EQ(nvlist_error(in_array[i]), 0); + ATF_REQUIRE(nvlist_empty(in_array[i])); + + cookie = NULL; + + nvlist_add_null(in_array[i], subkeys+i); + ATF_REQUIRE_EQ(strcmp(subkeys+i, nvlist_next(in_array[i], + &type, &cookie)),0); + ATF_REQUIRE_EQ(nvlist_error(in_array[i]), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(in_array[i])); + ATF_REQUIRE(nvlist_exists(in_array[i], subkeys+i)); + ATF_REQUIRE(nvlist_exists_null(in_array[i], subkeys+i)); + ATF_REQUIRE_EQ(nvlist_next(in_array[i], &type, &cookie), + static_cast(NULL)); + } + + cookie = NULL; + key = "name"; + + nvlist_add_nvlist_array(nvl, key, in_array, 6); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_nvlist_array(nvl, key)); + + /* Get nvlist array by cnvlist function. */ + out_array = cnvlist_get_nvlist_array(cookie, &nitems); + ATF_REQUIRE(out_array != NULL); + ATF_REQUIRE_EQ(nitems, 6); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + /* Get nvlist array by nvlist function. */ + out_result = nvlist_get_nvlist_array(nvl, key, &nitems); + ATF_REQUIRE(out_result != NULL); + ATF_REQUIRE_EQ(nitems, 6); + + /* Validate assuming that nvlist returned a proper pointer */ + for (i = 0; i < 6; i++) { + ATF_REQUIRE_EQ(out_result[i], out_array[i]); + ATF_REQUIRE(out_array[i] != in_array[i]); + + /* Validate data inside nvlist. */ + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(subkeys+i, nvlist_next(out_array[i], + &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(out_array[i]), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(out_array[i])); + ATF_REQUIRE(nvlist_exists(out_array[i], subkeys+i)); + ATF_REQUIRE(nvlist_exists_null(out_array[i], subkeys+i)); + ATF_REQUIRE_EQ(nvlist_next(out_array[i], &type, &cookie), + static_cast(NULL)); + } + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_get_descriptor_array); +ATF_TEST_CASE_BODY(cnvlist_get_descriptor_array) +{ + nvlist_t *nvl; + size_t count, i, nitems; + const int *out_array; + int *in_array, type; + const char *key; + void *cookie; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + count = 50; + + in_array = static_cast(malloc(sizeof(*in_array)*count)); + ATF_REQUIRE(in_array != NULL); + for (i = 0; i < count; i++) { + in_array[i] = dup(STDERR_FILENO); + ATF_REQUIRE(fd_is_valid(in_array[i])); + } + + nvlist_add_descriptor_array(nvl, key, in_array, count); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_DESCRIPTOR_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_descriptor_array(nvl, key)); + + out_array = cnvlist_get_descriptor_array(cookie, &nitems); + ATF_REQUIRE_EQ(nitems, count); + ATF_REQUIRE(out_array != NULL); + for (i = 0; i < count; i++) + ATF_REQUIRE_EQ(fd_is_valid(out_array[i]), 1); + + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +/* ATF cnvlist_take tests. */ + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_bool); +ATF_TEST_CASE_BODY(cnvlist_take_bool) +{ + nvlist_t *nvl; + const char *key; + bool value; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = true; + + nvlist_add_bool(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_BOOL); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_bool(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(cnvlist_take_bool(nvl, cookie), value); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE(!nvlist_exists_bool(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_number); +ATF_TEST_CASE_BODY(cnvlist_take_number) +{ + nvlist_t *nvl; + const char *key; + uint64_t value; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = 69; + + nvlist_add_number(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_number(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(cnvlist_take_number(nvl, cookie), value); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE(!nvlist_exists_number(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_string); +ATF_TEST_CASE_BODY(cnvlist_take_string) +{ + nvlist_t *nvl; + const char *key; + const char *value; + char *out_string; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + value = "text"; + + nvlist_add_string(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_STRING); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_string(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + out_string = cnvlist_take_string(nvl, cookie); + ATF_REQUIRE(out_string != NULL); + ATF_REQUIRE_EQ(strcmp(out_string, value), 0); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE(!nvlist_exists_string(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + free(out_string); + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_nvlist); +ATF_TEST_CASE_BODY(cnvlist_take_nvlist) +{ + nvlist_t *nvl, *value, *result; + const char *key, *subkey; + void *cookie; + int type; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + value = nvlist_create(0); + ATF_REQUIRE(value != NULL); + ATF_REQUIRE_EQ(nvlist_error(value), 0); + ATF_REQUIRE(nvlist_empty(value)); + + key = "name"; + subkey = "subname"; + cookie = NULL; + + /* Add null to 'value' nvlist. */ + nvlist_add_null(value, subkey); + ATF_REQUIRE_EQ(strcmp(subkey, nvlist_next(value, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(value), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(value)); + ATF_REQUIRE(nvlist_exists(value, subkey)); + ATF_REQUIRE(nvlist_exists_null(value, subkey)); + ATF_REQUIRE_EQ(nvlist_next(value, &type, &cookie), + static_cast(NULL)); + + /* Add 'value' nvlist. */ + cookie = NULL; + nvlist_move_nvlist(nvl, key, value); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_nvlist(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + result = cnvlist_take_nvlist(nvl, cookie); + ATF_REQUIRE(!nvlist_exists_nvlist(nvl, key)); + ATF_REQUIRE(result == value); + + /* Validate data inside nvlist. */ + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(subkey, nvlist_next(result, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(value), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NULL); + ATF_REQUIRE(!nvlist_empty(value)); + ATF_REQUIRE(nvlist_exists(value, subkey)); + ATF_REQUIRE(nvlist_exists_null(value, subkey)); + ATF_REQUIRE_EQ(nvlist_next(value, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); + nvlist_destroy(value); +} + +/* ATF cnvlist_take array tests */ + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_bool_array); +ATF_TEST_CASE_BODY(cnvlist_take_bool_array) +{ + nvlist_t *nvl; + bool in_array[16]; + const bool *out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + for (i = 0; i < 16; i++) + in_array[i] = (i % 2 == 0); + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_bool_array(nvl, key, in_array, 16); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_BOOL_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_bool_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + out_array = cnvlist_take_bool_array(nvl, cookie, &nitems); + ATF_REQUIRE_EQ(nitems, 16); + ATF_REQUIRE(out_array != NULL); + for (i = 0; i < 16; i++) + ATF_REQUIRE_EQ(out_array[i], in_array[i]); + + cookie = NULL; + ATF_REQUIRE(!nvlist_exists_bool_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_number_array); +ATF_TEST_CASE_BODY(cnvlist_take_number_array) +{ + nvlist_t *nvl; + uint64_t in_array[16]; + const uint64_t *out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + for (i = 0; i < 16; i++) + in_array[i] = i; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_number_array(nvl, key, in_array, 16); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NUMBER_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_number_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + out_array = cnvlist_take_number_array(nvl, cookie, &nitems); + + ATF_REQUIRE(out_array != NULL); + ATF_REQUIRE_EQ(nitems, 16); + for (i = 0; i < 16; i++) + ATF_REQUIRE_EQ(out_array[i], in_array[i]); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE(!nvlist_exists_number_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_string_array); +ATF_TEST_CASE_BODY(cnvlist_take_string_array) +{ + nvlist_t *nvl; + const char *in_array[4] = {"inequality", "sks", ".", ""}; + char **out_array; + const char *key; + void *cookie; + int type, i; + size_t nitems; + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + key = "name"; + + nvlist_add_string_array(nvl, key, in_array, 4); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_STRING_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_string_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + out_array = cnvlist_take_string_array(nvl, cookie, &nitems); + ATF_REQUIRE_EQ(nitems, 4); + for (i = 0; i < 4; i++) { + ATF_REQUIRE(out_array[i] != NULL); + ATF_REQUIRE_EQ(strcmp(out_array[i], in_array[i]), 0); + } + ATF_REQUIRE(nvlist_empty(nvl)); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE(!nvlist_exists(nvl, key)); + ATF_REQUIRE(!nvlist_exists_number_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + free(out_array); + nvlist_destroy(nvl); +} + +ATF_TEST_CASE_WITHOUT_HEAD(cnvlist_take_nvlist_array); +ATF_TEST_CASE_BODY(cnvlist_take_nvlist_array) +{ + nvlist_t *testnvl[8]; + nvlist_t **result; + nvlist_t *nvl; + void *cookie; + size_t num_items; + unsigned int i; + int type; + const char *somestr[8] = { "a", "b", "c", "d", "e", "f", "g", "h" }; + const char *key; + + for (i = 0; i < 8; i++) { + testnvl[i] = nvlist_create(0); + ATF_REQUIRE(testnvl[i] != NULL); + ATF_REQUIRE_EQ(nvlist_error(testnvl[i]), 0); + ATF_REQUIRE(nvlist_empty(testnvl[i])); + nvlist_add_string(testnvl[i], "nvl/string", somestr[i]); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp("nvl/string", nvlist_next(testnvl[i], + &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(testnvl[i]), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_STRING); + ATF_REQUIRE(!nvlist_empty(testnvl[i])); + ATF_REQUIRE(nvlist_exists(testnvl[i], "nvl/string")); + ATF_REQUIRE(nvlist_exists_string(testnvl[i], "nvl/string")); + ATF_REQUIRE_EQ(nvlist_next(testnvl[i], &type, &cookie), + static_cast(NULL)); + } + + nvl = nvlist_create(0); + ATF_REQUIRE(nvl != NULL); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); + + key = "nvl/nvlist"; + cookie = NULL; + + nvlist_add_nvlist_array(nvl, key, (const nvlist_t * const *)testnvl, 8); + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE_EQ(type, NV_TYPE_NVLIST_ARRAY); + ATF_REQUIRE(!nvlist_empty(nvl)); + ATF_REQUIRE(nvlist_exists(nvl, key)); + ATF_REQUIRE(nvlist_exists_nvlist_array(nvl, key)); + ATF_REQUIRE_EQ(nvlist_next(nvl, &type, &cookie), + static_cast(NULL)); + + cookie = NULL; + ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); + result = cnvlist_take_nvlist_array(nvl, cookie, &num_items); + + ATF_REQUIRE(result != NULL); + ATF_REQUIRE_EQ(num_items, 8); + for (i = 0; i < num_items; i++) { + ATF_REQUIRE_EQ(nvlist_error(result[i]), 0); + ATF_REQUIRE(nvlist_get_array_next(result[i]) == NULL); + } + + ATF_REQUIRE(!nvlist_exists_string_array(nvl, key)); + ATF_REQUIRE(nvlist_empty(nvl)); + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + + cookie = NULL; + ATF_REQUIRE_EQ(nvlist_error(nvl), 0); + ATF_REQUIRE(nvlist_empty(nvl)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Mon Jul 16 15:02: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 2F242102BFE6; Mon, 16 Jul 2018 15:02:25 +0000 (UTC) (envelope-from kevans@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 C6363753FA; Mon, 16 Jul 2018 15:02:24 +0000 (UTC) (envelope-from kevans@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 8EB691E204; Mon, 16 Jul 2018 15:02:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6GF2ObE051209; Mon, 16 Jul 2018 15:02:24 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6GF2LXw050533; Mon, 16 Jul 2018 15:02:21 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807161502.w6GF2LXw050533@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 16 Jul 2018 15:02: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: r336346 - in stable/11: lib/libmd lib/libnv/tests share/man/man9 sys/contrib/libnv sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: lib/libmd lib/libnv/tests share/man/man9 sys/contrib/libnv sys/sys X-SVN-Commit-Revision: 336346 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.27 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, 16 Jul 2018 15:02:25 -0000 Author: kevans Date: Mon Jul 16 15:02:21 2018 New Revision: 336346 URL: https://svnweb.freebsd.org/changeset/base/336346 Log: MFC r304910, r304912, r304915, r304952, r325019, r328164, r331094, r332664, r335341-r335345, r335347, r335379-r335380, r335382 r304910: Introduce cnv man page. r304912: Add missed header file for cnv.h . r304915: Bump date in the man page. r304952: Remove duplicated declaration. r325019: Introduce cnvlist_name() and cnvlist_type() functions. Those function can be used when we are iterating over nvlist to reduce amount of extra variables we need to declare. r328164: libnv: Use mallocarray(9) for the nv_calloc. r331094: Fix formatting errors that resulted in apropos(1) output looking weird. r332664: Add missing argument in the cnv man page. r335341: libnv: change name of cookie from cookiep to cookie. The name was inconsistent with rest of the library. No functional change intended. r335342: libnv: add const to cookies arguments r335343: libnv: Remove nvlist argument from cnvlist_{take,free}_* functions. All information which are need for those operations is already stored in the cookie. We decided not to bump libnv version because this API is not used yet in the base system. r335344: libnv: clean parent in nvlist_array when removing it. When we are removing element form the nvlist we should also clean parent, because the array is not a part of the nvlist anymore. r335345: libnv: add regression test for r335344. r335347: libnv: Add nvlist_append_*_array() family of functions. The nvlist_append_{bool,number,string,nvlist,descriptor}_array() functions allows to dynamically extend array stored in the nvlist. r335379: Set prev to NULL so its garaunteed to have a value of some kind and gcc doesn't explode. Feel free to fix this correctly or whatever for gcc builds. This *should* quiesce tinderbox after r335347 for the gcc builds. r335380: style(9) fix, I was also going to silence gcc. r335382: Really fix the style. Added: stable/11/lib/libnv/tests/nvlist_append_test.c - copied unchanged from r335347, head/lib/libnv/tests/nvlist_append_test.c stable/11/share/man/man9/cnv.9 - copied, changed from r304910, head/share/man/man9/cnv.9 stable/11/sys/sys/cnv.h - copied, changed from r304912, head/sys/sys/cnv.h Modified: stable/11/lib/libmd/sha512.3 stable/11/lib/libnv/tests/Makefile stable/11/lib/libnv/tests/cnv_tests.cc stable/11/lib/libnv/tests/nv_array_tests.cc stable/11/share/man/man9/Makefile stable/11/share/man/man9/nv.9 stable/11/share/man/man9/owll.9 stable/11/share/man/man9/rwlock.9 stable/11/share/man/man9/zone.9 stable/11/sys/contrib/libnv/cnvlist.c stable/11/sys/contrib/libnv/nv_impl.h stable/11/sys/contrib/libnv/nvlist.c stable/11/sys/contrib/libnv/nvpair.c stable/11/sys/sys/nv.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libmd/sha512.3 ============================================================================== --- stable/11/lib/libmd/sha512.3 Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/lib/libmd/sha512.3 Mon Jul 16 15:02:21 2018 (r336346) @@ -26,7 +26,7 @@ .Nm SHA384_End , .Nm SHA384_File , .Nm SHA384_FileChunk , -.Nm SHA384_Data, +.Nm SHA384_Data , .Nm SHA512_256_Init , .Nm SHA512_256_Update , .Nm SHA512_256_Final , Modified: stable/11/lib/libnv/tests/Makefile ============================================================================== --- stable/11/lib/libnv/tests/Makefile Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/lib/libnv/tests/Makefile Mon Jul 16 15:02:21 2018 (r336346) @@ -7,6 +7,7 @@ ATF_TESTS_CXX= \ nv_tests \ TAP_TESTS_C+= nvlist_add_test +TAP_TESTS_C+= nvlist_append_test TAP_TESTS_C+= nvlist_exists_test TAP_TESTS_C+= nvlist_free_test TAP_TESTS_C+= nvlist_get_test Modified: stable/11/lib/libnv/tests/cnv_tests.cc ============================================================================== --- stable/11/lib/libnv/tests/cnv_tests.cc Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/lib/libnv/tests/cnv_tests.cc Mon Jul 16 15:02:21 2018 (r336346) @@ -575,7 +575,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_bool) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - ATF_REQUIRE_EQ(cnvlist_take_bool(nvl, cookie), value); + ATF_REQUIRE_EQ(cnvlist_take_bool(cookie), value); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -618,7 +618,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_number) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - ATF_REQUIRE_EQ(cnvlist_take_number(nvl, cookie), value); + ATF_REQUIRE_EQ(cnvlist_take_number(cookie), value); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -662,7 +662,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_string) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_string = cnvlist_take_string(nvl, cookie); + out_string = cnvlist_take_string(cookie); ATF_REQUIRE(out_string != NULL); ATF_REQUIRE_EQ(strcmp(out_string, value), 0); @@ -725,7 +725,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_nvlist) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - result = cnvlist_take_nvlist(nvl, cookie); + result = cnvlist_take_nvlist(cookie); ATF_REQUIRE(!nvlist_exists_nvlist(nvl, key)); ATF_REQUIRE(result == value); @@ -784,7 +784,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_bool_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_bool_array(nvl, cookie, &nitems); + out_array = cnvlist_take_bool_array(cookie, &nitems); ATF_REQUIRE_EQ(nitems, 16); ATF_REQUIRE(out_array != NULL); for (i = 0; i < 16; i++) @@ -836,7 +836,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_number_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_number_array(nvl, cookie, &nitems); + out_array = cnvlist_take_number_array(cookie, &nitems); ATF_REQUIRE(out_array != NULL); ATF_REQUIRE_EQ(nitems, 16); @@ -885,7 +885,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_string_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_array = cnvlist_take_string_array(nvl, cookie, &nitems); + out_array = cnvlist_take_string_array(cookie, &nitems); ATF_REQUIRE_EQ(nitems, 4); for (i = 0; i < 4; i++) { ATF_REQUIRE(out_array[i] != NULL); @@ -957,7 +957,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_nvlist_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - result = cnvlist_take_nvlist_array(nvl, cookie, &num_items); + result = cnvlist_take_nvlist_array(cookie, &num_items); ATF_REQUIRE(result != NULL); ATF_REQUIRE_EQ(num_items, 8); @@ -1022,7 +1022,7 @@ ATF_TEST_CASE_BODY(cnvlist_take_binary) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - out_binary = cnvlist_take_binary(nvl, cookie, &out_size); + out_binary = cnvlist_take_binary(cookie, &out_size); ATF_REQUIRE_EQ(out_size, in_size); ATF_REQUIRE_EQ(memcmp(in_binary, out_binary, out_size), 0); @@ -1069,7 +1069,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_bool) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_bool(nvl, cookie); + cnvlist_free_bool(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1112,7 +1112,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_number) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_number(nvl, cookie); + cnvlist_free_number(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1155,7 +1155,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_string) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_string(nvl, cookie); + cnvlist_free_string(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1215,7 +1215,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_nvlist) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_nvlist(nvl, cookie); + cnvlist_free_nvlist(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1262,7 +1262,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_binary) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_binary(nvl, cookie); + cnvlist_free_binary(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1309,7 +1309,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_bool_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_bool_array(nvl, cookie); + cnvlist_free_bool_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1354,7 +1354,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_number_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_number_array(nvl, cookie); + cnvlist_free_number_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1396,7 +1396,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_string_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_string_array(nvl, cookie); + cnvlist_free_string_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); @@ -1459,7 +1459,7 @@ ATF_TEST_CASE_BODY(cnvlist_free_nvlist_array) cookie = NULL; ATF_REQUIRE_EQ(strcmp(key, nvlist_next(nvl, &type, &cookie)), 0); - cnvlist_free_nvlist_array(nvl, cookie); + cnvlist_free_nvlist_array(cookie); cookie = NULL; ATF_REQUIRE_EQ(nvlist_error(nvl), 0); Modified: stable/11/lib/libnv/tests/nv_array_tests.cc ============================================================================== --- stable/11/lib/libnv/tests/nv_array_tests.cc Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/lib/libnv/tests/nv_array_tests.cc Mon Jul 16 15:02:21 2018 (r336346) @@ -312,6 +312,7 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__basic) for (i = 0; i < num_items; i++) { ATF_REQUIRE_EQ(nvlist_error(result[i]), 0); ATF_REQUIRE(nvlist_get_array_next(result[i]) == NULL); + ATF_REQUIRE(nvlist_get_parent(result[i], NULL) == NULL); ATF_REQUIRE(nvlist_get_array_next(const_result[i]) == NULL); ATF_REQUIRE(!nvlist_in_array(const_result[i])); } Copied: stable/11/lib/libnv/tests/nvlist_append_test.c (from r335347, head/lib/libnv/tests/nvlist_append_test.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/lib/libnv/tests/nvlist_append_test.c Mon Jul 16 15:02:21 2018 (r336346, copy of r335347, head/lib/libnv/tests/nvlist_append_test.c) @@ -0,0 +1,120 @@ +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include +#include + +static int ntest = 1; + +#define CHECK(expr) do { \ + if ((expr)) \ + printf("ok # %d %s:%u\n", ntest, __FILE__, __LINE__); \ + else \ + printf("not ok # %d %s:%u\n", ntest, __FILE__, __LINE__);\ + ntest++; \ +} while (0) + +int +main(void) +{ + const bool *bool_result; + const char * const *string_result; + const nvlist_t * const *nvl_result; + nvlist_t *nvl, *nvl1, *nvl2, **items; + unsigned int i; + size_t nitems; + + printf("1..32\n"); + + nvl = nvlist_create(0); + + for (i = 0; i < 16; i++) + nvlist_append_bool_array(nvl, "nvl/bool", i % 2 == 0); + + CHECK(nvlist_error(nvl) == 0); + CHECK(!nvlist_empty(nvl)); + CHECK(nvlist_exists_bool_array(nvl, "nvl/bool")); + + bool_result = nvlist_get_bool_array(nvl, "nvl/bool", &nitems); + CHECK(nitems == 16); + CHECK(bool_result != NULL); + for (i = 0; i < nitems; i++) + CHECK(bool_result[i] == (i % 2 == 0)); + + + nvlist_append_string_array(nvl, "nvl/string", "a"); + nvlist_append_string_array(nvl, "nvl/string", "abc"); + string_result = nvlist_get_string_array(nvl, "nvl/string", &nitems); + CHECK(nitems == 2); + CHECK(strcmp(string_result[0], "a") == 0); + CHECK(strcmp(string_result[1], "abc") == 0); + + + nvl1 = nvlist_create(0); + nvlist_add_string(nvl1, "key1", "test1"); + nvlist_append_nvlist_array(nvl, "nvl/nvl", nvl1); + nvlist_destroy(nvl1); + + nvl2 = nvlist_create(0); + nvlist_add_string(nvl2, "key2", "test2"); + nvlist_append_nvlist_array(nvl, "nvl/nvl", nvl2); + nvlist_destroy(nvl2); + + nvl_result = nvlist_get_nvlist_array(nvl, "nvl/nvl", &nitems); + CHECK(nitems == 2); + CHECK(strcmp(nvlist_get_string(nvl_result[0], "key1"), "test1") == 0); + CHECK(strcmp(nvlist_get_string(nvl_result[1], "key2"), "test2") == 0); + + nvl1 = nvlist_create(0); + nvlist_add_number(nvl1, "key1", 10); + nvlist_append_nvlist_array(nvl, "nvl/nvl_array", nvl1); + nvlist_destroy(nvl1); + + nvl2 = nvlist_create(0); + nvlist_add_number(nvl2, "key1", 20); + nvlist_append_nvlist_array(nvl, "nvl/nvl_array", nvl2); + nvlist_destroy(nvl2); + + items = nvlist_take_nvlist_array(nvl, "nvl/nvl_array", &nitems); + CHECK(nvlist_get_number(items[0], "key1") == 10); + CHECK(nvlist_get_number(items[1], "key1") == 20); + CHECK(nvlist_error(items[0]) == 0); + CHECK(nvlist_error(items[1]) == 0); + + nvlist_move_nvlist_array(nvl, "nvl/nvl_new_array", items, nitems); + CHECK(nvlist_error(nvl) == 0); + + nvlist_destroy(nvl); + + return (0); +} Modified: stable/11/share/man/man9/Makefile ============================================================================== --- stable/11/share/man/man9/Makefile Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/share/man/man9/Makefile Mon Jul 16 15:02:21 2018 (r336346) @@ -57,6 +57,7 @@ MAN= accept_filter.9 \ byteorder.9 \ casuword.9 \ cd.9 \ + cnv.9 \ condvar.9 \ config_intrhook.9 \ contigmalloc.9 \ @@ -619,6 +620,41 @@ MLINKS+=byteorder.9 be16dec.9 \ byteorder.9 le64dec.9 \ byteorder.9 le64enc.9 \ byteorder.9 le64toh.9 +MLINKS+=cnv.9 cnvlist.9 \ + cnv.9 cnvlist_free_binary.9 \ + cnv.9 cnvlist_free_bool.9 \ + cnv.9 cnvlist_free_bool_array.9 \ + cnv.9 cnvlist_free_descriptor.9 \ + cnv.9 cnvlist_free_descriptor_array.9 \ + cnv.9 cnvlist_free_null.9 \ + cnv.9 cnvlist_free_number.9 \ + cnv.9 cnvlist_free_number_array.9 \ + cnv.9 cnvlist_free_nvlist.9 \ + cnv.9 cnvlist_free_nvlist_array.9 \ + cnv.9 cnvlist_free_string.9 \ + cnv.9 cnvlist_free_string_array.9 \ + cnv.9 cnvlist_get_binary.9 \ + cnv.9 cnvlist_get_bool.9 \ + cnv.9 cnvlist_get_bool_array.9 \ + cnv.9 cnvlist_get_descriptor.9 \ + cnv.9 cnvlist_get_descriptor_array.9 \ + cnv.9 cnvlist_get_number.9 \ + cnv.9 cnvlist_get_number_array.9 \ + cnv.9 cnvlist_get_nvlist.9 \ + cnv.9 cnvlist_get_nvlist_array.9 \ + cnv.9 cnvlist_get_string.9 \ + cnv.9 cnvlist_get_string_array.9 \ + cnv.9 cnvlist_take_binary.9 \ + cnv.9 cnvlist_take_bool.9 \ + cnv.9 cnvlist_take_bool_array.9 \ + cnv.9 cnvlist_take_descriptor.9 \ + cnv.9 cnvlist_take_descriptor_array.9 \ + cnv.9 cnvlist_take_number.9 \ + cnv.9 cnvlist_take_number_array.9 \ + cnv.9 cnvlist_take_nvlist.9 \ + cnv.9 cnvlist_take_nvlist_array.9 \ + cnv.9 cnvlist_take_string.9 \ + cnv.9 cnvlist_take_string_array.9 MLINKS+=condvar.9 cv_broadcast.9 \ condvar.9 cv_broadcastpri.9 \ condvar.9 cv_destroy.9 \ Copied and modified: stable/11/share/man/man9/cnv.9 (from r304910, head/share/man/man9/cnv.9) ============================================================================== --- head/share/man/man9/cnv.9 Sat Aug 27 13:47:52 2016 (r304910, copy source) +++ stable/11/share/man/man9/cnv.9 Mon Jul 16 15:02:21 2018 (r336346) @@ -25,88 +25,93 @@ .\" .\" $FreeBSD$ .\" -.Dd July 26, 2016 +.Dd June 18, 2018 .Dt CNV 9 .Os .Sh NAME -.Nm cnvlist_get, -.Nm cnvlist_take, -.Nm cnvlist_free, +.Nm cnvlist_get , +.Nm cnvlist_take , +.Nm cnvlist_free .Nd "API for managing name/value pairs by cookie." .Sh LIBRARY .Lb libnv .Sh SYNOPSIS .In sys/cnv.h +.Ft const char * +.Fn cnvlist_name "const void *cookie" +.Ft int +.Fn cnvlist_type "const void *cookie" +.\" .Ft bool -.Fn cnvlist_get_bool "void *cookiep" +.Fn cnvlist_get_bool "const void *cookie" .Ft uint64_t -.Fn cnvlist_get_number "void *cookiep" +.Fn cnvlist_get_number "const void *cookie" .Ft "const char *" -.Fn cnvlist_get_string "void *cookiep" +.Fn cnvlist_get_string "const void *cookie" .Ft "const nvlist_t *" -.Fn cnvlist_get_nvlist "void *cookiep" +.Fn cnvlist_get_nvlist "const void *cookie" .Ft "const void *" -.Fn cnvlist_get_binary "void *cookiep" "size_t *sizep" +.Fn cnvlist_get_binary "const void *cookie" "size_t *sizep" .Ft "const bool *" -.Fn cnvlist_get_bool_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_get_bool_array "const void *cookie" "size_t *nitemsp" .Ft "const uint64_t *" -.Fn cnvlist_get_number_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_get_number_array "const void *cookie" "size_t *nitemsp" .Ft "const char * const *" -.Fn cnvlist_get_string_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_get_string_array "const void *cookie" "size_t *nitemsp" .Ft "const nvlist_t * const *" -.Fn cnvlist_get_nvlist_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_get_nvlist_array "const void *cookie" "size_t *nitemsp" .Ft int -.Fn cnvlist_get_descriptor "void *cookiep" +.Fn cnvlist_get_descriptor "const void *cookie" .Ft "const int *" -.Fn cnvlist_get_descriptor_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_get_descriptor_array "const void *cookie" "size_t *nitemsp" .\" .Ft bool -.Fn cnvlist_take_bool "void *cookiep" +.Fn cnvlist_take_bool "void *cookie" .Ft uint64_t -.Fn cnvlist_take_number "void *cookiep" +.Fn cnvlist_take_number "void *cookie" .Ft "const char *" -.Fn cnvlist_take_string "void *cookiep" +.Fn cnvlist_take_string "void *cookie" .Ft "const nvlist_t *" -.Fn cnvlist_take_nvlist "void *cookiep" +.Fn cnvlist_take_nvlist "void *cookie" .Ft "const void *" -.Fn cnvlist_take_binary "void *cookiep" "size_t *sizep" +.Fn cnvlist_take_binary "void *cookie" "size_t *sizep" .Ft "const bool *" -.Fn cnvlist_take_bool_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_take_bool_array "void *cookie" "size_t *nitemsp" .Ft "const uint64_t *" -.Fn cnvlist_take_number_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_take_number_array "void *cookie" "size_t *nitemsp" .Ft "const char * const *" -.Fn cnvlist_take_string_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_take_string_array "void *cookie" "size_t *nitemsp" .Ft "const nvlist_t * const *" -.Fn cnvlist_take_nvlist_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_take_nvlist_array "void *cookie" "size_t *nitemsp" .Ft int -.Fn cnvlist_take_descriptor "void *cookiep" +.Fn cnvlist_take_descriptor "void *cookie" .Ft "const int *' -.Fn cnvlist_take_descriptor_array "void *cookiep" "size_t *nitemsp" +.Fn cnvlist_take_descriptor_array "void *cookie" "size_t *nitemsp" .\" .Ft void -.Fn cnvlist_free_null "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_null "void *cookie" .Ft void -.Fn cnvlist_free_bool "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_bool "void *cookie" .Ft void -.Fn cnvlist_free_number "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_number "void *cookie" .Ft void -.Fn cnvlist_free_string "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_string "void *cookie" .Ft void -.Fn cnvlist_free_nvlist "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_nvlist "void *cookie" .Ft void -.Fn cnvlist_free_descriptor "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_descriptor "void *cookie" .Ft void -.Fn cnvlist_free_binary "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_binary "void *cookie" .Ft void -.Fn cnvlist_free_bool_array "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_bool_array "void *cookie" .Ft void -.Fn cnvlist_free_number_array "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_number_array "void *cookie" .Ft void -.Fn cnvlist_free_string_array "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_string_array "void *cookie" .Ft void -.Fn cnvlist_free_nvlist_array "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_nvlist_array "void *cookie" .Ft void -.Fn cnvlist_free_descriptor_array "nvlist_t *nvl" "void *cookiep" +.Fn cnvlist_free_descriptor_array "void *cookie" .Sh DESCRIPTION The .Nm libnv @@ -124,6 +129,16 @@ from .Xr nv 9 . .Pp The +.Fn cnvlist_name +function returns the name of an element associated with the given cookie. +.Pp +The +.Fn cnvlist_type +function returns the type of an element associated with the given cookie. +Types which can be returned are described in +.Xr nv 9 . +.Pp +The .Nm cnvlist_get family of functions obtains the value associated with the given cookie. Returned strings, nvlists, descriptors, binaries, or arrays must not be modified @@ -177,8 +192,8 @@ while (nvlist_next(nvl, &type, &cookie) != NULL) { } } -name = cnvlist_take_string(nvl, scookie); -cnvlist_free_bool(nvl, bcookie); +name = cnvlist_take_string(scookie); +cnvlist_free_bool(bcookie); printf("test2: %s\\n", name); free(name); Modified: stable/11/share/man/man9/nv.9 ============================================================================== --- stable/11/share/man/man9/nv.9 Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/share/man/man9/nv.9 Mon Jul 16 15:02:21 2018 (r336346) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 16, 2017 +.Dd June 19, 2018 .Dt NV 9 .Os .Sh NAME @@ -55,7 +55,8 @@ .Nm nvlist_add , .Nm nvlist_move , .Nm nvlist_get , -.Nm nvlist_take +.Nm nvlist_take , +.Nm nvlist_append .Nd "library for name/value pairs" .Sh LIBRARY .Lb libnv @@ -239,6 +240,17 @@ .Fn nvlist_take_descriptor_array "nvlist_t *nvl" "const char *name" "size_t *nitems" .\" .Ft void +.Fn nvlist_append_bool_array "nvlist_t *nvl" "const char *name" "const bool value" +.Ft void +.Fn nvlist_append_number_array "nvlist_t *nvl" "const char *name" "const uint64_t value" +.Ft void +.Fn nvlist_append_string_array "nvlist_t *nvl" "const char *name" "const char * const value" +.Ft void +.Fn nvlist_append_nvlist_array "nvlist_t *nvl" "const char *name" "const nvlist_t * const value" +.Ft void +.Fn nvlist_append_descriptor_array "nvlist_t *nvl" "const char *name" "int value" +.\" +.Ft void .Fn nvlist_free "nvlist_t *nvl" "const char *name" .Ft void .Fn nvlist_free_type "nvlist_t *nvl" "const char *name" "int type" @@ -708,6 +720,20 @@ the array using the .Xr free 3 function. The nvlist must not be in error state. +.Pp +The +.Fn nvlist_append_bool_array , +.Fn nvlist_append_number_array , +.Fn nvlist_append_string_array , +.Fn nvlist_append_nvlist_array , +.Fn nvlist_append_descriptor_array +functions append an element to the existing array using the same semantics +as the add functions (i.e. the element will be copied when applicable). +If the array for a given key does not exist, then it will be created +as if using the +.Fn nvlist_add__array +function. +The internal error is set on append failure. .Pp The .Fn nvlist_free Modified: stable/11/share/man/man9/owll.9 ============================================================================== --- stable/11/share/man/man9/owll.9 Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/share/man/man9/owll.9 Mon Jul 16 15:02:21 2018 (r336346) @@ -29,9 +29,9 @@ .Os .Sh NAME .Nm owll -.Nm OWLL_WRITE_ONE, -.Nm OWLL_WRITE_ZERO, -.Nm OWLL_READ_DATA, +.Nm OWLL_WRITE_ONE , +.Nm OWLL_WRITE_ZERO , +.Nm OWLL_READ_DATA , .Nm OWLL_REASET_AND_PRESENCE .Nd Dallas Semiconductor 1-Wire Link Layer Interface .Sh SYNOPSIS Modified: stable/11/share/man/man9/rwlock.9 ============================================================================== --- stable/11/share/man/man9/rwlock.9 Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/share/man/man9/rwlock.9 Mon Jul 16 15:02:21 2018 (r336346) @@ -30,7 +30,7 @@ .Sh NAME .Nm rwlock , .Nm rw_init , -.Nm rw_init_flags, +.Nm rw_init_flags , .Nm rw_destroy , .Nm rw_rlock , .Nm rw_wlock , Modified: stable/11/share/man/man9/zone.9 ============================================================================== --- stable/11/share/man/man9/zone.9 Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/share/man/man9/zone.9 Mon Jul 16 15:02:21 2018 (r336346) @@ -35,10 +35,10 @@ .Nm uma_zfree , .Nm uma_zfree_arg , .Nm uma_zdestroy , -.Nm uma_zone_set_max, -.Nm uma_zone_get_max, -.Nm uma_zone_get_cur, -.Nm uma_zone_set_warning, +.Nm uma_zone_set_max , +.Nm uma_zone_get_max , +.Nm uma_zone_get_cur , +.Nm uma_zone_set_warning , .Nm uma_zone_set_maxaction .Nd zone allocator .Sh SYNOPSIS Modified: stable/11/sys/contrib/libnv/cnvlist.c ============================================================================== --- stable/11/sys/contrib/libnv/cnvlist.c Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/sys/contrib/libnv/cnvlist.c Mon Jul 16 15:02:21 2018 (r336346) @@ -53,16 +53,30 @@ __FBSDID("$FreeBSD$"); #include "nvlist_impl.h" #include "nvpair_impl.h" +const char * +cnvlist_name(const void *cookie) +{ + + return (nvpair_name(cookie)); +} + +int +cnvlist_type(const void *cookie) +{ + + return (nvpair_type(cookie)); +} + #define CNVLIST_GET(ftype, type, NVTYPE) \ ftype \ -cnvlist_get_##type(void *cookiep) \ +cnvlist_get_##type(const void *cookie) \ { \ \ - if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) { \ + if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \ nvlist_report_missing(NV_TYPE_##NVTYPE, \ - nvpair_name(cookiep)); \ + nvpair_name(cookie)); \ } \ - return (nvpair_get_##type(cookiep)); \ + return (nvpair_get_##type(cookie)); \ } CNVLIST_GET(bool, bool, BOOL) @@ -77,14 +91,14 @@ CNVLIST_GET(int, descriptor, DESCRIPTOR) #define CNVLIST_GET_ARRAY(ftype, type, NVTYPE) \ ftype \ -cnvlist_get_##type(void *cookiep, size_t *nitemsp) \ +cnvlist_get_##type(const void *cookie, size_t *nitemsp) \ { \ \ - if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) { \ + if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \ nvlist_report_missing(NV_TYPE_##NVTYPE, \ - nvpair_name(cookiep)); \ + nvpair_name(cookie)); \ } \ - return (nvpair_get_##type(cookiep, nitemsp)); \ + return (nvpair_get_##type(cookie, nitemsp)); \ } CNVLIST_GET_ARRAY(const bool *, bool_array, BOOL_ARRAY) @@ -98,27 +112,29 @@ CNVLIST_GET_ARRAY(const int *, descriptor_array, DESCR #undef CNVLIST_GET_ARRAY const void * -cnvlist_get_binary(void *cookiep, size_t *sizep) +cnvlist_get_binary(const void *cookie, size_t *sizep) { - if (nvpair_type(cookiep) != NV_TYPE_BINARY) - nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookiep)); - return (nvpair_get_binary(cookiep, sizep)); + if (nvpair_type(cookie) != NV_TYPE_BINARY) + nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookie)); + return (nvpair_get_binary(cookie, sizep)); } #define CNVLIST_TAKE(ftype, type, NVTYPE) \ ftype \ -cnvlist_take_##type(nvlist_t *nvl, void *cookiep) \ +cnvlist_take_##type(void *cookie) \ { \ ftype value; \ + nvlist_t *nvl; \ \ - if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) { \ + if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \ nvlist_report_missing(NV_TYPE_##NVTYPE, \ - nvpair_name(cookiep)); \ + nvpair_name(cookie)); \ } \ - value = (ftype)(intptr_t)nvpair_get_##type(cookiep); \ - nvlist_remove_nvpair(nvl, cookiep); \ - nvpair_free_structure(cookiep); \ + nvl = nvpair_nvlist(cookie); \ + value = (ftype)(intptr_t)nvpair_get_##type(cookie); \ + nvlist_remove_nvpair(nvl, cookie); \ + nvpair_free_structure(cookie); \ return (value); \ } @@ -134,17 +150,19 @@ CNVLIST_TAKE(int, descriptor, DESCRIPTOR) #define CNVLIST_TAKE_ARRAY(ftype, type, NVTYPE) \ ftype \ -cnvlist_take_##type(nvlist_t *nvl, void *cookiep, size_t *nitemsp) \ +cnvlist_take_##type(void *cookie, size_t *nitemsp) \ { \ ftype value; \ + nvlist_t *nvl; \ \ - if (nvpair_type(cookiep) != NV_TYPE_##NVTYPE) { \ + if (nvpair_type(cookie) != NV_TYPE_##NVTYPE) { \ nvlist_report_missing(NV_TYPE_##NVTYPE, \ - nvpair_name(cookiep)); \ + nvpair_name(cookie)); \ } \ - value = (ftype)(intptr_t)nvpair_get_##type(cookiep, nitemsp); \ - nvlist_remove_nvpair(nvl, cookiep); \ - nvpair_free_structure(cookiep); \ + nvl = nvpair_nvlist(cookie); \ + value = (ftype)(intptr_t)nvpair_get_##type(cookie, nitemsp); \ + nvlist_remove_nvpair(nvl, cookie); \ + nvpair_free_structure(cookie); \ return (value); \ } @@ -159,25 +177,27 @@ CNVLIST_TAKE_ARRAY(int *, descriptor_array, DESCRIPTOR #undef CNVLIST_TAKE_ARRAY void * -cnvlist_take_binary(nvlist_t *nvl, void *cookiep, size_t *sizep) +cnvlist_take_binary(void *cookie, size_t *sizep) { void *value; + nvlist_t *nvl; - if (nvpair_type(cookiep) != NV_TYPE_BINARY) - nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookiep)); - value = (void *)(intptr_t)nvpair_get_binary(cookiep, sizep); - nvlist_remove_nvpair(nvl, cookiep); - nvpair_free_structure(cookiep); + if (nvpair_type(cookie) != NV_TYPE_BINARY) + nvlist_report_missing(NV_TYPE_BINARY, nvpair_name(cookie)); + nvl = nvpair_nvlist(cookie); + value = (void *)(intptr_t)nvpair_get_binary(cookie, sizep); + nvlist_remove_nvpair(nvl, cookie); + nvpair_free_structure(cookie); return (value); } #define CNVLIST_FREE(type) \ void \ -cnvlist_free_##type(nvlist_t *nvl, void *cookiep) \ +cnvlist_free_##type(void *cookie) \ { \ \ - nvlist_free_nvpair(nvl, cookiep); \ + nvlist_free_nvpair(nvpair_nvlist(cookie), cookie); \ } CNVLIST_FREE(bool) Modified: stable/11/sys/contrib/libnv/nv_impl.h ============================================================================== --- stable/11/sys/contrib/libnv/nv_impl.h Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/sys/contrib/libnv/nv_impl.h Mon Jul 16 15:02:21 2018 (r336346) @@ -51,7 +51,7 @@ typedef struct nvpair nvpair_t; #ifdef _KERNEL #define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK) -#define nv_calloc(n, size) malloc((n) * (size), M_NVLIST, \ +#define nv_calloc(n, size) mallocarray((n), (size), M_NVLIST, \ M_WAITOK | M_ZERO) #define nv_realloc(buf, size) realloc((buf), (size), M_NVLIST, \ M_WAITOK) @@ -140,6 +140,12 @@ nvpair_t *nvpair_move_nvlist_array(const char *name, n nvpair_t *nvpair_move_descriptor_array(const char *name, int *value, size_t nitems); nvpair_t *nvpair_move_number_array(const char *name, uint64_t *value, size_t nitems); nvpair_t *nvpair_move_string_array(const char *name, char **value, size_t nitems); + +int nvpair_append_bool_array(nvpair_t *nvp, const bool value); +int nvpair_append_number_array(nvpair_t *nvp, const uint64_t value); +int nvpair_append_string_array(nvpair_t *nvp, const char *value); +int nvpair_append_nvlist_array(nvpair_t *nvp, const nvlist_t *value); +int nvpair_append_descriptor_array(nvpair_t *nvp, const int value); bool nvpair_get_bool(const nvpair_t *nvp); uint64_t nvpair_get_number(const nvpair_t *nvp); Modified: stable/11/sys/contrib/libnv/nvlist.c ============================================================================== --- stable/11/sys/contrib/libnv/nvlist.c Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/sys/contrib/libnv/nvlist.c Mon Jul 16 15:02:21 2018 (r336346) @@ -1606,6 +1606,37 @@ NVLIST_ADD_ARRAY(const int *, descriptor) #undef NVLIST_ADD_ARRAY +#define NVLIST_APPEND_ARRAY(vtype, type, TYPE) \ +void \ +nvlist_append_##type##_array(nvlist_t *nvl, const char *name, vtype value)\ +{ \ + nvpair_t *nvp; \ + \ + if (nvlist_error(nvl) != 0) { \ + ERRNO_SET(nvlist_error(nvl)); \ + return; \ + } \ + nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \ + if (nvp == NULL) { \ + nvlist_add_##type##_array(nvl, name, &value, 1); \ + return; \ + } \ + if (nvpair_append_##type##_array(nvp, value) == -1) { \ + nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \ + ERRNO_SET(nvl->nvl_error); \ + } \ +} + +NVLIST_APPEND_ARRAY(const bool, bool, BOOL) +NVLIST_APPEND_ARRAY(const uint64_t, number, NUMBER) +NVLIST_APPEND_ARRAY(const char *, string, STRING) +NVLIST_APPEND_ARRAY(const nvlist_t *, nvlist, NVLIST) +#ifndef _KERNEL +NVLIST_APPEND_ARRAY(const int, descriptor, DESCRIPTOR) +#endif + +#undef NVLIST_APPEND_ARRAY + bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp) { Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Mon Jul 16 14:56:30 2018 (r336345) +++ stable/11/sys/contrib/libnv/nvpair.c Mon Jul 16 15:02:21 2018 (r336346) @@ -142,6 +142,28 @@ nvpair_allocv(const char *name, int type, uint64_t dat return (nvp); } +static int +nvpair_append(nvpair_t *nvp, const void *value, size_t valsize, size_t datasize) +{ + void *olddata, *data, *valp; + size_t oldlen; + + oldlen = nvp->nvp_nitems * valsize; + olddata = (void *)(uintptr_t)nvp->nvp_data; + data = nv_realloc(olddata, oldlen + valsize); + if (data == NULL) { + ERRNO_SET(ENOMEM); + return (-1); + } + valp = (unsigned char *)data + oldlen; + memcpy(valp, value, valsize); + + nvp->nvp_data = (uint64_t)(uintptr_t)data; + nvp->nvp_datasize += datasize; + nvp->nvp_nitems++; + return (0); +} + nvlist_t * nvpair_nvlist(const nvpair_t *nvp) { @@ -204,8 +226,10 @@ nvpair_remove_nvlist_array(nvpair_t *nvp) /* XXX: DECONST is bad, mkay? */ nvlarray = __DECONST(nvlist_t **, nvpair_get_nvlist_array(nvp, &count)); - for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { nvlist_set_array_next(nvlarray[i], NULL); + nvlist_set_parent(nvlarray[i], NULL); + } } void @@ -1906,6 +1930,122 @@ nvpair_get_descriptor_array(const nvpair_t *nvp, size_ *nitems = nvp->nvp_nitems; return ((const int *)(intptr_t)nvp->nvp_data); +} +#endif + +int +nvpair_append_bool_array(nvpair_t *nvp, const bool value) +{ + + NVPAIR_ASSERT(nvp); + PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_BOOL_ARRAY); + return (nvpair_append(nvp, &value, sizeof(value), sizeof(value))); +} + +int +nvpair_append_number_array(nvpair_t *nvp, const uint64_t value) +{ + + NVPAIR_ASSERT(nvp); + PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NUMBER_ARRAY); + return (nvpair_append(nvp, &value, sizeof(value), sizeof(value))); +} + +int +nvpair_append_string_array(nvpair_t *nvp, const char *value) +{ + char *str; + + NVPAIR_ASSERT(nvp); + PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_STRING_ARRAY); + if (value == NULL) { + ERRNO_SET(EINVAL); + return (-1); + } + str = nv_strdup(value); + if (str == NULL) { + return (-1); + } + if (nvpair_append(nvp, &str, sizeof(str), strlen(str) + 1) == -1) { + nv_free(str); + return (-1); + } + return (0); +} + +int +nvpair_append_nvlist_array(nvpair_t *nvp, const nvlist_t *value) +{ + nvpair_t *tmpnvp; + nvlist_t *nvl, *prev; + int flags; + + NVPAIR_ASSERT(nvp); + PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NVLIST_ARRAY); + if (value == NULL || nvlist_error(value) != 0 || + nvlist_get_pararr(value, NULL) != NULL) { + ERRNO_SET(EINVAL); + return (-1); + } + nvl = nvlist_clone(value); + if (nvl == NULL) { + return (-1); + } + flags = nvlist_flags(nvl) | NV_FLAG_IN_ARRAY; + nvlist_set_flags(nvl, flags); + + tmpnvp = NULL; + prev = NULL; + if (nvp->nvp_nitems > 0) { + nvlist_t **nvls = (void *)(uintptr_t)nvp->nvp_data; + + prev = nvls[nvp->nvp_nitems - 1]; + PJDLOG_ASSERT(prev != NULL); + + tmpnvp = nvpair_allocv(" ", NV_TYPE_NVLIST, + (uint64_t)(uintptr_t)nvl, 0, 0); + if (tmpnvp == NULL) { + goto fail; + } + } + if (nvpair_append(nvp, &nvl, sizeof(nvl), 0) == -1) { + goto fail; + } + if (tmpnvp) { + NVPAIR_ASSERT(tmpnvp); + nvlist_set_array_next(prev, tmpnvp); + } + nvlist_set_parent(nvl, nvp); + return (0); +fail: + if (tmpnvp) { + nvpair_free(tmpnvp); + } + nvlist_destroy(nvl); + return (-1); +} + +#ifndef _KERNEL *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Tue Jul 17 11:44:05 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 44604103BCDC; Tue, 17 Jul 2018 11:44:05 +0000 (UTC) (envelope-from peterj@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 EE376850AE; Tue, 17 Jul 2018 11:44:04 +0000 (UTC) (envelope-from peterj@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 D0ADC2E3E; Tue, 17 Jul 2018 11:44:04 +0000 (UTC) (envelope-from peterj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6HBi49M091359; Tue, 17 Jul 2018 11:44:04 GMT (envelope-from peterj@FreeBSD.org) Received: (from peterj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6HBi42u091358; Tue, 17 Jul 2018 11:44:04 GMT (envelope-from peterj@FreeBSD.org) Message-Id: <201807171144.w6HBi42u091358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: peterj set sender to peterj@FreeBSD.org using -f From: Peter Jeremy Date: Tue, 17 Jul 2018 11:44: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: r336409 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: peterj X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 336409 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.27 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: Tue, 17 Jul 2018 11:44:05 -0000 Author: peterj Date: Tue Jul 17 11:44:04 2018 New Revision: 336409 URL: https://svnweb.freebsd.org/changeset/base/336409 Log: Retrospectively document SVN branch points for stable-11 and its releases. This is a direct commit to stable/11 because the releases are taken from this branch. Approved by: jhb (mentor) Differential Revision: https://reviews.freebsd.org/D16264 Modified: stable/11/UPDATING Modified: stable/11/UPDATING ============================================================================== --- stable/11/UPDATING Tue Jul 17 11:43:43 2018 (r336408) +++ stable/11/UPDATING Tue Jul 17 11:44:04 2018 (r336409) @@ -22,6 +22,9 @@ from older version of current across the gcc/clang cut prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. +20180601: + The releng/11.2 branch has been created from stable/11@r334458. + 20180504: The tz database (tzdb) has been updated to 2018e. This version more correctly models time stamps in time zones with negative DST such as @@ -88,6 +91,9 @@ from older version of current across the gcc/clang cut starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' to which you should answer yes. +20170629: + The releng/11.1 branch has been created from stable/11@r320475. + 20170518: arm64 builds now use the base system LLD 4.0.0 linker by default, instead of requiring that the aarch64-binutils port or package be @@ -174,6 +180,12 @@ from older version of current across the gcc/clang cut to use an extension of .pico instead. The purpose of this change is to avoid a name clash with shared libraries on case-insensitive file systems. On those file systems, foo.So is the same file as foo.so. + +20160811: + The releng/11.0 branch has been created from stable/11@r303970. + +20160708: + The stable/11 branch has been created from head@r302406. 20160622: The libc stub for the pipe(2) system call has been replaced with From owner-svn-src-stable-11@freebsd.org Tue Jul 17 19:10:17 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 02A36104AD4B; Tue, 17 Jul 2018 19:10:17 +0000 (UTC) (envelope-from rmacklem@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 A7855753C4; Tue, 17 Jul 2018 19:10:16 +0000 (UTC) (envelope-from rmacklem@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 87EC07971; Tue, 17 Jul 2018 19:10:16 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6HJAG7k022566; Tue, 17 Jul 2018 19:10:16 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6HJAGXn022564; Tue, 17 Jul 2018 19:10:16 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807171910.w6HJAGXn022564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Tue, 17 Jul 2018 19:10:16 +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: r336421 - in stable/11/sys/fs: nfs nfsserver X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/11/sys/fs: nfs nfsserver X-SVN-Commit-Revision: 336421 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.27 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: Tue, 17 Jul 2018 19:10:17 -0000 Author: rmacklem Date: Tue Jul 17 19:10:15 2018 New Revision: 336421 URL: https://svnweb.freebsd.org/changeset/base/336421 Log: MFC: r333645 End grace for the NFSv4 server if all mounts do ReclaimComplete. The NFSv4 protocol requires that the server only allow reclaim of state and not issue any new open/lock state for a grace period after booting. The NFSv4.0 protocol required this grace period to be greater than the lease duration (over 2minutes). For NFSv4.1, the client tells the server that it has done reclaiming state by doing a ReclaimComplete operation. If all NFSv4 clients are NFSv4.1, the grace period can end once all the clients have done ReclaimComplete, shortening the time period considerably. This patch does this. If there are any NFSv4.0 mounts, the grace period will still be over 2minutes. This change is only an optimization and does not affect correct operation. Modified: stable/11/sys/fs/nfs/nfsport.h stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfsport.h ============================================================================== --- stable/11/sys/fs/nfs/nfsport.h Tue Jul 17 19:05:30 2018 (r336420) +++ stable/11/sys/fs/nfs/nfsport.h Tue Jul 17 19:10:15 2018 (r336421) @@ -588,6 +588,7 @@ struct nfst_rec { #define NFSNST_NEWSTATE 0x1 #define NFSNST_REVOKE 0x2 #define NFSNST_GOTSTATE 0x4 +#define NFSNST_RECLAIMED 0x8 /* * This structure is linked onto nfsrv_stablefirst for the duration of Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Tue Jul 17 19:05:30 2018 (r336420) +++ stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Tue Jul 17 19:10:15 2018 (r336421) @@ -134,6 +134,7 @@ static int nfsrv_cbcallargs(struct nfsrv_descript *nd, static u_int32_t nfsrv_nextclientindex(void); static u_int32_t nfsrv_nextstateindex(struct nfsclient *clp); static void nfsrv_markstable(struct nfsclient *clp); +static void nfsrv_markreclaim(struct nfsclient *clp); static int nfsrv_checkstable(struct nfsclient *clp); static int nfsrv_clientconflict(struct nfsclient *clp, int *haslockp, struct vnode *vp, NFSPROC_T *p); @@ -4090,8 +4091,27 @@ static int nfsrv_checkgrace(struct nfsrv_descript *nd, struct nfsclient *clp, u_int32_t flags) { - int error = 0; + int error = 0, notreclaimed; + struct nfsrv_stable *sp; + if ((nfsrv_stablefirst.nsf_flags & (NFSNSF_UPDATEDONE | + NFSNSF_GRACEOVER)) == 0) { + /* + * First, check to see if all of the clients have done a + * ReclaimComplete. If so, grace can end now. + */ + notreclaimed = 0; + LIST_FOREACH(sp, &nfsrv_stablefirst.nsf_head, nst_list) { + if ((sp->nst_flag & NFSNST_RECLAIMED) == 0) { + notreclaimed = 1; + break; + } + } + if (notreclaimed == 0) + nfsrv_stablefirst.nsf_flags |= (NFSNSF_GRACEOVER | + NFSNSF_NEEDLOCK); + } + if ((nfsrv_stablefirst.nsf_flags & NFSNSF_GRACEOVER) != 0) { if (flags & NFSLCK_RECLAIM) { error = NFSERR_NOGRACE; @@ -4748,6 +4768,32 @@ nfsrv_markstable(struct nfsclient *clp) } /* + * This function is called when a NFSv4.1 client does a ReclaimComplete. + * Very similar to nfsrv_markstable(), except for the flag being set. + */ +static void +nfsrv_markreclaim(struct nfsclient *clp) +{ + struct nfsrv_stable *sp; + + /* + * First find the client structure. + */ + LIST_FOREACH(sp, &nfsrv_stablefirst.nsf_head, nst_list) { + if (sp->nst_len == clp->lc_idlen && + !NFSBCMP(sp->nst_client, clp->lc_id, sp->nst_len)) + break; + } + if (sp == LIST_END(&nfsrv_stablefirst.nsf_head)) + return; + + /* + * Now, just set the flag. + */ + sp->nst_flag |= NFSNST_RECLAIMED; +} + +/* * This function is called for a reclaim, to see if it gets grace. * It returns 0 if a reclaim is allowed, 1 otherwise. */ @@ -5905,8 +5951,10 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd) /* Check to see if reclaim complete has already happened. */ if ((sep->sess_clp->lc_flags & LCL_RECLAIMCOMPLETE) != 0) error = NFSERR_COMPLETEALREADY; - else + else { sep->sess_clp->lc_flags |= LCL_RECLAIMCOMPLETE; + nfsrv_markreclaim(sep->sess_clp); + } NFSUNLOCKSESSION(shp); NFSUNLOCKSTATE(); return (error); From owner-svn-src-stable-11@freebsd.org Wed Jul 18 01:57:14 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 583E8102F224; Wed, 18 Jul 2018 01:57:14 +0000 (UTC) (envelope-from eugen@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 0C4EE82ABB; Wed, 18 Jul 2018 01:57:14 +0000 (UTC) (envelope-from eugen@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 DBDB013BDB; Wed, 18 Jul 2018 01:57:13 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6I1vDjS030922; Wed, 18 Jul 2018 01:57:13 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6I1vDLG030921; Wed, 18 Jul 2018 01:57:13 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201807180157.w6I1vDLG030921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Wed, 18 Jul 2018 01:57:13 +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: r336440 - stable/11/sbin/dhclient X-SVN-Group: stable-11 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/11/sbin/dhclient X-SVN-Commit-Revision: 336440 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.27 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, 18 Jul 2018 01:57:14 -0000 Author: eugen Date: Wed Jul 18 01:57:13 2018 New Revision: 336440 URL: https://svnweb.freebsd.org/changeset/base/336440 Log: MFC r336195: unbreak dhclient(8) option 26 processing Make dhclient(8) verify if new MTU (option 26) differs from current one and skip unneeded MTU change. This check eliminates infinite loop of MTU change / link flap / lease verification / MTU change / link flap etc. in case of some NIC drivers like em(4) or igb(4). PR: 229432 Approved by: mav (mentor) Modified: stable/11/sbin/dhclient/dispatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dhclient/dispatch.c ============================================================================== --- stable/11/sbin/dhclient/dispatch.c Wed Jul 18 00:56:25 2018 (r336439) +++ stable/11/sbin/dhclient/dispatch.c Wed Jul 18 01:57:13 2018 (r336440) @@ -545,17 +545,29 @@ interface_set_mtu_priv(char *ifname, u_int16_t mtu) { struct ifreq ifr; int sock; + u_int16_t old_mtu; if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) error("Can't create socket"); memset(&ifr, 0, sizeof(ifr)); + old_mtu = 0; strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - ifr.ifr_mtu = mtu; - if (ioctl(sock, SIOCSIFMTU, &ifr) == -1) - warning("SIOCSIFMTU failed (%d): %s", mtu, + if (ioctl(sock, SIOCGIFMTU, (caddr_t)&ifr) == -1) + warning("SIOCGIFMTU failed (%s): %s", ifname, strerror(errno)); + else + old_mtu = ifr.ifr_mtu; + + if (mtu != old_mtu) { + ifr.ifr_mtu = mtu; + + if (ioctl(sock, SIOCSIFMTU, &ifr) == -1) + warning("SIOCSIFMTU failed (%d): %s", mtu, + strerror(errno)); + } + close(sock); } From owner-svn-src-stable-11@freebsd.org Wed Jul 18 09:54: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 1E61F1041E24; Wed, 18 Jul 2018 09:54: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 C59F672616; Wed, 18 Jul 2018 09:54:33 +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 A6E1918A59; Wed, 18 Jul 2018 09:54:33 +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 w6I9sXvQ076532; Wed, 18 Jul 2018 09:54:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6I9sWWd076529; Wed, 18 Jul 2018 09:54:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201807180954.w6I9sWWd076529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 18 Jul 2018 09:54:32 +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: r336449 - in stable/11: include lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11: include lib/libc/gen X-SVN-Commit-Revision: 336449 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.27 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, 18 Jul 2018 09:54:34 -0000 Author: kib Date: Wed Jul 18 09:54:32 2018 New Revision: 336449 URL: https://svnweb.freebsd.org/changeset/base/336449 Log: MFC r335939, r336088: Add setproctitle_fast(3) for frequent callers. Modified: stable/11/include/unistd.h stable/11/lib/libc/gen/Symbol.map stable/11/lib/libc/gen/setproctitle.3 stable/11/lib/libc/gen/setproctitle.c Directory Properties: stable/11/ (props changed) Modified: stable/11/include/unistd.h ============================================================================== --- stable/11/include/unistd.h Wed Jul 18 09:32:43 2018 (r336448) +++ stable/11/include/unistd.h Wed Jul 18 09:54:32 2018 (r336449) @@ -569,6 +569,7 @@ int setloginclass(const char *); void *setmode(const char *); int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */ void setproctitle(const char *_fmt, ...) __printf0like(1, 2); +void setproctitle_fast(const char *_fmt, ...) __printf0like(1, 2); int setresgid(gid_t, gid_t, gid_t); int setresuid(uid_t, uid_t, uid_t); int setrgid(gid_t); Modified: stable/11/lib/libc/gen/Symbol.map ============================================================================== --- stable/11/lib/libc/gen/Symbol.map Wed Jul 18 09:32:43 2018 (r336448) +++ stable/11/lib/libc/gen/Symbol.map Wed Jul 18 09:54:32 2018 (r336449) @@ -420,6 +420,7 @@ FBSD_1.4 { FBSD_1.5 { sem_clockwait_np; + setproctitle_fast; }; FBSDprivate_1.0 { Modified: stable/11/lib/libc/gen/setproctitle.3 ============================================================================== --- stable/11/lib/libc/gen/setproctitle.3 Wed Jul 18 09:32:43 2018 (r336448) +++ stable/11/lib/libc/gen/setproctitle.3 Wed Jul 18 09:54:32 2018 (r336449) @@ -20,7 +20,7 @@ .\" $FreeBSD$ .\" .\" The following requests are required for all man pages. -.Dd December 16, 1995 +.Dd July 4, 2018 .Dt SETPROCTITLE 3 .Os .Sh NAME @@ -31,12 +31,20 @@ .In unistd.h .Ft void .Fn setproctitle "const char *fmt" "..." +.Ft void +.Fn setproctitle_fast "const char *fmt" "..." .Sh DESCRIPTION The .Fn setproctitle library routine sets the process title that appears on the .Xr ps 1 command. +The +.Fn setproctitle_fast +variant is optimized for high frequency updates, but may make the +.Xr ps 1 +command slightly slower by not updating the kernel cache of the program +arguments. .Pp The title is set from the executable's name, followed by the result of a @@ -96,6 +104,10 @@ The function first appeared in .Fx 2.2 . +The +.Fn setproctitle_fast +function first appeared in +.Fx 12 . Other operating systems have similar functions. .Sh AUTHORS Modified: stable/11/lib/libc/gen/setproctitle.c ============================================================================== --- stable/11/lib/libc/gen/setproctitle.c Wed Jul 18 09:32:43 2018 (r336448) +++ stable/11/lib/libc/gen/setproctitle.c Wed Jul 18 09:54:32 2018 (r336449) @@ -55,8 +55,8 @@ struct old_ps_strings { #define SPT_BUFSIZE 2048 /* from other parts of sendmail */ -void -setproctitle(const char *fmt, ...) +static char * +setproctitle_internal(const char *fmt, va_list ap) { static struct ps_strings *ps_strings; static char *buf = NULL; @@ -67,27 +67,23 @@ setproctitle(const char *fmt, ...) char **nargvp; int nargc; int i; - va_list ap; size_t len; unsigned long ul_ps_strings; - int oid[4]; if (buf == NULL) { buf = malloc(SPT_BUFSIZE); if (buf == NULL) - return; + return (NULL); nargv[0] = buf; } if (obuf == NULL ) { obuf = malloc(SPT_BUFSIZE); if (obuf == NULL) - return; + return (NULL); *obuf = '\0'; } - va_start(ap, fmt); - if (fmt) { buf[SPT_BUFSIZE - 1] = '\0'; @@ -114,22 +110,13 @@ setproctitle(const char *fmt, ...) kbuf = obuf; } else /* Nothing to restore */ - return; + return (NULL); - va_end(ap); - - /* Set the title into the kernel cached command line */ - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1); - if (ps_strings == NULL) { len = sizeof(ul_ps_strings); if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, 0) == -1) - return; + return (NULL); ps_strings = (struct ps_strings *)ul_ps_strings; } @@ -138,7 +125,7 @@ setproctitle(const char *fmt, ...) * Should not happen. */ if (ps_strings->ps_argvstr == NULL) - return; + return (NULL); /* style #3 */ if (oargc == -1) { @@ -167,4 +154,52 @@ setproctitle(const char *fmt, ...) } ps_strings->ps_nargvstr = nargc; ps_strings->ps_argvstr = nargvp; + + return (nargvp[0]); +} + +static int fast_update = 0; + +void +setproctitle_fast(const char *fmt, ...) +{ + va_list ap; + char *buf; + int oid[4]; + + va_start(ap, fmt); + buf = setproctitle_internal(fmt, ap); + va_end(ap); + + if (buf && !fast_update) { + /* Tell the kernel to start looking in user-space */ + oid[0] = CTL_KERN; + oid[1] = KERN_PROC; + oid[2] = KERN_PROC_ARGS; + oid[3] = getpid(); + sysctl(oid, 4, 0, 0, "", 0); + fast_update = 1; + } +} + +void +setproctitle(const char *fmt, ...) +{ + va_list ap; + char *buf; + int oid[4]; + + va_start(ap, fmt); + buf = setproctitle_internal(fmt, ap); + va_end(ap); + + if (buf != NULL) { + /* Set the title into the kernel cached command line */ + oid[0] = CTL_KERN; + oid[1] = KERN_PROC; + oid[2] = KERN_PROC_ARGS; + oid[3] = getpid(); + sysctl(oid, 4, 0, 0, buf, strlen(buf) + 1); + fast_update = 0; + } } From owner-svn-src-stable-11@freebsd.org Thu Jul 19 07:30:19 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 DEAB6104E34D; Thu, 19 Jul 2018 07:30:19 +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 8824681F50; Thu, 19 Jul 2018 07:30:19 +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 66AEB2608C; Thu, 19 Jul 2018 07:30:19 +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 w6J7UJqM042327; Thu, 19 Jul 2018 07:30:19 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6J7UJrx042326; Thu, 19 Jul 2018 07:30:19 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201807190730.w6J7UJrx042326@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 19 Jul 2018 07:30: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: r336468 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 336468 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.27 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, 19 Jul 2018 07:30:20 -0000 Author: ae Date: Thu Jul 19 07:30:18 2018 New Revision: 336468 URL: https://svnweb.freebsd.org/changeset/base/336468 Log: MFC r336219: Use correct size when we are allocating array for skipto index. Also, there is no need to use M_ZERO for idxmap_back. It will be re-filled just after allocation in update_skipto_cache(). PR: 229665 Modified: stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Thu Jul 19 04:31:41 2018 (r336467) +++ stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Thu Jul 19 07:30:18 2018 (r336468) @@ -299,10 +299,8 @@ ipfw_init_skipto_cache(struct ip_fw_chain *chain) { int *idxmap, *idxmap_back; - idxmap = malloc(65536 * sizeof(uint32_t *), M_IPFW, - M_WAITOK | M_ZERO); - idxmap_back = malloc(65536 * sizeof(uint32_t *), M_IPFW, - M_WAITOK | M_ZERO); + idxmap = malloc(65536 * sizeof(int), M_IPFW, M_WAITOK | M_ZERO); + idxmap_back = malloc(65536 * sizeof(int), M_IPFW, M_WAITOK); /* * Note we may be called at any time after initialization, From owner-svn-src-stable-11@freebsd.org Thu Jul 19 20:59: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 C309A104AC00; Thu, 19 Jul 2018 20:59:00 +0000 (UTC) (envelope-from rmacklem@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 747277C0AA; Thu, 19 Jul 2018 20:59:00 +0000 (UTC) (envelope-from rmacklem@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 552DC2E6D5; Thu, 19 Jul 2018 20:59:00 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6JKx0pO062347; Thu, 19 Jul 2018 20:59:00 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JKx0V4062346; Thu, 19 Jul 2018 20:59:00 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807192059.w6JKx0V4062346@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 19 Jul 2018 20:59: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: r336516 - stable/11/sys/fs/nfsserver X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sys/fs/nfsserver X-SVN-Commit-Revision: 336516 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.27 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, 19 Jul 2018 20:59:00 -0000 Author: rmacklem Date: Thu Jul 19 20:58:59 2018 New Revision: 336516 URL: https://svnweb.freebsd.org/changeset/base/336516 Log: MFC: r333766 Add a missing nfsrv_freesession() call for an unlikely failure case. Since NFSv4.1 clients normally create a single session which supports both fore and back channels, it is unlikely that a callback will fail due to a lack of a back channel. However, if this failure occurred, the session wasn't being dereferenced and would never be free'd. Found by inspection during pNFS server development. Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Thu Jul 19 20:23:27 2018 (r336515) +++ stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Thu Jul 19 20:58:59 2018 (r336516) @@ -4254,9 +4254,10 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, */ (void) newnfs_sndlock(&clp->lc_req.nr_lock); if (clp->lc_req.nr_client == NULL) { - if ((clp->lc_flags & LCL_NFSV41) != 0) + if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; - else if (nd->nd_procnum == NFSV4PROC_CBNULL) + nfsrv_freesession(sep, NULL); + } else if (nd->nd_procnum == NFSV4PROC_CBNULL) error = newnfs_connect(NULL, &clp->lc_req, cred, NULL, 1); else From owner-svn-src-stable-11@freebsd.org Thu Jul 19 22:45:15 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 EACE1104EA5A; Thu, 19 Jul 2018 22:45:14 +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 8D0BA80314; Thu, 19 Jul 2018 22:45:14 +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 691932F873; Thu, 19 Jul 2018 22:45:14 +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 w6JMjErw018923; Thu, 19 Jul 2018 22:45:14 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JMjE5l018922; Thu, 19 Jul 2018 22:45:14 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807192245.w6JMjE5l018922@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Jul 2018 22:45:14 +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: r336521 - stable/11/contrib/elftoolchain/elfcopy X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 336521 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.27 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, 19 Jul 2018 22:45:15 -0000 Author: markj Date: Thu Jul 19 22:45:13 2018 New Revision: 336521 URL: https://svnweb.freebsd.org/changeset/base/336521 Log: MFC r336226: Pass the right sizes to malloc() and realloc(). Modified: stable/11/contrib/elftoolchain/elfcopy/sections.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- stable/11/contrib/elftoolchain/elfcopy/sections.c Thu Jul 19 21:59:52 2018 (r336520) +++ stable/11/contrib/elftoolchain/elfcopy/sections.c Thu Jul 19 22:45:13 2018 (r336521) @@ -716,13 +716,13 @@ filter_reloc(struct elfcopy *ecp, struct section *s) #define COPYREL(REL, SZ) do { \ if (nrels == 0) { \ if ((REL##SZ = malloc(cap * \ - sizeof(Elf##SZ##_Rel))) == NULL) \ + sizeof(*REL##SZ))) == NULL) \ err(EXIT_FAILURE, "malloc failed"); \ } \ if (nrels >= cap) { \ cap *= 2; \ if ((REL##SZ = realloc(REL##SZ, cap * \ - sizeof(Elf##SZ##_Rel))) == NULL) \ + sizeof(*REL##SZ))) == NULL) \ err(EXIT_FAILURE, "realloc failed"); \ } \ REL##SZ[nrels].r_offset = REL.r_offset; \ From owner-svn-src-stable-11@freebsd.org Thu Jul 19 22:45:50 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 35AE4104EAEE; Thu, 19 Jul 2018 22:45:50 +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 DC97E80453; Thu, 19 Jul 2018 22:45:49 +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 BD4092F874; Thu, 19 Jul 2018 22:45:49 +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 w6JMjnNX019001; Thu, 19 Jul 2018 22:45:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JMjnSY018999; Thu, 19 Jul 2018 22:45:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807192245.w6JMjnSY018999@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Jul 2018 22:45:49 +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: r336522 - in stable/11/sys/dev: ahci usb/controller X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11/sys/dev: ahci usb/controller X-SVN-Commit-Revision: 336522 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.27 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, 19 Jul 2018 22:45:50 -0000 Author: markj Date: Thu Jul 19 22:45:49 2018 New Revision: 336522 URL: https://svnweb.freebsd.org/changeset/base/336522 Log: MFC r336225: Add PCI IDs for AMD X370 AHCI and XHCI. Modified: stable/11/sys/dev/ahci/ahci_pci.c stable/11/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ahci/ahci_pci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci_pci.c Thu Jul 19 22:45:13 2018 (r336521) +++ stable/11/sys/dev/ahci/ahci_pci.c Thu Jul 19 22:45:49 2018 (r336522) @@ -69,7 +69,8 @@ static const struct { /* Not sure SB8x0/SB9x0 needs this quirk. Be conservative though */ {0x43951002, 0x00, "AMD SB8x0/SB9x0", AHCI_Q_ATI_PMP_BUG}, {0x43b61022, 0x00, "AMD X399", 0}, - {0x43b71022, 0x00, "AMD 300 Series", 0}, + {0x43b51022, 0x00, "AMD 300 Series", 0}, /* X370 */ + {0x43b71022, 0x00, "AMD 300 Series", 0}, /* B350 */ {0x78001022, 0x00, "AMD Hudson-2", 0}, {0x78011022, 0x00, "AMD Hudson-2", 0}, {0x78021022, 0x00, "AMD Hudson-2", 0}, Modified: stable/11/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/11/sys/dev/usb/controller/xhci_pci.c Thu Jul 19 22:45:13 2018 (r336521) +++ stable/11/sys/dev/usb/controller/xhci_pci.c Thu Jul 19 22:45:49 2018 (r336522) @@ -99,7 +99,8 @@ xhci_pci_match(device_t self) return ("AMD KERNCZ USB 3.0 controller"); case 0x43ba1022: return ("AMD X399 USB 3.0 controller"); - case 0x43bb1022: + case 0x43b91022: /* X370 */ + case 0x43bb1022: /* B350 */ return ("AMD 300 Series USB 3.0 controller"); case 0x78141022: return ("AMD FCH USB 3.0 controller"); From owner-svn-src-stable-11@freebsd.org Thu Jul 19 22:53:24 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 DF882104F189; Thu, 19 Jul 2018 22:53:23 +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 9022C809D9; Thu, 19 Jul 2018 22:53:23 +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 71CF82FA0B; Thu, 19 Jul 2018 22:53:23 +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 w6JMrN1Q023971; Thu, 19 Jul 2018 22:53:23 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JMrNZn023970; Thu, 19 Jul 2018 22:53:23 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807192253.w6JMrNZn023970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 19 Jul 2018 22:53: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: r336523 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 336523 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.27 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, 19 Jul 2018 22:53:24 -0000 Author: markj Date: Thu Jul 19 22:53:23 2018 New Revision: 336523 URL: https://svnweb.freebsd.org/changeset/base/336523 Log: MFC r335784, r335971: Invalidate the mapping before updating its physical address. Modified: stable/11/sys/amd64/amd64/pmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Thu Jul 19 22:45:49 2018 (r336522) +++ stable/11/sys/amd64/amd64/pmap.c Thu Jul 19 22:53:23 2018 (r336523) @@ -4772,6 +4772,7 @@ retry: panic("pmap_enter: invalid page directory va=%#lx", va); origpte = *pte; + pv = NULL; /* * Is the specified virtual address already mapped? @@ -4813,6 +4814,45 @@ retry: goto unchanged; goto validate; } + + /* + * The physical page has changed. Temporarily invalidate + * the mapping. This ensures that all threads sharing the + * pmap keep a consistent view of the mapping, which is + * necessary for the correct handling of COW faults. It + * also permits reuse of the old mapping's PV entry, + * avoiding an allocation. + * + * For consistency, handle unmanaged mappings the same way. + */ + origpte = pte_load_clear(pte); + KASSERT((origpte & PG_FRAME) == opa, + ("pmap_enter: unexpected pa update for %#lx", va)); + if ((origpte & PG_MANAGED) != 0) { + om = PHYS_TO_VM_PAGE(opa); + + /* + * The pmap lock is sufficient to synchronize with + * concurrent calls to pmap_page_test_mappings() and + * pmap_ts_referenced(). + */ + if ((origpte & (PG_M | PG_RW)) == (PG_M | PG_RW)) + vm_page_dirty(om); + if ((origpte & PG_A) != 0) + vm_page_aflag_set(om, PGA_REFERENCED); + CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, opa); + pv = pmap_pvh_remove(&om->md, pmap, va); + if ((newpte & PG_MANAGED) == 0) + free_pv_entry(pmap, pv); + if ((om->aflags & PGA_WRITEABLE) != 0 && + TAILQ_EMPTY(&om->md.pv_list) && + ((om->flags & PG_FICTITIOUS) != 0 || + TAILQ_EMPTY(&pa_to_pvh(opa)->pv_list))) + vm_page_aflag_clear(om, PGA_WRITEABLE); + } + if ((origpte & PG_A) != 0) + pmap_invalidate_page(pmap, va); + origpte = 0; } else { /* * Increment the counters. @@ -4826,8 +4866,10 @@ retry: * Enter on the PV list if part of our managed memory. */ if ((newpte & PG_MANAGED) != 0) { - pv = get_pv_entry(pmap, &lock); - pv->pv_va = va; + if (pv == NULL) { + pv = get_pv_entry(pmap, &lock); + pv->pv_va = va; + } CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, pa); TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next); m->md.pv_gen++; @@ -4841,25 +4883,10 @@ retry: if ((origpte & PG_V) != 0) { validate: origpte = pte_load_store(pte, newpte); - opa = origpte & PG_FRAME; - if (opa != pa) { - if ((origpte & PG_MANAGED) != 0) { - om = PHYS_TO_VM_PAGE(opa); - if ((origpte & (PG_M | PG_RW)) == (PG_M | - PG_RW)) - vm_page_dirty(om); - if ((origpte & PG_A) != 0) - vm_page_aflag_set(om, PGA_REFERENCED); - CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, opa); - pmap_pvh_free(&om->md, pmap, va); - if ((om->aflags & PGA_WRITEABLE) != 0 && - TAILQ_EMPTY(&om->md.pv_list) && - ((om->flags & PG_FICTITIOUS) != 0 || - TAILQ_EMPTY(&pa_to_pvh(opa)->pv_list))) - vm_page_aflag_clear(om, PGA_WRITEABLE); - } - } else if ((newpte & PG_M) == 0 && (origpte & (PG_M | - PG_RW)) == (PG_M | PG_RW)) { + KASSERT((origpte & PG_FRAME) == pa, + ("pmap_enter: unexpected pa update for %#lx", va)); + if ((newpte & PG_M) == 0 && (origpte & (PG_M | PG_RW)) == + (PG_M | PG_RW)) { if ((origpte & PG_MANAGED) != 0) vm_page_dirty(m); From owner-svn-src-stable-11@freebsd.org Fri Jul 20 15:31: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 97FFF1049564; Fri, 20 Jul 2018 15:31:52 +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 48DAC81272; Fri, 20 Jul 2018 15:31:52 +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 2A0BA12016; Fri, 20 Jul 2018 15:31:52 +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 w6KFVphZ034253; Fri, 20 Jul 2018 15:31:51 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6KFVpTo034252; Fri, 20 Jul 2018 15:31:51 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201807201531.w6KFVpTo034252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 20 Jul 2018 15:31: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: r336550 - 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: 336550 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.27 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, 20 Jul 2018 15:31:52 -0000 Author: markj Date: Fri Jul 20 15:31:51 2018 New Revision: 336550 URL: https://svnweb.freebsd.org/changeset/base/336550 Log: MFC r336417: Add a FALLTHROUGH comment to kvprintf(). Modified: stable/11/sys/kern/subr_prf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/subr_prf.c ============================================================================== --- stable/11/sys/kern/subr_prf.c Fri Jul 20 14:32:36 2018 (r336549) +++ stable/11/sys/kern/subr_prf.c Fri Jul 20 15:31:51 2018 (r336550) @@ -710,6 +710,7 @@ reswitch: switch (ch = (u_char)*fmt++) { padc = '0'; goto reswitch; } + /* FALLTHROUGH */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': for (n = 0;; ++fmt) { From owner-svn-src-stable-11@freebsd.org Sat Jul 21 07:00: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 A9294103DE0F; Sat, 21 Jul 2018 07:00:22 +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 555167F36E; Sat, 21 Jul 2018 07:00:22 +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 33A021BA5B; Sat, 21 Jul 2018 07:00:22 +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 w6L70MrC009577; Sat, 21 Jul 2018 07:00:22 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6L70Mwc009576; Sat, 21 Jul 2018 07:00:22 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201807210700.w6L70Mwc009576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 21 Jul 2018 07:00:22 +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: r336575 - 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: 336575 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.27 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, 21 Jul 2018 07:00:22 -0000 Author: kp Date: Sat Jul 21 07:00:21 2018 New Revision: 336575 URL: https://svnweb.freebsd.org/changeset/base/336575 Log: MFC r336275: pf: Fix synproxy Synproxy was accidentally broken by r335569. The 'return (action)' must be executed for every non-PF_PASS result, but the error packet (TCP RST or ICMP error) should only be sent if the packet was dropped (i.e. PF_DROP) and the return flag is set. PR: 229477 Submitted by: Andre Albsmeier 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 Jul 21 02:14:13 2018 (r336574) +++ stable/11/sys/netpfil/pf/pf.c Sat Jul 21 07:00:21 2018 (r336575) @@ -3544,9 +3544,11 @@ pf_test_rule(struct pf_rule **rm, struct pf_state **sm action = pf_create_state(r, nr, a, pd, nsn, nk, sk, m, off, sport, dport, &rewrite, kif, sm, tag, bproto_sum, bip_sum, hdrlen); - if (action != PF_PASS && r->rule_flag & PFRULE_RETURN) { - pf_return(r, nr, pd, sk, off, m, th, kif, - bproto_sum, bip_sum, hdrlen, &reason); + if (action != PF_PASS) { + if (action == PF_DROP && + (r->rule_flag & PFRULE_RETURN)) + pf_return(r, nr, pd, sk, off, m, th, kif, + bproto_sum, bip_sum, hdrlen, &reason); return (action); } } else { From owner-svn-src-stable-11@freebsd.org Sat Jul 21 07:50:47 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 F1FEC103F8E2; Sat, 21 Jul 2018 07:50:46 +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 9F4E180827; Sat, 21 Jul 2018 07:50:46 +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 807CC1C36F; Sat, 21 Jul 2018 07:50:46 +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 w6L7okEo034829; Sat, 21 Jul 2018 07:50:46 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6L7okot034828; Sat, 21 Jul 2018 07:50:46 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201807210750.w6L7okot034828@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sat, 21 Jul 2018 07:50:46 +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: r336576 - 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: 336576 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.27 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, 21 Jul 2018 07:50:47 -0000 Author: kp Date: Sat Jul 21 07:50:46 2018 New Revision: 336576 URL: https://svnweb.freebsd.org/changeset/base/336576 Log: MFC r336273: pf: Fix panic on vnet jail shutdown with synproxy When shutting down a vnet jail pf_shutdown() clears the remaining states, which through pf_clear_states() calls pf_unlink_state(). For synproxy states pf_unlink_state() will send a TCP RST, which eventually tries to schedule the pf swi in pf_send(). This means we can't remove the software interrupt until after pf_shutdown(). Modified: stable/11/sys/netpfil/pf/pf_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- stable/11/sys/netpfil/pf/pf_ioctl.c Sat Jul 21 07:00:21 2018 (r336575) +++ stable/11/sys/netpfil/pf/pf_ioctl.c Sat Jul 21 07:50:46 2018 (r336576) @@ -3938,7 +3938,6 @@ pf_unload_vnet(void) V_pf_vnet_active = 0; V_pf_status.running = 0; - swi_remove(V_pf_swi_cookie); error = dehook_pf(); if (error) { /* @@ -3955,6 +3954,8 @@ pf_unload_vnet(void) PF_RULES_WLOCK(); shutdown_pf(); PF_RULES_WUNLOCK(); + + swi_remove(V_pf_swi_cookie); pf_normalize_cleanup(); PF_RULES_WLOCK(); From owner-svn-src-stable-11@freebsd.org Sat Jul 21 20:52: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 776BB102C7D5 for ; Sat, 21 Jul 2018 20:52:22 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-yw0-x241.google.com (mail-yw0-x241.google.com [IPv6:2607:f8b0:4002:c05::241]) (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 088C277882 for ; Sat, 21 Jul 2018 20:52:22 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-yw0-x241.google.com with SMTP id e23-v6so5557798ywe.13 for ; Sat, 21 Jul 2018 13:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gqpyzY8mWQgJNuFZZNGf4JED9QJ+/qWBA8s4LD3wYps=; b=V4WgMuZP0rzKzplql54lHXxrzDPsJDrSp3dHM3OPA2oxVOX4a3CE3ltdsiV5nfXvey eznkSyIac4DYxBZ5rJeZLMN/f3KBoTYq8WCFwwMAMt7Lrk7M98WSbXRbA5UHxEmukDJ+ fCqylfUKd7JZFF9E0k64WrMaZvIh32rf1P4iEPZzDD9e8s3p0bDmaxR6ftAehabr9yuI bJ5fkDuMgfq5B1wzTrxFytrkmXNQLv0yxyBJ0FF5prbT2f8Ii06FcuvzVoTXpp2DYX/n nz/kE8xrYwRbHLbmeUeGmz04onRXEXJhEKUV/eI39+9MZ9iodbLS45lt7JF+13dU00FQ kYtg== 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=gqpyzY8mWQgJNuFZZNGf4JED9QJ+/qWBA8s4LD3wYps=; b=kRp/6K5gOo4sd/OW2i9REFHJdiArJzPoqqPBwsw16unHwgJo74+L23EMG7wQScM7sW tZ5xBUUhn3e/OF0BgdMJdChvppI4fgy3mHnI8kIkFWPeYTIUc928UbOLu5RUTMJPbXFW PYzc67i57KjKNV7Gv3ZP3qV+OgLKajkhK5O8/zQg52qB9bjJfyJujfcBjywoAcEakzuf XRNa6k3L/KQkH3hpsy5qB3dN6ZLIPB2EAiaCXb0f7SjSu6wbrrqBmcjMCWkVgtFe56pZ WGs/apAY2NVzcssfLBvS4FGr2dI73MsU3LtH8SessRPTezDFKvqeFzt/83znm04QymP/ oROw== X-Gm-Message-State: AOUpUlFj47g7AEV0yRp4tFlKX7ThavRn0DXltMSp6vSb6TG+K0hYNA5R UCu+9r24XOWsuxACZ8+5qRW1lmXRe2i3xFxWs1wTOQA+h5I= X-Google-Smtp-Source: AAOMgpd2HDzxQZYhmfCdHOxFMG0L101IB2CbBiH6ko6oyEq/qZoVhl+3uRcX/Tm8QPBIsORF3lhLvVSVu9JR3irx7ac= X-Received: by 2002:a81:5f56:: with SMTP id t83-v6mr3599140ywb.382.1532206341419; Sat, 21 Jul 2018 13:52:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:b90:0:0:0:0:0 with HTTP; Sat, 21 Jul 2018 13:52:20 -0700 (PDT) In-Reply-To: <201807161502.w6GF2LXw050533@repo.freebsd.org> References: <201807161502.w6GF2LXw050533@repo.freebsd.org> From: Oliver Pinter Date: Sat, 21 Jul 2018 22:52:20 +0200 Message-ID: Subject: Re: svn commit: r336346 - in stable/11: lib/libmd lib/libnv/tests share/man/man9 sys/contrib/libnv sys/sys To: Kyle Evans Cc: src-committers@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.27 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, 21 Jul 2018 20:52:22 -0000 On 7/16/18, Kyle Evans wrote: > Author: kevans > Date: Mon Jul 16 15:02:21 2018 > New Revision: 336346 > URL: https://svnweb.freebsd.org/changeset/base/336346 > > Log: > MFC r304910, r304912, r304915, r304952, r325019, r328164, r331094, > r332664, > r335341-r335345, r335347, r335379-r335380, r335382 > > r304910: > Introduce cnv man page. > > r304912: > Add missed header file for cnv.h . > > r304915: > Bump date in the man page. > > r304952: > Remove duplicated declaration. > > r325019: > Introduce cnvlist_name() and cnvlist_type() functions. > > Those function can be used when we are iterating over nvlist to reduce > amount of extra variables we need to declare. > > r328164: > libnv: Use mallocarray(9) for the nv_calloc. > > r331094: > Fix formatting errors that resulted in apropos(1) output looking weird. > > r332664: > Add missing argument in the cnv man page. > > r335341: > libnv: change name of cookie from cookiep to cookie. > > The name was inconsistent with rest of the library. > No functional change intended. > > r335342: > libnv: add const to cookies arguments > > r335343: > libnv: Remove nvlist argument from cnvlist_{take,free}_* functions. > > All information which are need for those operations is already stored in > the cookie. > > We decided not to bump libnv version because this API is not used yet in > the > base system. > > r335344: > libnv: clean parent in nvlist_array when removing it. > > When we are removing element form the nvlist we should also clean parent, > because the array is not a part of the nvlist anymore. > > r335345: > libnv: add regression test for r335344. > > r335347: > libnv: Add nvlist_append_*_array() family of functions. > > The nvlist_append_{bool,number,string,nvlist,descriptor}_array() > functions > allows to dynamically extend array stored in the nvlist. > > r335379: > Set prev to NULL so its garaunteed to have a value of some kind and > gcc doesn't explode. Feel free to fix this correctly or whatever for > gcc builds. > > This *should* quiesce tinderbox after r335347 for the gcc builds. > > r335380: > style(9) fix, I was also going to silence gcc. > > r335382: > Really fix the style. > > Added: > stable/11/lib/libnv/tests/nvlist_append_test.c > - copied unchanged from r335347, > head/lib/libnv/tests/nvlist_append_test.c > stable/11/share/man/man9/cnv.9 > - copied, changed from r304910, head/share/man/man9/cnv.9 > stable/11/sys/sys/cnv.h > - copied, changed from r304912, head/sys/sys/cnv.h > Modified: > stable/11/lib/libmd/sha512.3 > stable/11/lib/libnv/tests/Makefile > stable/11/lib/libnv/tests/cnv_tests.cc > stable/11/lib/libnv/tests/nv_array_tests.cc > stable/11/share/man/man9/Makefile > stable/11/share/man/man9/nv.9 > stable/11/share/man/man9/owll.9 > stable/11/share/man/man9/rwlock.9 > stable/11/share/man/man9/zone.9 > stable/11/sys/contrib/libnv/cnvlist.c > stable/11/sys/contrib/libnv/nv_impl.h > stable/11/sys/contrib/libnv/nvlist.c > stable/11/sys/contrib/libnv/nvpair.c > stable/11/sys/sys/nv.h > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/lib/libmd/sha512.3 > ============================================================================== > --- stable/11/lib/libmd/sha512.3 Mon Jul 16 14:56:30 2018 (r336345) > +++ stable/11/lib/libmd/sha512.3 Mon Jul 16 15:02:21 2018 (r336346) > @@ -26,7 +26,7 @@ > .Nm SHA384_End , > .Nm SHA384_File , > .Nm SHA384_FileChunk , > -.Nm SHA384_Data, > +.Nm SHA384_Data , > .Nm SHA512_256_Init , > .Nm SHA512_256_Update , > .Nm SHA512_256_Final , > Hi! This part of patch belongs to other commit. > Modified: stable/11/lib/libnv/tests/Makefile > trim