ip6_tunnel.c (c5e77f5216abdd1d98e6d14d9a3eb4e88d80011a) ip6_tunnel.c (63159f29be1df7f93563a8a0f78c5e65fc844ed6)
1/*
2 * IPv6 tunneling device
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Ville Nuorvala <vnuorval@tcs.hut.fi>
7 * Yasuyuki Kozakai <kozakai@linux-ipv6.org>
8 *

--- 50 unchanged lines hidden (view full) ---

59#include <net/netns/generic.h>
60
61MODULE_AUTHOR("Ville Nuorvala");
62MODULE_DESCRIPTION("IPv6 tunneling device");
63MODULE_LICENSE("GPL");
64MODULE_ALIAS_RTNL_LINK("ip6tnl");
65MODULE_ALIAS_NETDEV("ip6tnl0");
66
1/*
2 * IPv6 tunneling device
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Ville Nuorvala <vnuorval@tcs.hut.fi>
7 * Yasuyuki Kozakai <kozakai@linux-ipv6.org>
8 *

--- 50 unchanged lines hidden (view full) ---

59#include <net/netns/generic.h>
60
61MODULE_AUTHOR("Ville Nuorvala");
62MODULE_DESCRIPTION("IPv6 tunneling device");
63MODULE_LICENSE("GPL");
64MODULE_ALIAS_RTNL_LINK("ip6tnl");
65MODULE_ALIAS_NETDEV("ip6tnl0");
66
67#ifdef IP6_TNL_DEBUG
68#define IP6_TNL_TRACE(x...) pr_debug("%s:" x "\n", __func__)
69#else
70#define IP6_TNL_TRACE(x...) do {;} while(0)
71#endif
72
73#define HASH_SIZE_SHIFT 5
74#define HASH_SIZE (1 << HASH_SIZE_SHIFT)
75
76static bool log_ecn_error = true;
77module_param(log_ecn_error, bool, 0644);
78MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
79
80static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)

--- 51 unchanged lines hidden (view full) ---

132 * Locking : hash tables are protected by RCU and RTNL
133 */
134
135struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
136{
137 struct dst_entry *dst = t->dst_cache;
138
139 if (dst && dst->obsolete &&
67#define HASH_SIZE_SHIFT 5
68#define HASH_SIZE (1 << HASH_SIZE_SHIFT)
69
70static bool log_ecn_error = true;
71module_param(log_ecn_error, bool, 0644);
72MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
73
74static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)

--- 51 unchanged lines hidden (view full) ---

126 * Locking : hash tables are protected by RCU and RTNL
127 */
128
129struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
130{
131 struct dst_entry *dst = t->dst_cache;
132
133 if (dst && dst->obsolete &&
140 dst->ops->check(dst, t->dst_cookie) == NULL) {
134 !dst->ops->check(dst, t->dst_cookie)) {
141 t->dst_cache = NULL;
142 dst_release(dst);
143 return NULL;
144 }
145
146 return dst;
147}
148EXPORT_SYMBOL_GPL(ip6_tnl_dst_check);

--- 177 unchanged lines hidden (view full) ---

326
327 if (p->name[0])
328 strlcpy(name, p->name, IFNAMSIZ);
329 else
330 sprintf(name, "ip6tnl%%d");
331
332 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
333 ip6_tnl_dev_setup);
135 t->dst_cache = NULL;
136 dst_release(dst);
137 return NULL;
138 }
139
140 return dst;
141}
142EXPORT_SYMBOL_GPL(ip6_tnl_dst_check);

--- 177 unchanged lines hidden (view full) ---

320
321 if (p->name[0])
322 strlcpy(name, p->name, IFNAMSIZ);
323 else
324 sprintf(name, "ip6tnl%%d");
325
326 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
327 ip6_tnl_dev_setup);
334 if (dev == NULL)
328 if (!dev)
335 goto failed;
336
337 dev_net_set(dev, net);
338
339 t = netdev_priv(dev);
340 t->parms = *p;
341 t->net = dev_net(dev);
342 err = ip6_tnl_create2(dev);

--- 154 unchanged lines hidden (view full) ---

497 int err = -ENOENT;
498
499 /* If the packet doesn't contain the original IPv6 header we are
500 in trouble since we might need the source address for further
501 processing of the error. */
502
503 rcu_read_lock();
504 t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr, &ipv6h->saddr);
329 goto failed;
330
331 dev_net_set(dev, net);
332
333 t = netdev_priv(dev);
334 t->parms = *p;
335 t->net = dev_net(dev);
336 err = ip6_tnl_create2(dev);

--- 154 unchanged lines hidden (view full) ---

491 int err = -ENOENT;
492
493 /* If the packet doesn't contain the original IPv6 header we are
494 in trouble since we might need the source address for further
495 processing of the error. */
496
497 rcu_read_lock();
498 t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr, &ipv6h->saddr);
505 if (t == NULL)
499 if (!t)
506 goto out;
507
508 tproto = ACCESS_ONCE(t->parms.proto);
509 if (tproto != ipproto && tproto != 0)
510 goto out;
511
512 err = 0;
513

--- 761 unchanged lines hidden (view full) ---

1275 if (p->flags & IP6_TNL_F_CAP_XMIT) {
1276 int strict = (ipv6_addr_type(&p->raddr) &
1277 (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
1278
1279 struct rt6_info *rt = rt6_lookup(t->net,
1280 &p->raddr, &p->laddr,
1281 p->link, strict);
1282
500 goto out;
501
502 tproto = ACCESS_ONCE(t->parms.proto);
503 if (tproto != ipproto && tproto != 0)
504 goto out;
505
506 err = 0;
507

--- 761 unchanged lines hidden (view full) ---

1269 if (p->flags & IP6_TNL_F_CAP_XMIT) {
1270 int strict = (ipv6_addr_type(&p->raddr) &
1271 (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
1272
1273 struct rt6_info *rt = rt6_lookup(t->net,
1274 &p->raddr, &p->laddr,
1275 p->link, strict);
1276
1283 if (rt == NULL)
1277 if (!rt)
1284 return;
1285
1286 if (rt->dst.dev) {
1287 dev->hard_header_len = rt->dst.dev->hard_header_len +
1288 sizeof(struct ipv6hdr);
1289
1290 dev->mtu = rt->dst.dev->mtu - sizeof(struct ipv6hdr);
1291 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))

--- 659 unchanged lines hidden ---
1278 return;
1279
1280 if (rt->dst.dev) {
1281 dev->hard_header_len = rt->dst.dev->hard_header_len +
1282 sizeof(struct ipv6hdr);
1283
1284 dev->mtu = rt->dst.dev->mtu - sizeof(struct ipv6hdr);
1285 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))

--- 659 unchanged lines hidden ---