[ovs-dev] [PATCH v2] datapath: Use currect rcu API in exact match flow lookup function.

Pravin Shelar pshelar at nicira.com
Mon Jul 28 19:38:53 UTC 2014


On Mon, Jul 28, 2014 at 11:46 AM, Andy Zhou <azhou at nicira.com> wrote:
> Does unmasked_key also not memset to zero, like key? if yes, is there
> a possibility of mismatch when calling
> ovs_flow_cmp_unmasked_key?
>
unmasked_key is always memset to zero before building the key from
netlink attributes.

> On Sun, Jul 27, 2014 at 11:55 AM, Pravin B Shelar <pshelar at nicira.com> wrote:
>> Exact match flow lookup is always done under ovs lock. So use
>> ovsl_dereference() API for rcu access.
>>
>> Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
>> ---
>>  datapath/flow_table.c | 17 +++++++----------
>>  1 file changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/datapath/flow_table.c b/datapath/flow_table.c
>> index 21f67bf..cfd5a84 100644
>> --- a/datapath/flow_table.c
>> +++ b/datapath/flow_table.c
>> @@ -666,23 +666,20 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,
>>  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;
>> +       struct mask_array *ma = ovsl_dereference(tbl->mask_array);
>>         int i;
>>
>>         /* Always called under ovs-mutex. */
>>         for (i = 0; i < ma->count; i++) {
>> +               struct table_instance *ti = ovsl_dereference(tbl->ti);
>> +               u32 __always_unused n_mask_hit;
>>                 struct sw_flow_mask *mask;
>> +               struct sw_flow *flow;
>>
>>                 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;
>> -                       }
>> -               }
>> +               flow = masked_flow_lookup(ti, match->key, mask, &n_mask_hit);
>> +               if (flow && ovs_flow_cmp_unmasked_key(flow, match))
>> +                       return flow;
>>         }
>>         return NULL;
>>  }
>> --
>> 1.9.3
>>
>> _______________________________________________
>> dev mailing list
>> dev at openvswitch.org
>> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list