]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
11 years agolibc: Use O_CLOEXEC for various internal file descriptors.
jilles [Sat, 29 Sep 2012 11:54:34 +0000 (11:54 +0000)]
libc: Use O_CLOEXEC for various internal file descriptors.

This fixes a race condition where another thread may fork() before CLOEXEC
is set, unintentionally passing the descriptor to the child process.

This commit only adds O_CLOEXEC flags to open() or openat() calls where no
fcntl(fd, F_SETFD, FD_CLOEXEC) follows. The separate fcntl() call still
leaves a race window so it should be fixed later.

11 years agoGive a clue how to force tcpdump(8) to interpret correctly CARP packets.
glebius [Sat, 29 Sep 2012 10:49:02 +0000 (10:49 +0000)]
Give a clue how to force tcpdump(8) to interpret correctly CARP packets.

11 years agoUpdate a comment to reflect recent locking changes.
alc [Sat, 29 Sep 2012 08:11:12 +0000 (08:11 +0000)]
Update a comment to reflect recent locking changes.

11 years agocarp_send_ad() should never return without rescheduling next run.
glebius [Sat, 29 Sep 2012 05:52:19 +0000 (05:52 +0000)]
carp_send_ad() should never return without rescheduling next run.

11 years agoAllow deferred word-splitting via f_sysrc_get() by allowing $IFS in the
dteske [Sat, 29 Sep 2012 03:41:21 +0000 (03:41 +0000)]
Allow deferred word-splitting via f_sysrc_get() by allowing $IFS in the
"clean-room" environment used to query rc.conf(5) parameters.

This brings bsdconfig(8)'s sysrc.subr in-line with both the sysrc(8) manual
[provided by sysutils/sysrc] and sysrc(8)'s own sysrc.subr (now identical to
bsdconfig(8)'s sysrc.subr as of this patch).

Finally, this will allow a clean import of sysutils/sysrc (sans sysrc.subr,
already provided here).

Reviewed by: jilles
Approved by: adrian (co-mentor)

11 years agoSimplify and somewhat redesign interaction between pf_purge_thread() and
glebius [Fri, 28 Sep 2012 20:43:03 +0000 (20:43 +0000)]
Simplify and somewhat redesign interaction between pf_purge_thread() and
pf_purge_expired_states().

Now pf purging daemon stores the current hash table index on stack
in pf_purge_thread(), and supplies it to next iteration of
pf_purge_expired_states(). The latter returns new index back.

The important change is that whenever pf_purge_expired_states() wraps
around the array it returns immediately. This makes our knowledge about
status of states expiry run more consistent. Prior to this change it
could happen that n-th run stopped on i-th entry, and returned (1) as
full run complete, then next (n+1) full run stopped on j-th entry, where
j < i, and that broke the mark-and-sweep algorythm that saves references
rules. A referenced rule was freed, and this later lead to a crash.

11 years agoThe drbr(9) API appeared to be so unclear, that most drivers in
glebius [Fri, 28 Sep 2012 18:28:27 +0000 (18:28 +0000)]
The drbr(9) API appeared to be so unclear, that most drivers in
tree used it incorrectly, which lead to inaccurate overrated
if_obytes accounting. The drbr(9) used to update ifnet stats on
drbr_enqueue(), which is not accurate since enqueuing doesn't
imply successful processing by driver. Dequeuing neither mean
that. Most drivers also called drbr_stats_update() which did
accounting again, leading to doubled if_obytes statistics. And
in case of severe transmitting, when a packet could be several
times enqueued and dequeued it could have been accounted several
times.

o Thus, make drbr(9) API thinner. Now drbr(9) merely chooses between
  ALTQ queueing or buf_ring(9) queueing.
  - It doesn't touch the buf_ring stats any more.
  - It doesn't touch ifnet stats anymore.
  - drbr_stats_update() no longer exists.

o buf_ring(9) handles its stats itself:
  - It handles br_drops itself.
  - br_prod_bytes stats are dropped. Rationale: no one ever
    reads them but update of a common counter on every packet
    negatively affects performance due to excessive cache
    invalidation.
  - buf_ring_enqueue_bytes() reduced to buf_ring_enqueue(), since
    we no longer account bytes.

o Drivers handle their stats theirselves: if_obytes, if_omcasts.

o mlx4(4), igb(4), em(4), vxge(4), oce(4) and  ixv(4) no longer
  use drbr_stats_update(), and update ifnet stats theirselves.

o bxe(4) was the most correct driver, it didn't call
  drbr_stats_update(), thus it was the only driver accurate under
  moderate load. Now it also maintains stats itself.

o ixgbe(4) had already taken stats from hardware, so just
  - drop software stats updating.
  - take multicast packet count from hardware as well.

o mxge(4) just no longer needs NO_SLOW_STATS define.

o cxgb(4), cxgbe(4) need no change, since they obtain stats
  from hardware.

Reviewed by: jfv, gnn

11 years agoFix some nearby type and style errors.
mdf [Fri, 28 Sep 2012 17:34:34 +0000 (17:34 +0000)]
Fix some nearby type and style errors.

Pointed out by: bde

11 years agoMake sure we don't leak a mbuf in a fail case.
hselasky [Fri, 28 Sep 2012 16:23:01 +0000 (16:23 +0000)]
Make sure we don't leak a mbuf in a fail case.

11 years agoRemove some trailing bytes which are not part of the ethernet packet.
hselasky [Fri, 28 Sep 2012 15:33:13 +0000 (15:33 +0000)]
Remove some trailing bytes which are not part of the ethernet packet.

Discussed with: bgray @

11 years agoCorrect NYET handling. Remove superfluous transfer complete interrupt mask.
hselasky [Fri, 28 Sep 2012 15:24:14 +0000 (15:24 +0000)]
Correct NYET handling. Remove superfluous transfer complete interrupt mask.

