]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agobsdgrep: create additional tests for coverage on recent fixes
emaste [Wed, 5 Apr 2017 18:41:44 +0000 (18:41 +0000)]
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.

PR: 175314 202022 195763 180990 197555 197531 181263 209116
Submitted by: Kyle Evans <kevans91@ksu.edu>
Reviewed by: cem, ngie, emaste
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D10112

7 years agoFix memory leak in "gpart bootcode"
asomers [Wed, 5 Apr 2017 18:31:26 +0000 (18:31 +0000)]
Fix memory leak in "gpart bootcode"

Also, annotate that gpart_issue never returns

Reported by: Coverity
CID: 1007105
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

7 years agoStop building assym.o into the module.
bdrewery [Wed, 5 Apr 2017 17:56:21 +0000 (17:56 +0000)]
Stop building assym.o into the module.

DTrace includes assym.s, to build this we build assym.o, however
this is unneeded as assym.s only contains macros.

Remove the need to build this by removing it from OBJS, but keep assym.s
in the module dependencies via DPSRCS.

This fixes the build when there is no assembler, e.g. on arm64 without
the external binutils.

Submitted by: andrew
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10041

7 years agoSupport assym.s in DPSRCS to depend on it but not link it in.
bdrewery [Wed, 5 Apr 2017 17:56:17 +0000 (17:56 +0000)]
Support assym.s in DPSRCS to depend on it but not link it in.

Reported by: andrew
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

7 years agoMake nfs pageout coherent with the dirty state of the buffers.
kib [Wed, 5 Apr 2017 17:26:20 +0000 (17:26 +0000)]
Make nfs pageout coherent with the dirty state of the buffers.

Write out the dirty pages using VOP_WRITE() instead of directly
calling ncl_writerpc(). The state of the buffers now reflects the
write, fixing some hard to diagnose consistency and write order
issues.  The change also allowed to remove remapping of paged out
pages into kernel space and related allocation of the phys buffer.

Reviewed by: markj, rmacklem
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D10241

7 years agoHandle nfs IO_ASYNC write requests asynchronously.
kib [Wed, 5 Apr 2017 17:20:31 +0000 (17:20 +0000)]
Handle nfs IO_ASYNC write requests asynchronously.

Reviewed by: markj, rmacklem
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoFix clearing geom metadata if DIOCGSECTORSIZE fails
asomers [Wed, 5 Apr 2017 17:17:18 +0000 (17:17 +0000)]
Fix clearing geom metadata if DIOCGSECTORSIZE fails

An unhandled error case would result in passing SIZE_MAX to malloc.
While I'm here, remove an unnecessary NULL check before free

Reported by: Coverity
CID: 1017793
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

7 years agoHandle possible vnode reclamation after ncl_vinvalbuf() call.
kib [Wed, 5 Apr 2017 17:11:39 +0000 (17:11 +0000)]
Handle possible vnode reclamation after ncl_vinvalbuf() call.

ncl_vinvalbuf() might need to upgrade vnode lock, allowing the vnode
to be reclaimed by other thread.  Handle the situation, indicated by
the returned error zero and VI_DOOMED iflag set, converting it into
EBADF.  Handle all calls, even where the vnode is exclusively locked
right now.

Reviewed by: markj, rmacklem
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoAdd V_VMIO flag for vinvalbuf(9) to indicate that the flush request
kib [Wed, 5 Apr 2017 16:57:53 +0000 (16:57 +0000)]
Add V_VMIO flag for vinvalbuf(9) to indicate that the flush request
was issued during VM-initiated i/o (pageout), so that the function
does not try to flush or remove pages or wait for the vm object
paging-in-progress counter.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoRevert the optimization from r304436
rstone [Wed, 5 Apr 2017 16:57:13 +0000 (16:57 +0000)]
Revert the optimization from r304436

r304436 attempted to optimize the handling of incoming UDP packet by only
making an expensive call to in_broadcast() if the mbuf was marked as an
broadcast packet.  Unfortunately, this cannot work in the case of point-to-
point L2 protocols like PPP, which have no notion of "broadcast".  The
optimization has been disabled for several months now with no progress
towards fixing it, so it needs to go.

7 years agoExtract calculation of ioflags from the vm_pager_putpages flags into a
kib [Wed, 5 Apr 2017 16:56:04 +0000 (16:56 +0000)]
Extract calculation of ioflags from the vm_pager_putpages flags into a
helper.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoSome style fixes for vnode_pager_generic_putpages(), in the local
kib [Wed, 5 Apr 2017 16:45:00 +0000 (16:45 +0000)]
Some style fixes for vnode_pager_generic_putpages(), in the local
declaration block.

Reviewed by: markj (as part of the larger patch)
Tested by: pho (as part of the larger patch)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoUse int instead of boolean_t for flags argument type in
kib [Wed, 5 Apr 2017 16:30:41 +0000 (16:30 +0000)]
Use int instead of boolean_t for flags argument type in
vnode_pager_generic_putpages() prototype; change the argument name to
reflect that it is flags.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-Differential revision: https://reviews.freebsd.org/D10241

7 years agoRemove a duplicate fclose() that snuck into r316501
asomers [Wed, 5 Apr 2017 16:13:36 +0000 (16:13 +0000)]
Remove a duplicate fclose() that snuck into r316501

Reported by: Coverity
CID: 1373338
MFC after: 20 days
X-MFC-With: 316501
Sponsored by: Spectra Logic Corp

