ARPQuerier: add ENTRY_PACKET_CAPACITY

This parameter limits how many packets an ARPQuerier stores for any
given ARP entry. The default (and existing behaviour) is to store an
unlimited number of packets (subject to PACKET_CAPACITY).  A packet that
arrives for an ARP entry that has reached ENTRY_PACKET_CAPACITY is
dropped.

Also, fix a packet leak for the case that append_query() returns
-ENOMEM.  Previously, this leak probably wasn't that important /
noticeable since it would only occur on memory allocation failure.
However, we now hit this case whenever ENTRY_PACKET_CAPACITY is
exceeded.

Reviewed-by: asa@meraki.com
Fix multithread bug: Reset _run_args, etc.

Problem: Imagine executing Script.run for a Script that returns
$1 (i.e., its first parameter). $1 is a substring of _run_args.
_run_args is a member of Script. Script.run is multithread-safe
(it's an "exclusive" handler, so at most one Script.run can run
at a time). But we didn't reset _run_args at the end. So: the
return value of Script.run shared memory with Script::_run_args.
The return value is manipulated by clickfs, and eventually
dereferenced and freed, OUTSIDE the configuration lock. But
Script::_run_args is reset the next time Script runs, which
might be concurrent! Crash.

Derrick Pallas reported the problem and helped narrow it down.
Add more String methods for managing sharing.

- String::data_shared: is_shared is a better name.
- String::is_stable: add it.
- String::unique: returns a new copy of *this if *this
  is_shared() && !is_stable(). (Maybe unique_or_stable
  would be a better name?)
Fix the shared-string handler problem better.

This fix would catch problems in other exclusive handlers.
ARPQuerier-08.testie: add valgrind support

Cliff spotted this.
StoreIPAddr: Accept other OFFSET arguments than 'src'.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Clickfs: Move read-handler preparation into its own function.

A version of this was done at Meraki.
Clickfs: Simplify flag handling, kill dead flags.
Clickfs: Add read-parameter support by opening with O_RDWR.

Again, original version from Meraki.
pkg-Makefile: add CLICKFINDELEMFLAGS to findelem call

elementmap.xml will now include elements that are built with
dependencies passed in via CLICKFINDELEMFLAGS.
Stop supporting Linux 2.4.

About time.
Internal: one unlock_config() function.
click/string: make mutable_data more explicit about memo refcount

Previously, String::mutable_data might deref but then continue to use
_r.data and _r.length.  It would prevent the underlying memo_t from
disappearing by taking a temporary reference via a local String.

This change makes that intention more explict by using the temporary instead
of accessing the now invalid _r directly.
click/linux: add dump stack to click_assert_failed

Now when an assertion fails, we will dump stack even if we don't panic.
This is crazy useful.
Handler flag cleanup.

No driver needs more than 2 driver flags, and there is no evidence
for user flags being useful at all that I remember, so reduce
their number.
Use newer spelling of Handler::h_nonexclusive.
Fix handler exclusivity.

- Remove Handler::exclusive(). Provide more specific and clear
  Handler::allow_concurrent_handlers(), allow_concurrent_threads().
- Read handlers obey Handler::exclusive() properly. Derrick Pallas
  showed that the previous code didn't: multiple HANDLERS could
  proceed in parallel, even though a read handler would block out
  concurrent threads. This behavior disagreed with the documentation.
- Use a version of Derrick's lock-upgrade code. Also introduce lock-
  downgrading for write handlers.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Improve compilability of --enable-adaptive.
Simplify and I believe correct handler locking.

- Config handlers are NOT nonexclusive! In fact they must be
  exclusive, because they modify click_router. Previously they
  weren't even protected from one another.
- In this commit click_router and click_config_generation are
  protected by the exclusive clickfs_lock mutex.
- Most file system functions keep the exclusive clickfs_lock
  during their operation, so that click_ino is protected.
  This makes the separate click_ino_lock redundant; it was
  inadequate anyway, since writing /click/config could change
  click_router at any time.
- Will this reduce scalability? Perhaps: but note that the
  clickfs_lock was ALWAYS an exclusive mutex (we faked read
  locking ourselves). I bet this will perform simiarly, with
  respect to directory operations and such.
- Support lock downgrading for non-exclusive handlers. Downgrading
  (1) "uses" the current router (so it won't be deleted by a
  concurrent /click/config write), (2) releases the clickfs_lock.
  It is not OK to access click_router, click_config_generation,
  or click_ino after downgrading the lock, so don't do that.
  Releasing a downgraded lock reduces the refcount on the relevant
  router.
Merge pull request #98 from jdizzle/master

pkg-Makefile: add CLICKFINDELEMFLAGS to findelem call