]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
netns: constify net_hash_mix() and various callers
authorEric Dumazet <edumazet@google.com>
Wed, 18 Mar 2015 21:05:33 +0000 (14:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Mar 2015 02:00:34 +0000 (22:00 -0400)
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>
include/linux/udp.h
include/net/inet_hashtables.h
include/net/netns/hash.h
net/ipv4/devinet.c
net/ipv4/inet_hashtables.c
net/ipv4/ping.c
net/ipv4/udp.c
net/ipv6/inet6_hashtables.c
net/ipv6/udp.c

index 247cfdcc4b08bbf377ff5819ebd02683806b0c83..87c094961bd5867a3a4bc7e83e6db7a38c2397cf 100644 (file)
@@ -34,7 +34,7 @@ static inline struct udphdr *inner_udp_hdr(const struct sk_buff *skb)
 
 #define UDP_HTABLE_SIZE_MIN            (CONFIG_BASE_SMALL ? 128 : 256)
 
-static inline int udp_hashfn(struct net *net, unsigned num, unsigned mask)
+static inline u32 udp_hashfn(const struct net *net, u32 num, u32 mask)
 {
        return (num + net_hash_mix(net)) & mask;
 }
index bcd64756e5fe7f8a05bbdb8c3de0d5a554ecb9d8..eb1963af0ebd27f15ce1fe4935fdbd9cf3db0f79 100644 (file)
@@ -221,8 +221,8 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net,
 void inet_bind_bucket_destroy(struct kmem_cache *cachep,
                              struct inet_bind_bucket *tb);
 
-static inline int inet_bhashfn(struct net *net, const __u16 lport,
-                              const int bhash_size)
+static inline u32 inet_bhashfn(const struct net *net, const __u16 lport,
+                              const u32 bhash_size)
 {
        return (lport + net_hash_mix(net)) & (bhash_size - 1);
 }
@@ -231,7 +231,7 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
                    const unsigned short snum);
 
 /* These can have wildcards, don't try too hard. */
-static inline int inet_lhashfn(struct net *net, const unsigned short num)
+static inline u32 inet_lhashfn(const struct net *net, const unsigned short num)
 {
        return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1);
 }
index c06ac58ca107c1a11f9d3a479efe86fe3cc9a4dc..69a6715d9f3fd16c9a6e90f9be403ba0cba1f022 100644 (file)
@@ -5,7 +5,7 @@
 
 struct net;
 