7 years agoUnify error handling when si_drv1 is NULL in the LinuxKPI.
hselasky [Wed, 5 Apr 2017 12:48:24 +0000 (12:48 +0000)]
Unify error handling when si_drv1 is NULL in the LinuxKPI.

Make sure the character device poll callback function does not return
an error code, but a POLLXXX value, in case of failure.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoImplement down_write_killable() in the LinuxKPI.
hselasky [Wed, 5 Apr 2017 12:10:02 +0000 (12:10 +0000)]
Implement down_write_killable() in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agohyperv/hn: Fixat RNDIS rxfilter after the successful RNDIS init.
sephe [Wed, 5 Apr 2017 08:25:22 +0000 (08:25 +0000)]
hyperv/hn: Fixat RNDIS rxfilter after the successful RNDIS init.

Under certain conditions on certain versions of Hyper-V, the RNDIS
rxfilter is _not_ zero on the hypervisor side after the successful
RNDIS initialization, which breaks the assumption of any following
code (well, it breaks the RNDIS API contract actually).  Clear the
RNDIS rxfilter explicitly, drain packets sneaking through, and drain
the interrupt taskqueues scheduled due to the stealth packets.

Reported by: dexuan@
MFC after: 3 days
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D10230

7 years agohyperv/storvsc: Fixup SRB status.
sephe [Wed, 5 Apr 2017 08:15:47 +0000 (08:15 +0000)]
hyperv/storvsc: Fixup SRB status.

This unbreaks GEN2 Hyper-V cd support.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
Reviewed by: dexuan@
MFC after: 3 days
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D10212

7 years agor316487 altered the defined values of rc_force from "yes" (for yes)
cy [Wed, 5 Apr 2017 05:23:09 +0000 (05:23 +0000)]
r316487 altered the defined values of rc_force from "yes" (for yes)
and NULL (for no) to "no" (for no) and no change to the definition
of yes. Two rc.d scripts, dhclient and bgfsck check rc_force for
yesi, using test -n, and no, using test -z. The redefinition of
yes and no by r316487 caused rc.d/dhclient, when invoked by devd
using a devd.conf rule, to assign DHCP assigned IP addresses for
interfaces with statically assigned interfaces, breaking boot.
Point of breakage was at line 25 of etc/rc.d/dhclient (r301068)
where $rc_force needs to be NULL.

MFC after: 3 weeks
X-MFC with: r316487

7 years agohyperv/kbd: Add support for synthetic keyboard.
sephe [Wed, 5 Apr 2017 05:01:23 +0000 (05:01 +0000)]
hyperv/kbd: Add support for synthetic keyboard.

Synthetic keyboard is the only supported keyboard on GEN2 Hyper-V.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D10196

7 years agoAlways pass the linker emulation via -m when linking modules and kernels.
jhb [Wed, 5 Apr 2017 03:05:04 +0000 (03:05 +0000)]
Always pass the linker emulation via -m when linking modules and kernels.

Previously the linker emulation was only passed when building binary
objects for firmware modules.  This change always passes the desired
output format for kernel modules and kernels rather than requiring the
toolchain's default output format to match the desired output format.
This in turn permits use of external toolchains whose default output
format does not match the desired output format.

Reviewed by: imp, emaste
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoSync SYSTEM_LD in Makefile.arm with kern.pre.mk.
jhb [Wed, 5 Apr 2017 03:00:52 +0000 (03:00 +0000)]
Sync SYSTEM_LD in Makefile.arm with kern.pre.mk.

- Add --no-warn-mismatch.
- Use same whitespace to make future updates simpler.

Reviewed by: imp (part of a larger change)
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoUse correct linker emulation name for armeb.
jhb [Wed, 5 Apr 2017 02:52:49 +0000 (02:52 +0000)]
Use correct linker emulation name for armeb.

MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoAdd an implementation of __ffssi2() derived from __ffsdi2().
jhb [Wed, 5 Apr 2017 02:40:53 +0000 (02:40 +0000)]
Add an implementation of __ffssi2() derived from __ffsdi2().

Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code.  This is true for at
least GCC 6.2 when compiling world for mips and mips64.

Reviewed by: jmallett, dim
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10086

7 years agoDon't leak a session and lock if a GMAC key has an invalid length.
jhb [Wed, 5 Apr 2017 01:46:41 +0000 (01:46 +0000)]
Don't leak a session and lock if a GMAC key has an invalid length.

Reviewed by: delphij (secteam)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10273

7 years agoufs: Export UFS_MAXNAMLEN to pathconf, statfs
cem [Wed, 5 Apr 2017 01:44:03 +0000 (01:44 +0000)]
ufs: Export UFS_MAXNAMLEN to pathconf, statfs

Rather than the global NAME_MAX constant.  This change is required to
support systems with a NAME_MAX/MAXNAMLEN that differs from UFS_MAXNAMLEN.

This was missed in r313475 due to the alternative spelling ("NAME_MAX") of
MAXNAMLEN.  This change is also similar in spirit to r313780.

Reported by: ngie@
Sponsored by: Dell EMC Isilon

7 years agoUse unique SPI.
ae [Tue, 4 Apr 2017 23:30:05 +0000 (23:30 +0000)]
Use unique SPI.

MFC after: 1 week

7 years agoIn the example section show that TCP-MD5 connection needs SA for both
ae [Tue, 4 Apr 2017 23:28:22 +0000 (23:28 +0000)]
In the example section show that TCP-MD5 connection needs SA for both
directions.

Submitted by: Mike Tancsa <mike at sentex net>
MFC after: 1 week

