[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>
This commit is contained in:
committed by
David S. Miller
parent
c877efb207
commit
0303770deb
@@ -803,7 +803,7 @@ struct xfrm_algo_desc {
|
|||||||
/* XFRM tunnel handlers. */
|
/* XFRM tunnel handlers. */
|
||||||
struct xfrm_tunnel {
|
struct xfrm_tunnel {
|
||||||
int (*handler)(struct sk_buff *skb);
|
int (*handler)(struct sk_buff *skb);
|
||||||
void (*err_handler)(struct sk_buff *skb, void *info);
|
void (*err_handler)(struct sk_buff *skb, __u32 info);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfrm6_tunnel {
|
struct xfrm6_tunnel {
|
||||||
|
@@ -235,7 +235,6 @@ config IP_PNP_RARP
|
|||||||
# bool ' IP: ARP support' CONFIG_IP_PNP_ARP
|
# bool ' IP: ARP support' CONFIG_IP_PNP_ARP
|
||||||
config NET_IPIP
|
config NET_IPIP
|
||||||
tristate "IP: tunneling"
|
tristate "IP: tunneling"
|
||||||
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
|
||||||
|
@@ -273,7 +273,7 @@ static void ipip_tunnel_uninit(struct net_device *dev)
|
|||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipip_err(struct sk_buff *skb, void *__unused)
|
static void ipip_err(struct sk_buff *skb, u32 info)
|
||||||
{
|
{
|
||||||
#ifndef I_WISH_WORLD_WERE_PERFECT
|
#ifndef I_WISH_WORLD_WERE_PERFECT
|
||||||
|
|
||||||
@@ -852,11 +852,39 @@ static int __init ipip_fb_tunnel_init(struct net_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_INET_TUNNEL
|
||||||
static struct xfrm_tunnel ipip_handler = {
|
static struct xfrm_tunnel ipip_handler = {
|
||||||
.handler = ipip_rcv,
|
.handler = ipip_rcv,
|
||||||
.err_handler = ipip_err,
|
.err_handler = ipip_err,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int ipip_register(void)
|
||||||
|
{
|
||||||
|
return xfrm4_tunnel_register(&ipip_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ipip_unregister(void)
|
||||||
|
{
|
||||||
|
return xfrm4_tunnel_deregister(&ipip_handler);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static struct net_protocol ipip_protocol = {
|
||||||
|
.handler = ipip_rcv,
|
||||||
|
.err_handler = ipip_err,
|
||||||
|
.no_policy = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline int ipip_register(void)
|
||||||
|
{
|
||||||
|
return inet_add_protocol(&ipip_protocol, IPPROTO_IPIP);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ipip_unregister(void)
|
||||||
|
{
|
||||||
|
return inet_del_protocol(&ipip_protocol, IPPROTO_IPIP);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static char banner[] __initdata =
|
static char banner[] __initdata =
|
||||||
KERN_INFO "IPv4 over IPv4 tunneling driver\n";
|
KERN_INFO "IPv4 over IPv4 tunneling driver\n";
|
||||||
|
|
||||||
@@ -866,7 +894,7 @@ static int __init ipip_init(void)
|
|||||||
|
|
||||||
printk(banner);
|
printk(banner);
|
||||||
|
|
||||||
if (xfrm4_tunnel_register(&ipip_handler) < 0) {
|
if (ipip_register() < 0) {
|
||||||
printk(KERN_INFO "ipip init: can't register tunnel\n");
|
printk(KERN_INFO "ipip init: can't register tunnel\n");
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
@@ -888,13 +916,13 @@ static int __init ipip_init(void)
|
|||||||
err2:
|
err2:
|
||||||
free_netdev(ipip_fb_tunnel_dev);
|
free_netdev(ipip_fb_tunnel_dev);
|
||||||
err1:
|
err1:
|
||||||
xfrm4_tunnel_deregister(&ipip_handler);
|
ipip_unregister();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit ipip_fini(void)
|
static void __exit ipip_fini(void)
|
||||||
{
|
{
|
||||||
if (xfrm4_tunnel_deregister(&ipip_handler) < 0)
|
if (ipip_unregister() < 0)
|
||||||
printk(KERN_INFO "ipip close: can't deregister tunnel\n");
|
printk(KERN_INFO "ipip close: can't deregister tunnel\n");
|
||||||
|
|
||||||
unregister_netdev(ipip_fb_tunnel_dev);
|
unregister_netdev(ipip_fb_tunnel_dev);
|
||||||
|
@@ -78,10 +78,9 @@ static int ipip_rcv(struct sk_buff *skb)
|
|||||||
static void ipip_err(struct sk_buff *skb, u32 info)
|
static void ipip_err(struct sk_buff *skb, u32 info)
|
||||||
{
|
{
|
||||||
struct xfrm_tunnel *handler = ipip_handler;
|
struct xfrm_tunnel *handler = ipip_handler;
|
||||||
u32 arg = info;
|
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
handler->err_handler(skb, &arg);
|
handler->err_handler(skb, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipip_init_state(struct xfrm_state *x)
|
static int ipip_init_state(struct xfrm_state *x)
|
||||||
|
@@ -91,7 +91,6 @@ config INET6_TUNNEL
|
|||||||
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 INET6_TUNNEL
|
|
||||||
---help---
|
---help---
|
||||||
Support for IPv6-in-IPv6 tunnels described in RFC 2473.
|
Support for IPv6-in-IPv6 tunnels described in RFC 2473.
|
||||||
|
|
||||||
|
@@ -1110,11 +1110,39 @@ ip6ip6_fb_tnl_dev_init(struct net_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_INET6_TUNNEL
|
||||||
static struct xfrm6_tunnel ip6ip6_handler = {
|
static struct xfrm6_tunnel ip6ip6_handler = {
|
||||||
.handler = ip6ip6_rcv,
|
.handler = ip6ip6_rcv,
|
||||||
.err_handler = ip6ip6_err,
|
.err_handler = ip6ip6_err,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int ip6ip6_register(void)
|
||||||
|
{
|
||||||
|
return xfrm6_tunnel_register(&ip6ip6_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ip6ip6_unregister(void)
|
||||||
|
{
|
||||||
|
return xfrm6_tunnel_unregister(&ip6ip6_handler);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static struct inet6_protocol xfrm6_tunnel_protocol = {
|
||||||
|
.handler = ip6ip6_rcv,
|
||||||
|
.err_handler = ip6ip6_err,
|
||||||
|
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline int ip6ip6_register(void)
|
||||||
|
{
|
||||||
|
return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ip6ip6_unregister(void)
|
||||||
|
{
|
||||||
|
return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ip6_tunnel_init - register protocol and reserve needed resources
|
* ip6_tunnel_init - register protocol and reserve needed resources
|
||||||
*
|
*
|
||||||
@@ -1125,7 +1153,7 @@ static int __init ip6_tunnel_init(void)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (xfrm6_tunnel_register(&ip6ip6_handler) < 0) {
|
if (ip6ip6_register() < 0) {
|
||||||
printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
|
printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1172,7 @@ static int __init ip6_tunnel_init(void)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
xfrm6_tunnel_deregister(&ip6ip6_handler);
|
ip6ip6_unregister();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,7 +1182,7 @@ fail:
|
|||||||
|
|
||||||
static void __exit ip6_tunnel_cleanup(void)
|
static void __exit ip6_tunnel_cleanup(void)
|
||||||
{
|
{
|
||||||
if (xfrm6_tunnel_deregister(&ip6ip6_handler) < 0)
|
if (ip6ip6_unregister() < 0)
|
||||||
printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
|
printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
|
||||||
|
|
||||||
unregister_netdev(ip6ip6_fb_tnl_dev);
|
unregister_netdev(ip6ip6_fb_tnl_dev);
|
||||||
|
Reference in New Issue
Block a user