11 years agoSlight stylification.
des [Fri, 28 Sep 2012 13:50:37 +0000 (13:50 +0000)]
Slight stylification.

11 years agoRemove unnecessary #include.
des [Fri, 28 Sep 2012 12:29:25 +0000 (12:29 +0000)]
Remove unnecessary #include.

11 years agoChange queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to make
mav [Fri, 28 Sep 2012 12:13:34 +0000 (12:13 +0000)]
Change queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to make
them enabled on HEAD by default. It is probably better to do single compare
then hunt for unexpected memory corruption.

11 years ago- Re-shuffle the <machine/pc/bios.h> headers to move all kernel-specific
jhb [Fri, 28 Sep 2012 11:59:32 +0000 (11:59 +0000)]
- Re-shuffle the <machine/pc/bios.h> headers to move all kernel-specific
  bits under #ifdef _KERNEL but leave definitions for various structures
  defined by standards ($PIR table, SMAP entries, etc.) available to
  userland.
- Consolidate duplicate SMBIOS table structure definitions in ipmi(4)
  and smbios(4) in <machine/pc/bios.h> and make them available to
  userland.

MFC after: 2 weeks

11 years agoChange "only only" to "only" in portsnap(8).
issyl0 [Fri, 28 Sep 2012 11:40:59 +0000 (11:40 +0000)]
Change "only only" to "only" in portsnap(8).

Spotted by: Ruslan Mahmatkhanov
Approved by: gabor (mentor, implicit)

11 years agoFix the mis-handling of the VV_TEXT on the nullfs vnodes.
kib [Fri, 28 Sep 2012 11:25:02 +0000 (11:25 +0000)]
Fix the mis-handling of the VV_TEXT on the nullfs vnodes.

If you have a binary on a filesystem which is also mounted over by
nullfs, you could execute the binary from the lower filesystem, or
from the nullfs mount. When executed from lower filesystem, the lower
vnode gets VV_TEXT flag set, and the file cannot be modified while the
binary is active. But, if executed as the nullfs alias, only the
nullfs vnode gets VV_TEXT set, and you still can open the lower vnode
for write.

Add a set of VOPs for the VV_TEXT query, set and clear operations,
which are correctly bypassed to lower vnode.

Tested by: pho (previous version)
MFC after: 2 weeks

11 years agoAdd a note to portsnap(8) about the behaviour of the example cron command.
issyl0 [Fri, 28 Sep 2012 11:11:42 +0000 (11:11 +0000)]
Add a note to portsnap(8) about the behaviour of the example cron command.

PR: docs/171759
Submitted by: Paul Hoffman (phoffman at proper dot com)
Approved by: cperciva, gabor (mentor)
MFC after: 3 days

11 years agoMake the loader a bit smarter, when it tries to open disk and the slice
ae [Fri, 28 Sep 2012 10:49:41 +0000 (10:49 +0000)]
Make the loader a bit smarter, when it tries to open disk and the slice
number is not exactly specified. When the disk has MBR, also try to read
BSD label after ptable_getpart() call. When the disk has GPT, also set
d_partition to 255.  Mostly, this is how it worked before.

11 years agoRemove the topology lock from disk_gone(), it might be called with regular
pjd [Fri, 28 Sep 2012 08:22:51 +0000 (08:22 +0000)]
Remove the topology lock from disk_gone(), it might be called with regular
mutexes held and the topology lock is an sx lock.

The topology lock was there to protect traversing through the list of providers
of disk's geom, but it seems that disk's geom has always exactly one provider.

Change the code to call g_wither_provider() for this one provider, which is
safe to do without holding the topology lock and assert that there is indeed
only one provider.

Discussed with: ken
MFC after: 1 week

11 years agoMake sure that each va_start has one and only one matching va_end,
kevlo [Fri, 28 Sep 2012 07:51:30 +0000 (07:51 +0000)]
Make sure that each va_start has one and only one matching va_end,
especially in error cases.

11 years agoEliminate a stale comment. It describes another use case for the pmap in
alc [Fri, 28 Sep 2012 05:30:59 +0000 (05:30 +0000)]
Eliminate a stale comment.  It describes another use case for the pmap in
Mach that doesn't exist in FreeBSD.

11 years agoSanitize varname argument in f_sysrc_find. This is as much for security as it
dteske [Fri, 28 Sep 2012 01:39:25 +0000 (01:39 +0000)]
Sanitize varname argument in f_sysrc_find. This is as much for security as it
is for sanity.

Reviewed by: jilles
Approved by: adrian (co-mentor)

11 years agoFix usr.bin/ and usr.sbin/ build with a 64-bit ino_t.
mdf [Thu, 27 Sep 2012 23:31:19 +0000 (23:31 +0000)]
Fix usr.bin/ and usr.sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou

11 years agoFix bin/ build with a 64-bit ino_t.
mdf [Thu, 27 Sep 2012 23:31:12 +0000 (23:31 +0000)]
Fix bin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou

11 years agoFix sbin/ build with a 64-bit ino_t.
mdf [Thu, 27 Sep 2012 23:31:06 +0000 (23:31 +0000)]
Fix sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou

11 years agoFix fsck_ffs build with a 64-bit ino_t.
mdf [Thu, 27 Sep 2012 23:30:58 +0000 (23:30 +0000)]
Fix fsck_ffs build with a 64-bit ino_t.

Original code by: Gleb Kurtsou

11 years agoFix up kernel sources to be ready for a 64-bit ino_t.
mdf [Thu, 27 Sep 2012 23:30:49 +0000 (23:30 +0000)]
Fix up kernel sources to be ready for a 64-bit ino_t.