7 years agocxgbe(4): Program the global RSS key once instead of once per ifnet.
np [Tue, 4 Apr 2017 23:14:03 +0000 (23:14 +0000)]
cxgbe(4): Program the global RSS key once instead of once per ifnet.

MFC after: 3 days
Sponsored by: Chelsio Communications

7 years agoDon't assume NAME_MAX is 255
ngie [Tue, 4 Apr 2017 21:36:13 +0000 (21:36 +0000)]
Don't assume NAME_MAX is 255

Query the filesystem limit via getconf(3) instead

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoClean up more trailing whitespace in the licensing tort that
ngie [Tue, 4 Apr 2017 21:30:24 +0000 (21:30 +0000)]
Clean up more trailing whitespace in the licensing tort that
happened to be spaces, not tabs

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoClean up trailing whitespace
ngie [Tue, 4 Apr 2017 21:29:37 +0000 (21:29 +0000)]
Clean up trailing whitespace

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoAllow MSIX to be turned off by tuneable per interface, per driver.
sbruno [Tue, 4 Apr 2017 21:03:34 +0000 (21:03 +0000)]
Allow MSIX to be turned off by tuneable per interface, per driver.

Sponsored by: Limelight Networks

7 years agoFix file descriptor and memory leaks in pr(1)
asomers [Tue, 4 Apr 2017 20:03:57 +0000 (20:03 +0000)]
Fix file descriptor and memory leaks in pr(1)

Also, hook NetBSD's pr test into the build, and add three more test cases.

Reported by: Coverity, Valgrind
CID: 271650 271651 271652 271653 271654 271655 271656 271656
CID: 271657 271658 271659 1006939 1006940 1006941 1006942 1009098
Reviewed by: ngie
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9137

7 years agostrcpy => strlcpy, strcat => strlcat
asomers [Tue, 4 Apr 2017 19:46:23 +0000 (19:46 +0000)]
strcpy => strlcpy, strcat => strlcat

Reported by: Coverity
CID: 1006703 978863 1006745 1347163
Reviewed by: cem
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D10192

7 years agoCorrect a kernel stack leak in 32-bit compat when vfc_name is short.
brooks [Tue, 4 Apr 2017 17:32:08 +0000 (17:32 +0000)]
Correct a kernel stack leak in 32-bit compat when vfc_name is short.

Don't zero unused pointer members again.

Per discussion with secteam we are not issuing an advisory for this
issue as we have no current evidence it leaks exploitable information.

Reviewed by: rwatson, glebius, delphij
MFC after: 1 day
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10227

7 years agoCorrect the grammar mistakes introduced by me in the previous commit.
sevan [Tue, 4 Apr 2017 17:18:45 +0000 (17:18 +0000)]
Correct the grammar mistakes introduced by me in the previous commit.
The original sentence used the correct article to reference the MAC & radio.

Reported by: ian
MFC after: 5 days

7 years agobsdgrep(1): Fix errors with invalid expressions
cem [Tue, 4 Apr 2017 17:05:37 +0000 (17:05 +0000)]
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.

Submitted by: Kyle Evans <kevans91 at ksu.edu>
Reviewed by: me
Differential Revision: https://reviews.freebsd.org/D10113

7 years agono_desc_avail is tracked in iflib now making this redundant.
sbruno [Tue, 4 Apr 2017 16:54:46 +0000 (16:54 +0000)]
no_desc_avail is tracked in iflib now making this redundant.

Sponsored by: Limelight Networks

7 years agoAssert that the align parameter to uma_zcreate() is valid.
jhb [Tue, 4 Apr 2017 16:26:46 +0000 (16:26 +0000)]
Assert that the align parameter to uma_zcreate() is valid.

Reviewed by: kib
MFC after: 1 week
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10100

7 years agobsdgrep(1): Rip out "xmalloc" bits
cem [Tue, 4 Apr 2017 16:08:51 +0000 (16:08 +0000)]
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.)

Submitted by: Kyle Evans <kevans91 at ksu.edu>
Reviewed by: emaste, cem
Differential Revision: https://reviews.freebsd.org/D10269

7 years agobsdgrep: revert color changes from r316477
emaste [Tue, 4 Apr 2017 14:17:50 +0000 (14:17 +0000)]
bsdgrep: revert color changes from r316477

r316477 changed the color output to match exactly the in-tree GNU grep,
but introduces unnecessary escape sequences.

Submitted by: Kyle Evans <kevans91 at ksu.edu>
Reported by: ache
MFC after: 1 month
MFC with: r316477

7 years agoWhen we are doing SA lookup for TCP-MD5, check both source and
ae [Tue, 4 Apr 2017 13:41:50 +0000 (13:41 +0000)]
When we are doing SA lookup for TCP-MD5, check both source and
destination addresses. Previous code has used only destination address
for lookup. But for inbound packets the source address was used as SA
destination address. Thus only outbound SA were used for both directions.
Now we use addresses from a packet as is, thus SAs for both directions are
needed.

Reported by: Mike Tancsa
MFC after: 1 week

7 years agobsdgrep: Initialize vars to avoid a false positive GCC warning
emaste [Tue, 4 Apr 2017 13:34:19 +0000 (13:34 +0000)]
bsdgrep: Initialize vars to avoid a false positive GCC warning

Reported by: lwhsu
MFC after: 1 month
MFC with: r316477

7 years agoReplace an with a
sevan [Tue, 4 Apr 2017 13:18:56 +0000 (13:18 +0000)]
Replace an with a
Reword caveat on PCI 2.2 requirement.

