]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoAdd and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
marius [Tue, 7 Mar 2017 22:42:44 +0000 (22:42 +0000)]
Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
as kernel drivers and their dependency onto mmc(4); this allows for
incrementing the mmc(4) module version but also for entire omission
of these bridge declarations for mmccam(4) in a single place, i. e.
in dev/mmc/bridge.h.

7 years agopwait: Add a -t flag to specify a timeout before exiting, and tests.
bdrewery [Tue, 7 Mar 2017 22:16:55 +0000 (22:16 +0000)]
pwait: Add a -t flag to specify a timeout before exiting, and tests.

The exit status will be 124, as the timeout(1) utility uses.

Reviewed by: jilles
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D9697

7 years agoFix booting with >4GB RAM on PowerMac G5 hardware
jhibbits [Tue, 7 Mar 2017 22:11:57 +0000 (22:11 +0000)]
Fix booting with >4GB RAM on PowerMac G5 hardware

===
From Nathan Whitehorn:

Open Firmware runs in virtual mode on the Powermac G5. This runs inside the
kernel page table, which preserves all address translations made by OF before
the kernel starts; as a result, the kernel address space is a strict superset of
OF's.

Where this explodes is if OF uses an unmapped SLB entry. The SLB fault handler
runs in real mode and refers to the PCPU pointer in SPRG0, which blows up the
kernel. Having a value of SPRG0 that works for the kernel is less fatal than
preserving OF's value in this case.

===

The result of this is seemingly random panics from NULL dereferences, or hangs
immediately upon boot.  By not restoring SPRG0 for Open Firmware entry the
kernel PCPU pointer is preserved and SLB faults are successful, resulting in a
stable kernel.

PR: 205458
Reported by: several (over bugzilla, lists, IRC)
Reviewed by: andreast
Tested by: many (various forms)
MFC after: 2 weeks

7 years agoMake multi-namespace nvme drives more robust.
imp [Tue, 7 Mar 2017 21:47:54 +0000 (21:47 +0000)]
Make multi-namespace nvme drives more robust.

Fix assumptions about name spaces in NVME driver. First, it assumes
cdata.nn is the number of configured devices. However, it is the
number of supported name spaces. Second, it assumes that there will
never be more than 16 name spaces supported, but a certain drive I'm
testing reports 1024. It assumes that name spaces are a tightly packed
namespace, but the standard seems to indicate otherwise. Finally, it
assumes that an error would be generated when quearying an
unconfigured namespace. Instead, it succeeds but the identify data is
all zeros.

Fix these by limiting the number of name spaces we probe to 16. Remove
aborting when we find one in error. When the size of the name space is
zero, ignore it.

This is admittedly a bandaide. The long term fix will be to
participate in the enumeration and name space change protocols
definfed in the NVNe standard.

Sponsored by: Netflix

7 years agoufsread: Use appropriate UFS_MAXNAMLEN constant
cem [Tue, 7 Mar 2017 21:40:01 +0000 (21:40 +0000)]
ufsread: Use appropriate UFS_MAXNAMLEN constant

A follow-up to r313475.

Submitted by: Gaurav Gangalwar <Gaurav.Gangalwar at emc.com>
Sponsored by: Dell EMC Isilon

7 years agoAdd support for constant pointer constructs to READ_ONCE() in the
hselasky [Tue, 7 Mar 2017 20:24:34 +0000 (20:24 +0000)]
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.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agolpr(1): small bounds check with reallocarray(3).
pfg [Tue, 7 Mar 2017 19:30:22 +0000 (19:30 +0000)]
lpr(1): small bounds check with reallocarray(3).

While here plug a memory leak upon error and postpose a multiplication
until after reallocation has succeded.

Hinted partially by: OpenBSD
Reviewed by: gad
MFC after: 2 weeks

7 years agom_mbuftouio() doesn't modify the mbuf.
glebius [Tue, 7 Mar 2017 19:00:50 +0000 (19:00 +0000)]
m_mbuftouio() doesn't modify the mbuf.

7 years agoCatch up with Clang 4.0.0.
jkim [Tue, 7 Mar 2017 19:00:27 +0000 (19:00 +0000)]
Catch up with Clang 4.0.0.

7 years agoAdd bsd.man.mk references for MAN under bsd.lib.mk and bsd.prog.mk
ngie [Tue, 7 Mar 2017 17:53:53 +0000 (17:53 +0000)]
Add bsd.man.mk references for MAN under bsd.lib.mk and bsd.prog.mk

The latter set of manpages directly consume bsd.man.mk, so the bsd.man.mk
behavior should be the source of truth for underlying behavior, whereas
the other manpage fragment descriptions should document how they tweak
the variable behavior, if at all (bsd.prog.mk does tweak the default
value, as noted in its description)

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix LINKS example in bsd.prog.mk
ngie [Tue, 7 Mar 2017 17:42:23 +0000 (17:42 +0000)]
Fix LINKS example in bsd.prog.mk

LINKS appends DESTDIR -- don't suggest double-append in example.

MFC after: 1 week
Reported by: rgrimes (D9918)
Sponsored by: Dell EMC Isilon

7 years agoAdd mechanism to unload CAM periph drivers.
mav [Tue, 7 Mar 2017 17:41:08 +0000 (17:41 +0000)]
Add mechanism to unload CAM periph drivers.

For now it allows to unload CTL kernel module if there are no target-capable
SIMs in CAM.  As next step full teardown of CAM targets can be implemented.

7 years agoAlphabetically sort variables
ngie [Tue, 7 Mar 2017 17:38:52 +0000 (17:38 +0000)]
Alphabetically sort variables

