datapath: Improve net-namespace compat code.

Following patch improves compat net-namespace code which is mostly
targeted for 2.6.32 kernel. upcoming vxlan restructuring patch
needs this patch.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Restructure vxlan tunneling.

Following patch restructures vxlan tunneling so that it is more
in sync with upstream vxlan tunneling code.

Signed-off-by: Pravin Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath: Conditionally define skb_unclone in datapath compat code

Recent versions of Fedora have skb_unclone included in their
kernels. This patch adds a conditional check into the compat directory so as
not to error out by defining it twice. This allows the latest OVS kernel
module to build on Fedora 19.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
dpif-netdev: Make 'max_mtu' a per-dp feature, for thread safety.

This ensures that an external lock around a dpif_netdev will allow
thread-safe access to it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-msgs: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
jsonrpc: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lockfile: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
memory: Add note about threaded usage to comment.

Signed-off-by: Ben Pfaff <blp@nicira.com>
meta-flow: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
xenserver: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
dirs: Make thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
dpif: Serialize initialization.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ovsdb-data: Make ovsdb_atom_default() thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
clang: Fix segfault in unit tests.

It seems that 'clang' compiler applies strict protection on pointer
dereference. And it causes unexpected execution in macro functions
like "HMAP_FOR_EACH()" and unit test failures. This commit fixes
this issue and pass all unit tests.

Co-authored-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
clang: Fix the "expression result unused" warning.

This commit makes macro function "ASSIGN_CONTAINER()" evaluates
to "(void)0". This is to avoid the 'clang' warning: "expression
result unused", since most of time, the final evaluated value
is not used.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
configure: Remove -Wno-override-init, add -Wextra to compile options.

The build is clean against -Wextra at least with GCC 4.4.

(-Wextra includes -Woverride-init.)

Suggested-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
sparse: Avoid sparse warnings for additional pthread initializers.

Reported-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: remove RCU annotation from flow->mask

After a mask is assigned to a flow, it will not change for the life of
the flow. Since flow access is protected by RCU lock, access to
flow->mask after getting a flow is always safe.

Suggested-by: Jesse Gross <jesse@nicira.com>
Reported-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
lib: Add CRC32C Implementation

This implementation was derived from FreeBSD:
http://code.google.com/p/freebsd-head/source/browse/sys/libkern/crc32.c

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Joe Stringer <joe@wand.net.nz>
---
v4: Fold in debian license modification
    Suppress checksum test sparse warning
v3: Rebase
    Return crc32c checksum in network byte-order
    Add checksum tests based on Intel IPPs documentation
v2: Update copyright notice
    Include config.h (Fix sparse error)
datapath: Add SCTP support

This patch adds support for rewriting SCTP src,dst ports similar to the
functionality already available for TCP/UDP.

Rewriting SCTP ports is expensive due to double-recalculation of the
SCTP checksums; this is performed to ensure that packets traversing OVS
with invalid checksums will continue to the destination with any
checksum corruption intact.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Joe Stringer <joe@wand.net.nz>
---
This patch introduces sparse warnings when calling
sctp_end_cksum(), due to a bug that was fixed in v3.10:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=eee1d5a14780b9391ec51f3feaf4cffb521ddbb1

v4: Rebase against megaflow
    Move compute_sctp_checksum to compat/
    Move openvswitch.h header changes in from other patch
    Don't set CHECKSUM_UNNECESSARY on port-rewrite
    Remove checksumming from Xen compat code
v3: Rebase
    Refactor sctp checksum computation
    Handle skb fragments for checksum calculation
    Fix sparse errors
v2: Remove SCTP checksum recalculation when changing IP address
    Calculate checksums as delta from incoming checksum