From owner-svn-src-stable-11@freebsd.org Sun Aug 13 13:14:06 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B544ADE0C40; Sun, 13 Aug 2017 13:14:06 +0000 (UTC) (envelope-from andre@fbsd.e4m.org) Received: from mail.g66.org (mail.g66.org [85.10.206.112]) by mx1.freebsd.org (Postfix) with ESMTP id 499096DE8A; Sun, 13 Aug 2017 13:14:05 +0000 (UTC) (envelope-from andre@fbsd.e4m.org) Received: from x55b58567.dyn.telefonica.de (x55b58567.dyn.telefonica.de [85.181.133.103]) (authenticated bits=128) by mail.g66.org (8.15.2/8.15.2) with ESMTPA id v7DDDCdF026994; Sun, 13 Aug 2017 15:13:13 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: from stationary.client ([192.168.128.2]) by gate.local (8.15.2/8.15.2) with ESMTP id v7DDDBPM005086; Sun, 13 Aug 2017 15:13:12 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: from submit.client ([127.0.0.1]) by voyager.local (8.15.2/8.15.2) with ESMTP id v7DDDBmX024496; Sun, 13 Aug 2017 15:13:11 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: (from user@localhost) by voyager.local (8.15.2/8.15.2/Submit) id v7DDDBwL024495; Sun, 13 Aug 2017 15:13:11 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Date: Sun, 13 Aug 2017 15:13:11 +0200 From: Andre Albsmeier To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org, andre@fbsd.e4m.org Subject: Re: svn commit: r322345 - stable/11/lib/libc/x86/sys Message-ID: <20170813131311.GA24473@voyager> References: <201708100900.v7A90FjI094474@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201708100900.v7A90FjI094474@repo.freebsd.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-Virus-Scanned: clamav-milter 0.99.2 at colo X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 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, 13 Aug 2017 13:14:06 -0000 On Thu, 10-Aug-2017 at 09:00:15 +0000, Konstantin Belousov wrote: > Author: kib > Date: Thu Aug 10 09:00:15 2017 > New Revision: 322345 > URL: https://svnweb.freebsd.org/changeset/base/322345 > > Log: > MFC r321608: > Use MFENCE to serialize RDTSC on non-Intel CPUs. This broke libc on my FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0) VT(vga): text 80x25 CPU: AMD-K6tm w/ multimedia extensions (199.44-MHz 586-class CPU) Origin="AuthenticAMD" Id=0x562 Family=0x5 Model=0x6 Stepping=2 Features=0x8001bf AMD Features=0x400<> On system start, it actually makes various programmes hang until Ctrl-C is pressed. Reboot is not possible (endlessly hanging with 'zillions of defunct processes). Going back to r322042 fixes it... -Andre > > Modified: > stable/11/lib/libc/x86/sys/__vdso_gettc.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/lib/libc/x86/sys/__vdso_gettc.c > ============================================================================== > --- stable/11/lib/libc/x86/sys/__vdso_gettc.c Thu Aug 10 06:59:43 2017 (r322344) > +++ stable/11/lib/libc/x86/sys/__vdso_gettc.c Thu Aug 10 09:00:15 2017 (r322345) > @@ -52,57 +52,108 @@ __FBSDID("$FreeBSD$"); > #endif > #include "libc_private.h" > > +static enum LMB { > + LMB_UNKNOWN, > + LMB_NONE, > + LMB_MFENCE, > + LMB_LFENCE > +} lfence_works = LMB_UNKNOWN; > + > static void > -lfence_mb(void) > +cpuidp(u_int leaf, u_int p[4]) > { > + > + __asm __volatile( > #if defined(__i386__) > - static int lfence_works = -1; > + " pushl %%ebx\n" > +#endif > + " cpuid\n" > +#if defined(__i386__) > + " movl %%ebx,%1\n" > + " popl %%ebx" > +#endif > + : "=a" (p[0]), > +#if defined(__i386__) > + "=r" (p[1]), > +#elif defined(__amd64__) > + "=b" (p[1]), > +#else > +#error "Arch" > +#endif > + "=c" (p[2]), "=d" (p[3]) > + : "0" (leaf)); > +} > + > +static enum LMB > +select_lmb(void) > +{ > + u_int p[4]; > + static const char intel_id[] = "GenuntelineI"; > + > + cpuidp(0, p); > + return (memcmp(p + 1, intel_id, sizeof(intel_id) - 1) == 0 ? > + LMB_LFENCE : LMB_MFENCE); > +} > + > +static void > +init_fence(void) > +{ > +#if defined(__i386__) > u_int cpuid_supported, p[4]; > > - if (lfence_works == -1) { > - __asm __volatile( > - " pushfl\n" > - " popl %%eax\n" > - " movl %%eax,%%ecx\n" > - " xorl $0x200000,%%eax\n" > - " pushl %%eax\n" > - " popfl\n" > - " pushfl\n" > - " popl %%eax\n" > - " xorl %%eax,%%ecx\n" > - " je 1f\n" > - " movl $1,%0\n" > - " jmp 2f\n" > - "1: movl $0,%0\n" > - "2:\n" > - : "=r" (cpuid_supported) : : "eax", "ecx", "cc"); > - if (cpuid_supported) { > - __asm __volatile( > - " pushl %%ebx\n" > - " cpuid\n" > - " movl %%ebx,%1\n" > - " popl %%ebx\n" > - : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3]) > - : "0" (0x1)); > - lfence_works = (p[3] & CPUID_SSE2) != 0; > - } else > - lfence_works = 0; > - } > - if (lfence_works == 1) > - lfence(); > + __asm __volatile( > + " pushfl\n" > + " popl %%eax\n" > + " movl %%eax,%%ecx\n" > + " xorl $0x200000,%%eax\n" > + " pushl %%eax\n" > + " popfl\n" > + " pushfl\n" > + " popl %%eax\n" > + " xorl %%eax,%%ecx\n" > + " je 1f\n" > + " movl $1,%0\n" > + " jmp 2f\n" > + "1: movl $0,%0\n" > + "2:\n" > + : "=r" (cpuid_supported) : : "eax", "ecx", "cc"); > + if (cpuid_supported) { > + cpuidp(0x1, p); > + if ((p[3] & CPUID_SSE2) != 0) > + lfence_works = select_lmb(); > + } else > + lfence_works = LMB_NONE; > #elif defined(__amd64__) > - lfence(); > + lfence_works = select_lmb(); > #else > -#error "arch" > +#error "Arch" > #endif > } > > +static void > +rdtsc_mb(void) > +{ > + > +again: > + if (__predict_true(lfence_works == LMB_LFENCE)) { > + lfence(); > + return; > + } else if (lfence_works == LMB_MFENCE) { > + mfence(); > + return; > + } else if (lfence_works == LMB_NONE) { > + return; > + } > + init_fence(); > + goto again; > +} > + > static u_int > __vdso_gettc_rdtsc_low(const struct vdso_timehands *th) > { > u_int rv; > > - lfence_mb(); > + rdtsc_mb(); > __asm __volatile("rdtsc; shrd %%cl, %%edx, %0" > : "=a" (rv) : "c" (th->th_x86_shift) : "edx"); > return (rv); > @@ -112,7 +163,7 @@ static u_int > __vdso_rdtsc32(void) > { > > - lfence_mb(); > + rdtsc_mb(); > return (rdtsc32()); > } > > @@ -211,7 +262,7 @@ __vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int > scale = tsc_ref->tsc_scale; > ofs = tsc_ref->tsc_ofs; > > - lfence_mb(); > + rdtsc_mb(); > tsc = rdtsc(); > > /* ret = ((tsc * scale) >> 64) + ofs */ > _______________________________________________ > svn-src-stable-11@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-stable-11 > To unsubscribe, send any mail to "svn-src-stable-11-unsubscribe@freebsd.org" -- Stuxnet? Find ich gut. Manche lernen nur auf die harte Tour... From owner-svn-src-stable-11@freebsd.org Sun Aug 13 13:38:16 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F4165DE21EA; Sun, 13 Aug 2017 13:38:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8799C6EB35; Sun, 13 Aug 2017 13:38:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v7DDbaFg067559 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 13 Aug 2017 16:37:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v7DDbaFg067559 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v7DDbagC067558; Sun, 13 Aug 2017 16:37:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 13 Aug 2017 16:37:36 +0300 From: Konstantin Belousov To: Andre Albsmeier Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r322345 - stable/11/lib/libc/x86/sys Message-ID: <20170813133736.GO1700@kib.kiev.ua> References: <201708100900.v7A90FjI094474@repo.freebsd.org> <20170813131311.GA24473@voyager> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170813131311.GA24473@voyager> User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 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, 13 Aug 2017 13:38:16 -0000 On Sun, Aug 13, 2017 at 03:13:11PM +0200, Andre Albsmeier wrote: > On Thu, 10-Aug-2017 at 09:00:15 +0000, Konstantin Belousov wrote: > > Author: kib > > Date: Thu Aug 10 09:00:15 2017 > > New Revision: 322345 > > URL: https://svnweb.freebsd.org/changeset/base/322345 > > > > Log: > > MFC r321608: > > Use MFENCE to serialize RDTSC on non-Intel CPUs. > > This broke libc on my > > FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0) > VT(vga): text 80x25 > CPU: AMD-K6tm w/ multimedia extensions (199.44-MHz 586-class CPU) > Origin="AuthenticAMD" Id=0x562 Family=0x5 Model=0x6 Stepping=2 > Features=0x8001bf > AMD Features=0x400<> > > On system start, it actually makes various programmes hang until > Ctrl-C is pressed. Reboot is not possible (endlessly hanging with > 'zillions of defunct processes). > > Going back to r322042 fixes it... Indeed code is broken on i386 machines which have CPUID but no SSE. Try this. diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c index 4ada5e7eac1..ef2ca69edf7 100644 --- a/lib/libc/x86/sys/__vdso_gettc.c +++ b/lib/libc/x86/sys/__vdso_gettc.c @@ -101,6 +101,7 @@ init_fence(void) #if defined(__i386__) u_int cpuid_supported, p[4]; + lfence_works = LMB_NONE; __asm __volatile( " pushfl\n" " popl %%eax\n" @@ -121,8 +122,7 @@ init_fence(void) cpuidp(0x1, p); if ((p[3] & CPUID_SSE2) != 0) lfence_works = select_lmb(); - } else - lfence_works = LMB_NONE; + } #elif defined(__amd64__) lfence_works = select_lmb(); #else From owner-svn-src-stable-11@freebsd.org Sun Aug 13 13:54:45 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99C16D93389; Sun, 13 Aug 2017 13:54:45 +0000 (UTC) (envelope-from andre@fbsd.e4m.org) Received: from mail.g66.org (mail.g66.org [85.10.206.112]) by mx1.freebsd.org (Postfix) with ESMTP id 1904D6F89F; Sun, 13 Aug 2017 13:54:44 +0000 (UTC) (envelope-from andre@fbsd.e4m.org) Received: from x55b58567.dyn.telefonica.de (x55b58567.dyn.telefonica.de [85.181.133.103]) (authenticated bits=128) by mail.g66.org (8.15.2/8.15.2) with ESMTPA id v7DDsglA027313; Sun, 13 Aug 2017 15:54:43 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: from stationary.client ([192.168.128.2]) by gate.local (8.15.2/8.15.2) with ESMTP id v7DDsgHi006730; Sun, 13 Aug 2017 15:54:42 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: from submit.client ([127.0.0.1]) by voyager.local (8.15.2/8.15.2) with ESMTP id v7DDsgWF028764; Sun, 13 Aug 2017 15:54:42 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Received: (from user@localhost) by voyager.local (8.15.2/8.15.2/Submit) id v7DDsgxp028763; Sun, 13 Aug 2017 15:54:42 +0200 (CEST) (envelope-from andre@fbsd.e4m.org) Date: Sun, 13 Aug 2017 15:54:42 +0200 From: Andre Albsmeier To: Konstantin Belousov Cc: Andre Albsmeier , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r322345 - stable/11/lib/libc/x86/sys Message-ID: <20170813135442.GA28728@voyager> References: <201708100900.v7A90FjI094474@repo.freebsd.org> <20170813131311.GA24473@voyager> <20170813133736.GO1700@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170813133736.GO1700@kib.kiev.ua> User-Agent: Mutt/1.7.2 (2016-11-26) X-Virus-Scanned: clamav-milter 0.99.2 at colo X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 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, 13 Aug 2017 13:54:45 -0000 On Sun, 13-Aug-2017 at 16:37:36 +0300, Konstantin Belousov wrote: > On Sun, Aug 13, 2017 at 03:13:11PM +0200, Andre Albsmeier wrote: > > On Thu, 10-Aug-2017 at 09:00:15 +0000, Konstantin Belousov wrote: > > > Author: kib > > > Date: Thu Aug 10 09:00:15 2017 > > > New Revision: 322345 > > > URL: https://svnweb.freebsd.org/changeset/base/322345 > > > > > > Log: > > > MFC r321608: > > > Use MFENCE to serialize RDTSC on non-Intel CPUs. > > > > This broke libc on my > > > > FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0) > > VT(vga): text 80x25 > > CPU: AMD-K6tm w/ multimedia extensions (199.44-MHz 586-class CPU) > > Origin="AuthenticAMD" Id=0x562 Family=0x5 Model=0x6 Stepping=2 > > Features=0x8001bf > > AMD Features=0x400<> > > > > On system start, it actually makes various programmes hang until > > Ctrl-C is pressed. Reboot is not possible (endlessly hanging with > > 'zillions of defunct processes). > > > > Going back to r322042 fixes it... > > Indeed code is broken on i386 machines which have CPUID but no SSE. Wonder how many of these still exist... > Try this. I just compiled and installed libc.so.7 with this patch on the machine in question and the test I used for hunting down the reason (ls -l /lib) was OK. I then rebooted the whole box and it looked good as well. I did not compile stuff which links libc statically and hung before (devd) but I am pretty sure this will be OK as well... Thanks, -Andre > > diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c > index 4ada5e7eac1..ef2ca69edf7 100644 > --- a/lib/libc/x86/sys/__vdso_gettc.c > +++ b/lib/libc/x86/sys/__vdso_gettc.c > @@ -101,6 +101,7 @@ init_fence(void) > #if defined(__i386__) > u_int cpuid_supported, p[4]; > > + lfence_works = LMB_NONE; > __asm __volatile( > " pushfl\n" > " popl %%eax\n" > @@ -121,8 +122,7 @@ init_fence(void) > cpuidp(0x1, p); > if ((p[3] & CPUID_SSE2) != 0) > lfence_works = select_lmb(); > - } else > - lfence_works = LMB_NONE; > + } > #elif defined(__amd64__) > lfence_works = select_lmb(); > #else -- My other computer is your windows box. From owner-svn-src-stable-11@freebsd.org Sun Aug 13 16:40:31 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B473DC9352; Sun, 13 Aug 2017 16:40:31 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id 1984A75853; Sun, 13 Aug 2017 16:40:31 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7DGeUr2057785; Sun, 13 Aug 2017 16:40:30 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7DGeUMi057784; Sun, 13 Aug 2017 16:40:30 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708131640.v7DGeUMi057784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 13 Aug 2017 16:40: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: r322460 - stable/11/sys/dev/uart X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/dev/uart X-SVN-Commit-Revision: 322460 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.23 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, 13 Aug 2017 16:40:31 -0000 Author: emaste Date: Sun Aug 13 16:40:29 2017 New Revision: 322460 URL: https://svnweb.freebsd.org/changeset/base/322460 Log: MFC r215837: uart: add AX99100 chipset support PR: 215837 Modified: stable/11/sys/dev/uart/uart_bus_pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/uart/uart_bus_pci.c ============================================================================== --- stable/11/sys/dev/uart/uart_bus_pci.c Sun Aug 13 16:39:49 2017 (r322459) +++ stable/11/sys/dev/uart/uart_bus_pci.c Sun Aug 13 16:40:29 2017 (r322460) @@ -86,6 +86,8 @@ static const struct pci_id pci_ns8250_ids[] = { { 0x103c, 0x3301, 0xffff, 0, "HP iLO serial port", 0x10 }, { 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 }, { 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 }, +{ 0x125b, 0x9100, 0xa000, 0x1000, + "ASIX AX99100 PCIe 1/2/3/4-port RS-232/422/485", 0x10 }, { 0x1282, 0x6585, 0xffff, 0, "Davicom 56PDV PCI Modem", 0x10 }, { 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 }, { 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 }, From owner-svn-src-stable-11@freebsd.org Sun Aug 13 16:44:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11CAADC99A5; Sun, 13 Aug 2017 16:44:57 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id E272675EEA; Sun, 13 Aug 2017 16:44:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7DGiu4O061729; Sun, 13 Aug 2017 16:44:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7DGiufm061728; Sun, 13 Aug 2017 16:44:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708131644.v7DGiufm061728@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 13 Aug 2017 16:44:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322461 - stable/11/usr.sbin/acpi/acpidump X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.sbin/acpi/acpidump X-SVN-Commit-Revision: 322461 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.23 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, 13 Aug 2017 16:44:57 -0000 Author: emaste Date: Sun Aug 13 16:44:55 2017 New Revision: 322461 URL: https://svnweb.freebsd.org/changeset/base/322461 Log: MFC r321298: acpidump: add ACPI NFIT (NVDIMM Firmware Interface Table) Also MFC r322351 by mav, add two NFIT fields missed in initial commit. Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 16:40:29 2017 (r322460) +++ stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 16:44:55 2017 (r322461) @@ -40,6 +40,7 @@ #include #include #include +#include #include "acpidump.h" @@ -70,6 +71,8 @@ static void acpi_print_srat_memory(ACPI_SRAT_MEM_AFFIN static void acpi_print_srat(ACPI_SUBTABLE_HEADER *srat); static void acpi_handle_srat(ACPI_TABLE_HEADER *sdp); static void acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp); +static void acpi_print_nfit(ACPI_NFIT_HEADER *nfit); +static void acpi_handle_nfit(ACPI_TABLE_HEADER *sdp); static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp); static void acpi_print_fadt(ACPI_TABLE_HEADER *sdp); static void acpi_print_facs(ACPI_TABLE_FACS *facs); @@ -79,6 +82,8 @@ static void acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp); static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp); static void acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, void (*action)(ACPI_SUBTABLE_HEADER *)); +static void acpi_walk_nfit(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_NFIT_HEADER *)); /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */ static int addr_size; @@ -277,6 +282,27 @@ acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *fi } static void +acpi_walk_nfit(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_NFIT_HEADER *)) +{ + ACPI_NFIT_HEADER *subtable; + char *end; + + subtable = first; + end = (char *)table + table->Length; + while ((char *)subtable < end) { + printf("\n"); + if (subtable->Length < sizeof(ACPI_NFIT_HEADER)) { + warnx("invalid subtable length %u", subtable->Length); + return; + } + action(subtable); + subtable = (ACPI_NFIT_HEADER *)((char *)subtable + + subtable->Length); + } +} + +static void acpi_print_cpu(u_char cpu_id) { @@ -1137,7 +1163,177 @@ acpi_handle_srat(ACPI_TABLE_HEADER *sdp) printf(END_COMMENT); } +static const char *nfit_types[] = { + [ACPI_NFIT_TYPE_SYSTEM_ADDRESS] = "System Address", + [ACPI_NFIT_TYPE_MEMORY_MAP] = "Memory Map", + [ACPI_NFIT_TYPE_INTERLEAVE] = "Interleave", + [ACPI_NFIT_TYPE_SMBIOS] = "SMBIOS", + [ACPI_NFIT_TYPE_CONTROL_REGION] = "Control Region", + [ACPI_NFIT_TYPE_DATA_REGION] = "Data Region", + [ACPI_NFIT_TYPE_FLUSH_ADDRESS] = "Flush Address" +}; + + static void +acpi_print_nfit(ACPI_NFIT_HEADER *nfit) +{ + char *uuidstr; + uint32_t status; + + ACPI_NFIT_SYSTEM_ADDRESS *sysaddr; + ACPI_NFIT_MEMORY_MAP *mmap; + ACPI_NFIT_INTERLEAVE *ileave; + ACPI_NFIT_SMBIOS *smbios; + ACPI_NFIT_CONTROL_REGION *ctlreg; + ACPI_NFIT_DATA_REGION *datareg; + ACPI_NFIT_FLUSH_ADDRESS *fladdr; + + if (nfit->Type < nitems(nfit_types)) + printf("\tType=%s\n", nfit_types[nfit->Type]); + else + printf("\tType=%u (unknown)\n", nfit->Type); + switch (nfit->Type) { + case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: + sysaddr = (ACPI_NFIT_SYSTEM_ADDRESS *)nfit; + printf("\tRangeIndex=%u\n", (u_int)sysaddr->RangeIndex); + printf("\tProximityDomain=%u\n", + (u_int)sysaddr->ProximityDomain); + uuid_to_string((uuid_t *)(sysaddr->RangeGuid), + &uuidstr, &status); + if (status != uuid_s_ok) + errx(1, "uuid_to_string: status=%u", status); + printf("\tRangeGuid=%s\n", uuidstr); + free(uuidstr); + printf("\tAddress=0x%016jx\n", (uintmax_t)sysaddr->Address); + printf("\tLength=0x%016jx\n", (uintmax_t)sysaddr->Length); + printf("\tMemoryMapping=0x%016jx\n", + (uintmax_t)sysaddr->MemoryMapping); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(sysaddr->Flags, ADD_ONLINE_ONLY); + PRINTFLAG(sysaddr->Flags, PROXIMITY_VALID); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_MEMORY_MAP: + mmap = (ACPI_NFIT_MEMORY_MAP *)nfit; + printf("\tDeviceHandle=%u\n", (u_int)mmap->DeviceHandle); + printf("\tPhysicalId=%u\n", (u_int)mmap->PhysicalId); + printf("\tRegionId=%u\n", (u_int)mmap->RegionId); + printf("\tRangeIndex=%u\n", (u_int)mmap->RangeIndex); + printf("\tRegionIndex=%u\n", (u_int)mmap->RegionIndex); + printf("\tRegionSize=0x%016jx\n", (uintmax_t)mmap->RegionSize); + printf("\tRegionOffset=0x%016jx\n", + (uintmax_t)mmap->RegionOffset); + printf("\tAddress=0x%016jx\n", (uintmax_t)mmap->Address); + printf("\tInterleaveIndex=%u\n", (u_int)mmap->InterleaveIndex); + printf("\tInterleaveWays=%u\n", (u_int)mmap->InterleaveWays); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_MEM_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(mmap->Flags, SAVE_FAILED); + PRINTFLAG(mmap->Flags, RESTORE_FAILED); + PRINTFLAG(mmap->Flags, FLUSH_FAILED); + PRINTFLAG(mmap->Flags, NOT_ARMED); + PRINTFLAG(mmap->Flags, HEALTH_OBSERVED); + PRINTFLAG(mmap->Flags, HEALTH_ENABLED); + PRINTFLAG(mmap->Flags, MAP_FAILED); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_INTERLEAVE: + ileave = (ACPI_NFIT_INTERLEAVE *)nfit; + printf("\tInterleaveIndex=%u\n", + (u_int)ileave->InterleaveIndex); + printf("\tLineCount=%u\n", (u_int)ileave->LineCount); + printf("\tLineSize=%u\n", (u_int)ileave->LineSize); + /* XXX ileave->LineOffset[i] output is not supported */ + break; + case ACPI_NFIT_TYPE_SMBIOS: + smbios = (ACPI_NFIT_SMBIOS *)nfit; + /* XXX smbios->Data[x] output is not supported */ + break; + case ACPI_NFIT_TYPE_CONTROL_REGION: + ctlreg = (ACPI_NFIT_CONTROL_REGION *)nfit; + printf("\tRegionIndex=%u\n", (u_int)ctlreg->RegionIndex); + printf("\tVendorId=0x%04x\n", (u_int)ctlreg->VendorId); + printf("\tDeviceId=0x%04x\n", (u_int)ctlreg->DeviceId); + printf("\tRevisionId=%u\n", (u_int)ctlreg->RevisionId); + printf("\tSubsystemVendorId=0x%04x\n", + (u_int)ctlreg->SubsystemVendorId); + printf("\tSubsystemDeviceId=0x%04x\n", + (u_int)ctlreg->SubsystemDeviceId); + printf("\tSubsystemRevisionId=%u\n", + (u_int)ctlreg->SubsystemRevisionId); + printf("\tValidFields=%u\n", (u_int)ctlreg->ValidFields); + printf("\tManufacturingLocation=%u\n", + (u_int)ctlreg->ManufacturingLocation); + printf("\tManufacturingDate=%u\n", + (u_int)ctlreg->ManufacturingDate); + printf("\tSerialNumber=%u\n", + (u_int)ctlreg->SerialNumber); + printf("\tCode=0x%04x\n", (u_int)ctlreg->Code); + printf("\tWindows=%u\n", (u_int)ctlreg->Windows); + printf("\tWindowSize=0x%016jx\n", + (uintmax_t)ctlreg->WindowSize); + printf("\tCommandOffset=0x%016jx\n", + (uintmax_t)ctlreg->CommandOffset); + printf("\tCommandSize=0x%016jx\n", + (uintmax_t)ctlreg->CommandSize); + printf("\tStatusOffset=0x%016jx\n", + (uintmax_t)ctlreg->StatusOffset); + printf("\tStatusSize=0x%016jx\n", + (uintmax_t)ctlreg->StatusSize); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(mmap->Flags, ADD_ONLINE_ONLY); + PRINTFLAG(mmap->Flags, PROXIMITY_VALID); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_DATA_REGION: + datareg = (ACPI_NFIT_DATA_REGION *)nfit; + printf("\tRegionIndex=%u\n", (u_int)datareg->RegionIndex); + printf("\tWindows=%u\n", (u_int)datareg->Windows); + printf("\tOffset=0x%016jx\n", (uintmax_t)datareg->Offset); + printf("\tSize=0x%016jx\n", (uintmax_t)datareg->Size); + printf("\tCapacity=0x%016jx\n", (uintmax_t)datareg->Capacity); + printf("\tStartAddress=0x%016jx\n", + (uintmax_t)datareg->StartAddress); + break; + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + fladdr = (ACPI_NFIT_FLUSH_ADDRESS *)nfit; + printf("\tDeviceHandle=%u\n", (u_int)fladdr->DeviceHandle); + printf("\tHintCount=%u\n", (u_int)fladdr->HintCount); + /* XXX fladdr->HintAddress[i] output is not supported */ + break; + } +} + +static void +acpi_handle_nfit(ACPI_TABLE_HEADER *sdp) +{ + ACPI_TABLE_NFIT *nfit; + + printf(BEGIN_COMMENT); + acpi_print_sdt(sdp); + nfit = (ACPI_TABLE_NFIT *)sdp; + acpi_walk_nfit(sdp, (nfit + 1), acpi_print_nfit); + printf(END_COMMENT); +} + +static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp) { printf(" "); @@ -1452,6 +1648,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) acpi_handle_tcpa(sdp); else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4)) acpi_handle_dmar(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) + acpi_handle_nfit(sdp); else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp); From owner-svn-src-stable-11@freebsd.org Sun Aug 13 18:12:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E26D1DCFCC2; Sun, 13 Aug 2017 18:12:57 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id AED737D26A; Sun, 13 Aug 2017 18:12:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7DICuGW098642; Sun, 13 Aug 2017 18:12:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7DICugT098641; Sun, 13 Aug 2017 18:12:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708131812.v7DICugT098641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 13 Aug 2017 18:12:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322466 - stable/11/usr.sbin/acpi/acpidump X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.sbin/acpi/acpidump X-SVN-Commit-Revision: 322466 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.23 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, 13 Aug 2017 18:12:58 -0000 Author: emaste Date: Sun Aug 13 18:12:56 2017 New Revision: 322466 URL: https://svnweb.freebsd.org/changeset/base/322466 Log: MFC r304000 (maxim): acpidump: move variable initialization out of assert(3) This fixes acpidump(8) compiled with "WITHOUT_ASSERT_DEBUG=yes" that removes assert(3)'s from the code. Submitted by: Alexander Nedotsukov Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 18:10:24 2017 (r322465) +++ stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 18:12:56 2017 (r322466) @@ -1772,8 +1772,8 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HE perror("mkdtemp tmp working dir"); return; } - assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, iname) - <= sizeof(tmpstr) - 1); + len = (size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, iname); + assert(len <= sizeof(tmpstr) - 1); fd = open(tmpstr, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); if (fd < 0) { perror("iasl tmp file"); @@ -1805,8 +1805,8 @@ aml_disassemble(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HE } /* Dump iasl's output to stdout */ - assert((size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, oname) - <= sizeof(tmpstr) -1); + len = (size_t)snprintf(tmpstr, sizeof(tmpstr), "%s%s", wrkdir, oname); + assert(len <= sizeof(tmpstr) - 1); fp = fopen(tmpstr, "r"); if (unlink(tmpstr) < 0) { perror("unlink"); From owner-svn-src-stable-11@freebsd.org Sun Aug 13 18:14:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E9BFDCFF06; Sun, 13 Aug 2017 18:14:25 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id 2B77B7D4A4; Sun, 13 Aug 2017 18:14:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7DIEO4S098744; Sun, 13 Aug 2017 18:14:24 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7DIEOtG098743; Sun, 13 Aug 2017 18:14:24 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708131814.v7DIEOtG098743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 13 Aug 2017 18:14:24 +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: r322467 - stable/11/usr.sbin/acpi/acpidump X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/usr.sbin/acpi/acpidump X-SVN-Commit-Revision: 322467 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.23 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, 13 Aug 2017 18:14:25 -0000 Author: emaste Date: Sun Aug 13 18:14:24 2017 New Revision: 322467 URL: https://svnweb.freebsd.org/changeset/base/322467 Log: MFC r320736: acpidump: warn and exit loop on invalid subtable length Submitted by: Guangyuan Yang Sponsored by: The FreeBSD Foundation Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 18:12:56 2017 (r322466) +++ stable/11/usr.sbin/acpi/acpidump/acpi.c Sun Aug 13 18:14:24 2017 (r322467) @@ -275,6 +275,10 @@ acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *fi end = (char *)table + table->Length; while ((char *)subtable < end) { printf("\n"); + if (subtable->Length < sizeof(ACPI_SUBTABLE_HEADER)) { + warnx("invalid subtable length %u", subtable->Length); + return; + } action(subtable); subtable = (ACPI_SUBTABLE_HEADER *)((char *)subtable + subtable->Length); From owner-svn-src-stable-11@freebsd.org Sun Aug 13 19:35:49 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6AA58DD5548; Sun, 13 Aug 2017 19:35:49 +0000 (UTC) (envelope-from cy@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 mx1.freebsd.org (Postfix) with ESMTPS id 372D48027F; Sun, 13 Aug 2017 19:35:49 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7DJZmOm031535; Sun, 13 Aug 2017 19:35:48 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7DJZmKG031534; Sun, 13 Aug 2017 19:35:48 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201708131935.v7DJZmKG031534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 13 Aug 2017 19:35:48 +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: r322472 - stable/11/kerberos5/libexec/ipropd-master X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/11/kerberos5/libexec/ipropd-master X-SVN-Commit-Revision: 322472 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.23 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, 13 Aug 2017 19:35:49 -0000 Author: cy Date: Sun Aug 13 19:35:48 2017 New Revision: 322472 URL: https://svnweb.freebsd.org/changeset/base/322472 Log: MFC r322113: Remove dead target introduced in r178828. Modified: stable/11/kerberos5/libexec/ipropd-master/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/kerberos5/libexec/ipropd-master/Makefile ============================================================================== --- stable/11/kerberos5/libexec/ipropd-master/Makefile Sun Aug 13 18:59:19 2017 (r322471) +++ stable/11/kerberos5/libexec/ipropd-master/Makefile Sun Aug 13 19:35:48 2017 (r322472) @@ -10,9 +10,6 @@ DPADD= ${LDAPDPADD} LDADD= ${LDAPLDADD} LDFLAGS=${LDAPLDFLAGS} -foo:: - echo ${LIBHX509} - .include .PATH: ${KRB5DIR}/lib/kadm5 From owner-svn-src-stable-11@freebsd.org Mon Aug 14 02:49:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACB04DCBCCF; Mon, 14 Aug 2017 02:49:32 +0000 (UTC) (envelope-from mckusick@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 mx1.freebsd.org (Postfix) with ESMTPS id 889C76872D; Mon, 14 Aug 2017 02:49:32 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7E2nVOU006561; Mon, 14 Aug 2017 02:49:31 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7E2nV6o006560; Mon, 14 Aug 2017 02:49:31 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708140249.v7E2nV6o006560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 14 Aug 2017 02:49:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322480 - stable/11/sys/geom/journal X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sys/geom/journal X-SVN-Commit-Revision: 322480 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.23 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, 14 Aug 2017 02:49:32 -0000 Author: mckusick Date: Mon Aug 14 02:49:31 2017 New Revision: 322480 URL: https://svnweb.freebsd.org/changeset/base/322480 Log: MFC r322178 Bug 198500 reports bad sysctl values for gjournal cache limit. PR: 198500 Submitted by: Dr. Andreas Longwitz Reported by: Eugene Grosbein Discussed with: kib Modified: stable/11/sys/geom/journal/g_journal.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/journal/g_journal.c ============================================================================== --- stable/11/sys/geom/journal/g_journal.c Mon Aug 14 02:23:10 2017 (r322479) +++ stable/11/sys/geom/journal/g_journal.c Mon Aug 14 02:49:31 2017 (r322480) @@ -130,26 +130,26 @@ SYSCTL_PROC(_kern_geom_journal, OID_AUTO, record_entri SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, &g_journal_do_optimize, 0, "Try to combine bios on flush and copy"); -static u_int g_journal_cache_used = 0; -static u_int g_journal_cache_limit = 64 * 1024 * 1024; +static u_long g_journal_cache_used = 0; +static u_long g_journal_cache_limit = 64 * 1024 * 1024; static u_int g_journal_cache_divisor = 2; static u_int g_journal_cache_switch = 90; static u_int g_journal_cache_misses = 0; static u_int g_journal_cache_alloc_failures = 0; -static u_int g_journal_cache_low = 0; +static u_long g_journal_cache_low = 0; static SYSCTL_NODE(_kern_geom_journal, OID_AUTO, cache, CTLFLAG_RW, 0, "GEOM_JOURNAL cache"); -SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, +SYSCTL_ULONG(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, &g_journal_cache_used, 0, "Number of allocated bytes"); static int g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) { - u_int limit; + u_long limit; int error; limit = g_journal_cache_limit; - error = sysctl_handle_int(oidp, &limit, 0, req); + error = sysctl_handle_long(oidp, &limit, 0, req); if (error != 0 || req->newptr == NULL) return (error); g_journal_cache_limit = limit; @@ -157,7 +157,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_ULONG | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, @@ -3046,9 +3046,9 @@ g_journal_switcher(void *arg) kproc_exit(0); } if (error == 0 && g_journal_sync_requested == 0) { - GJ_DEBUG(1, "Out of cache, force switch (used=%u " - "limit=%u).", g_journal_cache_used, - g_journal_cache_limit); + GJ_DEBUG(1, "Out of cache, force switch (used=%jd " + "limit=%jd).", (intmax_t)g_journal_cache_used, + (intmax_t)g_journal_cache_limit); } GJ_TIMER_START(1, &bt); g_journal_do_switch(mp); From owner-svn-src-stable-11@freebsd.org Mon Aug 14 06:29:26 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 072B6DD825B; Mon, 14 Aug 2017 06:29:26 +0000 (UTC) (envelope-from sephe@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 mx1.freebsd.org (Postfix) with ESMTPS id C279C6FBB7; Mon, 14 Aug 2017 06:29:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7E6TOxE096034; Mon, 14 Aug 2017 06:29:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7E6TOBf096032; Mon, 14 Aug 2017 06:29:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201708140629.v7E6TOBf096032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 14 Aug 2017 06:29:24 +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: r322489 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/11/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 322489 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.23 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, 14 Aug 2017 06:29:26 -0000 Author: sephe Date: Mon Aug 14 06:29:24 2017 New Revision: 322489 URL: https://svnweb.freebsd.org/changeset/base/322489 Log: MFC 322299 hyperv/hn: Implement transparent mode network VF. How network VF works with hn(4) on Hyper-V in transparent mode: - Each network VF has a cooresponding hn(4). - The network VF and the it's cooresponding hn(4) have the same hardware address. - Once the network VF is attached, the cooresponding hn(4) waits several seconds to make sure that the network VF attach routing completes, then: o Set the intersection of the network VF's if_capabilities and the cooresponding hn(4)'s if_capabilities to the cooresponding hn(4)'s if_capabilities. And adjust the cooresponding hn(4) if_capable and if_hwassist accordingly. (*) o Make sure that the cooresponding hn(4)'s TSO parameters meet the constraints posed by both the network VF and the cooresponding hn(4). (*) o The network VF's if_input is overridden. The overriding if_input changes the input packet's rcvif to the cooreponding hn(4). The network layers are tricked into thinking that all packets are neceived by the cooresponding hn(4). o If the cooresponding hn(4) was brought up, bring up the network VF. The transmission dispatched to the cooresponding hn(4) are redispatched to the network VF. o Bringing down the cooresponding hn(4) also brings down the network VF. o All IOCTLs issued to the cooresponding hn(4) are pass-through'ed to the network VF; the cooresponding hn(4) changes its internal state if necessary. o The media status of the cooresponding hn(4) solely relies on the network VF. o If there are multicast filters on the cooresponding hn(4), allmulti will be enabled on the network VF. (**) - Once the network VF is detached. Undo all damages did to the cooresponding hn(4) in the above item. NOTE: No operation should be issued directly to the network VF, if the network VF transparent mode is enabled. The network VF transparent mode can be enabled by setting tunable hw.hn.vf_transparent to 1. The network VF transparent mode is _not_ enabled by default, as of this commit. The benefit of the network VF transparent mode is that the network VF attachment and detachment are transparent to all network layers; e.g. live migration detaches and reattaches the network VF. The major drawbacks of the network VF transparent mode: - The netmap(4) support is lost, even if the VF supports it. - ALTQ does not work, since if_start method cannot be properly supported. (*) These decisions were made so that things will not be messed up too much during the transition period. (**) This does _not_ need to go through the fancy multicast filter management stuffs like what vlan(4) has, at least currently: - As of this write, multicast does not work in Azure. - As of this write, multicast packets go through the cooresponding hn(4). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11803 Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c stable/11/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hn.c Mon Aug 14 06:00:50 2017 (r322488) +++ stable/11/sys/dev/hyperv/netvsc/if_hn.c Mon Aug 14 06:29:24 2017 (r322489) @@ -123,6 +123,8 @@ __FBSDID("$FreeBSD$"); #define HN_VFMAP_SIZE_DEF 8 +#define HN_XPNT_VF_ATTWAIT_MIN 2 /* seconds */ + /* YYY should get it from the underlying channel */ #define HN_TX_DESC_CNT 512 @@ -263,6 +265,7 @@ static void hn_ifnet_event(void *, struct ifnet *, i static void hn_ifaddr_event(void *, struct ifnet *); static void hn_ifnet_attevent(void *, struct ifnet *); static void hn_ifnet_detevent(void *, struct ifnet *); +static void hn_ifnet_lnkevent(void *, struct ifnet *, int); static bool hn_ismyvf(const struct hn_softc *, const struct ifnet *); @@ -270,6 +273,15 @@ static void hn_rxvf_change(struct hn_softc *, struct ifnet *, bool); static void hn_rxvf_set(struct hn_softc *, struct ifnet *); static void hn_rxvf_set_task(void *, int); +static void hn_xpnt_vf_input(struct ifnet *, struct mbuf *); +static int hn_xpnt_vf_iocsetflags(struct hn_softc *); +static int hn_xpnt_vf_iocsetcaps(struct hn_softc *, + struct ifreq *); +static void hn_xpnt_vf_saveifflags(struct hn_softc *); +static bool hn_xpnt_vf_isready(struct hn_softc *); +static void hn_xpnt_vf_setready(struct hn_softc *); +static void hn_xpnt_vf_init_taskfunc(void *, int); +static void hn_xpnt_vf_init(struct hn_softc *); static int hn_rndis_rxinfo(const void *, int, struct hn_rxinfo *); @@ -322,6 +334,8 @@ static int hn_vf_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rxvf_sysctl(SYSCTL_HANDLER_ARGS); static int hn_vflist_sysctl(SYSCTL_HANDLER_ARGS); static int hn_vfmap_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_xpnt_vf_accbpf_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_xpnt_vf_enabled_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *, bool); static void hn_init_locked(struct hn_softc *); @@ -352,6 +366,7 @@ static void hn_disable_rx(struct hn_softc *); static void hn_drain_rxtx(struct hn_softc *, int); static void hn_polling(struct hn_softc *, u_int); static void hn_chan_polling(struct vmbus_channel *, u_int); +static void hn_mtu_change_fixup(struct hn_softc *); static void hn_update_link_status(struct hn_softc *); static void hn_change_network(struct hn_softc *); @@ -529,6 +544,22 @@ SYSCTL_PROC(_hw_hn, OID_AUTO, vflist, CTLFLAG_RD | CTL SYSCTL_PROC(_hw_hn, OID_AUTO, vfmap, CTLFLAG_RD | CTLTYPE_STRING, 0, 0, hn_vfmap_sysctl, "A", "VF mapping"); +/* Transparent VF */ +static int hn_xpnt_vf = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_transparent, CTLFLAG_RDTUN, + &hn_xpnt_vf, 0, "Transparent VF mod"); + +/* Accurate BPF support for Transparent VF */ +static int hn_xpnt_vf_accbpf = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_xpnt_accbpf, CTLFLAG_RDTUN, + &hn_xpnt_vf_accbpf, 0, "Accurate BPF for transparent VF"); + +/* Extra wait for transparent VF attach routing; unit seconds. */ +static int hn_xpnt_vf_attwait = HN_XPNT_VF_ATTWAIT_MIN; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_xpnt_attwait, CTLFLAG_RWTUN, + &hn_xpnt_vf_attwait, 0, + "Extra wait for transparent VF attach routing; unit: seconds"); + static u_int hn_cpu_index; /* next CPU for channel */ static struct taskqueue **hn_tx_taskque;/* shared TX taskqueues */ @@ -807,8 +838,12 @@ hn_rxfilter_config(struct hn_softc *sc) HN_LOCK_ASSERT(sc); - if ((ifp->if_flags & IFF_PROMISC) || - (sc->hn_flags & HN_FLAG_RXVF)) { + /* + * If the non-transparent mode VF is activated, we don't know how + * its RX filter is configured, so stick the synthetic device in + * the promiscous mode. + */ + if ((ifp->if_flags & IFF_PROMISC) || (sc->hn_flags & HN_FLAG_RXVF)) { filter = NDIS_PACKET_TYPE_PROMISCUOUS; } else { filter = NDIS_PACKET_TYPE_DIRECTED; @@ -1086,7 +1121,7 @@ hn_rxvf_change(struct hn_softc *sc, struct ifnet *ifp, } hn_nvs_set_datapath(sc, - rxvf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTHETIC); + rxvf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTH); hn_rxvf_set(sc, rxvf ? ifp : NULL); @@ -1126,7 +1161,323 @@ hn_ifaddr_event(void *arg, struct ifnet *ifp) hn_rxvf_change(arg, ifp, ifp->if_flags & IFF_UP); } +static int +hn_xpnt_vf_iocsetcaps(struct hn_softc *sc, struct ifreq *ifr) +{ + struct ifnet *ifp, *vf_ifp; + uint64_t tmp; + int error; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + vf_ifp = sc->hn_vf_ifp; + + /* + * Fix up requested capabilities w/ supported capabilities, + * since the supported capabilities could have been changed. + */ + ifr->ifr_reqcap &= ifp->if_capabilities; + /* Pass SIOCSIFCAP to VF. */ + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFCAP, (caddr_t)ifr); + + /* + * NOTE: + * The error will be propagated to the callers, however, it + * is _not_ useful here. + */ + + /* + * Merge VF's enabled capabilities. + */ + ifp->if_capenable = vf_ifp->if_capenable & ifp->if_capabilities; + + tmp = vf_ifp->if_hwassist & HN_CSUM_IP_HWASSIST(sc); + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & HN_CSUM_IP6_HWASSIST(sc); + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & CSUM_IP_TSO; + if (ifp->if_capenable & IFCAP_TSO4) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & CSUM_IP6_TSO; + if (ifp->if_capenable & IFCAP_TSO6) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + return (error); +} + +static int +hn_xpnt_vf_iocsetflags(struct hn_softc *sc) +{ + struct ifnet *vf_ifp; + struct ifreq ifr; + + HN_LOCK_ASSERT(sc); + vf_ifp = sc->hn_vf_ifp; + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_flags = vf_ifp->if_flags & 0xffff; + ifr.ifr_flagshigh = vf_ifp->if_flags >> 16; + return (vf_ifp->if_ioctl(vf_ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); +} + static void +hn_xpnt_vf_saveifflags(struct hn_softc *sc) +{ + struct ifnet *ifp = sc->hn_ifp; + int allmulti = 0; + + HN_LOCK_ASSERT(sc); + + /* XXX vlan(4) style mcast addr maintenance */ + if (!TAILQ_EMPTY(&ifp->if_multiaddrs)) + allmulti = IFF_ALLMULTI; + + /* Always set the VF's if_flags */ + sc->hn_vf_ifp->if_flags = ifp->if_flags | allmulti; +} + +static void +hn_xpnt_vf_input(struct ifnet *vf_ifp, struct mbuf *m) +{ + struct rm_priotracker pt; + struct ifnet *hn_ifp = NULL; + struct mbuf *mn; + + /* + * XXX racy, if hn(4) ever detached. + */ + rm_rlock(&hn_vfmap_lock, &pt); + if (vf_ifp->if_index < hn_vfmap_size) + hn_ifp = hn_vfmap[vf_ifp->if_index]; + rm_runlock(&hn_vfmap_lock, &pt); + + if (hn_ifp != NULL) { + /* + * Fix up rcvif and go through hn(4)'s if_input and + * increase ipackets. + */ + for (mn = m; mn != NULL; mn = mn->m_nextpkt) { + /* Allow tapping on the VF. */ + ETHER_BPF_MTAP(vf_ifp, mn); + mn->m_pkthdr.rcvif = hn_ifp; + if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1); + } + hn_ifp->if_input(hn_ifp, m); + } else { + /* + * In the middle of the transition; free this + * mbuf chain. + */ + while (m != NULL) { + mn = m->m_nextpkt; + m->m_nextpkt = NULL; + m_freem(m); + m = mn; + } + } +} + +static void +hn_mtu_change_fixup(struct hn_softc *sc) +{ + struct ifnet *ifp; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + + hn_set_tso_maxsize(sc, hn_tso_maxlen, ifp->if_mtu); +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); +#endif +} + +static void +hn_xpnt_vf_setready(struct hn_softc *sc) +{ + struct ifnet *ifp, *vf_ifp; + struct ifreq ifr; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + vf_ifp = sc->hn_vf_ifp; + + /* + * Mark the VF ready. + */ + sc->hn_vf_rdytick = 0; + + /* + * Save information for restoration. + */ + sc->hn_saved_caps = ifp->if_capabilities; + sc->hn_saved_tsomax = ifp->if_hw_tsomax; + sc->hn_saved_tsosegcnt = ifp->if_hw_tsomaxsegcount; + sc->hn_saved_tsosegsz = ifp->if_hw_tsomaxsegsize; + + /* + * Intersect supported/enabled capabilities. + * + * NOTE: + * if_hwassist is not changed here. + */ + ifp->if_capabilities &= vf_ifp->if_capabilities; + ifp->if_capenable &= ifp->if_capabilities; + + /* + * Fix TSO settings. + */ + if (ifp->if_hw_tsomax > vf_ifp->if_hw_tsomax) + ifp->if_hw_tsomax = vf_ifp->if_hw_tsomax; + if (ifp->if_hw_tsomaxsegcount > vf_ifp->if_hw_tsomaxsegcount) + ifp->if_hw_tsomaxsegcount = vf_ifp->if_hw_tsomaxsegcount; + if (ifp->if_hw_tsomaxsegsize > vf_ifp->if_hw_tsomaxsegsize) + ifp->if_hw_tsomaxsegsize = vf_ifp->if_hw_tsomaxsegsize; + + /* + * Change VF's enabled capabilities. + */ + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_reqcap = ifp->if_capenable; + hn_xpnt_vf_iocsetcaps(sc, &ifr); + + if (ifp->if_mtu != ETHERMTU) { + int error; + + /* + * Change VF's MTU. + */ + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = ifp->if_mtu; + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFMTU, (caddr_t)&ifr); + if (error) { + if_printf(ifp, "%s SIOCSIFMTU %u failed\n", + vf_ifp->if_xname, ifp->if_mtu); + if (ifp->if_mtu > ETHERMTU) { + if_printf(ifp, "change MTU to %d\n", ETHERMTU); + + /* + * XXX + * No need to adjust the synthetic parts' MTU; + * failure of the adjustment will cause us + * infinite headache. + */ + ifp->if_mtu = ETHERMTU; + hn_mtu_change_fixup(sc); + } + } + } +} + +static bool +hn_xpnt_vf_isready(struct hn_softc *sc) +{ + + HN_LOCK_ASSERT(sc); + + if (!hn_xpnt_vf || sc->hn_vf_ifp == NULL) + return (false); + + if (sc->hn_vf_rdytick == 0) + return (true); + + if (sc->hn_vf_rdytick > ticks) + return (false); + + /* Mark VF as ready. */ + hn_xpnt_vf_setready(sc); + return (true); +} + +static void +hn_xpnt_vf_init(struct hn_softc *sc) +{ + int error; + + HN_LOCK_ASSERT(sc); + + KASSERT((sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) == 0, + ("%s: transparent VF was enabled", sc->hn_ifp->if_xname)); + + if (bootverbose) { + if_printf(sc->hn_ifp, "try bringing up %s\n", + sc->hn_vf_ifp->if_xname); + } + + /* + * Bring the VF up. + */ + hn_xpnt_vf_saveifflags(sc); + sc->hn_vf_ifp->if_flags |= IFF_UP; + error = hn_xpnt_vf_iocsetflags(sc); + if (error) { + if_printf(sc->hn_ifp, "bringing up %s failed: %d\n", + sc->hn_vf_ifp->if_xname, error); + return; + } + + /* + * NOTE: + * Datapath setting must happen _after_ bringing the VF up. + */ + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_VF); + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags |= HN_XVFFLAG_ENABLED; + rm_wunlock(&sc->hn_vf_lock); +} + +static void +hn_xpnt_vf_init_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + + HN_LOCK(sc); + + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + goto done; + if (sc->hn_vf_ifp == NULL) + goto done; + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + goto done; + + if (sc->hn_vf_rdytick != 0) { + /* Mark VF as ready. */ + hn_xpnt_vf_setready(sc); + } + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Delayed VF initialization. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "delayed initialize %s\n", + sc->hn_vf_ifp->if_xname); + } + hn_xpnt_vf_init(sc); + } +done: + HN_UNLOCK(sc); +} + +static void hn_ifnet_attevent(void *xsc, struct ifnet *ifp) { struct hn_softc *sc = xsc; @@ -1145,6 +1496,16 @@ hn_ifnet_attevent(void *xsc, struct ifnet *ifp) goto done; } + if (hn_xpnt_vf && ifp->if_start != NULL) { + /* + * ifnet.if_start is _not_ supported by transparent + * mode VF; mainly due to the IFF_DRV_OACTIVE flag. + */ + if_printf(sc->hn_ifp, "%s uses if_start, which is unsupported " + "in transparent VF mode.\n", ifp->if_xname); + goto done; + } + rm_wlock(&hn_vfmap_lock); if (ifp->if_index >= hn_vfmap_size) { @@ -1168,7 +1529,37 @@ hn_ifnet_attevent(void *xsc, struct ifnet *ifp) rm_wunlock(&hn_vfmap_lock); + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + KASSERT((sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) == 0, + ("%s: transparent VF was enabled", sc->hn_ifp->if_xname)); sc->hn_vf_ifp = ifp; + rm_wunlock(&sc->hn_vf_lock); + + if (hn_xpnt_vf) { + int wait_ticks; + + /* + * Install if_input for vf_ifp, which does vf_ifp -> hn_ifp. + * Save vf_ifp's current if_input for later restoration. + */ + sc->hn_vf_input = ifp->if_input; + ifp->if_input = hn_xpnt_vf_input; + + /* + * Stop link status management; use the VF's. + */ + hn_suspend_mgmt(sc); + + /* + * Give VF sometime to complete its attach routing. + */ + wait_ticks = hn_xpnt_vf_attwait * hz; + sc->hn_vf_rdytick = ticks + wait_ticks; + + taskqueue_enqueue_timeout(sc->hn_vf_taskq, &sc->hn_vf_init, + wait_ticks); + } done: HN_UNLOCK(sc); } @@ -1186,7 +1577,61 @@ hn_ifnet_detevent(void *xsc, struct ifnet *ifp) if (!hn_ismyvf(sc, ifp)) goto done; + if (hn_xpnt_vf) { + /* + * Make sure that the delayed initialization is not running. + * + * NOTE: + * - This lock _must_ be released, since the hn_vf_init task + * will try holding this lock. + * - It is safe to release this lock here, since the + * hn_ifnet_attevent() is interlocked by the hn_vf_ifp. + * + * XXX racy, if hn(4) ever detached. + */ + HN_UNLOCK(sc); + taskqueue_drain_timeout(sc->hn_vf_taskq, &sc->hn_vf_init); + HN_LOCK(sc); + + KASSERT(sc->hn_vf_input != NULL, ("%s VF input is not saved", + sc->hn_ifp->if_xname)); + ifp->if_input = sc->hn_vf_input; + sc->hn_vf_input = NULL; + + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_SYNTH); + + if (sc->hn_vf_rdytick == 0) { + /* + * The VF was ready; restore some settings. + */ + sc->hn_ifp->if_capabilities = sc->hn_saved_caps; + /* + * NOTE: + * There is _no_ need to fixup if_capenable and + * if_hwassist, since the if_capabilities before + * restoration was an intersection of the VF's + * if_capabilites and the synthetic device's + * if_capabilites. + */ + sc->hn_ifp->if_hw_tsomax = sc->hn_saved_tsomax; + sc->hn_ifp->if_hw_tsomaxsegcount = + sc->hn_saved_tsosegcnt; + sc->hn_ifp->if_hw_tsomaxsegsize = sc->hn_saved_tsosegsz; + } + + /* + * Resume link status management, which was suspended + * by hn_ifnet_attevent(). + */ + hn_resume_mgmt(sc); + } + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; sc->hn_vf_ifp = NULL; + rm_wunlock(&sc->hn_vf_lock); rm_wlock(&hn_vfmap_lock); @@ -1205,6 +1650,15 @@ done: HN_UNLOCK(sc); } +static void +hn_ifnet_lnkevent(void *xsc, struct ifnet *ifp, int link_state) +{ + struct hn_softc *sc = xsc; + + if (sc->hn_vf_ifp == ifp) + if_link_state_change(sc->hn_ifp, link_state); +} + /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ static const struct hyperv_guid g_net_vsc_device_type = { .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, @@ -1236,6 +1690,9 @@ hn_attach(device_t dev) sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); HN_LOCK_INIT(sc); + rm_init(&sc->hn_vf_lock, "hnvf"); + if (hn_xpnt_vf && hn_xpnt_vf_accbpf) + sc->hn_xvf_flags |= HN_XVFFLAG_ACCBPF; /* * Initialize these tunables once. @@ -1275,6 +1732,18 @@ hn_attach(device_t dev) TIMEOUT_TASK_INIT(sc->hn_mgmt_taskq0, &sc->hn_netchg_status, 0, hn_netchg_status_taskfunc, sc); + if (hn_xpnt_vf) { + /* + * Setup taskqueue for VF tasks, e.g. delayed VF bringing up. + */ + sc->hn_vf_taskq = taskqueue_create("hn_vf", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_vf_taskq); + taskqueue_start_threads(&sc->hn_vf_taskq, 1, PI_NET, "%s vf", + device_get_nameunit(dev)); + TIMEOUT_TASK_INIT(sc->hn_vf_taskq, &sc->hn_vf_init, 0, + hn_xpnt_vf_init_taskfunc, sc); + } + /* * Allocate ifnet and setup its name earlier, so that if_printf * can be used by functions, which will be called after @@ -1401,6 +1870,14 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "hwassist", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_hwassist_sysctl, "A", "hwassist"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_max", + CTLFLAG_RD, &ifp->if_hw_tsomax, 0, "max TSO size"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_maxsegcnt", + CTLFLAG_RD, &ifp->if_hw_tsomaxsegcount, 0, + "max # of TSO segments"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_maxsegsz", + CTLFLAG_RD, &ifp->if_hw_tsomaxsegsize, 0, + "max size of TSO segment"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxfilter", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_rxfilter_sysctl, "A", "rxfilter"); @@ -1445,9 +1922,20 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_vf_sysctl, "A", "Virtual Function's name"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxvf", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, - hn_rxvf_sysctl, "A", "activated Virtual Function's name"); + if (!hn_xpnt_vf) { + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxvf", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rxvf_sysctl, "A", "activated Virtual Function's name"); + } else { + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf_xpnt_enabled", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_xpnt_vf_enabled_sysctl, "I", + "Transparent VF enabled"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf_xpnt_accbpf", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_xpnt_vf_accbpf_sysctl, "I", + "Accurate BPF for transparent VF"); + } /* * Setup the ifmedia, which has been initialized earlier. @@ -1480,7 +1968,7 @@ hn_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO; + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO | IFCAP_LINKSTATE; #ifdef foo /* We can't diff IPv6 packets from IPv4 packets on RX path. */ ifp->if_capabilities |= IFCAP_RXCSUM_IPV6; @@ -1515,7 +2003,13 @@ hn_attach(device_t dev) ifp->if_hwassist &= ~(HN_CSUM_IP6_MASK | CSUM_IP6_TSO); if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + /* + * Lock hn_set_tso_maxsize() to simplify its + * internal logic. + */ + HN_LOCK(sc); hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + HN_UNLOCK(sc); ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; ifp->if_hw_tsomaxsegsize = PAGE_SIZE; } @@ -1536,10 +2030,15 @@ hn_attach(device_t dev) sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; hn_update_link_status(sc); - sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event, - hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY); - sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event, - hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY); + if (!hn_xpnt_vf) { + sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event, + hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY); + sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event, + hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY); + } else { + sc->hn_ifnet_lnkhand = EVENTHANDLER_REGISTER(ifnet_link_event, + hn_ifnet_lnkevent, sc, EVENTHANDLER_PRI_ANY); + } /* * NOTE: @@ -1566,6 +2065,14 @@ hn_detach(device_t dev) struct hn_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->hn_ifp, *vf_ifp; + if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { + /* + * In case that the vmbus missed the orphan handler + * installation. + */ + vmbus_xact_ctx_orphan(sc->hn_xact); + } + if (sc->hn_ifaddr_evthand != NULL) EVENTHANDLER_DEREGISTER(ifaddr_event, sc->hn_ifaddr_evthand); if (sc->hn_ifnet_evthand != NULL) @@ -1578,20 +2085,14 @@ hn_detach(device_t dev) EVENTHANDLER_DEREGISTER(ifnet_departure_event, sc->hn_ifnet_dethand); } + if (sc->hn_ifnet_lnkhand != NULL) + EVENTHANDLER_DEREGISTER(ifnet_link_event, sc->hn_ifnet_lnkhand); vf_ifp = sc->hn_vf_ifp; __compiler_membar(); if (vf_ifp != NULL) hn_ifnet_detevent(sc, vf_ifp); - if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { - /* - * In case that the vmbus missed the orphan handler - * installation. - */ - vmbus_xact_ctx_orphan(sc->hn_xact); - } - if (device_is_attached(dev)) { HN_LOCK(sc); if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { @@ -1621,6 +2122,8 @@ hn_detach(device_t dev) free(sc->hn_tx_taskqs, M_DEVBUF); } taskqueue_free(sc->hn_mgmt_taskq0); + if (sc->hn_vf_taskq != NULL) + taskqueue_free(sc->hn_vf_taskq); if (sc->hn_xact != NULL) { /* @@ -1634,6 +2137,7 @@ hn_detach(device_t dev) if_free(ifp); HN_LOCK_DESTROY(sc); + rm_destroy(&sc->hn_vf_lock); return (0); } @@ -2699,7 +3203,8 @@ static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct hn_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; + struct ifreq *ifr = (struct ifreq *)data, ifr_vf; + struct ifnet *vf_ifp; int mask, error = 0; switch (cmd) { @@ -2728,6 +3233,21 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + if (hn_xpnt_vf_isready(sc)) { + vf_ifp = sc->hn_vf_ifp; + ifr_vf = *ifr; + strlcpy(ifr_vf.ifr_name, vf_ifp->if_xname, + sizeof(ifr_vf.ifr_name)); + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFMTU, + (caddr_t)&ifr_vf); + if (error) { + HN_UNLOCK(sc); + if_printf(ifp, "%s SIOCSIFMTU %d failed: %d\n", + vf_ifp->if_xname, ifr->ifr_mtu, error); + break; + } + } + /* * Suspend this interface before the synthetic parts * are ripped. @@ -2756,23 +3276,32 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; /* - * Make sure that various parameters based on MTU are - * still valid, after the MTU change. + * Synthetic parts' reattach may change the chimney + * sending size; update it. */ if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); - hn_set_tso_maxsize(sc, hn_tso_maxlen, ifp->if_mtu); -#if __FreeBSD_version >= 1100099 - if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < - HN_LRO_LENLIM_MIN(ifp)) - hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); -#endif /* + * Make sure that various parameters based on MTU are + * still valid, after the MTU change. + */ + hn_mtu_change_fixup(sc); + + /* * All done! Resume the interface now. */ hn_resume(sc); + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) { + /* + * Since we have reattached the NVS part, + * change the datapath to VF again; in case + * that it is lost, after the NVS was detached. + */ + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_VF); + } + HN_UNLOCK(sc); break; @@ -2784,6 +3313,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + if (hn_xpnt_vf_isready(sc)) + hn_xpnt_vf_saveifflags(sc); + if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { /* @@ -2794,6 +3326,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) HN_NO_SLEEPING(sc); hn_rxfilter_config(sc); HN_SLEEPING_OK(sc); + + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + error = hn_xpnt_vf_iocsetflags(sc); } else { hn_init_locked(sc); } @@ -2808,8 +3343,23 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFCAP: HN_LOCK(sc); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; + if (hn_xpnt_vf_isready(sc)) { + ifr_vf = *ifr; + strlcpy(ifr_vf.ifr_name, sc->hn_vf_ifp->if_xname, + sizeof(ifr_vf.ifr_name)); + error = hn_xpnt_vf_iocsetcaps(sc, &ifr_vf); + HN_UNLOCK(sc); + break; + } + + /* + * Fix up requested capabilities w/ supported capabilities, + * since the supported capabilities could have been changed. + */ + mask = (ifr->ifr_reqcap & ifp->if_capabilities) ^ + ifp->if_capenable; + if (mask & IFCAP_TXCSUM) { ifp->if_capenable ^= IFCAP_TXCSUM; if (ifp->if_capenable & IFCAP_TXCSUM) @@ -2873,11 +3423,42 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) HN_SLEEPING_OK(sc); } + /* XXX vlan(4) style mcast addr maintenance */ + if (hn_xpnt_vf_isready(sc)) { + int old_if_flags; + + old_if_flags = sc->hn_vf_ifp->if_flags; + hn_xpnt_vf_saveifflags(sc); + + if ((sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) && + ((old_if_flags ^ sc->hn_vf_ifp->if_flags) & + IFF_ALLMULTI)) + error = hn_xpnt_vf_iocsetflags(sc); + } + HN_UNLOCK(sc); break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: + HN_LOCK(sc); + if (hn_xpnt_vf_isready(sc)) { + /* + * SIOCGIFMEDIA expects ifmediareq, so don't + * create and pass ifr_vf to the VF here; just + * replace the ifr_name. + */ + vf_ifp = sc->hn_vf_ifp; + strlcpy(ifr->ifr_name, vf_ifp->if_xname, + sizeof(ifr->ifr_name)); + error = vf_ifp->if_ioctl(vf_ifp, cmd, data); + /* Restore the ifr_name. */ + strlcpy(ifr->ifr_name, ifp->if_xname, + sizeof(ifr->ifr_name)); + HN_UNLOCK(sc); + break; + } + HN_UNLOCK(sc); error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); break; @@ -2899,11 +3480,37 @@ hn_stop(struct hn_softc *sc, bool detaching) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); + /* Clear RUNNING bit ASAP. */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + /* Disable polling. */ hn_polling(sc, 0); - /* Clear RUNNING bit _before_ hn_suspend_data() */ - atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) { + KASSERT(sc->hn_vf_ifp != NULL, + ("%s: VF is not attached", ifp->if_xname)); + + /* NOTE: hn_vf_lock for hn_transmit() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; + rm_wunlock(&sc->hn_vf_lock); + + /* + * NOTE: + * Datapath setting must happen _before_ bringing + * the VF down. + */ + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_SYNTH); + + /* + * Bring the VF down. + */ + hn_xpnt_vf_saveifflags(sc); + sc->hn_vf_ifp->if_flags &= ~IFF_UP; + hn_xpnt_vf_iocsetflags(sc); + } + + /* Suspend data transfers. */ hn_suspend_data(sc); /* Clear OACTIVE bit. */ @@ -2912,8 +3519,8 @@ hn_stop(struct hn_softc *sc, bool detaching) sc->hn_tx_ring[i].hn_oactive = 0; /* - * If the VF is active, make sure the filter is not 0, even if - * the synthetic NIC is down. + * If the non-transparent mode VF is active, make sure + * that the RX filter still allows packet reception. */ if (!detaching && (sc->hn_flags & HN_FLAG_RXVF)) hn_rxfilter_config(sc); @@ -2944,6 +3551,11 @@ hn_init_locked(struct hn_softc *sc) /* Clear TX 'suspended' bit. */ hn_resume_tx(sc, sc->hn_tx_ring_inuse); + if (hn_xpnt_vf_isready(sc)) { + /* Initialize transparent VF. */ + hn_xpnt_vf_init(sc); + } + /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); @@ -3567,6 +4179,42 @@ hn_vfmap_sysctl(SYSCTL_HANDLER_ARGS) } static int +hn_xpnt_vf_accbpf_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error, onoff = 0; + + if (sc->hn_xvf_flags & HN_XVFFLAG_ACCBPF) + onoff = 1; + error = sysctl_handle_int(oidp, &onoff, 0, req); + if (error || req->newptr == NULL) + return (error); + + HN_LOCK(sc); + /* NOTE: hn_vf_lock for hn_transmit() */ + rm_wlock(&sc->hn_vf_lock); + if (onoff) + sc->hn_xvf_flags |= HN_XVFFLAG_ACCBPF; + else + sc->hn_xvf_flags &= ~HN_XVFFLAG_ACCBPF; + rm_wunlock(&sc->hn_vf_lock); + HN_UNLOCK(sc); + + return (0); +} + +static int +hn_xpnt_vf_enabled_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int enabled = 0; + + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + enabled = 1; + return (sysctl_handle_int(oidp, &enabled, 0, req)); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; @@ -4282,8 +4930,11 @@ static void hn_set_tso_maxsize(struct hn_softc *sc, int tso_maxlen, int mtu) { struct ifnet *ifp = sc->hn_ifp; + u_int hw_tsomax; int tso_minlen; + HN_LOCK_ASSERT(sc); + if ((ifp->if_capabilities & (IFCAP_TSO4 | IFCAP_TSO6)) == 0) return; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Mon Aug 14 06:46:17 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43018DD8AC4; Mon, 14 Aug 2017 06:46:17 +0000 (UTC) (envelope-from sephe@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 mx1.freebsd.org (Postfix) with ESMTPS id 1326970424; Mon, 14 Aug 2017 06:46:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7E6kGdm004134; Mon, 14 Aug 2017 06:46:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7E6kF3Z004130; Mon, 14 Aug 2017 06:46:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201708140646.v7E6kF3Z004130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 14 Aug 2017 06:46:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322490 - in stable/11/sys: amd64/amd64 i386/include x86/include x86/x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 322490 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.23 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, 14 Aug 2017 06:46:17 -0000 Author: sephe Date: Mon Aug 14 06:46:15 2017 New Revision: 322490 URL: https://svnweb.freebsd.org/changeset/base/322490 Log: MFC 322323 by jkim Split identify_cpu() into two functions for amd64 as we do for i386. This reduces diff between amd64 and i386. Also, it fixes a regression introduced in r322076, i.e., identify_hypervisor() failed to identify some hypervisors. This function assumes cpu_feature2 is already initialized. Reported by: dexuan Tested by: dexuan Modified: stable/11/sys/amd64/amd64/machdep.c stable/11/sys/i386/include/md_var.h stable/11/sys/x86/include/x86_var.h stable/11/sys/x86/x86/identcpu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/machdep.c Mon Aug 14 06:29:24 2017 (r322489) +++ stable/11/sys/amd64/amd64/machdep.c Mon Aug 14 06:46:15 2017 (r322490) @@ -1544,6 +1544,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) kmdp = init_ops.parse_preload_data(modulep); + identify_cpu(); identify_hypervisor(); /* Init basic tunables, hz etc */ @@ -1650,7 +1651,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) != NULL) vty_set_preferred(VTY_VT); - identify_cpu(); /* Final stage of CPU initialization */ + finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ initializecpucache(); Modified: stable/11/sys/i386/include/md_var.h ============================================================================== --- stable/11/sys/i386/include/md_var.h Mon Aug 14 06:29:24 2017 (r322489) +++ stable/11/sys/i386/include/md_var.h Mon Aug 14 06:46:15 2017 (r322490) @@ -59,7 +59,6 @@ void doreti_popl_es(void) __asm(__STRING(doreti_popl_e void doreti_popl_es_fault(void) __asm(__STRING(doreti_popl_es_fault)); void doreti_popl_fs(void) __asm(__STRING(doreti_popl_fs)); void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault)); -void finishidentcpu(void); void fill_based_sd(struct segment_descriptor *sdp, uint32_t base); void i686_pagezero(void *addr); void sse2_pagezero(void *addr); Modified: stable/11/sys/x86/include/x86_var.h ============================================================================== --- stable/11/sys/x86/include/x86_var.h Mon Aug 14 06:29:24 2017 (r322489) +++ stable/11/sys/x86/include/x86_var.h Mon Aug 14 06:46:15 2017 (r322490) @@ -115,6 +115,7 @@ void cpu_probe_amdc1e(void); void cpu_setregs(void); void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); +void finishidentcpu(void); void identify_cpu(void); void identify_hypervisor(void); void initializecpu(void); Modified: stable/11/sys/x86/x86/identcpu.c ============================================================================== --- stable/11/sys/x86/x86/identcpu.c Mon Aug 14 06:29:24 2017 (r322489) +++ stable/11/sys/x86/x86/identcpu.c Mon Aug 14 06:46:15 2017 (r322490) @@ -1372,23 +1372,12 @@ fix_cpuid(void) return (false); } -/* - * Final stage of CPU identification. - */ -#ifdef __i386__ +#ifdef __amd64__ void -finishidentcpu(void) -#else -void identify_cpu(void) -#endif { - u_int regs[4], cpu_stdext_disable; -#ifdef __i386__ - u_char ccr3; -#endif + u_int regs[4]; -#ifdef __amd64__ do_cpuid(0, regs); cpu_high = regs[0]; ((u_int *)&cpu_vendor)[0] = regs[1]; @@ -1401,6 +1390,18 @@ identify_cpu(void) cpu_procinfo = regs[1]; cpu_feature = regs[3]; cpu_feature2 = regs[2]; +} +#endif + +/* + * Final stage of CPU identification. + */ +void +finishidentcpu(void) +{ + u_int regs[4], cpu_stdext_disable; +#ifdef __i386__ + u_char ccr3; #endif cpu_vendor_id = find_cpu_vendor_id(); From owner-svn-src-stable-11@freebsd.org Mon Aug 14 11:04:07 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6695DE31C2; Mon, 14 Aug 2017 11:04:07 +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 mx1.freebsd.org (Postfix) with ESMTPS id 84A977766F; Mon, 14 Aug 2017 11:04:07 +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 v7EB46DR015190; Mon, 14 Aug 2017 11:04:06 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7EB46pD015189; Mon, 14 Aug 2017 11:04:06 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708141104.v7EB46pD015189@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 14 Aug 2017 11:04:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322491 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 322491 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.23 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, 14 Aug 2017 11:04:07 -0000 Author: kib Date: Mon Aug 14 11:04:06 2017 New Revision: 322491 URL: https://svnweb.freebsd.org/changeset/base/322491 Log: MFC r322171: Explain why delayed invalidation is not required in pmap_protect() and pmap_remove_pages(). 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 Mon Aug 14 06:46:15 2017 (r322490) +++ stable/11/sys/amd64/amd64/pmap.c Mon Aug 14 11:04:06 2017 (r322491) @@ -4055,6 +4055,26 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t PG_RW = pmap_rw_bit(pmap); anychanged = FALSE; + /* + * Although this function delays and batches the invalidation + * of stale TLB entries, it does not need to call + * pmap_delayed_invl_started() and + * pmap_delayed_invl_finished(), because it does not + * ordinarily destroy mappings. Stale TLB entries from + * protection-only changes need only be invalidated before the + * pmap lock is released, because protection-only changes do + * not destroy PV entries. Even operations that iterate over + * a physical page's PV list of mappings, like + * pmap_remove_write(), acquire the pmap lock for each + * mapping. Consequently, for protection-only changes, the + * pmap lock suffices to synchronize both page table and TLB + * updates. + * + * This function only destroys a mapping if pmap_demote_pde() + * fails. In that case, stale TLB entries are immediately + * invalidated. + */ + PMAP_LOCK(pmap); for (; sva < eva; sva = va_next) { @@ -5378,6 +5398,15 @@ pmap_page_is_mapped(vm_page_t m) * no processor is currently accessing the user address space. In * particular, a page table entry's dirty bit won't change state once * this function starts. + * + * Although this function destroys all of the pmap's managed, + * non-wired mappings, it can delay and batch the invalidation of TLB + * entries without calling pmap_delayed_invl_started() and + * pmap_delayed_invl_finished(). Because the pmap is not active on + * any other processor, none of these TLB entries will ever be used + * before their eventual invalidation. Consequently, there is no need + * for either pmap_remove_all() or pmap_remove_write() to wait for + * that eventual TLB invalidation. */ void pmap_remove_pages(pmap_t pmap) From owner-svn-src-stable-11@freebsd.org Mon Aug 14 11:06:10 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80994DE32E5; Mon, 14 Aug 2017 11:06:10 +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 mx1.freebsd.org (Postfix) with ESMTPS id 56826777B8; Mon, 14 Aug 2017 11:06:10 +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 v7EB69PI015311; Mon, 14 Aug 2017 11:06:09 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7EB6915015310; Mon, 14 Aug 2017 11:06:09 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708141106.v7EB6915015310@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 14 Aug 2017 11:06: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: r322492 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 322492 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.23 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, 14 Aug 2017 11:06:10 -0000 Author: kib Date: Mon Aug 14 11:06:09 2017 New Revision: 322492 URL: https://svnweb.freebsd.org/changeset/base/322492 Log: MFC r322175: Avoid DI recursion when reclaim_pv_chunk() is called from pmap_advise() or pmap_remove(). 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 Mon Aug 14 11:04:06 2017 (r322491) +++ stable/11/sys/amd64/amd64/pmap.c Mon Aug 14 11:06:09 2017 (r322492) @@ -430,8 +430,15 @@ static struct lock_object invl_gen_ts = { .lo_name = "invlts", }; +static bool +pmap_not_in_di(void) +{ + + return (curthread->td_md.md_invl_gen.gen == 0); +} + #define PMAP_ASSERT_NOT_IN_DI() \ - KASSERT(curthread->td_md.md_invl_gen.gen == 0, ("DI already started")) + KASSERT(pmap_not_in_di(), ("DI already started")) /* * Start a new Delayed Invalidation (DI) block of code, executed by @@ -2847,6 +2854,19 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG "Current number of spare pv entries"); #endif +static void +reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked_pmap, bool start_di) +{ + + if (pmap == NULL) + return; + pmap_invalidate_all(pmap); + if (pmap != locked_pmap) + PMAP_UNLOCK(pmap); + if (start_di) + pmap_delayed_invl_finished(); +} + /* * We are in a serious low memory condition. Resort to * drastic measures to free some pages so we can allocate @@ -2874,6 +2894,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l struct spglist free; uint64_t inuse; int bit, field, freed; + bool start_di; PMAP_LOCK_ASSERT(locked_pmap, MA_OWNED); KASSERT(lockp != NULL, ("reclaim_pv_chunk: lockp is NULL")); @@ -2882,19 +2903,21 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l PG_G = PG_A = PG_M = PG_RW = 0; SLIST_INIT(&free); TAILQ_INIT(&new_tail); - pmap_delayed_invl_started(); + + /* + * A delayed invalidation block should already be active if + * pmap_advise() or pmap_remove() called this function by way + * of pmap_demote_pde_locked(). + */ + start_di = pmap_not_in_di(); + mtx_lock(&pv_chunks_mutex); while ((pc = TAILQ_FIRST(&pv_chunks)) != NULL && SLIST_EMPTY(&free)) { TAILQ_REMOVE(&pv_chunks, pc, pc_lru); mtx_unlock(&pv_chunks_mutex); if (pmap != pc->pc_pmap) { - if (pmap != NULL) { - pmap_invalidate_all(pmap); - if (pmap != locked_pmap) - PMAP_UNLOCK(pmap); - } - pmap_delayed_invl_finished(); - pmap_delayed_invl_started(); + reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, + start_di); pmap = pc->pc_pmap; /* Avoid deadlock and lock recursion. */ if (pmap > locked_pmap) { @@ -2911,6 +2934,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l PG_A = pmap_accessed_bit(pmap); PG_M = pmap_modified_bit(pmap); PG_RW = pmap_rw_bit(pmap); + if (start_di) + pmap_delayed_invl_started(); } /* @@ -2985,12 +3010,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l } TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru); mtx_unlock(&pv_chunks_mutex); - if (pmap != NULL) { - pmap_invalidate_all(pmap); - if (pmap != locked_pmap) - PMAP_UNLOCK(pmap); - } - pmap_delayed_invl_finished(); + reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di); if (m_pc == NULL && !SLIST_EMPTY(&free)) { m_pc = SLIST_FIRST(&free); SLIST_REMOVE_HEAD(&free, plinks.s.ss); From owner-svn-src-stable-11@freebsd.org Mon Aug 14 12:37:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04D9EDC4565; Mon, 14 Aug 2017 12:37:00 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id C74597F15D; Mon, 14 Aug 2017 12:36:59 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7ECawJd052327; Mon, 14 Aug 2017 12:36:58 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ECawGh052326; Mon, 14 Aug 2017 12:36:58 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708141236.v7ECawGh052326@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 14 Aug 2017 12:36:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322497 - stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Commit-Revision: 322497 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.23 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, 14 Aug 2017 12:37:00 -0000 Author: hselasky Date: Mon Aug 14 12:36:58 2017 New Revision: 322497 URL: https://svnweb.freebsd.org/changeset/base/322497 Log: MFC r322305: Increment queue drops in the network statistics when transmitted packets are dropped by the mlx4en(4) driver. Submitted by: Sepherosa Ziehau Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/net/mlx4/en_tx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/net/mlx4/en_tx.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_tx.c Mon Aug 14 11:23:07 2017 (r322496) +++ stable/11/sys/ofed/drivers/net/mlx4/en_tx.c Mon Aug 14 12:36:58 2017 (r322497) @@ -1073,6 +1073,10 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) taskqueue_enqueue(cq->tq, &cq->cq_task); } +#if __FreeBSD_version >= 1100000 + if (unlikely(err != 0)) + if_inc_counter(dev, IFCOUNTER_IQDROPS, 1); +#endif return (err); } From owner-svn-src-stable-11@freebsd.org Mon Aug 14 12:45:56 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61ECFDC4C3B; Mon, 14 Aug 2017 12:45:56 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id 2C3937F6B8; Mon, 14 Aug 2017 12:45:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7ECjtHn056208; Mon, 14 Aug 2017 12:45:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ECjtbD056207; Mon, 14 Aug 2017 12:45:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708141245.v7ECjtbD056207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 14 Aug 2017 12:45:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322498 - stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 322498 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.23 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, 14 Aug 2017 12:45:56 -0000 Author: hselasky Date: Mon Aug 14 12:45:55 2017 New Revision: 322498 URL: https://svnweb.freebsd.org/changeset/base/322498 Log: MFC r314878: Add support for constant pointer constructs to READ_ONCE() in the LinuxKPI. When the type of the argument is constant the temporary variable cannot be assigned after the barrier. Instead assign the temporary variable by initialization. Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h Mon Aug 14 12:36:58 2017 (r322497) +++ stable/11/sys/compat/linuxkpi/common/include/linux/compiler.h Mon Aug 14 12:45:55 2017 (r322498) @@ -86,9 +86,10 @@ } while (0) #define READ_ONCE(x) ({ \ - __typeof(x) __var; \ - barrier(); \ - __var = ACCESS_ONCE(x); \ + __typeof(x) __var = ({ \ + barrier(); \ + ACCESS_ONCE(x); \ + }); \ barrier(); \ __var; \ }) From owner-svn-src-stable-11@freebsd.org Mon Aug 14 12:47:17 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E701FDC4E47; Mon, 14 Aug 2017 12:47:17 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id C2C0F7F97E; Mon, 14 Aug 2017 12:47:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7EClHXh056312; Mon, 14 Aug 2017 12:47:17 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7EClHbA056311; Mon, 14 Aug 2017 12:47:17 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708141247.v7EClHbA056311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 14 Aug 2017 12:47:17 +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: r322499 - stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Commit-Revision: 322499 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.23 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, 14 Aug 2017 12:47:18 -0000 Author: hselasky Date: Mon Aug 14 12:47:16 2017 New Revision: 322499 URL: https://svnweb.freebsd.org/changeset/base/322499 Log: MFC r322304: Add support for RX and TX statistics when the mlx4en(4) PCI device is in VF or SRIOV mode typically in a virtual machine environment. Submitted by: Sepherosa Ziehau Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/net/mlx4/en_port.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/net/mlx4/en_port.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_port.c Mon Aug 14 12:45:55 2017 (r322498) +++ stable/11/sys/ofed/drivers/net/mlx4/en_port.c Mon Aug 14 12:47:16 2017 (r322499) @@ -124,11 +124,45 @@ out: return err; } +static void mlx4_en_fold_software_stats(struct net_device *dev) +{ + struct mlx4_en_priv *priv = netdev_priv(dev); + struct mlx4_en_dev *mdev = priv->mdev; + u64 packets, bytes; + int i; + + if (!priv->port_up || mlx4_is_master(mdev->dev)) + return; + + packets = 0; + bytes = 0; + for (i = 0; i < priv->rx_ring_num; i++) { + const struct mlx4_en_rx_ring *ring = priv->rx_ring[i]; + + packets += READ_ONCE(ring->packets); + bytes += READ_ONCE(ring->bytes); + } + priv->pkstats.rx_packets = packets; + priv->pkstats.rx_bytes = bytes; + + packets = 0; + bytes = 0; + for (i = 0; i < priv->tx_ring_num; i++) { + const struct mlx4_en_tx_ring *ring = priv->tx_ring[i]; + + packets += READ_ONCE(ring->packets); + bytes += READ_ONCE(ring->bytes); + } + priv->pkstats.tx_packets = packets; + priv->pkstats.tx_bytes = bytes; +} + int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset) { struct mlx4_en_stat_out_mbox *mlx4_en_stats; struct mlx4_en_stat_out_flow_control_mbox *flowstats; - struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]); + struct net_device *dev = mdev->pndev[port]; + struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_vport_stats *vport_stats = &priv->vport_stats; struct mlx4_cmd_mailbox *mailbox = NULL; struct mlx4_cmd_mailbox *mailbox_flow = NULL; @@ -138,7 +172,6 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u int do_if_stat = 1; unsigned long period = (unsigned long) (jiffies - priv->last_ifq_jiffies); struct mlx4_en_vport_stats tmp_vport_stats; - struct net_device *dev; if (jiffies_to_msecs(period) < EN_IFQ_MIN_INTERVAL || priv->counter_index == 0xff) @@ -523,8 +556,12 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u be64_to_cpu(flowstats[i].tx_pause_transition); } - memset(&tmp_vport_stats, 0, sizeof(tmp_vport_stats)); + mlx4_en_fold_software_stats(dev); + spin_unlock(&priv->stats_lock); + + memset(&tmp_vport_stats, 0, sizeof(tmp_vport_stats)); + err = mlx4_get_vport_ethtool_stats(mdev->dev, port, &tmp_vport_stats, reset); spin_lock(&priv->stats_lock); @@ -547,42 +584,37 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u vport_stats->tx_errors = tmp_vport_stats.tx_errors; } - if (!mlx4_is_mfunc(mdev->dev)) { -/* netdevice stats format */ #if __FreeBSD_version >= 1100000 - if (reset == 0) { - dev = mdev->pndev[port]; - if_inc_counter(dev, IFCOUNTER_IPACKETS, - priv->pkstats.rx_packets - priv->pkstats_last.rx_packets); - if_inc_counter(dev, IFCOUNTER_OPACKETS, - priv->pkstats.tx_packets - priv->pkstats_last.tx_packets); - if_inc_counter(dev, IFCOUNTER_IBYTES, - priv->pkstats.rx_bytes - priv->pkstats_last.rx_bytes); - if_inc_counter(dev, IFCOUNTER_OBYTES, - priv->pkstats.tx_bytes - priv->pkstats_last.tx_bytes); - if_inc_counter(dev, IFCOUNTER_IERRORS, - priv->pkstats.rx_errors - priv->pkstats_last.rx_errors); - if_inc_counter(dev, IFCOUNTER_IQDROPS, - priv->pkstats.rx_dropped - priv->pkstats_last.rx_dropped); - if_inc_counter(dev, IFCOUNTER_IMCASTS, - priv->pkstats.rx_multicast_packets - priv->pkstats_last.rx_multicast_packets); - if_inc_counter(dev, IFCOUNTER_OMCASTS, - priv->pkstats.tx_multicast_packets - priv->pkstats_last.tx_multicast_packets); - } - priv->pkstats_last = priv->pkstats; + if (reset == 0) { + if_inc_counter(dev, IFCOUNTER_IPACKETS, + priv->pkstats.rx_packets - priv->pkstats_last.rx_packets); + if_inc_counter(dev, IFCOUNTER_OPACKETS, + priv->pkstats.tx_packets - priv->pkstats_last.tx_packets); + if_inc_counter(dev, IFCOUNTER_IBYTES, + priv->pkstats.rx_bytes - priv->pkstats_last.rx_bytes); + if_inc_counter(dev, IFCOUNTER_OBYTES, + priv->pkstats.tx_bytes - priv->pkstats_last.tx_bytes); + if_inc_counter(dev, IFCOUNTER_IERRORS, + priv->pkstats.rx_errors - priv->pkstats_last.rx_errors); + if_inc_counter(dev, IFCOUNTER_IQDROPS, + priv->pkstats.rx_dropped - priv->pkstats_last.rx_dropped); + if_inc_counter(dev, IFCOUNTER_IMCASTS, + priv->pkstats.rx_multicast_packets - priv->pkstats_last.rx_multicast_packets); + if_inc_counter(dev, IFCOUNTER_OMCASTS, + priv->pkstats.tx_multicast_packets - priv->pkstats_last.tx_multicast_packets); + } + priv->pkstats_last = priv->pkstats; #else - dev = mdev->pndev[port]; - dev->if_ipackets = priv->pkstats.rx_packets; - dev->if_opackets = priv->pkstats.tx_packets; - dev->if_ibytes = priv->pkstats.rx_bytes; - dev->if_obytes = priv->pkstats.tx_bytes; - dev->if_ierrors = priv->pkstats.rx_errors; - dev->if_iqdrops = priv->pkstats.rx_dropped; - dev->if_imcasts = priv->pkstats.rx_multicast_packets; - dev->if_omcasts = priv->pkstats.tx_multicast_packets; - dev->if_collisions = 0; + dev->if_ipackets = priv->pkstats.rx_packets; + dev->if_opackets = priv->pkstats.tx_packets; + dev->if_ibytes = priv->pkstats.rx_bytes; + dev->if_obytes = priv->pkstats.tx_bytes; + dev->if_ierrors = priv->pkstats.rx_errors; + dev->if_iqdrops = priv->pkstats.rx_dropped; + dev->if_imcasts = priv->pkstats.rx_multicast_packets; + dev->if_omcasts = priv->pkstats.tx_multicast_packets; + dev->if_collisions = 0; #endif - } spin_unlock(&priv->stats_lock); From owner-svn-src-stable-11@freebsd.org Mon Aug 14 13:32:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81320DC82DB; Mon, 14 Aug 2017 13:32:25 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id 11AFB81FE4; Mon, 14 Aug 2017 13:32:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7EDWL73077965; Mon, 14 Aug 2017 13:32:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7EDWLWE077964; Mon, 14 Aug 2017 13:32:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708141332.v7EDWLWE077964@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 14 Aug 2017 13:32: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: r322505 - stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Commit-Revision: 322505 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.23 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, 14 Aug 2017 13:32:25 -0000 Author: hselasky Date: Mon Aug 14 13:32:21 2017 New Revision: 322505 URL: https://svnweb.freebsd.org/changeset/base/322505 Log: MFC r322306: Print maximum MTU when trying to set invalid MTU in the mlx4en(4) driver. Useful for debugging. Submitted by: Sepherosa Ziehau Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Aug 14 13:28:40 2017 (r322504) +++ stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Aug 14 13:32:21 2017 (r322505) @@ -1771,7 +1771,8 @@ static int mlx4_en_change_mtu(struct net_device *dev, (unsigned)dev->if_mtu, (unsigned)new_mtu); if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) { - en_err(priv, "Bad MTU size:%d.\n", new_mtu); + en_err(priv, "Bad MTU size:%d, max %u.\n", new_mtu, + priv->max_mtu); return -EPERM; } mutex_lock(&mdev->state_lock); From owner-svn-src-stable-11@freebsd.org Mon Aug 14 15:08:51 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5F2ADDCF87B; Mon, 14 Aug 2017 15:08:51 +0000 (UTC) (envelope-from gahr@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 mx1.freebsd.org (Postfix) with ESMTPS id 3AB3D1607; Mon, 14 Aug 2017 15:08:51 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7EF8oNu014469; Mon, 14 Aug 2017 15:08:50 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7EF8oRu014465; Mon, 14 Aug 2017 15:08:50 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201708141508.v7EF8oRu014465@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Mon, 14 Aug 2017 15:08:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322509 - in stable/11: contrib/top usr.bin/top X-SVN-Group: stable-11 X-SVN-Commit-Author: gahr X-SVN-Commit-Paths: in stable/11: contrib/top usr.bin/top X-SVN-Commit-Revision: 322509 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.23 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, 14 Aug 2017 15:08:51 -0000 Author: gahr (ports committer) Date: Mon Aug 14 15:08:49 2017 New Revision: 322509 URL: https://svnweb.freebsd.org/changeset/base/322509 Log: MFC r322139 Enhance top(1) to filter on multiple usernames Reviewed by: cognet, bapt Approved by: cognet Relnotes: yes Differential Revision: https://reviews.freebsd.org/D11840 Modified: stable/11/contrib/top/machine.h stable/11/contrib/top/top.c stable/11/contrib/top/top.xs stable/11/usr.bin/top/machine.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/top/machine.h ============================================================================== --- stable/11/contrib/top/machine.h Mon Aug 14 14:16:56 2017 (r322508) +++ stable/11/contrib/top/machine.h Mon Aug 14 15:08:49 2017 (r322509) @@ -70,7 +70,8 @@ struct process_select int self; /* show self */ int system; /* show system processes */ int thread; /* show threads */ - int uid; /* only this uid (unless uid == -1) */ +#define TOP_MAX_UIDS 8 + int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */ int wcpu; /* show weighted cpu */ int jid; /* only this jid (unless jid == -1) */ int jail; /* show jail ID */ Modified: stable/11/contrib/top/top.c ============================================================================== --- stable/11/contrib/top/top.c Mon Aug 14 14:16:56 2017 (r322508) +++ stable/11/contrib/top/top.c Mon Aug 14 15:08:49 2017 (r322509) @@ -133,7 +133,110 @@ void (*d_process)() = i_process; void reset_display(void); +static void +reset_uids() +{ + for (size_t i = 0; i < TOP_MAX_UIDS; ++i) + ps.uid[i] = -1; +} +static int +add_uid(int uid) +{ + size_t i = 0; + + /* Add the uid if there's room */ + for (; i < TOP_MAX_UIDS; ++i) + { + if (ps.uid[i] == -1 || ps.uid[i] == uid) + { + ps.uid[i] = uid; + break; + } + } + + return (i == TOP_MAX_UIDS); +} + +static void +rem_uid(int uid) +{ + size_t i = 0; + size_t where = TOP_MAX_UIDS; + + /* Look for the user to remove - no problem if it's not there */ + for (; i < TOP_MAX_UIDS; ++i) + { + if (ps.uid[i] == -1) + break; + if (ps.uid[i] == uid) + where = i; + } + + /* Make sure we don't leave a hole in the middle */ + if (where != TOP_MAX_UIDS) + { + ps.uid[where] = ps.uid[i-1]; + ps.uid[i-1] = -1; + } +} + +static int +handle_user(char *buf, size_t buflen) +{ + int rc = 0; + int uid = -1; + char *buf2 = buf; + + new_message(MT_standout, "Username to show (+ for all): "); + if (readline(buf, buflen, No) <= 0) + { + clear_message(); + return rc; + } + + if (buf[0] == '+' || buf[0] == '-') + { + if (buf[1] == '\0') + { + reset_uids(); + goto end; + } + else + ++buf2; + } + + if ((uid = userid(buf2)) == -1) + { + new_message(MT_standout, " %s: unknown user", buf2); + rc = 1; + goto end; + } + + if (buf2 == buf) + { + reset_uids(); + ps.uid[0] = uid; + goto end; + } + + if (buf[0] == '+') + { + if (add_uid(uid)) + { + new_message(MT_standout, " too many users, reset with '+'"); + rc = 1; + goto end; + } + } + else + rem_uid(uid); + +end: + putchar('\r'); + return rc; +} + int main(argc, argv) @@ -251,7 +354,7 @@ char *argv[]; ps.idle = Yes; ps.self = -1; ps.system = No; - ps.uid = -1; + reset_uids(); ps.thread = No; ps.wcpu = 1; ps.jid = -1; @@ -298,7 +401,7 @@ char *argv[]; break; case 'U': /* display only username's processes */ - if ((ps.uid = userid(optarg)) == -1) + if ((ps.uid[0] = userid(optarg)) == -1) { fprintf(stderr, "%s: unknown user\n", optarg); exit(1); @@ -1003,31 +1106,8 @@ restart: break; case CMD_user: - new_message(MT_standout, - "Username to show (+ for all): "); - if (readline(tempbuf2, sizeof(tempbuf2), No) > 0) - { - if (tempbuf2[0] == '+' && - tempbuf2[1] == '\0') - { - ps.uid = -1; - } - else if ((i = userid(tempbuf2)) == -1) - { - new_message(MT_standout, - " %s: unknown user", tempbuf2); - no_command = Yes; - } - else - { - ps.uid = i; - } - putchar('\r'); - } - else - { - clear_message(); - } + if (handle_user(tempbuf2, sizeof(tempbuf2))) + no_command = Yes; break; case CMD_thrtog: Modified: stable/11/contrib/top/top.xs ============================================================================== --- stable/11/contrib/top/top.xs Mon Aug 14 14:16:56 2017 (r322508) +++ stable/11/contrib/top/top.xs Mon Aug 14 15:08:49 2017 (r322509) @@ -307,9 +307,11 @@ This acts similarly to the command .IR renice (8)). .TP .B u -Display only processes owned by a specific username (prompt for username). -If the username specified is simply \*(lq+\*(rq, then processes belonging -to all users will be displayed. +Display only processes owned by a specific set of usernames (prompt for +username). If the username specified is simply \*(lq+\*(rq or \*(lq-\*(rq, +then processes belonging to all users will be displayed. Usernames can be added +to and removed from the set by prepending them with \*(lq+\*(rq and +\*(lq-\*(rq, respectively. .TP .B o Change the order in which the display is sorted. This command is not Modified: stable/11/usr.bin/top/machine.c ============================================================================== --- stable/11/usr.bin/top/machine.c Mon Aug 14 14:16:56 2017 (r322508) +++ stable/11/usr.bin/top/machine.c Mon Aug 14 15:08:49 2017 (r322509) @@ -273,7 +273,19 @@ static const char *format_nice(const struct kinfo_proc static void getsysctl(const char *name, void *ptr, size_t len); static int swapmode(int *retavail, int *retfree); static void update_layout(void); +static int find_uid(uid_t needle, int *haystack); +static int +find_uid(uid_t needle, int *haystack) +{ + size_t i = 0; + + for (; i < TOP_MAX_UIDS; ++i) + if ((uid_t)haystack[i] == needle) + return 1; + return 0; +} + void toggle_pcpustats(void) { @@ -847,7 +859,7 @@ get_process_info(struct system_info *si, struct proces show_jid = sel->jid != -1; show_self = sel->self == -1; show_system = sel->system; - show_uid = sel->uid != -1; + show_uid = sel->uid[0] != -1; show_command = sel->command != NULL; show_kidle = sel->kidle; @@ -906,7 +918,7 @@ get_process_info(struct system_info *si, struct proces /* skip proc. that don't belong to the selected JID */ continue; - if (show_uid && pp->ki_ruid != (uid_t)sel->uid) + if (show_uid && !find_uid(pp->ki_ruid, sel->uid)) /* skip proc. that don't belong to the selected UID */ continue; From owner-svn-src-stable-11@freebsd.org Mon Aug 14 21:48:51 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3392DC2452; Mon, 14 Aug 2017 21:48:51 +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 mx1.freebsd.org (Postfix) with ESMTPS id 8CD0B70244; Mon, 14 Aug 2017 21:48:51 +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 v7ELmoDS078924; Mon, 14 Aug 2017 21:48:50 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ELmoMo078922; Mon, 14 Aug 2017 21:48:50 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708142148.v7ELmoMo078922@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 14 Aug 2017 21:48:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322520 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322520 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.23 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, 14 Aug 2017 21:48:51 -0000 Author: kevans Date: Mon Aug 14 21:48:50 2017 New Revision: 322520 URL: https://svnweb.freebsd.org/changeset/base/322520 Log: MFC r313948: bsdgrep: fix EOF handling with --mmap Rework part of the loop in grep_fgetln to return the rest of the line and ensure that we still advance the buffer by the length of the rest of the line. PR: 165471 Approved by: emaste (mentor) Modified: stable/11/usr.bin/grep/file.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/file.c ============================================================================== --- stable/11/usr.bin/grep/file.c Mon Aug 14 20:53:01 2017 (r322519) +++ stable/11/usr.bin/grep/file.c Mon Aug 14 21:48:50 2017 (r322520) @@ -219,12 +219,18 @@ grep_fgetln(struct file *f, size_t *lenp) if (bufrem == 0) /* EOF: return partial line */ break; - if ((p = memchr(bufpos, '\n', bufrem)) == NULL) + if ((p = memchr(bufpos, '\n', bufrem)) == NULL && + filebehave != FILE_MMAP) continue; - /* got it: finish up the line (like code above) */ - ++p; - diff = p - bufpos; - len += diff; + if (p == NULL) { + /* mmap EOF: return partial line, consume buffer */ + diff = len; + } else { + /* got it: finish up the line (like code above) */ + ++p; + diff = p - bufpos; + len += diff; + } if (grep_lnbufgrow(len)) goto error; memcpy(lnbuf + off, bufpos, diff); From owner-svn-src-stable-11@freebsd.org Tue Aug 15 00:54:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5362BDCDDC5; Tue, 15 Aug 2017 00:54:18 +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 mx1.freebsd.org (Postfix) with ESMTPS id 1F65E76706; Tue, 15 Aug 2017 00:54:18 +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 v7F0sHKk056381; Tue, 15 Aug 2017 00:54:17 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F0sHVF056379; Tue, 15 Aug 2017 00:54:17 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201708150054.v7F0sHVF056379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 15 Aug 2017 00:54:17 +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: r322524 - in stable/11/lib/libc: gen tests/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in stable/11/lib/libc: gen tests/gen X-SVN-Commit-Revision: 322524 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.23 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, 15 Aug 2017 00:54:18 -0000 Author: pfg Date: Tue Aug 15 00:54:16 2017 New Revision: 322524 URL: https://svnweb.freebsd.org/changeset/base/322524 Log: MFC r322368, r322371: fnmatch(3): improve POSIX conformance. In a recent interpretation[1], "\\" shall return a non-zero value (indicating either no match or an error). The fix involves a change over r254091 and now the behavior matches the Sun/IBM/HP closed source implementations and also likely musl libc. Submitted by: Joerg Schilling [1] http://austingroupbugs.net/view.php?id=806 Modified: stable/11/lib/libc/gen/fnmatch.c stable/11/lib/libc/tests/gen/fnmatch_testcases.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/fnmatch.c ============================================================================== --- stable/11/lib/libc/gen/fnmatch.c Mon Aug 14 23:46:10 2017 (r322523) +++ stable/11/lib/libc/gen/fnmatch.c Tue Aug 15 00:54:16 2017 (r322524) @@ -184,7 +184,8 @@ fnmatch1(const char *pattern, const char *string, cons if (!(flags & FNM_NOESCAPE)) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) + if (pclen == 0 || pclen == (size_t)-1 || + pclen == (size_t)-2) return (FNM_NOMATCH); pattern += pclen; } Modified: stable/11/lib/libc/tests/gen/fnmatch_testcases.h ============================================================================== --- stable/11/lib/libc/tests/gen/fnmatch_testcases.h Mon Aug 14 23:46:10 2017 (r322523) +++ stable/11/lib/libc/tests/gen/fnmatch_testcases.h Tue Aug 15 00:54:16 2017 (r322524) @@ -131,7 +131,7 @@ struct testcase { { "\\(", "\\(", 0, FNM_NOMATCH }, { "\\a", "\\a", 0, FNM_NOMATCH }, { "\\", "\\", 0, FNM_NOMATCH }, - { "\\", "", 0, 0 }, + { "\\", "", 0, FNM_NOMATCH }, { "\\*", "\\*", FNM_NOESCAPE, 0 }, { "\\?", "\\?", FNM_NOESCAPE, 0 }, { "\\", "\\", FNM_NOESCAPE, 0 }, From owner-svn-src-stable-11@freebsd.org Tue Aug 15 01:22:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 610C9DD061E; Tue, 15 Aug 2017 01:22:41 +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 mx1.freebsd.org (Postfix) with ESMTPS id 2F52077AE6; Tue, 15 Aug 2017 01:22:41 +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 v7F1MeGx068432; Tue, 15 Aug 2017 01:22:40 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F1MdN2068429; Tue, 15 Aug 2017 01:22:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708150122.v7F1MdN2068429@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 15 Aug 2017 01:22: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: r322525 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322525 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.23 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, 15 Aug 2017 01:22:41 -0000 Author: kevans Date: Tue Aug 15 01:22:39 2017 New Revision: 322525 URL: https://svnweb.freebsd.org/changeset/base/322525 Log: bsdgrep: treat rgrep as grep -r and install rgrep symlink MFC r316473: bsdgrep: treat rgrep as grep -r MFC r316484: bsdgrep(1): create rgrep link Create a convenience rgrep link for bsdgrep(1) that observes 'grep -r' behavior. A follow-up to r316473. Approved by: emaste (mentor) Modified: stable/11/usr.bin/grep/Makefile stable/11/usr.bin/grep/grep.1 stable/11/usr.bin/grep/grep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/Makefile ============================================================================== --- stable/11/usr.bin/grep/Makefile Tue Aug 15 00:54:16 2017 (r322524) +++ stable/11/usr.bin/grep/Makefile Tue Aug 15 01:22:39 2017 (r322525) @@ -25,12 +25,14 @@ CFLAGS.gcc+= --param max-inline-insns-single=500 .if ${MK_BSD_GREP} == "yes" LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ ${BINDIR}/grep ${BINDIR}/fgrep \ + ${BINDIR}/grep ${BINDIR}/rgrep \ ${BINDIR}/grep ${BINDIR}/zgrep \ ${BINDIR}/grep ${BINDIR}/zegrep \ ${BINDIR}/grep ${BINDIR}/zfgrep MLINKS= grep.1 egrep.1 \ grep.1 fgrep.1 \ + grep.1 rgrep.1 \ grep.1 zgrep.1 \ grep.1 zegrep.1 \ grep.1 zfgrep.1 Modified: stable/11/usr.bin/grep/grep.1 ============================================================================== --- stable/11/usr.bin/grep/grep.1 Tue Aug 15 00:54:16 2017 (r322524) +++ stable/11/usr.bin/grep/grep.1 Tue Aug 15 01:22:39 2017 (r322525) @@ -34,7 +34,7 @@ .Dt GREP 1 .Os .Sh NAME -.Nm grep , egrep , fgrep , +.Nm grep , egrep , fgrep , rgrep , .Nm zgrep , zegrep , zfgrep .Nd file pattern searcher .Sh SYNOPSIS @@ -341,6 +341,10 @@ will only search a file until a match has been found, making searches potentially less expensive. .It Fl R , Fl r , Fl Fl recursive Recursively search subdirectories listed. +(i.e. force +.Nm grep +to behave as +.Nm rgrep ) . .It Fl S If .Fl R Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Tue Aug 15 00:54:16 2017 (r322524) +++ stable/11/usr.bin/grep/grep.c Tue Aug 15 01:22:39 2017 (r322525) @@ -361,6 +361,9 @@ main(int argc, char *argv[]) } else if (pn[0] == 'l' && pn[1] == 'z') { filebehave = FILE_LZMA; pn += 2; + } else if (pn[0] == 'r') { + dirbehave = DIR_RECURSE; + Hflag = true; } else if (pn[0] == 'z') { filebehave = FILE_GZIP; pn += 1; From owner-svn-src-stable-11@freebsd.org Tue Aug 15 08:29:05 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D724DC4507; Tue, 15 Aug 2017 08:29:05 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id 479A1653BC; Tue, 15 Aug 2017 08:29:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7F8T4bA038010; Tue, 15 Aug 2017 08:29:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F8T41G038004; Tue, 15 Aug 2017 08:29:04 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708150829.v7F8T41G038004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 15 Aug 2017 08:29: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: r322529 - stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Commit-Revision: 322529 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.23 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, 15 Aug 2017 08:29:05 -0000 Author: hselasky Date: Tue Aug 15 08:29:03 2017 New Revision: 322529 URL: https://svnweb.freebsd.org/changeset/base/322529 Log: MFC r322248: Fix for mlx4en(4) to properly call m_defrag(). The m_defrag() function can only defrag mbuf chains which have a valid mbuf packet header. In r291699 when the mlx4en(4) driver was converted into using BUSDMA(9), the call to m_defrag() was moved after the part of the transmit routine which strips the header from the mbuf chain. This effectivly disabled the mbuf defrag mechanism and such packets simply got dropped. This patch removes the stripping of mbufs from a chain and loads all mbufs using busdma. If busdma finds there are no segments, unload the DMA map and free the mbuf right away, because that means all data in the mbuf has been inlined in the TX ring. Else proceed as usual. Add a per-ring rounter for the number of defrag attempts and make sure the oversized_packets counter gets zeroed while at it. The counters are per-ring to avoid excessive cache misses in the TX path. Submitted by: mjoras@ Differential Revision: https://reviews.freebsd.org/D11683 Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c stable/11/sys/ofed/drivers/net/mlx4/en_port.c stable/11/sys/ofed/drivers/net/mlx4/en_tx.c stable/11/sys/ofed/drivers/net/mlx4/mlx4_en.h stable/11/sys/ofed/drivers/net/mlx4/mlx4_stats.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Tue Aug 15 07:21:47 2017 (r322528) +++ stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Tue Aug 15 08:29:03 2017 (r322529) @@ -2682,6 +2682,8 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_chksum_offload", CTLFLAG_RD, &priv->port_stats.tx_chksum_offload, "TX checksum offloads"); + SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "defrag_attempts", CTLFLAG_RD, + &priv->port_stats.defrag_attempts, "Oversized chains defragged"); /* Could strdup the names and add in a loop. This is simpler. */ SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_bytes", CTLFLAG_RD, @@ -2775,6 +2777,10 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p CTLFLAG_RD, &tx_ring->packets, "TX packets"); SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "bytes", CTLFLAG_RD, &tx_ring->bytes, "TX bytes"); + SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "tso_packets", + CTLFLAG_RD, &tx_ring->tso_packets, "TSO packets"); + SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "defrag_attempts", + CTLFLAG_RD, &tx_ring->defrag_attempts, "Oversized chains defragged"); } for (i = 0; i < priv->rx_ring_num; i++) { Modified: stable/11/sys/ofed/drivers/net/mlx4/en_port.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_port.c Tue Aug 15 07:21:47 2017 (r322528) +++ stable/11/sys/ofed/drivers/net/mlx4/en_port.c Tue Aug 15 08:29:03 2017 (r322529) @@ -224,11 +224,16 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u priv->port_stats.tx_chksum_offload = 0; priv->port_stats.queue_stopped = 0; priv->port_stats.wake_queue = 0; + priv->port_stats.oversized_packets = 0; + priv->port_stats.tso_packets = 0; + priv->port_stats.defrag_attempts = 0; for (i = 0; i < priv->tx_ring_num; i++) { priv->port_stats.tx_chksum_offload += priv->tx_ring[i]->tx_csum; priv->port_stats.queue_stopped += priv->tx_ring[i]->queue_stopped; priv->port_stats.wake_queue += priv->tx_ring[i]->wake_queue; priv->port_stats.oversized_packets += priv->tx_ring[i]->oversized_packets; + priv->port_stats.tso_packets += priv->tx_ring[i]->tso_packets; + priv->port_stats.defrag_attempts += priv->tx_ring[i]->defrag_attempts; } /* RX Statistics */ priv->pkstats.rx_packets = be64_to_cpu(mlx4_en_stats->RTOT_prio_0) + Modified: stable/11/sys/ofed/drivers/net/mlx4/en_tx.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_tx.c Tue Aug 15 07:21:47 2017 (r322528) +++ stable/11/sys/ofed/drivers/net/mlx4/en_tx.c Tue Aug 15 08:29:03 2017 (r322529) @@ -793,7 +793,7 @@ static int mlx4_en_xmit(struct mlx4_en_priv *priv, int num_pkts = DIV_ROUND_UP(payload_len, mss); ring->bytes += payload_len + (num_pkts * ihs); ring->packets += num_pkts; - priv->port_stats.tso_packets++; + ring->tso_packets++; /* store pointer to inline header */ dseg_inline = dseg; /* copy data inline */ @@ -814,20 +814,11 @@ static int mlx4_en_xmit(struct mlx4_en_priv *priv, int } m_adj(mb, ihs); - /* trim off empty mbufs */ - while (mb->m_len == 0) { - mb = m_free(mb); - /* check if all data has been inlined */ - if (mb == NULL) { - nr_segs = 0; - goto skip_dma; - } - } - err = bus_dmamap_load_mbuf_sg(ring->dma_tag, tx_info->dma_map, mb, segs, &nr_segs, BUS_DMA_NOWAIT); if (unlikely(err == EFBIG)) { /* Too many mbuf fragments */ + ring->defrag_attempts++; m = m_defrag(mb, M_NOWAIT); if (m == NULL) { ring->oversized_packets++; @@ -843,11 +834,18 @@ static int mlx4_en_xmit(struct mlx4_en_priv *priv, int ring->oversized_packets++; goto tx_drop; } - /* make sure all mbuf data is written to RAM */ - bus_dmamap_sync(ring->dma_tag, tx_info->dma_map, - BUS_DMASYNC_PREWRITE); + /* If there were no errors and we didn't load anything, don't sync. */ + if (nr_segs != 0) { + /* make sure all mbuf data is written to RAM */ + bus_dmamap_sync(ring->dma_tag, tx_info->dma_map, + BUS_DMASYNC_PREWRITE); + } else { + /* All data was inlined, free the mbuf. */ + bus_dmamap_unload(ring->dma_tag, tx_info->dma_map); + m_freem(mb); + mb = NULL; + } -skip_dma: /* compute number of DS needed */ ds_cnt = (dseg - ((volatile struct mlx4_wqe_data_seg *)tx_desc)) + nr_segs; Modified: stable/11/sys/ofed/drivers/net/mlx4/mlx4_en.h ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/mlx4_en.h Tue Aug 15 07:21:47 2017 (r322528) +++ stable/11/sys/ofed/drivers/net/mlx4/mlx4_en.h Tue Aug 15 08:29:03 2017 (r322529) @@ -278,6 +278,8 @@ struct mlx4_en_tx_ring { unsigned long queue_stopped; unsigned long oversized_packets; unsigned long wake_queue; + unsigned long tso_packets; + unsigned long defrag_attempts; struct mlx4_bf bf; bool bf_enabled; int hwtstamp_tx_type; Modified: stable/11/sys/ofed/drivers/net/mlx4/mlx4_stats.h ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/mlx4_stats.h Tue Aug 15 07:21:47 2017 (r322528) +++ stable/11/sys/ofed/drivers/net/mlx4/mlx4_stats.h Tue Aug 15 08:29:03 2017 (r322529) @@ -126,6 +126,7 @@ struct mlx4_en_port_stats { unsigned long rx_chksum_good; unsigned long rx_chksum_none; unsigned long tx_chksum_offload; + unsigned long defrag_attempts; }; struct mlx4_en_perf_stats { From owner-svn-src-stable-11@freebsd.org Tue Aug 15 09:36:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2E0FDC7B59; Tue, 15 Aug 2017 09:36:01 +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 mx1.freebsd.org (Postfix) with ESMTPS id BAED567534; Tue, 15 Aug 2017 09:36:01 +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 v7F9a0D3066452; Tue, 15 Aug 2017 09:36:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F9a0CD066451; Tue, 15 Aug 2017 09:36:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708150936.v7F9a0CD066451@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 15 Aug 2017 09:36: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: r322532 - stable/11/sys/dev/hwpmc X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/dev/hwpmc X-SVN-Commit-Revision: 322532 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.23 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, 15 Aug 2017 09:36:02 -0000 Author: kib Date: Tue Aug 15 09:36:00 2017 New Revision: 322532 URL: https://svnweb.freebsd.org/changeset/base/322532 Log: MFC r322256: Fix logic error in the the assert, causing the condition to be always true. PR: 217741 Modified: stable/11/sys/dev/hwpmc/hwpmc_piv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hwpmc/hwpmc_piv.c ============================================================================== --- stable/11/sys/dev/hwpmc/hwpmc_piv.c Tue Aug 15 09:21:46 2017 (r322531) +++ stable/11/sys/dev/hwpmc/hwpmc_piv.c Tue Aug 15 09:36:00 2017 (r322532) @@ -809,8 +809,8 @@ p4_config_pmc(int cpu, int ri, struct pmc *pm) mtx_lock_spin(&pc->pc_mtx); cfgflags = P4_PCPU_GET_CFGFLAGS(pc,ri); - KASSERT(cfgflags >= 0 || cfgflags <= 3, - ("[p4,%d] illegal cfgflags cfg=%d on cpu=%d ri=%d", __LINE__, + KASSERT((cfgflags & ~0x3) == 0, + ("[p4,%d] illegal cfgflags cfg=%#x on cpu=%d ri=%d", __LINE__, cfgflags, cpu, ri)); KASSERT(cfgflags == 0 || phw->phw_pmc, @@ -835,8 +835,8 @@ p4_config_pmc(int cpu, int ri, struct pmc *pm) phw->phw_pmc = NULL; } - KASSERT(cfgflags >= 0 || cfgflags <= 3, - ("[p4,%d] illegal runcount cfg=%d on cpu=%d ri=%d", __LINE__, + KASSERT((cfgflags & ~0x3) == 0, + ("[p4,%d] illegal runcount cfg=%#x on cpu=%d ri=%d", __LINE__, cfgflags, cpu, ri)); P4_PCPU_SET_CFGFLAGS(pc,ri,cfgflags); From owner-svn-src-stable-11@freebsd.org Tue Aug 15 09:40:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E5C5DC7F4F; Tue, 15 Aug 2017 09:40:58 +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 mx1.freebsd.org (Postfix) with ESMTPS id 3CE1B677CE; Tue, 15 Aug 2017 09:40:58 +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 v7F9evs7066688; Tue, 15 Aug 2017 09:40:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F9evNg066687; Tue, 15 Aug 2017 09:40:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708150940.v7F9evNg066687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 15 Aug 2017 09:40: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: r322533 - stable/11/lib/libc/string X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/lib/libc/string X-SVN-Commit-Revision: 322533 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.23 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, 15 Aug 2017 09:40:58 -0000 Author: kib Date: Tue Aug 15 09:40:57 2017 New Revision: 322533 URL: https://svnweb.freebsd.org/changeset/base/322533 Log: MFC r322426: Fix indent. Modified: stable/11/lib/libc/string/memset_s.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/string/memset_s.c ============================================================================== --- stable/11/lib/libc/string/memset_s.c Tue Aug 15 09:36:00 2017 (r322532) +++ stable/11/lib/libc/string/memset_s.c Tue Aug 15 09:40:57 2017 (r322533) @@ -49,7 +49,7 @@ memset_s(void *s, rsize_t smax, int c, rsize_t n) __throw_constraint_handler_s("memset_s : s is NULL", ret); } else if (smax > RSIZE_MAX) { __throw_constraint_handler_s("memset_s : smax > RSIZE_MAX", - ret); + ret); } else if (n > RSIZE_MAX) { __throw_constraint_handler_s("memset_s : n > RSIZE_MAX", ret); } else { From owner-svn-src-stable-11@freebsd.org Tue Aug 15 09:44:20 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55AD7DC8381; Tue, 15 Aug 2017 09:44:20 +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 mx1.freebsd.org (Postfix) with ESMTPS id 2433367B90; Tue, 15 Aug 2017 09:44:20 +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 v7F9iJDb070371; Tue, 15 Aug 2017 09:44:19 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7F9iJnf070370; Tue, 15 Aug 2017 09:44:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708150944.v7F9iJnf070370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 15 Aug 2017 09:44: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: r322534 - stable/11/lib/libc/x86/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/lib/libc/x86/sys X-SVN-Commit-Revision: 322534 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.23 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, 15 Aug 2017 09:44:20 -0000 Author: kib Date: Tue Aug 15 09:44:18 2017 New Revision: 322534 URL: https://svnweb.freebsd.org/changeset/base/322534 Log: MFC r322456: On i386 with CPUID but without SSE2, set lfence_works to LMB_NONE instead of looping. Modified: stable/11/lib/libc/x86/sys/__vdso_gettc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/x86/sys/__vdso_gettc.c ============================================================================== --- stable/11/lib/libc/x86/sys/__vdso_gettc.c Tue Aug 15 09:40:57 2017 (r322533) +++ stable/11/lib/libc/x86/sys/__vdso_gettc.c Tue Aug 15 09:44:18 2017 (r322534) @@ -101,6 +101,7 @@ init_fence(void) #if defined(__i386__) u_int cpuid_supported, p[4]; + lfence_works = LMB_NONE; __asm __volatile( " pushfl\n" " popl %%eax\n" @@ -121,8 +122,7 @@ init_fence(void) cpuidp(0x1, p); if ((p[3] & CPUID_SSE2) != 0) lfence_works = select_lmb(); - } else - lfence_works = LMB_NONE; + } #elif defined(__amd64__) lfence_works = select_lmb(); #else From owner-svn-src-stable-11@freebsd.org Tue Aug 15 12:30:12 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D20D7DD0F95; Tue, 15 Aug 2017 12:30:12 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id 9F2606D819; Tue, 15 Aug 2017 12:30:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7FCUBPE035392; Tue, 15 Aug 2017 12:30:11 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7FCUBRr035391; Tue, 15 Aug 2017 12:30:11 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708151230.v7FCUBRr035391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 15 Aug 2017 12:30: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: r322537 - stable/11/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 322537 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.23 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, 15 Aug 2017 12:30:12 -0000 Author: hselasky Date: Tue Aug 15 12:30:11 2017 New Revision: 322537 URL: https://svnweb.freebsd.org/changeset/base/322537 Log: MFC r322251: Make sure the received IP header gets 32-bit aligned for short packets in the mlx5en(4) driver. Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Tue Aug 15 12:28:16 2017 (r322536) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Tue Aug 15 12:30:11 2017 (r322537) @@ -355,9 +355,11 @@ mlx5e_poll_rx_cq(struct mlx5e_rq *rq, int budget) rq->stats.wqe_err++; goto wq_ll_pop; } - - if (MHLEN >= byte_cnt && + if ((MHLEN - MLX5E_NET_IP_ALIGN) >= byte_cnt && (mb = m_gethdr(M_NOWAIT, MT_DATA)) != NULL) { + /* get IP header aligned */ + mb->m_data += MLX5E_NET_IP_ALIGN; + bcopy(rq->mbuf[wqe_counter].data, mtod(mb, caddr_t), byte_cnt); } else { From owner-svn-src-stable-11@freebsd.org Tue Aug 15 12:56:44 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1788BDD260A; Tue, 15 Aug 2017 12:56:44 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id D575D6EAA4; Tue, 15 Aug 2017 12:56:43 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7FCugf2047753; Tue, 15 Aug 2017 12:56:42 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7FCugIv047752; Tue, 15 Aug 2017 12:56:42 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201708151256.v7FCugIv047752@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 15 Aug 2017 12:56: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: r322539 - stable/11/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 322539 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.23 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, 15 Aug 2017 12:56:44 -0000 Author: hselasky Date: Tue Aug 15 12:56:42 2017 New Revision: 322539 URL: https://svnweb.freebsd.org/changeset/base/322539 Log: MFC r322250: Count drop events due to lack of PCI bandwidth as queue drops and not as input errors in the mlx5en(4) driver. This improves the sysadmin view of physical port errors. Submitted by: gallatin@ Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Tue Aug 15 12:54:19 2017 (r322538) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Tue Aug 15 12:56:42 2017 (r322539) @@ -552,7 +552,6 @@ mlx5e_update_stats_work(struct work_struct *work) priv->stats.pport.alignment_err + priv->stats.pport.check_seq_err + priv->stats.pport.crc_align_errors + - priv->stats.pport.drop_events + priv->stats.pport.in_range_len_errors + priv->stats.pport.jabbers + priv->stats.pport.out_of_range_len + @@ -561,7 +560,8 @@ mlx5e_update_stats_work(struct work_struct *work) priv->stats.pport.too_long_errors + priv->stats.pport.undersize_pkts + priv->stats.pport.unsupported_op_rx; - ifp->if_iqdrops = s->rx_out_of_buffer; + ifp->if_iqdrops = s->rx_out_of_buffer + + priv->stats.pport.drop_events; ifp->if_opackets = s->tx_packets; ifp->if_oerrors = s->tx_error_packets; ifp->if_snd.ifq_drops = s->tx_queue_dropped; @@ -2467,7 +2467,6 @@ mlx5e_get_counter(struct ifnet *ifp, ift_counter cnt) priv->stats.pport.alignment_err + priv->stats.pport.check_seq_err + priv->stats.pport.crc_align_errors + - priv->stats.pport.drop_events + priv->stats.pport.in_range_len_errors + priv->stats.pport.jabbers + priv->stats.pport.out_of_range_len + @@ -2478,7 +2477,8 @@ mlx5e_get_counter(struct ifnet *ifp, ift_counter cnt) priv->stats.pport.unsupported_op_rx; break; case IFCOUNTER_IQDROPS: - retval = priv->stats.vport.rx_out_of_buffer; + retval = priv->stats.vport.rx_out_of_buffer + + priv->stats.pport.drop_events; break; case IFCOUNTER_OPACKETS: retval = priv->stats.vport.tx_packets; From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:12:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CEC43DD7453; Wed, 16 Aug 2017 00:12: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 mx1.freebsd.org (Postfix) with ESMTPS id 9853B65E9F; Wed, 16 Aug 2017 00:12: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 v7G0COtt024706; Wed, 16 Aug 2017 00:12:24 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0CMMl024686; Wed, 16 Aug 2017 00:12:22 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160012.v7G0CMMl024686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:12: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: r322555 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Commit-Revision: 322555 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.23 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, 16 Aug 2017 00:12:25 -0000 Author: kevans Date: Wed Aug 16 00:12:22 2017 New Revision: 322555 URL: https://svnweb.freebsd.org/changeset/base/322555 Log: bsdgrep: Fix matching behavior and add regression tests MFC r316477: bsdgrep: fix matching behaviour - Set REG_NOTBOL if we've already matched beginning of line and we're examining later parts - For each pattern we examine, apply it to the remaining bits of the line rather than (potentially) smaller subsets - Check for REG_NOSUB after we've looked at all patterns initially matching the line - Keep track of the last match we made to later determine if we're simply not matching any longer or if we need to proceed another byte because we hit a zero-length match - Match the earliest and longest bit of each line before moving the beginning of what we match to further in the line, past the end of the longest match; this generally matches how gnugrep(1) seems to behave, and seems like pretty good behavior to me - Finally, bail out of printing any matches if we were set to print all (empty pattern) but -o (output matches) was set MFC r316489: bsdgrep: Initialize vars to avoid a false positive GCC warning MFC r316491: bsdgrep: revert color changes from r316477 r316477 changed the color output to match exactly the in-tree GNU grep, but introduces unnecessary escape sequences. MFC r316536: bsdgrep: create additional tests for coverage on recent fixes Create additional tests to cover regressions that were discovered by PRs linked to reviews D10098, D10102, and D10104. It is worth noting that neither bsdgrep(1) nor gnugrep(1) in the base system currently pass all of these tests, and gnugrep(1) not quite being up to snuff was also noted in at least one of the PRs. MFC r317052: bsdgrep: fix zero-length matches without the -o flag r316477 broke zero-length matches when not using the -o flag, by skipping over them entirely. Add a regression test so that it doesn't break again in the future. PR: 175314, 180990, 181263, 195763, 197531, 197555, 202022, 209116 Approved by: emaste (mentor, blanket MFC) Relnotes: yes Added: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_c.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_c.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_escmap.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_escmap.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out - copied unchanged from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/tests/Makefile stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.in) @@ -0,0 +1 @@ +abcd* Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_a.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_a.out) @@ -0,0 +1 @@ +abcd* Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.in) @@ -0,0 +1,5 @@ +fojeiwuroiuwet +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc + Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_b.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_b.out) @@ -0,0 +1,3 @@ +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_c.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_c.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_color_c.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_color_c.out) @@ -0,0 +1,3 @@ +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_escmap.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_escmap.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_escmap.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_escmap.in) @@ -0,0 +1 @@ +f.oo Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in) @@ -0,0 +1,2 @@ +Fish zebra monkey suits + Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in) @@ -0,0 +1 @@ +01:1:01 Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out) @@ -0,0 +1,3 @@ +0 +: +:0 Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in) @@ -0,0 +1 @@ +1:1:01 Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out) @@ -0,0 +1,2 @@ +: +:0 Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in) @@ -0,0 +1 @@ +bla bla Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out) @@ -0,0 +1,2 @@ +bla +bla Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in) @@ -0,0 +1,3 @@ +bla +bla + Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in) @@ -0,0 +1 @@ +abcdef Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out (from r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out Wed Aug 16 00:12:22 2017 (r322555, copy of r316536, head/contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out) @@ -0,0 +1 @@ +ab Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:04:57 2017 (r322554) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:12:22 2017 (r322555) @@ -226,10 +226,116 @@ context2_body() atf_check -o file:"$(atf_get_srcdir)/d_context2_c.out" \ grep -z -C1 cod test1 test2 } +# Begin FreeBSD +atf_test_case oflag_zerolen +oflag_zerolen_head() +{ + atf_set "descr" "Check behavior of zero-length matches with -o flag (PR 195763)" +} +oflag_zerolen_body() +{ + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_a.out" \ + grep -Eo '(^|:)0*' "$(atf_get_srcdir)/d_oflag_zerolen_a.in" + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_b.out" \ + grep -Eo '(^|:)0*' "$(atf_get_srcdir)/d_oflag_zerolen_b.in" + + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_c.out" \ + grep -Eo '[[:alnum:]]*' "$(atf_get_srcdir)/d_oflag_zerolen_c.in" + + atf_check -o empty grep -Eo '' "$(atf_get_srcdir)/d_oflag_zerolen_d.in" + + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_e.out" \ + grep -o -e 'ab' -e 'bc' "$(atf_get_srcdir)/d_oflag_zerolen_e.in" + + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_e.out" \ + grep -o -e 'bc' -e 'ab' "$(atf_get_srcdir)/d_oflag_zerolen_e.in" +} + +atf_test_case xflag +xflag_head() +{ + atf_set "descr" "Check that we actually get a match with -x flag (PR 180990)" +} +xflag_body() +{ + echo 128 > match_file + seq 1 128 > pattern_file + grep -xf pattern_file match_file +} + +atf_test_case color +color_head() +{ + atf_set "descr" "Check --color support" +} +color_body() +{ + echo 'abcd*' > grepfile + echo 'abc$' >> grepfile + echo '^abc' >> grepfile + + atf_check -o file:"$(atf_get_srcdir)/d_color_a.out" \ + grep --color=auto -e '.*' -e 'a' "$(atf_get_srcdir)/d_color_a.in" + + atf_check -o file:"$(atf_get_srcdir)/d_color_b.out" \ + grep --color=auto -f grepfile "$(atf_get_srcdir)/d_color_b.in" + + atf_check -o file:"$(atf_get_srcdir)/d_color_c.out" \ + grep --color=always -f grepfile "$(atf_get_srcdir)/d_color_b.in" +} + +atf_test_case f_file_empty +f_file_empty_head() +{ + atf_set "descr" "Check for handling of a null byte in empty file, specified by -f (PR 202022)" +} +f_file_empty_body() +{ + printf "\0\n" > nulpat + + atf_check -s exit:1 grep -f nulpat "$(atf_get_srcdir)/d_f_file_empty.in" +} + +atf_test_case escmap +escmap_head() +{ + atf_set "descr" "Check proper handling of escaped vs. unescaped dot expressions (PR 175314)" +} +escmap_body() +{ + atf_check -s exit:1 grep -o 'f.o\.' "$(atf_get_srcdir)/d_escmap.in" + atf_check -o not-empty grep -o 'f.o.' "$(atf_get_srcdir)/d_escmap.in" +} + +atf_test_case egrep_empty_invalid +egrep_empty_invalid_head() +{ + atf_set "descr" "Check for handling of an invalid empty pattern (PR 194823)" +} +egrep_empty_invalid_body() +{ + atf_check -s exit:1 egrep '{' /dev/null +} + +atf_test_case zerolen +zerolen_head() +{ + atf_set "descr" "Check for successful zero-length matches with ^$" +} +zerolen_body() +{ + printf "Eggs\n\nCheese" > test1 + + atf_check -o inline:"\n" grep -e "^$" test1 + + atf_check -o inline:"Eggs\nCheese\n" grep -v -e "^$" test1 +} +# End FreeBSD + atf_init_test_cases() { - atf_add_test_case basic + atf_add_test_case basic atf_add_test_case binary atf_add_test_case recurse atf_add_test_case recurse_symlink @@ -245,4 +351,13 @@ atf_init_test_cases() atf_add_test_case zgrep atf_add_test_case nonexistent atf_add_test_case context2 +# Begin FreeBSD + atf_add_test_case oflag_zerolen + atf_add_test_case xflag + atf_add_test_case color + atf_add_test_case f_file_empty + atf_add_test_case escmap + atf_add_test_case egrep_empty_invalid + atf_add_test_case zerolen +# End FreeBSD } Modified: stable/11/usr.bin/grep/tests/Makefile ============================================================================== --- stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 00:04:57 2017 (r322554) +++ stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 00:12:22 2017 (r322555) @@ -8,6 +8,11 @@ ${PACKAGE}FILES+= d_basic.out ${PACKAGE}FILES+= d_begin_end_a.out ${PACKAGE}FILES+= d_begin_end_b.out ${PACKAGE}FILES+= d_binary.out +${PACKAGE}FILES+= d_color_a.in +${PACKAGE}FILES+= d_color_a.out +${PACKAGE}FILES+= d_color_b.in +${PACKAGE}FILES+= d_color_b.out +${PACKAGE}FILES+= d_color_c.out ${PACKAGE}FILES+= d_context2_a.out ${PACKAGE}FILES+= d_context2_b.out ${PACKAGE}FILES+= d_context2_c.out @@ -18,12 +23,23 @@ ${PACKAGE}FILES+= d_context_b.out ${PACKAGE}FILES+= d_context_c.out ${PACKAGE}FILES+= d_context_d.out ${PACKAGE}FILES+= d_egrep.out +${PACKAGE}FILES+= d_escmap.in +${PACKAGE}FILES+= d_f_file_empty.in ${PACKAGE}FILES+= d_file_exp.in ${PACKAGE}FILES+= d_file_exp.out ${PACKAGE}FILES+= d_ignore_case.out ${PACKAGE}FILES+= d_input ${PACKAGE}FILES+= d_invert.in ${PACKAGE}FILES+= d_invert.out +${PACKAGE}FILES+= d_oflag_zerolen_a.in +${PACKAGE}FILES+= d_oflag_zerolen_a.out +${PACKAGE}FILES+= d_oflag_zerolen_b.in +${PACKAGE}FILES+= d_oflag_zerolen_b.out +${PACKAGE}FILES+= d_oflag_zerolen_c.in +${PACKAGE}FILES+= d_oflag_zerolen_c.out +${PACKAGE}FILES+= d_oflag_zerolen_d.in +${PACKAGE}FILES+= d_oflag_zerolen_e.in +${PACKAGE}FILES+= d_oflag_zerolen_e.out ${PACKAGE}FILES+= d_recurse.out ${PACKAGE}FILES+= d_recurse_symlink.err ${PACKAGE}FILES+= d_recurse_symlink.out Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 00:04:57 2017 (r322554) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 00:12:22 2017 (r322555) @@ -271,28 +271,32 @@ static int procline(struct str *l, int nottext) { regmatch_t matches[MAX_LINE_MATCHES]; - regmatch_t pmatch; - size_t st = 0; + regmatch_t pmatch, lastmatch; + size_t st = 0, nst = 0; unsigned int i; - int c = 0, m = 0, r = 0; + int c = 0, m = 0, r = 0, lastmatches = 0, leflags = eflags; + int startm = 0; + /* Initialize to avoid a false positive warning from GCC. */ + lastmatch.rm_so = lastmatch.rm_eo = 0; + /* Loop to process the whole line */ while (st <= l->len) { - pmatch.rm_so = st; - pmatch.rm_eo = l->len; - + lastmatches = 0; + startm = m; + if (st > 0) + leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ for (i = 0; i < patterns; i++) { + pmatch.rm_so = st; + pmatch.rm_eo = l->len; if (fg_pattern[i].pattern) r = fastexec(&fg_pattern[i], - l->dat, 1, &pmatch, eflags); + l->dat, 1, &pmatch, leflags); else r = regexec(&r_pattern[i], l->dat, 1, - &pmatch, eflags); + &pmatch, leflags); r = (r == 0) ? 0 : REG_NOMATCH; - st = (cflags & REG_NOSUB) - ? (size_t)l->len - : (size_t)pmatch.rm_eo; if (r == REG_NOMATCH) continue; /* Check for full match */ @@ -319,10 +323,26 @@ procline(struct str *l, int nottext) r = REG_NOMATCH; } if (r == 0) { + lastmatches++; + lastmatch = pmatch; if (m == 0) c++; - if (m < MAX_LINE_MATCHES) - matches[m++] = pmatch; + + if (m < MAX_LINE_MATCHES) { + /* Replace previous match if the new one is earlier and/or longer */ + if (m > startm) { + if (pmatch.rm_so < matches[m-1].rm_so || + (pmatch.rm_so == matches[m-1].rm_so && (pmatch.rm_eo - pmatch.rm_so) > (matches[m-1].rm_eo - matches[m-1].rm_so))) { + matches[m-1] = pmatch; + nst = pmatch.rm_eo; + } + } else { + /* Advance as normal if not */ + matches[m++] = pmatch; + nst = pmatch.rm_eo; + } + } + /* matches - skip further patterns */ if ((color == NULL && !oflag) || qflag || lflag) @@ -339,8 +359,19 @@ procline(struct str *l, int nottext) if (!wflag && ((color == NULL && !oflag) || qflag || lflag || Lflag)) break; - if (st == (size_t)pmatch.rm_so) - break; /* No matches */ + /* If we didn't have any matches or REG_NOSUB set */ + if (lastmatches == 0 || (cflags & REG_NOSUB)) + nst = l->len; + + if (lastmatches == 0) + /* No matches */ + break; + else if (st == nst && lastmatch.rm_so == lastmatch.rm_eo) + /* Zero-length match -- advance one more so we don't get stuck */ + nst++; + + /* Advance st based on previous matches */ + st = nst; } @@ -439,6 +470,10 @@ printline(struct str *line, int sep, regmatch_t *match size_t a = 0; int i, n = 0; + /* If matchall, everything matches but don't actually print for -o */ + if (oflag && matchall) + return; + if (!hflag) { if (!nullflag) { fputs(line->file, stdout); @@ -465,6 +500,9 @@ printline(struct str *line, int sep, regmatch_t *match /* --color and -o */ if ((oflag || color) && m > 0) { for (i = 0; i < m; i++) { + /* Don't output zero length matches */ + if (matches[i].rm_so == matches[i].rm_eo) + continue; if (!oflag) fwrite(line->dat + a, matches[i].rm_so - a, 1, stdout); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:20:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9486FDD7CB3; Wed, 16 Aug 2017 00:20:00 +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 mx1.freebsd.org (Postfix) with ESMTPS id 702D666366; Wed, 16 Aug 2017 00:20:00 +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 v7G0JxDF025967; Wed, 16 Aug 2017 00:19:59 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0JxQx025966; Wed, 16 Aug 2017 00:19:59 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160019.v7G0JxQx025966@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:19: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: r322556 - stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Commit-Revision: 322556 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.23 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, 16 Aug 2017 00:20:00 -0000 Author: kevans Date: Wed Aug 16 00:19:59 2017 New Revision: 322556 URL: https://svnweb.freebsd.org/changeset/base/322556 Log: MFC r316750 (ngie): Fix expectations for testcases per bsdgrep vs gnu grep The following failures occur with various versions of grep: BSD grep: - :context - :context2 GNU grep (base): - :color - :oflag_zerolen GNU grep (ports): - :recurse_symlink Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:12:22 2017 (r322555) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:19:59 2017 (r322556) @@ -69,6 +69,12 @@ recurse_symlink_head() } recurse_symlink_body() { + # Begin FreeBSD + grep_type + if [ $? -eq $GREP_TYPE_GNU ]; then + atf_expect_fail "this test doesn't pass with gnu grep from ports" + fi + # End FreeBSD mkdir -p test/c/d (cd test/c/d && ln -s ../d .) echo "Test string" > test/c/match @@ -153,6 +159,12 @@ context_head() } context_body() { + # Begin FreeBSD + grep_type + if [ $? -eq $GREP_TYPE_BSD ]; then + atf_expect_fail "this test doesn't pass with BSD grep yet" + fi + # End FreeBSD cp $(atf_get_srcdir)/d_context_*.* . atf_check -o file:d_context_a.out grep -C2 bamboo d_context_a.in @@ -214,6 +226,12 @@ context2_head() } context2_body() { + # Begin FreeBSD + grep_type + if [ $? -eq $GREP_TYPE_BSD ]; then + atf_expect_fail "this test doesn't pass with BSD grep yet" + fi + # End FreeBSD printf "haddock\000cod\000plaice\000" > test1 printf "mackeral\000cod\000crab\000" > test2 @@ -227,6 +245,38 @@ context2_body() grep -z -C1 cod test1 test2 } # Begin FreeBSD + +# What grep(1) are we working with? +# - 0 : bsdgrep +# - 1 : gnu grep 2.51 (base) +# - 2 : gnu grep (ports) +GREP_TYPE_BSD=0 +GREP_TYPE_GNU_FREEBSD=1 +GREP_TYPE_GNU=2 +GREP_TYPE_UNKNOWN=3 + +grep_type() +{ + local grep_version=$(grep --version) + + case "$grep_version" in + *"BSD grep"*) + return $GREP_TYPE_BSD + ;; + *"GNU grep"*) + case "$grep_version" in + *2.5.1-FreeBSD*) + return $GREP_TYPE_GNU_FREEBSD + ;; + *) + return $GREP_TYPE_GNU + ;; + esac + ;; + esac + atf_fail "unknown grep type: $grep_version" +} + atf_test_case oflag_zerolen oflag_zerolen_head() { @@ -234,6 +284,11 @@ oflag_zerolen_head() } oflag_zerolen_body() { + grep_type + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test doesn't pass with gnu grep in base" + fi + atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_a.out" \ grep -Eo '(^|:)0*' "$(atf_get_srcdir)/d_oflag_zerolen_a.in" @@ -271,6 +326,11 @@ color_head() } color_body() { + grep_type + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test doesn't pass with gnu grep in base" + fi + echo 'abcd*' > grepfile echo 'abc$' >> grepfile echo '^abc' >> grepfile From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:24:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B175DDD8178; Wed, 16 Aug 2017 00:24:00 +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 mx1.freebsd.org (Postfix) with ESMTPS id 881E4667AA; Wed, 16 Aug 2017 00:24:00 +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 v7G0NxAi029803; Wed, 16 Aug 2017 00:23:59 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0NxG3029799; Wed, 16 Aug 2017 00:23:59 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160023.v7G0NxG3029799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:23: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: r322557 - in stable/11/usr.bin/grep: . regex X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . regex X-SVN-Commit-Revision: 322557 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.23 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, 16 Aug 2017 00:24:00 -0000 Author: kevans Date: Wed Aug 16 00:23:59 2017 New Revision: 322557 URL: https://svnweb.freebsd.org/changeset/base/322557 Log: MFC r316492: bsdgrep(1): Rip out "xmalloc" bits xmalloc was a debug malloc implementation, but the x{malloc,calloc,free} functions default to calling the malloc(3) equivalents. Instead of relying on this malloc shim, we can devise better ways to debug malloc issues that aren't misleading upon initial inspection. (I.e., using jemalloc's various built-in debugging capabilities.) Approved by: emaste (mentor, blanket MFC) Deleted: stable/11/usr.bin/grep/regex/xmalloc.c stable/11/usr.bin/grep/regex/xmalloc.h Modified: stable/11/usr.bin/grep/Makefile stable/11/usr.bin/grep/regex/fastmatch.c stable/11/usr.bin/grep/regex/tre-compile.c stable/11/usr.bin/grep/regex/tre-fastmatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/Makefile ============================================================================== --- stable/11/usr.bin/grep/Makefile Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/Makefile Wed Aug 16 00:23:59 2017 (r322557) @@ -17,7 +17,7 @@ SRCS= file.c grep.c queue.c util.c # Extra files ported backported form some regex improvements .PATH: ${.CURDIR}/regex -SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c xmalloc.c +SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c CFLAGS+=-I${.CURDIR}/regex CFLAGS.gcc+= --param max-inline-insns-single=500 Modified: stable/11/usr.bin/grep/regex/fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/fastmatch.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/fastmatch.c Wed Aug 16 00:23:59 2017 (r322557) @@ -34,7 +34,6 @@ #include #include "tre-fastmatch.h" -#include "xmalloc.h" int tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) Modified: stable/11/usr.bin/grep/regex/tre-compile.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-compile.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/tre-compile.c Wed Aug 16 00:23:59 2017 (r322557) @@ -9,8 +9,6 @@ #include #include -#include "xmalloc.h" - int tre_convert_pattern(const char *regex, size_t n, tre_char_t **w, size_t *wn) @@ -19,7 +17,7 @@ tre_convert_pattern(const char *regex, size_t n, tre_c tre_char_t *wregex; size_t wlen; - wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); + wregex = malloc(sizeof(tre_char_t) * (n + 1)); if (wregex == NULL) return REG_ESPACE; @@ -60,13 +58,13 @@ tre_convert_pattern(const char *regex, size_t n, tre_c consumed = 1; else { - xfree(wregex); + free(wregex); return REG_BADPAT; } break; case -1: DPRINT(("mbrtowc: error %d: %s.\n", errno, strerror(errno))); - xfree(wregex); + free(wregex); return REG_BADPAT; case -2: /* The last character wasn't complete. Let's not call it a @@ -98,6 +96,6 @@ void tre_free_pattern(tre_char_t *wregex) { #if TRE_WCHAR - xfree(wregex); + free(wregex); #endif } Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:19:59 2017 (r322556) +++ stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:23:59 2017 (r322557) @@ -42,7 +42,6 @@ #include "hashtable.h" #include "tre-fastmatch.h" -#include "xmalloc.h" static int fastcmp(const fastmatch_t *fg, const void *data, tre_str_type_t type); @@ -53,9 +52,9 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FAIL_COMP(errcode) \ { \ if (fg->pattern) \ - xfree(fg->pattern); \ + free(fg->pattern); \ if (fg->wpattern) \ - xfree(fg->wpattern); \ + free(fg->wpattern); \ if (fg->qsBc_table) \ hashtable_free(fg->qsBc_table); \ fg = NULL; \ @@ -92,7 +91,7 @@ static int fastcmp(const fastmatch_t *fg, const void * if (siz == (size_t)-1) \ return REG_BADPAT; \ fg->len = siz; \ - fg->pattern = xmalloc(siz + 1); \ + fg->pattern = malloc(siz + 1); \ if (fg->pattern == NULL) \ return REG_ESPACE; \ wcstombs(fg->pattern, fg->wpattern, siz); \ @@ -340,7 +339,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS \ if (!fg->hasdot) \ { \ - fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ + fg->sbmGs = malloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ return REG_ESPACE; \ if (fg->len == 1) \ @@ -356,7 +355,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS_WIDE \ if (!fg->hasdot) \ { \ - fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ + fg->bmGs = malloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \ return REG_ESPACE; \ if (fg->wlen == 1) \ @@ -376,13 +375,13 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ if (fg->icase) \ { \ - wp = xmalloc(plen * sizeof(tre_char_t)); \ + wp = malloc(plen * sizeof(tre_char_t)); \ if (wp == NULL) \ return REG_ESPACE; \ for (unsigned int i = 0; i < plen; i++) \ wp[i] = towlower(pat[i]); \ _CALC_BMGS(arr, wp, plen); \ - xfree(wp); \ + free(wp); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -391,13 +390,13 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ if (fg->icase) \ { \ - p = xmalloc(plen); \ + p = malloc(plen); \ if (p == NULL) \ return REG_ESPACE; \ for (unsigned int i = 0; i < plen; i++) \ p[i] = tolower((unsigned char)pat[i]); \ _CALC_BMGS(arr, p, plen); \ - xfree(p); \ + free(p); \ } \ else \ _CALC_BMGS(arr, pat, plen); \ @@ -408,7 +407,7 @@ static int fastcmp(const fastmatch_t *fg, const void * { \ int f = 0, g; \ \ - int *suff = xmalloc(plen * sizeof(int)); \ + int *suff = malloc(plen * sizeof(int)); \ if (suff == NULL) \ return REG_ESPACE; \ \ @@ -440,7 +439,7 @@ static int fastcmp(const fastmatch_t *fg, const void * for (unsigned int i = 0; i <= plen - 2; i++) \ arr[plen - 1 - suff[i]] = plen - 1 - i; \ \ - xfree(suff); \ + free(suff); \ } /* @@ -449,7 +448,7 @@ static int fastcmp(const fastmatch_t *fg, const void * */ #define SAVE_PATTERN(src, srclen, dst, dstlen) \ dstlen = srclen; \ - dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + dst = malloc((dstlen + 1) * sizeof(tre_char_t)); \ if (dst == NULL) \ return REG_ESPACE; \ if (dstlen > 0) \ @@ -489,11 +488,11 @@ static int fastcmp(const fastmatch_t *fg, const void * if (n == 0) \ { \ fg->matchall = true; \ - fg->pattern = xmalloc(sizeof(char)); \ + fg->pattern = malloc(sizeof(char)); \ if (!fg->pattern) \ FAIL_COMP(REG_ESPACE); \ fg->pattern[0] = '\0'; \ - fg->wpattern = xmalloc(sizeof(tre_char_t)); \ + fg->wpattern = malloc(sizeof(tre_char_t)); \ if (!fg->wpattern) \ FAIL_COMP(REG_ESPACE); \ fg->wpattern[0] = TRE_CHAR('\0'); \ @@ -580,7 +579,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; - tmp = xmalloc((n + 1) * sizeof(tre_char_t)); + tmp = malloc((n + 1) * sizeof(tre_char_t)); if (tmp == NULL) return REG_ESPACE; @@ -631,10 +630,10 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa if (escaped) { if (!_escmap) - _escmap = xmalloc(n * sizeof(bool)); + _escmap = malloc(n * sizeof(bool)); if (!_escmap) { - xfree(tmp); + free(tmp); return REG_ESPACE; } _escmap[i] = true; @@ -688,7 +687,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa } continue; badpat: - xfree(tmp); + free(tmp); DPRINT(("tre_compile_fast: compilation of pattern failed, falling" "back to NFA\n")); return REG_BADPAT; @@ -715,7 +714,7 @@ badpat: { if (fg->wescmap != NULL) { - fg->escmap = xmalloc(fg->len * sizeof(bool)); + fg->escmap = malloc(fg->len * sizeof(bool)); if (!fg->escmap) { tre_free_fast(fg); @@ -746,7 +745,7 @@ badpat: fg->escmap = _escmap; #endif - xfree(tmp); + free(tmp); DPRINT(("tre_compile_fast: pattern: %s, len %zu, bol %c, eol %c, " "icase: %c, word: %c, newline %c\n", fg->pattern, fg->len, @@ -977,16 +976,16 @@ tre_free_fast(fastmatch_t *fg) #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); if (!fg->hasdot) - xfree(fg->bmGs); + free(fg->bmGs); if (fg->wescmap) - xfree(fg->wescmap); - xfree(fg->wpattern); + free(fg->wescmap); + free(fg->wpattern); #endif if (!fg->hasdot) - xfree(fg->sbmGs); + free(fg->sbmGs); if (fg->escmap) - xfree(fg->escmap); - xfree(fg->pattern); + free(fg->escmap); + free(fg->pattern); } /* From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:40:15 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CFB2DD912B; Wed, 16 Aug 2017 00:40:15 +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 mx1.freebsd.org (Postfix) with ESMTPS id E048C66EE3; Wed, 16 Aug 2017 00:40:14 +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 v7G0eEoM034110; Wed, 16 Aug 2017 00:40:14 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0eEN4034109; Wed, 16 Aug 2017 00:40:14 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160040.v7G0eEN4034109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:40: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: r322558 - stable/11/usr.bin/grep/regex X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep/regex X-SVN-Commit-Revision: 322558 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.23 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, 16 Aug 2017 00:40:15 -0000 Author: kevans Date: Wed Aug 16 00:40:13 2017 New Revision: 322558 URL: https://svnweb.freebsd.org/changeset/base/322558 Log: MFC r316495: bsdgrep(1): Fix errors with invalid expressions Invalid expressions with an ultimate compiled pattern length of 0 (e.g., "grep -E {") were not taken into account and caused a segfault while trying to fill in the good suffix table. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:23:59 2017 (r322557) +++ stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 00:40:13 2017 (r322558) @@ -337,7 +337,7 @@ static int fastcmp(const fastmatch_t *fg, const void * * Fills in the good suffix table for SB/MB strings. */ #define FILL_BMGS \ - if (!fg->hasdot) \ + if (fg->len > 0 && !fg->hasdot) \ { \ fg->sbmGs = malloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ @@ -353,7 +353,7 @@ static int fastcmp(const fastmatch_t *fg, const void * * Fills in the good suffix table for wide strings. */ #define FILL_BMGS_WIDE \ - if (!fg->hasdot) \ + if (fg->wlen > 0 && !fg->hasdot) \ { \ fg->bmGs = malloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \ From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:42:53 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16712DD957C; Wed, 16 Aug 2017 00:42:53 +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 mx1.freebsd.org (Postfix) with ESMTPS id D6A27672BC; Wed, 16 Aug 2017 00:42:52 +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 v7G0gqf3037746; Wed, 16 Aug 2017 00:42:52 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0gqZM037745; Wed, 16 Aug 2017 00:42:52 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160042.v7G0gqZM037745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322559 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322559 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.23 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, 16 Aug 2017 00:42:53 -0000 Author: kevans Date: Wed Aug 16 00:42:51 2017 New Revision: 322559 URL: https://svnweb.freebsd.org/changeset/base/322559 Log: MFC r316542: bsdgrep: Handle special case of single-byte NUL pattern PR: 202022 Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/grep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 00:40:13 2017 (r322558) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 00:42:51 2017 (r322559) @@ -315,8 +315,12 @@ read_patterns(const char *fn) } len = 0; line = NULL; - while ((rlen = getline(&line, &len, f)) != -1) + while ((rlen = getline(&line, &len, f)) != -1) { + if (line[0] == '\0') + continue; add_pattern(line, line[0] == '\n' ? 0 : (size_t)rlen); + } + free(line); if (ferror(f)) err(2, "%s", fn); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:47:55 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA6CADD9983; Wed, 16 Aug 2017 00:47:55 +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 mx1.freebsd.org (Postfix) with ESMTPS id 9564E674A0; Wed, 16 Aug 2017 00:47:55 +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 v7G0lsJR038014; Wed, 16 Aug 2017 00:47:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0lrwM037998; Wed, 16 Aug 2017 00:47:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160047.v7G0lrwM037998@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:47:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322560 - in stable/11/usr.bin/grep: . nls X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . nls X-SVN-Commit-Revision: 322560 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.23 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, 16 Aug 2017 00:47:55 -0000 Author: kevans Date: Wed Aug 16 00:47:53 2017 New Revision: 322560 URL: https://svnweb.freebsd.org/changeset/base/322560 Log: bsdgrep: add -z/--null-data support and update NLS catalogs accordingly MFC r317049: bsdgrep: add -z/--null-data support -z treats input and output data as sequences of lines terminated by a zero byte instead of a newline. This brings it more in line with GNU grep and brings us closer to passing the current tests with BSD grep. MFC r317679: bsdgrep: correct nls usage data after r317049 r317049 added -z/--null-data to BSD grep but missed the update to nls catalogs. Approved by: emaste (mentor, blanket MFC) Relnotes: yes Modified: stable/11/usr.bin/grep/file.c stable/11/usr.bin/grep/grep.1 stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/nls/C.msg stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/file.c ============================================================================== --- stable/11/usr.bin/grep/file.c Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/file.c Wed Aug 16 00:47:53 2017 (r322560) @@ -197,7 +197,7 @@ grep_fgetln(struct file *f, size_t *lenp) } /* Look for a newline in the remaining part of the buffer */ - if ((p = memchr(bufpos, '\n', bufrem)) != NULL) { + if ((p = memchr(bufpos, fileeol, bufrem)) != NULL) { ++p; /* advance over newline */ ret = bufpos; len = p - bufpos; @@ -219,7 +219,7 @@ grep_fgetln(struct file *f, size_t *lenp) if (bufrem == 0) /* EOF: return partial line */ break; - if ((p = memchr(bufpos, '\n', bufrem)) == NULL && + if ((p = memchr(bufpos, fileeol, bufrem)) == NULL && filebehave != FILE_MMAP) continue; if (p == NULL) { @@ -322,7 +322,8 @@ grep_open(const char *path) goto error2; /* Check for binary stuff, if necessary */ - if (binbehave != BINFILE_TEXT && memchr(bufpos, '\0', bufrem) != NULL) + if (binbehave != BINFILE_TEXT && fileeol != '\0' && + memchr(bufpos, '\0', bufrem) != NULL) f->binary = true; return (f); Modified: stable/11/usr.bin/grep/grep.1 ============================================================================== --- stable/11/usr.bin/grep/grep.1 Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/grep.1 Wed Aug 16 00:47:53 2017 (r322560) @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd July 28, 2010 +.Dd April 17, 2017 .Dt GREP 1 .Os .Sh NAME @@ -40,7 +40,7 @@ .Sh SYNOPSIS .Nm grep .Bk -words -.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZ +.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZz .Op Fl A Ar num .Op Fl B Ar num .Op Fl C Ns Op Ar num @@ -378,7 +378,10 @@ expression are considered to be matching lines. Equivalent to .Fl i . Obsoleted. -.It Fl Z , Fl z , Fl Fl decompress +.It Fl z , Fl Fl null-data +Treat input and output data as sequences of lines terminated by a +zero-byte instead of a newline. +.It Fl Z , Fl Fl decompress Force .Nm grep to behave as Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 00:47:53 2017 (r322560) @@ -67,7 +67,7 @@ const char *errstr[] = { /* 1*/ "(standard input)", /* 2*/ "cannot read bzip2 compressed file", /* 3*/ "unknown %s option", -/* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n", +/* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n", /* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n", /* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n", /* 7*/ "\t[--null] [pattern] [file ...]\n", @@ -110,6 +110,7 @@ bool lflag; /* -l: only show names of files with mat bool mflag; /* -m x: stop reading the files after x matches */ long long mcount; /* count for -m */ long long mlimit; /* requested value for -m */ +char fileeol; /* indicator for eol */ bool nflag; /* -n: show line numbers in front of matching lines */ bool oflag; /* -o: print only matching part */ bool qflag; /* -q: quiet mode (don't output anything) */ @@ -166,7 +167,7 @@ usage(void) exit(2); } -static const char *optstr = "0123456789A:B:C:D:EFGHIJMLOPSRUVZabcd:e:f:hilm:nopqrsuvwxXy"; +static const char *optstr = "0123456789A:B:C:D:EFGHIJMLOPSRUVZabcd:e:f:hilm:nopqrsuvwxXyz"; static const struct option long_options[] = { @@ -216,6 +217,7 @@ static const struct option long_options[] = {"word-regexp", no_argument, NULL, 'w'}, {"line-regexp", no_argument, NULL, 'x'}, {"xz", no_argument, NULL, 'X'}, + {"null-data", no_argument, NULL, 'z'}, {"decompress", no_argument, NULL, 'Z'}, {NULL, no_argument, NULL, 0} }; @@ -385,6 +387,7 @@ main(int argc, char *argv[]) newarg = 1; prevoptind = 1; needpattern = 1; + fileeol = '\n'; eopts = getenv("GREP_OPTIONS"); @@ -605,6 +608,9 @@ main(int argc, char *argv[]) break; case 'X': filebehave = FILE_XZ; + break; + case 'z': + fileeol = '\0'; break; case 'Z': filebehave = FILE_GZIP; Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/grep.h Wed Aug 16 00:47:53 2017 (r322560) @@ -116,6 +116,7 @@ extern bool dexclude, dinclude, fexclude, finclude, l extern unsigned long long Aflag, Bflag; extern long long mcount; extern long long mlimit; +extern char fileeol; extern char *label; extern const char *color; extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave; Modified: stable/11/usr.bin/grep/nls/C.msg ============================================================================== --- stable/11/usr.bin/grep/nls/C.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/C.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(standard input)" 2 "cannot read bzip2 compressed file" 3 "unknown %s option" -4 "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n" +4 "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n" 5 "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n" 6 "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n" 7 "\t[--null] [pattern] [file ...]\n" Modified: stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(entrada estándar)" 2 "no se puede leer el fichero comprimido bzip2" 3 "opción desconocida de %s" -4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A no] [-B no] [-C[no]]\n" +4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A no] [-B no] [-C[no]]\n" 5 "\t[-e pauta] [-f fichero] [--binary-files=valor] [--color=cuando]\n" 6 "\t[--context[=no]] [--directories=acción] [--label] [--line-buffered]\n" 7 "\t[--null] [pauta] [fichero ...]\n" Modified: stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(entrada estándar)" 2 "non se pode ler o ficheiro comprimido bzip2" 3 "opción descoñecida de %s" -4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A no] [-B no] [-C[no]]\n" +4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A no] [-B no] [-C[no]]\n" 5 "\t[-e pauta] [-f ficheiro] [--binary-files=valor] [--color=cando]\n" 6 "\t[--context[=no]] [--directories=acción] [--label] [--line-buffered]\n" 7 "\t[--null] [pauta] [ficheiro ...]\n" Modified: stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg ============================================================================== --- stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(szabványos bemenet)" 2 "bzip2 tömörített fájl nem olvasható" 3 "ismeretlen %s opció" -4 "használat: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A szám] [-B szám] [-C[szám]]\n" +4 "használat: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A szám] [-B szám] [-C[szám]]\n" 5 "\t[-e minta] [-f fájl] [--binary-files=érték] [--color=mikor]\n" 6 "\t[--context[=szám]] [--directories=mûvelet] [--label] [--line-buffered]\n" 7 "\t[--null] [minta] [fájl ...]\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(•W€“ü—Í)" 2 "bzip2 ˆ³kƒtƒ@ƒCƒ‹‚ð“Ç‚Ýž‚Þ‚±‚Æ‚ª‚Å‚«‚Ü‚¹‚ñ" 3 "%s ƒIƒvƒVƒ‡ƒ“‚ÌŽw’è’l‚ÉŒë‚肪‚ ‚è‚Ü‚·" -4 "Žg‚¢•û: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A ”Žš] [-B ”Žš] [-C[”Žš]]\n" +4 "Žg‚¢•û: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A ”Žš] [-B ”Žš] [-C[”Žš]]\n" 5 "\t[-e ƒpƒ^[ƒ“] [-f ƒtƒ@ƒCƒ‹–¼] [--binary-files=’l] [--color=’l]\n" 6 "\t[--context[=”Žš]] [--directories=“®ì] [--label] [--line-buffered]\n" 7 "\t[--null] [ƒpƒ^[ƒ“] [ƒtƒ@ƒCƒ‹–¼ ...]\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(標準入力)" 2 "bzip2 圧縮ファイルを読ã¿è¾¼ã‚€ã“ã¨ãŒã§ãã¾ã›ã‚“" 3 "%s オプションã®æŒ‡å®šå€¤ã«èª¤ã‚ŠãŒã‚ã‚Šã¾ã™" -4 "使ã„æ–¹: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A æ•°å­—] [-B æ•°å­—] [-C[æ•°å­—]]\n" +4 "使ã„æ–¹: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A æ•°å­—] [-B æ•°å­—] [-C[æ•°å­—]]\n" 5 "\t[-e パターン] [-f ファイルå] [--binary-files=値] [--color=値]\n" 6 "\t[--context[=æ•°å­—]] [--directories=動作] [--label] [--line-buffered]\n" 7 "\t[--null] [パターン] [ファイルå ...]\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(ɸ½àÆþÎÏ)" 2 "bzip2 °µ½Ì¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó" 3 "%s ¥ª¥×¥·¥ç¥ó¤Î»ØÄêÃͤ˸í¤ê¤¬¤¢¤ê¤Þ¤¹" -4 "»È¤¤Êý: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A ¿ô»ú] [-B ¿ô»ú] [-C[¿ô»ú]]\n" +4 "»È¤¤Êý: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A ¿ô»ú] [-B ¿ô»ú] [-C[¿ô»ú]]\n" 5 "\t[-e ¥Ñ¥¿¡¼¥ó] [-f ¥Õ¥¡¥¤¥ë̾] [--binary-files=ÃÍ] [--color=ÃÍ]\n" 6 "\t[--context[=¿ô»ú]] [--directories=Æ°ºî] [--label] [--line-buffered]\n" 7 "\t[--null] [¥Ñ¥¿¡¼¥ó] [¥Õ¥¡¥¤¥ë̾ ...]\n" Modified: stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(entrada padrão)" 2 "não se posso ler o fichero comprimido bzip2" 3 "opcão não conhecida de %s" -4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n" +4 "uso: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n" 5 "\t[-e padrão] [-f arquivo] [--binary-files=valor] [--color=quando]\n" 6 "\t[--context[=num]] [--directories=ação] [--label] [--line-buffered]\n" 7 "\t[--null] [padrão] [arquivo ...]\n" Modified: stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(ÓÔÁÎÄÁÒÔÎÙÊ ××ÏÄ)" 2 "ÎÅ ÍÏÇÕ ÐÒÏÞÉÔÁÔØ ÓÖÁÔÙÊ × bzip2 ÆÁÊÌ" 3 "ÎÅÉÚ×ÅÓÔÎÙÊ ËÌÀÞ %s" -4 "ÉÓÐÏÌØÚÏ×ÁÎÉÅ: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A ÞÉÓ] [-B ÞÉÓ] [-C[ÞÉÓ]]\n" +4 "ÉÓÐÏÌØÚÏ×ÁÎÉÅ: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A ÞÉÓ] [-B ÞÉÓ] [-C[ÞÉÓ]]\n" 5 "\t[-e ÛÁÂÌÏÎ] [-f ÆÁÊÌ] [--binary-files=ÚÎÁÞÅÎÉÅ] [--color=ËÏÇÄÁ]\n" 6 "\t[--context[=ÞÉÓ]] [--directories=ÄÅÊÓÔ×ÉÅ] [--label] [--line-buffered]\n" 7 "\t[--null] [ÛÁÂÌÏÎ] [ÆÁÊÌ ...]\n" Modified: stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -4,7 +4,7 @@ $quote " 1 "(Ñтандартний ввід)" 2 "не можу прочитати ÑтиÑнутий bzip2 файл" 3 "невiдома Ð¾Ð¿Ñ†Ñ–Ñ %s" -4 "викориÑтаннÑ: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A чиÑ] [-B чиÑ] [-C[чиÑ]]\n" +4 "викориÑтаннÑ: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A чиÑ] [-B чиÑ] [-C[чиÑ]]\n" 5 "\t[-e шаблон] [-f файл] [--binary-files=значеннÑ] [--color=коли]\n" 6 "\t[--context[=чиÑ] [--directories=діÑ] [--label] [--line-buffered]\n" 7 "\t[--null] [шаблон] [файл ...]\n" Modified: stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg Wed Aug 16 00:47:53 2017 (r322560) @@ -5,7 +5,7 @@ $quote " 1 "(标准输入)" 2 "è¯»å– bzip2 压缩文件时出错" 3 "选项 %s 无法识别" -4 "用法: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A 行数] [-B 行数] [-C[行数]]\n" +4 "用法: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A 行数] [-B 行数] [-C[行数]]\n" 5 "\t[-e 模å¼] [-f 文件] [--binary-files=值] [--color=何时]\n" 6 "\t[--context[=行数]] [--directories=动作] [--label] [--line-buffered]\n" 7 "\t[--null] [模å¼] [文件å ...]\n" Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 00:42:51 2017 (r322559) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 00:47:53 2017 (r322560) @@ -216,7 +216,7 @@ procfile(const char *fn) else break; } - if (ln.len > 0 && ln.dat[ln.len - 1] == '\n') + if (ln.len > 0 && ln.dat[ln.len - 1] == fileeol) --ln.len; ln.line_no++; @@ -525,6 +525,6 @@ printline(struct str *line, int sep, regmatch_t *match } } else { fwrite(line->dat, line->len, 1, stdout); - putchar('\n'); + putchar(fileeol); } } From owner-svn-src-stable-11@freebsd.org Wed Aug 16 00:55:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 246D5DDA183; Wed, 16 Aug 2017 00:55: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 mx1.freebsd.org (Postfix) with ESMTPS id EFC226799B; Wed, 16 Aug 2017 00:55:57 +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 v7G0tu6A042079; Wed, 16 Aug 2017 00:55:56 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G0tun2042078; Wed, 16 Aug 2017 00:55:56 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160055.v7G0tun2042078@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 00:55:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322561 - stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Commit-Revision: 322561 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.23 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, 16 Aug 2017 00:55:58 -0000 Author: kevans Date: Wed Aug 16 00:55:56 2017 New Revision: 322561 URL: https://svnweb.freebsd.org/changeset/base/322561 Log: bsdgrep: Revise tests based on recent fixes and future changes MFC r317297: Remove the expected failures for :context and :context2 with bsdgrep(1) They're no longer needed after recent fixes made to bsdgrep(1). MFC r317299: Add more sanity tests for grep, egrep, and fgrep The test suite currently lacks basic sanity checks to ensure that egrep, fgrep, and grep are actually matching the right expression types, i.e. passing the right flags to regcomp(3). Amend the test suite to make sure that not only are the individual versions doing the right thing, but also that we don't have some kind of frankenregex situation happening where egrep is accepting a BRE or grep an ERE. I've chosen to not expand the 'basic' test but to add the 'grep_sanity' checks to their own test case since this is testing for more than just 'grep matches things', but actual expression types. MFC r317694: bsdgrep: revise test case which will soon become a failure Work in progress (D10315) is going to make egrep_empty_invalid an actually invalid regex, to be consistent with the equivalent BRE "{" behavior, when using regex(3). Any non-0 exit value is acceptable, depending on how the installed grep interprets the expression. GNU grep interprets it as non-matching, and in the future BSD grep will interpret it is an error. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:47:53 2017 (r322560) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 00:55:56 2017 (r322561) @@ -159,12 +159,6 @@ context_head() } context_body() { - # Begin FreeBSD - grep_type - if [ $? -eq $GREP_TYPE_BSD ]; then - atf_expect_fail "this test doesn't pass with BSD grep yet" - fi - # End FreeBSD cp $(atf_get_srcdir)/d_context_*.* . atf_check -o file:d_context_a.out grep -C2 bamboo d_context_a.in @@ -226,12 +220,6 @@ context2_head() } context2_body() { - # Begin FreeBSD - grep_type - if [ $? -eq $GREP_TYPE_BSD ]; then - atf_expect_fail "this test doesn't pass with BSD grep yet" - fi - # End FreeBSD printf "haddock\000cod\000plaice\000" > test1 printf "mackeral\000cod\000crab\000" > test2 @@ -375,7 +363,7 @@ egrep_empty_invalid_head() } egrep_empty_invalid_body() { - atf_check -s exit:1 egrep '{' /dev/null + atf_check -e ignore -s not-exit:0 egrep '{' /dev/null } atf_test_case zerolen @@ -391,6 +379,66 @@ zerolen_body() atf_check -o inline:"Eggs\nCheese\n" grep -v -e "^$" test1 } + +atf_test_case fgrep_sanity +fgrep_sanity_head() +{ + atf_set "descr" "Check for fgrep sanity, literal expressions only" +} +fgrep_sanity_body() +{ + printf "Foo" > test1 + + atf_check -o inline:"Foo\n" fgrep -e "Foo" test1 + + atf_check -s exit:1 -o empty fgrep -e "Fo." test1 +} + +atf_test_case egrep_sanity +egrep_sanity_head() +{ + atf_set "descr" "Check for egrep sanity, EREs only" +} +egrep_sanity_body() +{ + printf "Foobar(ed)" > test1 + printf "M{1}" > test2 + + atf_check -o inline:"Foo\n" egrep -o -e "F.." test1 + + atf_check -o inline:"Foobar\n" egrep -o -e "F[a-z]*" test1 + + atf_check -o inline:"Fo\n" egrep -o -e "F(o|p)" test1 + + atf_check -o inline:"(ed)\n" egrep -o -e "\(ed\)" test1 + + atf_check -o inline:"M\n" egrep -o -e "M{1}" test2 + + atf_check -o inline:"M{1}\n" egrep -o -e "M\{1\}" test2 +} + +atf_test_case grep_sanity +grep_sanity_head() +{ + atf_set "descr" "Check for basic grep sanity, BREs only" +} +grep_sanity_body() +{ + printf "Foobar(ed)" > test1 + printf "M{1}" > test2 + + atf_check -o inline:"Foo\n" grep -o -e "F.." test1 + + atf_check -o inline:"Foobar\n" grep -o -e "F[a-z]*" test1 + + atf_check -o inline:"Fo\n" grep -o -e "F\(o\)" test1 + + atf_check -o inline:"(ed)\n" grep -o -e "(ed)" test1 + + atf_check -o inline:"M{1}\n" grep -o -e "M{1}" test2 + + atf_check -o inline:"M\n" grep -o -e "M\{1\}" test2 +} # End FreeBSD atf_init_test_cases() @@ -419,5 +467,8 @@ atf_init_test_cases() atf_add_test_case escmap atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen + atf_add_test_case fgrep_sanity + atf_add_test_case egrep_sanity + atf_add_test_case grep_sanity # End FreeBSD } From owner-svn-src-stable-11@freebsd.org Wed Aug 16 01:03:05 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86C23DDA8B7; Wed, 16 Aug 2017 01:03:05 +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 mx1.freebsd.org (Postfix) with ESMTPS id 61CA867E3E; Wed, 16 Aug 2017 01:03:05 +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 v7G134O9046028; Wed, 16 Aug 2017 01:03:04 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G134AS046027; Wed, 16 Aug 2017 01:03:04 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160103.v7G134AS046027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 01:03: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: r322562 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322562 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.23 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, 16 Aug 2017 01:03:05 -0000 Author: kevans Date: Wed Aug 16 01:03:04 2017 New Revision: 322562 URL: https://svnweb.freebsd.org/changeset/base/322562 Log: MFC r317051: bsdgrep: remove output separators between overlapping segments Make bsdgrep more sensitive to context overlaps. If it's printing context that either overlaps or is immediately adjacent to another bit of context, don't print a separator. - Non-overlapping segments no longer have two separators between them - Overlapping segments no longer have separators between them with overlapping sections repeated Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 00:55:56 2017 (r322561) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 01:03:04 2017 (r322562) @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); static int linesqueued; static int procline(struct str *l, int); +static int lasta; +static bool ctxover; + bool file_matching(const char *fname) { @@ -204,8 +207,10 @@ procfile(const char *fn) strcpy(ln.file, fn); ln.line_no = 0; ln.len = 0; + ctxover = false; linesqueued = 0; tail = 0; + lasta = 0; ln.off = -1; for (c = 0; c == 0 || !(lflag || qflag); ) { @@ -227,10 +232,24 @@ procfile(const char *fn) free(f); return (0); } - /* Process the file line-by-line */ + + /* Process the file line-by-line, enqueue non-matching lines */ if ((t = procline(&ln, f->binary)) == 0 && Bflag > 0) { - enqueue(&ln); - linesqueued++; + /* Except don't enqueue lines that appear in -A ctx */ + if (ln.line_no == 0 || lasta != ln.line_no) { + /* queue is maxed to Bflag number of lines */ + enqueue(&ln); + linesqueued++; + ctxover = false; + } else { + /* + * Indicate to procline() that we have ctx + * overlap and make sure queue is empty. + */ + if (!ctxover) + clearqueue(); + ctxover = true; + } } c += t; if (mflag && mcount <= 0) @@ -385,17 +404,19 @@ procline(struct str *l, int nottext) /* Dealing with the context */ if ((tail || c) && !cflag && !qflag && !lflag && !Lflag) { if (c) { - if (!first && !prev && !tail && Aflag) + if (!first && !prev && !tail && (Bflag || Aflag) && + !ctxover) printf("--\n"); tail = Aflag; if (Bflag > 0) { - if (!first && !prev) - printf("--\n"); printqueue(); + ctxover = false; } linesqueued = 0; printline(l, ':', matches, m); } else { + /* Print -A lines following matches */ + lasta = l->line_no; printline(l, '-', matches, m); tail--; } From owner-svn-src-stable-11@freebsd.org Wed Aug 16 01:45:54 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A38C5DDD72B; Wed, 16 Aug 2017 01:45:54 +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 mx1.freebsd.org (Postfix) with ESMTPS id 7FFEA69D3E; Wed, 16 Aug 2017 01:45:54 +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 v7G1jrLa062483; Wed, 16 Aug 2017 01:45:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G1jrLW062479; Wed, 16 Aug 2017 01:45:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708160145.v7G1jrLW062479@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 01:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322564 - in stable/11/usr.bin/grep: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . tests X-SVN-Commit-Revision: 322564 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.23 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, 16 Aug 2017 01:45:54 -0000 Author: kevans Date: Wed Aug 16 01:45:53 2017 New Revision: 322564 URL: https://svnweb.freebsd.org/changeset/base/322564 Log: bsdgrep: Use implied working directory for -r if no directories are passed MFC r317050: bsdgrep: for -r, use the working directory if none specified This is more sensible than the previous behaviour of grepping stdin, and matches newer GNU grep behaviour. MFC r317300 (ngie): Only expect :grep_r_implied to pass with bsdgrep(1) The test fails with gnu grep from base and ports. MFC r319002 (ngie): :rgrep : use atf-check to check the exit code/save the output of grep -r instead of calling grep -r without it, and saving the output to a file This ensures that any errors thrown via grep -r are caught, not lost, and uses existing atf-sh idioms for saving files. PR: 216307 Approved by: emaste (mentor, blanket MFC) Relnotes: yes Added: stable/11/usr.bin/grep/tests/grep_freebsd_test.sh - copied, changed from r317050, head/usr.bin/grep/tests/grep_freebsd_test.sh Modified: stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/tests/Makefile stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 01:27:48 2017 (r322563) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 01:45:53 2017 (r322564) @@ -739,7 +739,7 @@ main(int argc, char *argv[]) if ((aargc == 0 || aargc == 1) && !Hflag) hflag = true; - if (aargc == 0) + if (aargc == 0 && dirbehave != DIR_RECURSE) exit(!procfile("-")); if (dirbehave == DIR_RECURSE) Modified: stable/11/usr.bin/grep/tests/Makefile ============================================================================== --- stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 01:27:48 2017 (r322563) +++ stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 01:45:53 2017 (r322564) @@ -2,6 +2,7 @@ PACKAGE= tests +ATF_TESTS_SH+= grep_freebsd_test NETBSD_ATF_TESTS_SH= grep_test ${PACKAGE}FILES+= d_basic.out Copied and modified: stable/11/usr.bin/grep/tests/grep_freebsd_test.sh (from r317050, head/usr.bin/grep/tests/grep_freebsd_test.sh) ============================================================================== --- head/usr.bin/grep/tests/grep_freebsd_test.sh Mon Apr 17 13:22:39 2017 (r317050, copy source) +++ stable/11/usr.bin/grep/tests/grep_freebsd_test.sh Wed Aug 16 01:45:53 2017 (r322564) @@ -25,11 +25,45 @@ # # $FreeBSD$ +# What grep(1) are we working with? +# - 0 : bsdgrep +# - 1 : gnu grep 2.51 (base) +# - 2 : gnu grep (ports) +GREP_TYPE_BSD=0 +GREP_TYPE_GNU_FREEBSD=1 +GREP_TYPE_GNU=2 +GREP_TYPE_UNKNOWN=3 + +grep_type() +{ + local grep_version=$(grep --version) + + case "$grep_version" in + *"BSD grep"*) + return $GREP_TYPE_BSD + ;; + *"GNU grep"*) + case "$grep_version" in + *2.5.1-FreeBSD*) + return $GREP_TYPE_GNU_FREEBSD + ;; + *) + return $GREP_TYPE_GNU + ;; + esac + ;; + esac + atf_fail "unknown grep type: $grep_version" +} + atf_test_case grep_r_implied grep_r_implied_body() { - (cd "$(atf_get_srcdir)" && grep -r -e "test" < /dev/null) || - atf_skip "Implied working directory is not supported with your version of grep(1)" + grep_type + if [ $? -ne $GREP_TYPE_BSD ]; then + atf_skip "this test only works with bsdgrep(1)" + fi + (cd "$(atf_get_srcdir)" && grep -r --exclude="*.out" -e "test" .) > d_grep_r_implied.out atf_check -s exit:0 -x \ @@ -43,8 +77,7 @@ rgrep_head() } rgrep_body() { - grep -r --exclude="*.out" -e "test" "$(atf_get_srcdir)" > d_grep_r_implied.out - + atf_check -o save:d_grep_r_implied.out grep -r --exclude="*.out" -e "test" "$(atf_get_srcdir)" atf_check -o file:d_grep_r_implied.out rgrep --exclude="*.out" -e "test" "$(atf_get_srcdir)" } Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 01:27:48 2017 (r322563) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 01:45:53 2017 (r322564) @@ -109,6 +109,7 @@ grep_tree(char **argv) FTSENT *p; int c, fts_flags; bool ok; + const char *wd[] = { ".", NULL }; c = fts_flags = 0; @@ -126,7 +127,9 @@ grep_tree(char **argv) fts_flags |= FTS_NOSTAT | FTS_NOCHDIR; - if (!(fts = fts_open(argv, fts_flags, NULL))) + fts = fts_open((argv[0] == NULL) ? + __DECONST(char * const *, wd) : argv, fts_flags, NULL); + if (fts == NULL) err(2, "fts_open"); while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { From owner-svn-src-stable-11@freebsd.org Wed Aug 16 07:59:59 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55EDADCBD59; Wed, 16 Aug 2017 07:59:59 +0000 (UTC) (envelope-from truckman@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 mx1.freebsd.org (Postfix) with ESMTPS id 3195474A5B; Wed, 16 Aug 2017 07:59:59 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7G7xwx8012976; Wed, 16 Aug 2017 07:59:58 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7G7xw0b012972; Wed, 16 Aug 2017 07:59:58 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201708160759.v7G7xw0b012972@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Wed, 16 Aug 2017 07:59:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322569 - in stable/11/sys/amd64: amd64 include linux X-SVN-Group: stable-11 X-SVN-Commit-Author: truckman X-SVN-Commit-Paths: in stable/11/sys/amd64: amd64 include linux X-SVN-Commit-Revision: 322569 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.23 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, 16 Aug 2017 07:59:59 -0000 Author: truckman Date: Wed Aug 16 07:59:57 2017 New Revision: 322569 URL: https://svnweb.freebsd.org/changeset/base/322569 Log: MFC r321899 Lower the amd64 shared page, which contains the signal trampoline, from the top of user memory to one page lower on machines with the Ryzen (AMD Family 17h) CPU. This pushes ps_strings and the stack down by one page as well. On Ryzen there is some sort of interaction between code running at the top of user memory address space and interrupts that can cause FreeBSD to either hang or silently reset. This sounds similar to the problem found with DragonFly BSD that was fixed with this commit: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20 but our signal trampoline location was already lower than the address that DragonFly moved their signal trampoline to. It also does not appear to be related to SMT as described here: https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498 "Hi, Matt Dillon here. Yes, I did find what I believe to be a hardware issue with Ryzen related to concurrent operations. In a nutshell, for any given hyperthread pair, if one hyperthread is in a cpu-bound loop of any kind (can be in user mode), and the other hyperthread is returning from an interrupt via IRETQ, the hyperthread issuing the IRETQ can stall indefinitely until the other hyperthread with the cpu-bound loop pauses (aka HLT until next interrupt). After this situation occurs, the system appears to destabilize. The situation does not occur if the cpu-bound loop is on a different core than the core doing the IRETQ. The %rip the IRETQ returns to (e.g. userland %rip address) matters a *LOT*. The problem occurs more often with high %rip addresses such as near the top of the user stack, which is where DragonFly's signal trampoline traditionally resides. So a user program taking a signal on one thread while another thread is cpu-bound can cause this behavior. Changing the location of the signal trampoline makes it more difficult to reproduce the problem. I have not been because the able to completely mitigate it. When a cpu-thread stalls in this manner it appears to stall INSIDE the microcode for IRETQ. It doesn't make it to the return pc, and the cpu thread cannot take any IPIs or other hardware interrupts while in this state." since the system instability has been observed on FreeBSD with SMT disabled. Interrupts to appear to play a factor since running a signal-intensive process on the first CPU core, which handles most of the interrupts on my machine, is far more likely to trigger the problem than running such a process on any other core. Also lower sv_maxuser to prevent a malicious user from using mmap() to load and execute code in the top page of user memory that was made available when the shared page was moved down. Make the same changes to the 64-bit Linux emulator. PR: 219399 Reported by: nbe@renzel.net Reviewed by: kib Reviewed by: dchagin (previous version) Tested by: nbe@renzel.net (earlier version) Differential Revision: https://reviews.freebsd.org/D11780 Modified: stable/11/sys/amd64/amd64/elf_machdep.c stable/11/sys/amd64/amd64/initcpu.c stable/11/sys/amd64/include/md_var.h stable/11/sys/amd64/linux/linux_sysvec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/elf_machdep.c Wed Aug 16 06:43:50 2017 (r322568) +++ stable/11/sys/amd64/amd64/elf_machdep.c Wed Aug 16 07:59:57 2017 (r322569) @@ -84,6 +84,25 @@ struct sysentvec elf64_freebsd_sysvec = { }; INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec); +void +amd64_lower_shared_page(struct sysentvec *sv) +{ + if (hw_lower_amd64_sharedpage != 0) { + sv->sv_maxuser -= PAGE_SIZE; + sv->sv_shared_page_base -= PAGE_SIZE; + sv->sv_usrstack -= PAGE_SIZE; + sv->sv_psstrings -= PAGE_SIZE; + } +} + +/* + * Do this fixup before INIT_SYSENTVEC (SI_ORDER_ANY) because the latter + * uses the value of sv_shared_page_base. + */ +SYSINIT(elf64_sysvec_fixup, SI_SUB_EXEC, SI_ORDER_FIRST, + (sysinit_cfunc_t) amd64_lower_shared_page, + &elf64_freebsd_sysvec); + static Elf64_Brandinfo freebsd_brand_info = { .brand = ELFOSABI_FREEBSD, .machine = EM_X86_64, Modified: stable/11/sys/amd64/amd64/initcpu.c ============================================================================== --- stable/11/sys/amd64/amd64/initcpu.c Wed Aug 16 06:43:50 2017 (r322568) +++ stable/11/sys/amd64/amd64/initcpu.c Wed Aug 16 07:59:57 2017 (r322569) @@ -48,6 +48,11 @@ __FBSDID("$FreeBSD$"); static int hw_instruction_sse; SYSCTL_INT(_hw, OID_AUTO, instruction_sse, CTLFLAG_RD, &hw_instruction_sse, 0, "SIMD/MMX2 instructions available in CPU"); +static int lower_sharedpage_init; +int hw_lower_amd64_sharedpage; +SYSCTL_INT(_hw, OID_AUTO, lower_amd64_sharedpage, CTLFLAG_RDTUN, + &hw_lower_amd64_sharedpage, 0, + "Lower sharedpage to work around Ryzen issue with executing code near the top of user memory"); /* * -1: automatic (default) * 0: keep enable CLFLUSH @@ -120,6 +125,28 @@ init_amd(void) msr = rdmsr(0xc0011020); msr |= (uint64_t)1 << 15; wrmsr(0xc0011020, msr); + } + } + + /* + * Work around a problem on Ryzen that is triggered by executing + * code near the top of user memory, in our case the signal + * trampoline code in the shared page on amd64. + * + * This function is executed once for the BSP before tunables take + * effect so the value determined here can be overridden by the + * tunable. This function is then executed again for each AP and + * also on resume. Set a flag the first time so that value set by + * the tunable is not overwritten. + * + * The stepping and/or microcode versions should be checked after + * this issue is fixed by AMD so that we don't use this mode if not + * needed. + */ + if (lower_sharedpage_init == 0) { + lower_sharedpage_init = 1; + if (CPUID_TO_FAMILY(cpu_id) == 0x17) { + hw_lower_amd64_sharedpage = 1; } } } Modified: stable/11/sys/amd64/include/md_var.h ============================================================================== --- stable/11/sys/amd64/include/md_var.h Wed Aug 16 06:43:50 2017 (r322568) +++ stable/11/sys/amd64/include/md_var.h Wed Aug 16 07:59:57 2017 (r322569) @@ -34,11 +34,14 @@ #include -extern uint64_t *vm_page_dump; +extern uint64_t *vm_page_dump; +extern int hw_lower_amd64_sharedpage; struct savefpu; +struct sysentvec; void amd64_db_resume_dbreg(void); +void amd64_lower_shared_page(struct sysentvec *); void amd64_syscall(struct thread *td, int traced); void doreti_iret(void) __asm(__STRING(doreti_iret)); void doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault)); Modified: stable/11/sys/amd64/linux/linux_sysvec.c ============================================================================== --- stable/11/sys/amd64/linux/linux_sysvec.c Wed Aug 16 06:43:50 2017 (r322568) +++ stable/11/sys/amd64/linux/linux_sysvec.c Wed Aug 16 07:59:57 2017 (r322569) @@ -833,6 +833,8 @@ static void linux_vdso_install(void *param) { + amd64_lower_shared_page(&elf_linux_sysvec); + linux_szsigcode = (&_binary_linux_locore_o_end - &_binary_linux_locore_o_start); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 10:28:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF3ECDD2AAC; Wed, 16 Aug 2017 10:28:35 +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 mx1.freebsd.org (Postfix) with ESMTPS id 87CDA7D289; Wed, 16 Aug 2017 10:28:35 +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 v7GASYAT073910; Wed, 16 Aug 2017 10:28:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GASY4O073906; Wed, 16 Aug 2017 10:28:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201708161028.v7GASY4O073906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 16 Aug 2017 10:28:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322572 - in stable/11/sys/dev: ahci sound/pci/hda usb/controller X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys/dev: ahci sound/pci/hda usb/controller X-SVN-Commit-Revision: 322572 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.23 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, 16 Aug 2017 10:28:35 -0000 Author: mav Date: Wed Aug 16 10:28:34 2017 New Revision: 322572 URL: https://svnweb.freebsd.org/changeset/base/322572 Log: MFC r322308: Add new Intel Lewisburg and Union Point chipset PCI IDs. While there, polish some old AHCI ones, since they are still reused. Modified: stable/11/sys/dev/ahci/ahci_pci.c stable/11/sys/dev/sound/pci/hda/hdac.c stable/11/sys/dev/sound/pci/hda/hdac.h 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 Wed Aug 16 08:49:11 2017 (r322571) +++ stable/11/sys/dev/ahci/ahci_pci.c Wed Aug 16 10:28:34 2017 (r322572) @@ -92,10 +92,10 @@ static const struct { {0x27c58086, 0x00, "Intel ICH7M", 0}, {0x27c68086, 0x00, "Intel ICH7M", 0}, {0x28218086, 0x00, "Intel ICH8", 0}, - {0x28228086, 0x00, "Intel ICH8", 0}, + {0x28228086, 0x00, "Intel ICH8+ (RAID)", 0}, {0x28248086, 0x00, "Intel ICH8", 0}, {0x28298086, 0x00, "Intel ICH8M", 0}, - {0x282a8086, 0x00, "Intel ICH8M", 0}, + {0x282a8086, 0x00, "Intel ICH8M+ (RAID)", 0}, {0x29228086, 0x00, "Intel ICH9", 0}, {0x29238086, 0x00, "Intel ICH9", 0}, {0x29248086, 0x00, "Intel ICH9", 0}, @@ -108,23 +108,24 @@ static const struct { {0x292f8086, 0x00, "Intel ICH9M", 0}, {0x294d8086, 0x00, "Intel ICH9", 0}, {0x294e8086, 0x00, "Intel ICH9M", 0}, - {0x3a058086, 0x00, "Intel ICH10", 0}, + {0x3a058086, 0x00, "Intel ICH10 (RAID)", 0}, {0x3a228086, 0x00, "Intel ICH10", 0}, - {0x3a258086, 0x00, "Intel ICH10", 0}, + {0x3a258086, 0x00, "Intel ICH10 (RAID)", 0}, {0x3b228086, 0x00, "Intel 5 Series/3400 Series", 0}, {0x3b238086, 0x00, "Intel 5 Series/3400 Series", 0}, - {0x3b258086, 0x00, "Intel 5 Series/3400 Series", 0}, + {0x3b258086, 0x00, "Intel 5 Series/3400 Series (RAID)", 0}, {0x3b298086, 0x00, "Intel 5 Series/3400 Series", 0}, - {0x3b2c8086, 0x00, "Intel 5 Series/3400 Series", 0}, + {0x3b2c8086, 0x00, "Intel 5 Series/3400 Series (RAID)", 0}, {0x3b2f8086, 0x00, "Intel 5 Series/3400 Series", 0}, {0x1c028086, 0x00, "Intel Cougar Point", 0}, {0x1c038086, 0x00, "Intel Cougar Point", 0}, - {0x1c048086, 0x00, "Intel Cougar Point", 0}, - {0x1c058086, 0x00, "Intel Cougar Point", 0}, + {0x1c048086, 0x00, "Intel Cougar Point (RAID)", 0}, + {0x1c058086, 0x00, "Intel Cougar Point (RAID)", 0}, + {0x1c068086, 0x00, "Intel Cougar Point (RAID)", 0}, {0x1d028086, 0x00, "Intel Patsburg", 0}, {0x1d048086, 0x00, "Intel Patsburg", 0}, {0x1d068086, 0x00, "Intel Patsburg", 0}, - {0x28268086, 0x00, "Intel Patsburg (RAID)", 0}, + {0x28268086, 0x00, "Intel Patsburg+ (RAID)", 0}, {0x1e028086, 0x00, "Intel Panther Point", 0}, {0x1e038086, 0x00, "Intel Panther Point", 0}, {0x1e048086, 0x00, "Intel Panther Point (RAID)", 0}, @@ -150,8 +151,6 @@ static const struct { {0x1f3e8086, 0x00, "Intel Avoton (RAID)", 0}, {0x1f3f8086, 0x00, "Intel Avoton (RAID)", 0}, {0x23a38086, 0x00, "Intel Coleto Creek", 0}, - {0x28238086, 0x00, "Intel Wellsburg (RAID)", 0}, - {0x28278086, 0x00, "Intel Wellsburg (RAID)", 0}, {0x8c028086, 0x00, "Intel Lynx Point", 0}, {0x8c038086, 0x00, "Intel Lynx Point", 0}, {0x8c048086, 0x00, "Intel Lynx Point (RAID)", 0}, @@ -175,6 +174,8 @@ static const struct { {0x8d648086, 0x00, "Intel Wellsburg (RAID)", 0}, {0x8d668086, 0x00, "Intel Wellsburg (RAID)", 0}, {0x8d6e8086, 0x00, "Intel Wellsburg (RAID)", 0}, + {0x28238086, 0x00, "Intel Wellsburg+ (RAID)", 0}, + {0x28278086, 0x00, "Intel Wellsburg+ (RAID)", 0}, {0x9c028086, 0x00, "Intel Lynx Point-LP", 0}, {0x9c038086, 0x00, "Intel Lynx Point-LP", 0}, {0x9c048086, 0x00, "Intel Lynx Point-LP (RAID)", 0}, @@ -192,6 +193,17 @@ static const struct { {0xa1068086, 0x00, "Intel Sunrise Point (RAID)", 0}, {0xa1078086, 0x00, "Intel Sunrise Point (RAID)", 0}, {0xa10f8086, 0x00, "Intel Sunrise Point (RAID)", 0}, + {0xa1828086, 0x00, "Intel Lewisburg", 0}, + {0xa1868086, 0x00, "Intel Lewisburg (RAID)", 0}, + {0xa1d28086, 0x00, "Intel Lewisburg", 0}, + {0xa1d68086, 0x00, "Intel Lewisburg (RAID)", 0}, + {0xa2028086, 0x00, "Intel Lewisburg", 0}, + {0xa2068086, 0x00, "Intel Lewisburg (RAID)", 0}, + {0xa2528086, 0x00, "Intel Lewisburg", 0}, + {0xa2568086, 0x00, "Intel Lewisburg (RAID)", 0}, + {0xa2828086, 0x00, "Intel Union Point", 0}, + {0xa2868086, 0x00, "Intel Union Point (RAID)", 0}, + {0xa28e8086, 0x00, "Intel Union Point (RAID)", 0}, {0x23238086, 0x00, "Intel DH89xxCC", 0}, {0x2360197b, 0x00, "JMicron JMB360", 0}, {0x2361197b, 0x00, "JMicron JMB361", AHCI_Q_NOFORCE | AHCI_Q_1CH}, Modified: stable/11/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.c Wed Aug 16 08:49:11 2017 (r322571) +++ stable/11/sys/dev/sound/pci/hda/hdac.c Wed Aug 16 10:28:34 2017 (r322572) @@ -97,6 +97,8 @@ static const struct { { HDA_INTEL_KBLKLP, "Intel Kabylake-LP", 0, 0 }, { HDA_INTEL_SRPT, "Intel Sunrise Point", 0, 0 }, { HDA_INTEL_KBLK, "Intel Kabylake", 0, 0 }, + { HDA_INTEL_KBLKH, "Intel Kabylake-H", 0, 0 }, + { HDA_INTEL_CFLK, "Intel Coffelake", 0, 0 }, { HDA_INTEL_82801F, "Intel 82801F", 0, 0 }, { HDA_INTEL_63XXESB, "Intel 631x/632xESB", 0, 0 }, { HDA_INTEL_82801G, "Intel 82801G", 0, 0 }, Modified: stable/11/sys/dev/sound/pci/hda/hdac.h ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.h Wed Aug 16 08:49:11 2017 (r322571) +++ stable/11/sys/dev/sound/pci/hda/hdac.h Wed Aug 16 10:28:34 2017 (r322572) @@ -73,6 +73,8 @@ #define HDA_INTEL_KBLKLP HDA_MODEL_CONSTRUCT(INTEL, 0x9d71) #define HDA_INTEL_SRPT HDA_MODEL_CONSTRUCT(INTEL, 0xa170) #define HDA_INTEL_KBLK HDA_MODEL_CONSTRUCT(INTEL, 0xa171) +#define HDA_INTEL_KBLKH HDA_MODEL_CONSTRUCT(INTEL, 0xa2f0) +#define HDA_INTEL_CFLK HDA_MODEL_CONSTRUCT(INTEL, 0xa348) #define HDA_INTEL_ALL HDA_MODEL_CONSTRUCT(INTEL, 0xffff) /* Nvidia */ Modified: stable/11/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/11/sys/dev/usb/controller/xhci_pci.c Wed Aug 16 08:49:11 2017 (r322571) +++ stable/11/sys/dev/usb/controller/xhci_pci.c Wed Aug 16 10:28:34 2017 (r322572) @@ -132,6 +132,10 @@ xhci_pci_match(device_t self) return ("Intel Sunrise Point-LP USB 3.0 controller"); case 0xa12f8086: return ("Intel Sunrise Point USB 3.0 controller"); + case 0xa1af8086: + return ("Intel Lewisburg USB 3.0 controller"); + case 0xa2af8086: + return ("Intel Union Point USB 3.0 controller"); case 0xa01b177d: return ("Cavium ThunderX USB 3.0 controller"); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 10:30:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9975DD2BC1; Wed, 16 Aug 2017 10:30:24 +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 mx1.freebsd.org (Postfix) with ESMTPS id 9095D7D3DD; Wed, 16 Aug 2017 10:30:24 +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 v7GAUNdm074052; Wed, 16 Aug 2017 10:30:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GAUN9x074048; Wed, 16 Aug 2017 10:30:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201708161030.v7GAUN9x074048@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 16 Aug 2017 10:30: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: r322573 - in stable/11/sys/dev: ahci ata ata/chipsets sound/pci/hda X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11/sys/dev: ahci ata ata/chipsets sound/pci/hda X-SVN-Commit-Revision: 322573 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.23 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, 16 Aug 2017 10:30:24 -0000 Author: mav Date: Wed Aug 16 10:30:23 2017 New Revision: 322573 URL: https://svnweb.freebsd.org/changeset/base/322573 Log: MFC r322309, r322316: Use "Ibex Peak" codename for "5 Series/3400 Series" chipsets. This is shorter and unifies naming with later chipsets. Modified: stable/11/sys/dev/ahci/ahci_pci.c stable/11/sys/dev/ata/ata-pci.h stable/11/sys/dev/ata/chipsets/ata-intel.c stable/11/sys/dev/sound/pci/hda/hdac.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ahci/ahci_pci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci_pci.c Wed Aug 16 10:28:34 2017 (r322572) +++ stable/11/sys/dev/ahci/ahci_pci.c Wed Aug 16 10:30:23 2017 (r322573) @@ -111,12 +111,12 @@ static const struct { {0x3a058086, 0x00, "Intel ICH10 (RAID)", 0}, {0x3a228086, 0x00, "Intel ICH10", 0}, {0x3a258086, 0x00, "Intel ICH10 (RAID)", 0}, - {0x3b228086, 0x00, "Intel 5 Series/3400 Series", 0}, - {0x3b238086, 0x00, "Intel 5 Series/3400 Series", 0}, - {0x3b258086, 0x00, "Intel 5 Series/3400 Series (RAID)", 0}, - {0x3b298086, 0x00, "Intel 5 Series/3400 Series", 0}, - {0x3b2c8086, 0x00, "Intel 5 Series/3400 Series (RAID)", 0}, - {0x3b2f8086, 0x00, "Intel 5 Series/3400 Series", 0}, + {0x3b228086, 0x00, "Intel Ibex Peak", 0}, + {0x3b238086, 0x00, "Intel Ibex Peak", 0}, + {0x3b258086, 0x00, "Intel Ibex Peak (RAID)", 0}, + {0x3b298086, 0x00, "Intel Ibex Peak-M", 0}, + {0x3b2c8086, 0x00, "Intel Ibex Peak-M (RAID)", 0}, + {0x3b2f8086, 0x00, "Intel Ibex Peak-M", 0}, {0x1c028086, 0x00, "Intel Cougar Point", 0}, {0x1c038086, 0x00, "Intel Cougar Point", 0}, {0x1c048086, 0x00, "Intel Cougar Point (RAID)", 0}, Modified: stable/11/sys/dev/ata/ata-pci.h ============================================================================== --- stable/11/sys/dev/ata/ata-pci.h Wed Aug 16 10:28:34 2017 (r322572) +++ stable/11/sys/dev/ata/ata-pci.h Wed Aug 16 10:30:23 2017 (r322573) @@ -193,12 +193,12 @@ struct ata_pci_controller { #define ATA_I82801JI_S1 0x3a208086 #define ATA_I82801JI_S2 0x3a268086 -#define ATA_5Series_S1 0x3b208086 -#define ATA_5Series_S2 0x3b218086 -#define ATA_5Series_S3 0x3b268086 -#define ATA_5Series_S4 0x3b288086 -#define ATA_5Series_S5 0x3b2d8086 -#define ATA_5Series_S6 0x3b2e8086 +#define ATA_IBP_S1 0x3b208086 +#define ATA_IBP_S2 0x3b218086 +#define ATA_IBP_S3 0x3b268086 +#define ATA_IBP_S4 0x3b288086 +#define ATA_IBP_S5 0x3b2d8086 +#define ATA_IBP_S6 0x3b2e8086 #define ATA_CPT_S1 0x1c008086 #define ATA_CPT_S2 0x1c018086 Modified: stable/11/sys/dev/ata/chipsets/ata-intel.c ============================================================================== --- stable/11/sys/dev/ata/chipsets/ata-intel.c Wed Aug 16 10:28:34 2017 (r322572) +++ stable/11/sys/dev/ata/chipsets/ata-intel.c Wed Aug 16 10:30:23 2017 (r322573) @@ -149,12 +149,12 @@ ata_intel_probe(device_t dev) { ATA_I82801JD_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH10" }, { ATA_I82801JI_S1, 0, INTEL_6CH, 0, ATA_SA300, "ICH10" }, { ATA_I82801JI_S2, 0, INTEL_6CH2, 0, ATA_SA300, "ICH10" }, - { ATA_5Series_S1, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S2, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S3, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S4, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S5, 0, INTEL_6CH2, 0, ATA_SA300, "5 Series/3400 Series PCH" }, - { ATA_5Series_S6, 0, INTEL_6CH, 0, ATA_SA300, "5 Series/3400 Series PCH" }, + { ATA_IBP_S1, 0, INTEL_6CH, 0, ATA_SA300, "Ibex Peak" }, + { ATA_IBP_S2, 0, INTEL_6CH2, 0, ATA_SA300, "Ibex Peak" }, + { ATA_IBP_S3, 0, INTEL_6CH2, 0, ATA_SA300, "Ibex Peak" }, + { ATA_IBP_S4, 0, INTEL_6CH, 0, ATA_SA300, "Ibex Peak-M" }, + { ATA_IBP_S5, 0, INTEL_6CH2, 0, ATA_SA300, "Ibex Peak-M" }, + { ATA_IBP_S6, 0, INTEL_6CH, 0, ATA_SA300, "Ibex Peak-M" }, { ATA_CPT_S1, 0, INTEL_6CH, 0, ATA_SA600, "Cougar Point" }, { ATA_CPT_S2, 0, INTEL_6CH, 0, ATA_SA600, "Cougar Point" }, { ATA_CPT_S3, 0, INTEL_6CH2, 0, ATA_SA300, "Cougar Point" }, Modified: stable/11/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.c Wed Aug 16 10:28:34 2017 (r322572) +++ stable/11/sys/dev/sound/pci/hda/hdac.c Wed Aug 16 10:30:23 2017 (r322573) @@ -106,8 +106,8 @@ static const struct { { HDA_INTEL_82801I, "Intel 82801I", 0, 0 }, { HDA_INTEL_82801JI, "Intel 82801JI", 0, 0 }, { HDA_INTEL_82801JD, "Intel 82801JD", 0, 0 }, - { HDA_INTEL_PCH, "Intel 5 Series/3400 Series", 0, 0 }, - { HDA_INTEL_PCH2, "Intel 5 Series/3400 Series", 0, 0 }, + { HDA_INTEL_PCH, "Intel Ibex Peak", 0, 0 }, + { HDA_INTEL_PCH2, "Intel Ibex Peak", 0, 0 }, { HDA_INTEL_SCH, "Intel SCH", 0, 0 }, { HDA_NVIDIA_MCP51, "NVIDIA MCP51", 0, HDAC_QUIRK_MSI }, { HDA_NVIDIA_MCP55, "NVIDIA MCP55", 0, HDAC_QUIRK_MSI }, From owner-svn-src-stable-11@freebsd.org Wed Aug 16 12:01:23 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9712DD7636; Wed, 16 Aug 2017 12:01:23 +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 mx1.freebsd.org (Postfix) with ESMTPS id 79D2D8006E; Wed, 16 Aug 2017 12:01:23 +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 v7GC1M2d013185; Wed, 16 Aug 2017 12:01:22 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GC1MfD013184; Wed, 16 Aug 2017 12:01:22 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201708161201.v7GC1MfD013184@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 16 Aug 2017 12:01: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: r322576 - 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: 322576 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.23 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, 16 Aug 2017 12:01:23 -0000 Author: ae Date: Wed Aug 16 12:01:22 2017 New Revision: 322576 URL: https://svnweb.freebsd.org/changeset/base/322576 Log: MFC r322328: Make user supplied data checks a bit stricter. key_msg2sp() is used for parsing data from setsockopt(IP[V6]_IPSEC_POLICY) call. This socket option is usually used to configure IPsec bypass for socket. Only privileged user can set this socket option. The message syntax is described here http://www.kame.net/newsletter/20021210/ and our libipsec is usually used to create the correct request. Add additional checks: * that sadb_x_ipsecrequest_len is not out of bounds of user supplied buffer * that src/dst's sa_len is the same * that 2*sa_len is not out of bounds of user supplied buffer * that 2*sa_len fits into bounds of sadb_x_ipsecrequest Reported by: Ilja van Sprundel Modified: stable/11/sys/netipsec/key.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netipsec/key.c ============================================================================== --- stable/11/sys/netipsec/key.c Wed Aug 16 10:59:37 2017 (r322575) +++ stable/11/sys/netipsec/key.c Wed Aug 16 12:01:22 2017 (r322576) @@ -1403,7 +1403,8 @@ key_msg2sp(struct sadb_x_policy *xpl0, size_t len, int while (tlen > 0) { /* length check */ - if (xisr->sadb_x_ipsecrequest_len < sizeof(*xisr)) { + if (xisr->sadb_x_ipsecrequest_len < sizeof(*xisr) || + xisr->sadb_x_ipsecrequest_len > tlen) { ipseclog((LOG_DEBUG, "%s: invalid ipsecrequest " "length.\n", __func__)); key_freesp(&newsp); @@ -1517,10 +1518,12 @@ key_msg2sp(struct sadb_x_policy *xpl0, size_t len, int if (xisr->sadb_x_ipsecrequest_len > sizeof(*xisr)) { struct sockaddr *paddr; + len = tlen - sizeof(*xisr); paddr = (struct sockaddr *)(xisr + 1); /* validity check */ - if (paddr->sa_len - > sizeof(isr->saidx.src)) { + if (len < sizeof(struct sockaddr) || + len < 2 * paddr->sa_len || + paddr->sa_len > sizeof(isr->saidx.src)) { ipseclog((LOG_DEBUG, "%s: invalid " "request address length.\n", __func__)); @@ -1528,13 +1531,26 @@ key_msg2sp(struct sadb_x_policy *xpl0, size_t len, int *error = EINVAL; return NULL; } + /* + * Request length should be enough to keep + * source and destination addresses. + */ + if (xisr->sadb_x_ipsecrequest_len < + sizeof(*xisr) + 2 * paddr->sa_len) { + ipseclog((LOG_DEBUG, "%s: invalid " + "ipsecrequest length.\n", + __func__)); + key_freesp(&newsp); + *error = EINVAL; + return (NULL); + } bcopy(paddr, &isr->saidx.src, paddr->sa_len); paddr = (struct sockaddr *)((caddr_t)paddr + paddr->sa_len); /* validity check */ - if (paddr->sa_len - > sizeof(isr->saidx.dst)) { + if (paddr->sa_len != + isr->saidx.src.sa.sa_len) { ipseclog((LOG_DEBUG, "%s: invalid " "request address length.\n", __func__)); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 13:06:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3865DDAEAE; Wed, 16 Aug 2017 13:06:27 +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 mx1.freebsd.org (Postfix) with ESMTPS id 7031482A36; Wed, 16 Aug 2017 13:06:27 +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 v7GD6Qtr038623; Wed, 16 Aug 2017 13:06:26 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GD6QwQ038621; Wed, 16 Aug 2017 13:06:26 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161306.v7GD6QwQ038621@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 13:06: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: r322577 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322577 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.23 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, 16 Aug 2017 13:06:27 -0000 Author: kevans Date: Wed Aug 16 13:06:26 2017 New Revision: 322577 URL: https://svnweb.freebsd.org/changeset/base/322577 Log: MFC r303444 (ed): Call basename() in a portable way. Pull a copy of the filename string before calling basename(). Change the loop to not return on its own, so we can put a free() statement at the bottom. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 12:01:22 2017 (r322576) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 13:06:26 2017 (r322577) @@ -61,21 +61,26 @@ static bool ctxover; bool file_matching(const char *fname) { - char *fname_base; + char *fname_base, *fname_buf; bool ret; ret = finclude ? false : true; - fname_base = basename(fname); + fname_buf = strdup(fname); + if (fname_buf == NULL) + err(2, "strdup"); + fname_base = basename(fname_buf); for (unsigned int i = 0; i < fpatterns; ++i) { if (fnmatch(fpattern[i].pat, fname, 0) == 0 || fnmatch(fpattern[i].pat, fname_base, 0) == 0) { - if (fpattern[i].mode == EXCL_PAT) - return (false); - else + if (fpattern[i].mode == EXCL_PAT) { + ret = false; + break; + } else ret = true; } } + free(fname_buf); return (ret); } From owner-svn-src-stable-11@freebsd.org Wed Aug 16 17:38:39 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B2C5DC30FA; Wed, 16 Aug 2017 17:38:39 +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 mx1.freebsd.org (Postfix) with ESMTPS id 44ACA677A6; Wed, 16 Aug 2017 17:38:39 +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 v7GHcche050839; Wed, 16 Aug 2017 17:38:38 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GHcbii050832; Wed, 16 Aug 2017 17:38:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161738.v7GHcbii050832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 17:38:37 +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: r322582 - in stable/11: share/man/man5 share/mk tools/build/options usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: share/man/man5 share/mk tools/build/options usr.bin/grep X-SVN-Commit-Revision: 322582 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.23 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, 16 Aug 2017 17:38:39 -0000 Author: kevans Date: Wed Aug 16 17:38:37 2017 New Revision: 322582 URL: https://svnweb.freebsd.org/changeset/base/322582 Log: MFC r317254: bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch Bugs have been found in the fastmatch implementation as used in bsdgrep. Some have been fixed (r316495) while fixes for others are in review (D10098). In comparison with the fastmatch implementation, Kyle Evans found that: - regex(3)'s performance with literal expressions offers a speed improvement over fastmatch - regex(3)'s performance, both with simple BREs and EREs, seems to be comparable The regex implementation was imported in r226035, and the commit message reports: This is a temporary solution until the whole regex library is not replaced so that BSD grep development can continue and the backported code gets some review and testing. This change only improves scalability slightly, there is no big performance boost yet but several minor bugs have been found and fixed. Introduce a WITH_/WITHOUT_BSD_GREP_FASTMATCH knob to support testing of both approaches. Regenerate src.conf(5) as per the original commit PR: 175314, 194823 Approved by: emaste (mentor, blanket MFC) Added: stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH - copied unchanged from r317254, head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH Modified: stable/11/share/man/man5/src.conf.5 stable/11/share/mk/src.opts.mk stable/11/usr.bin/grep/Makefile stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man5/src.conf.5 ============================================================================== --- stable/11/share/man/man5/src.conf.5 Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/share/man/man5/src.conf.5 Wed Aug 16 17:38:37 2017 (r322582) @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd August 5, 2017 +.Dd August 16, 2017 .Dt SRC.CONF 5 .Os .Sh NAME @@ -214,6 +214,11 @@ Set to not build the BSD licensed version of cpio base .Xr libarchive 3 . .It Va WITH_BSD_GREP Install BSD-licensed grep as '[ef]grep' instead of GNU grep. +.It Va WITHOUT_BSD_GREP_FASTMATCH +Set this option to exclude the fastmatch implementation from +.Xr bsdgrep 1 , +instead using only +.Xr regex 3 . .It Va WITHOUT_BSNMP Set to not build or install .Xr bsnmpd 1 Modified: stable/11/share/mk/src.opts.mk ============================================================================== --- stable/11/share/mk/src.opts.mk Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/share/mk/src.opts.mk Wed Aug 16 17:38:37 2017 (r322582) @@ -62,6 +62,7 @@ __DEFAULT_YES_OPTIONS = \ BOOTPARAMD \ BOOTPD \ BSD_CPIO \ + BSD_GREP_FASTMATCH \ BSDINSTALL \ BSNMP \ BZIP2 \ Copied: stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH (from r317254, head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH Wed Aug 16 17:38:37 2017 (r322582, copy of r317254, head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH) @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set this option to exclude the fastmatch implementation from +.Xr bsdgrep 1 , +instead using only +.Xr regex 3 . Modified: stable/11/usr.bin/grep/Makefile ============================================================================== --- stable/11/usr.bin/grep/Makefile Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/usr.bin/grep/Makefile Wed Aug 16 17:38:37 2017 (r322582) @@ -15,10 +15,14 @@ bsdgrep.1: grep.1 .endif SRCS= file.c grep.c queue.c util.c -# Extra files ported backported form some regex improvements +.if ${MK_BSD_GREP_FASTMATCH} == "yes" +# Extra files ported backported for some regex improvements .PATH: ${.CURDIR}/regex SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c CFLAGS+=-I${.CURDIR}/regex +.else +CFLAGS+= -DWITHOUT_FASTMATCH +.endif CFLAGS.gcc+= --param max-inline-insns-single=500 Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 17:38:37 2017 (r322582) @@ -50,7 +50,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifndef WITHOUT_FASTMATCH #include "fastmatch.h" +#endif #include "grep.h" #ifndef WITHOUT_NLS @@ -87,7 +89,9 @@ unsigned int patterns; static unsigned int pattern_sz; struct pat *pattern; regex_t *r_pattern; +#ifndef WITHOUT_FASTMATCH fastmatch_t *fg_pattern; +#endif /* Filename exclusion/inclusion patterns */ unsigned int fpatterns, dpatterns; @@ -716,20 +720,25 @@ main(int argc, char *argv[]) usage(); } +#ifndef WITHOUT_FASTMATCH fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); +#endif r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); /* Check if cheating is allowed (always is for fgrep). */ for (i = 0; i < patterns; ++i) { +#ifndef WITHOUT_FASTMATCH + /* Attempt compilation with fastmatch regex and fallback to + regex(3) if it fails. */ if (fastncomp(&fg_pattern[i], pattern[i].pat, - pattern[i].len, cflags) != 0) { - /* Fall back to full regex library */ - c = regcomp(&r_pattern[i], pattern[i].pat, cflags); - if (c != 0) { - regerror(c, &r_pattern[i], re_error, - RE_ERROR_BUF); - errx(2, "%s", re_error); - } + pattern[i].len, cflags) == 0) + continue; +#endif + c = regcomp(&r_pattern[i], pattern[i].pat, cflags); + if (c != 0) { + regerror(c, &r_pattern[i], re_error, + RE_ERROR_BUF); + errx(2, "%s", re_error); } } Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/usr.bin/grep/grep.h Wed Aug 16 17:38:37 2017 (r322582) @@ -36,7 +36,9 @@ #include #include +#ifndef WITHOUT_FASTMATCH #include "fastmatch.h" +#endif #ifdef WITHOUT_NLS #define getstr(n) errstr[n] @@ -127,7 +129,9 @@ extern unsigned int dpatterns, fpatterns, patterns; extern struct pat *pattern; extern struct epat *dpattern, *fpattern; extern regex_t *er_pattern, *r_pattern; +#ifndef WITHOUT_FASTMATCH extern fastmatch_t *fg_pattern; +#endif /* For regex errors */ #define RE_ERROR_BUF 512 Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 17:22:42 2017 (r322581) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 17:38:37 2017 (r322582) @@ -49,7 +49,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifndef WITHOUT_FASTMATCH #include "fastmatch.h" +#endif #include "grep.h" static int linesqueued; @@ -317,10 +319,12 @@ procline(struct str *l, int nottext) for (i = 0; i < patterns; i++) { pmatch.rm_so = st; pmatch.rm_eo = l->len; +#ifndef WITHOUT_FASTMATCH if (fg_pattern[i].pattern) r = fastexec(&fg_pattern[i], l->dat, 1, &pmatch, leflags); else +#endif r = regexec(&r_pattern[i], l->dat, 1, &pmatch, leflags); r = (r == 0) ? 0 : REG_NOMATCH; @@ -332,7 +336,11 @@ procline(struct str *l, int nottext) (size_t)pmatch.rm_eo != l->len) r = REG_NOMATCH; /* Check for whole word match */ +#ifndef WITHOUT_FASTMATCH if (r == 0 && (wflag || fg_pattern[i].word)) { +#else + if (r == 0 && wflag) { +#endif wchar_t wbegin, wend; wbegin = wend = L' '; From owner-svn-src-stable-11@freebsd.org Wed Aug 16 17:42:40 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77C6EDC3721; Wed, 16 Aug 2017 17:42:40 +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 mx1.freebsd.org (Postfix) with ESMTPS id 5333B67D1F; Wed, 16 Aug 2017 17:42:40 +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 v7GHgdjS054783; Wed, 16 Aug 2017 17:42:39 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GHgdB4054781; Wed, 16 Aug 2017 17:42:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161742.v7GHgdB4054781@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 17:42: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: r322583 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322583 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.23 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, 16 Aug 2017 17:42:40 -0000 Author: kevans Date: Wed Aug 16 17:42:39 2017 New Revision: 322583 URL: https://svnweb.freebsd.org/changeset/base/322583 Log: MFC r317665: bsdgrep: fix -w -v matching improperly with certain patterns -w and -v flag matching was mostly functional but had some minor problems: 1. -w flag processing only allowed one iteration through pattern matching on a line. This was problematic if one pattern could match more than once, or if there were multiple patterns and the earliest/ longest match was not the most ideal, and 2. Previous work "fixed" things to not further process a line if the first iteration through patterns produced no matches. This is clearly wrong if we're dealing with the more restrictive -w matching. #2 breakage could have also occurred before recent broad rewrites, but it would be more arbitrary based on input patterns as to whether or not it actually affected things. Fix both of these by forcing a retry of the patterns after advancing just past the start of the first match if we're doing more restrictive -w matching and we didn't get any hits to start with. Also move -v flag processing outside of the loop so that we have a greater change to match in the more restrictive cases. This wasn't strictly wrong, but it could be a little more error prone. While here, introduce some regressions tests for this behavior and fix some excessive wrapping nearby that hindered readability. GNU grep passes these new tests. PR: 218467, 218811 Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 17:38:37 2017 (r322582) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 17:42:39 2017 (r322583) @@ -93,6 +93,12 @@ word_regexps_body() { atf_check -o file:"$(atf_get_srcdir)/d_word_regexps.out" \ grep -w separated $(atf_get_srcdir)/d_input + + # Begin FreeBSD + printf "xmatch pmatch\n" > test1 + + atf_check -o inline:"pmatch\n" grep -Eow "(match )?pmatch" test1 + # End FreeBSD } atf_test_case begin_end @@ -439,6 +445,23 @@ grep_sanity_body() atf_check -o inline:"M\n" grep -o -e "M\{1\}" test2 } + +atf_test_case wv_combo_break +wv_combo_break_head() +{ + atf_set "descr" "Check for incorrectly matching lines with both -w and -v flags (PR 218467)" +} +wv_combo_break_body() +{ + printf "x xx\n" > test1 + printf "xx x\n" > test2 + + atf_check -o file:test1 grep -w "x" test1 + atf_check -o file:test2 grep -w "x" test2 + + atf_check -s exit:1 grep -v -w "x" test1 + atf_check -s exit:1 grep -v -w "x" test2 +} # End FreeBSD atf_init_test_cases() @@ -467,6 +490,7 @@ atf_init_test_cases() atf_add_test_case escmap atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen + atf_add_test_case wv_combo_break atf_add_test_case fgrep_sanity atf_add_test_case egrep_sanity atf_add_test_case grep_sanity Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 17:38:37 2017 (r322582) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 17:42:39 2017 (r322583) @@ -305,6 +305,7 @@ procline(struct str *l, int nottext) unsigned int i; int c = 0, m = 0, r = 0, lastmatches = 0, leflags = eflags; int startm = 0; + int retry; /* Initialize to avoid a false positive warning from GCC. */ lastmatch.rm_so = lastmatch.rm_eo = 0; @@ -313,6 +314,7 @@ procline(struct str *l, int nottext) while (st <= l->len) { lastmatches = 0; startm = m; + retry = 0; if (st > 0) leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ @@ -356,6 +358,17 @@ procline(struct str *l, int nottext) else if (iswword(wbegin) || iswword(wend)) r = REG_NOMATCH; + /* + * If we're doing whole word matching and we + * matched once, then we should try the pattern + * again after advancing just past the start of + * the earliest match. This allows the pattern + * to match later on in the line and possibly + * still match a whole word. + */ + if (r == REG_NOMATCH && + (retry == 0 || pmatch.rm_so + 1 < retry)) + retry = pmatch.rm_so + 1; } if (r == 0) { lastmatches++; @@ -385,9 +398,14 @@ procline(struct str *l, int nottext) } } - if (vflag) { - c = !c; - break; + /* + * Advance to just past the start of the earliest match, try + * again just in case we still have a chance to match later in + * the string. + */ + if (lastmatches == 0 && retry > 0) { + st = retry; + continue; } /* One pass if we are not recording matches */ @@ -409,6 +427,9 @@ procline(struct str *l, int nottext) st = nst; } + + if (vflag) + c = !c; /* Count the matches if we have a match limit */ if (mflag) From owner-svn-src-stable-11@freebsd.org Wed Aug 16 17:46:48 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B834DC3D60; Wed, 16 Aug 2017 17:46:48 +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 mx1.freebsd.org (Postfix) with ESMTPS id 06D086829F; Wed, 16 Aug 2017 17:46:47 +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 v7GHklMY055168; Wed, 16 Aug 2017 17:46:47 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GHkjcC055154; Wed, 16 Aug 2017 17:46:45 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161746.v7GHkjcC055154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 17:46: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: r322584 - in stable/11/usr.bin/grep: . nls X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . nls X-SVN-Commit-Revision: 322584 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.23 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, 16 Aug 2017 17:46:48 -0000 Author: kevans Date: Wed Aug 16 17:46:45 2017 New Revision: 322584 URL: https://svnweb.freebsd.org/changeset/base/322584 Log: MFC r317678: bsdgrep: Add GNU compatible version string indicator As reported in r218614 it's useful to have an indication of whether or not BSD grep was built with GNU_GREP_COMPAT. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/Makefile stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/nls/C.msg stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/Makefile ============================================================================== --- stable/11/usr.bin/grep/Makefile Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/Makefile Wed Aug 16 17:46:45 2017 (r322584) @@ -82,7 +82,7 @@ CFLAGS+= -DWITHOUT_BZIP2 .endif .if ${MK_GNU_GREP_COMPAT} != "no" -CFLAGS+= -I${DESTDIR}/usr/include/gnu +CFLAGS+= -I${DESTDIR}/usr/include/gnu -DWITH_GNU LIBADD+= gnuregex .endif Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 17:46:45 2017 (r322584) @@ -75,6 +75,7 @@ const char *errstr[] = { /* 7*/ "\t[--null] [pattern] [file ...]\n", /* 8*/ "Binary file %s matches\n", /* 9*/ "%s (BSD grep) %s\n", +/* 10*/ "%s (BSD grep, GNU compatible) %s\n", }; /* Flags passed to regcomp() and regexec() */ @@ -597,7 +598,11 @@ main(int argc, char *argv[]) filebehave = FILE_MMAP; break; case 'V': +#ifdef WITH_GNU + printf(getstr(10), getprogname(), VERSION); +#else printf(getstr(9), getprogname(), VERSION); +#endif exit(0); case 'v': vflag = true; Modified: stable/11/usr.bin/grep/nls/C.msg ============================================================================== --- stable/11/usr.bin/grep/nls/C.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/C.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [pattern] [file ...]\n" 8 "Binary file %s matches\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/es_ES.ISO8859-1.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [pauta] [fichero ...]\n" 8 "fichero binario %s se ajusta\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/gl_ES.ISO8859-1.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [pauta] [ficheiro ...]\n" 8 "ficheiro binario %s conforma\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg ============================================================================== --- stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/hu_HU.ISO8859-2.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [minta] [fájl ...]\n" 8 "%s bináris fájl illeszkedik\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/ja_JP.SJIS.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [ƒpƒ^[ƒ“] [ƒtƒ@ƒCƒ‹–¼ ...]\n" 8 "ƒoƒCƒiƒŠƒtƒ@ƒCƒ‹ %s ‚Ƀ}ƒbƒ`‚µ‚Ü‚µ‚½\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/ja_JP.UTF-8.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [パターン] [ファイルå ...]\n" 8 "ãƒã‚¤ãƒŠãƒªãƒ•ã‚¡ã‚¤ãƒ« %s ã«ãƒžãƒƒãƒã—ã¾ã—ãŸ\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/ja_JP.eucJP.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [¥Ñ¥¿¡¼¥ó] [¥Õ¥¡¥¤¥ë̾ ...]\n" 8 "¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë %s ¤Ë¥Þ¥Ã¥Á¤·¤Þ¤·¤¿\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg ============================================================================== --- stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/pt_BR.ISO8859-1.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [padrão] [arquivo ...]\n" 8 "arquivo binário %s casa com o padrão\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg ============================================================================== --- stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/ru_RU.KOI8-R.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [ÛÁÂÌÏÎ] [ÆÁÊÌ ...]\n" 8 "Ä×ÏÉÞÎÙÊ ÆÁÊÌ %s ÓÏ×ÐÁÄÁÅÔ\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/uk_UA.UTF-8.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -10,3 +10,4 @@ $quote " 7 "\t[--null] [шаблон] [файл ...]\n" 8 "двійковий файл %s Ñпівпадає\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" Modified: stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg ============================================================================== --- stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg Wed Aug 16 17:42:39 2017 (r322583) +++ stable/11/usr.bin/grep/nls/zh_CN.UTF-8.msg Wed Aug 16 17:46:45 2017 (r322584) @@ -11,3 +11,4 @@ $quote " 7 "\t[--null] [模å¼] [文件å ...]\n" 8 "二进制文件 %s 包å«æ¨¡å¼\n" 9 "%s (BSD grep) %s\n" +10 "%s (BSD grep, GNU compatible) %s\n" From owner-svn-src-stable-11@freebsd.org Wed Aug 16 17:54:31 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 258D7DC54C6; Wed, 16 Aug 2017 17:54: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 mx1.freebsd.org (Postfix) with ESMTPS id 0277E687BB; Wed, 16 Aug 2017 17:54:30 +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 v7GHsU5q059236; Wed, 16 Aug 2017 17:54:30 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GHsU0n059235; Wed, 16 Aug 2017 17:54:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161754.v7GHsU0n059235@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 17:54: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: r322586 - stable/11/usr.bin/grep/regex X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep/regex X-SVN-Commit-Revision: 322586 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.23 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, 16 Aug 2017 17:54:31 -0000 Author: kevans Date: Wed Aug 16 17:54:29 2017 New Revision: 322586 URL: https://svnweb.freebsd.org/changeset/base/322586 Log: bsdgrep: fix escape map building when using TRE (BSD_GREP_FASTMATCH) MFC r317700: bsdgrep: use calloc where appropriate in grep's tre-fastmatch Also apply style(9) to a related NULL check. MFC r317701: bsdgrep: correct test sense from r317700 Kyle's change in review D10098 was correct. I introduced the error when extracting a portion of that change. MFC r317704: bsdgrep: fix escape map building for multibyte strings In BSD grep, fix escape map building in the regex parser. It was previously using memory not explicitly initialized, and the MBS escape map was being built based on a version of the pattern with escapes already parsed out. This is Kyle's change, but I restored the broken style that already exists in this file. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 17:54:24 2017 (r322585) +++ stable/11/usr.bin/grep/regex/tre-fastmatch.c Wed Aug 16 17:54:29 2017 (r322586) @@ -98,6 +98,18 @@ static int fastcmp(const fastmatch_t *fg, const void * fg->pattern[siz] = '\0'; \ } \ +#define CONV_MBS_PAT(src, dest, destsz) \ + { \ + destsz = wcstombs(NULL, src, 0); \ + if (destsz == (size_t)-1) \ + return REG_BADPAT; \ + dest = malloc(destsz + 1); \ + if (dest == NULL) \ + return REG_ESPACE; \ + wcstombs(dest, src, destsz); \ + dest[destsz] = '\0'; \ + } \ + #define IS_OUT_OF_BOUNDS \ ((!fg->reversed \ ? ((type == STR_WIDE) ? ((j + fg->wlen) > len) \ @@ -630,7 +642,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pa if (escaped) { if (!_escmap) - _escmap = malloc(n * sizeof(bool)); + _escmap = calloc(n, sizeof(bool)); if (!_escmap) { free(tmp); @@ -714,8 +726,8 @@ badpat: { if (fg->wescmap != NULL) { - fg->escmap = malloc(fg->len * sizeof(bool)); - if (!fg->escmap) + fg->escmap = calloc(fg->len, sizeof(bool)); + if (fg->escmap == NULL) { tre_free_fast(fg); return REG_ESPACE; @@ -723,15 +735,29 @@ badpat: } escaped = false; - for (unsigned int i = 0; i < fg->len; i++) - if (fg->pattern[i] == '\\') - escaped = !escaped; - else if (fg->pattern[i] == '.' && fg->escmap && escaped) + char *_checkpat = NULL; + size_t _checklen = 0; + unsigned int escofs = 0; + /* + * Make a copy here of the original pattern, because fg->pattern has + * already been stripped of all escape sequences in the above processing. + * This is necessary if we wish to later treat fg->escmap as an actual, + * functional replacement of fg->wescmap. + */ + CONV_MBS_PAT(pat, _checkpat, _checklen); + for (unsigned int i = 0; i < n; i++) + if (_checkpat[i] == '\\') { - fg->escmap[i] = true; + escaped = !escaped; + if (escaped) + ++escofs; + } + else if (_checkpat[i] == '.' && fg->escmap != NULL && escaped) + { + fg->escmap[i - escofs] = true; escaped = false; } - else if (fg->pattern[i] == '.' && !escaped) + else if (_checkpat[i] == '.' && !escaped) { hasdot = i; if (firstdot == -1) @@ -739,6 +765,7 @@ badpat: } else escaped = false; + free(_checkpat); } #else SAVE_PATTERN(tmp, pos, fg->pattern, fg->len); From owner-svn-src-stable-11@freebsd.org Wed Aug 16 18:00:34 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B923BDC5A05; Wed, 16 Aug 2017 18:00:34 +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 mx1.freebsd.org (Postfix) with ESMTPS id 0C0FD68B37; Wed, 16 Aug 2017 18:00:33 +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 v7GI0Xc1059565; Wed, 16 Aug 2017 18:00:33 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GI0W8A059555; Wed, 16 Aug 2017 18:00:32 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708161800.v7GI0W8A059555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 18:00: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: r322587 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Commit-Revision: 322587 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.23 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, 16 Aug 2017 18:00:34 -0000 Author: kevans Date: Wed Aug 16 18:00:32 2017 New Revision: 322587 URL: https://svnweb.freebsd.org/changeset/base/322587 Log: bsdgrep: fix -w flag matching with an empty pattern MFC r317703: bsdgrep: fix -w flag matching with an empty pattern -w flag matching with an empty pattern was generally 'broken', allowing matches to occur on any line whether or not it actually matches -w criteria. This fix required a good amount of refactoring to address. procline() is altered to *only* process the line and return whether it was a match or not, necessary to be able to short-circuit the whole function in case of this matchall flag. -m flag handling is moved out as well because it suffers from the same fate as context handling if we bypass any actual pattern matching. The matching context (matches, mostly) didn't previously exist outside of procline(), so we go ahead and create context object for file processing bits to pass around. grep_printline() was created due to this, for the scenarios where the matches don't actually matter and we just want to print a line or two, a la flushing the context queue and no -o or --color specified. Damage from this broken behavior would have been mitigated by the fact that it is unlikely users would invoke grep -w with an empty pattern. This was identified while checking PR 105221 for problems it this may cause in BSD grep, but PR 105221 is *not* a report of this behavior. MFC r317741: bsdgrep: correct uninitialized variable introduced in r317703 MFC r317842: bsdgrep: don't ouptut matches with -c, -l, -L Refactoring done in r317703 broke -c, -l, and -L flags implying suppression of match printing. Fortunately this is just a matter of not doing any printing of the resulting matches and context printing was not broken in this refactoring. Add some regression tests since this area may still see further refactoring, include different context flags as well even though they were not broken in this case. PR: 219077 Approved by: emaste (mentor, blanket MFC) Added: stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.in - copied unchanged from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.in stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.out - copied unchanged from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_f.out - copied unchanged from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_f.out stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_g.out - copied unchanged from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_g.out Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/queue.c stable/11/usr.bin/grep/tests/Makefile stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.in (from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.in Wed Aug 16 18:00:32 2017 (r322587, copy of r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.in) @@ -0,0 +1,10 @@ +monkey +banana +apple +fruit +monkey +banna +apple +fruit +apple +monkey Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.out (from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_e.out Wed Aug 16 18:00:32 2017 (r322587, copy of r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_e.out) @@ -0,0 +1,9 @@ +monkey +banana +apple +fruit +monkey +banna +-- +apple +monkey Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_f.out (from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_f.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_f.out Wed Aug 16 18:00:32 2017 (r322587, copy of r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_f.out) @@ -0,0 +1,9 @@ +monkey +banana +apple +fruit +monkey +banna +apple +fruit +apple Copied: stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_g.out (from r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_g.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/d_context_g.out Wed Aug 16 18:00:32 2017 (r322587, copy of r317703, head/contrib/netbsd-tests/usr.bin/grep/d_context_g.out) @@ -0,0 +1,8 @@ +apple +fruit +-- +banna +apple +fruit +apple +monkey Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Wed Aug 16 18:00:32 2017 (r322587) @@ -171,6 +171,12 @@ context_body() atf_check -o file:d_context_b.out grep -A3 tilt d_context_a.in atf_check -o file:d_context_c.out grep -B4 Whig d_context_a.in atf_check -o file:d_context_d.out grep -C1 pig d_context_a.in d_context_b.in + atf_check -o file:d_context_e.out \ + grep -E -C1 '(banana|monkey)' d_context_e.in + atf_check -o file:d_context_f.out \ + grep -Ev -B2 '(banana|monkey|fruit)' d_context_e.in + atf_check -o file:d_context_g.out \ + grep -Ev -A1 '(banana|monkey|fruit)' d_context_e.in } atf_test_case file_exp @@ -386,6 +392,32 @@ zerolen_body() atf_check -o inline:"Eggs\nCheese\n" grep -v -e "^$" test1 } +atf_test_case wflag_emptypat +wflag_emptypat_head() +{ + atf_set "descr" "Check for proper handling of -w with an empty pattern (PR 105221)" +} +wflag_emptypat_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test does not pass with GNU grep in base" + fi + + printf "" > test1 + printf "\n" > test2 + printf "qaz" > test3 + printf " qaz\n" > test4 + + atf_check -s exit:1 -o empty grep -w -e "" test1 + + atf_check -o file:test2 grep -w -e "" test2 + + atf_check -s exit:1 -o empty grep -w -e "" test3 + + atf_check -o file:test4 grep -w -e "" test4 +} + atf_test_case fgrep_sanity fgrep_sanity_head() { @@ -462,6 +494,34 @@ wv_combo_break_body() atf_check -s exit:1 grep -v -w "x" test1 atf_check -s exit:1 grep -v -w "x" test2 } + +atf_test_case grep_nomatch_flags +grep_nomatch_flags_head() +{ + atf_set "descr" "Check for no match (-c, -l, -L, -q) flags not producing line matches or context (PR 219077)" +} + +grep_nomatch_flags_body() +{ + printf "A\nB\nC\n" > test1 + + atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1 + atf_check -o inline:"1\n" grep -c -B 1 -e "B" test1 + atf_check -o inline:"1\n" grep -c -A 1 -e "B" test1 + atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1 + + atf_check -o inline:"test1\n" grep -l -e "B" test1 + atf_check -o inline:"test1\n" grep -l -B 1 -e "B" test1 + atf_check -o inline:"test1\n" grep -l -A 1 -e "B" test1 + atf_check -o inline:"test1\n" grep -l -C 1 -e "B" test1 + + atf_check -s exit:1 -o inline:"test1\n" grep -L -e "D" test1 + + atf_check -o empty grep -q -e "B" test1 + atf_check -o empty grep -q -B 1 -e "B" test1 + atf_check -o empty grep -q -A 1 -e "B" test1 + atf_check -o empty grep -q -C 1 -e "B" test1 +} # End FreeBSD atf_init_test_cases() @@ -490,9 +550,11 @@ atf_init_test_cases() atf_add_test_case escmap atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen + atf_add_test_case wflag_emptypat atf_add_test_case wv_combo_break atf_add_test_case fgrep_sanity atf_add_test_case egrep_sanity atf_add_test_case grep_sanity + atf_add_test_case grep_nomatch_flags # End FreeBSD } Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 18:00:32 2017 (r322587) @@ -82,7 +82,13 @@ const char *errstr[] = { int cflags = REG_NOSUB; int eflags = REG_STARTEND; -/* Shortcut for matching all cases like empty regex */ +/* XXX TODO: Get rid of this flag. + * matchall is a gross hack that means that an empty pattern was passed to us. + * It is a necessary evil at the moment because our regex(3) implementation + * does not allow for empty patterns, as supported by POSIX's definition of + * grammar for BREs/EREs. When libregex becomes available, it would be wise + * to remove this and let regex(3) handle the dirty details of empty patterns. + */ bool matchall; /* Searching patterns */ @@ -154,9 +160,6 @@ enum { static inline const char *init_color(const char *); /* Housekeeping */ -bool first = true; /* flag whether we are processing the first match */ -bool prev; /* flag whether or not the previous line matched */ -int tail; /* lines left to print */ bool file_err; /* file reading error */ /* @@ -730,20 +733,25 @@ main(int argc, char *argv[]) #endif r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); - /* Check if cheating is allowed (always is for fgrep). */ - for (i = 0; i < patterns; ++i) { + /* Don't process any patterns if we have a blank one */ + if (!matchall) { + /* Check if cheating is allowed (always is for fgrep). */ + for (i = 0; i < patterns; ++i) { #ifndef WITHOUT_FASTMATCH - /* Attempt compilation with fastmatch regex and fallback to - regex(3) if it fails. */ - if (fastncomp(&fg_pattern[i], pattern[i].pat, - pattern[i].len, cflags) == 0) - continue; + /* + * Attempt compilation with fastmatch regex and + * fallback to regex(3) if it fails. + */ + if (fastncomp(&fg_pattern[i], pattern[i].pat, + pattern[i].len, cflags) == 0) + continue; #endif - c = regcomp(&r_pattern[i], pattern[i].pat, cflags); - if (c != 0) { - regerror(c, &r_pattern[i], re_error, - RE_ERROR_BUF); - errx(2, "%s", re_error); + c = regcomp(&r_pattern[i], pattern[i].pat, cflags); + if (c != 0) { + regerror(c, &r_pattern[i], re_error, + RE_ERROR_BUF); + errx(2, "%s", re_error); + } } } Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/usr.bin/grep/grep.h Wed Aug 16 18:00:32 2017 (r322587) @@ -123,8 +123,7 @@ extern char *label; extern const char *color; extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave; -extern bool file_err, first, matchall, prev; -extern int tail; +extern bool file_err, matchall; extern unsigned int dpatterns, fpatterns, patterns; extern struct pat *pattern; extern struct epat *dpattern, *fpattern; @@ -145,10 +144,10 @@ void *grep_malloc(size_t size); void *grep_calloc(size_t nmemb, size_t size); void *grep_realloc(void *ptr, size_t size); char *grep_strdup(const char *str); -void printline(struct str *line, int sep, regmatch_t *matches, int m); +void grep_printline(struct str *line, int sep); /* queue.c */ -void enqueue(struct str *x); +bool enqueue(struct str *x); void printqueue(void); void clearqueue(void); Modified: stable/11/usr.bin/grep/queue.c ============================================================================== --- stable/11/usr.bin/grep/queue.c Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/usr.bin/grep/queue.c Wed Aug 16 18:00:32 2017 (r322587) @@ -53,7 +53,10 @@ static unsigned long long count; static struct qentry *dequeue(void); -void +/* + * Enqueue another line; return true if we've dequeued a line as a result + */ +bool enqueue(struct str *x) { struct qentry *item; @@ -72,7 +75,9 @@ enqueue(struct str *x) item = dequeue(); free(item->data.dat); free(item); + return (true); } + return (false); } static struct qentry * @@ -95,7 +100,7 @@ printqueue(void) struct qentry *item; while ((item = dequeue()) != NULL) { - printline(&item->data, '-', NULL, 0); + grep_printline(&item->data, '-'); free(item->data.dat); free(item); } Modified: stable/11/usr.bin/grep/tests/Makefile ============================================================================== --- stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/usr.bin/grep/tests/Makefile Wed Aug 16 18:00:32 2017 (r322587) @@ -20,9 +20,13 @@ ${PACKAGE}FILES+= d_context2_c.out ${PACKAGE}FILES+= d_context_a.in ${PACKAGE}FILES+= d_context_a.out ${PACKAGE}FILES+= d_context_b.in +${PACKAGE}FILES+= d_context_e.in ${PACKAGE}FILES+= d_context_b.out ${PACKAGE}FILES+= d_context_c.out ${PACKAGE}FILES+= d_context_d.out +${PACKAGE}FILES+= d_context_e.out +${PACKAGE}FILES+= d_context_f.out +${PACKAGE}FILES+= d_context_g.out ${PACKAGE}FILES+= d_egrep.out ${PACKAGE}FILES+= d_escmap.in ${PACKAGE}FILES+= d_f_file_empty.in Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Wed Aug 16 17:54:29 2017 (r322586) +++ stable/11/usr.bin/grep/util.c Wed Aug 16 18:00:32 2017 (r322587) @@ -54,12 +54,24 @@ __FBSDID("$FreeBSD$"); #endif #include "grep.h" -static int linesqueued; -static int procline(struct str *l, int); +static bool first_match = true; -static int lasta; -static bool ctxover; +/* + * Parsing context; used to hold things like matches made and + * other useful bits + */ +struct parsec { + regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ + struct str ln; /* Current line */ + size_t matchidx; /* Latest used match index */ + bool binary; /* Binary file? */ +}; + +static int procline(struct parsec *pc); +static void printline(struct parsec *pc, int sep); +static void printline_metadata(struct str *line, int sep); + bool file_matching(const char *fname) { @@ -183,14 +195,14 @@ grep_tree(char **argv) int procfile(const char *fn) { + struct parsec pc; struct file *f; struct stat sb; - struct str ln; + struct str *ln; mode_t s; - int c, t; + int c, last_outed, t, tail; + bool doctx, printmatch, same_file; - mcount = mlimit; - if (strcmp(fn, "-") == 0) { fn = label != NULL ? label : getstr(1); f = grep_open(NULL); @@ -213,57 +225,99 @@ procfile(const char *fn) return (0); } - ln.file = grep_malloc(strlen(fn) + 1); - strcpy(ln.file, fn); - ln.line_no = 0; - ln.len = 0; - ctxover = false; - linesqueued = 0; + /* Convenience */ + ln = &pc.ln; + pc.ln.file = grep_malloc(strlen(fn) + 1); + strcpy(pc.ln.file, fn); + pc.ln.line_no = 0; + pc.ln.len = 0; + pc.ln.off = -1; + pc.binary = f->binary; tail = 0; - lasta = 0; - ln.off = -1; + last_outed = 0; + same_file = false; + doctx = false; + printmatch = true; + if ((pc.binary && binbehave == BINFILE_BIN) || cflag || qflag || + lflag || Lflag) + printmatch = false; + if (printmatch && (Aflag != 0 || Bflag != 0)) + doctx = true; + mcount = mlimit; for (c = 0; c == 0 || !(lflag || qflag); ) { - ln.off += ln.len + 1; - if ((ln.dat = grep_fgetln(f, &ln.len)) == NULL || ln.len == 0) { - if (ln.line_no == 0 && matchall) - exit(0); + /* Reset match count for every line processed */ + pc.matchidx = 0; + pc.ln.off += pc.ln.len + 1; + if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL || + pc.ln.len == 0) { + if (pc.ln.line_no == 0 && matchall) + /* + * An empty file with an empty pattern and the + * -w flag does not match + */ + exit(matchall && wflag ? 1 : 0); else break; } - if (ln.len > 0 && ln.dat[ln.len - 1] == fileeol) - --ln.len; - ln.line_no++; + if (pc.ln.len > 0 && pc.ln.dat[pc.ln.len - 1] == fileeol) + --pc.ln.len; + pc.ln.line_no++; + /* Return if we need to skip a binary file */ - if (f->binary && binbehave == BINFILE_SKIP) { + if (pc.binary && binbehave == BINFILE_SKIP) { grep_close(f); - free(ln.file); + free(pc.ln.file); free(f); return (0); } - /* Process the file line-by-line, enqueue non-matching lines */ - if ((t = procline(&ln, f->binary)) == 0 && Bflag > 0) { - /* Except don't enqueue lines that appear in -A ctx */ - if (ln.line_no == 0 || lasta != ln.line_no) { - /* queue is maxed to Bflag number of lines */ - enqueue(&ln); - linesqueued++; - ctxover = false; + if ((t = procline(&pc)) == 0) + ++c; + + /* Deal with any -B context or context separators */ + if (t == 0 && doctx) { + if (!first_match && (!same_file || last_outed > 0)) + printf("--\n"); + if (Bflag > 0) + printqueue(); + tail = Aflag; + } + /* Print the matching line, but only if not quiet/binary */ + if (t == 0 && printmatch) { + printline(&pc, ':'); + first_match = false; + same_file = true; + last_outed = 0; + } + if (t != 0 && doctx) { + /* Deal with any -A context */ + if (tail > 0) { + printline(&pc, '-'); + tail--; + if (Bflag > 0) + clearqueue(); } else { /* - * Indicate to procline() that we have ctx - * overlap and make sure queue is empty. + * Enqueue non-matching lines for -B context. + * If we're not actually doing -B context or if + * the enqueue resulted in a line being rotated + * out, then go ahead and increment last_outed + * to signify a gap between context/match. */ - if (!ctxover) - clearqueue(); - ctxover = true; + if (Bflag == 0 || (Bflag > 0 && enqueue(ln))) + ++last_outed; } } - c += t; - if (mflag && mcount <= 0) - break; + + /* Count the matches if we have a match limit */ + if (t == 0 && mflag) { + --mcount; + if (mflag && mcount <= 0) + break; + } + } if (Bflag > 0) clearqueue(); @@ -271,7 +325,7 @@ procfile(const char *fn) if (cflag) { if (!hflag) - printf("%s:", ln.file); + printf("%s:", pc.ln.file); printf("%u\n", c); } if (lflag && !qflag && c != 0) @@ -282,7 +336,7 @@ procfile(const char *fn) binbehave == BINFILE_BIN && f->binary && !qflag) printf(getstr(8), fn); - free(ln.file); + free(pc.ln.file); free(f); return (c); } @@ -297,62 +351,72 @@ procfile(const char *fn) * appropriate output. */ static int -procline(struct str *l, int nottext) +procline(struct parsec *pc) { - regmatch_t matches[MAX_LINE_MATCHES]; - regmatch_t pmatch, lastmatch; + regmatch_t pmatch, lastmatch, chkmatch; + wchar_t wbegin, wend; size_t st = 0, nst = 0; unsigned int i; - int c = 0, m = 0, r = 0, lastmatches = 0, leflags = eflags; - int startm = 0; + int c = 0, r = 0, lastmatches = 0, leflags = eflags; + size_t startm = 0, matchidx; int retry; + matchidx = pc->matchidx; + + /* Special case: empty pattern with -w flag, check first character */ + if (matchall && wflag) { + if (pc->ln.len == 0) + return (0); + wend = L' '; + if (sscanf(&pc->ln.dat[0], "%lc", &wend) != 1 || iswword(wend)) + return (1); + else + return (0); + } else if (matchall) + return (0); + /* Initialize to avoid a false positive warning from GCC. */ lastmatch.rm_so = lastmatch.rm_eo = 0; /* Loop to process the whole line */ - while (st <= l->len) { + while (st <= pc->ln.len) { lastmatches = 0; - startm = m; + startm = matchidx; retry = 0; if (st > 0) leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ for (i = 0; i < patterns; i++) { pmatch.rm_so = st; - pmatch.rm_eo = l->len; + pmatch.rm_eo = pc->ln.len; #ifndef WITHOUT_FASTMATCH if (fg_pattern[i].pattern) r = fastexec(&fg_pattern[i], - l->dat, 1, &pmatch, leflags); + pc->ln.dat, 1, &pmatch, leflags); else #endif - r = regexec(&r_pattern[i], l->dat, 1, + r = regexec(&r_pattern[i], pc->ln.dat, 1, &pmatch, leflags); - r = (r == 0) ? 0 : REG_NOMATCH; - if (r == REG_NOMATCH) + if (r != 0) continue; /* Check for full match */ - if (r == 0 && xflag) - if (pmatch.rm_so != 0 || - (size_t)pmatch.rm_eo != l->len) - r = REG_NOMATCH; + if (xflag && (pmatch.rm_so != 0 || + (size_t)pmatch.rm_eo != pc->ln.len)) + continue; /* Check for whole word match */ #ifndef WITHOUT_FASTMATCH - if (r == 0 && (wflag || fg_pattern[i].word)) { + if (wflag || fg_pattern[i].word) { #else - if (r == 0 && wflag) { + if (wflag) { #endif - wchar_t wbegin, wend; - wbegin = wend = L' '; if (pmatch.rm_so != 0 && - sscanf(&l->dat[pmatch.rm_so - 1], + sscanf(&pc->ln.dat[pmatch.rm_so - 1], "%lc", &wbegin) != 1) r = REG_NOMATCH; else if ((size_t)pmatch.rm_eo != - l->len && - sscanf(&l->dat[pmatch.rm_eo], + pc->ln.len && + sscanf(&pc->ln.dat[pmatch.rm_eo], "%lc", &wend) != 1) r = REG_NOMATCH; else if (iswword(wbegin) || @@ -361,7 +425,7 @@ procline(struct str *l, int nottext) /* * If we're doing whole word matching and we * matched once, then we should try the pattern - * again after advancing just past the start of + * again after advancing just past the start of * the earliest match. This allows the pattern * to match later on in the line and possibly * still match a whole word. @@ -369,33 +433,40 @@ procline(struct str *l, int nottext) if (r == REG_NOMATCH && (retry == 0 || pmatch.rm_so + 1 < retry)) retry = pmatch.rm_so + 1; + if (r == REG_NOMATCH) + continue; } - if (r == 0) { - lastmatches++; - lastmatch = pmatch; - if (m == 0) - c++; - if (m < MAX_LINE_MATCHES) { - /* Replace previous match if the new one is earlier and/or longer */ - if (m > startm) { - if (pmatch.rm_so < matches[m-1].rm_so || - (pmatch.rm_so == matches[m-1].rm_so && (pmatch.rm_eo - pmatch.rm_so) > (matches[m-1].rm_eo - matches[m-1].rm_so))) { - matches[m-1] = pmatch; - nst = pmatch.rm_eo; - } - } else { - /* Advance as normal if not */ - matches[m++] = pmatch; - nst = pmatch.rm_eo; - } - } + lastmatches++; + lastmatch = pmatch; - /* matches - skip further patterns */ - if ((color == NULL && !oflag) || - qflag || lflag) - break; + if (matchidx == 0) + c++; + + /* + * Replace previous match if the new one is earlier + * and/or longer. This will lead to some amount of + * extra work if -o/--color are specified, but it's + * worth it from a correctness point of view. + */ + if (matchidx > startm) { + chkmatch = pc->matches[matchidx - 1]; + if (pmatch.rm_so < chkmatch.rm_so || + (pmatch.rm_so == chkmatch.rm_so && + (pmatch.rm_eo - pmatch.rm_so) > + (chkmatch.rm_eo - chkmatch.rm_so))) { + pc->matches[matchidx - 1] = pmatch; + nst = pmatch.rm_eo; + } + } else { + /* Advance as normal if not */ + pc->matches[matchidx++] = pmatch; + nst = pmatch.rm_eo; } + /* avoid excessive matching - skip further patterns */ + if ((color == NULL && !oflag) || qflag || lflag || + matchidx >= MAX_LINE_MATCHES) + break; } /* @@ -414,7 +485,7 @@ procline(struct str *l, int nottext) /* If we didn't have any matches or REG_NOSUB set */ if (lastmatches == 0 || (cflags & REG_NOSUB)) - nst = l->len; + nst = pc->ln.len; if (lastmatches == 0) /* No matches */ @@ -427,45 +498,11 @@ procline(struct str *l, int nottext) st = nst; } - + /* Reflect the new matchidx in the context */ + pc->matchidx = matchidx; if (vflag) c = !c; - - /* Count the matches if we have a match limit */ - if (mflag) - mcount -= c; - - if (c && binbehave == BINFILE_BIN && nottext) - return (c); /* Binary file */ - - /* Dealing with the context */ - if ((tail || c) && !cflag && !qflag && !lflag && !Lflag) { - if (c) { - if (!first && !prev && !tail && (Bflag || Aflag) && - !ctxover) - printf("--\n"); - tail = Aflag; - if (Bflag > 0) { - printqueue(); - ctxover = false; - } - linesqueued = 0; - printline(l, ':', matches, m); - } else { - /* Print -A lines following matches */ - lasta = l->line_no; - printline(l, '-', matches, m); - tail--; - } - } - - if (c) { - prev = true; - first = false; - } else - prev = false; - - return (c); + return (c ? 0 : 1); } /* @@ -520,69 +557,89 @@ grep_strdup(const char *str) } /* - * Prints a matching line according to the command line options. + * Print an entire line as-is, there are no inline matches to consider. This is + * used for printing context. */ -void -printline(struct str *line, int sep, regmatch_t *matches, int m) +void grep_printline(struct str *line, int sep) { + printline_metadata(line, sep); + fwrite(line->dat, line->len, 1, stdout); + putchar(fileeol); +} + +static void +printline_metadata(struct str *line, int sep) { - size_t a = 0; - int i, n = 0; + bool printsep; - /* If matchall, everything matches but don't actually print for -o */ - if (oflag && matchall) - return; - + printsep = false; if (!hflag) { if (!nullflag) { fputs(line->file, stdout); - ++n; + printsep = true; } else { printf("%s", line->file); putchar(0); } } if (nflag) { - if (n > 0) + if (printsep) putchar(sep); printf("%d", line->line_no); - ++n; + printsep = true; } if (bflag) { - if (n > 0) + if (printsep) putchar(sep); printf("%lld", (long long)line->off); - ++n; + printsep = true; } - if (n) + if (printsep) putchar(sep); +} + +/* + * Prints a matching line according to the command line options. + */ +static void +printline(struct parsec *pc, int sep) +{ + size_t a = 0; + size_t i, matchidx; + regmatch_t match; + + /* If matchall, everything matches but don't actually print for -o */ + if (oflag && matchall) + return; + + matchidx = pc->matchidx; + /* --color and -o */ - if ((oflag || color) && m > 0) { - for (i = 0; i < m; i++) { + if ((oflag || color) && matchidx > 0) { + printline_metadata(&pc->ln, sep); + for (i = 0; i < matchidx; i++) { + match = pc->matches[i]; /* Don't output zero length matches */ - if (matches[i].rm_so == matches[i].rm_eo) + if (match.rm_so == match.rm_eo) continue; if (!oflag) - fwrite(line->dat + a, matches[i].rm_so - a, 1, + fwrite(pc->ln.dat + a, match.rm_so - a, 1, stdout); - if (color) + if (color) fprintf(stdout, "\33[%sm\33[K", color); - - fwrite(line->dat + matches[i].rm_so, - matches[i].rm_eo - matches[i].rm_so, 1, - stdout); - if (color) + fwrite(pc->ln.dat + match.rm_so, + match.rm_eo - match.rm_so, 1, stdout); + if (color) fprintf(stdout, "\33[m\33[K"); - a = matches[i].rm_eo; + a = match.rm_eo; if (oflag) putchar('\n'); } if (!oflag) { - if (line->len - a > 0) - fwrite(line->dat + a, line->len - a, 1, stdout); + if (pc->ln.len - a > 0) + fwrite(pc->ln.dat + a, pc->ln.len - a, 1, + stdout); putchar('\n'); } - } else { - fwrite(line->dat, line->len, 1, stdout); - putchar(fileeol); - } + } else + grep_printline(&pc->ln, sep); } From owner-svn-src-stable-11@freebsd.org Wed Aug 16 19:52:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6844ADCC8D1; Wed, 16 Aug 2017 19:52:33 +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 mx1.freebsd.org (Postfix) with ESMTPS id 32B786CF8C; Wed, 16 Aug 2017 19:52:33 +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 v7GJqWPw007857; Wed, 16 Aug 2017 19:52:32 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GJqWhQ007856; Wed, 16 Aug 2017 19:52:32 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201708161952.v7GJqWhQ007856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Wed, 16 Aug 2017 19:52: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: r322591 - 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: 322591 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.23 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, 16 Aug 2017 19:52:33 -0000 Author: kp Date: Wed Aug 16 19:52:31 2017 New Revision: 322591 URL: https://svnweb.freebsd.org/changeset/base/322591 Log: MFC r322280: pf_get_sport(): Prevent possible endless loop when searching for an unused nat port This is an import of Alexander Bluhm's OpenBSD commit r1.60, the first chunk had to be modified because on OpenBSD the 'cut' declaration is located elsewhere. Upstream report by Jingmin Zhou: https://marc.info/?l=openbsd-pf&m=150020133510896&w=2 OpenBSD commit message: Use a 32 bit variable to detect integer overflow when searching for an unused nat port. Prevents a possible endless loop if high port is 65535 or low port is 0. report and analysis Jingmin Zhou; OK sashan@ visa@ Quoted from: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/net/pf_lb.c PR: 221201 Submitted by: Fabian Keil Obtained from: OpenBSD via ElectroBSD Modified: stable/11/sys/netpfil/pf/pf_lb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/pf/pf_lb.c ============================================================================== --- stable/11/sys/netpfil/pf/pf_lb.c Wed Aug 16 19:40:07 2017 (r322590) +++ stable/11/sys/netpfil/pf/pf_lb.c Wed Aug 16 19:52:31 2017 (r322591) @@ -259,7 +259,8 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf return (0); } } else { - uint16_t tmp, cut; + uint32_t tmp; + uint16_t cut; if (low > high) { tmp = low; @@ -269,7 +270,7 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf /* low < high */ cut = arc4random() % (1 + high - low) + low; /* low <= cut <= high */ - for (tmp = cut; tmp <= high; ++(tmp)) { + for (tmp = cut; tmp <= high && tmp <= 0xffff; ++tmp) { key.port[1] = htons(tmp); if (pf_find_state_all(&key, PF_IN, NULL) == NULL) { @@ -277,7 +278,8 @@ pf_get_sport(sa_family_t af, u_int8_t proto, struct pf return (0); } } - for (tmp = cut - 1; tmp >= low; --(tmp)) { + tmp = cut; + for (tmp -= 1; tmp >= low && tmp <= 0xffff; --tmp) { key.port[1] = htons(tmp); if (pf_find_state_all(&key, PF_IN, NULL) == NULL) { From owner-svn-src-stable-11@freebsd.org Wed Aug 16 22:00:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8E3BDD4BFD; Wed, 16 Aug 2017 22:00:57 +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 mx1.freebsd.org (Postfix) with ESMTPS id 91E12718F0; Wed, 16 Aug 2017 22:00:57 +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 v7GM0uxw059313; Wed, 16 Aug 2017 22:00:56 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7GM0u6O059312; Wed, 16 Aug 2017 22:00:56 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708162200.v7GM0u6O059312@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 16 Aug 2017 22:00:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322597 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322597 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.23 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, 16 Aug 2017 22:00:57 -0000 Author: kevans Date: Wed Aug 16 22:00:56 2017 New Revision: 322597 URL: https://svnweb.freebsd.org/changeset/base/322597 Log: MFC r317705: bsdgrep: avoid use of magic number for REG_NOSPEC Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/grep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Wed Aug 16 21:42:27 2017 (r322596) +++ stable/11/usr.bin/grep/grep.c Wed Aug 16 22:00:56 2017 (r322597) @@ -717,8 +717,13 @@ main(int argc, char *argv[]) case GREP_BASIC: break; case GREP_FIXED: - /* XXX: header mess, REG_LITERAL not defined in gnu/regex.h */ - cflags |= 0020; +#if defined(REG_NOSPEC) + cflags |= REG_NOSPEC; +#elif defined(REG_LITERAL) + cflags |= REG_LITERAL; +#else + errx(2, "literal expressions not supported at compile time"); +#endif break; case GREP_EXTENDED: cflags |= REG_EXTENDED; From owner-svn-src-stable-11@freebsd.org Thu Aug 17 01:31:39 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50400DE15FA; Thu, 17 Aug 2017 01:31:39 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id 130B67D031; Thu, 17 Aug 2017 01:31:38 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7H1Vc9x044275; Thu, 17 Aug 2017 01:31:38 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H1Vcwg044274; Thu, 17 Aug 2017 01:31:38 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708170131.v7H1Vcwg044274@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 17 Aug 2017 01:31:38 +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: r322604 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 322604 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.23 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, 17 Aug 2017 01:31:39 -0000 Author: emaste Date: Thu Aug 17 01:31:37 2017 New Revision: 322604 URL: https://svnweb.freebsd.org/changeset/base/322604 Log: MFC r322356: Mark PROFILE option as broken when targetting mips64 The assembly in sys/mips/include/profile.h will only work for o32 ABI. Submitted by: Alexander Richardson Modified: stable/11/share/mk/src.opts.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/src.opts.mk ============================================================================== --- stable/11/share/mk/src.opts.mk Thu Aug 17 00:20:50 2017 (r322603) +++ stable/11/share/mk/src.opts.mk Thu Aug 17 01:31:37 2017 (r322604) @@ -273,7 +273,10 @@ BROKEN_OPTIONS+=LIBSOFT .if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*} BROKEN_OPTIONS+=EFI .endif - +.if ${__T:Mmips64*} +# profiling won't work on MIPS64 because there is only assembly for o32 +BROKEN_OPTIONS+=PROFILE +.endif .if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \ ${__T} == "powerpc64" || ${__T} == "sparc64" __DEFAULT_YES_OPTIONS+=CXGBETOOL From owner-svn-src-stable-11@freebsd.org Thu Aug 17 03:48:52 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A13B3DC6796; Thu, 17 Aug 2017 03:48:52 +0000 (UTC) (envelope-from sephe@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 mx1.freebsd.org (Postfix) with ESMTPS id 3E667834E8; Thu, 17 Aug 2017 03:48:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7H3mpTB099611; Thu, 17 Aug 2017 03:48:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H3mpWN099609; Thu, 17 Aug 2017 03:48:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201708170348.v7H3mpWN099609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 17 Aug 2017 03:48: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: r322605 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/11/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 322605 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.23 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, 17 Aug 2017 03:48:52 -0000 Author: sephe Date: Thu Aug 17 03:48:50 2017 New Revision: 322605 URL: https://svnweb.freebsd.org/changeset/base/322605 Log: MFC 322483,322485-322487 322483 hyperv/hn: Update VF's ibytes properly under transparent VF mode. While, I'm here add comment about why updating VF's imcast stat is not necessary. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11948 322485 hyperv/hn: Fix/enhance receiving path when VF is activated. - Update hn(4)'s stats properly for non-transparent mode VF. - Allow BPF tapping to hn(4) for non-transparent mode VF. - Don't setup mbuf hash, if 'options RSS' is set. In Azure, when VF is activated, TCP SYN and SYN|ACK go through hn(4) while the rest of segments and ACKs belonging to the same TCP 4-tuple go through the VF. So don't setup mbuf hash, if a VF is activated and 'options RSS' is not enabled. hn(4) and the VF may use neither the same RSS hash key nor the same RSS hash function, so the hash value for packets belonging to the same flow could be different! - Disable LRO. hn(4) will only receive broadcast packets, multicast packets, TCP SYN and SYN|ACK (in Azure), LRO is useless for these packet types. For non-transparent, we definitely _cannot_ enable LRO at all, since the LRO flush will use hn(4) as the receiving interface; i.e. hn_ifp->if_input(hn_ifp, m). While I'm here, remove unapplied comment and minor style change. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11978 322486 hyperv/hn: Minor cleanup Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11979 322487 hyperv/hn: Re-set datapath after synthetic parts reattached. Do this even for non-transparent mode VF. Better safe than sorry. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11981 Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hn.c Thu Aug 17 01:31:37 2017 (r322604) +++ stable/11/sys/dev/hyperv/netvsc/if_hn.c Thu Aug 17 03:48:50 2017 (r322605) @@ -282,6 +282,8 @@ static bool hn_xpnt_vf_isready(struct hn_softc *); static void hn_xpnt_vf_setready(struct hn_softc *); static void hn_xpnt_vf_init_taskfunc(void *, int); static void hn_xpnt_vf_init(struct hn_softc *); +static void hn_xpnt_vf_setenable(struct hn_softc *); +static void hn_xpnt_vf_setdisable(struct hn_softc *, bool); static int hn_rndis_rxinfo(const void *, int, struct hn_rxinfo *); @@ -578,6 +580,12 @@ hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { }; #endif /* !RSS */ +static const struct hyperv_guid hn_guid = { + .hv_guid = { + 0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46, + 0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e } +}; + static device_method_t hn_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hn_probe), @@ -1266,16 +1274,37 @@ hn_xpnt_vf_input(struct ifnet *vf_ifp, struct mbuf *m) rm_runlock(&hn_vfmap_lock, &pt); if (hn_ifp != NULL) { - /* - * Fix up rcvif and go through hn(4)'s if_input and - * increase ipackets. - */ for (mn = m; mn != NULL; mn = mn->m_nextpkt) { - /* Allow tapping on the VF. */ + /* + * Allow tapping on the VF. + */ ETHER_BPF_MTAP(vf_ifp, mn); + + /* + * Update VF stats. + */ + if ((vf_ifp->if_capenable & IFCAP_HWSTATS) == 0) { + if_inc_counter(vf_ifp, IFCOUNTER_IBYTES, + mn->m_pkthdr.len); + } + /* + * XXX IFCOUNTER_IMCAST + * This stat updating is kinda invasive, since it + * requires two checks on the mbuf: the length check + * and the ethernet header check. As of this write, + * all multicast packets go directly to hn(4), which + * makes imcast stat updating in the VF a try in vian. + */ + + /* + * Fix up rcvif and increase hn(4)'s ipackets. + */ mn->m_pkthdr.rcvif = hn_ifp; if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1); } + /* + * Go through hn(4)'s if_input. + */ hn_ifp->if_input(hn_ifp, m); } else { /* @@ -1406,6 +1435,40 @@ hn_xpnt_vf_isready(struct hn_softc *sc) } static void +hn_xpnt_vf_setenable(struct hn_softc *sc) +{ + int i; + + HN_LOCK_ASSERT(sc); + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags |= HN_XVFFLAG_ENABLED; + rm_wunlock(&sc->hn_vf_lock); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags |= HN_RX_FLAG_XPNT_VF; +} + +static void +hn_xpnt_vf_setdisable(struct hn_softc *sc, bool clear_vf) +{ + int i; + + HN_LOCK_ASSERT(sc); + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; + if (clear_vf) + sc->hn_vf_ifp = NULL; + rm_wunlock(&sc->hn_vf_lock); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags &= ~HN_RX_FLAG_XPNT_VF; +} + +static void hn_xpnt_vf_init(struct hn_softc *sc) { int error; @@ -1438,10 +1501,8 @@ hn_xpnt_vf_init(struct hn_softc *sc) */ hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_VF); - /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ - rm_wlock(&sc->hn_vf_lock); - sc->hn_xvf_flags |= HN_XVFFLAG_ENABLED; - rm_wunlock(&sc->hn_vf_lock); + /* Mark transparent mode VF as enabled. */ + hn_xpnt_vf_setenable(sc); } static void @@ -1627,11 +1688,8 @@ hn_ifnet_detevent(void *xsc, struct ifnet *ifp) hn_resume_mgmt(sc); } - /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ - rm_wlock(&sc->hn_vf_lock); - sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; - sc->hn_vf_ifp = NULL; - rm_wunlock(&sc->hn_vf_lock); + /* Mark transparent mode VF as disabled. */ + hn_xpnt_vf_setdisable(sc, true /* clear hn_vf_ifp */); rm_wlock(&hn_vfmap_lock); @@ -1659,18 +1717,11 @@ hn_ifnet_lnkevent(void *xsc, struct ifnet *ifp, int li if_link_state_change(sc->hn_ifp, link_state); } -/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const struct hyperv_guid g_net_vsc_device_type = { - .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} -}; - static int hn_probe(device_t dev) { - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, - &g_net_vsc_device_type) == 0) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &hn_guid) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); return BUS_PROBE_DEFAULT; } @@ -2973,13 +3024,16 @@ static int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_rxinfo *info) { - struct ifnet *ifp; + struct ifnet *ifp, *hn_ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; int hash_type; - /* If the VF is active, inject the packet through the VF */ - ifp = rxr->hn_rxvf_ifp ? rxr->hn_rxvf_ifp : rxr->hn_ifp; + /* + * If the non-transparent mode VF is active, inject this packet + * into the VF. + */ + ifp = rxr->hn_rxvf_ifp ? rxr->hn_rxvf_ifp : hn_ifp; if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { /* @@ -2993,10 +3047,15 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int return (0); } + if (__predict_false(dlen < ETHER_HDR_LEN)) { + if_inc_counter(hn_ifp, IFCOUNTER_IERRORS, 1); + return (0); + } + if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { - if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IQDROPS, 1); return (0); } memcpy(mtod(m_new, void *), data, dlen); @@ -3017,7 +3076,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); if (m_new == NULL) { - if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IQDROPS, 1); return (0); } @@ -3025,7 +3084,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int } m_new->m_pkthdr.rcvif = ifp; - if (__predict_false((ifp->if_capenable & IFCAP_RXCSUM) == 0)) + if (__predict_false((hn_ifp->if_capenable & IFCAP_RXCSUM) == 0)) do_csum = 0; /* receive side checksum offload */ @@ -3066,8 +3125,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int int hoff; hoff = sizeof(*eh); - if (m_new->m_len < hoff) - goto skip; + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); + eh = mtod(m_new, struct ether_header *); etype = ntohs(eh->ether_type); if (etype == ETHERTYPE_VLAN) { @@ -3122,6 +3182,37 @@ skip: m_new->m_flags |= M_VLANTAG; } + /* + * If VF is activated (tranparent/non-transparent mode does not + * matter here). + * + * - Don't setup mbuf hash, if 'options RSS' is set. + * + * In Azure, when VF is activated, TCP SYN and SYN|ACK go + * through hn(4) while the rest of segments and ACKs belonging + * to the same TCP 4-tuple go through the VF. So don't setup + * mbuf hash, if a VF is activated and 'options RSS' is not + * enabled. hn(4) and the VF may use neither the same RSS + * hash key nor the same RSS hash function, so the hash value + * for packets belonging to the same flow could be different! + * + * - Disable LRO + * + * hn(4) will only receive broadcast packets, multicast packets, + * TCP SYN and SYN|ACK (in Azure), LRO is useless for these + * packet types. + * + * For non-transparent, we definitely _cannot_ enable LRO at + * all, since the LRO flush will use hn(4) as the receiving + * interface; i.e. hn_ifp->if_input(hn_ifp, m). + */ + if (hn_ifp != ifp || (rxr->hn_rx_flags & HN_RX_FLAG_XPNT_VF)) { + do_lro = 0; /* disable LRO. */ +#ifndef RSS + goto skip_hash; /* skip mbuf hash setup */ +#endif + } + if (info->hash_info != HN_NDIS_HASH_INFO_INVALID) { rxr->hn_rss_pkts++; m_new->m_pkthdr.flowid = info->hash_value; @@ -3171,15 +3262,36 @@ skip: } M_HASHTYPE_SET(m_new, hash_type); - /* - * Note: Moved RX completion back to hv_nv_on_receive() so all - * messages (not just data messages) will trigger a response. - */ - +#ifndef RSS +skip_hash: +#endif if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if (hn_ifp != ifp) { + const struct ether_header *eh; + + /* + * Non-transparent mode VF is activated. + */ + + /* + * Allow tapping on hn(4). + */ + ETHER_BPF_MTAP(hn_ifp, m_new); + + /* + * Update hn(4)'s stats. + */ + if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IBYTES, m_new->m_pkthdr.len); + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= ETHER_HDR_LEN, ("not ethernet frame")); + eh = mtod(m_new, struct ether_header *); + if (ETHER_IS_MULTICAST(eh->ether_dhost)) + if_inc_counter(hn_ifp, IFCOUNTER_IMCASTS, 1); + } rxr->hn_pkts++; - if ((ifp->if_capenable & IFCAP_LRO) && do_lro) { + if ((hn_ifp->if_capenable & IFCAP_LRO) && do_lro) { #if defined(INET) || defined(INET6) struct lro_ctrl *lro = &rxr->hn_lro; @@ -3192,10 +3304,8 @@ skip: } #endif } + ifp->if_input(ifp, m_new); - /* We're not holding the lock here, so don't release it */ - (*ifp->if_input)(ifp, m_new); - return (0); } @@ -3293,7 +3403,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ hn_resume(sc); - if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) { + if ((sc->hn_flags & HN_FLAG_RXVF) || + (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED)) { /* * Since we have reattached the NVS part, * change the datapath to VF again; in case @@ -3490,10 +3601,8 @@ hn_stop(struct hn_softc *sc, bool detaching) KASSERT(sc->hn_vf_ifp != NULL, ("%s: VF is not attached", ifp->if_xname)); - /* NOTE: hn_vf_lock for hn_transmit() */ - rm_wlock(&sc->hn_vf_lock); - sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; - rm_wunlock(&sc->hn_vf_lock); + /* Mark transparent mode VF as disabled. */ + hn_xpnt_vf_setdisable(sc, false /* keep hn_vf_ifp */); /* * NOTE: Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Thu Aug 17 01:31:37 2017 (r322604) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Thu Aug 17 03:48:50 2017 (r322605) @@ -63,6 +63,7 @@ struct hn_rx_ring { struct hn_tx_ring *hn_txr; void *hn_pktbuf; int hn_pktbuf_len; + int hn_rx_flags; /* HN_RX_FLAG_ */ uint8_t *hn_rxbuf; /* shadow sc->hn_rxbuf */ int hn_rx_idx; @@ -82,7 +83,6 @@ struct hn_rx_ring { /* Rarely used stuffs */ struct sysctl_oid *hn_rx_sysctl_tree; - int hn_rx_flags; void *hn_br; /* TX/RX bufring */ struct hyperv_dma hn_br_dma; @@ -96,6 +96,7 @@ struct hn_rx_ring { #define HN_RX_FLAG_ATTACHED 0x0001 #define HN_RX_FLAG_BR_REF 0x0002 +#define HN_RX_FLAG_XPNT_VF 0x0004 struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING From owner-svn-src-stable-11@freebsd.org Thu Aug 17 03:56:44 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11411DC75CE; Thu, 17 Aug 2017 03:56:44 +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 mx1.freebsd.org (Postfix) with ESMTPS id CE1EB83C99; Thu, 17 Aug 2017 03:56:43 +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 v7H3ugeM003602; Thu, 17 Aug 2017 03:56:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H3ugCU003601; Thu, 17 Aug 2017 03:56:42 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708170356.v7H3ugCU003601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 03:56: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: r322606 - stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/contrib/netbsd-tests/usr.bin/grep X-SVN-Commit-Revision: 322606 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.23 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, 17 Aug 2017 03:56:44 -0000 Author: kevans Date: Thu Aug 17 03:56:42 2017 New Revision: 322606 URL: https://svnweb.freebsd.org/changeset/base/322606 Log: MFC r318004 (ngie): Remove expected failure that no longer fails with gnu grep in base Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 03:48:50 2017 (r322605) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 03:56:42 2017 (r322606) @@ -399,11 +399,6 @@ wflag_emptypat_head() } wflag_emptypat_body() { - grep_type - if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then - atf_expect_fail "this test does not pass with GNU grep in base" - fi - printf "" > test1 printf "\n" > test2 printf "qaz" > test3 From owner-svn-src-stable-11@freebsd.org Thu Aug 17 04:04:43 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7B03DC7F0A; Thu, 17 Aug 2017 04:04:43 +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 mx1.freebsd.org (Postfix) with ESMTPS id 8E8B5208; Thu, 17 Aug 2017 04:04:43 +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 v7H44gpi007767; Thu, 17 Aug 2017 04:04:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H44gg0007762; Thu, 17 Aug 2017 04:04:42 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708170404.v7H44gg0007762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 04:04: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: r322607 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322607 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.23 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, 17 Aug 2017 04:04:43 -0000 Author: kevans Date: Thu Aug 17 04:04:42 2017 New Revision: 322607 URL: https://svnweb.freebsd.org/changeset/base/322607 Log: bsdgrep: Don't allow negative context flags, add more tests MFC r318302: bsdgrep: don't allow negative -A / -B / -C Previously, when given a negative -A/-B/-C argument bsdgrep would overflow the respective context flag(s) and exhibited surprising behavior. Fix this by removing unsignedness of Aflag/Bflag and erroring out if we're given a value < 0. Also adjust the type used to track 'tail' context in procfile() so that it accurately reflects the Aflag value rather than overflowing and losing trailing context. This also fixes an inconsistency previously existing between -n and -C "n" behavior. They are now both limited to LLONG_MAX, to be consistent. Add some test cases to make sure grep errors out properly for both negative context values as well as non-numeric context values rather than giving bogus matches. MFC r318317: bsdgrep: add more tests for different binary flags The existing 'binary' test in netbsd-tests/ does a basic check of the default treatment for binary behavior, but not much more than that. Given some opportunity for breakage recently that did not trigger any failures, add some tests to cover the three different binary file behaviors (a, -I, -U) and their --binary-files= equivalent values. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/queue.c stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 03:56:42 2017 (r322606) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:04:42 2017 (r322607) @@ -517,6 +517,63 @@ grep_nomatch_flags_body() atf_check -o empty grep -q -A 1 -e "B" test1 atf_check -o empty grep -q -C 1 -e "B" test1 } + +atf_test_case badcontext +badcontext_head() +{ + atf_set "descr" "Check for handling of invalid context arguments" +} +badcontext_body() +{ + printf "A\nB\nC\n" > test1 + + atf_check -s not-exit:0 -e ignore grep -A "-1" "B" test1 + + atf_check -s not-exit:0 -e ignore grep -B "-1" "B" test1 + + atf_check -s not-exit:0 -e ignore grep -C "-1" "B" test1 + + atf_check -s not-exit:0 -e ignore grep -A "B" "B" test1 + + atf_check -s not-exit:0 -e ignore grep -B "B" "B" test1 + + atf_check -s not-exit:0 -e ignore grep -C "B" "B" test1 +} + +atf_test_case binary_flags +binary_flags_head() +{ + atf_set "descr" "Check output for binary flags (-a, -I, -U, --binary-files)" +} +binary_flags_body() +{ + printf "A\000B\000C" > test1 + printf "A\n\000B\n\000C" > test2 + binmatchtext="Binary file test1 matches\n" + + # Binaries not treated as text (default, -U) + atf_check -o inline:"${binmatchtext}" grep 'B' test1 + atf_check -o inline:"${binmatchtext}" grep 'B' -C 1 test1 + + atf_check -o inline:"${binmatchtext}" grep -U 'B' test1 + atf_check -o inline:"${binmatchtext}" grep -U 'B' -C 1 test1 + + # Binary, -a, no newlines + atf_check -o inline:"A\000B\000C\n" grep -a 'B' test1 + atf_check -o inline:"A\000B\000C\n" grep -a 'B' -C 1 test1 + + # Binary, -a, newlines + atf_check -o inline:"\000B\n" grep -a 'B' test2 + atf_check -o inline:"A\n\000B\n\000C\n" grep -a 'B' -C 1 test2 + + # Binary files ignored + atf_check -s exit:1 grep -I 'B' test2 + + # --binary-files equivalence + atf_check -o inline:"${binmatchtext}" grep --binary-files=binary 'B' test1 + atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1 + atf_check -s exit:1 grep --binary-files=without-match 'B' test2 +} # End FreeBSD atf_init_test_cases() @@ -551,5 +608,7 @@ atf_init_test_cases() atf_add_test_case egrep_sanity atf_add_test_case grep_sanity atf_add_test_case grep_nomatch_flags + atf_add_test_case binary_flags + atf_add_test_case badcontext # End FreeBSD } Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Thu Aug 17 03:56:42 2017 (r322606) +++ stable/11/usr.bin/grep/grep.c Thu Aug 17 04:04:42 2017 (r322607) @@ -109,8 +109,8 @@ struct epat *dpattern, *fpattern; char re_error[RE_ERROR_BUF + 1]; /* Command-line flags */ -unsigned long long Aflag; /* -A x: print x lines trailing each match */ -unsigned long long Bflag; /* -B x: print x lines leading each match */ +long long Aflag; /* -A x: print x lines trailing each match */ +long long Bflag; /* -B x: print x lines leading each match */ bool Hflag; /* -H: always print file name */ bool Lflag; /* -L: only show names of files with no matches */ bool bflag; /* -b: show block numbers for each match */ @@ -352,7 +352,7 @@ main(int argc, char *argv[]) char **aargv, **eargv, *eopts; char *ep; const char *pn; - unsigned long long l; + long long l; unsigned int aargc, eargc, i; int c, lastc, needpattern, newarg, prevoptind; @@ -439,10 +439,11 @@ main(int argc, char *argv[]) case '5': case '6': case '7': case '8': case '9': if (newarg || !isdigit(lastc)) Aflag = 0; - else if (Aflag > LLONG_MAX / 10) { + else if (Aflag > LLONG_MAX / 10 - 1) { errno = ERANGE; err(2, NULL); } + Aflag = Bflag = (Aflag * 10) + (c - '0'); break; case 'C': @@ -455,14 +456,17 @@ main(int argc, char *argv[]) /* FALLTHROUGH */ case 'B': errno = 0; - l = strtoull(optarg, &ep, 10); - if (((errno == ERANGE) && (l == ULLONG_MAX)) || - ((errno == EINVAL) && (l == 0))) + l = strtoll(optarg, &ep, 10); + if (errno == ERANGE || errno == EINVAL) err(2, NULL); else if (ep[0] != '\0') { errno = EINVAL; err(2, NULL); + } else if (l < 0) { + errno = EINVAL; + err(2, "context argument must be non-negative"); } + if (c == 'A') Aflag = l; else if (c == 'B') Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Thu Aug 17 03:56:42 2017 (r322606) +++ stable/11/usr.bin/grep/grep.h Thu Aug 17 04:04:42 2017 (r322607) @@ -115,7 +115,7 @@ extern bool Eflag, Fflag, Gflag, Hflag, Lflag, bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag, qflag, sflag, vflag, wflag, xflag; extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag; -extern unsigned long long Aflag, Bflag; +extern long long Aflag, Bflag; extern long long mcount; extern long long mlimit; extern char fileeol; Modified: stable/11/usr.bin/grep/queue.c ============================================================================== --- stable/11/usr.bin/grep/queue.c Thu Aug 17 03:56:42 2017 (r322606) +++ stable/11/usr.bin/grep/queue.c Thu Aug 17 04:04:42 2017 (r322607) @@ -49,7 +49,7 @@ struct qentry { }; static STAILQ_HEAD(, qentry) queue = STAILQ_HEAD_INITIALIZER(queue); -static unsigned long long count; +static long long count; static struct qentry *dequeue(void); Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 03:56:42 2017 (r322606) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 04:04:42 2017 (r322607) @@ -196,11 +196,12 @@ int procfile(const char *fn) { struct parsec pc; + long long tail; struct file *f; struct stat sb; struct str *ln; mode_t s; - int c, last_outed, t, tail; + int c, last_outed, t; bool doctx, printmatch, same_file; if (strcmp(fn, "-") == 0) { From owner-svn-src-stable-11@freebsd.org Thu Aug 17 04:18:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EFA4DC8FDE; Thu, 17 Aug 2017 04:18:32 +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 mx1.freebsd.org (Postfix) with ESMTPS id 46072BFE; Thu, 17 Aug 2017 04:18:32 +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 v7H4IVMR012004; Thu, 17 Aug 2017 04:18:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H4IVEM012002; Thu, 17 Aug 2017 04:18:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708170418.v7H4IVEM012002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 04:18:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322608 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322608 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.23 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, 17 Aug 2017 04:18:32 -0000 Author: kevans Date: Thu Aug 17 04:18:31 2017 New Revision: 322608 URL: https://svnweb.freebsd.org/changeset/base/322608 Log: bsdgrep: fix segfault with --mmap and add relevant test MFC r318565: bsdgrep: fix segfault with --mmap r313948 partially fixed --mmap behavior but was incomplete. This commit generally reverts it and does it the more correct way- by just consuming the rest of the buffer and moving on. MFC r318908: bsdgrep: add --mmap tests Basic sanity tests as well as coverage for the bug fixed in r318565. PR: 219402 Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/file.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:04:42 2017 (r322607) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:18:31 2017 (r322608) @@ -574,6 +574,46 @@ binary_flags_body() atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1 atf_check -s exit:1 grep --binary-files=without-match 'B' test2 } + +atf_test_case mmap +mmap_head() +{ + atf_set "descr" "Check basic matching with --mmap flag" +} +mmap_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU ]; then + atf_expect_fail "gnu grep from ports has no --mmap option" + fi + + printf "A\nB\nC\n" > test1 + + atf_check -s exit:0 -o inline:"B\n" grep --mmap -oe "B" test1 + atf_check -s exit:1 grep --mmap -e "Z" test1 +} + +atf_test_case mmap_eof_not_eol +mmap_eof_not_eol_head() +{ + atf_set "descr" "Check --mmap flag handling of encountering EOF without EOL (PR 165471, 219402)" +} +mmap_eof_not_eol_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU ]; then + atf_expect_fail "gnu grep from ports has no --mmap option" + fi + + printf "ABC" > test1 + jot -b " " -s "" 4096 >> test2 + + atf_check -s exit:0 -o inline:"B\n" grep --mmap -oe "B" test1 + # Dependency on jemalloc(3) to detect buffer overflow, otherwise this + # unreliably produces a SIGSEGV or SIGBUS + atf_check -s exit:0 -o not-empty \ + env MALLOC_CONF="redzone:true" grep --mmap -e " " test2 +} # End FreeBSD atf_init_test_cases() @@ -610,5 +650,7 @@ atf_init_test_cases() atf_add_test_case grep_nomatch_flags atf_add_test_case binary_flags atf_add_test_case badcontext + atf_add_test_case mmap + atf_add_test_case mmap_eof_not_eol # End FreeBSD } Modified: stable/11/usr.bin/grep/file.c ============================================================================== --- stable/11/usr.bin/grep/file.c Thu Aug 17 04:04:42 2017 (r322607) +++ stable/11/usr.bin/grep/file.c Thu Aug 17 04:18:31 2017 (r322608) @@ -213,24 +213,24 @@ grep_fgetln(struct file *f, size_t *lenp) if (grep_lnbufgrow(len + LNBUFBUMP)) goto error; memcpy(lnbuf + off, bufpos, len - off); + /* With FILE_MMAP, this is EOF; there's no more to refill */ + if (filebehave == FILE_MMAP) { + bufrem -= len; + break; + } off = len; + /* Fetch more to try and find EOL/EOF */ if (grep_refill(f) != 0) goto error; if (bufrem == 0) /* EOF: return partial line */ break; - if ((p = memchr(bufpos, fileeol, bufrem)) == NULL && - filebehave != FILE_MMAP) + if ((p = memchr(bufpos, fileeol, bufrem)) == NULL) continue; - if (p == NULL) { - /* mmap EOF: return partial line, consume buffer */ - diff = len; - } else { - /* got it: finish up the line (like code above) */ - ++p; - diff = p - bufpos; - len += diff; - } + /* got it: finish up the line (like code above) */ + ++p; + diff = p - bufpos; + len += diff; if (grep_lnbufgrow(len)) goto error; memcpy(lnbuf + off, bufpos, diff); From owner-svn-src-stable-11@freebsd.org Thu Aug 17 04:26:05 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3353DC98E7; Thu, 17 Aug 2017 04:26:05 +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 mx1.freebsd.org (Postfix) with ESMTPS id A1E891188; Thu, 17 Aug 2017 04:26:05 +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 v7H4Q4dX015846; Thu, 17 Aug 2017 04:26:04 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H4Q4SL015844; Thu, 17 Aug 2017 04:26:04 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708170426.v7H4Q4SL015844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 04:26: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: r322609 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322609 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.23 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, 17 Aug 2017 04:26:06 -0000 Author: kevans Date: Thu Aug 17 04:26:04 2017 New Revision: 322609 URL: https://svnweb.freebsd.org/changeset/base/322609 Log: MFC r318571: bsdgrep: emit more than MAX_LINE_MATCHES per line We should not set an arbitrary cap on the number of matches on a line, and in any case MAX_LINE_MATCHES of 32 is much too low. Instead, if we match more than MAX_LINE_MATCHES, keep processing and matching from the last match until all are found. For the regression test, we produce 4096 matches (larger than we expect we'll ever set MAX_LINE_MATCHES) and make sure we actually get 4096 lines of output with the -o flag. We'll also make sure that every distinct line is getting its own line number to detect line metadata not being printed as appropriate along the way. PR: 218811 Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:18:31 2017 (r322608) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:26:04 2017 (r322609) @@ -413,6 +413,26 @@ wflag_emptypat_body() atf_check -o file:test4 grep -w -e "" test4 } +atf_test_case excessive_matches +excessive_matches_head() +{ + atf_set "descr" "Check for proper handling of lines with excessive matches (PR 218811)" +} +excessive_matches_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test does not pass with GNU grep in base" + fi + + for i in $(jot 4096); do + printf "x" >> test.in + done + + atf_check -s exit:0 -x '[ $(grep -o x test.in | wc -l) -eq 4096 ]' + #atf_check -s exit:1 -x 'grep -on x test.in | grep -v "1:x"' +} + atf_test_case fgrep_sanity fgrep_sanity_head() { @@ -643,6 +663,7 @@ atf_init_test_cases() atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen atf_add_test_case wflag_emptypat + atf_add_test_case excessive_matches atf_add_test_case wv_combo_break atf_add_test_case fgrep_sanity atf_add_test_case egrep_sanity Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 04:18:31 2017 (r322608) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 04:26:04 2017 (r322609) @@ -63,6 +63,7 @@ static bool first_match = true; struct parsec { regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ struct str ln; /* Current line */ + size_t lnstart; /* Start of line processing */ size_t matchidx; /* Latest used match index */ bool binary; /* Binary file? */ }; @@ -247,8 +248,9 @@ procfile(const char *fn) mcount = mlimit; for (c = 0; c == 0 || !(lflag || qflag); ) { - /* Reset match count for every line processed */ + /* Reset match count and line start for every line processed */ pc.matchidx = 0; + pc.lnstart = 0; pc.ln.off += pc.ln.len + 1; if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL || pc.ln.len == 0) { @@ -288,6 +290,14 @@ procfile(const char *fn) /* Print the matching line, but only if not quiet/binary */ if (t == 0 && printmatch) { printline(&pc, ':'); + while (pc.matchidx >= MAX_LINE_MATCHES) { + /* Reset matchidx and try again */ + pc.matchidx = 0; + if (procline(&pc) == 0) + printline(&pc, ':'); + else + break; + } first_match = false; same_file = true; last_outed = 0; @@ -356,11 +366,11 @@ procline(struct parsec *pc) { regmatch_t pmatch, lastmatch, chkmatch; wchar_t wbegin, wend; - size_t st = 0, nst = 0; + size_t st, nst; unsigned int i; int c = 0, r = 0, lastmatches = 0, leflags = eflags; size_t startm = 0, matchidx; - int retry; + unsigned int retry; matchidx = pc->matchidx; @@ -376,6 +386,8 @@ procline(struct parsec *pc) } else if (matchall) return (0); + st = pc->lnstart; + nst = 0; /* Initialize to avoid a false positive warning from GCC. */ lastmatch.rm_so = lastmatch.rm_eo = 0; @@ -432,12 +444,12 @@ procline(struct parsec *pc) * still match a whole word. */ if (r == REG_NOMATCH && - (retry == 0 || pmatch.rm_so + 1 < retry)) + (retry == pc->lnstart || + pmatch.rm_so + 1 < retry)) retry = pmatch.rm_so + 1; if (r == REG_NOMATCH) continue; } - lastmatches++; lastmatch = pmatch; @@ -466,8 +478,11 @@ procline(struct parsec *pc) } /* avoid excessive matching - skip further patterns */ if ((color == NULL && !oflag) || qflag || lflag || - matchidx >= MAX_LINE_MATCHES) + matchidx >= MAX_LINE_MATCHES) { + pc->lnstart = nst; + lastmatches = 0; break; + } } /* @@ -475,7 +490,7 @@ procline(struct parsec *pc) * again just in case we still have a chance to match later in * the string. */ - if (lastmatches == 0 && retry > 0) { + if (lastmatches == 0 && retry > pc->lnstart) { st = retry; continue; } @@ -497,6 +512,7 @@ procline(struct parsec *pc) /* Advance st based on previous matches */ st = nst; + pc->lnstart = st; } /* Reflect the new matchidx in the context */ From owner-svn-src-stable-11@freebsd.org Thu Aug 17 04:30:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2FB86DC9E37; Thu, 17 Aug 2017 04:30:33 +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 mx1.freebsd.org (Postfix) with ESMTPS id 060801457; Thu, 17 Aug 2017 04:30:32 +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 v7H4UVIg016094; Thu, 17 Aug 2017 04:30:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H4UVws016090; Thu, 17 Aug 2017 04:30:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708170430.v7H4UVws016090@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 04:30:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322610 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322610 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.23 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, 17 Aug 2017 04:30:33 -0000 Author: kevans Date: Thu Aug 17 04:30:31 2017 New Revision: 322610 URL: https://svnweb.freebsd.org/changeset/base/322610 Log: MFC r318574: bsdgrep: Correct per-line line metadata printing Metadata printing with -b, -H, or -n flags suffered from a few flaws: 1) -b/offset printing was broken when used in conjunction with -o 2) With -o, bsdgrep did not print metadata for every match/line, just the first match of a line 3) There were no tests for this Address these issues by outputting this data per-match if the -o flag is specified, and prior to outputting any matches if -o but not --color, since --color alone will not generate a new line of output for every iteration over the matches. To correct -b output, fudge the line offset as we're printing matches. While here, make sure we're using grep_printline in -A context. Context printing should *never* look at the parsing context, just the line. The tests included do not pass with gnugrep in base due to it exhibiting similar quirky behavior that bsdgrep previously exhibited. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/queue.c stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:26:04 2017 (r322609) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Thu Aug 17 04:30:31 2017 (r322610) @@ -430,7 +430,7 @@ excessive_matches_body() done atf_check -s exit:0 -x '[ $(grep -o x test.in | wc -l) -eq 4096 ]' - #atf_check -s exit:1 -x 'grep -on x test.in | grep -v "1:x"' + atf_check -s exit:1 -x 'grep -on x test.in | grep -v "1:x"' } atf_test_case fgrep_sanity @@ -510,6 +510,39 @@ wv_combo_break_body() atf_check -s exit:1 grep -v -w "x" test2 } +atf_test_case ocolor_metadata +ocolor_metadata_head() +{ + atf_set "descr" "Check for -n/-b producing per-line metadata output" +} +ocolor_metadata_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test does not pass with GNU grep in base" + fi + + printf "xxx\nyyyy\nzzz\nfoobarbaz\n" > test1 + check_expr="^[^:]*[0-9][^:]*:[^:]+$" + + atf_check -o inline:"1:1:xx\n" grep -bon "xx$" test1 + + atf_check -o inline:"2:4:yyyy\n" grep -bn "yy" test1 + + atf_check -o inline:"2:6:yy\n" grep -bon "yy$" test1 + + # These checks ensure that grep isn't producing bogus line numbering + # in the middle of a line. + atf_check -s exit:1 -x \ + "grep -Eon 'x|y|z|f' test1 | grep -Ev '${check_expr}'" + + atf_check -s exit:1 -x \ + "grep -En 'x|y|z|f' --color=always test1 | grep -Ev '${check_expr}'" + + atf_check -s exit:1 -x \ + "grep -Eon 'x|y|z|f' --color=always test1 | grep -Ev '${check_expr}'" +} + atf_test_case grep_nomatch_flags grep_nomatch_flags_head() { @@ -668,6 +701,7 @@ atf_init_test_cases() atf_add_test_case fgrep_sanity atf_add_test_case egrep_sanity atf_add_test_case grep_sanity + atf_add_test_case ocolor_metadata atf_add_test_case grep_nomatch_flags atf_add_test_case binary_flags atf_add_test_case badcontext Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Thu Aug 17 04:26:04 2017 (r322609) +++ stable/11/usr.bin/grep/grep.h Thu Aug 17 04:30:31 2017 (r322610) @@ -90,6 +90,7 @@ struct file { }; struct str { + off_t boff; off_t off; size_t len; char *dat; Modified: stable/11/usr.bin/grep/queue.c ============================================================================== --- stable/11/usr.bin/grep/queue.c Thu Aug 17 04:26:04 2017 (r322609) +++ stable/11/usr.bin/grep/queue.c Thu Aug 17 04:30:31 2017 (r322610) @@ -65,6 +65,7 @@ enqueue(struct str *x) item->data.dat = grep_malloc(sizeof(char) * x->len); item->data.len = x->len; item->data.line_no = x->line_no; + item->data.boff = x->boff; item->data.off = x->off; memcpy(item->data.dat, x->dat, x->len); item->data.file = x->file; Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 04:26:04 2017 (r322609) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 04:30:31 2017 (r322610) @@ -61,11 +61,12 @@ static bool first_match = true; * other useful bits */ struct parsec { - regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ - struct str ln; /* Current line */ - size_t lnstart; /* Start of line processing */ - size_t matchidx; /* Latest used match index */ - bool binary; /* Binary file? */ + regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ + struct str ln; /* Current line */ + size_t lnstart; /* Position in line */ + size_t matchidx; /* Latest match index */ + int printed; /* Metadata printed? */ + bool binary; /* Binary file? */ }; @@ -233,8 +234,10 @@ procfile(const char *fn) strcpy(pc.ln.file, fn); pc.ln.line_no = 0; pc.ln.len = 0; + pc.ln.boff = 0; pc.ln.off = -1; pc.binary = f->binary; + pc.printed = 0; tail = 0; last_outed = 0; same_file = false; @@ -248,9 +251,11 @@ procfile(const char *fn) mcount = mlimit; for (c = 0; c == 0 || !(lflag || qflag); ) { - /* Reset match count and line start for every line processed */ + /* Reset per-line statistics */ + pc.printed = 0; pc.matchidx = 0; pc.lnstart = 0; + pc.ln.boff = 0; pc.ln.off += pc.ln.len + 1; if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL || pc.ln.len == 0) { @@ -305,7 +310,7 @@ procfile(const char *fn) if (t != 0 && doctx) { /* Deal with any -A context */ if (tail > 0) { - printline(&pc, '-'); + grep_printline(&pc.ln, '-'); tail--; if (Bflag > 0) clearqueue(); @@ -607,7 +612,7 @@ printline_metadata(struct str *line, int sep) if (bflag) { if (printsep) putchar(sep); - printf("%lld", (long long)line->off); + printf("%lld", (long long)(line->off + line->boff)); printsep = true; } if (printsep) @@ -632,13 +637,22 @@ printline(struct parsec *pc, int sep) /* --color and -o */ if ((oflag || color) && matchidx > 0) { - printline_metadata(&pc->ln, sep); + /* Only print metadata once per line if --color */ + if (!oflag && pc->printed == 0) + printline_metadata(&pc->ln, sep); for (i = 0; i < matchidx; i++) { match = pc->matches[i]; /* Don't output zero length matches */ if (match.rm_so == match.rm_eo) continue; - if (!oflag) + /* + * Metadata is printed on a per-line basis, so every + * match gets file metadata with the -o flag. + */ + if (oflag) { + pc->ln.boff = match.rm_so; + printline_metadata(&pc->ln, sep); + } else fwrite(pc->ln.dat + a, match.rm_so - a, 1, stdout); if (color) @@ -659,4 +673,5 @@ printline(struct parsec *pc, int sep) } } else grep_printline(&pc->ln, sep); + pc->printed++; } From owner-svn-src-stable-11@freebsd.org Thu Aug 17 05:09:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97BC5DCC7C1; Thu, 17 Aug 2017 05:09:25 +0000 (UTC) (envelope-from sephe@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 mx1.freebsd.org (Postfix) with ESMTPS id 543832CA1; Thu, 17 Aug 2017 05:09:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7H59OV2032361; Thu, 17 Aug 2017 05:09:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7H59M1b032343; Thu, 17 Aug 2017 05:09:22 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201708170509.v7H59M1b032343@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 17 Aug 2017 05:09: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: r322612 - in stable/11/sys/dev/hyperv: include netvsc pcib storvsc utilities vmbus vmbus/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: in stable/11/sys/dev/hyperv: include netvsc pcib storvsc utilities vmbus vmbus/amd64 X-SVN-Commit-Revision: 322612 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.23 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, 17 Aug 2017 05:09:25 -0000 Author: sephe Date: Thu Aug 17 05:09:22 2017 New Revision: 322612 URL: https://svnweb.freebsd.org/changeset/base/322612 Log: MFC 322488 hyperv: Update copyright for the files changed in 2017 Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11982 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hn_nvs.c stable/11/sys/dev/hyperv/netvsc/hn_nvs.h stable/11/sys/dev/hyperv/netvsc/hn_rndis.c stable/11/sys/dev/hyperv/netvsc/hn_rndis.h stable/11/sys/dev/hyperv/netvsc/if_hn.c stable/11/sys/dev/hyperv/netvsc/if_hnreg.h stable/11/sys/dev/hyperv/netvsc/if_hnvar.h stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/vmbus_timesync.c stable/11/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_et.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/include/hyperv.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hn_nvs.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/hn_nvs.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/netvsc/hn_nvs.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hn_nvs.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/hn_nvs.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/netvsc/hn_rndis.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hn_rndis.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/hn_rndis.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/netvsc/hn_rndis.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hn_rndis.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/hn_rndis.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2010-2012 Citrix Inc. * Copyright (c) 2012 NetApp Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hn.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/if_hn.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2010-2012 Citrix Inc. - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * All rights reserved. * Modified: stable/11/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/if_hnreg.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/netvsc/if_hnvar.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c ============================================================================== --- stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/storvsc/hv_vstorage.h Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012 Microsoft Corp. + * Copyright (c) 2009-2012,2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/hv_kvp.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014,2016 Microsoft Corp. + * Copyright (c) 2014,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/utilities/vmbus_timesync.c ============================================================================== --- stable/11/sys/dev/hyperv/utilities/vmbus_timesync.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/utilities/vmbus_timesync.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014,2016 Microsoft Corp. + * Copyright (c) 2014,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Microsoft Corp. + * Copyright (c) 2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. * Copyright (c) 2012 NetApp Inc. * Copyright (c) 2012 Citrix Inc. * All rights reserved. Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_et.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_et.c Thu Aug 17 04:37:27 2017 (r322611) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_et.c Thu Aug 17 05:09:22 2017 (r322612) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015,2016 Microsoft Corp. + * Copyright (c) 2015,2016-2017 Microsoft Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-stable-11@freebsd.org Thu Aug 17 10:48:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8683DDA855; Thu, 17 Aug 2017 10:48:57 +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 mx1.freebsd.org (Postfix) with ESMTPS id 81C026BE8A; Thu, 17 Aug 2017 10:48:57 +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 v7HAmuk6070276; Thu, 17 Aug 2017 10:48:56 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HAmu3h070275; Thu, 17 Aug 2017 10:48:56 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708171048.v7HAmu3h070275@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 17 Aug 2017 10:48:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322615 - stable/11/usr.sbin/cpucontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/usr.sbin/cpucontrol X-SVN-Commit-Revision: 322615 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.23 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, 17 Aug 2017 10:48:57 -0000 Author: kib Date: Thu Aug 17 10:48:56 2017 New Revision: 322615 URL: https://svnweb.freebsd.org/changeset/base/322615 Log: MFC r322493: Remove confusion in the line explaining syntax of the msr read. Specify words order in the display. Modified: stable/11/usr.sbin/cpucontrol/cpucontrol.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cpucontrol/cpucontrol.8 ============================================================================== --- stable/11/usr.sbin/cpucontrol/cpucontrol.8 Thu Aug 17 07:20:09 2017 (r322614) +++ stable/11/usr.sbin/cpucontrol/cpucontrol.8 Thu Aug 17 10:48:56 2017 (r322615) @@ -90,9 +90,10 @@ The following options are available: .It Fl d Ar datadir Where to look for microcode images. The option can be specified multiple times. -.It Fl m Ar msr Ns Op = Ns Ar value +.It Fl m Ar msr Show value of the specified MSR. MSR register number should be given as a hexadecimal number. +The high word is printed first, then the low word is printed second. .It Fl m Ar msr Ns = Ns Ar value Store the .Ar value From owner-svn-src-stable-11@freebsd.org Thu Aug 17 10:56:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21108DDACAC; Thu, 17 Aug 2017 10:56:24 +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 mx1.freebsd.org (Postfix) with ESMTPS id DB27F6C406; Thu, 17 Aug 2017 10:56:23 +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 v7HAuMGR074313; Thu, 17 Aug 2017 10:56:22 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HAuMYd074312; Thu, 17 Aug 2017 10:56:22 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708171056.v7HAuMYd074312@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 17 Aug 2017 10:56: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: r322616 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 322616 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.23 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, 17 Aug 2017 10:56:24 -0000 Author: kib Date: Thu Aug 17 10:56:22 2017 New Revision: 322616 URL: https://svnweb.freebsd.org/changeset/base/322616 Log: MFC r322494: Style. Modified: stable/11/sys/amd64/amd64/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Thu Aug 17 10:48:56 2017 (r322615) +++ stable/11/sys/amd64/amd64/trap.c Thu Aug 17 10:56:22 2017 (r322616) @@ -166,15 +166,21 @@ trap(struct trapframe *frame) #ifdef KDTRACE_HOOKS struct reg regs; #endif - struct thread *td = curthread; - struct proc *p = td->td_proc; + ksiginfo_t ksi; + struct thread *td; + struct proc *p; + register_t addr; #ifdef KDB register_t dr6; #endif - int i = 0, ucode = 0; + int i, ucode; u_int type; - register_t addr = 0; - ksiginfo_t ksi; + + td = curthread; + p = td->td_proc; + i = 0; + ucode = 0; + addr = 0; PCPU_INC(cnt.v_trap); type = frame->tf_trapno; From owner-svn-src-stable-11@freebsd.org Thu Aug 17 13:48:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9C7ADE2DAC; Thu, 17 Aug 2017 13:48:47 +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 mx1.freebsd.org (Postfix) with ESMTPS id 73C4372B8C; Thu, 17 Aug 2017 13:48:47 +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 v7HDmkx8045348; Thu, 17 Aug 2017 13:48:46 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HDmkqe045347; Thu, 17 Aug 2017 13:48:46 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708171348.v7HDmkqe045347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 13:48: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: r322619 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322619 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.23 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, 17 Aug 2017 13:48:47 -0000 Author: kevans Date: Thu Aug 17 13:48:46 2017 New Revision: 322619 URL: https://svnweb.freebsd.org/changeset/base/322619 Log: bsdgrep: fix build when linking against libgnuregex MFC r322618: bsdgrep: cast pmatch.rm_so to fix build when linking against libgnuregex Approved by: emaste (mentor) Modified: stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 13:40:45 2017 (r322618) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 13:48:46 2017 (r322619) @@ -450,7 +450,7 @@ procline(struct parsec *pc) */ if (r == REG_NOMATCH && (retry == pc->lnstart || - pmatch.rm_so + 1 < retry)) + (unsigned int)pmatch.rm_so + 1 < retry)) retry = pmatch.rm_so + 1; if (r == REG_NOMATCH) continue; From owner-svn-src-stable-11@freebsd.org Thu Aug 17 13:55:12 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46838DE328D for ; Thu, 17 Aug 2017 13:55:12 +0000 (UTC) (envelope-from steven.hartland@multiplay.co.uk) Received: from mail-wr0-x22c.google.com (mail-wr0-x22c.google.com [IPv6:2a00:1450:400c:c0c::22c]) (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 CBF9173190 for ; Thu, 17 Aug 2017 13:55:11 +0000 (UTC) (envelope-from steven.hartland@multiplay.co.uk) Received: by mail-wr0-x22c.google.com with SMTP id y96so41402535wrc.1 for ; Thu, 17 Aug 2017 06:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=multiplay-co-uk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=kG/qGSgkJJFq2gw1jF3gOeY3oBHNAtqAqIPcYxYEppE=; b=y8RPT93jp4BA7lP9YYaRP3p6oZViDfrZ9Cq7okq5Pl/UTem5jpXShC2OkJRkGlWV09 UTYfBsEutTSg7lDNIaT4KpiiiE/FFPMxVROiKm2DUioavwSI6KpHtSIuY4/OeQvlHyJf oM9cKBGwqgflrNSMwPKLkAXEVU9oFs3FLUd6Xd0N77aUVX76sf+S3WJk4Kze5FERml1j PC2u7359esCkGXa5ZbASoiMq9i+eVkA9v5/aUmMIUF2k1T+OV5bCcbOP47StPtqLMGPz ItWjIQ8omx/X2VNpedkNcV6UMbCu9XzcxZn63Un5214GLabs7q+bb7uBe9shJSoF9R/C F2rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=kG/qGSgkJJFq2gw1jF3gOeY3oBHNAtqAqIPcYxYEppE=; b=Aejrx8wTylSkvijaN6zZR0j2EctyJatVm8Nub68zOMQ9xVBd/uOWMta+XDAsGHbz6V bkOglhJFY8e3iUIhX0lmKtLoKcPF6RZXoKvtUI34mtgUFLglJmuTKQwJGnOKkCDRwh6z BVR1pqls/diLSPtGOQZpVju4uw2ARWm95be0JyxEfGYeCV/ZFevk+05XWvNVoiWRwg3d nxw2TLv4X9z/x9IETxvWBEUu5/Eom+Vvbd7+3xCn5YGPLG5SWJFijmABMYyje9vJvqEj zwn4gibi8k3t5S/DbJgryXhChA3Q0s6jbIdJIVT/gCQxRxXZQAIVGD9iWw9X76ICe4fB akjg== X-Gm-Message-State: AHYfb5jIrYXx77wiB/Sup/FyoH4QyNNOaU93Ez4rkkNL6NIPO2uEhjts zREYb2Ei3p0DoKX/dm85hQ== X-Received: by 10.28.105.5 with SMTP id e5mr1295670wmc.42.1502978109938; Thu, 17 Aug 2017 06:55:09 -0700 (PDT) Received: from [10.10.1.111] ([185.97.61.15]) by smtp.gmail.com with ESMTPSA id n17sm3288241wra.6.2017.08.17.06.55.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 06:55:09 -0700 (PDT) Subject: Re: svn commit: r322619 - stable/11/usr.bin/grep To: Kyle Evans , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201708171348.v7HDmkqe045347@repo.freebsd.org> From: Steven Hartland Message-ID: Date: Thu, 17 Aug 2017 14:55:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <201708171348.v7HDmkqe045347@repo.freebsd.org> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Aug 2017 13:55:12 -0000 This seems a little quick considering it only hit head 8 mins ago. On 17/08/2017 14:48, Kyle Evans wrote: > Author: kevans > Date: Thu Aug 17 13:48:46 2017 > New Revision: 322619 > URL: https://svnweb.freebsd.org/changeset/base/322619 > > Log: > bsdgrep: fix build when linking against libgnuregex > > MFC r322618: bsdgrep: cast pmatch.rm_so to fix build when linking against > libgnuregex > > Approved by: emaste (mentor) > > Modified: > stable/11/usr.bin/grep/util.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/usr.bin/grep/util.c > ============================================================================== > --- stable/11/usr.bin/grep/util.c Thu Aug 17 13:40:45 2017 (r322618) > +++ stable/11/usr.bin/grep/util.c Thu Aug 17 13:48:46 2017 (r322619) > @@ -450,7 +450,7 @@ procline(struct parsec *pc) > */ > if (r == REG_NOMATCH && > (retry == pc->lnstart || > - pmatch.rm_so + 1 < retry)) > + (unsigned int)pmatch.rm_so + 1 < retry)) > retry = pmatch.rm_so + 1; > if (r == REG_NOMATCH) > continue; > From owner-svn-src-stable-11@freebsd.org Thu Aug 17 14:04:19 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 75FB1DE3901; Thu, 17 Aug 2017 14:04:19 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-ua0-f177.google.com (mail-ua0-f177.google.com [209.85.217.177]) (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 2F77573676; Thu, 17 Aug 2017 14:04:18 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-ua0-f177.google.com with SMTP id k43so25086576uaf.3; Thu, 17 Aug 2017 07:04:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=COTzbNz5kX+SMYWqMhDIxP8Ud4tjb3qhiTrEq1fghNg=; b=isD7bYMN7cfHmh3RSZ98DjhKlhCF7CvV5h/YLD0Pu7UbNzceMsmEhombzGEERWScqn 60E5rRvB2LkJDlEunn/H2U9RCK7znUHofN6par+kD7JsbAEtbrD1PTxcduWG3iy3bOHZ b5vfxEUJeQudpUtd3pVpekF5OtCViZ/Rb8dKccl+2JQytZSMrDIcWWBe/KYOfZs7wjif +KmgWWrfIF2euTShAiZUpfpyzSkrAdIVUfvwSYfTYF9vazr/L+eKFAqvXl12ctUX/ZLs NHklLPfJYAKDLTtZpYaqwaN+T1jcM9fgDdiaanfOgCpO6q2Z41DPJVvIfby4fdX1Kc3B xMgQ== X-Gm-Message-State: AHYfb5jIqrrMSkJXKtJZsewZ3gT9AUUX9/ueli8lCiKjPgbmxNRadzp5 QK6PrVbAExz1tUSHQ2HP5g== X-Received: by 10.176.25.197 with SMTP id r5mr3667717uai.22.1502978652414; Thu, 17 Aug 2017 07:04:12 -0700 (PDT) Received: from mail-ua0-f177.google.com (mail-ua0-f177.google.com. [209.85.217.177]) by smtp.gmail.com with ESMTPSA id t2sm691214vke.1.2017.08.17.07.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Aug 2017 07:04:11 -0700 (PDT) Received: by mail-ua0-f177.google.com with SMTP id r9so15723793uad.0; Thu, 17 Aug 2017 07:04:11 -0700 (PDT) X-Received: by 10.176.26.12 with SMTP id a12mr3578617uai.110.1502978651632; Thu, 17 Aug 2017 07:04:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.56.194 with HTTP; Thu, 17 Aug 2017 07:03:51 -0700 (PDT) In-Reply-To: References: <201708171348.v7HDmkqe045347@repo.freebsd.org> From: Kyle Evans Date: Thu, 17 Aug 2017 09:03:51 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r322619 - stable/11/usr.bin/grep To: Steven Hartland Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Aug 2017 14:04:19 -0000 Previous commit had broken the build and the fix had been prepared/tested locally for a while due to other changes On Thu, Aug 17, 2017 at 8:55 AM, Steven Hartland < steven.hartland@multiplay.co.uk> wrote: > This seems a little quick considering it only hit head 8 mins ago. > > > On 17/08/2017 14:48, Kyle Evans wrote: > > Author: kevans > Date: Thu Aug 17 13:48:46 2017 > New Revision: 322619 > URL: https://svnweb.freebsd.org/changeset/base/322619 > > Log: > bsdgrep: fix build when linking against libgnuregex > > MFC r322618: bsdgrep: cast pmatch.rm_so to fix build when linking against > libgnuregex > > Approved by: emaste (mentor) > > Modified: > stable/11/usr.bin/grep/util.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/usr.bin/grep/util.c > ============================================================================== > --- stable/11/usr.bin/grep/util.c Thu Aug 17 13:40:45 2017 (r322618) > +++ stable/11/usr.bin/grep/util.c Thu Aug 17 13:48:46 2017 (r322619) > @@ -450,7 +450,7 @@ procline(struct parsec *pc) > */ > if (r == REG_NOMATCH && > (retry == pc->lnstart || > - pmatch.rm_so + 1 < retry)) > + (unsigned int)pmatch.rm_so + 1 < retry)) > retry = pmatch.rm_so + 1; > if (r == REG_NOMATCH) > continue; > > > > From owner-svn-src-stable-11@freebsd.org Thu Aug 17 17:09:29 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3F0EDCA701; Thu, 17 Aug 2017 17:09:29 +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 mx1.freebsd.org (Postfix) with ESMTPS id BB63F7FF7D; Thu, 17 Aug 2017 17:09:29 +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 v7HH9SQn035583; Thu, 17 Aug 2017 17:09:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HH9SeZ035580; Thu, 17 Aug 2017 17:09:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708171709.v7HH9SeZ035580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 17:09:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322622 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322622 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.23 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, 17 Aug 2017 17:09:30 -0000 Author: kevans Date: Thu Aug 17 17:09:28 2017 New Revision: 322622 URL: https://svnweb.freebsd.org/changeset/base/322622 Log: MFC r318914: bsdgrep: correct assumptions to prepare for chunking Correct a couple of minor BSD grep assumptions that are valid for line processing but not future chunk-based processing. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/grep.c Thu Aug 17 17:09:28 2017 (r322622) @@ -79,7 +79,7 @@ const char *errstr[] = { }; /* Flags passed to regcomp() and regexec() */ -int cflags = REG_NOSUB; +int cflags = REG_NOSUB | REG_NEWLINE; int eflags = REG_STARTEND; /* XXX TODO: Get rid of this flag. Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/grep.h Thu Aug 17 17:09:28 2017 (r322622) @@ -82,7 +82,7 @@ extern const char *errstr[]; #define EXCL_PAT 0 #define INCL_PAT 1 -#define MAX_LINE_MATCHES 32 +#define MAX_MATCHES 32 struct file { int fd; Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 17:09:28 2017 (r322622) @@ -61,7 +61,7 @@ static bool first_match = true; * other useful bits */ struct parsec { - regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ + regmatch_t matches[MAX_MATCHES]; /* Matches made */ struct str ln; /* Current line */ size_t lnstart; /* Position in line */ size_t matchidx; /* Latest match index */ @@ -295,7 +295,7 @@ procfile(const char *fn) /* Print the matching line, but only if not quiet/binary */ if (t == 0 && printmatch) { printline(&pc, ':'); - while (pc.matchidx >= MAX_LINE_MATCHES) { + while (pc.matchidx >= MAX_MATCHES) { /* Reset matchidx and try again */ pc.matchidx = 0; if (procline(&pc) == 0) @@ -401,7 +401,7 @@ procline(struct parsec *pc) lastmatches = 0; startm = matchidx; retry = 0; - if (st > 0) + if (st > 0 && pc->ln.dat[st - 1] != fileeol) leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ for (i = 0; i < patterns; i++) { @@ -483,7 +483,7 @@ procline(struct parsec *pc) } /* avoid excessive matching - skip further patterns */ if ((color == NULL && !oflag) || qflag || lflag || - matchidx >= MAX_LINE_MATCHES) { + matchidx >= MAX_MATCHES) { pc->lnstart = nst; lastmatches = 0; break; From owner-svn-src-stable-11@freebsd.org Thu Aug 17 17:12:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04B15DCAA1F; Thu, 17 Aug 2017 17:12:01 +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 mx1.freebsd.org (Postfix) with ESMTPS id C2E86802FA; Thu, 17 Aug 2017 17:12:00 +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 v7HHBxrX038626; Thu, 17 Aug 2017 17:11:59 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HHBxc7038625; Thu, 17 Aug 2017 17:11:59 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201708171711.v7HHBxc7038625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 17 Aug 2017 17:11: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: r322623 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 322623 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.23 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, 17 Aug 2017 17:12:01 -0000 Author: markj Date: Thu Aug 17 17:11:59 2017 New Revision: 322623 URL: https://svnweb.freebsd.org/changeset/base/322623 Log: MFC r322383: Make vm_page_sunbusy() assert that the page is unlocked. Modified: stable/11/sys/vm/vm_page.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Thu Aug 17 17:09:28 2017 (r322622) +++ stable/11/sys/vm/vm_page.c Thu Aug 17 17:11:59 2017 (r322623) @@ -745,6 +745,7 @@ vm_page_sunbusy(vm_page_t m) { u_int x; + vm_page_lock_assert(m, MA_NOTOWNED); vm_page_assert_sbusied(m); for (;;) { From owner-svn-src-stable-11@freebsd.org Thu Aug 17 17:13:16 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67DC0DCAC26; Thu, 17 Aug 2017 17:13:16 +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 mx1.freebsd.org (Postfix) with ESMTPS id 31965806D7; Thu, 17 Aug 2017 17:13:16 +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 v7HHDF3r039587; Thu, 17 Aug 2017 17:13:15 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HHDFF4039586; Thu, 17 Aug 2017 17:13:15 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708171713.v7HHDFF4039586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 17:13:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322624 - stable/11/usr.bin/grep/regex X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep/regex X-SVN-Commit-Revision: 322624 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.23 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, 17 Aug 2017 17:13:16 -0000 Author: kevans Date: Thu Aug 17 17:13:15 2017 New Revision: 322624 URL: https://svnweb.freebsd.org/changeset/base/322624 Log: MFC r318916: bsdgrep: use safer sizeof() construct Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/regex/tre-fastmatch.c ============================================================================== --- stable/11/usr.bin/grep/regex/tre-fastmatch.c Thu Aug 17 17:11:59 2017 (r322623) +++ stable/11/usr.bin/grep/regex/tre-fastmatch.c Thu Aug 17 17:13:15 2017 (r322624) @@ -351,7 +351,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS \ if (fg->len > 0 && !fg->hasdot) \ { \ - fg->sbmGs = malloc(fg->len * sizeof(int)); \ + fg->sbmGs = malloc(fg->len * sizeof(*fg->sbmGs)); \ if (!fg->sbmGs) \ return REG_ESPACE; \ if (fg->len == 1) \ @@ -367,7 +367,7 @@ static int fastcmp(const fastmatch_t *fg, const void * #define FILL_BMGS_WIDE \ if (fg->wlen > 0 && !fg->hasdot) \ { \ - fg->bmGs = malloc(fg->wlen * sizeof(int)); \ + fg->bmGs = malloc(fg->wlen * sizeof(*fg->bmGs)); \ if (!fg->bmGs) \ return REG_ESPACE; \ if (fg->wlen == 1) \ From owner-svn-src-stable-11@freebsd.org Thu Aug 17 17:17:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 294A4DCB010; Thu, 17 Aug 2017 17:17:30 +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 mx1.freebsd.org (Postfix) with ESMTPS id 0124680A41; Thu, 17 Aug 2017 17:17:29 +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 v7HHHTrv039913; Thu, 17 Aug 2017 17:17:29 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HHHS66039910; Thu, 17 Aug 2017 17:17:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708171717.v7HHHS66039910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 17:17:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322625 - in stable/11/usr.bin/grep: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/usr.bin/grep: . tests X-SVN-Commit-Revision: 322625 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.23 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, 17 Aug 2017 17:17:30 -0000 Author: kevans Date: Thu Aug 17 17:17:28 2017 New Revision: 322625 URL: https://svnweb.freebsd.org/changeset/base/322625 Log: bsdgrep: bump version number to 2.6.0 and update copyright information MFC r319132: bsdgrep: bump version number and add Kyle Evans copyright The following changes have been made over the last couple of months: Features: - With bsdgrep -r, the working directory is implied if no directory is specified - bsdgrep will now behave as bsdgrep -r does when it's named rgrep - bsdgrep now understands -z/--null-data to use \0 as EOL - GNU regex compatibility is now indicated with a "GNU compatible" in the version string Fixes: - --mmap no longer hangs when coming across an EOF without an accompanying EOL - -o/--color matching generally improved, now produces earliest / longest matches - Context output now more closely aligns with GNU grep - Zero-length matches no longer exhibit broken behavior - Every output line now honors -b/-H/-n flags Tests have been added for previous regressions as well as other previously untested behaviors. Various other fixes have been commited, and refactoring for further / later improvements has taken place. (The original submission changed the version string to 2.5.2, but I decided to use 2.6.0 to reflect the addition of new features.) MFC r320754: Update copyright e-mail address to @FreeBSD.org address Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/tests/grep_freebsd_test.sh stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Thu Aug 17 17:13:15 2017 (r322624) +++ stable/11/usr.bin/grep/grep.h Thu Aug 17 17:17:28 2017 (r322625) @@ -51,7 +51,7 @@ extern nl_catd catalog; extern const char *errstr[]; -#define VERSION "2.5.1-FreeBSD" +#define VERSION "2.6.0-FreeBSD" #define GREP_FIXED 0 #define GREP_BASIC 1 Modified: stable/11/usr.bin/grep/tests/grep_freebsd_test.sh ============================================================================== --- stable/11/usr.bin/grep/tests/grep_freebsd_test.sh Thu Aug 17 17:13:15 2017 (r322624) +++ stable/11/usr.bin/grep/tests/grep_freebsd_test.sh Thu Aug 17 17:17:28 2017 (r322625) @@ -1,5 +1,5 @@ # -# Copyright (c) 2017 Kyle Evans +# Copyright (c) 2017 Kyle Evans # All rights reserved. # # Redistribution and use in source and binary forms, with or without Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 17:13:15 2017 (r322624) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 17:17:28 2017 (r322625) @@ -5,6 +5,7 @@ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav * Copyright (C) 2008-2010 Gabor Kovesdan + * Copyright (C) 2017 Kyle Evans * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-svn-src-stable-11@freebsd.org Fri Aug 18 07:00:02 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3B3C8DCE90D; Fri, 18 Aug 2017 07:00:02 +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 mx1.freebsd.org (Postfix) with ESMTPS id 08A2975FA6; Fri, 18 Aug 2017 07:00:01 +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 v7I701N6080103; Fri, 18 Aug 2017 07:00:01 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7I701WD080102; Fri, 18 Aug 2017 07:00:01 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708180700.v7I701WD080102@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 18 Aug 2017 07:00: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: r322647 - stable/11/sbin/route X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sbin/route X-SVN-Commit-Revision: 322647 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.23 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, 18 Aug 2017 07:00:02 -0000 Author: kib Date: Fri Aug 18 07:00:00 2017 New Revision: 322647 URL: https://svnweb.freebsd.org/changeset/base/322647 Log: MFC r322550: Typo, the '-6' option selects inet6. Modified: stable/11/sbin/route/route.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/route/route.8 ============================================================================== --- stable/11/sbin/route/route.8 Fri Aug 18 04:07:25 2017 (r322646) +++ stable/11/sbin/route/route.8 Fri Aug 18 07:00:00 2017 (r322647) @@ -68,7 +68,7 @@ Specify address family as family hint for subcommands. .It Fl 6 Specify -.Cm inet +.Cm inet6 address family as family hint for subcommands. .It Fl d Run in debug-only mode, i.e., do not actually modify the routing table. From owner-svn-src-stable-11@freebsd.org Fri Aug 18 14:25:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A776CDE4BC9; Fri, 18 Aug 2017 14:25:09 +0000 (UTC) (envelope-from ken@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 mx1.freebsd.org (Postfix) with ESMTPS id 4C7F1654B4; Fri, 18 Aug 2017 14:25:09 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7IEP8fL063920; Fri, 18 Aug 2017 14:25:08 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7IEP7TY063909; Fri, 18 Aug 2017 14:25:07 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201708181425.v7IEP7TY063909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Fri, 18 Aug 2017 14:25:07 +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: r322658 - in stable/11/sys/dev: mpr mps X-SVN-Group: stable-11 X-SVN-Commit-Author: ken X-SVN-Commit-Paths: in stable/11/sys/dev: mpr mps X-SVN-Commit-Revision: 322658 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.23 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, 18 Aug 2017 14:25:09 -0000 Author: ken Date: Fri Aug 18 14:25:07 2017 New Revision: 322658 URL: https://svnweb.freebsd.org/changeset/base/322658 Log: MFC r321502, r321714, r321733, r321737, r321799, r322364: ------------------------------------------------------------------------ r321502 | scottl | 2017-07-25 19:48:13 -0600 (Tue, 25 Jul 2017) | 2 lines Quiet a message that sounds far more dire than it really is. ------------------------------------------------------------------------ r321714 | scottl | 2017-07-30 00:53:58 -0600 (Sun, 30 Jul 2017) | 13 lines Split the interrupt setup code into two parts: allocation and configuration. Do the allocation before requesting the IOCFacts message. This triggers the LSI firmware to recognize the multiqueue should be enabled if available. Multiqueue isn't used by the driver yet, but this also fixes a problem with the cached IOCFacts not matching latter checks, leading to potential problems with error recovery. As a side-effect, fetch the driver tunables as early as possible. Reviewed by: slm Obtained from: Netflix Differential Revision: D9243 ------------------------------------------------------------------------ r321733 | scottl | 2017-07-30 16:34:24 -0600 (Sun, 30 Jul 2017) | 5 lines Change from using underbar function names to normal function names for the informational print functions. Collapse the debug API a bit to be more generic and not require as much code duplication. While here, fix a bug in MPS that was already fixed in MPR. ------------------------------------------------------------------------ r321737 | scottl | 2017-07-30 18:05:49 -0600 (Sun, 30 Jul 2017) | 3 lines Don't re-parse PCI IDs in order to set card-specific flags, use the flags field in the PCIID table. ------------------------------------------------------------------------ r321799 | scottl | 2017-07-31 10:55:56 -0600 (Mon, 31 Jul 2017) | 4 lines Fix a logic bug in the split PCI interrupt code that slipped through Reported by: Harry Schmalzbauer ------------------------------------------------------------------------ r322364 | ken | 2017-08-10 08:59:17 -0600 (Thu, 10 Aug 2017) | 39 lines Changes to make mps(4) and mpr(4) handle reinit with reallocation. When the mps(4) and mpr(4) drivers need to reinitialize the firmware, they sometimes need to reallocate all of the memory allocated by the driver. The reallocation happens whenever the IOC Facts change. That should only happen after a firmware upgrade. If the reinitialization happens as a result of a timed out command sent to the card, the command that timed out and triggered the reinit may have been freed if iocfacts_allocate() reallocated all memory. If the caller attempts to access the command after that, the kernel will panic because the caller will be dereferencing freed memory. The solution is to set a flag in the softc when we reallocate, and avoid dereferencing the command strucure if we've reallocated. The changes are largely the same in both drivers, since mpr(4) is a derivative of mps(4). o In iocfacts_allocate(), if the IOC Facts have changed and we need to reallocate, set the REALLOCATED flag in the softc. o Change wait_command() to take a struct mps_command ** instead of a struct mps_command *. This allows us to NULL out the caller's command pointer if we have to reinit the controller and the data structures get reallocated. (The REALLOCATED flag will be set in the softc if that has happened.) o In every place that calls wait_command(), make sure we handle the case where the command is NULL after the call. o The mpr(4) driver has mpr_request_polled() which can also reinitialize the card. Also check for reallocation there. Reviewed by: scottl, slm Sponsored by: Spectra Logic ------------------------------------------------------------------------ Modified: stable/11/sys/dev/mpr/mpr.c stable/11/sys/dev/mpr/mpr_config.c stable/11/sys/dev/mpr/mpr_pci.c stable/11/sys/dev/mpr/mpr_sas.c stable/11/sys/dev/mpr/mpr_sas_lsi.c stable/11/sys/dev/mpr/mpr_table.c stable/11/sys/dev/mpr/mpr_table.h stable/11/sys/dev/mpr/mpr_user.c stable/11/sys/dev/mpr/mprvar.h stable/11/sys/dev/mps/mps.c stable/11/sys/dev/mps/mps_config.c stable/11/sys/dev/mps/mps_pci.c stable/11/sys/dev/mps/mps_sas.c stable/11/sys/dev/mps/mps_sas_lsi.c stable/11/sys/dev/mps/mps_table.c stable/11/sys/dev/mps/mps_table.h stable/11/sys/dev/mps/mps_user.c stable/11/sys/dev/mps/mpsvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpr/mpr.c ============================================================================== --- stable/11/sys/dev/mpr/mpr.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr.c Fri Aug 18 14:25:07 2017 (r322658) @@ -381,7 +381,7 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at } } - mpr_print_iocfacts(sc, sc->facts); + MPR_DPRINT_PAGE(sc, MPR_XINFO, iocfacts, sc->facts); snprintf(sc->fw_version, sizeof(sc->fw_version), "%02d.%02d.%02d.%02d", @@ -436,6 +436,8 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at /* Only deallocate and reallocate if relevant IOC Facts have changed */ reallocating = FALSE; + sc->mpr_flags &= ~MPR_FLAGS_REALLOCATED; + if ((!attaching) && ((saved_facts.MsgVersion != sc->facts->MsgVersion) || (saved_facts.HeaderVersion != sc->facts->HeaderVersion) || @@ -458,6 +460,9 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at (saved_facts.MaxPersistentEntries != sc->facts->MaxPersistentEntries))) { reallocating = TRUE; + + /* Record that we reallocated everything */ + sc->mpr_flags |= MPR_FLAGS_REALLOCATED; } /* @@ -1482,7 +1487,7 @@ mpr_init_queues(struct mpr_softc *sc) * Next are the global settings, if they exist. Highest are the per-unit * settings, if they exist. */ -static void +void mpr_get_tunables(struct mpr_softc *sc) { char tmpstr[80]; @@ -1658,8 +1663,6 @@ mpr_attach(struct mpr_softc *sc) { int error; - mpr_get_tunables(sc); - MPR_FUNCTRACE(sc); mtx_init(&sc->mpr_mtx, "MPR lock", NULL, MTX_DEF); @@ -1774,7 +1777,7 @@ mpr_log_evt_handler(struct mpr_softc *sc, uintptr_t da { MPI2_EVENT_DATA_LOG_ENTRY_ADDED *entry; - mpr_print_event(sc, event); + MPR_DPRINT_EVENT(sc, generic, event); switch (event->Event) { case MPI2_EVENT_LOG_DATA: @@ -2189,7 +2192,7 @@ mpr_reregister_events_complete(struct mpr_softc *sc, s mpr_dprint(sc, MPR_TRACE, "%s\n", __func__); if (cm->cm_reply) - mpr_print_event(sc, + MPR_DPRINT_EVENT(sc, generic, (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply); mpr_free_command(sc, cm); @@ -2231,8 +2234,8 @@ mpr_update_events(struct mpr_softc *sc, struct mpr_eve uint8_t *mask) { MPI2_EVENT_NOTIFICATION_REQUEST *evtreq; - MPI2_EVENT_NOTIFICATION_REPLY *reply; - struct mpr_command *cm; + MPI2_EVENT_NOTIFICATION_REPLY *reply = NULL; + struct mpr_command *cm = NULL; struct mpr_event_handle *eh; int error, i; @@ -2265,18 +2268,20 @@ mpr_update_events(struct mpr_softc *sc, struct mpr_eve cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_request_polled(sc, cm); - reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply; if ((reply == NULL) || (reply->IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS) error = ENXIO; if (reply) - mpr_print_event(sc, reply); + MPR_DPRINT_EVENT(sc, generic, reply); mpr_dprint(sc, MPR_TRACE, "%s finished error %d\n", __func__, error); - mpr_free_command(sc, cm); + if (cm != NULL) + mpr_free_command(sc, cm); return (error); } @@ -3262,11 +3267,12 @@ mpr_map_command(struct mpr_softc *sc, struct mpr_comma * be executed and enqueued automatically. Other errors come from msleep(). */ int -mpr_wait_command(struct mpr_softc *sc, struct mpr_command *cm, int timeout, +mpr_wait_command(struct mpr_softc *sc, struct mpr_command **cmp, int timeout, int sleep_flag) { int error, rc; struct timeval cur_time, start_time; + struct mpr_command *cm = *cmp; if (sc->mpr_flags & MPR_FLAGS_DIAGRESET) return EBUSY; @@ -3321,6 +3327,13 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm rc = mpr_reinit(sc); mpr_dprint(sc, MPR_FAULT, "Reinit %s\n", (rc == 0) ? "success" : "failed"); + if (sc->mpr_flags & MPR_FLAGS_REALLOCATED) { + /* + * Tell the caller that we freed the command in a + * reinit. + */ + *cmp = NULL; + } error = ETIMEDOUT; } return (error); @@ -3331,10 +3344,11 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm * completion. Its use should be rare. */ int -mpr_request_polled(struct mpr_softc *sc, struct mpr_command *cm) +mpr_request_polled(struct mpr_softc *sc, struct mpr_command **cmp) { - int error, timeout = 0, rc; + int error, rc; struct timeval cur_time, start_time; + struct mpr_command *cm = *cmp; error = 0; @@ -3342,7 +3356,7 @@ mpr_request_polled(struct mpr_softc *sc, struct mpr_co cm->cm_complete = NULL; mpr_map_command(sc, cm); - getmicrotime(&start_time); + getmicrouptime(&start_time); while ((cm->cm_flags & MPR_CM_FLAGS_COMPLETE) == 0) { mpr_intr_locked(sc); @@ -3355,9 +3369,9 @@ mpr_request_polled(struct mpr_softc *sc, struct mpr_co /* * Check for real-time timeout and fail if more than 60 seconds. */ - getmicrotime(&cur_time); - timeout = cur_time.tv_sec - start_time.tv_sec; - if (timeout > 60) { + getmicrouptime(&cur_time); + timevalsub(&cur_time, &start_time); + if (cur_time.tv_sec > 60) { mpr_dprint(sc, MPR_FAULT, "polling failed\n"); error = ETIMEDOUT; break; @@ -3369,6 +3383,14 @@ mpr_request_polled(struct mpr_softc *sc, struct mpr_co rc = mpr_reinit(sc); mpr_dprint(sc, MPR_FAULT, "Reinit %s\n", (rc == 0) ? "success" : "failed"); + + if (sc->mpr_flags & MPR_FLAGS_REALLOCATED) { + /* + * Tell the caller that we freed the command in a + * reinit. + */ + *cmp = NULL; + } } return (error); } @@ -3434,11 +3456,12 @@ mpr_read_config_page(struct mpr_softc *sc, struct mpr_ cm->cm_complete = mpr_config_complete; return (mpr_map_command(sc, cm)); } else { - error = mpr_wait_command(sc, cm, 0, CAN_SLEEP); + error = mpr_wait_command(sc, &cm, 0, CAN_SLEEP); if (error) { mpr_dprint(sc, MPR_FAULT, "Error %d reading config page\n", error); - mpr_free_command(sc, cm); + if (cm != NULL) + mpr_free_command(sc, cm); return (error); } mpr_config_complete(sc, cm); Modified: stable/11/sys/dev/mpr/mpr_config.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_config.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_config.c Fri Aug 18 14:25:07 2017 (r322658) @@ -95,8 +95,9 @@ mpr_config_get_ioc_pg8(struct mpr_softc *sc, Mpi2Confi request->Header.PageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -153,8 +154,9 @@ mpr_config_get_ioc_pg8(struct mpr_softc *sc, Mpi2Confi } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -225,8 +227,9 @@ mpr_config_get_iounit_pg8(struct mpr_softc *sc, Mpi2Co request->Header.PageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -283,8 +286,9 @@ mpr_config_get_iounit_pg8(struct mpr_softc *sc, Mpi2Co } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -393,8 +397,9 @@ mpr_config_get_dpm_pg0(struct mpr_softc *sc, Mpi2Confi MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -453,8 +458,9 @@ mpr_config_get_dpm_pg0(struct mpr_softc *sc, Mpi2Confi goto out; } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -529,8 +535,9 @@ int mpr_config_set_dpm_pg0(struct mpr_softc *sc, Mpi2C request->PageAddress |= htole16(entry_idx); cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -591,8 +598,9 @@ int mpr_config_set_dpm_pg0(struct mpr_softc *sc, Mpi2C bcopy(config_page, page, MIN(cm->cm_length, (sizeof(Mpi2DriverMappingPage0_t)))); cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -664,8 +672,9 @@ mpr_config_get_sas_device_pg0(struct mpr_softc *sc, Mp request->ExtPageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -724,8 +733,9 @@ mpr_config_get_sas_device_pg0(struct mpr_softc *sc, Mp } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -799,8 +809,9 @@ mpr_config_get_pcie_device_pg0(struct mpr_softc *sc, M request->ExtPageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -859,8 +870,9 @@ mpr_config_get_pcie_device_pg0(struct mpr_softc *sc, M } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -934,8 +946,9 @@ mpr_config_get_pcie_device_pg2(struct mpr_softc *sc, M request->ExtPageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -994,8 +1007,9 @@ mpr_config_get_pcie_device_pg2(struct mpr_softc *sc, M } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1066,8 +1080,9 @@ mpr_config_get_bios_pg3(struct mpr_softc *sc, Mpi2Conf request->Header.PageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1124,8 +1139,9 @@ mpr_config_get_bios_pg3(struct mpr_softc *sc, Mpi2Conf } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1173,7 +1189,7 @@ mpr_config_get_raid_volume_pg0(struct mpr_softc *sc, M *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 page_address) { MPI2_CONFIG_REQUEST *request; - MPI2_CONFIG_REPLY *reply; + MPI2_CONFIG_REPLY *reply = NULL; struct mpr_command *cm; Mpi2RaidVolPage0_t *page = NULL; int error = 0; @@ -1201,8 +1217,9 @@ mpr_config_get_raid_volume_pg0(struct mpr_softc *sc, M * This page must be polled because the IOC isn't ready yet when this * page is needed. */ - error = mpr_request_polled(sc, cm); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* If the poll returns error then we need to do diag reset */ @@ -1258,8 +1275,9 @@ mpr_config_get_raid_volume_pg0(struct mpr_softc *sc, M * This page must be polled because the IOC isn't ready yet when this * page is needed. */ - error = mpr_request_polled(sc, cm); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* If the poll returns error then we need to do diag reset */ @@ -1325,8 +1343,9 @@ mpr_config_get_raid_volume_pg1(struct mpr_softc *sc, M request->Header.PageLength = request->Header.PageVersion = 0; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; cm->cm_data = NULL; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1384,8 +1403,9 @@ mpr_config_get_raid_volume_pg1(struct mpr_softc *sc, M } cm->cm_data = page; - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1459,7 +1479,7 @@ mpr_config_get_raid_pd_pg0(struct mpr_softc *sc, Mpi2C Mpi2RaidPhysDiskPage0_t *config_page, u32 page_address) { MPI2_CONFIG_REQUEST *request; - MPI2_CONFIG_REPLY *reply; + MPI2_CONFIG_REPLY *reply = NULL; struct mpr_command *cm; Mpi2RaidPhysDiskPage0_t *page = NULL; int error = 0; @@ -1487,8 +1507,9 @@ mpr_config_get_raid_pd_pg0(struct mpr_softc *sc, Mpi2C * This page must be polled because the IOC isn't ready yet when this * page is needed. */ - error = mpr_request_polled(sc, cm); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* If the poll returns error then we need to do diag reset */ @@ -1544,8 +1565,9 @@ mpr_config_get_raid_pd_pg0(struct mpr_softc *sc, Mpi2C * This page must be polled because the IOC isn't ready yet when this * page is needed. */ - error = mpr_request_polled(sc, cm); - reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (MPI2_CONFIG_REPLY *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* If the poll returns error then we need to do diag reset */ Modified: stable/11/sys/dev/mpr/mpr_pci.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_pci.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_pci.c Fri Aug 18 14:25:07 2017 (r322658) @@ -69,6 +69,7 @@ static int mpr_pci_resume(device_t); static void mpr_pci_free(struct mpr_softc *); static int mpr_alloc_msix(struct mpr_softc *sc, int msgs); static int mpr_alloc_msi(struct mpr_softc *sc, int msgs); +static int mpr_pci_alloc_interrupts(struct mpr_softc *sc); static device_method_t mpr_methods[] = { DEVMETHOD(device_probe, mpr_pci_probe), @@ -124,23 +125,32 @@ struct mpr_ident { { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3324_2, 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3324_2" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3408, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3408" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3408" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3416, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3416" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3416" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3508, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3508" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3508" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3508_1, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3508_1" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3508_1" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3516, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3516" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3516" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3516_1, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3516_1" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3516_1" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3616, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3616" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3616" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3708, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3708" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3708" }, { MPI2_MFGPAGE_VENDORID_LSI, MPI26_MFGPAGE_DEVID_SAS3716, - 0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS3716" }, + 0xffff, 0xffff, MPR_FLAGS_GEN35_IOC, + "Avago Technologies (LSI) SAS3716" }, { 0, 0, 0, 0, 0, NULL } }; @@ -191,22 +201,11 @@ mpr_pci_attach(device_t dev) m = mpr_find_ident(dev); sc->mpr_flags = m->flags; + mpr_get_tunables(sc); + /* Twiddle basic PCI config bits for a sanity check */ pci_enable_busmaster(dev); - /* Set flag if this is a Gen3.5 IOC */ - if ((m->device == MPI26_MFGPAGE_DEVID_SAS3508) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3508_1) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3408) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3516) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3516_1) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3416) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3716) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3616) || - (m->device == MPI26_MFGPAGE_DEVID_SAS3708)) { - sc->mpr_flags |= MPR_FLAGS_GEN35_IOC; - } - for (i = 0; i < PCI_MAXMAPS_0; i++) { sc->mpr_regs_rid = PCIR_BAR(i); @@ -240,28 +239,52 @@ mpr_pci_attach(device_t dev) return (ENOMEM); } - if ((error = mpr_attach(sc)) != 0) + if (((error = mpr_pci_alloc_interrupts(sc)) != 0) || + ((error = mpr_attach(sc)) != 0)) mpr_pci_free(sc); return (error); } +/* + * Allocate, but don't assign interrupts early. Doing it before requesting + * the IOCFacts message informs the firmware that we want to do MSI-X + * multiqueue. We might not use all of the available messages, but there's + * no reason to re-alloc if we don't. + */ int -mpr_pci_setup_interrupts(struct mpr_softc *sc) +mpr_pci_alloc_interrupts(struct mpr_softc *sc) { device_t dev; - int i, error, msgs; + int error, msgs; dev = sc->mpr_dev; - error = ENXIO; + error = 0; + msgs = 0; + if ((sc->disable_msix == 0) && ((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT)) error = mpr_alloc_msix(sc, MPR_MSI_COUNT); if ((error != 0) && (sc->disable_msi == 0) && ((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT)) error = mpr_alloc_msi(sc, MPR_MSI_COUNT); + if (error != 0) + msgs = 0; - if (error != 0) { + sc->msi_msgs = msgs; + return (error); +} + +int +mpr_pci_setup_interrupts(struct mpr_softc *sc) +{ + device_t dev; + int i, error; + + dev = sc->mpr_dev; + error = ENXIO; + + if (sc->msi_msgs == 0) { sc->mpr_flags |= MPR_FLAGS_INTX; sc->mpr_irq_rid[0] = 0; sc->mpr_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ, Modified: stable/11/sys/dev/mpr/mpr_sas.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_sas.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_sas.c Fri Aug 18 14:25:07 2017 (r322658) @@ -1193,13 +1193,8 @@ mprsas_complete_all_commands(struct mpr_softc *sc) completed = 1; } - if (cm->cm_sc->io_cmds_active != 0) { + if (cm->cm_sc->io_cmds_active != 0) cm->cm_sc->io_cmds_active--; - } else { - mpr_dprint(cm->cm_sc, MPR_INFO, "Warning: " - "io_cmds_active is out of sync - resynching to " - "0\n"); - } if ((completed == 0) && (cm->cm_state != MPR_CM_STATE_FREE)) { /* this should never happen, but if it does, log */ @@ -2677,7 +2672,7 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mp if ((sassc->flags & MPRSAS_QUEUE_FROZEN) == 0) { xpt_freeze_simq(sassc->sim, 1); sassc->flags |= MPRSAS_QUEUE_FROZEN; - mpr_dprint(sc, MPR_INFO, "Error sending command, " + mpr_dprint(sc, MPR_XINFO, "Error sending command, " "freezing SIM queue\n"); } } Modified: stable/11/sys/dev/mpr/mpr_sas_lsi.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_sas_lsi.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_sas_lsi.c Fri Aug 18 14:25:07 2017 (r322658) @@ -139,7 +139,7 @@ mprsas_evt_handler(struct mpr_softc *sc, uintptr_t dat u16 sz; mpr_dprint(sc, MPR_TRACE, "%s\n", __func__); - mpr_print_evt_sas(sc, event); + MPR_DPRINT_EVENT(sc, sas, event); mprsas_record_event(sc, event); fw_event = malloc(sizeof(struct mpr_fw_event_work), M_MPR, @@ -324,7 +324,7 @@ mprsas_fw_work(struct mpr_softc *sc, struct mpr_fw_eve { // build RAID Action message Mpi2RaidActionRequest_t *action; - Mpi2RaidActionReply_t *reply; + Mpi2RaidActionReply_t *reply = NULL; struct mpr_command *cm; int error = 0; if ((cm = mpr_alloc_command(sc)) == NULL) { @@ -344,8 +344,10 @@ mprsas_fw_work(struct mpr_softc *sc, struct mpr_fw_eve action->PhysDiskNum = element->PhysDiskNum; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; - error = mpr_request_polled(sc, cm); - reply = (Mpi2RaidActionReply_t *)cm->cm_reply; + error = mpr_request_polled(sc, &cm); + if (cm != NULL) + reply = (Mpi2RaidActionReply_t *) + cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1132,12 +1134,14 @@ mprsas_get_sata_identify(struct mpr_softc *sc, u16 han "command\n", __func__); callout_reset(&cm->cm_callout, MPR_ATA_ID_TIMEOUT * hz, mprsas_ata_id_timeout, cm); - error = mpr_wait_command(sc, cm, 60, CAN_SLEEP); + error = mpr_wait_command(sc, &cm, 60, CAN_SLEEP); mpr_dprint(sc, MPR_XINFO, "%s stop timeout counter for SATA ID " "command\n", __func__); + /* XXX KDM need to fix the case where this command is destroyed */ callout_stop(&cm->cm_callout); - reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply; + if (cm != NULL) + reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply; if (error || (reply == NULL)) { /* FIXME */ /* @@ -1603,7 +1607,7 @@ mprsas_ir_shutdown(struct mpr_softc *sc) action->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; mpr_lock(sc); - mpr_wait_command(sc, cm, 5, CAN_SLEEP); + mpr_wait_command(sc, &cm, 5, CAN_SLEEP); mpr_unlock(sc); /* Modified: stable/11/sys/dev/mpr/mpr_table.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_table.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_table.c Fri Aug 18 14:25:07 2017 (r322658) @@ -219,7 +219,7 @@ mpr_describe_devinfo(uint32_t devinfo, char *string, i } void -_mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) +mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) { MPR_PRINTFIELD_START(sc, "IOCFacts"); MPR_PRINTFIELD(sc, facts, MsgVersion, 0x%x); @@ -259,7 +259,7 @@ _mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FAC } void -_mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts) +mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts) { MPR_PRINTFIELD_START(sc, "PortFacts"); @@ -269,7 +269,7 @@ _mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_F } void -_mpr_print_event(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) +mpr_print_evt_generic(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) { MPR_PRINTFIELD_START(sc, "EventReply"); @@ -281,7 +281,7 @@ _mpr_print_event(struct mpr_softc *sc, MPI2_EVENT_NOTI } void -_mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf) +mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf) { MPR_PRINTFIELD_START(sc, "SAS Device Page 0"); MPR_PRINTFIELD(sc, buf, Slot, %d); @@ -310,10 +310,10 @@ _mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_P } void -_mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) +mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) { - _mpr_print_event(sc, event); + mpr_print_evt_generic(sc, event); switch(event->Event) { case MPI2_EVENT_SAS_DISCOVERY: @@ -407,7 +407,7 @@ _mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NO } void -_mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf) +mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf) { MPR_PRINTFIELD_START(sc, "SAS Expander Page 1 #%d", buf->Phy); MPR_PRINTFIELD(sc, buf, PhysicalPort, %d); @@ -447,7 +447,7 @@ _mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG } void -_mpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf) +mpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf) { MPR_PRINTFIELD_START(sc, "SAS PHY Page 0"); MPR_PRINTFIELD(sc, buf, OwnerDevHandle, 0x%04x); Modified: stable/11/sys/dev/mpr/mpr_table.h ============================================================================== --- stable/11/sys/dev/mpr/mpr_table.h Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_table.h Fri Aug 18 14:25:07 2017 (r322658) @@ -42,63 +42,22 @@ extern struct mpr_table_lookup mpr_phystatus_names[]; extern struct mpr_table_lookup mpr_linkrate_names[]; extern struct mpr_table_lookup mpr_pcie_linkrate_names[]; -void _mpr_print_iocfacts(struct mpr_softc *, MPI2_IOC_FACTS_REPLY *); -void _mpr_print_portfacts(struct mpr_softc *, MPI2_PORT_FACTS_REPLY *); -void _mpr_print_event(struct mpr_softc *, MPI2_EVENT_NOTIFICATION_REPLY *); -void _mpr_print_sasdev0(struct mpr_softc *, MPI2_CONFIG_PAGE_SAS_DEV_0 *); -void _mpr_print_evt_sas(struct mpr_softc *, MPI2_EVENT_NOTIFICATION_REPLY *); -void _mpr_print_expander1(struct mpr_softc *, MPI2_CONFIG_PAGE_EXPANDER_1 *); -void _mpr_print_sasphy0(struct mpr_softc *, MPI2_CONFIG_PAGE_SAS_PHY_0 *); +void mpr_print_iocfacts(struct mpr_softc *, MPI2_IOC_FACTS_REPLY *); +void mpr_print_portfacts(struct mpr_softc *, MPI2_PORT_FACTS_REPLY *); +void mpr_print_evt_generic(struct mpr_softc *, MPI2_EVENT_NOTIFICATION_REPLY *); +void mpr_print_sasdev0(struct mpr_softc *, MPI2_CONFIG_PAGE_SAS_DEV_0 *); +void mpr_print_evt_sas(struct mpr_softc *, MPI2_EVENT_NOTIFICATION_REPLY *); +void mpr_print_expander1(struct mpr_softc *, MPI2_CONFIG_PAGE_EXPANDER_1 *); +void mpr_print_sasphy0(struct mpr_softc *, MPI2_CONFIG_PAGE_SAS_PHY_0 *); void mpr_print_sgl(struct mpr_softc *, struct mpr_command *, int); void mpr_print_scsiio_cmd(struct mpr_softc *, struct mpr_command *); -static __inline void -mpr_print_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts) -{ - if (sc->mpr_debug & MPR_XINFO) - _mpr_print_iocfacts(sc, facts); -} +#define MPR_DPRINT_PAGE(sc, level, func, buf) \ +do { \ + if ((sc)->mpr_debug & level) \ + mpr_print_##func((sc), buf); \ +} while (0) -static __inline void -mpr_print_portfacts(struct mpr_softc *sc, MPI2_PORT_FACTS_REPLY *facts) -{ - if (sc->mpr_debug & MPR_XINFO) - _mpr_print_portfacts(sc, facts); -} - -static __inline void -mpr_print_event(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) -{ - if (sc->mpr_debug & MPR_EVENT) - _mpr_print_event(sc, event); -} - -static __inline void -mpr_print_evt_sas(struct mpr_softc *sc, MPI2_EVENT_NOTIFICATION_REPLY *event) -{ - if (sc->mpr_debug & MPR_EVENT) - _mpr_print_evt_sas(sc, event); -} - -static __inline void -mpr_print_sasdev0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_DEV_0 *buf) -{ - if (sc->mpr_debug & MPR_XINFO) - _mpr_print_sasdev0(sc, buf); -} - -static __inline void -mpr_print_expander1(struct mpr_softc *sc, MPI2_CONFIG_PAGE_EXPANDER_1 *buf) -{ - if (sc->mpr_debug & MPR_XINFO) - _mpr_print_expander1(sc, buf); -} - -static __inline void -mpr_print_sasphy0(struct mpr_softc *sc, MPI2_CONFIG_PAGE_SAS_PHY_0 *buf) -{ - if (sc->mpr_debug & MPR_XINFO) - _mpr_print_sasphy0(sc, buf); -} - +#define MPR_DPRINT_EVENT(sc, func, buf) \ + MPR_DPRINT_PAGE(sc, MPR_EVENT, evt_##func, buf) #endif Modified: stable/11/sys/dev/mpr/mpr_user.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_user.c Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mpr_user.c Fri Aug 18 14:25:07 2017 (r322658) @@ -652,7 +652,7 @@ static int mpr_user_command(struct mpr_softc *sc, struct mpr_usr_command *cmd) { MPI2_REQUEST_HEADER *hdr; - MPI2_DEFAULT_REPLY *rpl; + MPI2_DEFAULT_REPLY *rpl = NULL; void *buf = NULL; struct mpr_command *cm = NULL; int err = 0; @@ -664,7 +664,7 @@ mpr_user_command(struct mpr_softc *sc, struct mpr_usr_ if (cm == NULL) { mpr_printf(sc, "%s: no mpr requests\n", __func__); err = ENOMEM; - goto Ret; + goto RetFree; } mpr_unlock(sc); @@ -706,15 +706,16 @@ mpr_user_command(struct mpr_softc *sc, struct mpr_usr_ goto RetFreeUnlocked; mpr_lock(sc); - err = mpr_wait_command(sc, cm, 30, CAN_SLEEP); + err = mpr_wait_command(sc, &cm, 30, CAN_SLEEP); - if (err) { + if (err || (cm == NULL)) { mpr_printf(sc, "%s: invalid request: error %d\n", __func__, err); - goto Ret; + goto RetFree; } - rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply; + if (cm != NULL) + rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply; if (rpl != NULL) sz = rpl->MsgLength * 4; else @@ -734,9 +735,9 @@ mpr_user_command(struct mpr_softc *sc, struct mpr_usr_ RetFreeUnlocked: mpr_lock(sc); +RetFree: if (cm != NULL) mpr_free_command(sc, cm); -Ret: mpr_unlock(sc); if (buf != NULL) free(buf, M_MPRUSER); @@ -850,7 +851,7 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru err = 1; } else { mprsas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD); - err = mpr_wait_command(sc, cm, 30, CAN_SLEEP); + err = mpr_wait_command(sc, &cm, 30, CAN_SLEEP); } if (err != 0) { @@ -861,7 +862,7 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru /* * Copy the reply data and sense data to user space. */ - if (cm->cm_reply != NULL) { + if ((cm != NULL) && (cm->cm_reply != NULL)) { rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply; sz = rpl->MsgLength * 4; @@ -1054,13 +1055,12 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru mpr_lock(sc); - err = mpr_wait_command(sc, cm, 30, CAN_SLEEP); + err = mpr_wait_command(sc, &cm, 30, CAN_SLEEP); - if (err) { + if (err || (cm == NULL)) { mpr_printf(sc, "%s: invalid request: error %d\n", __func__, err); - mpr_unlock(sc); - goto RetFreeUnlocked; + goto RetFree; } /* @@ -1153,6 +1153,7 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru RetFreeUnlocked: mpr_lock(sc); +RetFree: if (cm != NULL) { if (cm->cm_data) free(cm->cm_data, M_MPRUSER); @@ -1301,8 +1302,8 @@ mpr_post_fw_diag_buffer(struct mpr_softc *sc, /* * Send command synchronously. */ - status = mpr_wait_command(sc, cm, 30, CAN_SLEEP); - if (status) { + status = mpr_wait_command(sc, &cm, 30, CAN_SLEEP); + if (status || (cm == NULL)) { mpr_printf(sc, "%s: invalid request: error %d\n", __func__, status); status = MPR_DIAG_FAILURE; @@ -1333,7 +1334,8 @@ mpr_post_fw_diag_buffer(struct mpr_softc *sc, status = MPR_DIAG_SUCCESS; done: - mpr_free_command(sc, cm); + if (cm != NULL) + mpr_free_command(sc, cm); return (status); } @@ -1387,8 +1389,8 @@ mpr_release_fw_diag_buffer(struct mpr_softc *sc, /* * Send command synchronously. */ - status = mpr_wait_command(sc, cm, 30, CAN_SLEEP); - if (status) { + status = mpr_wait_command(sc, &cm, 30, CAN_SLEEP); + if (status || (cm == NULL)) { mpr_printf(sc, "%s: invalid request: error %d\n", __func__, status); status = MPR_DIAG_FAILURE; @@ -1423,6 +1425,9 @@ mpr_release_fw_diag_buffer(struct mpr_softc *sc, } done: + if (cm != NULL) + mpr_free_command(sc, cm); + return (status); } Modified: stable/11/sys/dev/mpr/mprvar.h ============================================================================== --- stable/11/sys/dev/mpr/mprvar.h Fri Aug 18 14:17:12 2017 (r322657) +++ stable/11/sys/dev/mpr/mprvar.h Fri Aug 18 14:25:07 2017 (r322658) @@ -275,9 +275,11 @@ struct mpr_softc { #define MPR_FLAGS_DIAGRESET (1 << 4) #define MPR_FLAGS_ATTACH_DONE (1 << 5) #define MPR_FLAGS_GEN35_IOC (1 << 6) +#define MPR_FLAGS_REALLOCATED (1 << 7) u_int mpr_debug; u_int disable_msix; u_int disable_msi; + int msi_msgs; u_int atomic_desc_capable; int tm_cmds_active; int io_cmds_active; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Fri Aug 18 20:20:50 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD802DD4582; Fri, 18 Aug 2017 20:20:50 +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 mx1.freebsd.org (Postfix) with ESMTPS id AA22D73B5B; Fri, 18 Aug 2017 20:20:50 +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 v7IKKnbO011467; Fri, 18 Aug 2017 20:20:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7IKKnlA011466; Fri, 18 Aug 2017 20:20:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201708182020.v7IKKnlA011466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 18 Aug 2017 20:20: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: r322673 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 322673 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.23 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, 18 Aug 2017 20:20:51 -0000 Author: markj Date: Fri Aug 18 20:20:49 2017 New Revision: 322673 URL: https://svnweb.freebsd.org/changeset/base/322673 Log: MFC r322391: Micro-optimize kmem_unback(). Modified: stable/11/sys/vm/vm_kern.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_kern.c ============================================================================== --- stable/11/sys/vm/vm_kern.c Fri Aug 18 18:55:07 2017 (r322672) +++ stable/11/sys/vm/vm_kern.c Fri Aug 18 20:20:49 2017 (r322673) @@ -386,17 +386,19 @@ retry: void kmem_unback(vm_object_t object, vm_offset_t addr, vm_size_t size) { - vm_page_t m; - vm_offset_t i, offset; + vm_page_t m, next; + vm_offset_t end, offset; KASSERT(object == kmem_object || object == kernel_object, ("kmem_unback: only supports kernel objects.")); pmap_remove(kernel_pmap, addr, addr + size); offset = addr - VM_MIN_KERNEL_ADDRESS; + end = offset + size; VM_OBJECT_WLOCK(object); - for (i = 0; i < size; i += PAGE_SIZE) { - m = vm_page_lookup(object, atop(offset + i)); + for (m = vm_page_lookup(object, atop(offset)); offset < end; + offset += PAGE_SIZE, m = next) { + next = vm_page_next(m); vm_page_unwire(m, PQ_NONE); vm_page_free(m); } From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:25:08 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F98ADE6E1E; Sat, 19 Aug 2017 01:25:08 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 6E7CF8250F; Sat, 19 Aug 2017 01:25:08 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1P7IA038367; Sat, 19 Aug 2017 01:25:07 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1P7Mp038366; Sat, 19 Aug 2017 01:25:07 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190125.v7J1P7Mp038366@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:25:07 +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: r322686 - stable/11/lib/ncurses/ncurses X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/lib/ncurses/ncurses X-SVN-Commit-Revision: 322686 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.23 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, 19 Aug 2017 01:25:08 -0000 Author: ngie Date: Sat Aug 19 01:25:07 2017 New Revision: 322686 URL: https://svnweb.freebsd.org/changeset/base/322686 Log: MFC r322445: Hide `sccsid` under #if 0, per example in style(9) This fixes a -Wunused warning with gcc 6.3.0/7.0.0. Modified: stable/11/lib/ncurses/ncurses/termcap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/ncurses/ncurses/termcap.c ============================================================================== --- stable/11/lib/ncurses/ncurses/termcap.c Sat Aug 19 01:21:46 2017 (r322685) +++ stable/11/lib/ncurses/ncurses/termcap.c Sat Aug 19 01:25:07 2017 (r322686) @@ -59,9 +59,11 @@ #include __FBSDID("$FreeBSD$"); +#if 0 #ifndef lint static const char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ +#endif #include #include From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:21:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAC59DE6880; Sat, 19 Aug 2017 01:21:47 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 919708210A; Sat, 19 Aug 2017 01:21:47 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1Lk2K037459; Sat, 19 Aug 2017 01:21:46 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1Lklt037458; Sat, 19 Aug 2017 01:21:46 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190121.v7J1Lklt037458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:21: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: r322685 - stable/11/bin/chmod/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/bin/chmod/tests X-SVN-Commit-Revision: 322685 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.23 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, 19 Aug 2017 01:21:48 -0000 Author: ngie Date: Sat Aug 19 01:21:46 2017 New Revision: 322685 URL: https://svnweb.freebsd.org/changeset/base/322685 Log: MFC r321949,r321950,r322101: r321949: Add expected failures for ZFS - :f_flag fails on ZFS because UF_IMMUTABLE isn't supported [1]. - :v_flag fails on ZFS because the mode for foo is [always] updated unnecessarily. get_filesystem(..) (supporting function that was added to the test script) is based on equivalent logic in usr.bin/extattr/tests/extattr_test.sh . PR: 221189 [1], 221188 [2] r321950: Always use first parameter passed to get_filesystem(..) instead of discarding it and using `.` instead. MFC with: r321949 PR: 221189 [1], 221188 [2] r322101: Don't check result of chflags in f_flag_cleanup() This will prevent false positives from occurring if the test is run on ZFS since ZFS doesn't support fflags throbbing like UFS. PR: 221189 MFC with: r321949 Modified: stable/11/bin/chmod/tests/chmod_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/chmod/tests/chmod_test.sh ============================================================================== --- stable/11/bin/chmod/tests/chmod_test.sh Sat Aug 19 01:12:05 2017 (r322684) +++ stable/11/bin/chmod/tests/chmod_test.sh Sat Aug 19 01:21:46 2017 (r322685) @@ -25,6 +25,13 @@ # # $FreeBSD$ +get_filesystem() +{ + local mountpoint=$1 + + df -T $mountpoint | tail -n 1 | cut -wf 2 +} + atf_test_case RH_flag RH_flag_head() { @@ -94,6 +101,11 @@ f_flag_body() { atf_check truncate -s 0 foo bar atf_check chmod 0750 foo bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS doesn't support UF_IMMUTABLE; returns EPERM - bug 221189" + ;; + esac atf_check chflags uchg foo atf_check -e not-empty -s not-exit:0 chmod 0700 foo bar atf_check -o inline:'100750\n100700\n' stat -f '%p' foo bar @@ -103,7 +115,7 @@ f_flag_body() f_flag_cleanup() { - atf_check chflags 0 foo + chflags 0 foo || : } atf_test_case h_flag @@ -140,6 +152,11 @@ v_flag_body() atf_check truncate -s 0 foo bar atf_check chmod 0600 foo atf_check chmod 0750 bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS updates mode for foo unnecessarily - bug 221188" + ;; + esac atf_check -o 'inline:bar\n' chmod -v 0600 foo bar atf_check chmod -v 0600 foo bar for f in foo bar; do From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:26:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2460DE7041; Sat, 19 Aug 2017 01:26:27 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 8EDC982675; Sat, 19 Aug 2017 01:26:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1QQ0k038470; Sat, 19 Aug 2017 01:26:26 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1QQ43038469; Sat, 19 Aug 2017 01:26:26 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190126.v7J1QQ43038469@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:26: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: r322687 - stable/11/usr.bin/getconf X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.bin/getconf X-SVN-Commit-Revision: 322687 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.23 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, 19 Aug 2017 01:26:27 -0000 Author: ngie Date: Sat Aug 19 01:26:26 2017 New Revision: 322687 URL: https://svnweb.freebsd.org/changeset/base/322687 Log: MFC r321080: Expose the ILP32/LP64 programming environments based on __ILP32__/__LP64__ instead of by architecture. The list was incomplete (previous commits purged invalid architectures, like __alpha__, but failed to add new ones). It's best to base the symbol presence on whether or not the architecture is ILP32 / LP64 capable, per the compiler. This fixes the ILP32/LP64 program environments on some architectures like arm64, and by proxy fixes the tests on those architectures. Modified: stable/11/usr.bin/getconf/progenv.gperf Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/getconf/progenv.gperf ============================================================================== --- stable/11/usr.bin/getconf/progenv.gperf Sat Aug 19 01:25:07 2017 (r322686) +++ stable/11/usr.bin/getconf/progenv.gperf Sat Aug 19 01:26:26 2017 (r322687) @@ -30,11 +30,11 @@ static const struct map *in_word_set(const char *str); * be updated. (We cheat here and define the supported environments * statically.) */ -#if defined(__sparc64__) || defined(__amd64__) +#ifdef __LP64__ #define have_LP64_OFF64 NULL #endif -#if defined(__i386__) || defined(__powerpc__) +#ifdef __ILP32__ #define have_ILP32_OFFBIG NULL #endif From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:45:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8495BDE8288; Sat, 19 Aug 2017 01:45:03 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 52E9083527; Sat, 19 Aug 2017 01:45:03 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1j2Cu046404; Sat, 19 Aug 2017 01:45:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1j2xM046403; Sat, 19 Aug 2017 01:45:02 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190145.v7J1j2xM046403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:45:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322690 - stable/11/usr.sbin/makefs/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.sbin/makefs/tests X-SVN-Commit-Revision: 322690 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.23 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, 19 Aug 2017 01:45:03 -0000 Author: ngie Date: Sat Aug 19 01:45:02 2017 New Revision: 322690 URL: https://svnweb.freebsd.org/changeset/base/322690 Log: MFC r321947: Require strings(1) with :o_flag_preparer and :o_flag_publisher strings(1) might not be installed on the system, e.g., if MK_TOOLCHAIN == no Modified: stable/11/usr.sbin/makefs/tests/makefs_cd9660_tests.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/makefs/tests/makefs_cd9660_tests.sh ============================================================================== --- stable/11/usr.sbin/makefs/tests/makefs_cd9660_tests.sh Sat Aug 19 01:43:02 2017 (r322689) +++ stable/11/usr.sbin/makefs/tests/makefs_cd9660_tests.sh Sat Aug 19 01:45:02 2017 (r322690) @@ -264,6 +264,10 @@ o_flag_isolevel_3_cleanup() } atf_test_case o_flag_preparer +o_flag_preparer_head() +{ + atf_set "require.progs" "strings" +} o_flag_preparer_body() { create_test_dirs @@ -279,6 +283,10 @@ o_flag_preparer_body() } atf_test_case o_flag_publisher +o_flag_publisher_head() +{ + atf_set "require.progs" "strings" +} o_flag_publisher_body() { create_test_dirs From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:43:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2ACCDE8040; Sat, 19 Aug 2017 01:43:03 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id C1F9B83408; Sat, 19 Aug 2017 01:43:03 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1h2SS046247; Sat, 19 Aug 2017 01:43:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1h2Gm046246; Sat, 19 Aug 2017 01:43:02 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190143.v7J1h2Gm046246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:43:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322689 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 322689 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.23 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, 19 Aug 2017 01:43:04 -0000 Author: ngie Date: Sat Aug 19 01:43:02 2017 New Revision: 322689 URL: https://svnweb.freebsd.org/changeset/base/322689 Log: MFC r321081: Sort the tests alphabetically before adding them to the Kyuafiles This is being done to aid in debugging test runs, in the event the output shifts due to refactored Makefiles, added tests, etc. Modified: stable/11/share/mk/bsd.test.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/bsd.test.mk ============================================================================== --- stable/11/share/mk/bsd.test.mk Sat Aug 19 01:40:30 2017 (r322688) +++ stable/11/share/mk/bsd.test.mk Sat Aug 19 01:43:02 2017 (r322689) @@ -66,6 +66,10 @@ _TESTS= .include .include +# Sort the tests alphabetically, so the results are deterministically formed +# across runs. +_TESTS:= ${_TESTS:O} + # kyua automatically descends directories; only run make check on the # top-level directory .if !make(check) From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:40:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19074DE7D9B; Sat, 19 Aug 2017 01:40:32 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id D73D283088; Sat, 19 Aug 2017 01:40:31 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1eUmB042588; Sat, 19 Aug 2017 01:40:30 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1eUgQ042587; Sat, 19 Aug 2017 01:40:30 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190140.v7J1eUgQ042587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:40: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: r322688 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 322688 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.23 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, 19 Aug 2017 01:40:32 -0000 Author: ngie Date: Sat Aug 19 01:40:30 2017 New Revision: 322688 URL: https://svnweb.freebsd.org/changeset/base/322688 Log: MFC r321954: Delete comment above "__DEFAULT_DEPENDENT_OPTIONS" related to "meta mode options" src.conf(5) should document which knobs are which and the dependency between each; remove the comment so the variable can apply to non-"meta mode options". Modified: stable/11/share/mk/bsd.opts.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/bsd.opts.mk ============================================================================== --- stable/11/share/mk/bsd.opts.mk Sat Aug 19 01:26:26 2017 (r322687) +++ stable/11/share/mk/bsd.opts.mk Sat Aug 19 01:40:30 2017 (r322688) @@ -72,7 +72,6 @@ __DEFAULT_NO_OPTIONS = \ INSTALL_AS_USER \ STALE_STAGED -# meta mode related __DEFAULT_DEPENDENT_OPTIONS = \ STAGING_MAN/STAGING \ STAGING_PROG/STAGING \ From owner-svn-src-stable-11@freebsd.org Sat Aug 19 01:49:11 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D445DE87CD; Sat, 19 Aug 2017 01:49:11 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id F047B8385E; Sat, 19 Aug 2017 01:49:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7J1nA9S046602; Sat, 19 Aug 2017 01:49:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J1nAqN046601; Sat, 19 Aug 2017 01:49:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708190149.v7J1nAqN046601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 19 Aug 2017 01:49:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322691 - stable/11/tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/tests/sys/kern X-SVN-Commit-Revision: 322691 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.23 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, 19 Aug 2017 01:49:11 -0000 Author: ngie Date: Sat Aug 19 01:49:09 2017 New Revision: 322691 URL: https://svnweb.freebsd.org/changeset/base/322691 Log: MFC r321959: Annotate tests that require root privileges appropriately This unbreaks running the tests with unprivileged users. Modified: stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Sat Aug 19 01:45:02 2017 (r322690) +++ stable/11/tests/sys/kern/ptrace_test.c Sat Aug 19 01:49:09 2017 (r322691) @@ -1867,7 +1867,12 @@ mask_usr1_thread(void *arg) * Verify that the SIGKILL from PT_KILL takes priority over other signals * and prevents spurious stops due to those other signals. */ -ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_signal); +ATF_TC(ptrace__PT_KILL_competing_signal); +ATF_TC_HEAD(ptrace__PT_KILL_competing_signal, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(ptrace__PT_KILL_competing_signal, tc) { pid_t fpid, wpid; @@ -1961,7 +1966,12 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_signal, tc) * Verify that the SIGKILL from PT_KILL takes priority over other stop events * and prevents spurious stops caused by those events. */ -ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_stop); +ATF_TC(ptrace__PT_KILL_competing_stop); +ATF_TC_HEAD(ptrace__PT_KILL_competing_stop, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(ptrace__PT_KILL_competing_stop, tc) { pid_t fpid, wpid; @@ -2939,13 +2949,24 @@ terminate_with_pending_sigstop(bool sigstop_from_main_ * to the older thread (the second test). This behavior has changed in the * past, so make no assumption. */ -ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop1); +ATF_TC(ptrace__parent_terminate_with_pending_sigstop1); +ATF_TC_HEAD(ptrace__parent_terminate_with_pending_sigstop1, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop1, tc) { terminate_with_pending_sigstop(true); } -ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop2); + +ATF_TC(ptrace__parent_terminate_with_pending_sigstop2); +ATF_TC_HEAD(ptrace__parent_terminate_with_pending_sigstop2, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop2, tc) { From owner-svn-src-stable-11@freebsd.org Sat Aug 19 09:38:45 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F91EDDD8D2; Sat, 19 Aug 2017 09:38:45 +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 mx1.freebsd.org (Postfix) with ESMTPS id 5B2336D69E; Sat, 19 Aug 2017 09:38:45 +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 v7J9cilP037678; Sat, 19 Aug 2017 09:38:44 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7J9chGd037675; Sat, 19 Aug 2017 09:38:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708190938.v7J9chGd037675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 19 Aug 2017 09:38:43 +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: r322692 - in stable/11/lib/libc: stdlib string tests/string X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/lib/libc: stdlib string tests/string X-SVN-Commit-Revision: 322692 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.23 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, 19 Aug 2017 09:38:45 -0000 Author: kib Date: Sat Aug 19 09:38:43 2017 New Revision: 322692 URL: https://svnweb.freebsd.org/changeset/base/322692 Log: MFC r322427: Improve standard compliance for memset_s() and abort_handler_s(). Modified: stable/11/lib/libc/stdlib/set_constraint_handler_s.c stable/11/lib/libc/string/memset_s.c stable/11/lib/libc/tests/string/memset_s_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/stdlib/set_constraint_handler_s.c ============================================================================== --- stable/11/lib/libc/stdlib/set_constraint_handler_s.c Sat Aug 19 01:49:09 2017 (r322691) +++ stable/11/lib/libc/stdlib/set_constraint_handler_s.c Sat Aug 19 09:38:43 2017 (r322692) @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include "un-namespace.h" #include "libc_private.h" @@ -81,10 +83,14 @@ __throw_constraint_handler_s(const char * restrict msg } void -abort_handler_s(const char * restrict msg __unused, - void * restrict ptr __unused, errno_t error __unused) +abort_handler_s(const char * restrict msg, void * restrict ptr __unused, + errno_t error __unused) { + static const char ahs[] = "abort_handler_s : "; + (void) _write(STDERR_FILENO, ahs, sizeof(ahs) - 1); + (void) _write(STDERR_FILENO, msg, strlen(msg)); + (void) _write(STDERR_FILENO, "\n", 1); abort(); } Modified: stable/11/lib/libc/string/memset_s.c ============================================================================== --- stable/11/lib/libc/string/memset_s.c Sat Aug 19 01:49:09 2017 (r322691) +++ stable/11/lib/libc/string/memset_s.c Sat Aug 19 09:38:43 2017 (r322692) @@ -42,7 +42,7 @@ memset_s(void *s, rsize_t smax, int c, rsize_t n) volatile unsigned char *dst; ret = EINVAL; - lim = smax; + lim = n < smax ? n : smax; v = (unsigned char)c; dst = (unsigned char *)s; if (s == NULL) { @@ -53,11 +53,14 @@ memset_s(void *s, rsize_t smax, int c, rsize_t n) } else if (n > RSIZE_MAX) { __throw_constraint_handler_s("memset_s : n > RSIZE_MAX", ret); } else { - if (n < smax) - lim = n; while (lim > 0) dst[--lim] = v; - ret = 0; + if (n > smax) { + __throw_constraint_handler_s("memset_s : n > smax", + ret); + } else { + ret = 0; + } } return (ret); } Modified: stable/11/lib/libc/tests/string/memset_s_test.c ============================================================================== --- stable/11/lib/libc/tests/string/memset_s_test.c Sat Aug 19 01:49:09 2017 (r322691) +++ stable/11/lib/libc/tests/string/memset_s_test.c Sat Aug 19 09:38:43 2017 (r322692) @@ -109,13 +109,18 @@ ATF_TC_BODY(n_lt_smax, tc) assert(b[2] == 3); } -/* n > smax */ +/* n > smax, handler */ ATF_TC_WITHOUT_HEAD(n_gt_smax); ATF_TC_BODY(n_gt_smax, tc) { char b[3] = {1, 2, 3}; - assert(memset_s(&b[0], 1, 9, 3) == 0); + e = 0; + m = NULL; + set_constraint_handler_s(h); + assert(memset_s(&b[0], 1, 9, 3) != 0); + assert(e > 0); + assert(strcmp(m, "memset_s : n > smax") == 0); assert(b[0] == 9); assert(b[1] == 2); assert(b[2] == 3);