The only content change is minor rewording around CLEANDIRS/CLEANFILES to
accomodate sorting order.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoLinux semop system call return EINVAL in case when the invalid nsops
dchagin [Tue, 7 Mar 2017 17:12:22 +0000 (17:12 +0000)]
Linux semop system call return EINVAL in case when the invalid nsops
or semid values specified.

MFC after: 1 month

7 years agoLinux kernel does not export to the user space ipc_perm.mode values
dchagin [Tue, 7 Mar 2017 17:09:12 +0000 (17:09 +0000)]
Linux kernel does not export to the user space ipc_perm.mode values
other than S_IRWXUGO (0777).

MFC after: 1 month

7 years agoReduce code duplication between MD Linux code by moving SYSV IPC 64-bit
dchagin [Tue, 7 Mar 2017 17:07:16 +0000 (17:07 +0000)]
Reduce code duplication between MD Linux code by moving SYSV IPC 64-bit
related struct definitions out into the MI path.

Invert the native ipc structs to the Linux ipc structs convesion logic.
Since 64-bit variant of ipc structs has more precision convert native ipc
structs to the 64-bit Linux ipc structs and then truncate 64-bit values
into the non 64-bit if needed. Unlike Linux, return EOVERFLOW if the
values do not fit.

Fix SYSV IPC for 64-bit Linuxulator which never sets IPC_64 bit.

MFC after: 1 month

7 years agoBump __FreeBSD_version for removal of pcap-int.h.
delphij [Tue, 7 Mar 2017 16:09:37 +0000 (16:09 +0000)]
Bump __FreeBSD_version for removal of pcap-int.h.

PR: 217221

7 years agofirewire/sbp: try to improve locking, plus a few style nits
avg [Tue, 7 Mar 2017 16:07:52 +0000 (16:07 +0000)]
firewire/sbp: try to improve locking, plus a few style nits

This change tries to fix the most obvious locking problems.

