datapath: Add mask check during flow lookup
authorAndy Zhou <azhou@nicira.com>
Fri, 19 Jul 2013 18:11:24 +0000 (11:11 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 19 Jul 2013 22:02:05 +0000 (15:02 -0700)
A mega flow matches when the masked key matches and the mask applied
is the same as the mask used to create the mega flow.

This patch adds the implementation of the second match condition
mentioned above. Without this fix, mega flow lookup may result false
match.

Bug #18584

Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
datapath/flow.c

index c766aa2..e2f3c87 100644 (file)
@@ -1046,7 +1046,8 @@ static struct sw_flow *ovs_masked_flow_lookup(struct flow_table *table,
        hash = ovs_flow_hash(&masked_key, key_start, key_len);
        head = find_bucket(table, hash);
        hlist_for_each_entry_rcu(flow, head, hash_node[table->node_ver]) {
-               if (__flow_cmp_key(flow, &masked_key, key_start, key_len))
+               if (flow->mask == mask &&
+                   __flow_cmp_key(flow, &masked_key, key_start, key_len))
                        return flow;
        }
        return NULL;