[ovs-dev] [murmurhash 2/4] hash: Correct implementation of mhash_finish().

Ben Pfaff blp at nicira.com
Tue Jan 15 21:26:57 UTC 2013


I noticed it because, without it, making murmurhash the default hash
function caused unit test failures in e.g. "row hashing (scalars)".

We really have a remarkably paranoid testsuite in some ways.

On Tue, Jan 15, 2013 at 01:21:37PM -0800, Ethan Jackson wrote:
> How did you notice this problem? Did the hash unit tests catch it?  If
> not, could we extend them in some way so that they would?
> 
> Acked-by: Ethan Jackson <ethan at nicira.com>
> 
> 
> On Fri, Dec 14, 2012 at 4:33 PM, Ben Pfaff <blp at nicira.com> wrote:
> > With rotates instead of shifts, the upper and lower 16 bits of the returned
> > hash are always the same.
> >
> > Signed-off-by: Ben Pfaff <blp at nicira.com>
> > ---
> >  lib/hash.h |    6 +++---
> >  1 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/hash.h b/lib/hash.h
> > index 701e686..96866c4 100644
> > --- a/lib/hash.h
> > +++ b/lib/hash.h
> > @@ -152,11 +152,11 @@ static inline uint32_t mhash_add(uint32_t hash, uint32_t data)
> >  static inline uint32_t mhash_finish(uint32_t hash, size_t n)
> >  {
> >      hash ^= n * 4;
> > -    hash ^= hash_rot(hash, 16);
> > +    hash ^= hash >> 16;
> >      hash *= 0x85ebca6b;
> > -    hash ^= hash_rot(hash, 13);
> > +    hash ^= hash >> 13;
> >      hash *= 0xc2b2ae35;
> > -    hash ^= hash_rot(hash, 16);
> > +    hash ^= hash >> 16;
> >      return hash;
> >  }
> >
> > --
> > 1.7.2.5
> >
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list