datapath: Use exact lookup for flow_get and flow_del.
[cascardo/ovs.git] / datapath / flow_table.c
index 9746822..9ab1020 100644 (file)
@@ -682,10 +682,33 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,
        u32 __always_unused n_mask_hit;
        u32 __always_unused index;
 
-       n_mask_hit = 0;
        return flow_lookup(tbl, ti, ma, key, &n_mask_hit, &index);
 }
 
+struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl,
+                                         struct sw_flow_match *match)
+{
+       struct table_instance *ti = rcu_dereference_ovsl(tbl->ti);
+       struct mask_array *ma = rcu_dereference_ovsl(tbl->mask_array);
+       struct sw_flow *flow;
+       u32 __always_unused n_mask_hit;
+       int i;
+
+       /* Always called under ovs-mutex. */
+       for (i = 0; i < ma->count; i++) {
+               struct sw_flow_mask *mask;
+
+               mask = ovsl_dereference(ma->masks[i]);
+               if (mask) {
+                       flow = masked_flow_lookup(ti, match->key, mask, &n_mask_hit);
+                       if (flow && ovs_flow_cmp_unmasked_key(flow, match)) { /* Found */
+                               return flow;
+                       }
+               }
+       }
+       return NULL;
+}
+
 int ovs_flow_tbl_num_masks(const struct flow_table *table)
 {
        struct mask_array *ma;