PR: 218070
Submitted by: <bassej4 AT rpi edu>
Approved by: bcr
MFC after: 5 days
Differential Revision:  https://reviews.freebsd.org/D10262

7 years agoAllow command modifiers (fast, quiet etc.) to be stacked in any order.
des [Tue, 4 Apr 2017 11:43:31 +0000 (11:43 +0000)]
Allow command modifiers (fast, quiet etc.) to be stacked in any order.
Add a "debug" modifier that sets rc_debug.

MFC after: 3 weeks

7 years agoRemove dead code/ifdef.
trasz [Tue, 4 Apr 2017 08:17:03 +0000 (08:17 +0000)]
Remove dead code/ifdef.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

7 years agoAdd 25/40/100Gigabit Ethernet Driver version v1.3.0 for Cavium Inc's.
davidcs [Tue, 4 Apr 2017 06:16:59 +0000 (06:16 +0000)]
Add 25/40/100Gigabit Ethernet Driver version v1.3.0 for Cavium Inc's.
Qlogic 45000 Series Adapters

MFC after:2 weeks

7 years agobsdgrep(1): create rgrep link
cem [Tue, 4 Apr 2017 05:56:42 +0000 (05:56 +0000)]
bsdgrep(1): create rgrep link

Create a convenience rgrep link for bsdgrep(1) that observes 'grep -r'
behavior.

A follow-up to r316473.

Submitted by: Kyle Evans <kevans91 at ksu.edu>
Reviewed by: emaste (earlier version), cem
Differential Revision: https://reviews.freebsd.org/D10109

7 years agoremove machine/metadata.h from sys/opencrypto/crypto.c
allanjude [Tue, 4 Apr 2017 04:01:02 +0000 (04:01 +0000)]
remove machine/metadata.h from sys/opencrypto/crypto.c

The header was added by the recent keybuf feature (r316343)

MODINFOMD_KEYBUF originally resided here, but was moved to linker.h

This change fixes the build on risc-5 which doesn't have a metadata.h

Detected by Jenkins: https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/1167/console

Reported by: lwhsu

7 years agoDon't calltsec_receive_intr_locked() from the error interrupt handler.
jhibbits [Tue, 4 Apr 2017 02:55:55 +0000 (02:55 +0000)]
Don't calltsec_receive_intr_locked() from the error interrupt handler.

The tsec_error_intr_locked() is called with the global lock owned (e.g.
the transmit and the receive lock are both owned).  We must not call
tsec_receive_intr_locked() while owning the transmit lock.  The normal
receive interrupt takes care that frames are received, this is none of
the business of the error interrupt.

Submitted by: Sebastian Huber <sebastian.huber_AT_embedded-brains.de>

7 years agoDefragment the transmit mbuf chain only if necessary.
jhibbits [Tue, 4 Apr 2017 02:48:27 +0000 (02:48 +0000)]
Defragment the transmit mbuf chain only if necessary.

Use a method similar to the if_dwc driver.  Use a wmb() before the flags of the
first transmit buffer of a frame are written.

Group transmit/receive structure members for better cache efficiency.

Tested on P1020RDB.  TCP transmit throughput increases from 60MiB/s to
90MiB/s.

Submitted by: Sebastian Huber <sebastian.huber_AT_embedded-brains.de>

7 years agoFix mis-manual merge.
jhibbits [Tue, 4 Apr 2017 02:37:41 +0000 (02:37 +0000)]
Fix mis-manual merge.

Timeout is now effectively a boolean rather than a time-remaining.  This was
missed in r316478, but included in the original patch (mis-merged with a manual
merge).

7 years agoFix set-but-not-used warnings
jhibbits [Tue, 4 Apr 2017 00:46:48 +0000 (00:46 +0000)]
Fix set-but-not-used warnings

Submitted by: Sebastian Huber <sebastian_DOT_huber_AT_embedded-brains_DOT_de>

7 years agoUse a common tsec_mii_wait() function to busy wait for status changes.
jhibbits [Tue, 4 Apr 2017 00:43:09 +0000 (00:43 +0000)]
Use a common tsec_mii_wait() function to busy wait for status changes.

The status indicators are not set immediatly after a command.  Discard
the first value.

Unlock the PHY mutex after a timeout in tsec_init_locked().

Tested on the P1020RDB.

Submitted by: Sebastian Huber <sebastian_DOT_huber_AT_embedded-brains_DOT_de>

7 years agobsdgrep: fix matching behaviour
emaste [Mon, 3 Apr 2017 23:16:51 +0000 (23:16 +0000)]
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

PR: 195763, 180990, 197555, 197531, 181263, 209116
Submitted by: "Kyle Evans" <kevans91@ksu.edu>
Reviewed by: cem
MFC after: 1 month
Relnotes: Yes
Differential Revision: https://reviews.freebsd.org/D10104

7 years agoFix spelling mistake, BCM2835_PASWORD -> BCM2835_PASSWORD
gavin [Mon, 3 Apr 2017 22:36:45 +0000 (22:36 +0000)]
Fix spelling mistake, BCM2835_PASWORD -> BCM2835_PASSWORD

7 years agoRemove unsafe and non-functional DDB functions that I added long ago
sbruno [Mon, 3 Apr 2017 21:19:12 +0000 (21:19 +0000)]
Remove unsafe and non-functional DDB functions that I added long ago
for debugging.

