Blame view
net/ipv6/xfrm6_tunnel.c
9.71 KB
1ccea77e2 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 |
/* * Copyright (C)2003,2004 USAGI/WIDE Project * |
1da177e4c Linux-2.6.12-rc2 |
5 |
* Authors Mitsuru KANDA <mk@linux-ipv6.org> |
67ba4152e ipv6: White-space... |
6 |
* YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> |
1da177e4c Linux-2.6.12-rc2 |
7 8 |
* * Based on net/ipv4/xfrm4_tunnel.c |
1da177e4c Linux-2.6.12-rc2 |
9 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
10 11 |
#include <linux/module.h> #include <linux/xfrm.h> |
5a0e3ad6a include cleanup: ... |
12 |
#include <linux/slab.h> |
91cc3bb0b xfrm6_tunnel: RCU... |
13 |
#include <linux/rculist.h> |
1da177e4c Linux-2.6.12-rc2 |
14 15 16 |
#include <net/ip.h> #include <net/xfrm.h> #include <net/ipv6.h> |
1da177e4c Linux-2.6.12-rc2 |
17 18 |
#include <linux/ipv6.h> #include <linux/icmpv6.h> |
4a3e2f711 [NET] sem2mutex: ... |
19 |
#include <linux/mutex.h> |
a16647739 netns xfrm: xfrm6... |
20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include <net/netns/generic.h> #define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256 #define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256 #define XFRM6_TUNNEL_SPI_MIN 1 #define XFRM6_TUNNEL_SPI_MAX 0xffffffff struct xfrm6_tunnel_net { struct hlist_head spi_byaddr[XFRM6_TUNNEL_SPI_BYADDR_HSIZE]; struct hlist_head spi_byspi[XFRM6_TUNNEL_SPI_BYSPI_HSIZE]; u32 spi; }; |
c7d03a00b netns: make struc... |
33 |
static unsigned int xfrm6_tunnel_net_id __read_mostly; |
a16647739 netns xfrm: xfrm6... |
34 35 36 37 |
static inline struct xfrm6_tunnel_net *xfrm6_tunnel_pernet(struct net *net) { return net_generic(net, xfrm6_tunnel_net_id); } |
1da177e4c Linux-2.6.12-rc2 |
38 |
|
1da177e4c Linux-2.6.12-rc2 |
39 |
/* |
1ab1457c4 [NET] IPV6: Fix w... |
40 |
* xfrm_tunnel_spi things are for allocating unique id ("spi") |
1da177e4c Linux-2.6.12-rc2 |
41 42 43 |
* per xfrm_address_t. */ struct xfrm6_tunnel_spi { |
91cc3bb0b xfrm6_tunnel: RCU... |
44 45 46 47 |
struct hlist_node list_byaddr; struct hlist_node list_byspi; xfrm_address_t addr; u32 spi; |
d12f3827e net, ipv6: conver... |
48 |
refcount_t refcnt; |
91cc3bb0b xfrm6_tunnel: RCU... |
49 |
struct rcu_head rcu_head; |
1da177e4c Linux-2.6.12-rc2 |
50 |
}; |
91cc3bb0b xfrm6_tunnel: RCU... |
51 |
static DEFINE_SPINLOCK(xfrm6_tunnel_spi_lock); |
1da177e4c Linux-2.6.12-rc2 |
52 |
|
e18b890bb [PATCH] slab: rem... |
53 |
static struct kmem_cache *xfrm6_tunnel_spi_kmem __read_mostly; |
1da177e4c Linux-2.6.12-rc2 |
54 |
|
95c961747 net: cleanup unsi... |
55 |
static inline unsigned int xfrm6_tunnel_spi_hash_byaddr(const xfrm_address_t *addr) |
1da177e4c Linux-2.6.12-rc2 |
56 |
{ |
95c961747 net: cleanup unsi... |
57 |
unsigned int h; |
1da177e4c Linux-2.6.12-rc2 |
58 |
|
2b464f61f ipv6 xfrm: Use ip... |
59 |
h = ipv6_addr_hash((const struct in6_addr *)addr); |
1da177e4c Linux-2.6.12-rc2 |
60 61 62 |
h ^= h >> 16; h ^= h >> 8; h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1; |
1da177e4c Linux-2.6.12-rc2 |
63 64 |
return h; } |
95c961747 net: cleanup unsi... |
65 |
static inline unsigned int xfrm6_tunnel_spi_hash_byspi(u32 spi) |
1da177e4c Linux-2.6.12-rc2 |
66 67 68 |
{ return spi % XFRM6_TUNNEL_SPI_BYSPI_HSIZE; } |
b71d1d426 inet: constify ip... |
69 |
static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr) |
1da177e4c Linux-2.6.12-rc2 |
70 |
{ |
a16647739 netns xfrm: xfrm6... |
71 |
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
1da177e4c Linux-2.6.12-rc2 |
72 |
struct xfrm6_tunnel_spi *x6spi; |
1da177e4c Linux-2.6.12-rc2 |
73 |
|
b67bfe0d4 hlist: drop the n... |
74 |
hlist_for_each_entry_rcu(x6spi, |
a16647739 netns xfrm: xfrm6... |
75 |
&xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], |
edf0d283d ipv6: xfrm6_tunne... |
76 |
list_byaddr, lockdep_is_held(&xfrm6_tunnel_spi_lock)) { |
ff88b30c7 xfrm: Use ipv6_ad... |
77 |
if (xfrm6_addr_equal(&x6spi->addr, saddr)) |
1da177e4c Linux-2.6.12-rc2 |
78 |
return x6spi; |
1da177e4c Linux-2.6.12-rc2 |
79 |
} |
1da177e4c Linux-2.6.12-rc2 |
80 81 |
return NULL; } |
b71d1d426 inet: constify ip... |
82 |
__be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr) |
1da177e4c Linux-2.6.12-rc2 |
83 84 85 |
{ struct xfrm6_tunnel_spi *x6spi; u32 spi; |
91cc3bb0b xfrm6_tunnel: RCU... |
86 |
rcu_read_lock_bh(); |
a16647739 netns xfrm: xfrm6... |
87 |
x6spi = __xfrm6_tunnel_spi_lookup(net, saddr); |
1da177e4c Linux-2.6.12-rc2 |
88 |
spi = x6spi ? x6spi->spi : 0; |
91cc3bb0b xfrm6_tunnel: RCU... |
89 |
rcu_read_unlock_bh(); |
5b1225454 [IPV6]: File the ... |
90 |
return htonl(spi); |
1da177e4c Linux-2.6.12-rc2 |
91 |
} |
1da177e4c Linux-2.6.12-rc2 |
92 |
EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup); |
a16647739 netns xfrm: xfrm6... |
93 |
static int __xfrm6_tunnel_spi_check(struct net *net, u32 spi) |
df8ea19b5 [XFRM] IPV6: Opti... |
94 |
{ |
a16647739 netns xfrm: xfrm6... |
95 |
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
df8ea19b5 [XFRM] IPV6: Opti... |
96 97 |
struct xfrm6_tunnel_spi *x6spi; int index = xfrm6_tunnel_spi_hash_byspi(spi); |
df8ea19b5 [XFRM] IPV6: Opti... |
98 |
|
b67bfe0d4 hlist: drop the n... |
99 |
hlist_for_each_entry(x6spi, |
a16647739 netns xfrm: xfrm6... |
100 |
&xfrm6_tn->spi_byspi[index], |
df8ea19b5 [XFRM] IPV6: Opti... |
101 102 103 104 105 106 |
list_byspi) { if (x6spi->spi == spi) return -1; } return index; } |
a16647739 netns xfrm: xfrm6... |
107 |
static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr) |
1da177e4c Linux-2.6.12-rc2 |
108 |
{ |
a16647739 netns xfrm: xfrm6... |
109 |
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
1da177e4c Linux-2.6.12-rc2 |
110 111 |
u32 spi; struct xfrm6_tunnel_spi *x6spi; |
df8ea19b5 [XFRM] IPV6: Opti... |
112 |
int index; |
1da177e4c Linux-2.6.12-rc2 |
113 |
|
a16647739 netns xfrm: xfrm6... |
114 115 116 |
if (xfrm6_tn->spi < XFRM6_TUNNEL_SPI_MIN || xfrm6_tn->spi >= XFRM6_TUNNEL_SPI_MAX) xfrm6_tn->spi = XFRM6_TUNNEL_SPI_MIN; |
1da177e4c Linux-2.6.12-rc2 |
117 |
else |
a16647739 netns xfrm: xfrm6... |
118 |
xfrm6_tn->spi++; |
1da177e4c Linux-2.6.12-rc2 |
119 |
|
a16647739 netns xfrm: xfrm6... |
120 121 |
for (spi = xfrm6_tn->spi; spi <= XFRM6_TUNNEL_SPI_MAX; spi++) { index = __xfrm6_tunnel_spi_check(net, spi); |
df8ea19b5 [XFRM] IPV6: Opti... |
122 123 |
if (index >= 0) goto alloc_spi; |
fa89a4593 xfrm6_tunnel: Fix... |
124 125 126 |
if (spi == XFRM6_TUNNEL_SPI_MAX) break; |
1da177e4c Linux-2.6.12-rc2 |
127 |
} |
a16647739 netns xfrm: xfrm6... |
128 129 |
for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tn->spi; spi++) { index = __xfrm6_tunnel_spi_check(net, spi); |
df8ea19b5 [XFRM] IPV6: Opti... |
130 131 |
if (index >= 0) goto alloc_spi; |
1da177e4c Linux-2.6.12-rc2 |
132 133 134 135 |
} spi = 0; goto out; alloc_spi: |
a16647739 netns xfrm: xfrm6... |
136 |
xfrm6_tn->spi = spi; |
54e6ecb23 [PATCH] slab: rem... |
137 |
x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, GFP_ATOMIC); |
a922ba551 [IPV6] xfrm6_tunn... |
138 |
if (!x6spi) |
1da177e4c Linux-2.6.12-rc2 |
139 |
goto out; |
a922ba551 [IPV6] xfrm6_tunn... |
140 |
|
1da177e4c Linux-2.6.12-rc2 |
141 142 |
memcpy(&x6spi->addr, saddr, sizeof(x6spi->addr)); x6spi->spi = spi; |
d12f3827e net, ipv6: conver... |
143 |
refcount_set(&x6spi->refcnt, 1); |
1da177e4c Linux-2.6.12-rc2 |
144 |
|
a16647739 netns xfrm: xfrm6... |
145 |
hlist_add_head_rcu(&x6spi->list_byspi, &xfrm6_tn->spi_byspi[index]); |
1da177e4c Linux-2.6.12-rc2 |
146 147 |
index = xfrm6_tunnel_spi_hash_byaddr(saddr); |
a16647739 netns xfrm: xfrm6... |
148 |
hlist_add_head_rcu(&x6spi->list_byaddr, &xfrm6_tn->spi_byaddr[index]); |
1da177e4c Linux-2.6.12-rc2 |
149 |
out: |
1da177e4c Linux-2.6.12-rc2 |
150 151 |
return spi; } |
a16647739 netns xfrm: xfrm6... |
152 |
__be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr) |
1da177e4c Linux-2.6.12-rc2 |
153 154 155 |
{ struct xfrm6_tunnel_spi *x6spi; u32 spi; |
91cc3bb0b xfrm6_tunnel: RCU... |
156 |
spin_lock_bh(&xfrm6_tunnel_spi_lock); |
a16647739 netns xfrm: xfrm6... |
157 |
x6spi = __xfrm6_tunnel_spi_lookup(net, saddr); |
1da177e4c Linux-2.6.12-rc2 |
158 |
if (x6spi) { |
d12f3827e net, ipv6: conver... |
159 |
refcount_inc(&x6spi->refcnt); |
1da177e4c Linux-2.6.12-rc2 |
160 161 |
spi = x6spi->spi; } else |
a16647739 netns xfrm: xfrm6... |
162 |
spi = __xfrm6_tunnel_alloc_spi(net, saddr); |
91cc3bb0b xfrm6_tunnel: RCU... |
163 |
spin_unlock_bh(&xfrm6_tunnel_spi_lock); |
1da177e4c Linux-2.6.12-rc2 |
164 |
|
5b1225454 [IPV6]: File the ... |
165 |
return htonl(spi); |
1da177e4c Linux-2.6.12-rc2 |
166 |
} |
1da177e4c Linux-2.6.12-rc2 |
167 |
EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); |
91cc3bb0b xfrm6_tunnel: RCU... |
168 169 170 171 172 |
static void x6spi_destroy_rcu(struct rcu_head *head) { kmem_cache_free(xfrm6_tunnel_spi_kmem, container_of(head, struct xfrm6_tunnel_spi, rcu_head)); } |
6f747aca5 xfrm6: make xfrm6... |
173 |
static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) |
1da177e4c Linux-2.6.12-rc2 |
174 |
{ |
a16647739 netns xfrm: xfrm6... |
175 |
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
1da177e4c Linux-2.6.12-rc2 |
176 |
struct xfrm6_tunnel_spi *x6spi; |
b67bfe0d4 hlist: drop the n... |
177 |
struct hlist_node *n; |
1da177e4c Linux-2.6.12-rc2 |
178 |
|
91cc3bb0b xfrm6_tunnel: RCU... |
179 |
spin_lock_bh(&xfrm6_tunnel_spi_lock); |
1da177e4c Linux-2.6.12-rc2 |
180 |
|
b67bfe0d4 hlist: drop the n... |
181 |
hlist_for_each_entry_safe(x6spi, n, |
a16647739 netns xfrm: xfrm6... |
182 |
&xfrm6_tn->spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], |
1da177e4c Linux-2.6.12-rc2 |
183 184 |
list_byaddr) { |
ff88b30c7 xfrm: Use ipv6_ad... |
185 |
if (xfrm6_addr_equal(&x6spi->addr, saddr)) { |
d12f3827e net, ipv6: conver... |
186 |
if (refcount_dec_and_test(&x6spi->refcnt)) { |
91cc3bb0b xfrm6_tunnel: RCU... |
187 188 189 |
hlist_del_rcu(&x6spi->list_byaddr); hlist_del_rcu(&x6spi->list_byspi); call_rcu(&x6spi->rcu_head, x6spi_destroy_rcu); |
1da177e4c Linux-2.6.12-rc2 |
190 191 192 193 |
break; } } } |
91cc3bb0b xfrm6_tunnel: RCU... |
194 |
spin_unlock_bh(&xfrm6_tunnel_spi_lock); |
1da177e4c Linux-2.6.12-rc2 |
195 |
} |
1da177e4c Linux-2.6.12-rc2 |
196 197 |
static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) { |
7b277b1a5 [IPSEC]: Set skb-... |
198 |
skb_push(skb, -skb_network_offset(skb)); |
1da177e4c Linux-2.6.12-rc2 |
199 200 |
return 0; } |
e695633e2 [IPSEC]: Kill unu... |
201 |
static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
202 |
{ |
04663d0b8 [IPSEC]: Fix pure... |
203 |
return skb_network_header(skb)[IP6CB(skb)->nhoff]; |
1da177e4c Linux-2.6.12-rc2 |
204 |
} |
d2acc3479 [INET]: Introduce... |
205 |
static int xfrm6_tunnel_rcv(struct sk_buff *skb) |
1da177e4c Linux-2.6.12-rc2 |
206 |
{ |
a16647739 netns xfrm: xfrm6... |
207 |
struct net *net = dev_net(skb->dev); |
b71d1d426 inet: constify ip... |
208 |
const struct ipv6hdr *iph = ipv6_hdr(skb); |
a252cc237 [XFRM]: xrfm_repl... |
209 |
__be32 spi; |
1da177e4c Linux-2.6.12-rc2 |
210 |
|
b71d1d426 inet: constify ip... |
211 |
spi = xfrm6_tunnel_spi_lookup(net, (const xfrm_address_t *)&iph->saddr); |
63c43787d vti6: fix input path |
212 |
return xfrm6_rcv_spi(skb, IPPROTO_IPV6, spi, NULL); |
1da177e4c Linux-2.6.12-rc2 |
213 |
} |
d2acc3479 [INET]: Introduce... |
214 |
static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt, |
d5fdd6bab ipv6: Use correct... |
215 |
u8 type, u8 code, int offset, __be32 info) |
1da177e4c Linux-2.6.12-rc2 |
216 |
{ |
1da177e4c Linux-2.6.12-rc2 |
217 218 |
/* xfrm6_tunnel native err handling */ switch (type) { |
1ab1457c4 [NET] IPV6: Fix w... |
219 |
case ICMPV6_DEST_UNREACH: |
1da177e4c Linux-2.6.12-rc2 |
220 |
switch (code) { |
1ab1457c4 [NET] IPV6: Fix w... |
221 |
case ICMPV6_NOROUTE: |
1da177e4c Linux-2.6.12-rc2 |
222 223 224 225 226 |
case ICMPV6_ADM_PROHIBITED: case ICMPV6_NOT_NEIGHBOUR: case ICMPV6_ADDR_UNREACH: case ICMPV6_PORT_UNREACH: default: |
1da177e4c Linux-2.6.12-rc2 |
227 228 229 230 |
break; } break; case ICMPV6_PKT_TOOBIG: |
1da177e4c Linux-2.6.12-rc2 |
231 232 233 234 |
break; case ICMPV6_TIME_EXCEED: switch (code) { case ICMPV6_EXC_HOPLIMIT: |
1da177e4c Linux-2.6.12-rc2 |
235 236 |
break; case ICMPV6_EXC_FRAGTIME: |
1ab1457c4 [NET] IPV6: Fix w... |
237 |
default: |
1da177e4c Linux-2.6.12-rc2 |
238 239 240 241 242 243 244 245 246 247 248 249 250 |
break; } break; case ICMPV6_PARAMPROB: switch (code) { case ICMPV6_HDR_FIELD: break; case ICMPV6_UNK_NEXTHDR: break; case ICMPV6_UNK_OPTION: break; } break; default: break; } |
d2acc3479 [INET]: Introduce... |
251 252 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
253 |
} |
72cb6962a [IPSEC]: Add xfrm... |
254 |
static int xfrm6_tunnel_init_state(struct xfrm_state *x) |
1da177e4c Linux-2.6.12-rc2 |
255 |
{ |
7e49e6de3 [XFRM]: Add XFRM_... |
256 |
if (x->props.mode != XFRM_MODE_TUNNEL) |
1da177e4c Linux-2.6.12-rc2 |
257 258 259 260 261 262 263 264 265 266 267 268 |
return -EINVAL; if (x->encap) return -EINVAL; x->props.header_len = sizeof(struct ipv6hdr); return 0; } static void xfrm6_tunnel_destroy(struct xfrm_state *x) { |
a16647739 netns xfrm: xfrm6... |
269 270 271 |
struct net *net = xs_net(x); xfrm6_tunnel_free_spi(net, (xfrm_address_t *)&x->props.saddr); |
1da177e4c Linux-2.6.12-rc2 |
272 |
} |
533cb5b0a [XFRM]: constify ... |
273 |
static const struct xfrm_type xfrm6_tunnel_type = { |
1da177e4c Linux-2.6.12-rc2 |
274 275 276 277 278 279 280 281 |
.description = "IP6IP6", .owner = THIS_MODULE, .proto = IPPROTO_IPV6, .init_state = xfrm6_tunnel_init_state, .destructor = xfrm6_tunnel_destroy, .input = xfrm6_tunnel_input, .output = xfrm6_tunnel_output, }; |
3ff2cfa55 ipv6: struct xfrm... |
282 |
static struct xfrm6_tunnel xfrm6_tunnel_handler __read_mostly = { |
1da177e4c Linux-2.6.12-rc2 |
283 |
.handler = xfrm6_tunnel_rcv, |
d2acc3479 [INET]: Introduce... |
284 |
.err_handler = xfrm6_tunnel_err, |
7fe94612d xfrm: interface: ... |
285 |
.priority = 3, |
1da177e4c Linux-2.6.12-rc2 |
286 |
}; |
3ff2cfa55 ipv6: struct xfrm... |
287 |
static struct xfrm6_tunnel xfrm46_tunnel_handler __read_mostly = { |
73d605d1a [IPSEC]: changing... |
288 289 |
.handler = xfrm6_tunnel_rcv, .err_handler = xfrm6_tunnel_err, |
7fe94612d xfrm: interface: ... |
290 |
.priority = 3, |
73d605d1a [IPSEC]: changing... |
291 |
}; |
a16647739 netns xfrm: xfrm6... |
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
static int __net_init xfrm6_tunnel_net_init(struct net *net) { struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); unsigned int i; for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++) INIT_HLIST_HEAD(&xfrm6_tn->spi_byaddr[i]); for (i = 0; i < XFRM6_TUNNEL_SPI_BYSPI_HSIZE; i++) INIT_HLIST_HEAD(&xfrm6_tn->spi_byspi[i]); xfrm6_tn->spi = 0; return 0; } static void __net_exit xfrm6_tunnel_net_exit(struct net *net) { |
baeb0dbbb xfrm6_tunnel: exi... |
308 309 |
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); unsigned int i; |
b48c05ab5 xfrm: Fix warning... |
310 |
xfrm_flush_gc(); |
dbb2483b2 xfrm: clean up xf... |
311 |
xfrm_state_flush(net, 0, false, true); |
b48c05ab5 xfrm: Fix warning... |
312 |
|
baeb0dbbb xfrm6_tunnel: exi... |
313 314 315 316 317 |
for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++) WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byaddr[i])); for (i = 0; i < XFRM6_TUNNEL_SPI_BYSPI_HSIZE; i++) WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byspi[i])); |
a16647739 netns xfrm: xfrm6... |
318 319 320 321 322 323 324 325 |
} static struct pernet_operations xfrm6_tunnel_net_ops = { .init = xfrm6_tunnel_net_init, .exit = xfrm6_tunnel_net_exit, .id = &xfrm6_tunnel_net_id, .size = sizeof(struct xfrm6_tunnel_net), }; |
1da177e4c Linux-2.6.12-rc2 |
326 327 |
static int __init xfrm6_tunnel_init(void) { |
e924960da netns xfrm: fixup... |
328 |
int rv; |
d5aa407f5 tunnels: fix netn... |
329 330 331 332 333 334 335 336 337 |
xfrm6_tunnel_spi_kmem = kmem_cache_create("xfrm6_tunnel_spi", sizeof(struct xfrm6_tunnel_spi), 0, SLAB_HWCACHE_ALIGN, NULL); if (!xfrm6_tunnel_spi_kmem) return -ENOMEM; rv = register_pernet_subsys(&xfrm6_tunnel_net_ops); if (rv < 0) goto out_pernet; |
e924960da netns xfrm: fixup... |
338 339 |
rv = xfrm_register_type(&xfrm6_tunnel_type, AF_INET6); if (rv < 0) |
d5aa407f5 tunnels: fix netn... |
340 |
goto out_type; |
e924960da netns xfrm: fixup... |
341 342 |
rv = xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6); if (rv < 0) |
d5aa407f5 tunnels: fix netn... |
343 |
goto out_xfrm6; |
e924960da netns xfrm: fixup... |
344 345 |
rv = xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET); if (rv < 0) |
d5aa407f5 tunnels: fix netn... |
346 |
goto out_xfrm46; |
1da177e4c Linux-2.6.12-rc2 |
347 |
return 0; |
5ce1bbb97 xfrm6_tunnel: joi... |
348 |
|
d5aa407f5 tunnels: fix netn... |
349 |
out_xfrm46: |
5ce1bbb97 xfrm6_tunnel: joi... |
350 |
xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); |
d5aa407f5 tunnels: fix netn... |
351 |
out_xfrm6: |
5ce1bbb97 xfrm6_tunnel: joi... |
352 |
xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
d5aa407f5 tunnels: fix netn... |
353 354 355 356 |
out_type: unregister_pernet_subsys(&xfrm6_tunnel_net_ops); out_pernet: kmem_cache_destroy(xfrm6_tunnel_spi_kmem); |
e924960da netns xfrm: fixup... |
357 |
return rv; |
1da177e4c Linux-2.6.12-rc2 |
358 359 360 361 |
} static void __exit xfrm6_tunnel_fini(void) { |
73d605d1a [IPSEC]: changing... |
362 363 |
xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET); xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); |
a922ba551 [IPV6] xfrm6_tunn... |
364 |
xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
d5aa407f5 tunnels: fix netn... |
365 |
unregister_pernet_subsys(&xfrm6_tunnel_net_ops); |
6ee02a54e xfrm6_tunnel: Fix... |
366 367 368 369 |
/* Someone maybe has gotten the xfrm6_tunnel_spi. * So need to wait it. */ rcu_barrier(); |
d5aa407f5 tunnels: fix netn... |
370 |
kmem_cache_destroy(xfrm6_tunnel_spi_kmem); |
1da177e4c Linux-2.6.12-rc2 |
371 372 373 374 375 |
} module_init(xfrm6_tunnel_init); module_exit(xfrm6_tunnel_fini); MODULE_LICENSE("GPL"); |
d3d6dd3ad [XFRM]: Add modul... |
376 |
MODULE_ALIAS_XFRM_TYPE(AF_INET6, XFRM_PROTO_IPV6); |