diff options
| author | James Morris <jmorris@intercode.com.au> | 2003-05-02 20:01:33 -0700 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2003-05-02 20:01:33 -0700 |
| commit | df5432ba285560e807afdf607643a7fadbf3727a (patch) | |
| tree | 0e58b860726594f06e4557ee465e4db3d67b54b1 | |
| parent | 43ee006165c42532fc141a501fa2fc4a2b6a614a (diff) | |
[NET]: Cosmetic cleanups of jhash code.
- Consistent naming (i.e. jhash_xxx)
- Reduces the 2&1 word variants to call jhash_3words()
- Replaces __inline__ with inline.
| -rw-r--r-- | include/linux/jhash.h | 32 | ||||
| -rw-r--r-- | net/ipv4/netfilter/ip_conntrack_core.c | 10 | ||||
| -rw-r--r-- | net/ipv4/route.c | 2 | ||||
| -rw-r--r-- | net/ipv4/tcp_ipv4.c | 3 | ||||
| -rw-r--r-- | net/ipv6/tcp_ipv6.c | 7 |
5 files changed, 16 insertions, 38 deletions
diff --git a/include/linux/jhash.h b/include/linux/jhash.h index ef973bb2a6c1..83f6af2ebcaa 100644 --- a/include/linux/jhash.h +++ b/include/linux/jhash.h @@ -41,7 +41,7 @@ * of bytes. No alignment or length assumptions are made about * the input key. */ -static __inline__ u32 jenkins_hash(void *key, u32 length, u32 initval) +static inline u32 jhash(void *key, u32 length, u32 initval) { u32 a, b, c, len; u8 *k = key; @@ -84,7 +84,7 @@ static __inline__ u32 jenkins_hash(void *key, u32 length, u32 initval) /* A special optimized version that handles 1 or more of u32s. * The length parameter here is the number of u32s in the key. */ -static __inline__ u32 hash2(u32 *k, u32 length, u32 initval) +static inline u32 jhash2(u32 *k, u32 length, u32 initval) { u32 a, b, c, len; @@ -119,8 +119,7 @@ static __inline__ u32 hash2(u32 *k, u32 length, u32 initval) * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally * done at the end is not done here. */ -static __inline__ u32 jenkins_hash_3words(u32 a, u32 b, u32 c, - u32 initval) +static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) { a += JHASH_GOLDEN_RATIO; b += JHASH_GOLDEN_RATIO; @@ -131,31 +130,14 @@ static __inline__ u32 jenkins_hash_3words(u32 a, u32 b, u32 c, return c; } -static __inline__ u32 jenkins_hash_2words(u32 a, u32 b, u32 initval) +static inline u32 jhash_2words(u32 a, u32 b, u32 initval) { - u32 c = 0; - - a += JHASH_GOLDEN_RATIO; - b += JHASH_GOLDEN_RATIO; - c += initval; - - __jhash_mix(a, b, c); - - return c; + return jhash_3words(a, b, 0, initval); } -static __inline__ u32 jenkins_hash_1word(u32 a, u32 initval) +static inline u32 jhash_1word(u32 a, u32 initval) { - u32 b = 0; - u32 c = 0; - - a += JHASH_GOLDEN_RATIO; - b += JHASH_GOLDEN_RATIO; - c += initval; - - __jhash_mix(a, b, c); - - return c; + return jhash_3words(a, 0, 0, initval); } #endif /* _LINUX_JHASH_H */ diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index 9b0a6c03d0fe..48aea8927526 100644 --- a/net/ipv4/netfilter/ip_conntrack_core.c +++ b/net/ipv4/netfilter/ip_conntrack_core.c @@ -115,12 +115,10 @@ hash_conntrack(const struct ip_conntrack_tuple *tuple) #if 0 dump_tuple(tuple); #endif - return (jenkins_hash_3words(tuple->src.ip, - (tuple->dst.ip ^ tuple->dst.protonum), - (tuple->src.u.all | - (tuple->dst.u.all << 16)), - ip_conntrack_hash_rnd) - % ip_conntrack_htable_size); + return (jhash_3words(tuple->src.ip, + (tuple->dst.ip ^ tuple->dst.protonum), + (tuple->src.u.all | (tuple->dst.u.all << 16)), + ip_conntrack_hash_rnd) % ip_conntrack_htable_size); } int diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 04a008ddcad9..92cc3175c771 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -207,7 +207,7 @@ static int rt_intern_hash(unsigned hash, struct rtable *rth, static unsigned int rt_hash_code(u32 daddr, u32 saddr, u8 tos) { - return (jenkins_hash_3words(daddr, saddr, (u32) tos, rt_hash_rnd) + return (jhash_3words(daddr, saddr, (u32) tos, rt_hash_rnd) & rt_hash_mask); } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index dc49f3b05003..65b4b06b8de0 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -886,8 +886,7 @@ static __inline__ int tcp_v4_iif(struct sk_buff *skb) static __inline__ u32 tcp_v4_synq_hash(u32 raddr, u16 rport, u32 rnd) { - return (jenkins_hash_2words(raddr, (u32) rport, rnd) - & (TCP_SYNQ_HSIZE - 1)); + return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); } static struct open_request *tcp_v4_search_req(struct tcp_opt *tp, diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d436c304b4c9..e86144cea433 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -390,10 +390,9 @@ __inline__ struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport, static u32 tcp_v6_synq_hash(struct in6_addr *raddr, u16 rport, u32 rnd) { - return (jenkins_hash_3words(raddr->s6_addr32[0] ^ raddr->s6_addr32[1], - raddr->s6_addr32[2] ^ raddr->s6_addr32[3], - (u32) rport, rnd) - & (TCP_SYNQ_HSIZE - 1)); + return (jhash_3words(raddr->s6_addr32[0] ^ raddr->s6_addr32[1], + raddr->s6_addr32[2] ^ raddr->s6_addr32[3], + (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); } static struct open_request *tcp_v6_search_req(struct tcp_opt *tp, |
