Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: Const'ify address args to hash helpers.

Signed-off-by: David S. Miller <davem@davemloft.net>

+26 -15
+19 -13
net/xfrm/xfrm_hash.h
··· 4 4 #include <linux/xfrm.h> 5 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 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 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 20 u32 sum = (__force u32)daddr->a4 + (__force u32)saddr->a4; 20 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 27 return ntohl(daddr->a6[2] ^ daddr->a6[3] ^ 26 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 33 u32 reqid, unsigned short family, 31 34 unsigned int hmask) 32 35 { ··· 45 42 return (h ^ (h >> 16)) & hmask; 46 43 } 47 44 48 - static inline unsigned __xfrm_src_hash(xfrm_address_t *daddr, 49 - xfrm_address_t *saddr, 45 + static inline unsigned __xfrm_src_hash(const xfrm_address_t *daddr, 46 + const xfrm_address_t *saddr, 50 47 unsigned short family, 51 48 unsigned int hmask) 52 49 { ··· 63 60 } 64 61 65 62 static inline unsigned int 66 - __xfrm_spi_hash(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family, 67 - unsigned int hmask) 63 + __xfrm_spi_hash(const xfrm_address_t *daddr, __be32 spi, u8 proto, 64 + unsigned short family, unsigned int hmask) 68 65 { 69 66 unsigned int h = (__force u32)spi ^ proto; 70 67 switch (family) { ··· 83 80 return (index ^ (index >> 8)) & hmask; 84 81 } 85 82 86 - static inline unsigned int __sel_hash(struct xfrm_selector *sel, unsigned short family, unsigned int hmask) 83 + static inline unsigned int __sel_hash(const struct xfrm_selector *sel, 84 + unsigned short family, unsigned int hmask) 87 85 { 88 - xfrm_address_t *daddr = &sel->daddr; 89 - xfrm_address_t *saddr = &sel->saddr; 86 + const xfrm_address_t *daddr = &sel->daddr; 87 + const xfrm_address_t *saddr = &sel->saddr; 90 88 unsigned int h = 0; 91 89 92 90 switch (family) { ··· 111 107 return h & hmask; 112 108 } 113 109 114 - static inline unsigned int __addr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr, unsigned short family, unsigned int hmask) 110 + static inline unsigned int __addr_hash(const xfrm_address_t *daddr, 111 + const xfrm_address_t *saddr, 112 + unsigned short family, unsigned int hmask) 115 113 { 116 114 unsigned int h = 0; 117 115
+7 -2
net/xfrm/xfrm_policy.c
··· 311 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 318 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; 317 319 unsigned int hash = __sel_hash(sel, family, hmask); ··· 323 321 net->xfrm.policy_bydst[dir].table + hash); 324 322 } 325 323 326 - static struct hlist_head *policy_hash_direct(struct net *net, xfrm_address_t *daddr, xfrm_address_t *saddr, unsigned short family, int dir) 324 + static struct hlist_head *policy_hash_direct(struct net *net, 325 + const xfrm_address_t *daddr, 326 + const xfrm_address_t *saddr, 327 + unsigned short family, int dir) 327 328 { 328 329 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; 329 330 unsigned int hash = __addr_hash(daddr, saddr, family, hmask);