Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 2 | * Linux NET3: IP/IP protocol decoder. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Version: $Id: ipip.c,v 1.50 2001/10/02 02:22:36 davem Exp $ |
| 5 | * |
| 6 | * Authors: |
| 7 | * Sam Lantinga (slouken@cs.ucdavis.edu) 02/01/95 |
| 8 | * |
| 9 | * Fixes: |
| 10 | * Alan Cox : Merged and made usable non modular (its so tiny its silly as |
| 11 | * a module taking up 2 pages). |
| 12 | * Alan Cox : Fixed bug with 1.3.18 and IPIP not working (now needs to set skb->h.iph) |
| 13 | * to keep ip_forward happy. |
| 14 | * Alan Cox : More fixes for 1.3.21, and firewall fix. Maybe this will work soon 8). |
| 15 | * Kai Schulte : Fixed #defines for IP_FIREWALL->FIREWALL |
| 16 | * David Woodhouse : Perform some basic ICMP handling. |
| 17 | * IPIP Routing without decapsulation. |
| 18 | * Carlos Picoto : GRE over IP support |
| 19 | * Alexey Kuznetsov: Reworked. Really, now it is truncated version of ipv4/ip_gre.c. |
| 20 | * I do not want to merge them together. |
| 21 | * |
| 22 | * This program is free software; you can redistribute it and/or |
| 23 | * modify it under the terms of the GNU General Public License |
| 24 | * as published by the Free Software Foundation; either version |
| 25 | * 2 of the License, or (at your option) any later version. |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | /* tunnel.c: an IP tunnel driver |
| 30 | |
| 31 | The purpose of this driver is to provide an IP tunnel through |
| 32 | which you can tunnel network traffic transparently across subnets. |
| 33 | |
| 34 | This was written by looking at Nick Holloway's dummy driver |
| 35 | Thanks for the great code! |
| 36 | |
| 37 | -Sam Lantinga (slouken@cs.ucdavis.edu) 02/01/95 |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | Minor tweaks: |
| 40 | Cleaned up the code a little and added some pre-1.3.0 tweaks. |
| 41 | dev->hard_header/hard_header_len changed to use no headers. |
| 42 | Comments/bracketing tweaked. |
| 43 | Made the tunnels use dev->name not tunnel: when error reporting. |
| 44 | Added tx_dropped stat |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | -Alan Cox (Alan.Cox@linux.org) 21 March 95 |
| 47 | |
| 48 | Reworked: |
| 49 | Changed to tunnel to destination gateway in addition to the |
| 50 | tunnel's pointopoint address |
| 51 | Almost completely rewritten |
| 52 | Note: There is currently no firewall or ICMP handling done. |
| 53 | |
| 54 | -Sam Lantinga (slouken@cs.ucdavis.edu) 02/13/96 |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | */ |
| 57 | |
| 58 | /* Things I wish I had known when writing the tunnel driver: |
| 59 | |
| 60 | When the tunnel_xmit() function is called, the skb contains the |
| 61 | packet to be sent (plus a great deal of extra info), and dev |
| 62 | contains the tunnel device that _we_ are. |
| 63 | |
| 64 | When we are passed a packet, we are expected to fill in the |
| 65 | source address with our source IP address. |
| 66 | |
| 67 | What is the proper way to allocate, copy and free a buffer? |
| 68 | After you allocate it, it is a "0 length" chunk of memory |
| 69 | starting at zero. If you want to add headers to the buffer |
| 70 | later, you'll have to call "skb_reserve(skb, amount)" with |
| 71 | the amount of memory you want reserved. Then, you call |
| 72 | "skb_put(skb, amount)" with the amount of space you want in |
| 73 | the buffer. skb_put() returns a pointer to the top (#0) of |
| 74 | that buffer. skb->len is set to the amount of space you have |
| 75 | "allocated" with skb_put(). You can then write up to skb->len |
| 76 | bytes to that buffer. If you need more, you can call skb_put() |
| 77 | again with the additional amount of space you need. You can |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 78 | find out how much more space you can allocate by calling |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | "skb_tailroom(skb)". |
| 80 | Now, to add header space, call "skb_push(skb, header_len)". |
| 81 | This creates space at the beginning of the buffer and returns |
| 82 | a pointer to this new space. If later you need to strip a |
| 83 | header from a buffer, call "skb_pull(skb, header_len)". |
| 84 | skb_headroom() will return how much space is left at the top |
| 85 | of the buffer (before the main data). Remember, this headroom |
| 86 | space must be reserved before the skb_put() function is called. |
| 87 | */ |
| 88 | |
| 89 | /* |
| 90 | This version of net/ipv4/ipip.c is cloned of net/ipv4/ip_gre.c |
| 91 | |
| 92 | For comments look at net/ipv4/ip_gre.c --ANK |
| 93 | */ |
| 94 | |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 95 | |
Randy Dunlap | 4fc268d | 2006-01-11 12:17:47 -0800 | [diff] [blame] | 96 | #include <linux/capability.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | #include <linux/module.h> |
| 98 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | #include <linux/kernel.h> |
| 100 | #include <asm/uaccess.h> |
| 101 | #include <linux/skbuff.h> |
| 102 | #include <linux/netdevice.h> |
| 103 | #include <linux/in.h> |
| 104 | #include <linux/tcp.h> |
| 105 | #include <linux/udp.h> |
| 106 | #include <linux/if_arp.h> |
| 107 | #include <linux/mroute.h> |
| 108 | #include <linux/init.h> |
| 109 | #include <linux/netfilter_ipv4.h> |
Kris Katterjohn | 46f25df | 2006-01-05 16:35:42 -0800 | [diff] [blame] | 110 | #include <linux/if_ether.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | #include <net/sock.h> |
| 113 | #include <net/ip.h> |
| 114 | #include <net/icmp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #include <net/ipip.h> |
| 116 | #include <net/inet_ecn.h> |
| 117 | #include <net/xfrm.h> |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 118 | #include <net/net_namespace.h> |
| 119 | #include <net/netns/generic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | #define HASH_SIZE 16 |
Al Viro | d5a0a1e | 2006-11-08 00:23:14 -0800 | [diff] [blame] | 122 | #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 124 | static int ipip_net_id; |
| 125 | struct ipip_net { |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 126 | struct ip_tunnel *tunnels_r_l[HASH_SIZE]; |
| 127 | struct ip_tunnel *tunnels_r[HASH_SIZE]; |
| 128 | struct ip_tunnel *tunnels_l[HASH_SIZE]; |
| 129 | struct ip_tunnel *tunnels_wc[1]; |
| 130 | struct ip_tunnel **tunnels[4]; |
| 131 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 132 | struct net_device *fb_tunnel_dev; |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | static int ipip_fb_tunnel_init(struct net_device *dev); |
| 136 | static int ipip_tunnel_init(struct net_device *dev); |
| 137 | static void ipip_tunnel_setup(struct net_device *dev); |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | static DEFINE_RWLOCK(ipip_lock); |
| 140 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 141 | static struct ip_tunnel * ipip_tunnel_lookup(struct net *net, |
| 142 | __be32 remote, __be32 local) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | { |
| 144 | unsigned h0 = HASH(remote); |
| 145 | unsigned h1 = HASH(local); |
| 146 | struct ip_tunnel *t; |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 147 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 149 | for (t = ipn->tunnels_r_l[h0^h1]; t; t = t->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | if (local == t->parms.iph.saddr && |
| 151 | remote == t->parms.iph.daddr && (t->dev->flags&IFF_UP)) |
| 152 | return t; |
| 153 | } |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 154 | for (t = ipn->tunnels_r[h0]; t; t = t->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | if (remote == t->parms.iph.daddr && (t->dev->flags&IFF_UP)) |
| 156 | return t; |
| 157 | } |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 158 | for (t = ipn->tunnels_l[h1]; t; t = t->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | if (local == t->parms.iph.saddr && (t->dev->flags&IFF_UP)) |
| 160 | return t; |
| 161 | } |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 162 | if ((t = ipn->tunnels_wc[0]) != NULL && (t->dev->flags&IFF_UP)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | return t; |
| 164 | return NULL; |
| 165 | } |
| 166 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 167 | static struct ip_tunnel **__ipip_bucket(struct ipip_net *ipn, |
| 168 | struct ip_tunnel_parm *parms) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | { |
YOSHIFUJI Hideaki | 87d1a16 | 2007-04-24 20:44:47 +0900 | [diff] [blame] | 170 | __be32 remote = parms->iph.daddr; |
| 171 | __be32 local = parms->iph.saddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | unsigned h = 0; |
| 173 | int prio = 0; |
| 174 | |
| 175 | if (remote) { |
| 176 | prio |= 2; |
| 177 | h ^= HASH(remote); |
| 178 | } |
| 179 | if (local) { |
| 180 | prio |= 1; |
| 181 | h ^= HASH(local); |
| 182 | } |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 183 | return &ipn->tunnels[prio][h]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 186 | static inline struct ip_tunnel **ipip_bucket(struct ipip_net *ipn, |
| 187 | struct ip_tunnel *t) |
YOSHIFUJI Hideaki | 87d1a16 | 2007-04-24 20:44:47 +0900 | [diff] [blame] | 188 | { |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 189 | return __ipip_bucket(ipn, &t->parms); |
YOSHIFUJI Hideaki | 87d1a16 | 2007-04-24 20:44:47 +0900 | [diff] [blame] | 190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 192 | static void ipip_tunnel_unlink(struct ipip_net *ipn, struct ip_tunnel *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | { |
| 194 | struct ip_tunnel **tp; |
| 195 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 196 | for (tp = ipip_bucket(ipn, t); *tp; tp = &(*tp)->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | if (t == *tp) { |
| 198 | write_lock_bh(&ipip_lock); |
| 199 | *tp = t->next; |
| 200 | write_unlock_bh(&ipip_lock); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 206 | static void ipip_tunnel_link(struct ipip_net *ipn, struct ip_tunnel *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 208 | struct ip_tunnel **tp = ipip_bucket(ipn, t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
| 210 | t->next = *tp; |
| 211 | write_lock_bh(&ipip_lock); |
| 212 | *tp = t; |
| 213 | write_unlock_bh(&ipip_lock); |
| 214 | } |
| 215 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 216 | static struct ip_tunnel * ipip_tunnel_locate(struct net *net, |
| 217 | struct ip_tunnel_parm *parms, int create) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | { |
Al Viro | d5a0a1e | 2006-11-08 00:23:14 -0800 | [diff] [blame] | 219 | __be32 remote = parms->iph.daddr; |
| 220 | __be32 local = parms->iph.saddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | struct ip_tunnel *t, **tp, *nt; |
| 222 | struct net_device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | char name[IFNAMSIZ]; |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 224 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 226 | for (tp = __ipip_bucket(ipn, parms); (t = *tp) != NULL; tp = &t->next) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) |
| 228 | return t; |
| 229 | } |
| 230 | if (!create) |
| 231 | return NULL; |
| 232 | |
| 233 | if (parms->name[0]) |
| 234 | strlcpy(name, parms->name, IFNAMSIZ); |
Pavel Emelyanov | 34cc7ba | 2008-02-23 20:19:20 -0800 | [diff] [blame] | 235 | else |
| 236 | sprintf(name, "tunl%%d"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
| 238 | dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup); |
| 239 | if (dev == NULL) |
| 240 | return NULL; |
| 241 | |
Pavel Emelyanov | b37d428b | 2008-02-26 23:51:04 -0800 | [diff] [blame] | 242 | if (strchr(name, '%')) { |
| 243 | if (dev_alloc_name(dev, name) < 0) |
| 244 | goto failed_free; |
| 245 | } |
| 246 | |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 247 | nt = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | dev->init = ipip_tunnel_init; |
| 249 | nt->parms = *parms; |
| 250 | |
Pavel Emelyanov | b37d428b | 2008-02-26 23:51:04 -0800 | [diff] [blame] | 251 | if (register_netdevice(dev) < 0) |
| 252 | goto failed_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
| 254 | dev_hold(dev); |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 255 | ipip_tunnel_link(ipn, nt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | return nt; |
| 257 | |
Pavel Emelyanov | b37d428b | 2008-02-26 23:51:04 -0800 | [diff] [blame] | 258 | failed_free: |
| 259 | free_netdev(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | return NULL; |
| 261 | } |
| 262 | |
| 263 | static void ipip_tunnel_uninit(struct net_device *dev) |
| 264 | { |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 265 | struct net *net = dev_net(dev); |
| 266 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
| 267 | |
| 268 | if (dev == ipn->fb_tunnel_dev) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | write_lock_bh(&ipip_lock); |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 270 | ipn->tunnels_wc[0] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | write_unlock_bh(&ipip_lock); |
| 272 | } else |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 273 | ipip_tunnel_unlink(ipn, netdev_priv(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | dev_put(dev); |
| 275 | } |
| 276 | |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 277 | static int ipip_err(struct sk_buff *skb, u32 info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | { |
| 279 | #ifndef I_WISH_WORLD_WERE_PERFECT |
| 280 | |
| 281 | /* It is not :-( All the routers (except for Linux) return only |
| 282 | 8 bytes of packet payload. It means, that precise relaying of |
| 283 | ICMP in the real Internet is absolutely infeasible. |
| 284 | */ |
| 285 | struct iphdr *iph = (struct iphdr*)skb->data; |
Arnaldo Carvalho de Melo | 88c7664 | 2007-03-13 14:43:18 -0300 | [diff] [blame] | 286 | const int type = icmp_hdr(skb)->type; |
| 287 | const int code = icmp_hdr(skb)->code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | struct ip_tunnel *t; |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 289 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
| 291 | switch (type) { |
| 292 | default: |
| 293 | case ICMP_PARAMETERPROB: |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 294 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | case ICMP_DEST_UNREACH: |
| 297 | switch (code) { |
| 298 | case ICMP_SR_FAILED: |
| 299 | case ICMP_PORT_UNREACH: |
| 300 | /* Impossible event. */ |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 301 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | case ICMP_FRAG_NEEDED: |
| 303 | /* Soft state for pmtu is maintained by IP core. */ |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 304 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | default: |
| 306 | /* All others are translated to HOST_UNREACH. |
| 307 | rfc2003 contains "deep thoughts" about NET_UNREACH, |
| 308 | I believe they are just ether pollution. --ANK |
| 309 | */ |
| 310 | break; |
| 311 | } |
| 312 | break; |
| 313 | case ICMP_TIME_EXCEEDED: |
| 314 | if (code != ICMP_EXC_TTL) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 315 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | break; |
| 317 | } |
| 318 | |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 319 | err = -ENOENT; |
| 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | read_lock(&ipip_lock); |
Pavel Emelyanov | cec3ffa | 2008-04-16 01:05:03 -0700 | [diff] [blame] | 322 | t = ipip_tunnel_lookup(dev_net(skb->dev), iph->daddr, iph->saddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | if (t == NULL || t->parms.iph.daddr == 0) |
| 324 | goto out; |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 325 | |
| 326 | err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) |
| 328 | goto out; |
| 329 | |
| 330 | if (jiffies - t->err_time < IPTUNNEL_ERR_TIMEO) |
| 331 | t->err_count++; |
| 332 | else |
| 333 | t->err_count = 1; |
| 334 | t->err_time = jiffies; |
| 335 | out: |
| 336 | read_unlock(&ipip_lock); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 337 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | #else |
| 339 | struct iphdr *iph = (struct iphdr*)dp; |
| 340 | int hlen = iph->ihl<<2; |
| 341 | struct iphdr *eiph; |
Arnaldo Carvalho de Melo | 88c7664 | 2007-03-13 14:43:18 -0300 | [diff] [blame] | 342 | const int type = icmp_hdr(skb)->type; |
| 343 | const int code = icmp_hdr(skb)->code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | int rel_type = 0; |
| 345 | int rel_code = 0; |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 346 | __be32 rel_info = 0; |
| 347 | __u32 n = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | struct sk_buff *skb2; |
| 349 | struct flowi fl; |
| 350 | struct rtable *rt; |
| 351 | |
| 352 | if (len < hlen + sizeof(struct iphdr)) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 353 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | eiph = (struct iphdr*)(dp + hlen); |
| 355 | |
| 356 | switch (type) { |
| 357 | default: |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 358 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | case ICMP_PARAMETERPROB: |
Arnaldo Carvalho de Melo | 88c7664 | 2007-03-13 14:43:18 -0300 | [diff] [blame] | 360 | n = ntohl(icmp_hdr(skb)->un.gateway) >> 24; |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 361 | if (n < hlen) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 362 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
| 364 | /* So... This guy found something strange INSIDE encapsulated |
| 365 | packet. Well, he is fool, but what can we do ? |
| 366 | */ |
| 367 | rel_type = ICMP_PARAMETERPROB; |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 368 | rel_info = htonl((n - hlen) << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | break; |
| 370 | |
| 371 | case ICMP_DEST_UNREACH: |
| 372 | switch (code) { |
| 373 | case ICMP_SR_FAILED: |
| 374 | case ICMP_PORT_UNREACH: |
| 375 | /* Impossible event. */ |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 376 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | case ICMP_FRAG_NEEDED: |
| 378 | /* And it is the only really necessary thing :-) */ |
Arnaldo Carvalho de Melo | 88c7664 | 2007-03-13 14:43:18 -0300 | [diff] [blame] | 379 | n = ntohs(icmp_hdr(skb)->un.frag.mtu); |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 380 | if (n < hlen+68) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 381 | return 0; |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 382 | n -= hlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | /* BSD 4.2 MORE DOES NOT EXIST IN NATURE. */ |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 384 | if (n > ntohs(eiph->tot_len)) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 385 | return 0; |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 386 | rel_info = htonl(n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | break; |
| 388 | default: |
| 389 | /* All others are translated to HOST_UNREACH. |
| 390 | rfc2003 contains "deep thoughts" about NET_UNREACH, |
| 391 | I believe, it is just ether pollution. --ANK |
| 392 | */ |
| 393 | rel_type = ICMP_DEST_UNREACH; |
| 394 | rel_code = ICMP_HOST_UNREACH; |
| 395 | break; |
| 396 | } |
| 397 | break; |
| 398 | case ICMP_TIME_EXCEEDED: |
| 399 | if (code != ICMP_EXC_TTL) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 400 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | break; |
| 402 | } |
| 403 | |
| 404 | /* Prepare fake skb to feed it to icmp_send */ |
| 405 | skb2 = skb_clone(skb, GFP_ATOMIC); |
| 406 | if (skb2 == NULL) |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 407 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | dst_release(skb2->dst); |
| 409 | skb2->dst = NULL; |
| 410 | skb_pull(skb2, skb->data - (u8*)eiph); |
Arnaldo Carvalho de Melo | c1d2bbe | 2007-04-10 20:45:18 -0700 | [diff] [blame] | 411 | skb_reset_network_header(skb2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | |
| 413 | /* Try to guess incoming interface */ |
| 414 | memset(&fl, 0, sizeof(fl)); |
| 415 | fl.fl4_daddr = eiph->saddr; |
| 416 | fl.fl4_tos = RT_TOS(eiph->tos); |
| 417 | fl.proto = IPPROTO_IPIP; |
Pavel Emelyanov | b99f015 | 2008-04-16 01:05:57 -0700 | [diff] [blame^] | 418 | if (ip_route_output_key(dev_net(skb->dev), &rt, &key)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | kfree_skb(skb2); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 420 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | skb2->dev = rt->u.dst.dev; |
| 423 | |
| 424 | /* route "incoming" packet */ |
| 425 | if (rt->rt_flags&RTCF_LOCAL) { |
| 426 | ip_rt_put(rt); |
| 427 | rt = NULL; |
| 428 | fl.fl4_daddr = eiph->daddr; |
| 429 | fl.fl4_src = eiph->saddr; |
| 430 | fl.fl4_tos = eiph->tos; |
Pavel Emelyanov | b99f015 | 2008-04-16 01:05:57 -0700 | [diff] [blame^] | 431 | if (ip_route_output_key(dev_net(skb->dev), &rt, &fl) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | rt->u.dst.dev->type != ARPHRD_TUNNEL) { |
| 433 | ip_rt_put(rt); |
| 434 | kfree_skb(skb2); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 435 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | } else { |
| 438 | ip_rt_put(rt); |
| 439 | if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos, skb2->dev) || |
| 440 | skb2->dst->dev->type != ARPHRD_TUNNEL) { |
| 441 | kfree_skb(skb2); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 442 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | |
| 446 | /* change mtu on this route */ |
| 447 | if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 448 | if (n > dst_mtu(skb2->dst)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | kfree_skb(skb2); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 450 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | } |
Al Viro | c55e2f4 | 2006-09-19 13:23:19 -0700 | [diff] [blame] | 452 | skb2->dst->ops->update_pmtu(skb2->dst, n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | } else if (type == ICMP_TIME_EXCEEDED) { |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 454 | struct ip_tunnel *t = netdev_priv(skb2->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | if (t->parms.iph.ttl) { |
| 456 | rel_type = ICMP_DEST_UNREACH; |
| 457 | rel_code = ICMP_HOST_UNREACH; |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | icmp_send(skb2, rel_type, rel_code, rel_info); |
| 462 | kfree_skb(skb2); |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 463 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | #endif |
| 465 | } |
| 466 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 467 | static inline void ipip_ecn_decapsulate(const struct iphdr *outer_iph, |
| 468 | struct sk_buff *skb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | { |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 470 | struct iphdr *inner_iph = ip_hdr(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | |
| 472 | if (INET_ECN_is_ce(outer_iph->tos)) |
| 473 | IP_ECN_set_ce(inner_iph); |
| 474 | } |
| 475 | |
| 476 | static int ipip_rcv(struct sk_buff *skb) |
| 477 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | struct ip_tunnel *tunnel; |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 479 | const struct iphdr *iph = ip_hdr(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | |
| 481 | read_lock(&ipip_lock); |
Pavel Emelyanov | cec3ffa | 2008-04-16 01:05:03 -0700 | [diff] [blame] | 482 | if ((tunnel = ipip_tunnel_lookup(dev_net(skb->dev), |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 483 | iph->saddr, iph->daddr)) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { |
| 485 | read_unlock(&ipip_lock); |
| 486 | kfree_skb(skb); |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | secpath_reset(skb); |
| 491 | |
Arnaldo Carvalho de Melo | b0e380b | 2007-04-10 21:21:55 -0700 | [diff] [blame] | 492 | skb->mac_header = skb->network_header; |
Arnaldo Carvalho de Melo | c1d2bbe | 2007-04-10 20:45:18 -0700 | [diff] [blame] | 493 | skb_reset_network_header(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | skb->protocol = htons(ETH_P_IP); |
| 495 | skb->pkt_type = PACKET_HOST; |
| 496 | |
| 497 | tunnel->stat.rx_packets++; |
| 498 | tunnel->stat.rx_bytes += skb->len; |
| 499 | skb->dev = tunnel->dev; |
| 500 | dst_release(skb->dst); |
| 501 | skb->dst = NULL; |
| 502 | nf_reset(skb); |
| 503 | ipip_ecn_decapsulate(iph, skb); |
| 504 | netif_rx(skb); |
| 505 | read_unlock(&ipip_lock); |
| 506 | return 0; |
| 507 | } |
| 508 | read_unlock(&ipip_lock); |
| 509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | return -1; |
| 511 | } |
| 512 | |
| 513 | /* |
| 514 | * This function assumes it is being called from dev_queue_xmit() |
| 515 | * and that skb is filled properly by that function. |
| 516 | */ |
| 517 | |
| 518 | static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) |
| 519 | { |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 520 | struct ip_tunnel *tunnel = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | struct net_device_stats *stats = &tunnel->stat; |
| 522 | struct iphdr *tiph = &tunnel->parms.iph; |
| 523 | u8 tos = tunnel->parms.iph.tos; |
Al Viro | d5a0a1e | 2006-11-08 00:23:14 -0800 | [diff] [blame] | 524 | __be16 df = tiph->frag_off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | struct rtable *rt; /* Route to the other host */ |
| 526 | struct net_device *tdev; /* Device to other host */ |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 527 | struct iphdr *old_iph = ip_hdr(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | struct iphdr *iph; /* Our new IP header */ |
Chuck Lever | c2636b4 | 2007-10-23 21:07:32 -0700 | [diff] [blame] | 529 | unsigned int max_headroom; /* The extra header space needed */ |
Al Viro | d5a0a1e | 2006-11-08 00:23:14 -0800 | [diff] [blame] | 530 | __be32 dst = tiph->daddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | int mtu; |
| 532 | |
| 533 | if (tunnel->recursion++) { |
| 534 | tunnel->stat.collisions++; |
| 535 | goto tx_error; |
| 536 | } |
| 537 | |
| 538 | if (skb->protocol != htons(ETH_P_IP)) |
| 539 | goto tx_error; |
| 540 | |
| 541 | if (tos&1) |
| 542 | tos = old_iph->tos; |
| 543 | |
| 544 | if (!dst) { |
| 545 | /* NBMA tunnel */ |
Eric Dumazet | ee6b967 | 2008-03-05 18:30:47 -0800 | [diff] [blame] | 546 | if ((rt = skb->rtable) == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | tunnel->stat.tx_fifo_errors++; |
| 548 | goto tx_error; |
| 549 | } |
| 550 | if ((dst = rt->rt_gateway) == 0) |
| 551 | goto tx_error_icmp; |
| 552 | } |
| 553 | |
| 554 | { |
| 555 | struct flowi fl = { .oif = tunnel->parms.link, |
| 556 | .nl_u = { .ip4_u = |
| 557 | { .daddr = dst, |
| 558 | .saddr = tiph->saddr, |
| 559 | .tos = RT_TOS(tos) } }, |
| 560 | .proto = IPPROTO_IPIP }; |
Pavel Emelyanov | b99f015 | 2008-04-16 01:05:57 -0700 | [diff] [blame^] | 561 | if (ip_route_output_key(dev_net(dev), &rt, &fl)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | tunnel->stat.tx_carrier_errors++; |
| 563 | goto tx_error_icmp; |
| 564 | } |
| 565 | } |
| 566 | tdev = rt->u.dst.dev; |
| 567 | |
| 568 | if (tdev == dev) { |
| 569 | ip_rt_put(rt); |
| 570 | tunnel->stat.collisions++; |
| 571 | goto tx_error; |
| 572 | } |
| 573 | |
| 574 | if (tiph->frag_off) |
| 575 | mtu = dst_mtu(&rt->u.dst) - sizeof(struct iphdr); |
| 576 | else |
| 577 | mtu = skb->dst ? dst_mtu(skb->dst) : dev->mtu; |
| 578 | |
| 579 | if (mtu < 68) { |
| 580 | tunnel->stat.collisions++; |
| 581 | ip_rt_put(rt); |
| 582 | goto tx_error; |
| 583 | } |
| 584 | if (skb->dst) |
| 585 | skb->dst->ops->update_pmtu(skb->dst, mtu); |
| 586 | |
| 587 | df |= (old_iph->frag_off&htons(IP_DF)); |
| 588 | |
| 589 | if ((old_iph->frag_off&htons(IP_DF)) && mtu < ntohs(old_iph->tot_len)) { |
| 590 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); |
| 591 | ip_rt_put(rt); |
| 592 | goto tx_error; |
| 593 | } |
| 594 | |
| 595 | if (tunnel->err_count > 0) { |
| 596 | if (jiffies - tunnel->err_time < IPTUNNEL_ERR_TIMEO) { |
| 597 | tunnel->err_count--; |
| 598 | dst_link_failure(skb); |
| 599 | } else |
| 600 | tunnel->err_count = 0; |
| 601 | } |
| 602 | |
| 603 | /* |
| 604 | * Okay, now see if we can stuff it in the buffer as-is. |
| 605 | */ |
| 606 | max_headroom = (LL_RESERVED_SPACE(tdev)+sizeof(struct iphdr)); |
| 607 | |
Patrick McHardy | cfbba49 | 2007-07-09 15:33:40 -0700 | [diff] [blame] | 608 | if (skb_headroom(skb) < max_headroom || skb_shared(skb) || |
| 609 | (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); |
| 611 | if (!new_skb) { |
| 612 | ip_rt_put(rt); |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 613 | stats->tx_dropped++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | dev_kfree_skb(skb); |
| 615 | tunnel->recursion--; |
| 616 | return 0; |
| 617 | } |
| 618 | if (skb->sk) |
| 619 | skb_set_owner_w(new_skb, skb->sk); |
| 620 | dev_kfree_skb(skb); |
| 621 | skb = new_skb; |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 622 | old_iph = ip_hdr(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Arnaldo Carvalho de Melo | b0e380b | 2007-04-10 21:21:55 -0700 | [diff] [blame] | 625 | skb->transport_header = skb->network_header; |
Arnaldo Carvalho de Melo | e2d1bca | 2007-04-10 20:46:21 -0700 | [diff] [blame] | 626 | skb_push(skb, sizeof(struct iphdr)); |
| 627 | skb_reset_network_header(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); |
Patrick McHardy | 48d5cad | 2006-02-15 15:10:22 -0800 | [diff] [blame] | 629 | IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | |
| 630 | IPSKB_REROUTED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | dst_release(skb->dst); |
| 632 | skb->dst = &rt->u.dst; |
| 633 | |
| 634 | /* |
| 635 | * Push down and install the IPIP header. |
| 636 | */ |
| 637 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 638 | iph = ip_hdr(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | iph->version = 4; |
| 640 | iph->ihl = sizeof(struct iphdr)>>2; |
| 641 | iph->frag_off = df; |
| 642 | iph->protocol = IPPROTO_IPIP; |
| 643 | iph->tos = INET_ECN_encapsulate(tos, old_iph->tos); |
| 644 | iph->daddr = rt->rt_dst; |
| 645 | iph->saddr = rt->rt_src; |
| 646 | |
| 647 | if ((iph->ttl = tiph->ttl) == 0) |
| 648 | iph->ttl = old_iph->ttl; |
| 649 | |
| 650 | nf_reset(skb); |
| 651 | |
| 652 | IPTUNNEL_XMIT(); |
| 653 | tunnel->recursion--; |
| 654 | return 0; |
| 655 | |
| 656 | tx_error_icmp: |
| 657 | dst_link_failure(skb); |
| 658 | tx_error: |
| 659 | stats->tx_errors++; |
| 660 | dev_kfree_skb(skb); |
| 661 | tunnel->recursion--; |
| 662 | return 0; |
| 663 | } |
| 664 | |
Michal Schmidt | 5533995 | 2007-12-12 11:01:43 -0800 | [diff] [blame] | 665 | static void ipip_tunnel_bind_dev(struct net_device *dev) |
| 666 | { |
| 667 | struct net_device *tdev = NULL; |
| 668 | struct ip_tunnel *tunnel; |
| 669 | struct iphdr *iph; |
| 670 | |
| 671 | tunnel = netdev_priv(dev); |
| 672 | iph = &tunnel->parms.iph; |
| 673 | |
| 674 | if (iph->daddr) { |
| 675 | struct flowi fl = { .oif = tunnel->parms.link, |
| 676 | .nl_u = { .ip4_u = |
| 677 | { .daddr = iph->daddr, |
| 678 | .saddr = iph->saddr, |
| 679 | .tos = RT_TOS(iph->tos) } }, |
| 680 | .proto = IPPROTO_IPIP }; |
| 681 | struct rtable *rt; |
Pavel Emelyanov | b99f015 | 2008-04-16 01:05:57 -0700 | [diff] [blame^] | 682 | if (!ip_route_output_key(dev_net(dev), &rt, &fl)) { |
Michal Schmidt | 5533995 | 2007-12-12 11:01:43 -0800 | [diff] [blame] | 683 | tdev = rt->u.dst.dev; |
| 684 | ip_rt_put(rt); |
| 685 | } |
| 686 | dev->flags |= IFF_POINTOPOINT; |
| 687 | } |
| 688 | |
| 689 | if (!tdev && tunnel->parms.link) |
Pavel Emelyanov | b99f015 | 2008-04-16 01:05:57 -0700 | [diff] [blame^] | 690 | tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link); |
Michal Schmidt | 5533995 | 2007-12-12 11:01:43 -0800 | [diff] [blame] | 691 | |
| 692 | if (tdev) { |
| 693 | dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr); |
| 694 | dev->mtu = tdev->mtu - sizeof(struct iphdr); |
| 695 | } |
| 696 | dev->iflink = tunnel->parms.link; |
| 697 | } |
| 698 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | static int |
| 700 | ipip_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) |
| 701 | { |
| 702 | int err = 0; |
| 703 | struct ip_tunnel_parm p; |
| 704 | struct ip_tunnel *t; |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 705 | struct net *net = dev_net(dev); |
| 706 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
| 708 | switch (cmd) { |
| 709 | case SIOCGETTUNNEL: |
| 710 | t = NULL; |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 711 | if (dev == ipn->fb_tunnel_dev) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) { |
| 713 | err = -EFAULT; |
| 714 | break; |
| 715 | } |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 716 | t = ipip_tunnel_locate(net, &p, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | } |
| 718 | if (t == NULL) |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 719 | t = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | memcpy(&p, &t->parms, sizeof(p)); |
| 721 | if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p))) |
| 722 | err = -EFAULT; |
| 723 | break; |
| 724 | |
| 725 | case SIOCADDTUNNEL: |
| 726 | case SIOCCHGTUNNEL: |
| 727 | err = -EPERM; |
| 728 | if (!capable(CAP_NET_ADMIN)) |
| 729 | goto done; |
| 730 | |
| 731 | err = -EFAULT; |
| 732 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) |
| 733 | goto done; |
| 734 | |
| 735 | err = -EINVAL; |
| 736 | if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP || |
| 737 | p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF))) |
| 738 | goto done; |
| 739 | if (p.iph.ttl) |
| 740 | p.iph.frag_off |= htons(IP_DF); |
| 741 | |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 742 | t = ipip_tunnel_locate(net, &p, cmd == SIOCADDTUNNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 744 | if (dev != ipn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | if (t != NULL) { |
| 746 | if (t->dev != dev) { |
| 747 | err = -EEXIST; |
| 748 | break; |
| 749 | } |
| 750 | } else { |
| 751 | if (((dev->flags&IFF_POINTOPOINT) && !p.iph.daddr) || |
| 752 | (!(dev->flags&IFF_POINTOPOINT) && p.iph.daddr)) { |
| 753 | err = -EINVAL; |
| 754 | break; |
| 755 | } |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 756 | t = netdev_priv(dev); |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 757 | ipip_tunnel_unlink(ipn, t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | t->parms.iph.saddr = p.iph.saddr; |
| 759 | t->parms.iph.daddr = p.iph.daddr; |
| 760 | memcpy(dev->dev_addr, &p.iph.saddr, 4); |
| 761 | memcpy(dev->broadcast, &p.iph.daddr, 4); |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 762 | ipip_tunnel_link(ipn, t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | netdev_state_change(dev); |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | if (t) { |
| 768 | err = 0; |
| 769 | if (cmd == SIOCCHGTUNNEL) { |
| 770 | t->parms.iph.ttl = p.iph.ttl; |
| 771 | t->parms.iph.tos = p.iph.tos; |
| 772 | t->parms.iph.frag_off = p.iph.frag_off; |
Michal Schmidt | 5533995 | 2007-12-12 11:01:43 -0800 | [diff] [blame] | 773 | if (t->parms.link != p.link) { |
| 774 | t->parms.link = p.link; |
| 775 | ipip_tunnel_bind_dev(dev); |
| 776 | netdev_state_change(dev); |
| 777 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | } |
| 779 | if (copy_to_user(ifr->ifr_ifru.ifru_data, &t->parms, sizeof(p))) |
| 780 | err = -EFAULT; |
| 781 | } else |
| 782 | err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT); |
| 783 | break; |
| 784 | |
| 785 | case SIOCDELTUNNEL: |
| 786 | err = -EPERM; |
| 787 | if (!capable(CAP_NET_ADMIN)) |
| 788 | goto done; |
| 789 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 790 | if (dev == ipn->fb_tunnel_dev) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | err = -EFAULT; |
| 792 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) |
| 793 | goto done; |
| 794 | err = -ENOENT; |
Pavel Emelyanov | b9fae5c | 2008-04-16 01:04:35 -0700 | [diff] [blame] | 795 | if ((t = ipip_tunnel_locate(net, &p, 0)) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | goto done; |
| 797 | err = -EPERM; |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 798 | if (t->dev == ipn->fb_tunnel_dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | goto done; |
| 800 | dev = t->dev; |
| 801 | } |
Stephen Hemminger | 22f8cde | 2007-02-07 00:09:58 -0800 | [diff] [blame] | 802 | unregister_netdevice(dev); |
| 803 | err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | break; |
| 805 | |
| 806 | default: |
| 807 | err = -EINVAL; |
| 808 | } |
| 809 | |
| 810 | done: |
| 811 | return err; |
| 812 | } |
| 813 | |
| 814 | static struct net_device_stats *ipip_tunnel_get_stats(struct net_device *dev) |
| 815 | { |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 816 | return &(((struct ip_tunnel*)netdev_priv(dev))->stat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | static int ipip_tunnel_change_mtu(struct net_device *dev, int new_mtu) |
| 820 | { |
| 821 | if (new_mtu < 68 || new_mtu > 0xFFF8 - sizeof(struct iphdr)) |
| 822 | return -EINVAL; |
| 823 | dev->mtu = new_mtu; |
| 824 | return 0; |
| 825 | } |
| 826 | |
| 827 | static void ipip_tunnel_setup(struct net_device *dev) |
| 828 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | dev->uninit = ipip_tunnel_uninit; |
| 830 | dev->hard_start_xmit = ipip_tunnel_xmit; |
| 831 | dev->get_stats = ipip_tunnel_get_stats; |
| 832 | dev->do_ioctl = ipip_tunnel_ioctl; |
| 833 | dev->change_mtu = ipip_tunnel_change_mtu; |
| 834 | dev->destructor = free_netdev; |
| 835 | |
| 836 | dev->type = ARPHRD_TUNNEL; |
| 837 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); |
Kris Katterjohn | 46f25df | 2006-01-05 16:35:42 -0800 | [diff] [blame] | 838 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | dev->flags = IFF_NOARP; |
| 840 | dev->iflink = 0; |
| 841 | dev->addr_len = 4; |
| 842 | } |
| 843 | |
| 844 | static int ipip_tunnel_init(struct net_device *dev) |
| 845 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | struct ip_tunnel *tunnel; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 848 | tunnel = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | |
| 850 | tunnel->dev = dev; |
| 851 | strcpy(tunnel->parms.name, dev->name); |
| 852 | |
| 853 | memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4); |
| 854 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); |
| 855 | |
Michal Schmidt | 5533995 | 2007-12-12 11:01:43 -0800 | [diff] [blame] | 856 | ipip_tunnel_bind_dev(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
| 858 | return 0; |
| 859 | } |
| 860 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 861 | static int ipip_fb_tunnel_init(struct net_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | { |
Patrick McHardy | 2941a48 | 2006-01-08 22:05:26 -0800 | [diff] [blame] | 863 | struct ip_tunnel *tunnel = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | struct iphdr *iph = &tunnel->parms.iph; |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 865 | struct ipip_net *ipn = net_generic(dev_net(dev), ipip_net_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | |
| 867 | tunnel->dev = dev; |
| 868 | strcpy(tunnel->parms.name, dev->name); |
| 869 | |
| 870 | iph->version = 4; |
| 871 | iph->protocol = IPPROTO_IPIP; |
| 872 | iph->ihl = 5; |
| 873 | |
| 874 | dev_hold(dev); |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 875 | ipn->tunnels_wc[0] = tunnel; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | return 0; |
| 877 | } |
| 878 | |
| 879 | static struct xfrm_tunnel ipip_handler = { |
| 880 | .handler = ipip_rcv, |
| 881 | .err_handler = ipip_err, |
Herbert Xu | d2acc34 | 2006-03-28 01:12:13 -0800 | [diff] [blame] | 882 | .priority = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | }; |
| 884 | |
| 885 | static char banner[] __initdata = |
| 886 | KERN_INFO "IPv4 over IPv4 tunneling driver\n"; |
| 887 | |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 888 | static void ipip_destroy_tunnels(struct ipip_net *ipn) |
| 889 | { |
| 890 | int prio; |
| 891 | |
| 892 | for (prio = 1; prio < 4; prio++) { |
| 893 | int h; |
| 894 | for (h = 0; h < HASH_SIZE; h++) { |
| 895 | struct ip_tunnel *t; |
| 896 | while ((t = ipn->tunnels[prio][h]) != NULL) |
| 897 | unregister_netdevice(t->dev); |
| 898 | } |
| 899 | } |
| 900 | } |
| 901 | |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 902 | static int ipip_init_net(struct net *net) |
| 903 | { |
| 904 | int err; |
| 905 | struct ipip_net *ipn; |
| 906 | |
| 907 | err = -ENOMEM; |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 908 | ipn = kzalloc(sizeof(struct ipip_net), GFP_KERNEL); |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 909 | if (ipn == NULL) |
| 910 | goto err_alloc; |
| 911 | |
| 912 | err = net_assign_generic(net, ipip_net_id, ipn); |
| 913 | if (err < 0) |
| 914 | goto err_assign; |
| 915 | |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 916 | ipn->tunnels[0] = ipn->tunnels_wc; |
| 917 | ipn->tunnels[1] = ipn->tunnels_l; |
| 918 | ipn->tunnels[2] = ipn->tunnels_r; |
| 919 | ipn->tunnels[3] = ipn->tunnels_r_l; |
| 920 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 921 | ipn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), |
| 922 | "tunl0", |
| 923 | ipip_tunnel_setup); |
| 924 | if (!ipn->fb_tunnel_dev) { |
| 925 | err = -ENOMEM; |
| 926 | goto err_alloc_dev; |
| 927 | } |
| 928 | |
| 929 | ipn->fb_tunnel_dev->init = ipip_fb_tunnel_init; |
| 930 | dev_net_set(ipn->fb_tunnel_dev, net); |
| 931 | |
| 932 | if ((err = register_netdev(ipn->fb_tunnel_dev))) |
| 933 | goto err_reg_dev; |
| 934 | |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 935 | return 0; |
| 936 | |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 937 | err_reg_dev: |
| 938 | free_netdev(ipn->fb_tunnel_dev); |
| 939 | err_alloc_dev: |
| 940 | /* nothing */ |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 941 | err_assign: |
| 942 | kfree(ipn); |
| 943 | err_alloc: |
| 944 | return err; |
| 945 | } |
| 946 | |
| 947 | static void ipip_exit_net(struct net *net) |
| 948 | { |
| 949 | struct ipip_net *ipn; |
| 950 | |
| 951 | ipn = net_generic(net, ipip_net_id); |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 952 | rtnl_lock(); |
Pavel Emelyanov | 44d3c29 | 2008-04-16 01:05:32 -0700 | [diff] [blame] | 953 | ipip_destroy_tunnels(ipn); |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 954 | unregister_netdevice(ipn->fb_tunnel_dev); |
| 955 | rtnl_unlock(); |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 956 | kfree(ipn); |
| 957 | } |
| 958 | |
| 959 | static struct pernet_operations ipip_net_ops = { |
| 960 | .init = ipip_init_net, |
| 961 | .exit = ipip_exit_net, |
| 962 | }; |
| 963 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | static int __init ipip_init(void) |
| 965 | { |
| 966 | int err; |
| 967 | |
| 968 | printk(banner); |
| 969 | |
Kazunori MIYAZAWA | c0d5640 | 2007-02-13 12:54:47 -0800 | [diff] [blame] | 970 | if (xfrm4_tunnel_register(&ipip_handler, AF_INET)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | printk(KERN_INFO "ipip init: can't register tunnel\n"); |
| 972 | return -EAGAIN; |
| 973 | } |
| 974 | |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 975 | err = register_pernet_gen_device(&ipip_net_id, &ipip_net_ops); |
| 976 | if (err) |
Pavel Emelyanov | b9855c5 | 2008-04-16 01:04:13 -0700 | [diff] [blame] | 977 | xfrm4_tunnel_deregister(&ipip_handler, AF_INET); |
| 978 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | static void __exit ipip_fini(void) |
| 983 | { |
Kazunori MIYAZAWA | c0d5640 | 2007-02-13 12:54:47 -0800 | [diff] [blame] | 984 | if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | printk(KERN_INFO "ipip close: can't deregister tunnel\n"); |
| 986 | |
Pavel Emelyanov | 10dc4c7 | 2008-04-16 01:03:13 -0700 | [diff] [blame] | 987 | unregister_pernet_gen_device(ipip_net_id, &ipip_net_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | module_init(ipip_init); |
| 991 | module_exit(ipip_fini); |
| 992 | MODULE_LICENSE("GPL"); |