sbp_cam_scan_lun() is never called with the sbp lock held, so the lock
needs to be acquired internally (if it's needed at all).
Without this change a kernel with INVARIANTS panics when a firewire disk
is connected:
  panic: mutex sbp not owned at /usr/src/sys/dev/firewire/sbp.c:967
  KDB: stack backtrace:
  db_trace_self_wrapper() at 0xffffffff80420bbb = db_trace_self_wrapper+0x2b/frame 0xfffffe0504df0930
  kdb_backtrace() at 0xffffffff80670359 = kdb_backtrace+0x39/frame 0xfffffe0504df09e0
  vpanic() at 0xffffffff8063986c = vpanic+0x14c/frame 0xfffffe0504df0a20
  panic() at 0xffffffff806395b3 = panic+0x43/frame 0xfffffe0504df0a80
  __mtx_assert() at 0xffffffff8061c40d = __mtx_assert+0xed/frame 0xfffffe0504df0ac0
  sbp_cam_scan_lun() at 0xffffffff80474667 = sbp_cam_scan_lun+0x37/frame 0xfffffe0504df0af0
  xpt_done_process() at 0xffffffff802aacfa = xpt_done_process+0x2da/frame 0xfffffe0504df0b30
  xpt_done_td() at 0xffffffff802ac2e5 = xpt_done_td+0xd5/frame 0xfffffe0504df0b80
  fork_exit() at 0xffffffff805ff72f = fork_exit+0xdf/frame 0xfffffe0504df0bf0
  fork_trampoline() at 0xffffffff8082483e = fork_trampoline+0xe/frame
  0xfffffe0504df0bf0
  --- trap 0, rip = 0, rsp = 0, rbp = 0 ---

Also, I tried to reduce the scope of the sbp lock to avoid holding it
while doing bus_dma allocations.

The code badly needs some re-engineering.  SBP really should implement
a CAM transport, so that it avoids control flow inversion when re-scanning
the bus.  Also, the sbp lock seems to be too coarse.

Additionally, the commit includes some changes not related to locking.

- sbp_cam_scan_lun: restore CAM_DEV_QFREEZE before re-queueing the ccb
  because xpt_setup_ccb resets ccb_h.flags
- sbp_post_busreset: call xpt_release_simq only if it's actually frozen
- don't place private SIMQ_FREEZED flag (sic, "freezed") into sim->flags,
  use sbp->flags for that
- some style fixes and control flow enhancements

Reviewed by: sbruno
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D9898

7 years agoStop installing pcap-int.h, which is the internal interface for libpcap.
delphij [Tue, 7 Mar 2017 16:06:53 +0000 (16:06 +0000)]
Stop installing pcap-int.h, which is the internal interface for libpcap.

Reference: https://github.com/the-tcpdump-group/libpcap/issues/560
PR: 217221

7 years agoqlxgbe: add GCC_MS_EXTENSIONS to CFLAGS to make old base GCC happy
avg [Tue, 7 Mar 2017 15:43:49 +0000 (15:43 +0000)]
qlxgbe: add GCC_MS_EXTENSIONS to CFLAGS to make old base GCC happy

The module uses unnamed structure and union fields and base GCC in
stable/10 doesn't like it.
I think that that is a C11 feature, so it is courteous of more modern
compilers to not complain about it when compiling in C99 mode.

Approved by: davidcs
MFC after: 5 days

7 years agoImplement time_is_after_eq_jiffies() function in the LinuxKPI.
hselasky [Tue, 7 Mar 2017 15:37:51 +0000 (15:37 +0000)]
Implement time_is_after_eq_jiffies() function in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoFix implementation of the DECLARE_RWSEM() macro in the LinuxKPI.
hselasky [Tue, 7 Mar 2017 15:34:49 +0000 (15:34 +0000)]
Fix implementation of the DECLARE_RWSEM() macro in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoMake sure jiffies value is cast to an integer in the LinuxKPI before
hselasky [Tue, 7 Mar 2017 15:33:38 +0000 (15:33 +0000)]
Make sure jiffies value is cast to an integer in the LinuxKPI before
doing millisecond conversion. Under FreeBSD jiffies are 32-bit.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoUpdate our Allwinner DTS to latest DTS changes in Linux 4.10
manu [Tue, 7 Mar 2017 13:59:30 +0000 (13:59 +0000)]
Update our Allwinner DTS to latest DTS changes in Linux 4.10

7 years agoUpdate our device tree files to a Linux 4.10
manu [Tue, 7 Mar 2017 13:56:49 +0000 (13:56 +0000)]
Update our device tree files to a Linux 4.10

7 years agoUse grouptaskqueue for tasklets in the LinuxKPI.
hselasky [Tue, 7 Mar 2017 13:51:14 +0000 (13:51 +0000)]
Use grouptaskqueue for tasklets in the LinuxKPI.

This avoids creating own per-CPU threads and also ensures the tasklet
execution happens on the same CPU core invoking the tasklet.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agodon't stop in issignal() if P_SINGLE_EXIT is set
badger [Tue, 7 Mar 2017 13:41:01 +0000 (13:41 +0000)]
don't stop in issignal() if P_SINGLE_EXIT is set

Suppose a traced process is stopped in ptracestop() due to receipt of a
SIGSTOP signal, and is awaiting orders from the tracing process on how
to handle the signal. Before sending any such orders, the tracing
process exits. This should kill the traced process. But suppose a second
thread handles the SIGKILL and proceeds to exit1(), calling
thread_single(). The first thread will now awaken and will have a chance
to check once more if it should go to sleep due to the SIGSTOP.  It must
not sleep after P_SINGLE_EXIT has been set; this would prevent the
SIGKILL from taking effect, leaving a stopped orphan behind after the
tracing process dies.

Also add new tests for this condition.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D9890

7 years agoWhen selecting brand based on old Elf branding, prefer the brand which
kib [Tue, 7 Mar 2017 13:38:25 +0000 (13:38 +0000)]
When selecting brand based on old Elf branding, prefer the brand which
interpreter exactly matches the one requested by the activated image.

This change applies r295277, which did the same for note branding, to
the old brand selection, with the same reasoning of fixing compat32
interpreter substitution.

PR: 211837
Reported by: kenji@kens.fm
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoRequire whole brand string matching for old Elf branding.
kib [Tue, 7 Mar 2017 13:37:35 +0000 (13:37 +0000)]
Require whole brand string matching for old Elf branding.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoConsistently use vm_ooffset_t type for the vm object offset in
kib [Tue, 7 Mar 2017 13:36:43 +0000 (13:36 +0000)]
Consistently use vm_ooffset_t type for the vm object offset in
elf_load_section.

The values passed currently as vm_offset_t are phdr.p_offset, which
have the native Elf word size.  Since elf_load_section interprets them
as the file offset, use vm object offset type.

Noted and reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoUpdate to Linux 4.10
manu [Tue, 7 Mar 2017 12:41:06 +0000 (12:41 +0000)]
Update to Linux 4.10

7 years agoLinuxKPI workqueue cleanup.
hselasky [Tue, 7 Mar 2017 12:09:14 +0000 (12:09 +0000)]
LinuxKPI workqueue cleanup.

This change makes the workqueue implementation behave more like in
Linux, both functionality wise and structure wise.

All workqueue code has been moved to linux_work.c

Add an atomic based statemachine to the work_struct to ensure proper
operation. Prior to this change struct_work was directly mapped to a
FreeBSD task. When a taskqueue has multiple threads the same task may
end up being executed on more than one worker thread simultaneously.
This might cause problems with code coming from Linux, which expects
serial behaviour, similar to Linux tasklets.

Move all global workqueue function names into the linux_xxx domain to
avoid symbol name clashes in the future.

Implement a few more workqueue related functions and macros.

Create two multithreaded taskqueues for the LinuxKPI during module
load, one for time-consuming callbacks and one for non-time consuming
callbacks.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoxen/netfront: fix inbound packet flags for checksum offload
royger [Tue, 7 Mar 2017 09:18:52 +0000 (09:18 +0000)]
xen/netfront: fix inbound packet flags for checksum offload

Currently netfront is setting the flags of inbound packets with the checksum
not present (offloaded) to (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID |
CSUM_PSEUDO_HDR). According to the mbuf(9) man page this is not the correct
combination of flags, it should instead be (CSUM_DATA_VALID |
CSUM_PSEUDO_HDR).

Reviewed by: Wei Liu <wei.liu2@citrix.com>
MFC after: 2 weeks
Sponsored by: Citrix Systems R&D
Differential revision: https://reviews.freebsd.org/D9831

7 years agoxenstore: fix suspension when using the xenstore device
royger [Tue, 7 Mar 2017 09:17:48 +0000 (09:17 +0000)]
xenstore: fix suspension when using the xenstore device

Lock the xenstore request mutex when suspending user-space processes, in order
to prevent any process from holding this lock when going into suspension, or
else the xenstore suspend process is going to deadlock.

Submitted by: Liuyingdong <liuyingdong@huawei.com>
Reviewed by: royger
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D9638

7 years agoxen: add support for canceled suspend
royger [Tue, 7 Mar 2017 09:16:51 +0000 (09:16 +0000)]
xen: add support for canceled suspend

When running on Xen, it's possible that a suspend request to the hypervisor
fails (return from HYPERVISOR_suspend different than 0). This means that the
suspend hasn't succeed, and the resume procedure needs to properly handle this
case.

First of all, when such situation happens there's no need to reset the vector
callback, hypercall page, shared info, event channels or grant table, because
it's state is preserved. Also, the PV drivers don't need to be reset to the
initial state, since the connection with the backed has not been interrupted.

Submitted by: Liuyingdong <liuyingdong@huawei.com>
Reviewed by: royger
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D9635

7 years agoiwn: deduplicate (RXON + txpower + broadcast node) command sequence.
avos [Tue, 7 Mar 2017 07:49:25 +0000 (07:49 +0000)]
iwn: deduplicate (RXON + txpower + broadcast node) command sequence.

Was previously applied to wpi(4) as a part of r278366.

Tested with Intel 6205, STA / MONITOR modes.

7 years agoFix the KASSERT check from r314813.
hiren [Tue, 7 Mar 2017 06:46:38 +0000 (06:46 +0000)]
Fix the KASSERT check from r314813.
len being 0 is valid.

Submitted by: ngie
Reported by: ngie (via jenkins test run)
Sponsored by: Limelight Networks

7 years agoThe relative symlink fix causes downstream issues for
rgrimes [Tue, 7 Mar 2017 06:11:36 +0000 (06:11 +0000)]
The relative symlink fix causes downstream issues for
EMC DELL Isilon so revert the relative symlink fix
pending a better solution.

Reported by: ngie
Approved by: greham (mentor) Implicit as reverting
MFC after: 1 week

7 years agoConvert absolute links to relative links.
rgrimes [Tue, 7 Mar 2017 05:10:38 +0000 (05:10 +0000)]
Convert absolute links to relative links.
Style.Makefile(9) has been ignored to produce minimal diffs.

Approved by: grehan (mentor)
MFC after: 1 week

7 years agops(1): Fix -w + UNLIMITED handling
cem [Tue, 7 Mar 2017 04:51:35 +0000 (04:51 +0000)]
ps(1): Fix -w + UNLIMITED handling

A follow-up fix for r314685.

Because the -w flag is parsed after ps(1) infers termwidth from COLUMNS and
stdout, and UNLIMITED happens to be the zero value, the single -w flag in
combination with a non-terminal stdout or COLUMNS=0 could result in output
truncated at 131 characters.  (Despite the output being unlimited without
-w.)

Obviously, adding more -w shouldn't truncate output lines.

The committed patch is from bdrewery@, and I've reviewed and tested it.

Submitted by: bdrewery@
Reported by: bdrewery@
Sponsored by: Dell EMC Isilon

7 years agoDon't rely on dependency in Makefile.inc1 for strfile; make datfiles depend on strfile
ngie [Tue, 7 Mar 2017 04:33:17 +0000 (04:33 +0000)]
Don't rely on dependency in Makefile.inc1 for strfile; make datfiles depend on strfile

In most cases strfile is built as part of build-tools, but in the event that someone
cd'ed to the directory, tried to build from scratch, and had MK_GAMES=no previously,
the build would fail in .../datfiles , trying to find strfile .

Mark this directory tree "SUBDIR_PARALLEL" safe to help facilitate this, instead of
shuffling around the SUBDIR entries (all of the other Makefiles will build standalone).

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agomergemaster: fix description of -p
ngie [Tue, 7 Mar 2017 04:13:22 +0000 (04:13 +0000)]
mergemaster: fix description of -p

-p only handles updating /etc/master.passwd and /etc/group . No more,
no less.

Also, mergemaster (and no other portions of the vanilla FreeBSD build
process) should be messing with __MAKECONF or SRCCONF as part of the
installworld or distribution process. Don't insinuate that mergemaster
does that as it's a false claim.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoloader.efi: fix an off-by-one bug in efi_verify_staging_size()
dexuan [Tue, 7 Mar 2017 03:35:50 +0000 (03:35 +0000)]
loader.efi: fix an off-by-one bug in efi_verify_staging_size()

Also remove the warning message: it may not be unusual to see
the memory range containing 2MB is not of EfiConventionalMemory.

MFC after: 2 weeks2 weeks
Sponsored by: Microsoft

7 years agoClang in base now supports -mlongcall, so remove this hack
jhibbits [Tue, 7 Mar 2017 02:17:38 +0000 (02:17 +0000)]
Clang in base now supports -mlongcall, so remove this hack

PR: 215947
MFC after: 2 weeks

7 years agoFix typo in comment.
sjg [Tue, 7 Mar 2017 01:42:30 +0000 (01:42 +0000)]
Fix typo in comment.

7 years agocxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp.
np [Tue, 7 Mar 2017 01:13:26 +0000 (01:13 +0000)]
cxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp.

Submitted by: KrishnamRaju ErapaRaju @ Chelsio
MFC after: 3 days
Sponsored by: Chelsio Communications

7 years agoWe've found a recurring problem where some userland process would be
hiren [Tue, 7 Mar 2017 00:20:01 +0000 (00:20 +0000)]
We've found a recurring problem where some userland process would be
stuck spinning at 100% cpu around sbcut_internal(). Inside
sbflush_internal(), sb_ccc reached to about 4GB and before passing it
to sbcut_internal(), we type-cast it from uint to int making it -ve.

The root cause of sockbuf growing this large is unknown. Correct fix
is also not clear but based on mailing list discussions, adding
KASSERTs to panic instead of looping endlessly.

Reviewed by: glebius
Sponsored by: Limelight Networks

7 years agoIntroduce the concept of IPsec security policies scope.
ae [Tue, 7 Mar 2017 00:13:53 +0000 (00:13 +0000)]
Introduce the concept of IPsec security policies scope.

Currently are defined three scopes: global, ifnet, and pcb.
Generic security policies that IKE daemon can add via PF_KEY interface
or an administrator creates with setkey(8) utility have GLOBAL scope.
Such policies can be applied by the kernel to outgoing packets and checked
agains inbound packets after IPsec processing.
Security policies created by if_ipsec(4) interfaces have IFNET scope.
Such policies are applied to packets that are passed through if_ipsec(4)
interface.
And security policies created by application using setsockopt()
IP_IPSEC_POLICY option have PCB scope. Such policies are applied to
packets related to specific socket. Currently there is no way to list
PCB policies via setkey(8) utility.

Modify setkey(8) and libipsec(3) to be able distinguish the scope of
security policies in the `setkey -DP` listing. Add two optional flags:
'-t' to list only policies related to virtual *tunneling* interfaces,
i.e. policies with IFNET scope, and '-g' to list only policies with GLOBAL
scope. By default policies from all scopes are listed.

To implement this PF_KEY's sadb_x_policy structure was modified.
sadb_x_policy_reserved field is used to pass the policy scope from the
kernel to userland. SADB_SPDDUMP message extended to support filtering
by scope: sadb_msg_satype field is used to specify bit mask of requested
scopes.

For IFNET policies the sadb_x_policy_priority field of struct sadb_x_policy
is used to pass if_ipsec's interface if_index to the userland. For GLOBAL
policies sadb_x_policy_priority is used only to manage order of security
policies in the SPDB. For IFNET policies it is not used, so it can be used
to keep if_index.

After this change the output of `setkey -DP` now looks like:
# setkey -DPt
0.0.0.0/0[any] 0.0.0.0/0[any] any
in ipsec
esp/tunnel/87.250.242.144-87.250.242.145/unique:145
spid=7 seq=3 pid=58025 scope=ifnet ifname=ipsec0
refcnt=1
# setkey -DPg
::/0 ::/0 icmp6 135,0
out none
spid=5 seq=1 pid=872 scope=global
refcnt=1

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

7 years agoo Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
marius [Mon, 6 Mar 2017 23:47:59 +0000 (23:47 +0000)]
o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
  comments, marking unused parameters as such, style(9), whitespace,
  etc.
o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
  - Remove redundant assignments of the default bus_generic_print_child
    device method (I've whipped these out of the tree as part of r227843
    once, but they keep coming back ...),
  - use DEVMETHOD_END,
  - use NULL instead of 0 for pointers.
o Trim/adjust includes.

7 years agopf: Fix a crash in low-memory situations
kp [Mon, 6 Mar 2017 23:41:23 +0000 (23:41 +0000)]
pf: Fix a crash in low-memory situations

If the call to pf_state_key_clone() in pf_get_translation() fails (i.e. there's
no more memory for it) it frees skp. This is wrong, because skp is a
pf_state_key **, so we need to free *skp, as is done later in the function.
Getting it wrong means we try to free a stack variable of the calling
pf_test_rule() function, and we panic.

7 years agoUpdate dirdeps/meta bits from latest bmake.
sjg [Mon, 6 Mar 2017 23:13:25 +0000 (23:13 +0000)]
Update dirdeps/meta bits from latest bmake.

7 years agoMerge bmake-20170301
sjg [Mon, 6 Mar 2017 23:02:33 +0000 (23:02 +0000)]
Merge bmake-20170301

7 years agoMove ATF_TC_WITHOUT_HEAD(getgrent) near the testcase it annotates
ngie [Mon, 6 Mar 2017 22:46:49 +0000 (22:46 +0000)]
Move ATF_TC_WITHOUT_HEAD(getgrent) near the testcase it annotates

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix compilation of r314784 on 32 bit.
glebius [Mon, 6 Mar 2017 22:32:56 +0000 (22:32 +0000)]
Fix compilation of r314784 on 32 bit.

7 years agoRemove *-api(3) manpages removed in ATF 0.21
ngie [Mon, 6 Mar 2017 22:18:14 +0000 (22:18 +0000)]
Remove *-api(3) manpages removed in ATF 0.21

I overlooked the fact that these manpages had been removed upstream
and replaced with their non *-api(3) equivalents. Follow upstream's
lead and remove the unused manpages.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix issues noted by igor/manlint
ngie [Mon, 6 Mar 2017 22:08:47 +0000 (22:08 +0000)]
Fix issues noted by igor/manlint

- Fix typos [1]:
-- manged -> managed
-- specifiying -> specifying
- Escape '.' at start of lines using & to tell the roff processor
  that the line isn't meant to be treated as a command [2].

Bump .Dd for the change

MFC after: 1 week
Reported by: igor [1], manlint [2]
Sponsored by: Dell EMC Isilon

7 years agoFix typos
ngie [Mon, 6 Mar 2017 21:50:35 +0000 (21:50 +0000)]
Fix typos

- specifiying -> specifying
- manged -> managed

Bump .Dd for the change

MFC after: 1 week
Reported by: igor
Sponsored by: Dell EMC Isilon

7 years agoFix atf-c-api(3) manpage issues
ngie [Mon, 6 Mar 2017 21:45:25 +0000 (21:45 +0000)]
Fix atf-c-api(3) manpage issues

- Fix typo (specifiying -> specifying).
- Remove surrounding ellipses in i.e. section and add a comma before
  and after the i.e. reference.

Bump .Dd for the change

MFC after: 1 week
Reported by: igor
Sponsored by: Dell EMC Isilon

7 years agoFix igor/manlint issues with atf-c(3)
ngie [Mon, 6 Mar 2017 21:43:47 +0000 (21:43 +0000)]
Fix igor/manlint issues with atf-c(3)

- Remove surrounding ellipses in i.e. section and add a comma before
  and after the i.e. reference [1].
- Fix typo (specifiying -> specifying) [1].
- Escape '.' at start of lines using & to tell the roff processor
  that the line isn't meant to be treated as a command [2].

Bump .Dd for the change

MFC after: 1 week
Reported by: igor [1], manlint [2]
Sponsored by: Dell EMC Isilon

7 years agoFix issues with atf-check(1) found by igor and refer to atf-check(1)
ngie [Mon, 6 Mar 2017 21:39:57 +0000 (21:39 +0000)]
Fix issues with atf-check(1) found by igor and refer to atf-check(1)

- Fix typo (specifiying -> specifying)
- Add atf-check(1) to SEE ALSO section for completeness. It's mentioned
  above, but by convention the SEE ALSO section should list all relevant
  references to other tools and APIs.

Bump .Dd for the change

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix manlint issues with atf-check(1)
ngie [Mon, 6 Mar 2017 21:35:33 +0000 (21:35 +0000)]
Fix manlint issues with atf-check(1)

- Use `.Bf Em`/`.Ef` instead of prefixing lines with `.Em`. The forms
  are equivalent with traditional roff, but unnecessarily verbose. The
  former form applies the .Em macro to the enclosed block.
- Move EXIT_STATUS section down so the section complies with section
  ordering specified by mdoc(7) and enforced by manlint(1).

Bump .Dd for the change

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix out-of-order sections in atf-sh(1)
ngie [Mon, 6 Mar 2017 21:30:06 +0000 (21:30 +0000)]
Fix out-of-order sections in atf-sh(1)

- `.Op` must be used in the SYNOPSIS section, not the NAME section.
- Move ATF_SHELL environment variable description up to first
  ENVIRONMENT section. Garbage collect the duplicate ENVIRONMENT
  section.

Bump .Dd for the change

MFC after: 1 week
Reported by: manlint
Sponsored by: Dell EMC Isilon

7 years agoFix grammar warning noted by igor
ngie [Mon, 6 Mar 2017 21:26:45 +0000 (21:26 +0000)]
Fix grammar warning noted by igor

Remove surrounding ellipses in e.g. section and add a comma before and after
the e.g. reference.

MFC after: 1 week
Reported by: igor
Sponsored by: Dell EMC Isilon

7 years agoFix atf-sh(3) manpage issues
ngie [Mon, 6 Mar 2017 21:24:55 +0000 (21:24 +0000)]
Fix atf-sh(3) manpage issues

- Fix spelling errors (specifiying -> specifying) [1]
- Escape '.' at start of lines using & to tell the roff processor
  that the line isn't meant to be treated as a command [2].

Bump .Dd for the change

MFC after: 1 week
Reported by: igor [1], manlint [2]
Sponsored by: Dell EMC Isilon

7 years agoReapply r287232 from upstream llvm trunk (by Daniil Fukalov):
dim [Mon, 6 Mar 2017 21:14:20 +0000 (21:14 +0000)]
Reapply r287232 from upstream llvm trunk (by Daniil Fukalov):

  [SCEV] limit recursion depth of CompareSCEVComplexity

  Summary:
  CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
  loop) and runs almost infinite time.

  Added cache of "equal" SCEV pairs to earlier cutoff of further
  estimation. Recursion depth limit was also introduced as a parameter.

  Reviewers: sanjoy

  Subscribers: mzolotukhin, tstellarAMD, llvm-commits

  Differential Revision: https://reviews.llvm.org/D26389

