datapath: Hold mutex for DP while userspace is blocking on read.
authorJesse Gross <jesse@nicira.com>
Wed, 8 Dec 2010 21:19:05 +0000 (13:19 -0800)
committerJesse Gross <jesse@nicira.com>
Fri, 10 Dec 2010 01:43:37 +0000 (17:43 -0800)
commite22d4953ec00df611fff0fd36ac81087c63e1d1e
treeba4b17872eb5516e7debf1785976145767735231
parentdad80ec3088c787d3fd876e8d3d11ad7b3f0f11b
datapath: Hold mutex for DP while userspace is blocking on read.

Currently we get a pointer to the DP in openvswitch_read() and
openvswitch_poll() and use it without any synchronization.  This means
that the DP could disappear from underneath us while we are using it.
Currently, this isn't a problem because userspace is single threaded but
it's better for the locking to be correct.

With this change we hold the mutex while doing a blocking wait, which
means that no changes can be made, including adding/removing flows.  It's
possible to make this finer grained but for the time being that isn't done,
since current userspace doesn't care.

Found with lockdep.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c