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/xfrm_hash.h | |
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/xfrm_hash.h')
-rw-r--r-- | net/xfrm/xfrm_hash.h | 32 |
1 files changed, 19 insertions, 13 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 | ||