Pull in r296992 from upstream llvm trunk (by Sanjoy Das):

  [SCEV] Decrease the recursion threshold for CompareValueComplexity

  Fixes PR32142.

  r287232 accidentally increased the recursion threshold for
  CompareValueComplexity from 2 to 32.  This change reverses that
  change by introducing a separate flag for CompareValueComplexity's
  threshold.

The latter revision fixes the excessive compile times for skein_block.c.

7 years agoFix bootstrapping libmd on older systems after r314709.
bdrewery [Mon, 6 Mar 2017 21:06:55 +0000 (21:06 +0000)]
Fix bootstrapping libmd on older systems after r314709.

This follows another fix to bootstrap libmd after r313404.  The
MD5FileChunk prototype is needed to build libmd, but it is
only reliably in the src tree's sys/md5.h header.  Rather than
polluting the legacy build with this header for the entire build,
just symlink it in here for now as is done in the elftoolchain
build.  Libmd is already referencing other src tree headers by
its used of CFLAGS+= ${SRCTOP}/sys/crypto/sha2.  This, and
other uses of CFLAGS+= ${SRCTOP}/sys..., may later change to
be in the legacy mechanism.

Reported by: bde, ian, sjg
Tested by: ian

7 years agoFix ATF_TP_ADD_TCS example in atf-c-api(3)
ngie [Mon, 6 Mar 2017 20:54:21 +0000 (20:54 +0000)]
Fix ATF_TP_ADD_TCS example in atf-c-api(3)