Original code by: Gleb Kurtsou

11 years agolibc/fts: Use O_CLOEXEC for internal file descriptors.
jilles [Thu, 27 Sep 2012 22:05:54 +0000 (22:05 +0000)]
libc/fts: Use O_CLOEXEC for internal file descriptors.

Because fts keeps internal file descriptors open across calls, making such
descriptors close-on-exec helps not only multi-threaded applications but
also single-threaded applications.

In particular, this prevents passing a temporary file descriptor for saving
the current directory to processes created via find -exec.

11 years agoEnsure that all cases that enqueue a netgraph item for delivery by a
rstone [Thu, 27 Sep 2012 20:12:51 +0000 (20:12 +0000)]
Ensure that all cases that enqueue a netgraph item for delivery by a
ngthread properly set the item's depth to 1.  In particular, prior to this
change if ng_snd_item failed to acquire a lock on a node, the item's depth
would not be set at all.  This fix ensures that the error code from rcvmsg/
rcvdata is properly passed back to the apply callback.  For example, this
fixes a bug where an error from rcvmsg/rcvdata would not previously
propagate back to a libnetgraph consumer when the message was queued.

Reviewed by: mav
MFC after: 1 month
Sponsored by: Sandvine Incorporated

11 years agoComplete revert of r239963:
pfg [Thu, 27 Sep 2012 20:06:37 +0000 (20:06 +0000)]
Complete revert of r239963:

The attempt to merge changes from the linux libtirpc caused
rpc.lockd to exit after startup under unclear conditions.

After many hours of selective experiments and inconsistent results
the conclusion is that it's better to just revert everything and
restart in a future time with a much smaller subset of the
changes.
____

MFC after: 3 days
Reported by: David Wolfskill
Tested by: David Wolfskill

11 years agoComplete revert of r239963:
pfg [Thu, 27 Sep 2012 19:10:25 +0000 (19:10 +0000)]
Complete revert of r239963:

The attempt to merge changes from the linux libtirpc caused
rpc.lockd to exit after startup under unclear conditions.

After many hours of selective experiments and inconsistent results
the conclusion is that it's better to just revert everything and
restart in a future time with a much smaller subset of the
changes.
____

MFC after: 3 days
Reported by: David Wolfskill
Tested by: David Wolfskill

11 years agoFix pseudo checksum calculation.
fjoe [Thu, 27 Sep 2012 18:15:01 +0000 (18:15 +0000)]
Fix pseudo checksum calculation.

This fixes ipfilter w/ network controllers that implement only
partial rx csum offloading.

PR: 106438
Obtained from: upstream
MFC after: 1 week

11 years agosigaction(2),sigwait(2),sigwaitinfo(2): Remove [EFAULT] error condition.
jilles [Thu, 27 Sep 2012 17:48:04 +0000 (17:48 +0000)]
sigaction(2),sigwait(2),sigwaitinfo(2): Remove [EFAULT] error condition.

Passing an invalid pointer results in undefined behaviour.

The wrappers in libthr access some of the data pointed to by the arguments
in userland, so that an invalid pointer will cause a signal and not an
[EFAULT] error return.

Furthermore, if the [EFAULT] error occurs when the kernel is writing, it is
not a proper error in the sense that the call still commits (changing the
signal disposition or accepting the signal).

MFC after: 1 week

11 years agoRevert r240931, as the previous comment was actually in sync with POSIX.
pjd [Thu, 27 Sep 2012 16:43:23 +0000 (16:43 +0000)]
Revert r240931, as the previous comment was actually in sync with POSIX.

I have to note that POSIX is simply stupid in how it describes O_EXEC/fexecve
and friends. Yes, not only inconsistent, but stupid.

In the open(2) description, O_RDONLY flag is described as:

O_RDONLY Open for reading only.

Taken from:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

Note "for reading only". Not "for reading or executing"!

In the fexecve(2) description you can find:

The fexecve() function shall fail if:

[EBADF]
The fd argument is not a valid file descriptor open for executing.

Taken from:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

As you can see the function shall fail if the file was not open with O_EXEC!

And yet, if you look closer you can find this mess in the exec.html:

Since execute permission is checked by fexecve(), the file description
fd need not have been opened with the O_EXEC flag.

Yes, O_EXEC flag doesn't have to be specified after all. You can open a file
with O_RDONLY and you still be able to fexecve(2) it.

11 years agoMake sure the "wMaxPacketSize" limitations are respected.
hselasky [Thu, 27 Sep 2012 15:45:24 +0000 (15:45 +0000)]
Make sure the "wMaxPacketSize" limitations are respected.

11 years agoMake sure we record NAK tokens in the TD structure for IN direction.
hselasky [Thu, 27 Sep 2012 15:23:38 +0000 (15:23 +0000)]
Make sure we record NAK tokens in the TD structure for IN direction.
Improve host channel disabling. Wait two times 125us for channel to be
disabled. The DWC OTG doesn't like when channels are re-used too early.

11 years agoKernel and modules have "set_vnet" linker set, where virtualized
trociny [Thu, 27 Sep 2012 14:55:15 +0000 (14:55 +0000)]
Kernel and modules have "set_vnet" linker set, where virtualized
global variables are placed. When a module is loaded by link_elf
linker its variables from "set_vnet" linker set are copied to the
kernel "set_vnet" ("modspace") and all references to these variables
inside the module are relocated accordingly.

The issue is when a module is loaded that has references to global
variables from another, previously loaded module: these references are
not relocated so an invalid address is used when the module tries to
access the variable. The example is V_layer3_chain, defined in ipfw
module and accessed from ipfw_nat.

The same issue is with DPCPU variables, which use "set_pcpu" linker
set.

