ofproto-dpif-xlate: Do initial rule lookup for callers.
authorEthan Jackson <ethan@nicira.com>
Wed, 9 Oct 2013 20:23:31 +0000 (13:23 -0700)
committerEthan Jackson <ethan@nicira.com>
Wed, 9 Oct 2013 23:45:57 +0000 (16:45 -0700)
commit10c44245ad673e03c50c03b711f6c4dea1d7f2e2
tree57affb0511fb77a268e1c4ff4feda816dc50e6ef
parent307873b7f3ffed26ea08e318676321acf41fd788
ofproto-dpif-xlate: Do initial rule lookup for callers.

None of the functions available in ofproto-dpif.h are thread safe
unless holding the xlate_rwlock because one can't know that an ofproto
or ofport used as argument will survive during the function call.  For
this reason, ofproto-dpif-upcall's invocation of rule_dpif_lookup()
is unsafe because the ofproto could be destroyed during the call.

This patch fixes the problem by optionally doing the initial rule
lookup in xlate_actions() so that it can be done while holding the
xlate_rwlock.  This has the nice side benefit of removing a bunch of
boilerplate.

Note that this only partially solves the problem, there's still
vsp_realdev_to_vlandev() and ofproto_dpif_send_packet_in() which
aren't thread safe for the same reason.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif-xlate.h
ofproto/ofproto-dpif.c