-static inline unsigned int net_hash_mix(struct net *net)
+static inline u32 net_hash_mix(const struct net *net)
 {
 #ifdef CONFIG_NET_NS
        /*
@@ -13,7 +13,7 @@ static inline unsigned int net_hash_mix(struct net *net)
         * always zeroed
         */
 
-       return (unsigned)(((unsigned long)net) >> L1_CACHE_SHIFT);
+       return (u32)(((unsigned long)net) >> L1_CACHE_SHIFT);
 #else
        return 0;
 #endif
index 5105759e4e00a5d4b7812bd6d7e098c7fb298506..375dc71b9a642d3ca856264c41f605f09aeedc50 100644 (file)
@@ -107,7 +107,7 @@ static const struct nla_policy ifa_ipv4_policy[IFA_MAX+1] = {
 
 static struct hlist_head inet_addr_lst[IN4_ADDR_HSIZE];
 
-static u32 inet_addr_hash(struct net *net, __be32 addr)
+static u32 inet_addr_hash(const struct net *net, __be32 addr)
 {
        u32 val = (__force u32) addr ^ net_hash_mix(net);
 
index c28bca4cc15bfef44bed4938d6af9db9aa4500dc..330a08bcd1c12eaeb4ac83c7ff4c532cce3173aa 100644 (file)
@@ -24,9 +24,9 @@
 #include <net/secure_seq.h>
 #include <net/ip.h>
 
-static unsigned int inet_ehashfn(struct net *net, const __be32 laddr,
-                                const __u16 lport, const __be32 faddr,
-                                const __be16 fport)
+static u32 inet_ehashfn(const struct net *net, const __be32 laddr,
+                       const __u16 lport, const __be32 faddr,
+                       const __be16 fport)
 {
        static u32 inet_ehash_secret __read_mostly;
 
index fd88f868776f822ed198764b27fff6716457ef7a..344e7cdfb8d40a91b3d8fd0eff0da96a14370922 100644 (file)
@@ -64,11 +64,11 @@ EXPORT_SYMBOL_GPL(pingv6_ops);
 
 static u16 ping_port_rover;
 
-static inline int ping_hashfn(struct net *net, unsigned int num, unsigned int mask)
+static inline u32 ping_hashfn(const struct net *net, u32 num, u32 mask)
 {
-       int res = (num + net_hash_mix(net)) & mask;
+       u32 res = (num + net_hash_mix(net)) & mask;
 
-       pr_debug("hash(%d) = %d\n", num, res);
+       pr_debug("hash(%u) = %u\n", num, res);
        return res;
 }
 EXPORT_SYMBOL_GPL(ping_hash);
index f27556e2158b08097c1b515b7f1b607c433b26e7..294af16633af63d87f5dfd2b1e28b15ce799fa61 100644 (file)
@@ -318,8 +318,8 @@ static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
                   inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
 }
 
-static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
-                                      unsigned int port)
+static u32 udp4_portaddr_hash(const struct net *net, __be32 saddr,
+                             unsigned int port)
 {
        return jhash_1word((__force u32)saddr, net_hash_mix(net)) ^ port;
 }
@@ -421,9 +421,9 @@ static inline int compute_score2(struct sock *sk, struct net *net,
        return score;
 }
 
-static unsigned int udp_ehashfn(struct net *net, const __be32 laddr,
-                                const __u16 lport, const __be32 faddr,
-                                const __be16 fport)
+static u32 udp_ehashfn(const struct net *net, const __be32 laddr,
+                      const __u16 lport, const __be32 faddr,
+                      const __be16 fport)
 {
        static u32 udp_ehash_secret __read_mostly;
 
index 051dffb49c90e979ca6cc58dd1c2cd2fe9b1cc4c..df7df99d1d7eb4f7b1a8acda2e4d44d3bac24992 100644 (file)
 #include <net/secure_seq.h>
 #include <net/ip.h>
 
-static unsigned int inet6_ehashfn(struct net *net,
-                                 const struct in6_addr *laddr,
-                                 const u16 lport,
-                                 const struct in6_addr *faddr,
-                                 const __be16 fport)
+static u32 inet6_ehashfn(const struct net *net,
+                        const struct in6_addr *laddr,
+                        const u16 lport,
+                        const struct in6_addr *faddr,
+                        const __be16 fport)
 {
        static u32 inet6_ehash_secret __read_mostly;
        static u32 ipv6_hash_secret __read_mostly;
index 70568a4548e4b54d5a883a3bb2837dac6717c8f4..7fe0329c0d37875d41ac8e1d385cbaadecd0927f 100644 (file)
 #include <trace/events/skb.h>
 #include "udp_impl.h"
 
-static unsigned int udp6_ehashfn(struct net *net,
-                                 const struct in6_addr *laddr,
-                                 const u16 lport,
-                                 const struct in6_addr *faddr,
-                                 const __be16 fport)
+static u32 udp6_ehashfn(const struct net *net,
+                       const struct in6_addr *laddr,
+                       const u16 lport,
+                       const struct in6_addr *faddr,
+                       const __be16 fport)
 {
        static u32 udp6_ehash_secret __read_mostly;
        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)
        return 0;
 }
 
-static unsigned int udp6_portaddr_hash(struct net *net,
-                                      const struct in6_addr *addr6,
-                                      unsigned int port)
+static u32 udp6_portaddr_hash(const struct net *net,
+                             const struct in6_addr *addr6,
+                             unsigned int port)
 {
        unsigned int hash, mix = net_hash_mix(net);