Subject: Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses

From: Chuck Lever <[email-masked]>
Date: Thu, 09 Aug 2007 11:14:45 -0400

Aurélien Charbon wrote:
>>> @@ -112,12 +112,16 @@
>>>      return (hash ^ (hash>>8)) & 0xff;
>>>  }
>>>  #endif
>>> +static inline int hash_ip6(struct in6_addr ip)
>>> +{
>>> +        return (hash_ip(ip.s6_addr32[0]) ^ hash_ip(ip.s6_addr32[1]) 
>>> ^ hash_ip(ip.s6_addr32[2]) ^ hash_ip(ip.s6_addr32[3])) ;
>>> +}
>>
>>
>> How have you tested the effectiveness of the new hash function?
> 
> I have not tested that point but I can easily imagine there are better 
> solutions.
> Perhaps we can keep the same function for an IPv4 address (only taking 
> the 32 bits of IPv4 addr), and then design one for IPv6 addresses.

I see that, to generate the hash, you would be xor-ing the FF and 00 
bytes in the canonicalized IPv4 address.  Yes, perhaps a better function 
is needed, or as you say, one specifically for IPv6 and one for 
canonicalized IPv4.

> Do you have any suggestion on that ?

I don't have anything specific, but you may find something useful if you 
poke around elsewhere under net/.