diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-03-28 04:12:13 -0500 |
|---|---|---|
| committer | David S. Miller <davem@sunset.davemloft.net> | 2006-03-28 20:02:46 -0500 |
| commit | d2acc3479cbccd5cfbca6c787be713ef1de12ec6 (patch) | |
| tree | aa348e19e15027db9abdd2da175a0c9055047858 | |
| parent | f0088a50e7c49d1ba285c88fe06345f223652fd3 (diff) | |
[INET]: Introduce tunnel4/tunnel6
Basically this patch moves the generic tunnel protocol stuff out of
xfrm4_tunnel/xfrm6_tunnel and moves it into the new files of tunnel4.c
and tunnel6 respectively.
The reason for this is that the problem that Hugo uncovered is only
the tip of the iceberg. The real problem is that when we removed the
dependency of ipip on xfrm4_tunnel we didn't really consider the module
case at all.
For instance, as it is it's possible to build both ipip and xfrm4_tunnel
as modules and if the latter is loaded then ipip simply won't load.
After considering the alternatives I've decided that the best way out of
this is to restore the dependency of ipip on the non-xfrm-specific part
of xfrm4_tunnel. This is acceptable IMHO because the intention of the
removal was really to be able to use ipip without the xfrm subsystem.
This is still preserved by this patch.
So now both ipip/xfrm4_tunnel depend on the new tunnel4.c which handles
the arbitration between the two. The order of processing is determined
by a simple integer which ensures that ipip gets processed before
xfrm4_tunnel.
The situation for ICMP handling is a little bit more complicated since
we may not have enough information to determine who it's for. It's not
a big deal at the moment since the xfrm ICMP handlers are basically
no-ops. In future we can deal with this when we look at ICMP caching
in general.
The user-visible change to this is the removal of the TUNNEL Kconfig
prompts. This makes sense because it can only be used through IPCOMP
as it stands.
The addition of the new modules shouldn't introduce any problems since
module dependency will cause them to be loaded.
Oh and I also turned some unnecessary pskb's in IPv6 related to this
patch to skb's.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/xfrm.h | 16 | ||||
| -rw-r--r-- | net/ipv4/Kconfig | 17 | ||||
| -rw-r--r-- | net/ipv4/Makefile | 3 | ||||
| -rw-r--r-- | net/ipv4/ipip.c | 79 | ||||
| -rw-r--r-- | net/ipv4/tunnel4.c | 113 | ||||
| -rw-r--r-- | net/ipv4/xfrm4_tunnel.c | 79 | ||||
| -rw-r--r-- | net/ipv6/Kconfig | 19 | ||||
| -rw-r--r-- | net/ipv6/Makefile | 3 | ||||
| -rw-r--r-- | net/ipv6/ip6_tunnel.c | 45 | ||||
| -rw-r--r-- | net/ipv6/tunnel6.c | 131 | ||||
| -rw-r--r-- | net/ipv6/xfrm6_input.c | 5 | ||||
| -rw-r--r-- | net/ipv6/xfrm6_tunnel.c | 81 |
12 files changed, 344 insertions, 247 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 61b7504fc2..e100291e43 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
| @@ -864,13 +864,19 @@ struct xfrm_algo_desc { | |||
| 864 | /* XFRM tunnel handlers. */ | 864 | /* XFRM tunnel handlers. */ |
| 865 | struct xfrm_tunnel { | 865 | struct xfrm_tunnel { |
| 866 | int (*handler)(struct sk_buff *skb); | 866 | int (*handler)(struct sk_buff *skb); |
| 867 | void (*err_handler)(struct sk_buff *skb, __u32 info); | 867 | int (*err_handler)(struct sk_buff *skb, __u32 info); |
| 868 | |||
| 869 | struct xfrm_tunnel *next; | ||
| 870 | int priority; | ||
| 868 | }; | 871 | }; |
| 869 | 872 | ||
| 870 | struct xfrm6_tunnel { | 873 | struct xfrm6_tunnel { |
| 871 | int (*handler)(struct sk_buff **pskb); | 874 | int (*handler)(struct sk_buff *skb); |
| 872 | void (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, | 875 | int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, |
| 873 | int type, int code, int offset, __u32 info); | 876 | int type, int code, int offset, __u32 info); |
| 877 | |||
| 878 | struct xfrm6_tunnel *next; | ||
| 879 | int priority; | ||
| 874 | }; | 880 | }; |
| 875 | 881 | ||
| 876 | extern void xfrm_init(void); | 882 | extern void xfrm_init(void); |
| @@ -906,7 +912,7 @@ extern int xfrm4_rcv(struct sk_buff *skb); | |||
| 906 | extern int xfrm4_output(struct sk_buff *skb); | 912 | extern int xfrm4_output(struct sk_buff *skb); |
| 907 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler); | 913 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler); |
| 908 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler); | 914 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler); |
| 909 | extern int xfrm6_rcv_spi(struct sk_buff **pskb, u32 spi); | 915 | extern int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi); |
| 910 | extern int xfrm6_rcv(struct sk_buff **pskb); | 916 | extern int xfrm6_rcv(struct sk_buff **pskb); |
| 911 | extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler); | 917 | extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler); |
| 912 | extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler); | 918 | extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler); |
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 011cca7ae0..e40f753223 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
| @@ -235,6 +235,7 @@ config IP_PNP_RARP | |||
| 235 | # bool ' IP: ARP support' CONFIG_IP_PNP_ARP | 235 | # bool ' IP: ARP support' CONFIG_IP_PNP_ARP |
| 236 | config NET_IPIP | 236 | config NET_IPIP |
| 237 | tristate "IP: tunneling" | 237 | tristate "IP: tunneling" |
| 238 | select INET_TUNNEL | ||
| 238 | ---help--- | 239 | ---help--- |
| 239 | Tunneling means encapsulating data of one protocol type within | 240 | Tunneling means encapsulating data of one protocol type within |
| 240 | another protocol and sending it over a channel that understands the | 241 | another protocol and sending it over a channel that understands the |
| @@ -395,7 +396,7 @@ config INET_ESP | |||
| 395 | config INET_IPCOMP | 396 | config INET_IPCOMP |
| 396 | tristate "IP: IPComp transformation" | 397 | tristate "IP: IPComp transformation" |
| 397 | select XFRM | 398 | select XFRM |
| 398 | select INET_TUNNEL | 399 | select INET_XFRM_TUNNEL |
| 399 | select CRYPTO | 400 | select CRYPTO |
| 400 | select CRYPTO_DEFLATE | 401 | select CRYPTO_DEFLATE |
| 401 | ---help--- | 402 | ---help--- |
| @@ -404,14 +405,14 @@ config INET_IPCOMP | |||
| 404 | 405 | ||
| 405 | If unsure, say Y. | 406 | If unsure, say Y. |
| 406 | 407 | ||
| 408 | config INET_XFRM_TUNNEL | ||
| 409 | tristate | ||
| 410 | select INET_TUNNEL | ||
| 411 | default n | ||
| 412 | |||
| 407 | config INET_TUNNEL | 413 | config INET_TUNNEL |
| 408 | tristate "IP: tunnel transformation" | 414 | tristate |
| 409 | select XFRM | 415 | default n |
| 410 | ---help--- | ||
| 411 | Support for generic IP tunnel transformation, which is required by | ||
| 412 | the IP tunneling module as well as tunnel mode IPComp. | ||
| 413 | |||
| 414 | If unsure, say Y. | ||
| 415 | 416 | ||
| 416 | config INET_DIAG | 417 | config INET_DIAG |
| 417 | tristate "INET: socket monitoring interface" | 418 | tristate "INET: socket monitoring interface" |
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index 35e5f59990..9ef50a0b9d 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile | |||
| @@ -22,7 +22,8 @@ obj-$(CONFIG_SYN_COOKIES) += syncookies.o | |||
| 22 | obj-$(CONFIG_INET_AH) += ah4.o | 22 | obj-$(CONFIG_INET_AH) += ah4.o |
| 23 | obj-$(CONFIG_INET_ESP) += esp4.o | 23 | obj-$(CONFIG_INET_ESP) += esp4.o |
| 24 | obj-$(CONFIG_INET_IPCOMP) += ipcomp.o | 24 | obj-$(CONFIG_INET_IPCOMP) += ipcomp.o |
| 25 | obj-$(CONFIG_INET_TUNNEL) += xfrm4_tunnel.o | 25 | obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o |
| 26 | obj-$(CONFIG_INET_TUNNEL) += tunnel4.o | ||
| 26 | obj-$(CONFIG_IP_PNP) += ipconfig.o | 27 | obj-$(CONFIG_IP_PNP) += ipconfig.o |
| 27 | obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o | 28 | obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o |
| 28 | obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o | 29 | obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 03d13742a4..eef07b0916 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
| @@ -114,7 +114,6 @@ | |||
| 114 | #include <net/sock.h> | 114 | #include <net/sock.h> |
| 115 | #include <net/ip.h> | 115 | #include <net/ip.h> |
| 116 | #include <net/icmp.h> | 116 | #include <net/icmp.h> |
| 117 | #include <net/protocol.h> | ||
| 118 | #include <net/ipip.h> | 117 | #include <net/ipip.h> |
| 119 | #include <net/inet_ecn.h> | 118 | #include <net/inet_ecn.h> |
| 120 | #include <net/xfrm.h> | 119 | #include <net/xfrm.h> |
| @@ -274,7 +273,7 @@ static void ipip_tunnel_uninit(struct net_device *dev) | |||
| 274 | dev_put(dev); | 273 | dev_put(dev); |
| 275 | } | 274 | } |
| 276 | 275 | ||
| 277 | static void ipip_err(struct sk_buff *skb, u32 info) | 276 | static int ipip_err(struct sk_buff *skb, u32 info) |
| 278 | { | 277 | { |
| 279 | #ifndef I_WISH_WORLD_WERE_PERFECT | 278 | #ifndef I_WISH_WORLD_WERE_PERFECT |
| 280 | 279 | ||
| @@ -286,21 +285,22 @@ static void ipip_err(struct sk_buff *skb, u32 info) | |||
| 286 | int type = skb->h.icmph->type; | 285 | int type = skb->h.icmph->type; |
| 287 | int code = skb->h.icmph->code; | 286 | int code = skb->h.icmph->code; |
| 288 | struct ip_tunnel *t; | 287 | struct ip_tunnel *t; |
| 288 | int err; | ||
| 289 | 289 | ||
| 290 | switch (type) { | 290 | switch (type) { |
| 291 | default: | 291 | default: |
| 292 | case ICMP_PARAMETERPROB: | 292 | case ICMP_PARAMETERPROB: |
| 293 | return; | 293 | return 0; |
| 294 | 294 | ||
| 295 | case ICMP_DEST_UNREACH: | 295 | case ICMP_DEST_UNREACH: |
| 296 | switch (code) { | 296 | switch (code) { |
| 297 | case ICMP_SR_FAILED: | 297 | case ICMP_SR_FAILED: |
| 298 | case ICMP_PORT_UNREACH: | 298 | case ICMP_PORT_UNREACH: |
| 299 | /* Impossible event. */ | 299 | /* Impossible event. */ |
| 300 | return; | 300 | return 0; |
| 301 | case ICMP_FRAG_NEEDED: | 301 | case ICMP_FRAG_NEEDED: |
| 302 | /* Soft state for pmtu is maintained by IP core. */ | 302 | /* Soft state for pmtu is maintained by IP core. */ |
| 303 | return; | 303 | return 0; |
| 304 | default: | 304 | default: |
| 305 | /* All others are translated to HOST_UNREACH. | 305 | /* All others are translated to HOST_UNREACH. |
| 306 | rfc2003 contains "deep thoughts" about NET_UNREACH, | 306 | rfc2003 contains "deep thoughts" about NET_UNREACH, |
| @@ -311,14 +311,18 @@ static void ipip_err(struct sk_buff *skb, u32 info) | |||
| 311 | break; | 311 | break; |
| 312 | case ICMP_TIME_EXCEEDED: | 312 | case ICMP_TIME_EXCEEDED: |
| 313 | if (code != ICMP_EXC_TTL) | 313 | if (code != ICMP_EXC_TTL) |
| 314 | return; | 314 | return 0; |
| 315 | break; | 315 | break; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | err = -ENOENT; | ||
| 319 | |||
| 318 | read_lock(&ipip_lock); | 320 | read_lock(&ipip_lock); |
| 319 | t = ipip_tunnel_lookup(iph->daddr, iph->saddr); | 321 | t = ipip_tunnel_lookup(iph->daddr, iph->saddr); |
| 320 | if (t == NULL || t->parms.iph.daddr == 0) | 322 | if (t == NULL || t->parms.iph.daddr == 0) |
| 321 | goto out; | 323 | goto out; |
| 324 | |||
| 325 | err = 0; | ||
| 322 | if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) | 326 | if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) |
| 323 | goto out; | 327 | goto out; |
| 324 | 328 | ||
| @@ -329,7 +333,7 @@ static void ipip_err(struct sk_buff *skb, u32 info) | |||
| 329 | t->err_time = jiffies; | 333 | t->err_time = jiffies; |
| 330 | out: | 334 | out: |
| 331 | read_unlock(&ipip_lock); | 335 | read_unlock(&ipip_lock); |
| 332 | return; | 336 | return err; |
| 333 | #else | 337 | #else |
| 334 | struct iphdr *iph = (struct iphdr*)dp; | 338 | struct iphdr *iph = (struct iphdr*)dp; |
| 335 | int hlen = iph->ihl<<2; | 339 | int hlen = iph->ihl<<2; |
| @@ -344,15 +348,15 @@ out: | |||
| 344 | struct rtable *rt; | 348 | struct rtable *rt; |
| 345 | 349 | ||
| 346 | if (len < hlen + sizeof(struct iphdr)) | 350 | if (len < hlen + sizeof(struct iphdr)) |
| 347 | return; | 351 | |
