[ovs-dev] [recirc datapath V4 4/5] datapath: add hash action

Andy Zhou azhou at nicira.com
Fri Apr 18 17:39:54 UTC 2014


On Fri, Apr 18, 2014 at 9:28 AM, Jesse Gross <jesse at nicira.com> wrote:
> On Fri, Apr 18, 2014 at 2:51 AM, Andy Zhou <azhou at nicira.com> wrote:
>> diff --git a/datapath/actions.c b/datapath/actions.c
>> index 82cfd2d..87a8a40 100644
>> --- a/datapath/actions.c
>> +++ b/datapath/actions.c
>> @@ -460,6 +460,20 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
>>                                   nla_len(acts_list), true);
>>  }
>>
>> +static void execute_hash(struct sk_buff *skb, const struct nlattr *attr)
>> +{
>> +       struct sw_flow_key *key = OVS_CB(skb)->pkt_key;
>> +       struct ovs_action_hash *hash_act = nla_data(attr);
>> +       u32 hash = 0;
>> +
>> +       /* OVS_HASH_ALG_L4 is the only possible hash algorithm.  */
>> +       hash = skb_get_rxhash(skb);
>> +       if (!hash)
>> +               hash = 0x1;
>> +
>> +       key->ovs_flow_hash = jhash_1word(hash, hash_act->hash_basis);
>
> I think you need to rehash before the zero check - otherwise after
> rehashing it's possible to have zero again.
Good catch.  Will do.
>
> I don't understand the other change about accepting a hash mask even
> when there isn't a hash value. Can you explain this?
It is not necessary now. I was thinking of the case Pravin suggested that
we do a  masked action.  A hash value may be zero after applying a mask.
In this case, the hash value won't be exported on a post recirculation miss, but
its mask can be supplied on flow installation. We can remove it if this is not
the direction we want to go.



More information about the dev mailing list