diff options
| author | Len Brown <len.brown@intel.com> | 2006-01-06 16:34:21 -0500 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2006-01-06 16:34:21 -0500 |
| commit | 25da0974601fc8096461f3d3f7ca3aab8e79adfb (patch) | |
| tree | f9b3c1bfbc63fdb6a94e82177b8c3ae891125422 /net/sunrpc/svcauth_unix.c | |
| parent | 036d25f79ddfbc9878da24ef8e468a6d22caa605 (diff) | |
| parent | d99cf9d679a520d67f81d805b7cb91c68e1847f0 (diff) | |
Auto-update from upstream
Diffstat (limited to 'net/sunrpc/svcauth_unix.c')
| -rw-r--r-- | net/sunrpc/svcauth_unix.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index cac2e774dd81..3e6c694bbad1 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/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) { |