ATF_TP_ADD_TC should use `tp` as the second argument, not `tcs`, as
ATF_TP_ADD_TCS uses `tp` as its first argument.

Bump .Dd for the change.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoAdded comments for why nmtree/libmd are bootstrapped.
bdrewery [Mon, 6 Mar 2017 20:32:17 +0000 (20:32 +0000)]
Added comments for why nmtree/libmd are bootstrapped.

7 years agoImport mpr(4) driver P12 to P14 diff from vendor site.
mav [Mon, 6 Mar 2017 19:39:31 +0000 (19:39 +0000)]
Import mpr(4) driver P12 to P14 diff from vendor site.

This is mostly a version bump to stay in version number sync with firmware.
The only change there was cosmetic:  Display degraded speed message upon
receiving Active Cable Exception Event with DEGRADED reason code.

Discussed with: slm@
MFC after: 1 week

7 years agoFix some trivial manlint warnings
ngie [Mon, 6 Mar 2017 19:33:15 +0000 (19:33 +0000)]
Fix some trivial manlint warnings

Sentences should begin on new lines, per manlint.

Bump .Dd for the change

MFC after: 1 month
Reviewed by: bcr
Reported by: make manlint
Sponsored by: Dell EMC Isilon

7 years agoIn panic() print current timestamp, which matches timestamp in the dump
glebius [Mon, 6 Mar 2017 19:14:08 +0000 (19:14 +0000)]
In panic() print current timestamp, which matches timestamp in the dump
header.  This will help to correlate console server logs with dump files,
no matter how precise is clock on a console server appliance, and how
buggy the appliance is.

