Commit 44716493 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Modularise xfrm_tunnel.

This patch allows the the user to build xfrm4_tunnel/xfrm6_tunnel as
modules.

This makes sense because they're only used by IPComp/IPIP/IP6Tunnel
which are modules themselves.  It also means that distros can cut
down on there core kernel size when compiling with IPsec support.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent c4a88af9
...@@ -792,8 +792,6 @@ extern void xfrm4_state_init(void); ...@@ -792,8 +792,6 @@ extern void xfrm4_state_init(void);
extern void xfrm4_state_fini(void); extern void xfrm4_state_fini(void);
extern void xfrm6_state_init(void); extern void xfrm6_state_init(void);
extern void xfrm6_state_fini(void); extern void xfrm6_state_fini(void);
extern void xfrm6_tunnel_init(void);
extern void xfrm6_tunnel_fini(void);
extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *);
extern struct xfrm_state *xfrm_state_alloc(void); extern struct xfrm_state *xfrm_state_alloc(void);
......
...@@ -187,7 +187,7 @@ config IP_PNP_RARP ...@@ -187,7 +187,7 @@ config IP_PNP_RARP
config NET_IPIP config NET_IPIP
tristate "IP: tunneling" tristate "IP: tunneling"
depends on INET depends on INET
select XFRM select INET_TUNNEL
---help--- ---help---
Tunneling means encapsulating data of one protocol type within Tunneling means encapsulating data of one protocol type within
another protocol and sending it over a channel that understands the another protocol and sending it over a channel that understands the
...@@ -351,6 +351,7 @@ config INET_ESP ...@@ -351,6 +351,7 @@ config INET_ESP
config INET_IPCOMP config INET_IPCOMP
tristate "IP: IPComp transformation" tristate "IP: IPComp transformation"
select XFRM select XFRM
select INET_TUNNEL
select CRYPTO select CRYPTO
select CRYPTO_DEFLATE select CRYPTO_DEFLATE
---help--- ---help---
...@@ -359,5 +360,14 @@ config INET_IPCOMP ...@@ -359,5 +360,14 @@ config INET_IPCOMP
If unsure, say Y. If unsure, say Y.
config INET_TUNNEL
tristate "IP: tunnel transformation"
select XFRM
---help---
Support for generic IP tunnel transformation, which is required by
the IP tunneling module as well as tunnel mode IPComp.
If unsure, say Y.
source "net/ipv4/ipvs/Kconfig" source "net/ipv4/ipvs/Kconfig"
...@@ -19,9 +19,10 @@ obj-$(CONFIG_SYN_COOKIES) += syncookies.o ...@@ -19,9 +19,10 @@ obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_INET_AH) += ah4.o obj-$(CONFIG_INET_AH) += ah4.o
obj-$(CONFIG_INET_ESP) += esp4.o obj-$(CONFIG_INET_ESP) += esp4.o
obj-$(CONFIG_INET_IPCOMP) += ipcomp.o obj-$(CONFIG_INET_IPCOMP) += ipcomp.o
obj-$(CONFIG_INET_TUNNEL) += xfrm4_tunnel.o
obj-$(CONFIG_IP_PNP) += ipconfig.o obj-$(CONFIG_IP_PNP) += ipconfig.o
obj-$(CONFIG_NETFILTER) += netfilter/ obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_IP_VS) += ipvs/ obj-$(CONFIG_IP_VS) += ipvs/
obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
xfrm4_tunnel.o xfrm4_output.o xfrm4_output.o
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/module.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/protocol.h> #include <net/protocol.h>
...@@ -43,6 +44,8 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler) ...@@ -43,6 +44,8 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler)
return ret; return ret;
} }
EXPORT_SYMBOL(xfrm4_tunnel_register);
int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler) int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler)
{ {
int ret; int ret;
...@@ -60,6 +63,8 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler) ...@@ -60,6 +63,8 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler)
return ret; return ret;
} }
EXPORT_SYMBOL(xfrm4_tunnel_deregister);
static int ipip_rcv(struct sk_buff *skb) static int ipip_rcv(struct sk_buff *skb)
{ {
struct xfrm_tunnel *handler = ipip_handler; struct xfrm_tunnel *handler = ipip_handler;
......
...@@ -48,6 +48,7 @@ config INET6_IPCOMP ...@@ -48,6 +48,7 @@ config INET6_IPCOMP
tristate "IPv6: IPComp transformation" tristate "IPv6: IPComp transformation"
depends on IPV6 depends on IPV6
select XFRM select XFRM
select INET6_TUNNEL
select CRYPTO select CRYPTO
select CRYPTO_DEFLATE select CRYPTO_DEFLATE
---help--- ---help---
...@@ -56,10 +57,21 @@ config INET6_IPCOMP ...@@ -56,10 +57,21 @@ config INET6_IPCOMP
If unsure, say Y. If unsure, say Y.
config INET6_TUNNEL
tristate "IPv6: tunnel transformation"
depends on IPV6
select XFRM
---help---
Support for generic IPv6-in-IPv6 tunnel transformation, which is
required by the IPv6-in-IPv6 tunneling module as well as tunnel mode
IPComp.
If unsure, say Y.
config IPV6_TUNNEL config IPV6_TUNNEL
tristate "IPv6: IPv6-in-IPv6 tunnel" tristate "IPv6: IPv6-in-IPv6 tunnel"
depends on IPV6 depends on IPV6
select XFRM select INET6_TUNNEL
---help--- ---help---
Support for IPv6-in-IPv6 tunnels described in RFC 2473. Support for IPv6-in-IPv6 tunnels described in RFC 2473.
......
...@@ -11,12 +11,13 @@ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \ ...@@ -11,12 +11,13 @@ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \
ip6_flowlabel.o ipv6_syms.o ip6_flowlabel.o ipv6_syms.o
ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \ ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \
xfrm6_tunnel.o xfrm6_output.o xfrm6_output.o
ipv6-objs += $(ipv6-y) ipv6-objs += $(ipv6-y)
obj-$(CONFIG_INET6_AH) += ah6.o obj-$(CONFIG_INET6_AH) += ah6.o
obj-$(CONFIG_INET6_ESP) += esp6.o obj-$(CONFIG_INET6_ESP) += esp6.o
obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o
obj-$(CONFIG_INET6_TUNNEL) += xfrm6_tunnel.o
obj-$(CONFIG_NETFILTER) += netfilter/ obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
......
...@@ -287,12 +287,10 @@ void __init xfrm6_init(void) ...@@ -287,12 +287,10 @@ void __init xfrm6_init(void)
{ {
xfrm6_policy_init(); xfrm6_policy_init();
xfrm6_state_init(); xfrm6_state_init();
xfrm6_tunnel_init();
} }
void __exit xfrm6_fini(void) void __exit xfrm6_fini(void)
{ {
xfrm6_tunnel_fini();
//xfrm6_input_fini(); //xfrm6_input_fini();
xfrm6_policy_fini(); xfrm6_policy_fini();
xfrm6_state_fini(); xfrm6_state_fini();
......
...@@ -501,31 +501,32 @@ static struct inet6_protocol xfrm6_tunnel_protocol = { ...@@ -501,31 +501,32 @@ static struct inet6_protocol xfrm6_tunnel_protocol = {
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
}; };
void __init xfrm6_tunnel_init(void) static int __init xfrm6_tunnel_init(void)
{ {
X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__); X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
if (xfrm_register_type(&xfrm6_tunnel_type, AF_INET6) < 0) { if (xfrm_register_type(&xfrm6_tunnel_type, AF_INET6) < 0) {
X6TPRINTK1(KERN_ERR X6TPRINTK1(KERN_ERR
"xfrm6_tunnel init: can't add xfrm type\n"); "xfrm6_tunnel init: can't add xfrm type\n");
return; return -EAGAIN;
} }
if (inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0) { if (inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6) < 0) {
X6TPRINTK1(KERN_ERR X6TPRINTK1(KERN_ERR
"xfrm6_tunnel init(): can't add protocol\n"); "xfrm6_tunnel init(): can't add protocol\n");
xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
return; return -EAGAIN;
} }
if (xfrm6_tunnel_spi_init() < 0) { if (xfrm6_tunnel_spi_init() < 0) {
X6TPRINTK1(KERN_ERR X6TPRINTK1(KERN_ERR
"xfrm6_tunnel init: failed to initialize spi\n"); "xfrm6_tunnel init: failed to initialize spi\n");
inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6); inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
return; return -EAGAIN;
} }
return 0;
} }
void __exit xfrm6_tunnel_fini(void) static void __exit xfrm6_tunnel_fini(void)
{ {
X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__); X6TPRINTK3(KERN_DEBUG "%s()\n", __FUNCTION__);
...@@ -537,3 +538,7 @@ void __exit xfrm6_tunnel_fini(void) ...@@ -537,3 +538,7 @@ void __exit xfrm6_tunnel_fini(void)
X6TPRINTK1(KERN_ERR X6TPRINTK1(KERN_ERR
"xfrm6_tunnel close: can't remove xfrm type\n"); "xfrm6_tunnel close: can't remove xfrm type\n");
} }
module_init(xfrm6_tunnel_init);
module_exit(xfrm6_tunnel_fini);
MODULE_LICENSE("GPL");
...@@ -33,8 +33,6 @@ EXPORT_SYMBOL(secpath_dup); ...@@ -33,8 +33,6 @@ EXPORT_SYMBOL(secpath_dup);
EXPORT_SYMBOL(xfrm_get_acqseq); EXPORT_SYMBOL(xfrm_get_acqseq);
EXPORT_SYMBOL(xfrm_parse_spi); EXPORT_SYMBOL(xfrm_parse_spi);
EXPORT_SYMBOL(xfrm4_rcv); EXPORT_SYMBOL(xfrm4_rcv);
EXPORT_SYMBOL(xfrm4_tunnel_register);
EXPORT_SYMBOL(xfrm4_tunnel_deregister);
EXPORT_SYMBOL(xfrm_register_type); EXPORT_SYMBOL(xfrm_register_type);
EXPORT_SYMBOL(xfrm_unregister_type); EXPORT_SYMBOL(xfrm_unregister_type);
EXPORT_SYMBOL(xfrm_get_type); EXPORT_SYMBOL(xfrm_get_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment