From 37c08785f6f21261981a4f7415178c8b001d6eba Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:09:49 -0800 Subject: [PATCH] --- yaml --- r: 16291 b: refs/heads/master c: 1f1e030bf75774b6a283518e1534d598e14147d4 h: refs/heads/master i: 16289: 441c921189d176a21935b380b951bcebb3d6eff2 16287: 97a6b7ed60624cb864daa4155b15147e167b629d v: v3 --- [refs] | 2 +- trunk/net/sunrpc/svcauth_unix.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index de5e6f4e3754..043dbabd97e7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 4b2f0260c74324abca76ccaa42d426af163125e7 +refs/heads/master: 1f1e030bf75774b6a283518e1534d598e14147d4 diff --git a/trunk/net/sunrpc/svcauth_unix.c b/trunk/net/sunrpc/svcauth_unix.c index cac2e774dd81..3e6c694bbad1 100644 --- a/trunk/net/sunrpc/svcauth_unix.c +++ b/trunk/net/sunrpc/svcauth_unix.c @@ -101,10 +101,22 @@ static void ip_map_put(struct cache_head *item, struct cache_detail *cd) } } +#if IP_HASHBITS == 8 +/* hash_long on a 64 bit machine is currently REALLY BAD for + * IP addresses in reverse-endian (i.e. on a little-endian machine). + * So use a trivial but reliable hash instead + */ +static inline int hash_ip(unsigned long ip) +{ + int hash = ip ^ (ip>>16); + return (hash ^ (hash>>8)) & 0xff; +} +#endif + static inline int ip_map_hash(struct ip_map *item) { return hash_str(item->m_class, IP_HASHBITS) ^ - hash_long((unsigned long)item->m_addr.s_addr, IP_HASHBITS); + hash_ip((unsigned long)item->m_addr.s_addr); } static inline int ip_map_match(struct ip_map *item, struct ip_map *tmp) {