diff options
author | David S. Miller <davem@davemloft.net> | 2011-02-24 00:33:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-24 02:07:42 -0500 |
commit | 5f803b58cd8528a93fbb72fa7b011547e7b1a310 (patch) | |
tree | fcd3e700440ad0be7ace178783d0bbd8b0181ba1 /net/xfrm | |
parent | 183cad12785ffc036571c4b789dc084ec61a1bad (diff) |
xfrm: Const'ify address args to hash helpers.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_hash.h | 32 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 9 |
2 files changed, 26 insertions, 15 deletions
diff --git a/net/xfrm/xfrm_hash.h b/net/xfrm/xfrm_hash.h index 8e69533d2313..7199d78b2aa1 100644 --- a/net/xfrm/xfrm_hash.h +++ b/net/xfrm/xfrm_hash.h | |||
@@ -4,29 +4,32 @@ | |||
4 | #include <linux/xfrm.h> | 4 | #include <linux/xfrm.h> |
5 | #include <linux/socket.h> | 5 | #include <linux/socket.h> |
6 | 6 | ||
7 | static inline unsigned int __xfrm4_addr_hash(xfrm_address_t *addr) | 7 | static inline unsigned int __xfrm4_addr_hash(const xfrm_address_t *addr) |
8 | { | 8 | { |
9 | return ntohl(addr->a4); | 9 | return ntohl(addr->a4); |
10 | } | 10 | } |
11 | 11 | ||
12 | static inline unsigned int __xfrm6_addr_hash(xfrm_address_t *addr) | 12 | static inline unsigned int __xfrm6_addr_hash(const xfrm_address_t *addr) |
13 | { | 13 | { |
14 | return ntohl(addr->a6[2] ^ addr->a6[3]); | 14 | return ntohl(addr->a6[2] ^ addr->a6[3]); |
15 | } | 15 | } |
16 | 16 | ||
17 | static inline unsigned int __xfrm4_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr) | 17 | static inline unsigned int __xfrm4_daddr_saddr_hash(const xfrm_address_t *daddr, |
18 | const xfrm_address_t *saddr) | ||
18 | { | 19 | { |
19 | u32 sum = (__force u32)daddr->a4 + (__force u32)saddr->a4; | 20 | u32 sum = (__force u32)daddr->a4 + (__force u32)saddr->a4; |
20 | return ntohl((__force __be32)sum); | 21 | return ntohl((__force __be32)sum); |
21 | } | 22 | } |
22 | 23 | ||
23 | static inline unsigned int __xfrm6_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr) | 24 | static inline unsigned int __xfrm6_daddr_saddr_hash(const xfrm_address_t *daddr, |
25 | const xfrm_address_t *saddr) | ||
24 | { | 26 | { |
25 | return ntohl(daddr->a6[2] ^ daddr->a6[3] ^ | 27 | return ntohl(daddr->a6[2] ^ daddr->a6[3] ^ |
26 | saddr->a6[2] ^ saddr->a6[3]); | 28 | saddr->a6[2] ^ saddr->a6[3]); |
27 | } | 29 | } |
28 | 30 | ||
29 | static inline unsigned int __xfrm_dst_hash(xfrm_address_t *daddr, xfrm_address_t *saddr, | 31 | static inline unsigned int __xfrm_dst_hash(const xfrm_address_t *daddr, |
32 | const xfrm_address_t *saddr, | ||
30 | u32 reqid, unsigned short family, | 33 | u32 reqid, unsigned short family, |
31 | unsigned int hmask) | 34 | unsigned int hmask) |
32 | { | 35 | { |
@@ -42,8 +45,8 @@ static inline unsigned int __xfrm_dst_hash(xfrm_address_t *daddr, xfrm_address_t | |||
42 | return (h ^ (h >> 16)) & hmask; | 45 | return (h ^ (h >> 16)) & hmask; |
43 | } | 46 | } |
44 | 47 | ||
45 | static inline unsigned __xfrm_src_hash(xfrm_address_t *daddr, | 48 | static inline unsigned __xfrm_src_hash(const xfrm_address_t *daddr, |
46 | xfrm_address_t *saddr, | 49 | const xfrm_address_t *saddr, |
47 | unsigned short family, | 50 | unsigned short family, |
48 | unsigned int hmask) | 51 | unsigned int hmask) |
49 | { | 52 | { |
@@ -60,8 +63,8 @@ static inline unsigned __xfrm_src_hash(xfrm_address_t *daddr, | |||
60 | } | 63 | } |
61 | 64 | ||
62 | static inline unsigned int | 65 | static inline unsigned int |
63 | __xfrm_spi_hash(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family, | 66 | __xfrm_spi_hash(const xfrm_address_t *daddr, __be32 spi, u8 proto, |
64 | unsigned int hmask) | 67 | unsigned short family, unsigned int hmask) |
65 | { | 68 | { |
66 | unsigned int h = (__force u32)spi ^ proto; | 69 | unsigned int h = (__force u32)spi ^ proto; |
67 | switch (family) { | 70 | switch (family) { |
@@ -80,10 +83,11 @@ static inline unsigned int __idx_hash(u32 index, unsigned int hmask) | |||
80 | return (index ^ (index >> 8)) & hmask; | 83 | return (index ^ (index >> 8)) & hmask; |
81 | } | 84 | } |
82 | 85 | ||
83 | static inline unsigned int __sel_hash(struct xfrm_selector *sel, unsigned short family, unsigned int hmask) | 86 | static inline unsigned int __sel_hash(const struct xfrm_selector *sel, |
87 | unsigned short family, unsigned int hmask) | ||
84 | { | 88 | { |
85 | xfrm_address_t *daddr = &sel->daddr; | 89 | const xfrm_address_t *daddr = &sel->daddr; |
86 | xfrm_address_t *saddr = &sel->saddr; | 90 | const xfrm_address_t *saddr = &sel->saddr; |
87 | unsigned int h = 0; | 91 | unsigned int h = 0; |
88 | 92 | ||
89 | switch (family) { | 93 | switch (family) { |
@@ -107,7 +111,9 @@ static inline unsigned int __sel_hash(struct xfrm_selector *sel, unsigned short | |||
107 | return h & hmask; | 111 | return h & hmask; |
108 | } | 112 | } |
109 | 113 | ||
110 | static inline unsigned int __addr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr, unsigned short family, unsigned int hmask) | 114 | static inline unsigned int __addr_hash(const xfrm_address_t *daddr, |
115 | const xfrm_address_t *saddr, | ||
116 | unsigned short family, unsigned int hmask) | ||
111 | { | 117 | { |
112 | unsigned int h = 0; | 118 | unsigned int h = 0; |
113 | 119 | ||
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index eb76da74dfa4..0770b3ae5ccb 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -311,7 +311,9 @@ static inline unsigned int idx_hash(struct net *net, u32 index) | |||
311 | return __idx_hash(index, net->xfrm.policy_idx_hmask); | 311 | return __idx_hash(index, net->xfrm.policy_idx_hmask); |
312 | } | 312 | } |
313 | 313 | ||
314 | static struct hlist_head *policy_hash_bysel(struct net *net, struct xfrm_selector *sel, unsigned short family, int dir) | 314 | static struct hlist_head *policy_hash_bysel(struct net *net, |
315 | const struct xfrm_selector *sel, | ||
316 | unsigned short family, int dir) | ||
315 | { | 317 | { |
316 | unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; | 318 | unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; |
317 | unsigned int hash = __sel_hash(sel, family, hmask); | 319 | unsigned int hash = __sel_hash(sel, family, hmask); |
@@ -321,7 +323,10 @@ static struct hlist_head *policy_hash_bysel(struct net *net, struct xfrm_selecto | |||
321 | net->xfrm.policy_bydst[dir].table + hash); | 323 | net->xfrm.policy_bydst[dir].table + hash); |
322 | } | 324 | } |
323 | 325 | ||
324 | static struct hlist_head *policy_hash_direct(struct net *net, xfrm_address_t *daddr, xfrm_address_t *saddr, unsigned short family, int dir) | 326 | static struct hlist_head *policy_hash_direct(struct net *net, |
327 | const xfrm_address_t *daddr, | ||
328 | const xfrm_address_t *saddr, | ||
329 | unsigned short family, int dir) | ||
325 | { | 330 | { |
326 | unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; | 331 | unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; |
327 | unsigned int hash = __addr_hash(daddr, saddr, family, hmask); | 332 | unsigned int hash = __addr_hash(daddr, saddr, family, hmask); |