ofproto-dpif: Make ofport_dpif_cast() internally consistent.

This function's assertion would dereference a null pointer given a null
'ofport' argument, but its return statement checked for a null pointer
argument.  This commit fixes the inconsistency in favor of supporting
null pointer arguments.  (I discovered this problem while writing a piece
of code that wanted support for a null pointer argument, otherwise I would
resolve the inconsistency in the other direction.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
tunnel: Make tnl_port_receive() parameter 'const'.

This function no longer has much need to modify its argument, because the
caller can now easily do the modification itself, so this commit makes
that change.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Simplify ofproto_receive().

The tunnel and non-tunnel paths were pretty much the same anyway, so this
commit simplifies by merging them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Remove ofproto_update_local_port_stats().

It's a bit odd, and not particularly useful.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif: Simplify send_packet().

Before this patch, send_packet() manually constructed the required
datapath output actions.  This worked fine when these actions were
simple, however as outputting to tunnels and patch ports became
more complex, this required quite a bit of complex duplicated code.
This patch solves the problem by running through the standard
xlate_actions() code path instead.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif: Update 'facet->rule' stats in facet_push_stats().

Before this patch, stats for 'facet->rule' were handled differently
than stats which 'facet' resubmitted into.  The former were
maintained in 'facet' until it was destroyed, while the latter were
pushed regularly in facet_push_stats().

This inconsistent behavior was not only confusing, it was often
incorrect.  In some circumstances, if a facet changed rules, it
could carry the statistics from the entirety of its lifetime from
the old rule to the new one.  This patch remedies the issue by
handling all rule stats in facet_push_stats().

Reported-by: Tmusic <Tmusic987@gmail.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Merge branch 'master' into bsd-port-threaded