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.
Documentation nit.
Prefer String::make_uninitialized to String::make_garbage.

A better name.
Yet more String stuff: Add String::empty().
ToHost: clear skb->sp on packets going to linux

Linux doesn't clear the sec_path variable in skb when the packet gets
sent to click.  If this packet originally came from linux and had xfrm
states applied, then they would still be saved in this member.  When
linux receives the packet again it will require that an appropriate
policy exists to match the packet and these xfrm states.

Clearing the sec_path makes linux treat the packet as a new packet
coming in off the wire.
Merge pull request #50 from JimRoewe/master

ToHost: clear skb->sp on packets going to linux
Merge branch 'master' of git://github.com/kohler/click