Make sballoc() and sbfree() functions. Ideally, they could be marked
as static, but unfortunately Infiniband (ab)uses them.

Sponsored by:	Nginx, Inc.
- Move sbcheck() declaration under SOCKBUF_DEBUG.
- Improve SOCKBUF_DEBUG macros.
- Improve sbcheck().

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
REALLOCARRAY: Import of the OpenBSD's realloc wrapper.
github-issue: #70

Signed-off-by: Shawn Webb <lattera@gmail.com>
(cherry picked from commit a635d5a389110b1279fe63ca99aa991bdb4db7aa)
Signed-off-by: Oliver Pinter <op@hardenedbsd.org>
Missed in r274421: use sbavail() instead of bare access to sb_cc.
Remove extra labels, ENTRY_NP already provides them.

Sponsored by:	ABT Systems Ltd
Correctly a few incorrect uses of ENTRY/EENTRY and END/EEND

Sponsored by:	ABT Systems Ltd
Remove duplicate FILESYSTEMS REQUIRE from etc/rc.d/ipmon and etc/rc.d/pflog
Merge from projects/sendfile:

o Introduce a notion of "not ready" mbufs in socket buffers.  These
mbufs are now being populated by some I/O in background and are
referenced outside.  This forces following implications:
- An mbuf which is "not ready" can't be taken out of the buffer.
- An mbuf that is behind a "not ready" in the queue neither.
- If sockbet buffer is flushed, then "not ready" mbufs shouln't be
  freed.

o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc.
  The sb_ccc stands for ""claimed character count", or "committed
  character count".  And the sb_acc is "available character count".
  Consumers of socket buffer API shouldn't already access them directly,
  but use sbused() and sbavail() respectively.
o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones
  with M_BLOCKED.
o New field sb_fnrdy points to the first not ready mbuf, to avoid linear
  search.
o New function sbready() is provided to activate certain amount of mbufs
  in a socket buffer.

A special note on SCTP:
  SCTP has its own sockbufs.  Unfortunately, FreeBSD stack doesn't yet
allow protocol specific sockbufs.  Thus, SCTP does some hacks to make
itself compatible with FreeBSD: it manages sockbufs on its own, but keeps
sb_cc updated to inform the stack of amount of data in them.  The new
notion of "not ready" data isn't supported by SCTP.  Instead, only a
mechanical substitute is done: s/sb_cc/sb_ccc/.
  A proper solution would be to take away struct sockbuf from struct
socket and allow protocols to implement their own socket buffers, like
SCTP already does.  This was discussed with rrs@.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
Add missing libraries when linking.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
Merge from projects/sendfile: extend protocols API to support
sending not ready data:
o Add new flag to pru_send() flags - PRUS_NOTREADY.
o Add new protocol method pru_ready().

Sponsored by:	Nginx, Inc.
Sponsored by:	Netflix
Fix building of some infiniband utilities by updating some header file
locations and compiler include directives.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
Merge from projects/sendfile:

Provide pru_ready for AF_LOCAL sockets.  Local sockets sendsdata directly
to the receive buffer of the peer, thus pru_ready also works on the peer
socket.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
Merge from projects/sendfile:

- Provide pru_ready function for TCP.
- Don't call tcp_output() from tcp_usr_send() if no ready data was put
  into the socket buffer.
- In case of dropped connection don't try to m_freem() not ready data.

Sponsored by:	Nginx, Inc.
Sponsored by:	Netflix
HBSD USERLAND: try a better compile error fix after reallocarray import

github-issue: #70
Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
CC: David Carlier <david.carlier@hardenedbsd.org>
(cherry picked from commit 97040b658a64c972b0d82aeabf62c3770d54666a)
Signed-off-by: Oliver Pinter <oliver.pinter@hardenedbsd.org>
Cleanup and performance improvement of the virtio_blk driver

  - Add support for GEOM direct completion. Depending on the benchmark,
    this tends to give a ~30% improvement w.r.t IOPs and BW.
  - Remove an invariants check in the strategy routine. This assertion
    is caught later on by an existing panic.
  - Rename and resort various related functions to make more sense.

MFC after:	1 month
Merge remote-tracking branch 'freebsd/master' into hardened/current/master
Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/aslr