aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-03-18 17:05:33 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-18 22:00:34 -0400
commit6eada0110c8984477f5f1e57a0b7f7b2fc841e30 (patch)
treeb7f6118fe6d137d56a2264fb81a8f5718236abb9
parent8f6320de5f6a817ba360be6ae39f721c7f9b26fb (diff)
netns: constify net_hash_mix() and various callers
const qualifiers ease code review by making clear which objects are not written in a function. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/udp.h2
-rw-r--r--include/net/inet_hashtables.h6
-rw-r--r--include/net/netns/hash.h4
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/inet_hashtables.c6
-rw-r--r--net/ipv4/ping.c6
-rw-r--r--net/ipv4/udp.c10
-rw-r--r--net/ipv6/inet6_hashtables.c10
-rw-r--r--net/ipv6/udp.c16
9 files changed, 31 insertions, 31 deletions
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 247cfdcc4b08..87c094961bd5 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -34,7 +34,7 @@ static inline struct udphdr *inner_udp_hdr(const struct sk_buff *skb)
34 34
35#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256) 35#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256)
36 36
37static inline int udp_hashfn(struct net *net, unsigned num, unsigned mask) 37static inline u32 udp_hashfn(const struct net *net, u32 num, u32 mask)
38{ 38{
39 return (num + net_hash_mix(net)) & mask; 39 return (num + net_hash_mix(net)) & mask;
40} 40}
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index bcd64756e5fe..eb1963af0ebd 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -221,8 +221,8 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net,
221void inet_bind_bucket_destroy(struct kmem_cache *cachep, 221void inet_bind_bucket_destroy(struct kmem_cache *cachep,
222 struct inet_bind_bucket *tb); 222 struct inet_bind_bucket *tb);
223 223
224static inline int inet_bhashfn(struct net *net, const __u16 lport, 224static inline u32 inet_bhashfn(const struct net *net, const __u16 lport,
225 const int bhash_size) 225 const u32 bhash_size)
226{ 226{
227 return (lport + net_hash_mix(net)) & (bhash_size - 1); 227 return (lport + net_hash_mix(net)) & (bhash_size - 1);
228} 228}
@@ -231,7 +231,7 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
231 const unsigned short snum); 231 const unsigned short snum);
232 232
233/* These can have wildcards, don't try too hard. */ 233/* These can have wildcards, don't try too hard. */
234static inline int inet_lhashfn(struct net *net, const unsigned short num) 234static inline u32 inet_lhashfn(const struct net *net, const unsigned short num)
235{ 235{
236 return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1); 236 return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1);
237} 237}
diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h
index c06ac58ca107..69a6715d9f3f 100644
--- a/include/net/netns/hash.h
+++ b/include/net/netns/hash.h
@@ -5,7 +5,7 @@
5 5
6struct net; 6struct net;
7 7
8static inline unsigned int net_hash_mix(struct net *net) 8static inline u32 net_hash_mix(const struct net *net)
9{ 9{
10#ifdef CONFIG_NET_NS 10#ifdef CONFIG_NET_NS
11 /* 11 /*
@@ -13,7 +13,7 @@ static inline unsigned int net_hash_mix(struct net *net)
13 * always zeroed 13 * always zeroed
14 */ 14 */
15 15
16 return (unsigned)(((unsigned long)net) >> L1_CACHE_SHIFT); 16 return (u32)(((unsigned long)net) >> L1_CACHE_SHIFT);
17#else 17#else
18 return 0; 18 return 0;
19#endif 19#endif
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 5105759e4e00..375dc71b9a64 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -107,7 +107,7 @@ static const struct nla_policy ifa_ipv4_policy[IFA_MAX+1] = {
107 107
108static struct hlist_head inet_addr_lst[IN4_ADDR_HSIZE]; 108static struct hlist_head inet_addr_lst[IN4_ADDR_HSIZE];
109 109
110static u32 inet_addr_hash(struct net *net, __be32 addr) 110static u32 inet_addr_hash(const struct net *net, __be32 addr)
111{ 111{
112 u32 val = (__force u32) addr ^ net_hash_mix(net); 112 u32 val = (__force u32) addr ^ net_hash_mix(net);
113 113
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index c28bca4cc15b..330a08bcd1c1 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -24,9 +24,9 @@
24#include <net/secure_seq.h> 24#include <net/secure_seq.h>
25#include <net/ip.h> 25#include <net/ip.h>
26 26
27static unsigned int inet_ehashfn(struct net *net, const __be32 laddr, 27static u32 inet_ehashfn(const struct net *net, const __be32 laddr,
28 const __u16 lport, const __be32 faddr, 28 const __u16 lport, const __be32 faddr,
29 const __be16 fport) 29 const __be16 fport)
30{ 30{
31 static u32 inet_ehash_secret __read_mostly; 31 static u32 inet_ehash_secret __read_mostly;
32 32
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index fd88f868776f..344e7cdfb8d4 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -64,11 +64,11 @@ EXPORT_SYMBOL_GPL(pingv6_ops);
64 64
65static u16 ping_port_rover; 65static u16 ping_port_rover;
66 66
67static inline int ping_hashfn(struct net *net, unsigned int num, unsigned int mask) 67static inline u32 ping_hashfn(const struct net *net, u32 num, u32 mask)
68{ 68{
69 int res = (num + net_hash_mix(net)) & mask; 69 u32 res = (num + net_hash_mix(net)) & mask;
70 70
71 pr_debug("hash(%d) = %d\n", num, res); 71 pr_debug("hash(%u) = %u\n", num, res);
72 return res; 72 return res;
73} 73}
74EXPORT_SYMBOL_GPL(ping_hash); 74EXPORT_SYMBOL_GPL(ping_hash);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f27556e2158b..294af16633af 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -318,8 +318,8 @@ static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
318 inet1->inet_rcv_saddr == inet2->inet_rcv_saddr)); 318 inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
319} 319}
320 320
321static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr, 321static u32 udp4_portaddr_hash(const struct net *net, __be32 saddr,
322 unsigned int port) 322 unsigned int port)
323{ 323{
324 return jhash_1word((__force u32)saddr, net_hash_mix(net)) ^ port; 324 return jhash_1word((__force u32)saddr, net_hash_mix(net)) ^ port;
325} 325}
@@ -421,9 +421,9 @@ static inline int compute_score2(struct sock *sk, struct net *net,
421 return score; 421 return score;
422} 422}
423 423
424static unsigned int udp_ehashfn(struct net *net, const __be32 laddr, 424static u32 udp_ehashfn(const struct net *net, const __be32 laddr,
425 const __u16 lport, const __be32 faddr, 425 const __u16 lport, const __be32 faddr,
426 const __be16 fport) 426 const __be16 fport)
427{ 427{
428 static u32 udp_ehash_secret __read_mostly; 428 static u32 udp_ehash_secret __read_mostly;
429 429
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 051dffb49c90..df7df99d1d7e 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -23,11 +23,11 @@
23#include <net/secure_seq.h> 23#include <net/secure_seq.h>
24#include <net/ip.h> 24#include <net/ip.h>
25 25
26static unsigned int inet6_ehashfn(struct net *net, 26static u32 inet6_ehashfn(const struct net *net,
27 const struct in6_addr *laddr, 27 const struct in6_addr *laddr,
28 const u16 lport, 28 const u16 lport,
29 const struct in6_addr *faddr, 29 const struct in6_addr *faddr,
30 const __be16 fport) 30 const __be16 fport)
31{ 31{
32 static u32 inet6_ehash_secret __read_mostly; 32 static u32 inet6_ehash_secret __read_mostly;
33 static u32 ipv6_hash_secret __read_mostly; 33 static u32 ipv6_hash_secret __read_mostly;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 70568a4548e4..7fe0329c0d37 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -53,11 +53,11 @@
53#include <trace/events/skb.h> 53#include <trace/events/skb.h>
54#include "udp_impl.h" 54#include "udp_impl.h"
55 55
56static unsigned int udp6_ehashfn(struct net *net, 56static u32 udp6_ehashfn(const struct net *net,
57 const struct in6_addr *laddr, 57 const struct in6_addr *laddr,
58 const u16 lport, 58 const u16 lport,
59 const struct in6_addr *faddr, 59 const struct in6_addr *faddr,
60 const __be16 fport) 60 const __be16 fport)
61{ 61{
62 static u32 udp6_ehash_secret __read_mostly; 62 static u32 udp6_ehash_secret __read_mostly;
63 static u32 udp_ipv6_hash_secret __read_mostly; 63 static u32 udp_ipv6_hash_secret __read_mostly;
@@ -104,9 +104,9 @@ int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
104 return 0; 104 return 0;
105} 105}
106 106
107static unsigned int udp6_portaddr_hash(struct net *net, 107static u32 udp6_portaddr_hash(const struct net *net,
108 const struct in6_addr *addr6, 108 const struct in6_addr *addr6,
109 unsigned int port) 109 unsigned int port)
110{ 110{
111 unsigned int hash, mix = net_hash_mix(net); 111 unsigned int hash, mix = net_hash_mix(net);
112 112