Fix this making the link_elf linker on a module load recognize
"external" DPCPU/VNET variables defined in the previously loaded
modules and relocate them accordingly. For this set_pcpu_list and
set_vnet_list are used, where the addresses of modules' "set_pcpu" and
"set_vnet" linker sets are stored.

Note, archs that use link_elf_obj (amd64) were not affected by this
issue.

Reviewed by: jhb, julian, zec (initial version)
MFC after: 1 month

11 years agoRemove useless NULL checks after M_WAITOK allocations.
trasz [Thu, 27 Sep 2012 10:51:38 +0000 (10:51 +0000)]
Remove useless NULL checks after M_WAITOK allocations.

11 years agoFix zillions of style(9) and spacing bugs introduced by r240981.
glebius [Thu, 27 Sep 2012 10:46:22 +0000 (10:46 +0000)]
Fix zillions of style(9) and spacing bugs introduced by r240981.

Pointy hat to: sobomax

11 years agoFix several build failures for !COMPAT_FREEBSD32 and
glebius [Thu, 27 Sep 2012 10:30:11 +0000 (10:30 +0000)]
Fix several build failures for !COMPAT_FREEBSD32 and
!COMPAT_FREEBSD* kernels introduced by r240981.

Pointy hat to: sobomax

11 years agoFix bug in TCP_KEEPCNT setting, which slipped in in the last round
glebius [Thu, 27 Sep 2012 07:13:21 +0000 (07:13 +0000)]
Fix bug in TCP_KEEPCNT setting, which slipped in in the last round
of reviewing of r231025.

Unlike other options from this family TCP_KEEPCNT doesn't specify
time interval, but a count, thus parameter supplied doesn't need
to be multiplied by hz.

Reported & tested by: amdmi3

11 years agoTrack the last ANI TX/RX sample correctly.
adrian [Thu, 27 Sep 2012 06:05:54 +0000 (06:05 +0000)]
Track the last ANI TX/RX sample correctly.

This doesn't specifically fix the issue(s) i'm seeing in this 2GHz
environment (where setting/increasing spur immunity causes OFDM restart
errors to skyrocket through the roof; but leaving it at 0 would leave
the environment cleaner..)

Pointy-hat-to: me, for committing this broken code in the first place.

11 years agoImplementing pmap_kextract(va) as pmap_extract(kernel_pmap, va) is
alc [Thu, 27 Sep 2012 05:39:42 +0000 (05:39 +0000)]
Implementing pmap_kextract(va) as pmap_extract(kernel_pmap, va) is
problematic because some callers to pmap_kextract() expect its
implementation to be lock-less.  In particular, uma_dbg_alloc() implicitly
requires this.  Otherwise, lock-order reversals occur between pmap locks and
UMA zone locks.  So, this change introduces a lock-less implementation of
pmap_kextract().

Disable recursion on the pvh global lock in the new armv6 pmap.  While
recursion on this locks occurs in the old arm pmap, it thankfully doesn't
occur in the armv6 pmap.

Tested by: jmg

11 years agoInitialize the num variable to avoid uninitialized data.
kevlo [Thu, 27 Sep 2012 05:26:29 +0000 (05:26 +0000)]
Initialize the num variable to avoid uninitialized data.
This fixes the bug introduced by r238378.

Reviewed by: pfg

11 years agoAdd 32-bit ABI compat shims. Those are necessary for i386 binary-only
sobomax [Thu, 27 Sep 2012 04:28:55 +0000 (04:28 +0000)]
Add 32-bit ABI compat shims. Those are necessary for i386 binary-only
tools like sysutils/hpacucli (HP P4xx RAID controller management
suite) working on amd64 systems.

PR: 139271
Submitted by: Kazumi MORINAGA, Eugene Grosbein
MFC after: 1 week

11 years agoatrun: Do not assume that MAXLOGNAME <= 100.
jilles [Wed, 26 Sep 2012 20:47:39 +0000 (20:47 +0000)]
atrun: Do not assume that MAXLOGNAME <= 100.

The reserved space for fmt was exactly sufficient for a two-digit value of
MAXLOGNAME - 1.

PR: bin/171815
Submitted by: Jeremy Huddleston Sequoia
MFC after: 1 week

11 years agofind: Do not pass fd to save current directory to child processes.
jilles [Wed, 26 Sep 2012 20:16:15 +0000 (20:16 +0000)]
find: Do not pass fd to save current directory to child processes.

This removes one of the two wrongly passed file descriptors. The other one
appears to be from fts(3).

MFC after: 1 week

11 years ago- In the bridge_enqueue() do success/error accounting for
glebius [Wed, 26 Sep 2012 20:09:48 +0000 (20:09 +0000)]
- In the bridge_enqueue() do success/error accounting for
  each fragment, not only once.
- In the GRAB_OUR_PACKETS() macro do increase if_ibytes.

11 years ago- Make C11 atomic macros usable in expressions:
tijl [Wed, 26 Sep 2012 19:49:22 +0000 (19:49 +0000)]
- Make C11 atomic macros usable in expressions:
  - Replace do-while statements with void expressions.
  - Wrap __asm statements in statement expressions.
- Make the macros function-like:
  - Evaluate all arguments exactly once.
  - Make sure there's a sequence point between evaluation of the arguments
    and the function body. Arguments should be evaluated before any memory
    barriers.
- Fix use of __atomic_is_lock_free built-in. It requires the address of
  an atomic variable as second argument. Use this built-in on clang as
  well because clang's __c11_atomic_is_lock_free only takes the size of the
  variable into account.
- In atomic_exchange_explicit put the barrier before instead of after the
  __sync_lock_test_and_set call.

Reviewed by: theraven