7 years agoRemove rx_processing_limit sysctl and now orphaned function em_set_sysctl_value
sbruno [Mon, 3 Apr 2017 21:17:57 +0000 (21:17 +0000)]
Remove rx_processing_limit sysctl and now orphaned function em_set_sysctl_value

Sponsored by: Limelight Networks

7 years agobsdgrep: treat rgrep as grep -r
emaste [Mon, 3 Apr 2017 21:10:02 +0000 (21:10 +0000)]
bsdgrep: treat rgrep as grep -r

Submitted by:    Kyle Evans <kevans91@ksu.edu>

7 years agoFix typo.
trasz [Mon, 3 Apr 2017 20:35:17 +0000 (20:35 +0000)]
Fix typo.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

7 years agoAdd basic description of kernel source layout.
trasz [Mon, 3 Apr 2017 20:33:14 +0000 (20:33 +0000)]
Add basic description of kernel source layout.

MFC after: 2 weeks

7 years agoRemove excessive horizontal whitespace from hier(7) by correctly
trasz [Mon, 3 Apr 2017 20:28:34 +0000 (20:28 +0000)]
Remove excessive horizontal whitespace from hier(7) by correctly
using "-width". The http://mdocml.bsd.lv/mdoc/details/width.html
says: "Do not use macros in the argument specifying the width,
that's not portable. While GNU troff can handle it, mandoc cannot."
The same problem seems to exist in many other man pages.

Reviewed by: bapt, vangyzen
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10238

7 years agoWhilst mount_pcfs originated as a patch in 386BSD, NetBSD 0.8 actually
sevan [Mon, 3 Apr 2017 18:50:04 +0000 (18:50 +0000)]
Whilst mount_pcfs originated as a patch in 386BSD, NetBSD 0.8 actually
was the first release of an OS to ship with it.
Heads up by Ingo Schwarze.

Approved by: bcr (mentor)
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D10209

7 years agoFix a missing const in my previous commit which broke the build at
bde [Mon, 3 Apr 2017 15:11:28 +0000 (15:11 +0000)]
Fix a missing const in my previous commit which broke the build at
normal WARNS.

Reported by: lwhsu

7 years agoRemove "IPFW static rules" rmlock.
ae [Mon, 3 Apr 2017 13:35:04 +0000 (13:35 +0000)]
Remove "IPFW static rules" rmlock.

Make PFIL's lock global and use it for this purpose.
This reduces the number of locks needed to acquire for each packet.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC
No objection from: #network
Differential Revision: https://reviews.freebsd.org/D10154

7 years agoFix expandsz 16.0E vals and vdev_min_asize of RAIDZ children
smh [Mon, 3 Apr 2017 13:11:28 +0000 (13:11 +0000)]
Fix expandsz 16.0E vals and vdev_min_asize of RAIDZ children

When a member of a RAIDZ has been replaced with a device smaller than the
original, then the top level vdev can report its expand size as 16.0E.

The reduced child asize causes the RAIDZ to have a vdev_asize lower than its
vdev_max_asize which then results in an underflow during the calculation of
the parents expand size.

Fix this by updating the vdev_asize if it shrinks, which is already
protected by a check against vdev_min_asize so should always be safe.

Also for RAIDZ vdevs, ensure that the sum of their child vdev_min_asize is
always greater than the parents vdev_min_size.

Fixes: https://www.illumos.org/issues/7885
MFC after: 2 weeks
Sponsored by: Multiplay

7 years agoShow high (blinking foreground/bright background) background colors. Format
bde [Mon, 3 Apr 2017 13:06:28 +0000 (13:06 +0000)]
Show high (blinking foreground/bright background) background colors.  Format
output and source better for this.  Format output for 40 columns if there
are less than 80 columns.

7 years agoMFV r316454,316455:
mm [Mon, 3 Apr 2017 12:26:20 +0000 (12:26 +0000)]
MFV r316454,316455:

Vendor changes (FreeBSD-related):
  Report which extended attributes could not be restored
  Update archive_read_disk.3 and archive_write_disk.3 manual pages
  Plug memory leaks in xattr tests.

MFC after: 1 week

7 years agoRemove the global variable 'info' and fix associated bugs and style bugs.
bde [Mon, 3 Apr 2017 10:47:01 +0000 (10:47 +0000)]
Remove the global variable 'info' and fix associated bugs and style bugs.

This variable was used 4 times in 1 function and all uses were wrong.
The 4 uses were in he test_frame() (show) function, to try to restore
4 colors, 2 unnecessarily and these 2 now broken.  This was wrong
because it is the previous colors that must be restored, but the global
holds the original colors.  Excessive setting of colors at the end
restored the previous colors correctly in most cases, but I removed
this a couple of revisions ago.

Originally, this variable had 1 correct use, to test for being on a vty
as a side effect of initializing it.  This is now down in init(), and
init() also leaves a better-named global with the same contents.

Fix this by reading the current console info into a local variable in
test_frame(), as is done for several other functions.  Fix style bugs
in this reading for all callers:
- extra blank lines
- all error messages different.  The first one now in init() is not as
  specific as the old one, but it is after a different specific one for
  another ioctl and is unlikely to be reached when the first ioctl
  succeeds.  Ones after the first are to repeat the ioctl, so are even
  more likely to be reached.  The correctness of full removal of the
  old global depends on the error handling for failure to initialize
  it being unreachable.
- err() instead of warn() for failure in load_font().  This is almost
  unreachable, and it makes no sense to continue after undoing previous
  changes with revert().
- unreachable return after err() for failure in dump_screen().

