aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-07-19 17:03:34 -0400
committerDavid S. Miller <davem@davemloft.net>2005-07-19 17:03:34 -0400
commit0303770deb834c15ca664a9d741d40f893c92f4e (patch)
treed48e2df54d3545052aaffeeeec1c34c214055056 /net
parentc877efb207bf4629cfa97ac13412f7392a873485 (diff)
[NET]: Make ipip/ip6_tunnel independant of XFRM
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/Kconfig1
-rw-r--r--net/ipv4/ipip.c36
-rw-r--r--net/ipv4/xfrm4_tunnel.c3
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/ip6_tunnel.c38
5 files changed, 66 insertions, 13 deletions
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index c7f1f9245bc9..fc561c0ae8e2 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -235,7 +235,6 @@ config IP_PNP_RARP
235# bool ' IP: ARP support' CONFIG_IP_PNP_ARP 235# bool ' IP: ARP support' CONFIG_IP_PNP_ARP
236config NET_IPIP 236config NET_IPIP
237 tristate "IP: tunneling" 237 tristate "IP: tunneling"
238 select INET_TUNNEL
239 ---help--- 238 ---help---
240 Tunneling means encapsulating data of one protocol type within 239 Tunneling means encapsulating data of one protocol type within
241 another protocol and sending it over a channel that understands the 240 another protocol and sending it over a channel that understands the
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 68a78731f722..c3947cd566b7 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -273,7 +273,7 @@ static void ipip_tunnel_uninit(struct net_device *dev)
273 dev_put(dev); 273 dev_put(dev);
274} 274}
275 275
276static void ipip_err(struct sk_buff *skb, void *__unused) 276static void ipip_err(struct sk_buff *skb, u32 info)
277{ 277{
278#ifndef I_WISH_WORLD_WERE_PERFECT 278#ifndef I_WISH_WORLD_WERE_PERFECT
279 279
@@ -852,11 +852,39 @@ static int __init ipip_fb_tunnel_init(struct net_device *dev)
852 return 0; 852 return 0;
853} 853}
854 854
855#ifdef CONFIG_INET_TUNNEL
855static struct xfrm_tunnel ipip_handler = { 856static struct xfrm_tunnel ipip_handler = {
856 .handler = ipip_rcv, 857 .handler = ipip_rcv,
857 .err_handler = ipip_err, 858 .err_handler = ipip_err,
858}; 859};
859 860
861static inline int ipip_register(void)
862{
863 return xfrm4_tunnel_register(&ipip_handler);
864}
865
866static inline int ipip_unregister(void)
867{
868 return xfrm4_tunnel_deregister(&ipip_handler);
869}
870#else
871static struct net_protocol ipip_protocol = {
872 .handler = ipip_rcv,
873 .err_handler = ipip_err,
874 .no_policy = 1,
875};
876
877static inline int ipip_register(void)
878{
879 return inet_add_protocol(&ipip_protocol, IPPROTO_IPIP);
880}
881
882static inline int ipip_unregister(void)
883{
884 return inet_del_protocol(&ipip_protocol, IPPROTO_IPIP);
885}
886#endif
887
860static char banner[] __initdata = 888static char banner[] __initdata =
861 KERN_INFO "IPv4 over IPv4 tunneling driver\n"; 889 KERN_INFO "IPv4 over IPv4 tunneling driver\n";
862 890
@@ -866,7 +894,7 @@ static int __init ipip_init(void)
866 894
867 printk(banner); 895 printk(banner);
868 896
869 if (xfrm4_tunnel_register(&ipip_handler) < 0) { 897 if (ipip_register() < 0) {
870 printk(KERN_INFO "ipip init: can't register tunnel\n"); 898 printk(KERN_INFO "ipip init: can't register tunnel\n");
871 return -EAGAIN; 899 return -EAGAIN;
872 } 900 }
@@ -888,13 +916,13 @@ static int __init ipip_init(void)
888 err2: 916 err2:
889 free_netdev(ipip_fb_tunnel_dev); 917 free_netdev(ipip_fb_tunnel_dev);
890 err1: 918 err1:
891 xfrm4_tunnel_deregister(&ipip_handler); 919 ipip_unregister();
892 goto out; 920 goto out;
893} 921}
894 922
895static void __exit ipip_fini(void) 923static void __exit ipip_fini(void)
896{ 924{
897 if (xfrm4_tunnel_deregister(&ipip_handler) < 0) 925 if (ipip_unregister() < 0)
898 printk(KERN_INFO "ipip close: can't deregister tunnel\n"); 926 printk(KERN_INFO "ipip close: can't deregister tunnel\n");
899 927
900 unregister_netdev(ipip_fb_tunnel_dev); 928 unregister_netdev(ipip_fb_tunnel_dev);
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index e1fe360ed27a..afbb0d4cc305 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -78,10 +78,9 @@ static int ipip_rcv(struct sk_buff *skb)
78static void ipip_err(struct sk_buff *skb, u32 info) 78static void ipip_err(struct sk_buff *skb, u32 info)
79{ 79{
80 struct xfrm_tunnel *handler = ipip_handler; 80 struct xfrm_tunnel *handler = ipip_handler;
81 u32 arg = info;
82 81
83 if (handler) 82 if (handler)
84 handler->err_handler(skb, &arg); 83 handler->err_handler(skb, info);
85} 84}
86 85
87static int ipip_init_state(struct xfrm_state *x) 86static int ipip_init_state(struct xfrm_state *x)
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 95163cd52ae0..ab7a9124f985 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -91,7 +91,6 @@ config INET6_TUNNEL
91config IPV6_TUNNEL 91config IPV6_TUNNEL
92 tristate "IPv6: IPv6-in-IPv6 tunnel" 92 tristate "IPv6: IPv6-in-IPv6 tunnel"
93 depends on IPV6 93 depends on IPV6
94 select INET6_TUNNEL
95 ---help--- 94 ---help---
96 Support for IPv6-in-IPv6 tunnels described in RFC 2473. 95 Support for IPv6-in-IPv6 tunnels described in RFC 2473.
97 96
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index ba3b0c267f75..f39ddeae1eef 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1110,11 +1110,39 @@ ip6ip6_fb_tnl_dev_init(struct net_device *dev)
1110 return 0; 1110 return 0;
1111} 1111}
1112 1112
1113#ifdef CONFIG_INET6_TUNNEL
1113static struct xfrm6_tunnel ip6ip6_handler = { 1114static struct xfrm6_tunnel ip6ip6_handler = {
1114 .handler = ip6ip6_rcv, 1115 .handler = ip6ip6_rcv,
1115 .err_handler = ip6ip6_err, 1116 .err_handler = ip6ip6_err,
1116}; 1117};
1117 1118
1119static inline int ip6ip6_register(void)
1120{
1121 return xfrm6_tunnel_register(&ip6ip6_handler);
1122}
1123
1124static inline int ip6ip6_unregister(void)
1125{
1126 return xfrm6_tunnel_unregister(&ip6ip6_handler);
1127}
1128#else
1129static struct inet6_protocol xfrm6_tunnel_protocol = {
1130 .handler = ip6ip6_rcv,
1131 .err_handler = ip6ip6_err,
1132 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
1133};
1134
1135static inline int ip6ip6_register(void)
1136{
1137 return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
1138}
1139
1140static inline int ip6ip6_unregister(void)
1141{
1142 return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
1143}
1144#endif
1145
1118/** 1146/**
1119 * ip6_tunnel_init - register protocol and reserve needed resources 1147 * ip6_tunnel_init - register protocol and reserve needed resources
1120 * 1148 *
@@ -1125,7 +1153,7 @@ static int __init ip6_tunnel_init(void)
1125{ 1153{
1126 int err; 1154 int err;
1127 1155
1128 if (xfrm6_tunnel_register(&ip6ip6_handler) < 0) { 1156 if (ip6ip6_register() < 0) {
1129 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); 1157 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
1130 return -EAGAIN; 1158 return -EAGAIN;
1131 } 1159 }
@@ -1144,7 +1172,7 @@ static int __init ip6_tunnel_init(void)
1144 } 1172 }
1145 return 0; 1173 return 0;
1146fail: 1174fail:
1147 xfrm6_tunnel_deregister(&ip6ip6_handler); 1175 ip6ip6_unregister();
1148 return err; 1176 return err;
1149} 1177}
1150 1178
@@ -1154,7 +1182,7 @@ fail:
1154 1182
1155static void __exit ip6_tunnel_cleanup(void) 1183static void __exit ip6_tunnel_cleanup(void)
1156{ 1184{
1157 if (xfrm6_tunnel_deregister(&ip6ip6_handler) < 0) 1185 if (ip6ip6_unregister() < 0)
1158 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); 1186 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
1159 1187
1160 unregister_netdev(ip6ip6_fb_tnl_dev); 1188 unregister_netdev(ip6ip6_fb_tnl_dev);