diff options
Diffstat (limited to 'net/ipv6/xfrm6_tunnel.c')
-rw-r--r-- | net/ipv6/xfrm6_tunnel.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index d6f9aeec69f7..ddce21e3459b 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c | |||
@@ -84,23 +84,6 @@ static inline unsigned xfrm6_tunnel_spi_hash_byspi(u32 spi) | |||
84 | return spi % XFRM6_TUNNEL_SPI_BYSPI_HSIZE; | 84 | return spi % XFRM6_TUNNEL_SPI_BYSPI_HSIZE; |
85 | } | 85 | } |
86 | 86 | ||
87 | |||
88 | static int __init xfrm6_tunnel_spi_init(void) | ||
89 | { | ||
90 | xfrm6_tunnel_spi_kmem = kmem_cache_create("xfrm6_tunnel_spi", | ||
91 | sizeof(struct xfrm6_tunnel_spi), | ||
92 | 0, SLAB_HWCACHE_ALIGN, | ||
93 | NULL); | ||
94 | if (!xfrm6_tunnel_spi_kmem) | ||
95 | return -ENOMEM; | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static void xfrm6_tunnel_spi_fini(void) | ||
100 | { | ||
101 | kmem_cache_destroy(xfrm6_tunnel_spi_kmem); | ||
102 | } | ||
103 | |||
104 | static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr) | 87 | static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr) |
105 | { | 88 | { |
106 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); | 89 | struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
@@ -375,42 +358,44 @@ static int __init xfrm6_tunnel_init(void) | |||
375 | { | 358 | { |
376 | int rv; | 359 | int rv; |
377 | 360 | ||
361 | xfrm6_tunnel_spi_kmem = kmem_cache_create("xfrm6_tunnel_spi", | ||
362 | sizeof(struct xfrm6_tunnel_spi), | ||
363 | 0, SLAB_HWCACHE_ALIGN, | ||
364 | NULL); | ||
365 | if (!xfrm6_tunnel_spi_kmem) | ||
366 | return -ENOMEM; | ||
367 | rv = register_pernet_subsys(&xfrm6_tunnel_net_ops); | ||
368 | if (rv < 0) | ||
369 | goto out_pernet; | ||
378 | rv = xfrm_register_type(&xfrm6_tunnel_type, AF_INET6); | 370 | rv = xfrm_register_type(&xfrm6_tunnel_type, AF_INET6); |
379 | if (rv < 0) | 371 | if (rv < 0) |
380 | goto err; | 372 | goto out_type; |
381 | rv = xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6); | 373 | rv = xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6); |
382 | if (rv < 0) | 374 | if (rv < 0) |
383 | goto unreg; | 375 | goto out_xfrm6; |
384 | rv = xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET); | 376 | rv = xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET); |
385 | if (rv < 0) | 377 | if (rv < 0) |
386 | goto dereg6; | 378 | goto out_xfrm46; |
387 | rv = xfrm6_tunnel_spi_init(); | ||
388 | if (rv < 0) | ||
389 | goto dereg46; | ||
390 | rv = register_pernet_subsys(&xfrm6_tunnel_net_ops); | ||
391 | if (rv < 0) | ||
392 | goto deregspi; | ||
393 | return 0; | 379 | return 0; |
394 | 380 | ||
395 | deregspi: | 381 | out_xfrm46: |
396 | xfrm6_tunnel_spi_fini(); | ||
397 | dereg46: | ||
398 | xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET); | ||
399 | dereg6: | ||
400 | xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); | 382 | xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); |
401 | unreg: | 383 | out_xfrm6: |
402 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); | 384 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
403 | err: | 385 | out_type: |
386 | unregister_pernet_subsys(&xfrm6_tunnel_net_ops); | ||
387 | out_pernet: | ||
388 | kmem_cache_destroy(xfrm6_tunnel_spi_kmem); | ||
404 | return rv; | 389 | return rv; |
405 | } | 390 | } |
406 | 391 | ||
407 | static void __exit xfrm6_tunnel_fini(void) | 392 | static void __exit xfrm6_tunnel_fini(void) |
408 | { | 393 | { |
409 | unregister_pernet_subsys(&xfrm6_tunnel_net_ops); | ||
410 | xfrm6_tunnel_spi_fini(); | ||
411 | xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET); | 394 | xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET); |
412 | xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); | 395 | xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6); |
413 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); | 396 | xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); |
397 | unregister_pernet_subsys(&xfrm6_tunnel_net_ops); | ||
398 | kmem_cache_destroy(xfrm6_tunnel_spi_kmem); | ||
414 | } | 399 | } |
415 | 400 | ||
416 | module_init(xfrm6_tunnel_init); | 401 | module_init(xfrm6_tunnel_init); |