Undo large renaming of local variables from the good name 'info' to the
bad name _info, which was done to protect the buggy global's bad name
from -Wshadow warnings.

7 years agoBreak audit_bsm_klib.c into two files: one (audit_bsm_klib.c)
rwatson [Mon, 3 Apr 2017 10:15:58 +0000 (10:15 +0000)]
Break audit_bsm_klib.c into two files: one (audit_bsm_klib.c)
retaining various utility functions used during BSM generation,
and a second (audit_bsm_db.c) that contains the various in-kernel
databases supporting various audit activities (the class and
event-name tables).

(No functional change is intended.)

Obtained from: TrustedBSD Project
MFC after: 3 weeks
Sponsored by: DARPA, AFRL

7 years agoSave errno across revert().
bde [Mon, 3 Apr 2017 09:21:00 +0000 (09:21 +0000)]
Save errno across revert().

Change 25 uses of errc() to err().  2 of these were correct.  23 used
errno for the arg so were just a verbose spelling of err().  5 of these
were just style bugs, and 18 depended on revert() saving errno.

1 warn() also depended on revert() saving errno.

Remove 2 warnx()'s that duplicate the message from a later errx().
These used to be before returns, and should have reported errno in
some cases.  errno is also not reported for for openguess() failures.

Only "restore" the video mode in revert() if the mode was just set
(necessarily partially).  Setting the mode to its current setting
doesn't "restore" it, but resets it, with the least harmful change
being to clear the screen.  revert() is called even for some harmless
syntax errors and usually did nothing except reset the mode.  Now it
usually does nothing.  The only things that it tries to restore apart
from the mode are the active vty number, the screen map, 2 colors that
only need to be restored (only after a mode change) to fix kernel bugs,
and 3 colors that can't be restored due to kernel bugs.  (This is
mostly for sc, since vt doesn't support mode changes.)

revert() is not called for syntax and setting errors after [mode], so
the mode reset is only done for failures to set raster mode after
setting graphics mode.  normal colors can only be set after [mode],
and that is why reverting them should be unnecessary.

7 years agoFix some parsing and error handling bugs.
bde [Mon, 3 Apr 2017 06:52:02 +0000 (06:52 +0000)]
Fix some parsing and error handling bugs.

r146736 added an undocumented syntax and many bugs handling it.  The
documented syntax is "... [mode] [fg [bg]] [show]", where it is critical
for reducing ambiguity and keeping things simple that the mode is
parsed first.  r146736 added buggy support for "... [mode] [fg [bg]]
[show] [mode] [fg [bg]]".  One error was that after for failing to set
a partially-supported graphics mode, argv[optind] remains pointing to
the mode so doesn't match the first [fg [bg]], so the setting is
attempted again, with slightly worse error handling.

Fix this by removing it (support for the trailing '[mode] [fg [bg]]')
and cleaning up.  The cleanups are mostly to remove convolutions and
bugs that didn't work to handle the ambiguous syntax '[fg [bg]] [fg [bg]]'
when [mode] and [show] are not present.  Globals were set to allow
repeating the color settings at the end.  The functions that set the
colors earlier were misnamed from set* to get*.  All that they "got" is
is settings from argv.  They applied the settings to the kernel and
the globals.

Fix restoration of colors in revert() by restoring 2 after the mode
change.  Colors should not need to be restored, but a bug in scteken
clobbers them on any mode change, including ones for restoration.  Don't
move the restoration of the other 3.  Teken doesn't clobber them on
mode changes because it doesn't support them at all (sc still supports
the border color, but only using a non-teken ioctl).

Add restoration of colors after a successful mode change to work around
the scteken bug there too.  The bug was previously masked by the general
setting of colors at the end.

Fix a longstanding parsing/error handling bug by exiting almost immediately
after matching the [mode] arg but failing to set the mode.  Just revert
if necessary.  Don't return to continue parsing but do it wrong.  This
bug caused spamming the output with a usage() message and exiting with
status 1 whenever [mode] is not present bug [fg [bg]] or [show].  The
exit code 1 was actualy an ambiguous internal code for failure to match
[mode] or failure to set [mode].  This 1 was obfuscated by spelling it
EXIT_FAILURE, but actual exit codes spell EXIT_FAILURE as 1.  Remove
another global which could have been used to disambiguate this but was
only used to micro-optimize the (unnecessary except for other bugs)
setting of colors at the end.

7 years agoGC some unused declarations.
ae [Mon, 3 Apr 2017 04:44:56 +0000 (04:44 +0000)]
GC some unused declarations.

MFC after: 1 week

7 years agoSmall cleanup to make i386/loader match efi/loader boot environment code
allanjude [Mon, 3 Apr 2017 04:29:57 +0000 (04:29 +0000)]
Small cleanup to make i386/loader match efi/loader boot environment code

7 years agoRestore EFI boot environment functionality broken in r313333
allanjude [Mon, 3 Apr 2017 04:28:53 +0000 (04:28 +0000)]
Restore EFI boot environment functionality broken in r313333

Reported by: Graham Perrin, JT Pennington <q5sys@bsdnow.tv>
Sponsored by: ScaleEngine Inc.

7 years agoAdd ipfw_pmod kernel module.
ae [Mon, 3 Apr 2017 03:07:48 +0000 (03:07 +0000)]
Add ipfw_pmod kernel module.

The module is designed for modification of a packets of any protocols.
For now it implements only TCP MSS modification. It adds the external
action handler for "tcp-setmss" action.

