Split ifnet serializer step 4/many: Add IFNET_SERIALIZE_MAIN, which is
used by polling(4) code. Now polling(4) no longer tries to hold all
of the serializers of the driver; it just holds driver's main serializer.

Split ifnet serializer step 2/many: Add if_serialize_assert() function
pointer to ifnet, so that upper layer could assert ifnet's serialization
states. Remove the serialization state assertion on ifnet.if_input()
path, since the serialization state normaly has nothing to do with the
input processing.

These three function pointers accept ifnet struct and ifnet_serialize
enumeration.

The ifnet_serialize enumeration indicates the serialization type:
IFNET_SERIALIZE_ALL:
All of the serializers should be held. Except for if_start and if_input,
this enumeration must be used when call ifnet function pointers.
IFNET_SERIALIZE_TX:
Only transmit serializer should be held. This enumeration could be used
when calling ifnet.if_start.
IFNET_SERIALIZE_RX:
Only receive serializer should be held. This enumeration could be used
when calling ifnet.if_input.

If the NIC driver does not set these three function pointer, then if_attach()
will set them to the default ones: only one serializer (if_serializer) is used
and ifnet_serialize parameter is ignored.

Following several inline functions are added which are sheer wrappers of the
three ifnet serialize function pointers:
ifnet_serialize_{all,tx,rx}()
ifnet_deserialize_{all,tx,rx}()
ifnet_tryserialize_{all,tx,rx}()

All of the protocol layers and most of the pseudo drivers are converted.

This is probably a good idea for other directories as well. It's too
cumbersome not having this file available on the vendor branch, since
that's really where the work is done to remove unwanted files from the
vendor's distribution.

There is an edge case where a record is physically destroyed on the master
and a mirroring or mirror-streaming operation attempts to delete the record
on the slave using a mirror-end TID that in fact matches the create_tid of
the record. This results in a protective panic.

Fix the problem simply by not deleting such edge-case records. They will
be deleted in the next pass, since in order to have been destroyed on the
master the master must have done the operation with a larger TID then
the create_tid of the record that was destroyed.

* Add a flag, -T, that tells syslogd to always replace the timestamp on
messages from the network. This option lets us replace timestamps that
are correctly formatted but wrong.

* Allow comment to be placed at the end of a configuration line.

* Add a -8 switch to syslogd to prevent it from mangling 8-bit data.

* Open ctty in non-blocking mode to avoid hangs during open and close.

* Handle "*" as a priority properly.

* Dynamically determine length vs. hardcoding it.

* Free the previous message buffer (f_prevline) only after logging all
the messages and just before the process exit. Also check f_prevline for
NULL before using it.

* Add the ability to log to an arbitrary udp port as well as the
standard syslog port.

* Currently, if writing out a log entry fails, we unlink that log entry
from our internal list of logfiles. So if writev(2) fails for potentially
transient errors like ENOSPC, syslogd requires a restart, even if the
filesystem has purged. This change allows syslogd to ignore ENOSPC
space errors, so that when the filesystem is cleaned up, syslogd will
automatically start logging again without requiring the reset.
This makes syslogd(8) a bit more reliable.

* Add cases for ENOBUFS and ENETDOWN. We need to make sure that we
catch all transient errors. This fixes situations where transient
error conditions such as network interfaces losing carrier signals
or the system running out of mbufs would result in the permanent
removal of forwarding syslog messages.

* Add -S option which allows to change the pathname of the privileged
socket /var/run/logpriv.

* Check that supplied facility is not bigger than LOG_NFACILITIES.

* Allow ':' and '%' in hostname specifications so that we can specify
IPv6 addresses and scope IDs.

* Protect against local flooder of /var/run/log. Do not loop forever in
syslog(3) if we are a priveleged program (sshd, su, etc.).

- Make syslogd open an additional socket /var/run/logpriv, with 0600
permissions.
- In libc, try to use this socket.
- Do not loop forever if we are using this socket

* Protect pidlist with a mutex to avoid a race causing a duplicate
free() when the same pipe FILE is pclosed()'d in different threads,
and to avoid corrupting the linked list when adding or removing
items.

* Add sanity checking for QUEUE(3) TAILQs and LISTs under
INVARIANTS. Races may lead to list corruption, which can be
difficult to unravel in a post-mortem analysis. These checks verify
that the prev and next pointers are consistent when inserting or
removing elements, thus catching any corruption earlier.

* Use TRASHIT to break LIST and SLIST link pointers on element removal.

* Add more _FOREACH_MUTABLEs. Note: FreeBSD and NetBSD call these _SAFE,
but _MUTABLE is a better name, so that's what we're using.

* Add a macro for SLIST traversal 'SLIST_FOREACH_PREVPTR',
this macro keeps a pointer to the previous element's next
pointer to allow for search and O(1) removal.