ofproto-dpif-xlate: Actually drop packets on mirror ports.

Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Modularize ofproto-dpif-xlate.

This patch modularizes ofproto-dpif-xlate by disentangling it from
ofproto-dpif.  Instead of poking around in ofproto-dpif's internal
data structures, ofproto-dpif-xlate is updated with a simple API
which can easily be made thread safe.  There are still some places
where ofproto-dpif-xlate needs to call into ofproto-dpif, but this
patch makes significant progress towards the final goal.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Remove pointers between rules and facets.

Before this patch, facets maintained a pointer to the first rule
used when translating their actions, and rules maintained a pointer
to those facets.  This made sense before the resubmit actions which
each facet used precisely one rule.  However, today a facet may
require many rules to translate, and therefore it makes no
conceptual sense to designate one as the "owning rule".

Furthermore, as Open vSwitch becomes multithreaded, maintaining a
facet's rule pointer will become more difficult.  One thread will
do the action translation, while another will maintain the facets.
During the hand-off between these threads, it's possible the
"owning rule" will expire leaving us with a stale pointer.

This patch does have a disadvantage,  Pushing a facet's statistics
will become slightly less efficient as it will involve an
additional classifier lookup.  We can revisit this issue once
multithreading is complete, but I suspect there's much lower
hanging fruit to worry about.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
tests: Additional test for run time addition of a database.

Adding a removed database covers a common use case.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath: Rename skb_network_protocol() to __skb_network_protocol()

The function skb_network_protocol() is already defined in
<linux/netdevice.h> upstream but not an exported symbol.

Rename the OVS internal implementation to work around this.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath: rhel: Account for RHEL specific backports

The following symbols have been backported to RHEL and the kernel
version is no longer an accurate indicator for their presence:

 - skb_gso_segment
 - netif_skb_features
 - netif_needs_gso

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath: rhel: Move RHEL OVS hook registration to netdev_rx_handler_register() backport

Moves the registration of the RHEL specific OVS hook to the compat
backport of netdev_rx_handler_register(). This moves the hook
unregistration from the RCU callback to the netdev_destroy()
callback directly.

This is purely cosmetic though, the RHEL hook is only used if the
IFF_OVS_DATAPATH flag is present which was removed under RTNL
protection before the RCU callback.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
utilities: New helper script ovs-dev.py.

ovs-dev.py is a script I've written to help perform common tasks
necessary for developing Open vSwitch.  It allows a developer to
configure, build, and run the switch with a minimum of effort or
knowledge of the various idiosyncrasies involved.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
csum: Suppress sparse warning.

The latest version of sparse triggers the following warning in the
checksum tests.  This patch suppresses it.

warning: too long initializer-string for array of char

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-vsctl: Fix behavioral regression for "--if-exists del-port <bridge>".

Commit 89f3c258fe (ovs-vsctl: Improve error message for "ovs-vsctl del-port
<bridge>".) changed the behavior of
    ovs-vsctl --if-exists del-port <bridge>
from a silent no-op to a hard failure.  This commit fixes this regression.

This caused problems on XenServer, for which the Open vSwitch integration
runs commands like:
    /usr/bin/ovs-vsctl --timeout=20 \
        -- --with-iface --if-exists del-port xapi103 \
        -- --if-exists del-br xapi103

Bug #18276.
Reported-by: Michael Hu <mhu@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>