click: add support for debug tracing packets

Allow packets to be marked for tracing. With each push or pull of a
packet marked for tracing, Click chatters a line indicating the source
and destination elements and ports.  Also, Click chatters a line when a
traced packet is killed.  The output looks like this (from a testie):

  traced_packet: trace_push [0] -> [0] RoundRobinSwitch@3
  traced_packet: RoundRobinSwitch@3 [0] -> [0] isw
  traced_packet: isw [0] -> [0] Discard@5
  traced_packet: killed

Arbitrary elements can mark packets for tracing. However, the typical
way to mark packets is through the Trace element added in a subsequent
commit.

I opted for a really simple implementation: a static Packet member that
stores a pointer to the traced packet. (Note that non-static Packet
members are not allowed in the Linux case.) This pointer is never
dereferenced - it just lets pushes and pulls identify a traced packet.
The implementation is not entirely thread safe: in particular, on
platforms where pointer assignment is not atomic, the pointer may end up
containing garbage. However, since the pointer is only used for
comparison and this is just a debugging feature, this should be OK.  The
static packet pointer is cleared whenever a traced packet is killed or
leaves Click. I believe linuxmodule's ToDevice and ToHost are the only
places a packet leaves Click without being killed.

With this implementation, only one packet can be traced at a time. In
particular, this means that normally you can't start tracing a packet if
another packet is still being traced. This behaviour can be changed
using the 'preempt' argument to set_traced().

Asa Zernik added code for printing the output port for push() and the
input port for pull(). Jignesh Patel added code for preempting tracing.

Reviewed-by: asa@meraki.com
click build: add --enable-packet-tracing configure option

Reviewed-by: asa@meraki.com
generate configure for "click build: add --enable-packet-tracing configure option"

This should be regenerated. I have an older version of autoconf.
Trace: element that marks packets for debug tracing

To debug where certain packets end up going, you can insert a Trace
element somewhere on a click path (e.g., as it is received from a
device). You would typically precede Trace with an (IP)Classifier to
pick out the packets you're actually interested in.

Trace has a LIMIT parameter (default 1) that limits the number of
packets marked in order to avoid overwhelming Linux with too many
chatters.  It also has a convenience 'poke' handler that sets the state
such that the next packet going through Trace will get marked (taking
care of setting _limit, resetting _count, and clearing a possibly bogus
traced packet pointer).

An optional second output port helps with printing which packets were
actually marked for tracing. A clone of each marked packet is emitted on
this port.

Preemption can be configured on per Trace element basis using the
PREEMPT config parameter or 'preempt' handler, or it can be set globally
for all Trace elements using the 'global_preempt' handler. If
global_preempt is set then some Trace elements can be set to not preempt
using the IGNOREGLOBALPREEMPT config parameter or ignoreglobalpreempt
handler.

Jignesh Patel added code for preempting tracing.

Reviewed-by: asa@meraki.com
userlevel click packet: don't use kill() to unreference a packet

In Linux click, Packet::kill() is called on a packet just once -- when
the user of the packet discards the packet -- at which time the packet
is recycled. Sharing data among packets to implement clone() is handled
outside of Packet, and killing clones of a packet does not affect the
cloned packet.

In userlevel (and other non-Linux) click, packets share data by having a
clone keep a reference to the cloned packet. When the clone is killed,
Packet internally calls kill() on the referenced packet to decrement a
reference count and (if the reference count drops to 0) recycle the
packet.  This means that a packet's kill() may be called several times:
once when the packet's user discards the packet and once each time a
clone is killed.

Unfortunately, the userlevel click behaviour breaks any code in kill()
that needs to run only when a packet is discarded by its user, in
particular packet tracing code.  For packet tracing, a packet may get
untraced prematurely if a clone of the packet is killed before the
packet itself.  This change fixes the issue by factoring out
dec_use_count() and having Packet use that instead of kill() to drop a
reference to a packet.

Reviewed-by: asa@meraki.com