A rule with tcp-setmss action does additional check for protocol and
TCP flags. If SYN flag is present, it parses TCP options and modifies
MSS option if its value is greater than configured value in the rule.
Then it adjustes TCP checksum if needed. After handling the search
continues with the next rule.

Obtained from: Yandex LLC
MFC after: 2 weeks
Relnotes: yes
Sponsored by: Yandex LLC
No objection from: #network
Differential Revision: https://reviews.freebsd.org/D10150

7 years agoAdd O_EXTERNAL_DATA opcode support.
ae [Mon, 3 Apr 2017 02:44:40 +0000 (02:44 +0000)]
Add O_EXTERNAL_DATA opcode support.

This opcode can be used to attach some data to external action opcode.
And unlike to O_EXTERNAL_INSTANCE opcode, this opcode does not require
creating of named instance to pass configuration arguments to external
action handler. The data is coming just next to O_EXTERNAL_ACTION opcode.

The userlevel part currenly supports formatting for opcode with ipfw_insn
size, by default it expects u16 numeric value in the arg1.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC

7 years agoAdd the log formatting for an external action opcode.
ae [Mon, 3 Apr 2017 02:26:30 +0000 (02:26 +0000)]
Add the log formatting for an external action opcode.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC

7 years agoFix indentation in dd(1)
vangyzen [Sun, 2 Apr 2017 21:30:05 +0000 (21:30 +0000)]
Fix indentation in dd(1)

Quoting http://mdocml.bsd.lv/mdoc/details/width.html

Do not use macros in the argument specifying the width,
since that's not portable.  While GNU troff can handle it,
mandoc cannot.

MFC after: 3 days
Sponsored by: Dell EMC

7 years ago[net80211] refactor the A-MPDU RX window code
adrian [Sun, 2 Apr 2017 20:59:12 +0000 (20:59 +0000)]
[net80211] refactor the A-MPDU RX window code

The RX window update code is effectively the same in both locations.

Reviewed by: avos
Differential Revision: https://reviews.freebsd.org/D10208

7 years agoFix variable for sizeof() in previous commit.
mav [Sun, 2 Apr 2017 20:57:59 +0000 (20:57 +0000)]
Fix variable for sizeof() in previous commit.

MFC after: 2 weeks

7 years agoAdd Log directory and SATA NCQ Send and Receive Log.
mav [Sun, 2 Apr 2017 20:39:51 +0000 (20:39 +0000)]
Add Log directory and SATA NCQ Send and Receive Log.

Those are used at least by Linux guests to detect queued TRIM support.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

7 years agoUse the kern_clock_nanosleep() to implement Linux clock_nanosleep() with
dchagin [Sun, 2 Apr 2017 18:16:00 +0000 (18:16 +0000)]
Use the kern_clock_nanosleep() to implement Linux clock_nanosleep() with
the proper handling of the TIMER_ABSTIME flag.

XMFC after: r315526

MFC after: 1 month

7 years agoFix sparc64 build broken by r316343 and r316076
allanjude [Sun, 2 Apr 2017 17:25:37 +0000 (17:25 +0000)]
Fix sparc64 build broken by r316343 and r316076

Reported by: markj
Sponsored by: ScaleEngine Inc.

7 years agoRemove checks that background (bg) colors are not bright and buggy
bde [Sun, 2 Apr 2017 16:39:39 +0000 (16:39 +0000)]
Remove checks that background (bg) colors are not bright and buggy
attempts to keep them that way.  The bg brightness bit is interpreted
as blinking in some modes, but it would barely be useful to disallow
setting it when it would give blinking in code which knew when that
is.  The old code mostly knew this wrong, and added handling errors.
It is in fact impossible to know, since future mode switches may
change the meaning of the bit many times on the screen and in history.

Old versions of vidcontrol disallowed bg color numbers >= 8 in all
cases.  This is very VGA/syscons-centric.  Syscons uses the VGA defaults
of blinking fg instead of bright bg in text mode and bright bg in
graphics mode.  On VGA, this is very easy to toggle at any time, and
vt blows away the VGA text mode default at boot time.

r146736 changed this to try to allow bg color numbers in graphics mode
only.  This is even more VGA/syscons-centric, and there are many bugs
in this, and many nearby bugs in the parser.  These are increased or
decreased by differences and bugs in vt and teken.

Perhaps the most obvious bug was that almost any vidcontrol command
which changes any color or the mode causes an error if the initial fg
color is bright.  E.g., in syscons text mode, after "vidcontrol
lightwhite" to make the fg bright, another "vidcontrol lightwhite" is
rejected and buggy fixup code changes the fg to white.  This is because
the bright fg color creates a bright bg color for the phantom reverse
video attribute, so was rejected.  (The reverse video attribute is
phantom because teken ignores the user's setting of it and simply
reverses the fg attributes to create the bg attributes.  Sometimes
some layer masks off the brightness/blinking bit, but not here.)

Perhaps the next most obvious one was that "vidcontrol lightgreen
lightblue" was misparsed as 2 settings of the fg instead of 1 setting
of the fg and 1 invalid setting of the bg.  This is because the
parser supports an undocumented syntax with many parsing bugs (an
ambiguity gives this one).

I recently fix bugs in teken that broke setting of bright fg's and
bg's in the normal way.  This gave more settings of then, so the old
bugs showed up more often.

7 years agosh: Remove an XXX comment: it is normal for builtins to use argptr.
jilles [Sun, 2 Apr 2017 15:53:11 +0000 (15:53 +0000)]
sh: Remove an XXX comment: it is normal for builtins to use argptr.

