Commit 0303770deb834c15ca664a9d741d40f893c92f4e

Authored by Patrick McHardy
Committed by David S. Miller
1 parent c877efb207

[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>

Showing 6 changed files with 67 additions and 14 deletions Side-by-side Diff

... ... @@ -803,7 +803,7 @@
803 803 /* XFRM tunnel handlers. */
804 804 struct xfrm_tunnel {
805 805 int (*handler)(struct sk_buff *skb);
806   - void (*err_handler)(struct sk_buff *skb, void *info);
  806 + void (*err_handler)(struct sk_buff *skb, __u32 info);
807 807 };
808 808  
809 809 struct xfrm6_tunnel {
... ... @@ -235,7 +235,6 @@
235 235 # bool ' IP: ARP support' CONFIG_IP_PNP_ARP
236 236 config NET_IPIP
237 237 tristate "IP: tunneling"
238   - select INET_TUNNEL
239 238 ---help---
240 239 Tunneling means encapsulating data of one protocol type within
241 240 another protocol and sending it over a channel that understands the
... ... @@ -273,7 +273,7 @@
273 273 dev_put(dev);
274 274 }
275 275  
276   -static void ipip_err(struct sk_buff *skb, void *__unused)
  276 +static void ipip_err(struct sk_buff *skb, u32 info)
277 277 {
278 278 #ifndef I_WISH_WORLD_WERE_PERFECT
279 279  
280 280  
... ... @@ -852,11 +852,39 @@
852 852 return 0;
853 853 }
854 854  
  855 +#ifdef CONFIG_INET_TUNNEL
855 856 static struct xfrm_tunnel ipip_handler = {
856 857 .handler = ipip_rcv,
857 858 .err_handler = ipip_err,
858 859 };
859 860  
  861 +static inline int ipip_register(void)
  862 +{
  863 + return xfrm4_tunnel_register(&ipip_handler);
  864 +}
  865 +
  866 +static inline int ipip_unregister(void)
  867 +{
  868 + return xfrm4_tunnel_deregister(&ipip_handler);
  869 +}
  870 +#else
  871 +static struct net_protocol ipip_protocol = {
  872 + .handler = ipip_rcv,
  873 + .err_handler = ipip_err,
  874 + .no_policy = 1,
  875 +};
  876 +
  877 +static inline int ipip_register(void)
  878 +{
  879 + return inet_add_protocol(&ipip_protocol, IPPROTO_IPIP);
  880 +}
  881 +
  882 +static inline int ipip_unregister(void)
  883 +{
  884 + return inet_del_protocol(&ipip_protocol, IPPROTO_IPIP);
  885 +}
  886 +#endif
  887 +
860 888 static char banner[] __initdata =
861 889 KERN_INFO "IPv4 over IPv4 tunneling driver\n";
862 890  
... ... @@ -866,7 +894,7 @@
866 894  
867 895 printk(banner);
868 896  
869   - if (xfrm4_tunnel_register(&ipip_handler) < 0) {
  897 + if (ipip_register() < 0) {
870 898 printk(KERN_INFO "ipip init: can't register tunnel\n");
871 899 return -EAGAIN;
872 900 }
873 901  
... ... @@ -888,13 +916,13 @@
888 916 err2:
889 917 free_netdev(ipip_fb_tunnel_dev);
890 918 err1:
891   - xfrm4_tunnel_deregister(&ipip_handler);
  919 + ipip_unregister();
892 920 goto out;
893 921 }
894 922  
895 923 static void __exit ipip_fini(void)
896 924 {
897   - if (xfrm4_tunnel_deregister(&ipip_handler) < 0)
  925 + if (ipip_unregister() < 0)
898 926 printk(KERN_INFO "ipip close: can't deregister tunnel\n");
899 927  
900 928 unregister_netdev(ipip_fb_tunnel_dev);
net/ipv4/xfrm4_tunnel.c
... ... @@ -78,10 +78,9 @@
78 78 static void ipip_err(struct sk_buff *skb, u32 info)
79 79 {
80 80 struct xfrm_tunnel *handler = ipip_handler;
81   - u32 arg = info;
82 81  
83 82 if (handler)
84   - handler->err_handler(skb, &arg);
  83 + handler->err_handler(skb, info);
85 84 }
86 85  
87 86 static int ipip_init_state(struct xfrm_state *x)
... ... @@ -91,7 +91,6 @@
91 91 config IPV6_TUNNEL
92 92 tristate "IPv6: IPv6-in-IPv6 tunnel"
93 93 depends on IPV6
94   - select INET6_TUNNEL
95 94 ---help---
96 95 Support for IPv6-in-IPv6 tunnels described in RFC 2473.
97 96  
net/ipv6/ip6_tunnel.c
... ... @@ -1110,11 +1110,39 @@
1110 1110 return 0;
1111 1111 }
1112 1112  
  1113 +#ifdef CONFIG_INET6_TUNNEL
1113 1114 static struct xfrm6_tunnel ip6ip6_handler = {
1114   - .handler = ip6ip6_rcv,
1115   - .err_handler = ip6ip6_err,
  1115 + .handler = ip6ip6_rcv,
  1116 + .err_handler = ip6ip6_err,
1116 1117 };
1117 1118  
  1119 +static inline int ip6ip6_register(void)
  1120 +{
  1121 + return xfrm6_tunnel_register(&ip6ip6_handler);
  1122 +}
  1123 +
  1124 +static inline int ip6ip6_unregister(void)
  1125 +{
  1126 + return xfrm6_tunnel_unregister(&ip6ip6_handler);
  1127 +}
  1128 +#else
  1129 +static 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 +
  1135 +static inline int ip6ip6_register(void)
  1136 +{
  1137 + return inet6_add_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
  1138 +}
  1139 +
  1140 +static inline int ip6ip6_unregister(void)
  1141 +{
  1142 + return inet6_del_protocol(&xfrm6_tunnel_protocol, IPPROTO_IPV6);
  1143 +}
  1144 +#endif
  1145 +
1118 1146 /**
1119 1147 * ip6_tunnel_init - register protocol and reserve needed resources
1120 1148 *
... ... @@ -1125,7 +1153,7 @@
1125 1153 {
1126 1154 int err;
1127 1155  
1128   - if (xfrm6_tunnel_register(&ip6ip6_handler) < 0) {
  1156 + if (ip6ip6_register() < 0) {
1129 1157 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
1130 1158 return -EAGAIN;
1131 1159 }
... ... @@ -1144,7 +1172,7 @@
1144 1172 }
1145 1173 return 0;
1146 1174 fail:
1147   - xfrm6_tunnel_deregister(&ip6ip6_handler);
  1175 + ip6ip6_unregister();
1148 1176 return err;
1149 1177 }
1150 1178  
... ... @@ -1154,7 +1182,7 @@
1154 1182  
1155 1183 static void __exit ip6_tunnel_cleanup(void)
1156 1184 {
1157   - if (xfrm6_tunnel_deregister(&ip6ip6_handler) < 0)
  1185 + if (ip6ip6_unregister() < 0)
1158 1186 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
1159 1187  
1160 1188 unregister_netdev(ip6ip6_fb_tnl_dev);