7 years agoRegenerated Linuxulator syscall tables for r314782
mmokhi [Mon, 6 Mar 2017 18:20:37 +0000 (18:20 +0000)]
Regenerated Linuxulator syscall tables for r314782

Approved by: dchagin
MFC after: 1 month

7 years agoAdd UNIMPLEMENTED() placeholder macro for
mmokhi [Mon, 6 Mar 2017 18:11:38 +0000 (18:11 +0000)]
Add UNIMPLEMENTED() placeholder macro for
the syscalls that are not implemented in Linux kernel itself.
Cleanup DUMMY() macros.

Reviewed by: dchagin, trasz
Approved by: dchagin
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D9804

7 years agolibpam: extra bounds checking through reallocarray(3).
pfg [Mon, 6 Mar 2017 15:45:46 +0000 (15:45 +0000)]
libpam: extra bounds checking through reallocarray(3).

Reviewed by: des
MFC after: 1 week

7 years agoRevert r314777: wrong log, the change was to libpam.
pfg [Mon, 6 Mar 2017 15:42:03 +0000 (15:42 +0000)]
Revert r314777: wrong log, the change was to libpam.

7 years agolibfetch: extra bounds checking through reallocarray(3).
pfg [Mon, 6 Mar 2017 15:38:03 +0000 (15:38 +0000)]
libfetch: extra bounds checking through reallocarray(3).

Reviewed by: des
MFC after: 1 week

7 years agolibfetch: extra bounds checking through reallocarray(3).
pfg [Mon, 6 Mar 2017 15:37:34 +0000 (15:37 +0000)]
libfetch: extra bounds checking through reallocarray(3).

Reviewed by: des
MFC after: 1 week

7 years agoImplement add_timer_on() function in the LinuxKPI.
hselasky [Mon, 6 Mar 2017 14:56:57 +0000 (14:56 +0000)]
Implement add_timer_on() function in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoInstead of direct use of vm_map_insert(), call vm_map_fixed(MAP_CHECK_EXCL).
kib [Mon, 6 Mar 2017 14:09:54 +0000 (14:09 +0000)]
Instead of direct use of vm_map_insert(), call vm_map_fixed(MAP_CHECK_EXCL).

This KPI explicitely indicates the intent of creating the mapping at
the fixed address, and incorporates the map locking into the callee.

Suggested and reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoImplement DECLARE_RWSEM() macro in the LinuxKPI to initialize a
hselasky [Mon, 6 Mar 2017 12:22:05 +0000 (12:22 +0000)]
Implement DECLARE_RWSEM() macro in the LinuxKPI to initialize a
Read-Write semaphore during module init time.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoGive LinuxKPI Read-Write semaphores better debug names when
hselasky [Mon, 6 Mar 2017 12:20:56 +0000 (12:20 +0000)]
Give LinuxKPI Read-Write semaphores better debug names when
WITNESS_ALL is defined. The lock name is based on the filename and
line number where the initialisation happens.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoloader.efi: fix recent UEFI-boot regression on physical machines
dexuan [Mon, 6 Mar 2017 09:34:31 +0000 (09:34 +0000)]
loader.efi: fix recent UEFI-boot regression on physical machines

This patch fixes my recent patch
"loader.efi: reduce the size of the staging area if necessary", which
causes EFI-boot failure on physical machines since Mar 2:
on the host there is a 1MB LoaderData memory range, which splits
the big Conventional Memory range into a small one (15MB) and a
big one: the small one is too small to hold the staging area.

We can actually use the LoaderData range safely, because when
amd64_tramp -> efi_copy_finish() starts to run, we're almost at
the very end of the efi loader code and we're going to "return"
to the kernel entry, so we're pretty sure we won't access any loader
data any more.

For people who are interested in the details: please see
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211746#c22

PS, some people also reported the regression happened to FreeBSD VM
running on Bhyve in EFI mode. This patch should resolve it too,
though I don't have such a setup to test.

Reviewed by: sephe
Approved by: sephe (mentor)
MFC after: 2 weeks
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9904

7 years agoRemove compatibility with old libpcap.
delphij [Mon, 6 Mar 2017 08:13:19 +0000 (08:13 +0000)]
Remove compatibility with old libpcap.

Differential Revision: https://reviews.freebsd.org/D9606

7 years agoFix mismerge of r280849.
cy [Mon, 6 Mar 2017 07:11:23 +0000 (07:11 +0000)]
Fix mismerge of r280849.

Reported by: des
MFC after: 3 days

7 years agoBuild the dtb files for the revb1 versions of wandboard.
ian [Mon, 6 Mar 2017 04:16:35 +0000 (04:16 +0000)]
Build the dtb files for the revb1 versions of wandboard.

7 years agoThe patch provides the same socket option as Linux IP_ORIGDSTADDR.
eri [Mon, 6 Mar 2017 04:01:58 +0000 (04:01 +0000)]
The patch provides the same socket option as Linux IP_ORIGDSTADDR.
Unfortunately they will have different integer value due to Linux value being already assigned in FreeBSD.

The patch is similar to IP_RECVDSTADDR but also provides the destination port value to the application.