11 years agoMake sure the DWC OTG host mode channels are given enough time to disable.
hselasky [Wed, 26 Sep 2012 18:59:20 +0000 (18:59 +0000)]
Make sure the DWC OTG host mode channels are given enough time to disable.

11 years agoMerge similar fixes from 223198 from igb to ixgbe:
jhb [Wed, 26 Sep 2012 18:11:43 +0000 (18:11 +0000)]
Merge similar fixes from 223198 from igb to ixgbe:
- Use a dedicated task to handle deferred transmits from the if_transmit
  method instead of reusing the existing per-queue interrupt task.
  Reusing the per-queue interrupt task could result in both an interrupt
  thread and the taskqueue thread trying to handle received packets on a
  single queue resulting in out-of-order packet processing and lock
  contention.
- Don't define ixgbe_start() at all where if_transmit is used.

Tested by: Vijay Singh
Reviewed by: jfv
MFC after: 2 weeks

11 years ago - Allow cross-architecture builds with 'generate-release.sh', which
gjb [Wed, 26 Sep 2012 18:04:16 +0000 (18:04 +0000)]
 - Allow cross-architecture builds with 'generate-release.sh', which
   is set by specifying '-a <arch>'.  (Only supported for i386 on amd64
   and powerpc on powerpc64 currently).
 - Change how textproc/docproj is installed:
   o Attempt to install from pkg(8);
   o Fall back to pkg_add(1) if pkg(8) installation is not
     successful;
   o Fall back to installing from ports as last resort.
 - Ensure the script is run by root[1].
 - Get OSVERSION from param.h[1].

Provided by: glebius [1]
Reviewed by: nwhitehorn, kensmith
Approved by: kensmith
MFC After: 2 weeks
X-Needs-MFC: r240586, r240587, r240588

11 years agoAdd a COMPILER_FEATURES variable that is set in bsd.compiler.mk.
brooks [Wed, 26 Sep 2012 17:25:15 +0000 (17:25 +0000)]
Add a COMPILER_FEATURES variable that is set in bsd.compiler.mk.

When the compiler is clang add c++11 to COMPILER_FEATURES.

When the compiler supports c++11, default to building libc++.  This will
not impact the compliation of programs, but will make it easier for
users with clang compiled systems to test libc++ by passing -stdlib=libc++
to their c++ compliations.

11 years agoCreate led(4) device nodes mapped to isci(4) SGPIO locate LEDs.
jimharris [Wed, 26 Sep 2012 16:46:44 +0000 (16:46 +0000)]
Create led(4) device nodes mapped to isci(4) SGPIO locate LEDs.

Device nodes are in the format /dev/led/isci.busX.portY.locate.

Sponsored by: Intel
Requested by: Paul Maulberger <paul dot maulberger at gmx dot de>
MFC after: 1 week

11 years agoRemove FreeBSD 4.x compat shims. Verified by md5.
jhb [Wed, 26 Sep 2012 14:17:14 +0000 (14:17 +0000)]
Remove FreeBSD 4.x compat shims.  Verified by md5.

11 years agoGrab the mfi_config_lock while performing a MFI_DCMD_CFG_FOREIGN_IMPORT
jhb [Wed, 26 Sep 2012 14:14:06 +0000 (14:14 +0000)]
Grab the mfi_config_lock while performing a MFI_DCMD_CFG_FOREIGN_IMPORT
request on behalf of a user utility.

Submitted by: Steven Hartland  killing multiplay co uk
MFC after: 1 week

11 years agoCreate the new initarm_ functions to reduce the diff to the other FDT
andrew [Wed, 26 Sep 2012 10:07:53 +0000 (10:07 +0000)]
Create the new initarm_ functions to reduce the diff to the other FDT
versions of initarm

11 years agoMerge recent vendor changes in ZFS.
mm [Wed, 26 Sep 2012 09:37:58 +0000 (09:37 +0000)]
Merge recent vendor changes in ZFS.

Illumos issued covered:
2811 missing implementation: zfs send -r
3139 zdb dies when it tries to determine path of unlinked file
3189 kernel panic in ZFS test suite during hotspare_onoffline_004_neg
3208 moving zpool cross-endian results in incorrect user/group accounting

References:
  https://www.illumos.org/issues/ + [issue_id]

Obtained from: illumos (vendor/illumos, vendor/illumos-sys)
MFC after: 2 weeks

11 years agoTeach getent(1) to look up a hostname and find IPv6 addresses.
kevlo [Wed, 26 Sep 2012 09:29:48 +0000 (09:29 +0000)]
Teach getent(1) to look up a hostname and find IPv6 addresses.

PR: bin/161548
Submitted by: matthew

11 years agoUse arm_dump_avail_init to build the dump_avail array
andrew [Wed, 26 Sep 2012 09:27:38 +0000 (09:27 +0000)]
Use arm_dump_avail_init to build the dump_avail array

11 years agoStart to clean up the lpc initarm as it also uses FDT.
andrew [Wed, 26 Sep 2012 09:25:31 +0000 (09:25 +0000)]
Start to clean up the lpc initarm as it also uses FDT.

11 years agoMake the updates of the tid ring buffer' head and tail pointers
kib [Wed, 26 Sep 2012 09:25:11 +0000 (09:25 +0000)]
Make the updates of the tid ring buffer' head and tail pointers
explicit by moving them into separate statements from the buffer
element accesses.

Requested by: jhb
MFC after: 3 days

11 years agoFix panic in CTL caused by trying to free invalid pointers passed
trasz [Wed, 26 Sep 2012 07:09:15 +0000 (07:09 +0000)]
Fix panic in CTL caused by trying to free invalid pointers passed
by the userland process via the IOCTL interface.

Reviewed by: ken@