7 years agosh: Remove global state from collate_range_cmp().
jilles [Sun, 2 Apr 2017 14:02:10 +0000 (14:02 +0000)]
sh: Remove global state from collate_range_cmp().

The global state is not used across invocations of collate_range_cmp().

7 years agosh: Don't scan word twice in ${param=word}.
jilles [Sun, 2 Apr 2017 13:43:45 +0000 (13:43 +0000)]
sh: Don't scan word twice in ${param=word}.

7 years agosh: Don't scan word twice in ${param#%##%%word}.
jilles [Sun, 2 Apr 2017 13:29:27 +0000 (13:29 +0000)]
sh: Don't scan word twice in ${param#%##%%word}.

If word is expanded, use the found end instead of iterating over the data
again.

7 years agoiwn: use correct mask for queue ids (0xf -> 0x1f).
avos [Sun, 2 Apr 2017 13:24:58 +0000 (13:24 +0000)]
iwn: use correct mask for queue ids (0xf -> 0x1f).

7 years agosh: Don't scan word twice in ${param+-word}.
jilles [Sun, 2 Apr 2017 12:37:43 +0000 (12:37 +0000)]
sh: Don't scan word twice in ${param+-word}.

There is no longer a case where argbackq has already been advanced but the
string pointer needs to be advanced.

7 years agoAdd IDs for several missing Intel SMBus controllers.
gavin [Sun, 2 Apr 2017 11:36:25 +0000 (11:36 +0000)]
Add IDs for several missing Intel SMBus controllers.

Obtained from: Data sheets, Linux defines, local hardware
MFH: 2 weeks

7 years agoAdd IDs for Intel Cougar Point USB 2.0 controller.
mav [Sun, 2 Apr 2017 11:32:05 +0000 (11:32 +0000)]
Add IDs for Intel Cougar Point USB 2.0 controller.

MFC after: 1 week

7 years agoRemove the unportable -msse4 here too after fixing crc32_sse42.c to not
bde [Sun, 2 Apr 2017 09:24:58 +0000 (09:24 +0000)]
Remove the unportable -msse4 here too after fixing crc32_sse42.c to not
depend on it.  This should have been part of r315983.

7 years agoReset the DAC to 6-bit mode before calling the BIOS to set the screen
bde [Sun, 2 Apr 2017 08:39:32 +0000 (08:39 +0000)]
Reset the DAC to 6-bit mode before calling the BIOS to set the screen
mode.  This works around bugs in at least 2 Intel BIOSes for our
subsequent setting of the DAC back to 8-bit mode.  The bug caused dark
(mostly 1/4-intensity) colors for all except the first setting to a
VESA graphics mode (including for settings to the current mode).

Remove restoration (with less bits) of the palette in vesa_unload()
after resetting the DAC to 6-bit mode.  Depend on the BIOS to keep
the palette consistent with the DAC for the simpler reset case like
we do everywhere else in places that are actually important.

Setting the video mode should reset everything to defaults, although
we usually don't want that.  Even the buggy BIOSes set the DAC to the
default 6-bit mode, and set the palette to a default that matches the
DAC.  We don't undo the reset for most things, but we do undo it for
the DAC (more precisely, we change to an 8-bit DAC if possible, and
this is the only way that we set to an 8-bit DAC; it is accidental
that if the DAC was in 8-bit mode from a previous mode switch then
setting it to 8-bit mode is an undo).  The buggy BIOSes are confused
by our setting of the DAC to 8-bit mode in the "undo" case.  They
should multiply palette entries by 4 to match, but they actually leave
all palette entries except #2 (green) and #248-255 (unused) untouched.
Green is mysteriously scaled from 0x2a to 0x6a, and #248-255 are scaled
correctly.

Our support for the 8-bit DAC had almost no effect except to enable
bugs.  Syscons barely supports 16 colors, so it doesn't benefit much
from having a palette with 16 million colors instead of only 256K.
Applications can manage the palette using FBIO_{GET,SET}PALETTE, but
the palette managed by this is only used in the less interesting modes
(text and non-truecolor graphics modes up to 8 bits wide), and the
kernel loses the changes on any mode switch (including to another vt
in a different mode).

7 years agoRemove excess tv_nsec test as this is done by linux_to_native_timespec().
dchagin [Sun, 2 Apr 2017 07:49:05 +0000 (07:49 +0000)]
Remove excess tv_nsec test as this is done by linux_to_native_timespec().

MFC after: 1 week

7 years agoThe value in the tv_nsec field should be in the range 0 to 999999999.
dchagin [Sun, 2 Apr 2017 07:47:28 +0000 (07:47 +0000)]
The value in the tv_nsec field should be in the range 0 to 999999999.

Pointed out by: bde@

MFC after: 1 week

7 years agoAs noted by bde@ negative tv_sec values are not checked for overflow,
dchagin [Sun, 2 Apr 2017 07:46:13 +0000 (07:46 +0000)]
As noted by bde@ negative tv_sec values are not checked for overflow,
so overflow can still occur. Fix that. Also remove the extra check for
tv_sec size as under COMPAT_LINUX32 it is always true.

Pointed out by: bde@

MFC after: 1 week

7 years agoAdd Freescale eSPI driver found on QorIQ SoCs
jhibbits [Sun, 2 Apr 2017 01:21:35 +0000 (01:21 +0000)]
Add Freescale eSPI driver found on QorIQ SoCs