revalidator: Eliminate duplicate flow handling.
authorJoe Stringer <joestringer@nicira.com>
Wed, 28 May 2014 00:39:51 +0000 (12:39 +1200)
committerJoe Stringer <joestringer@nicira.com>
Wed, 28 May 2014 02:08:44 +0000 (14:08 +1200)
commitfc9765d075833328695cc971d75200b2bfee87d9
treeae91cfdc7317d2a0ef82281f75b58a3b35dca7d8
parentb94e8ba3a9e8df26c408a0a156665c205e4dde2a
revalidator: Eliminate duplicate flow handling.

A series of bugs have been identified recently that are caused by a
combination of the awkward flow dump API, possibility of duplicate flows
in a flow dump, and premature optimisation of the revalidator logic.
This patch attempts to simplify the revalidator logic by combining
multiple critical sections into one, which should make the state more
consistent.

The new flow of logic is:
+ Lookup the ukey.
+ If the ukey doesn't exist, create it.
+ Insert the ukey into the udpif. If we can't insert it, skip this flow.
+ Lock the ukey. If we can't lock it, skip it.
+ Determine if the ukey was already handled. If it has, skip it.
+ Revalidate.
+ Update ukey's fields (mark, flow_exists).
+ Unlock the ukey.

Previously, we would attempt process a flow without creating a ukey if
it hadn't been dumped before and it was due to be deleted. This patch
changes this to always create a ukey, allowing the ukey's
mutex to be used as the basis for preventing a flow from being handled
twice. This is expected to cause some minor performance regression for
cases like TCP_CRR, in favour of correctness and readability.

Bug #1252997.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
ofproto/ofproto-dpif-upcall.c