11 years agoMap the non-QoS TID to the voice queue, in order to ensure important
adrian [Wed, 26 Sep 2012 03:45:42 +0000 (03:45 +0000)]
Map the non-QoS TID to the voice queue, in order to ensure important
things like EAPOL frames make it out.

After a whole bunch of hacking/testing, I discovered that they weren't
being early-dropped by the stack (but I should look at ensuring that
later..) but were even making to the hardware transmit queue.
They were mostly even being received by the remote end.  However, the
remote end was completely ignoring them.

This didn't happen under 150-170MBit TCP tests as I'm guessing the TX
queue stayed very busy and the STA didn't do any scanning. However, when
doing 100Mbit/s of TCP traffic, the STA would do background scanning -
which involves it coming in and out of powersave mode with the AP.

Now, this is a total and utter hack around the real problems, which are:

* I need to implement proper power save handling and integrate it into
  the filtered frames support, so the driver/stack doesn't send frames
  whilst the station is actually in sleep;

* .. but frames were actually making it to the STA (macbook pro) and
  the AP did receive an ACK; but a tcpdump on the receiving side showed
  the EAPOL frame never made it. So the stack was dropping it for
  some reason;

* Importantly - the EAPOL frames are currently going into the non-QoS
  TID, which maps to the BE queue and is susceptible to that queue being
  busy doing other things, but;

* There's other traffic going on in the non-QoS TID from other contexts
  when scanning is going on and it's possible there's some races causing
  sequence number/IV issues, but;

* Importantly importantlly, I think the interaction with TID 16 multicast
  traffic in power save mode is causing issues - since I -believe- the
  sequence number space being used by the EAPOL frames on TID 16 overlaps
  with the multicast frames that have sequence numbers allocated and
  are then stuffed on the cabq.  Since with EAPOL frames being in TID 16
  and queued to the BE queue, it's going to be waiting to be serviced
  with all of the aggregate traffic going on - and if the CABQ gets
  emptied beforehand, those TID 16 multicast frames with sequence numbers
  will go out beforehand.

Now, there's quite likely a bunch of "stuff happening slightly out of
sequence" going on due to the nature of the TX path (read: lots of
overlapping and concurrent ath_start() and ath_raw_xmit() calls going
on, sigh) but I thought I had caught them all and stuffed each TID TX
behind a lock (that lasted as long as it needed to in order to get
the frame onto the relevant destination queue - thus keeping things
in order.)

Unfortunately the last problem is the big one and I'm going to stare at
it some more.  If it _is_

So this is a work around for now to ensure that EAPOL frames actually
make it out before any other stuff in the non-QoS TID and HOPEFULLY
before the CABQ gets active.

I'm now going to spend a little time in the TX path figuring out exactly
why the sender is rejecting things. There's two (well, three if you count
EAPOL contents invalid) possibilities:

* The sequence number is out of order (ie, something else like the multicast
  traffic on CABQ) is going out first on TID 16;
* The CCMP IV is out of order (similar to above - but less likely,  as the
  TX key for multicast traffic is different to unicast traffic);
* EAPOL contents strangely invalid.

AP: Ubiquiti RSPRO, AR9160/AR9220 NICs
STA: Macbook Pro, Broadcom 11n NIC

11 years agoCorrect misspelling in debug output.
emaste [Wed, 26 Sep 2012 01:09:19 +0000 (01:09 +0000)]
Correct misspelling in debug output.

11 years agoAdd regression test for kern/172075.
emaste [Wed, 26 Sep 2012 00:25:09 +0000 (00:25 +0000)]
Add regression test for kern/172075.

Sponsored by: ADARA Networks
PR: kern/172075

11 years agoRevert part of an earlier patch attempt that snuck in with r240938.
emaste [Tue, 25 Sep 2012 23:41:45 +0000 (23:41 +0000)]
Revert part of an earlier patch attempt that snuck in with r240938.

11 years agoFix freebsd32_kmq_timedreceive() and freebsd32_kmq_timedsend() to use
pjd [Tue, 25 Sep 2012 22:15:59 +0000 (22:15 +0000)]
Fix freebsd32_kmq_timedreceive() and freebsd32_kmq_timedsend() to use
getmq_read() and getmq_write() respectively, just like sys_kmq_timedreceive()
and sys_kmq_timedsend().

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoAdd more SPI flash IDs.
ray [Tue, 25 Sep 2012 22:12:07 +0000 (22:12 +0000)]
Add more SPI flash IDs.

Submitted by: Luiz Otavio O Souza.
Submitted by: ZRouter.org project.
Approved by: adrian (menthor)

11 years agoAvoid INVARIANTS panic destroying an in-use tap(4)
emaste [Tue, 25 Sep 2012 22:10:14 +0000 (22:10 +0000)]
Avoid INVARIANTS panic destroying an in-use tap(4)

The requirement (implied by the KASSERT in tap_destroy) that the tap is
closed isn't valid; destroy_dev will block in devdrn while other threads
are in d_* functions.

Note: if_tun had the same issue, addressed in SVN revisions r186391,
r186483 and r186497.  The use of the condvar there appears to be
redundant with the functionality provided by destroy_dev.

Sponsored by: ADARA Networks
Reviewed by: dwhite
MFC after: 2 weeks

11 years agovn_write() always expects FOF_OFFSET flag, which is asserted at the begining,
pjd [Tue, 25 Sep 2012 21:31:17 +0000 (21:31 +0000)]
vn_write() always expects FOF_OFFSET flag, which is asserted at the begining,
so there is no need to check for it.

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoRemove an incorrect comment
emaste [Tue, 25 Sep 2012 21:19:17 +0000 (21:19 +0000)]
Remove an incorrect comment

