[ovs-dev] Question about miniflow_hash in lib/flow.c
kmindg at gmail.com
Mon Feb 10 03:29:16 UTC 2014
On Sun, Feb 9, 2014 at 9:56 AM, Jarno Rajahalme <jrajahalme at nicira.com> wrote:
>> On Feb 8, 2014, at 12:49 AM, Kmindg G <kmindg at gmail.com> wrote:
>> Hi all,
>> I have a little question about miniflow_hash().
>> At the end of miniflow_hash, "p - flow->values" is used as the second
>> paramter of mhash_finish. But "p - flow->valuse" is not the number of
>> bytes which has been added to hash in miniflow_hash. The second
>> parameter should be "sizeof hash_map + count_1bits(hash_map) * sizeof
>> Is this a real problem or I'm missing something?
> It is not a real problem. The reason for adding the count of bytes at the finishing step is to differentiate between inputs of different lengths that would otherwise be made the same due to zero padding to 32 bits.
> Miniflows are always a multiple of 32 bits, so any consistent value for the given input is fine.
Thanks for explanation.
>> diff --git a/lib/flow.c b/lib/flow.c
>> index 06ba036..dc6f4b8 100644
>> --- a/lib/flow.c
>> +++ b/lib/flow.c
>> @@ -1680,7 +1680,8 @@ miniflow_hash(const struct miniflow *flow, uint32_t basis)
>> hash = mhash_add(hash, hash_map);
>> hash = mhash_add(hash, hash_map >> 32);
>> - return mhash_finish(hash, p - flow->values);
>> + return mhash_finish(hash,
>> + sizeof hash_map + count_1bits(hash_map) * sizeof *p);
>> dev mailing list
>> dev at openvswitch.org
More information about the dev