RawSocket: Reduce warnings.
Script: add more handlers and a test.

With Eddie Kohler.

Signed-off-by: Cliff Frey <cliff@meraki.com>
Fix Bypass::Visitor declared as struct, friended as class
User-level driver: SIGINT gets default handling after router stops.

Before this commit, there was a race condition where SIGINT could
access a deleted router (bad).

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Array memory: Add cast() function to avoid warnings from old compilers.

g++ 4.1.2 was a problem.
Internal: Make click_fence() work on Mac llvm-gcc 4.2.1.

What a disaster! What a long time this took to find!

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
On some ABIs, "struct { char[N] }" has a size != N; so pack.

We must have "sizeof(char_array<S>) == S"! Cliff Frey, Raluca
Musaloiu-E., and others found this problem.
fromhost: Remove acquisition of dev_base_lock

FromHost() was acquiring dev_base_lock, but this is not necessary
when calling alloc_netdev(), and indeed its an error as alloc_netdev()
can sleep when allocing memory.

The low level routines handle their own synchronization so acquiring
dev_base_lock is rarely necessary.

Verified by looking at the v2.6.0 kernel sources: the difference between
dev_alloc() and alloc_netdev() is the need for locking, so place
the lock inside the dev_alloc() pre-2.6 case.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
click: FromDevice - Add support for Linux 2.6.39

The interface for netdev rx_handlers changed in 2.6.39 to return
a status code instead of a skb pointer. Change the Click element
FromDevice to build with both interfaces.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Click fixincludes: fix mangling of radix-tree.h

Kernel changes in V3.1 include changes to radix-tree.h that
matched the regular expression used, but effected other parts of
the source file. Make the regular expression more specific so that
it will only change what was intended.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Disable warning about Args::consume().

Cliff Frey points out that reasonable uses of consume() trigger the
warning. But leave the warning code in, controlled by the
CLICK_DEBUG_ARGS_USAGE symbol.
machine.hh: fix non-smp linuxmodule builds

The header for cpu_relax needs to be included.
Merge pull request #48 from clifffrey/machine-hh-fix

machine.hh: fix non-smp linuxmodule builds
Lexer: Warn if implicit "input" is used in a dangerous way.

This is valid & causes no warning: "... -> {->} -> ..."
This will cause a warning: "... -> { Idle; -> } -> ..."
To avoid the warning, add "input": "... -> { Idle; input -> output } -> ..."
Or add "[0]": "... -> { Idle; [0] -> output } -> ..."

Why? Well, implicit "input" caused confusion at Meraki when people added
spurious semicolons by mistake. This used to be an error:

Hello -> Foo
  -> Bar;
  -> Baz
  -> Quux;

But with implicit "input" it was parsed as

Hello -> Foo -> Bar;
input -> Baz -> Quux;

Figuring out the problem in such a mistaken config was harder than it
should have been.

Perhaps implicit "input" should be removed (so you'd have to at least
give a port number). But this is a smaller change.

Cliff Frey request.
Documentation nits
click lexer: support cpp # lines in element configurations

This caused issues for Meraki with some elements (like AnnotationInfo) which
would have very large configurations, sometimes with large #ifdef parts.

Signed-off-by: Cliff Frey <cliff@meraki.com>
Merge pull request #49 from clifffrey/lexer-cpp-config-lines

click lexer: support cpp # lines in element configurations
String: Improve addition performance for empty strings.

Now String() + x actually produces a copy of x (no memory copy).
Lexer: Fix minor bugs in d53cb2c... and port to tools.
Test: Verify String sharing optimization.