11 years agoWe cannot open file for reading and executing (O_RDONLY | O_EXEC).
pjd [Tue, 25 Sep 2012 21:11:40 +0000 (21:11 +0000)]
We cannot open file for reading and executing (O_RDONLY | O_EXEC).
Well, in theory we can pass those two flags, because O_RDONLY is 0,
but we won't be able to read from a descriptor opened with O_EXEC.

Update the comment.

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoRequire CAP_DELETE on directory descriptor for unlinkat(2).
pjd [Tue, 25 Sep 2012 21:00:36 +0000 (21:00 +0000)]
Require CAP_DELETE on directory descriptor for unlinkat(2).

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoRequire CAP_CREATE on directory descriptor for symlinkat(2).
pjd [Tue, 25 Sep 2012 20:59:12 +0000 (20:59 +0000)]
Require CAP_CREATE on directory descriptor for symlinkat(2).

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoRequire CAP_CREATE on directory descriptor for linkat(2).
pjd [Tue, 25 Sep 2012 20:58:15 +0000 (20:58 +0000)]
Require CAP_CREATE on directory descriptor for linkat(2).

Sponsored by: FreeBSD Foundation
MFC after: 2 weeks

11 years agoO_EXEC flag is not part of the O_ACCMODE mask, check it separately.
pjd [Tue, 25 Sep 2012 20:48:49 +0000 (20:48 +0000)]
O_EXEC flag is not part of the O_ACCMODE mask, check it separately.
If O_EXEC is provided don't require CAP_READ/CAP_WRITE, as O_EXEC
is mutually exclusive to O_RDONLY/O_WRONLY/O_RDWR.

Without this change CAP_FEXECVE capability right is not enforced.

Sponsored by: FreeBSD Foundation
MFC after: 3 days

11 years agoOops - don't do the clrdmask check in ath_tx_xmit_normal() - the wrong
adrian [Tue, 25 Sep 2012 20:41:43 +0000 (20:41 +0000)]
Oops - don't do the clrdmask check in ath_tx_xmit_normal() - the wrong
lock may be held.

Kim reported that the TID lock wasn't held when ath_tx_update_clrdmask()
was called. Well, the underlying hardware TXQ for that TID.

I'm betting it's the cabq stuff. ath_tx_xmit_normal() can be called
for both real and software cabq.  For software cabq, the real destination
txq is different to the txq. So, the lock check will fail.

Reported by: Kim Culhan <w8hdkim@gmail.com>

11 years agoChange the module name for the I/O provider to "kernel" from
gnn [Tue, 25 Sep 2012 19:16:28 +0000 (19:16 +0000)]
Change the module name for the I/O provider to "kernel" from
"genunix"  This will requires us to modify externally created
DTrace scripts but makes logical sense for FreeBSD.

Requested by: rpaulo
MFC after: 2 weeks

11 years agoSome aac(4) adapters will always report that a direct access device is
rstone [Tue, 25 Sep 2012 19:12:12 +0000 (19:12 +0000)]
Some aac(4) adapters will always report that a direct access device is
offline in response to a INQUIRY command that does not retreive vital
product data(I personally have observed the behaviour on an Adaptec 2405
and a 5805).  Force the peripheral qualifier to "connected" so that upper
layers correctly recognize that a disk is present.

This bug was uncovered by r216236.  Prior to that fix, aac(4) was
accidentally clearing the peripheral qualifier for all inquiry commands.

This fixes an issue where passthrough devices were not created for
disks behind aac(4) controllers suffering from the bug.  I have
verified that if a disk is not present that we still properly detect
that and not create the passthrough device.

Sponsored by: Sandvine Incorporated
MFC after: 1 week

11 years agoAdd optional entropy harvesting for software interrupts in swi_sched()
jhb [Tue, 25 Sep 2012 14:55:46 +0000 (14:55 +0000)]
Add optional entropy harvesting for software interrupts in swi_sched()
as controlled by kern.random.sys.harvest.swi.  SWI harvesting feeds into
the interrupt FIFO and each event is estimated as providing a single bit of
entropy.

Reviewed by: markm, obrien
MFC after: 2 weeks

11 years agoFix panic introduced by me in r240835, when zero weight
glebius [Tue, 25 Sep 2012 12:45:41 +0000 (12:45 +0000)]
Fix panic introduced by me in r240835, when zero weight
was passed to wtab_alloc().

Reported by: Kim Culhan <w8hdkim gmail.com>

11 years agoReduce delays in several wait loops from 10ms to 10us, same is it is done
mav [Tue, 25 Sep 2012 10:52:49 +0000 (10:52 +0000)]
Reduce delays in several wait loops from 10ms to 10us, same is it is done
in Linux. This substantially increases graphics performance on Ivy Bridge.

Submitted by: avg@
Reviewed by: kib@

11 years agoCall ath_tx_tid_unsched() after the node has been flushed, so the
adrian [Tue, 25 Sep 2012 05:56:59 +0000 (05:56 +0000)]
Call ath_tx_tid_unsched() after the node has been flushed, so the
state can be printed correctly.

11 years agoEliminate an unused declaration.
alc [Tue, 25 Sep 2012 03:59:10 +0000 (03:59 +0000)]
Eliminate an unused declaration.

11 years agoAttila Bogar reported a bug in mountd when multiple export
rmacklem [Mon, 24 Sep 2012 23:57:16 +0000 (23:57 +0000)]
Attila Bogar reported a bug in mountd when multiple export
entries with different security flavors are in the exports(5)
file. For that case, mountd replies with the security flavors
of the last entry and not the correct one for the client host.
This patch fixes that by storing separate copies of the flavors
for each host/net case, plus a default one for the case where
no hosts/nets are specified on an entry in the exports(5) file.
Unlike the patch in the PR, it replies with the security flavors
for the entry instead of merging the security flavors for all
the entries and replying with that.

