diff options
Diffstat (limited to 'net/ipv6/xfrm6_tunnel.c')
-rw-r--r-- | net/ipv6/xfrm6_tunnel.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index ee5a7065aacc..de2bcfaaf759 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c | |||
@@ -72,7 +72,7 @@ static inline unsigned int xfrm6_tunnel_spi_hash_byaddr(const xfrm_address_t *ad | |||
72 | { | 72 | { |
73 | unsigned int h; | 73 | unsigned int h; |
74 | 74 | ||
75 | h = (__force u32)(addr->a6[0] ^ addr->a6[1] ^ addr->a6[2] ^ addr->a6[3]); | 75 | h = ipv6_addr_hash((const struct in6_addr *)addr); |
76 | h ^= h >> 16; | 76 | h ^= h >> 16; |
77 | h ^= h >> 8; | 77 | h ^= h >> 8; |
78 | h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1; | 78 | h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1; |
@@ -89,12 +89,11 @@ static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, const | |||
89 | { | 89 | { |
90 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); | 90 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
91 | struct xfrm6_tunnel_spi *x6spi; | 91 | struct xfrm6_tunnel_spi *x6spi; |
92 | struct hlist_node *pos; | ||
93 | 92 | ||
94 | hlist_for_each_entry_rcu(x6spi, pos, | 93 | hlist_for_each_entry_rcu(x6spi, |
95 | &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], | 94 | &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], |
96 | list_byaddr) { | 95 | list_byaddr) { |
97 | if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0) | 96 | if (xfrm6_addr_equal(&x6spi->addr, saddr)) |
98 | return x6spi; | 97 | return x6spi; |
99 | } | 98 | } |
100 | 99 | ||
@@ -120,9 +119,8 @@ static int __xfrm6_tunnel_spi_check(struct net *net, u32 spi) | |||
120 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); | 119 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
121 | struct xfrm6_tunnel_spi *x6spi; | 120 | struct xfrm6_tunnel_spi *x6spi; |
122 | int index = xfrm6_tunnel_spi_hash_byspi(spi); | 121 | int index = xfrm6_tunnel_spi_hash_byspi(spi); |
123 | struct hlist_node *pos; | ||
124 | 122 | ||
125 | hlist_for_each_entry(x6spi, pos, | 123 | hlist_for_each_entry(x6spi, |
126 | &xfrm6_tn->spi_byspi[index], | 124 | &xfrm6_tn->spi_byspi[index], |
127 | list_byspi) { | 125 | list_byspi) { |
128 | if (x6spi->spi == spi) | 126 | if (x6spi->spi == spi) |
@@ -203,15 +201,15 @@ static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) | |||
203 | { | 201 | { |
204 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); | 202 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
205 | struct xfrm6_tunnel_spi *x6spi; | 203 | struct xfrm6_tunnel_spi *x6spi; |
206 | struct hlist_node *pos, *n; | 204 | struct hlist_node *n; |
207 | 205 | ||
208 | spin_lock_bh(&xfrm6_tunnel_spi_lock); | 206 | spin_lock_bh(&xfrm6_tunnel_spi_lock); |
209 | 207 | ||
210 | hlist_for_each_entry_safe(x6spi, pos, n, | 208 | hlist_for_each_entry_safe(x6spi, n, |
211 | &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], | 209 | &xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], |
212 | list_byaddr) | 210 | list_byaddr) |
213 | { | 211 | { |
214 | if (memcmp(&x6spi->addr, saddr, sizeof(x6spi->addr)) == 0) { | 212 | if (xfrm6_addr_equal(&x6spi->addr, saddr)) { |
215 | if (atomic_dec_and_test(&x6spi->refcnt)) { | 213 | if (atomic_dec_and_test(&x6spi->refcnt)) { |
216 | hlist_del_rcu(&x6spi->list_byaddr); | 214 | hlist_del_rcu(&x6spi->list_byaddr); |
217 | hlist_del_rcu(&x6spi->list_byspi); | 215 | hlist_del_rcu(&x6spi->list_byspi); |