ofproto-dpif: Make packet_ins thread safe.

This patch makes packet_ins thread safe by handing responsibility for
them to ofproto-dpif.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-thread: New function xpthread_setspecific().

Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-thread: Add support for globally visible per-thread data.

DEFINE_PER_THREAD_DATA always declared its data item as "static", meaning
that it was only directly visible within a single translation unit.
This commit adds additional forms of per-thread data that allow the data
to be accessible from multiple translation units.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-thread: New function ovsthread_id_self().

I foresee a need for possibly large numbers of instances of "struct
seq" (which is introduced in an upcoming patch).  Each struct seq
needs some per-thread data.  POSIX has pthread_key_t for this, but
the number of keys can be fairly limited, to as few as 128.  It is
reasonable to work around this by using a hash table indexed on the
current thread.  That only works if one can get a thread identifier
that is hashable (pthread_t is not).  This patch introduces a
hashable thread identifier.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif-xlate: Fix rare segfault on switch exit.

Not all 'xport's have 'xbundle's, so this dereference is unsafe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-thread: New function xpthread_join().

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto: Lock hard_timeout and idle_timeout of struct rule.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Lock the expirable list.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif: Hide rule_dpif_miss_rule().

It's simpler to hide it than to make it thread safe and ensure it
stays that way in the long term.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-thread: Remove superfluous semicolons in macro definitions.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif-xlate: Require a lock for reconfiguration.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath: Add 'ovs_' prefix to extern symbols.

The external symbols in the OVS kernel module are prefixed with
'ovs_' with the exception of ipv4_tun_to/from_nlattr(). This adds
the prefix and makes the out of tree version consistent with
upstream.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
compiler: Add OVS_ACQ_BEFORE, OVS_ACQ_AFTER macros.

An upcoming patch will add the first uses.

Signed-off-by: Ben Pfaff <blp@nicira.com>
classifier: Make use of the classifier thread safe.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto-dpif-xlate: Avoid MAC learning write lock on fast path.

Most of the trips through update_learning_table() do not actually change
the MAC learning table, but because some do the code there took the
MAC learning table's write lock.  This commit changes the common case to
take only the read lock, falling back to the write lock if a change was
actually necessary.

Ethan reported that this gave a 3.3x performance improvement in one test
case due to reduced lock contention.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
clang: Use OVS_REQUIRES() instead of OVS_REQ_WRLOCK() for plain mutex.

This commit changes the code to use OVS_REQUIRES() instead of
OVS_REQ_WRLOCK(), for plain mutex.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
clang: Pass objects, not their addresses, to thread-safety macros.

This commit changes the code such that arguments to thread-safety
macros are not ampersanded.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
CodingStyle: Add guide about using thread safety types and annotations.

This commit adds guide about using thread safety types and annotations
to CodingStyle file.

Signed-off-by: Alex Wang <alexw@nicira.com>
[blp@nicira.com edited the advice slightly]
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovs-bugtool: Collect database through CAP_NETWORK_STATUS.

Currently the openvswitch database is being collected with
CAP_NETWORK_CONFIG which has a max size of 50 KB. This is
quite low as the database can easily be larger than 50 KB.

Move database collection to CAP_NETWORK_STATUS which does
not have a max size. If database size exceeds 10 MB, create
a compacted version of it and then collect it.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovs-bugtool: Add config files to the debug bundle.

The previously defined config files were never included in
the debug bundle. This will include them.

Also increase the max size for CAP_NETWORK_CONFIG to 5 MB.
A pre-compressed size of 5 MB does not amount to much after
compression for config files.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>