Tested by: attila.bogar at linguamatics.com
PR: kern/164933
MFC after: 2 weeks

11 years agoUse CAM_SEL_TIMEOUT and CAM_DEV_NOT_THERE to report missing targets or
jimharris [Mon, 24 Sep 2012 21:45:41 +0000 (21:45 +0000)]
Use CAM_SEL_TIMEOUT and CAM_DEV_NOT_THERE to report missing targets or
LUNs respectively.  This removes a huge number of error messages
from CAM during bus scans.

Copied almost verbatim from mav's commit r237460.

Submitted by: Mike Tancsa <mike at sentex dot net>
MFC after: 3 days

11 years agoSpecify MTX_RECURSE for the controller's io_lock. Without it, tws(4)
jimharris [Mon, 24 Sep 2012 21:40:22 +0000 (21:40 +0000)]
Specify MTX_RECURSE for the controller's io_lock.  Without it, tws(4)
immediately panics on boot with INVARIANTS enabled.  The driver already
clearly expects to be able to recurse on this mutex - the main I/O
is always recursing on this lock.

Reported and tested by:  Mike Tancsa <mike at sentex dot net>
MFC after: 1 week

11 years agoMigrate the ath(4) KTR logging to use an ATH_KTR() macro.
adrian [Mon, 24 Sep 2012 20:35:56 +0000 (20:35 +0000)]
Migrate the ath(4) KTR logging to use an ATH_KTR() macro.

This should eventually be unified with ATH_DEBUG() so I can get both
from one macro; that may take some time.

Add some new probes for TX and TX completion.

11 years agoDebugging output fixes:
adrian [Mon, 24 Sep 2012 19:48:41 +0000 (19:48 +0000)]
Debugging output fixes:

* use the correct frame status - although the completion descriptor is
  the _last_ in the frame/aggregate, the status is currently stored in
  the _first_ buffer.

* Print out ath_buf specific fields once, not per descriptor in an ath_buf.

11 years agoWhitespace fixes
melifaro [Mon, 24 Sep 2012 17:34:30 +0000 (17:34 +0000)]
Whitespace fixes

MFC after: 2 weeks

11 years agoPermit table to be used as IPv6 address.
melifaro [Mon, 24 Sep 2012 17:31:08 +0000 (17:31 +0000)]
Permit table to be used as IPv6 address.

Reported by: Serhiy Popov <sergiuspso@ukr.net>
MFC after: 2 weeks

11 years agoMake sure moused is exiting as quick as possible after that the
hselasky [Mon, 24 Sep 2012 17:13:33 +0000 (17:13 +0000)]
Make sure moused is exiting as quick as possible after that the
umsX character device returns a read error. Update devd.conf rules
to use "DEVFS" events which are generated after that the umsX
character device node has been created/destroyed, and then there
should be no need for moused to wait up to 10 seconds for umsX to
be ready. Opening umsX should not fail except if the kernel is low
on memory. In that case the user can replug the USB mouse or use
"usbconfig" to reset the device. In case of USB mouse devices,
moused should neither retry to open its character device,
once the first read error has happened. This is an indication
of device detach.

MFC after: 1 week

11 years agoDWC OTG host mode improvements:
hselasky [Mon, 24 Sep 2012 16:34:13 +0000 (16:34 +0000)]
DWC OTG host mode improvements:
 - Make HSIC selection dynamic.
 - Make LOW speed USB devices work through HIGH speed USB HUB.

11 years agoMinor man page cleanup -- fix grammar, markup fixes, and start each
bjk [Mon, 24 Sep 2012 15:02:31 +0000 (15:02 +0000)]
Minor man page cleanup -- fix grammar, markup fixes, and start each
sentence on a new line.

Approved by: hrs (mentor)

11 years agoDocument ipv6 hook, present there for ages.
mav [Mon, 24 Sep 2012 08:32:19 +0000 (08:32 +0000)]
Document ipv6 hook, present there for ages.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

11 years agoFix panic caused by wrong pointer dereference, left after pin sense rewrite
mav [Mon, 24 Sep 2012 08:23:05 +0000 (08:23 +0000)]
Fix panic caused by wrong pointer dereference, left after pin sense rewrite
at r230551.

Also while there, make sense polling use reported for each node separately
instead of reporting accumulated total status.

Submitted by: Barbara <barbara.freebsd@gmail.com> (1)
MFC after: 3 days

11 years agoPrepare for software retransmission of non-aggregate frames but ensure
adrian [Mon, 24 Sep 2012 06:42:20 +0000 (06:42 +0000)]
Prepare for software retransmission of non-aggregate frames but ensure
it's disabled.

The previous commit to enable CLRDMASK setting didn't do it at all
correctly for non-aggregate sessions - so the CLRDMASK bit would be
cleared and never re-set.

* move ath_tx_update_clrdmask() to be called by functions that setup
  descriptors and queue frames to the hardware, rather than scattered
  everywhere.

* Force CLRDMASK to be set on all non-aggregate session frames being
  transmitted.

* Use ath_tx_normal_comp() now on non-aggregate sessoin frames
  that are queued via ath_tx_xmit_normal().  That way the TID hwq is
  updated and they can trigger (eventual) filter frame queue resets
  and software retransmits.

There's still a bit more work to do in this area to reverse the silly
short-sightedness on my part, however it's likely going to be better
to fix this now than just reverting the patch.

Thanks to people on the freebsd-wireless@ mailing list for promptly
pointing this out.

11 years agoIn (eventual) preparation for supporting disabling the whole 11n/software
adrian [Mon, 24 Sep 2012 06:00:51 +0000 (06:00 +0000)]
In (eventual) preparation for supporting disabling the whole 11n/software
retry path - add some code to make it obvious (to me!) how to disable
the software tx path.