This allows/improves implementation of transparent proxies on UDP sockets due to having the whole information on forwarded packets.

Reviewed by: adrian, aw
Approved by: ae (mentor)
Sponsored by: rsync.net
Differential Revision: D9235

7 years agoRevert r314669, r314670:
pfg [Mon, 6 Mar 2017 03:52:15 +0000 (03:52 +0000)]
Revert r314669, r314670:
Bring back the i486 option in GENERIC by default.

The code related to i386 CPU variants configuration has received many
changes in the last years: most of the features are detected automatically,
so there are no performance penalties from keeping the 486 support enabled.

Re-instate the 486 support: while the general configuration could still be
cleaned a bit, there is no advantage in removing it.

Differential Revision: https://reviews.freebsd.org/D9879

7 years agoUpgrade to OpenSSH 7.4p1.
des [Mon, 6 Mar 2017 01:37:05 +0000 (01:37 +0000)]
Upgrade to OpenSSH 7.4p1.

7 years agoFix the build. Use new ipfw_lookup_table() in the nat64 too.
ae [Mon, 6 Mar 2017 00:41:59 +0000 (00:41 +0000)]
Fix the build. Use new ipfw_lookup_table() in the nat64 too.

Reported by: cy
MFC after: 2 weeks

7 years agoStyle and punctuation fixes.
alc [Sun, 5 Mar 2017 23:59:04 +0000 (23:59 +0000)]
Style and punctuation fixes.

Reviewed by: kib
MFC after: 3 days

7 years agoAdd IPv6 support to O_IP_DST_LOOKUP opcode.
ae [Sun, 5 Mar 2017 23:48:24 +0000 (23:48 +0000)]
Add IPv6 support to O_IP_DST_LOOKUP opcode.

o check the size of O_IP_SRC_LOOKUP opcode, it can not exceed the size of
  ipfw_insn_u32;
o rename ipfw_lookup_table_extended() function into ipfw_lookup_table() and
  remove old ipfw_lookup_table();
o use args->f_id.flow_id6 that is in host byte order to get DSCP value;
o add SCTP ports support to 'lookup src/dst-port' opcode;
o add IPv6 support to 'lookup src/dst-ip' opcode.

PR: 217292
Reviewed by: melifaro
MFC after: 2 weeks
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D9873

7 years agoReject invalid object types that can not be used with specific opcodes.
ae [Sun, 5 Mar 2017 22:19:43 +0000 (22:19 +0000)]
Reject invalid object types that can not be used with specific opcodes.

When we doing reference counting of named objects in the new rule,
for existing objects check that opcode references to correct object,
otherwise return EINVAL.

PR: 217391
MFC after: 1 week
Sponsored by: Yandex LLC

7 years agoDon't kill pid -1 on overflow from strtol(3).
bdrewery [Sun, 5 Mar 2017 21:56:04 +0000 (21:56 +0000)]
Don't kill pid -1 on overflow from strtol(3).

Store the result in a proper long and then compare to the proper pid_t
for overflow, so that no MD assumptions are made.

Reviewed by: jilles
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D9887

7 years agoFix bootstrapping mtree after r313404 for older systems.
bdrewery [Sun, 5 Mar 2017 21:16:50 +0000 (21:16 +0000)]
Fix bootstrapping mtree after r313404 for older systems.

r313404 made libnetbsd require sha384.h from libmd.  Libmd added it in
r292782.  Update BOOTSTRAPPING to account for this.

Reported by: bde
Reviewed by: ngie

7 years agoFor now, revert r287232 from upstream llvm trunk (by Daniil Fukalov):
dim [Sun, 5 Mar 2017 19:56:20 +0000 (19:56 +0000)]
For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov):

  [SCEV] limit recursion depth of CompareSCEVComplexity

  Summary:
  CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
  loop) and runs almost infinite time.

  Added cache of "equal" SCEV pairs to earlier cutoff of further
  estimation. Recursion depth limit was also introduced as a parameter.

  Reviewers: sanjoy

  Subscribers: mzolotukhin, tstellarAMD, llvm-commits

  Differential Revision: https://reviews.llvm.org/D26389

This commit is the cause of excessive compile times on skein_block.c
(and possibly other files) during kernel builds on amd64.

We never saw the problematic behavior described in this upstream commit,
so for now it is better to revert it.  An upstream bug has been filed
here: https://bugs.llvm.org/show_bug.cgi?id=32142

Reported by: mjg

7 years agoadd missing MLINKS for functions that this man page documents.
jmg [Sun, 5 Mar 2017 18:37:25 +0000 (18:37 +0000)]
add missing MLINKS for functions that this man page documents.

This page should be renamed to eliminate an unneeded inode.

Forgotten by: markm

7 years agoremove the the duplicate words from share/
eadler [Sun, 5 Mar 2017 18:00:52 +0000 (18:00 +0000)]
remove the the duplicate words from share/

7 years agoAdd macOS 10.12
eadler [Sun, 5 Mar 2017 16:48:14 +0000 (16:48 +0000)]
Add macOS 10.12

7 years agobc/dc/patch: make some use of reallocarray(3).
pfg [Sun, 5 Mar 2017 16:10:35 +0000 (16:10 +0000)]
bc/dc/patch: make some use of reallocarray(3).

reallocarray(3) is a non portable extension from OpenBSD. Given that it is
already in FreeBSD, make easier future merges by adopting in some cases
where the code has some shared heritage with OpenBSD.

Obtained from: OpenBSD

7 years agoAdd support for card detect and write protect gpio pins to Tegra SDHCI.
mmel [Sun, 5 Mar 2017 15:34:32 +0000 (15:34 +0000)]
Add support for card detect and write protect gpio pins to Tegra SDHCI.