提交 4806126d 编写于 作者: A Al Viro 提交者: David S. Miller

[SUNRPC]: annotate hash_ip()

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8a74ff77
...@@ -101,9 +101,9 @@ static void ip_map_put(struct kref *kref) ...@@ -101,9 +101,9 @@ static void ip_map_put(struct kref *kref)
* IP addresses in reverse-endian (i.e. on a little-endian machine). * IP addresses in reverse-endian (i.e. on a little-endian machine).
* So use a trivial but reliable hash instead * So use a trivial but reliable hash instead
*/ */
static inline int hash_ip(unsigned long ip) static inline int hash_ip(__be32 ip)
{ {
int hash = ip ^ (ip>>16); int hash = (__force u32)ip ^ ((__force u32)ip>>16);
return (hash ^ (hash>>8)) & 0xff; return (hash ^ (hash>>8)) & 0xff;
} }
#endif #endif
...@@ -284,7 +284,7 @@ static struct ip_map *ip_map_lookup(char *class, struct in_addr addr) ...@@ -284,7 +284,7 @@ static struct ip_map *ip_map_lookup(char *class, struct in_addr addr)
ip.m_addr = addr; ip.m_addr = addr;
ch = sunrpc_cache_lookup(&ip_map_cache, &ip.h, ch = sunrpc_cache_lookup(&ip_map_cache, &ip.h,
hash_str(class, IP_HASHBITS) ^ hash_str(class, IP_HASHBITS) ^
hash_ip((unsigned long)addr.s_addr)); hash_ip(addr.s_addr));
if (ch) if (ch)
return container_of(ch, struct ip_map, h); return container_of(ch, struct ip_map, h);
...@@ -313,7 +313,7 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex ...@@ -313,7 +313,7 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex
ch = sunrpc_cache_update(&ip_map_cache, ch = sunrpc_cache_update(&ip_map_cache,
&ip.h, &ipm->h, &ip.h, &ipm->h,
hash_str(ipm->m_class, IP_HASHBITS) ^ hash_str(ipm->m_class, IP_HASHBITS) ^
hash_ip((unsigned long)ipm->m_addr.s_addr)); hash_ip(ipm->m_addr.s_addr));
if (!ch) if (!ch)
return -ENOMEM; return -ENOMEM;
cache_put(ch, &ip_map_cache); cache_put(ch, &ip_map_cache);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册