aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/ip6_tunnel.c')
-rw-r--r--net/ipv6/ip6_tunnel.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 8d918348f5bb..367b74832986 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -3,7 +3,7 @@
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Ville Nuorvala <vnuorval@tcs.hut.fi> 6 * Ville Nuorvala <vnuorval@tcs.hut.fi>
7 * 7 *
8 * $Id$ 8 * $Id$
9 * 9 *
@@ -67,8 +67,8 @@ MODULE_LICENSE("GPL");
67#define HASH_SIZE 32 67#define HASH_SIZE 32
68 68
69#define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \ 69#define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ 70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
71 (HASH_SIZE - 1)) 71 (HASH_SIZE - 1))
72 72
73static int ip6ip6_fb_tnl_dev_init(struct net_device *dev); 73static int ip6ip6_fb_tnl_dev_init(struct net_device *dev);
74static int ip6ip6_tnl_dev_init(struct net_device *dev); 74static int ip6ip6_tnl_dev_init(struct net_device *dev);
@@ -90,7 +90,7 @@ static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
90{ 90{
91 struct dst_entry *dst = t->dst_cache; 91 struct dst_entry *dst = t->dst_cache;
92 92
93 if (dst && dst->obsolete && 93 if (dst && dst->obsolete &&
94 dst->ops->check(dst, t->dst_cookie) == NULL) { 94 dst->ops->check(dst, t->dst_cookie) == NULL) {
95 t->dst_cache = NULL; 95 t->dst_cache = NULL;
96 dst_release(dst); 96 dst_release(dst);
@@ -116,12 +116,12 @@ static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
116 116
117/** 117/**
118 * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses 118 * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
119 * @remote: the address of the tunnel exit-point 119 * @remote: the address of the tunnel exit-point
120 * @local: the address of the tunnel entry-point 120 * @local: the address of the tunnel entry-point
121 * 121 *
122 * Return: 122 * Return:
123 * tunnel matching given end-points if found, 123 * tunnel matching given end-points if found,
124 * else fallback tunnel if its device is up, 124 * else fallback tunnel if its device is up,
125 * else %NULL 125 * else %NULL
126 **/ 126 **/
127 127
@@ -146,13 +146,13 @@ ip6ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local)
146 146
147/** 147/**
148 * ip6ip6_bucket - get head of list matching given tunnel parameters 148 * ip6ip6_bucket - get head of list matching given tunnel parameters
149 * @p: parameters containing tunnel end-points 149 * @p: parameters containing tunnel end-points
150 * 150 *
151 * Description: 151 * Description:
152 * ip6ip6_bucket() returns the head of the list matching the 152 * ip6ip6_bucket() returns the head of the list matching the
153 * &struct in6_addr entries laddr and raddr in @p. 153 * &struct in6_addr entries laddr and raddr in @p.
154 * 154 *
155 * Return: head of IPv6 tunnel list 155 * Return: head of IPv6 tunnel list
156 **/ 156 **/
157 157
158static struct ip6_tnl ** 158static struct ip6_tnl **
@@ -213,8 +213,8 @@ ip6ip6_tnl_unlink(struct ip6_tnl *t)
213 * 213 *
214 * Description: 214 * Description:
215 * Create tunnel matching given parameters. 215 * Create tunnel matching given parameters.
216 * 216 *
217 * Return: 217 * Return:
218 * created tunnel or NULL 218 * created tunnel or NULL
219 **/ 219 **/
220 220
@@ -234,7 +234,7 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
234 if (__dev_get_by_name(name) == NULL) 234 if (__dev_get_by_name(name) == NULL)
235 break; 235 break;
236 } 236 }
237 if (i == IP6_TNL_MAX) 237 if (i == IP6_TNL_MAX)
238 goto failed; 238 goto failed;
239 } 239 }
240 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup); 240 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup);
@@ -258,7 +258,7 @@ failed:
258 258
259/** 259/**
260 * ip6ip6_tnl_locate - find or create tunnel matching given parameters 260 * ip6ip6_tnl_locate - find or create tunnel matching given parameters
261 * @p: tunnel parameters 261 * @p: tunnel parameters
262 * @create: != 0 if allowed to create new tunnel if no match found 262 * @create: != 0 if allowed to create new tunnel if no match found
263 * 263 *
264 * Description: 264 * Description:
@@ -289,7 +289,7 @@ static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create)
289/** 289/**
290 * ip6ip6_tnl_dev_uninit - tunnel device uninitializer 290 * ip6ip6_tnl_dev_uninit - tunnel device uninitializer
291 * @dev: the device to be destroyed 291 * @dev: the device to be destroyed
292 * 292 *
293 * Description: 293 * Description:
294 * ip6ip6_tnl_dev_uninit() removes tunnel from its list 294 * ip6ip6_tnl_dev_uninit() removes tunnel from its list
295 **/ 295 **/
@@ -314,8 +314,8 @@ ip6ip6_tnl_dev_uninit(struct net_device *dev)
314 * parse_tvl_tnl_enc_lim - handle encapsulation limit option 314 * parse_tvl_tnl_enc_lim - handle encapsulation limit option
315 * @skb: received socket buffer 315 * @skb: received socket buffer
316 * 316 *
317 * Return: 317 * Return:
318 * 0 if none was found, 318 * 0 if none was found,
319 * else index to encapsulation limit 319 * else index to encapsulation limit
320 **/ 320 **/
321 321
@@ -392,8 +392,8 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
392 __u16 len; 392 __u16 len;
393 int err = -ENOENT; 393 int err = -ENOENT;
394 394
395 /* If the packet doesn't contain the original IPv6 header we are 395 /* If the packet doesn't contain the original IPv6 header we are
396 in trouble since we might need the source address for further 396 in trouble since we might need the source address for further
397 processing of the error. */ 397 processing of the error. */
398 398
399 read_lock(&ip6ip6_lock); 399 read_lock(&ip6ip6_lock);
@@ -418,7 +418,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
418 if (net_ratelimit()) 418 if (net_ratelimit())
419 printk(KERN_WARNING 419 printk(KERN_WARNING
420 "%s: Too small hop limit or " 420 "%s: Too small hop limit or "
421 "routing loop in tunnel!\n", 421 "routing loop in tunnel!\n",
422 t->parms.name); 422 t->parms.name);
423 rel_msg = 1; 423 rel_msg = 1;
424 } 424 }
@@ -502,7 +502,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
502 int ret = 0; 502 int ret = 0;
503 503
504 if (p->flags & IP6_TNL_F_CAP_RCV) { 504 if (p->flags & IP6_TNL_F_CAP_RCV) {
505 struct net_device *ldev = NULL; 505 struct net_device *ldev = NULL;
506 506
507 if (p->link) 507 if (p->link)
508 ldev = dev_get_by_index(p->link); 508 ldev = dev_get_by_index(p->link);
@@ -525,7 +525,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
525 * Return: 0 525 * Return: 0
526 **/ 526 **/
527 527
528static int 528static int
529ip6ip6_rcv(struct sk_buff *skb) 529ip6ip6_rcv(struct sk_buff *skb)
530{ 530{
531 struct ipv6hdr *ipv6h; 531 struct ipv6hdr *ipv6h;
@@ -595,13 +595,13 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit)
595/** 595/**
596 * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own 596 * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
597 * @t: the outgoing tunnel device 597 * @t: the outgoing tunnel device
598 * @hdr: IPv6 header from the incoming packet 598 * @hdr: IPv6 header from the incoming packet
599 * 599 *
600 * Description: 600 * Description:
601 * Avoid trivial tunneling loop by checking that tunnel exit-point 601 * Avoid trivial tunneling loop by checking that tunnel exit-point
602 * doesn't match source of incoming packet. 602 * doesn't match source of incoming packet.
603 * 603 *
604 * Return: 604 * Return:
605 * 1 if conflict, 605 * 1 if conflict,
606 * 0 else 606 * 0 else
607 **/ 607 **/
@@ -617,7 +617,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
617 struct ip6_tnl_parm *p = &t->parms; 617 struct ip6_tnl_parm *p = &t->parms;
618 int ret = 0; 618 int ret = 0;
619 619
620 if (p->flags & IP6_TNL_F_CAP_XMIT) { 620 if (p->flags & IP6_TNL_F_CAP_XMIT) {
621 struct net_device *ldev = NULL; 621 struct net_device *ldev = NULL;
622 622
623 if (p->link) 623 if (p->link)
@@ -641,19 +641,19 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
641 return ret; 641 return ret;
642} 642}
643/** 643/**
644 * ip6ip6_tnl_xmit - encapsulate packet and send 644 * ip6ip6_tnl_xmit - encapsulate packet and send
645 * @skb: the outgoing socket buffer 645 * @skb: the outgoing socket buffer
646 * @dev: the outgoing tunnel device 646 * @dev: the outgoing tunnel device
647 * 647 *
648 * Description: 648 * Description:
649 * Build new header and do some sanity checks on the packet before sending 649 * Build new header and do some sanity checks on the packet before sending
650 * it. 650 * it.
651 * 651 *
652 * Return: 652 * Return:
653 * 0 653 * 0
654 **/ 654 **/
655 655
656static int 656static int
657ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) 657ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
658{ 658{
659 struct ip6_tnl *t = netdev_priv(dev); 659 struct ip6_tnl *t = netdev_priv(dev);
@@ -715,7 +715,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
715 if (tdev == dev) { 715 if (tdev == dev) {
716 stats->collisions++; 716 stats->collisions++;
717 if (net_ratelimit()) 717 if (net_ratelimit())
718 printk(KERN_WARNING 718 printk(KERN_WARNING
719 "%s: Local routing loop detected!\n", 719 "%s: Local routing loop detected!\n",
720 t->parms.name); 720 t->parms.name);
721 goto tx_err_dst_release; 721 goto tx_err_dst_release;
@@ -741,11 +741,11 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
741 * Okay, now see if we can stuff it in the buffer as-is. 741 * Okay, now see if we can stuff it in the buffer as-is.
742 */ 742 */
743 max_headroom += LL_RESERVED_SPACE(tdev); 743 max_headroom += LL_RESERVED_SPACE(tdev);
744 744
745 if (skb_headroom(skb) < max_headroom || 745 if (skb_headroom(skb) < max_headroom ||
746 skb_cloned(skb) || skb_shared(skb)) { 746 skb_cloned(skb) || skb_shared(skb)) {
747 struct sk_buff *new_skb; 747 struct sk_buff *new_skb;
748 748
749 if (!(new_skb = skb_realloc_headroom(skb, max_headroom))) 749 if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
750 goto tx_err_dst_release; 750 goto tx_err_dst_release;
751 751
@@ -775,7 +775,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
775 ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst); 775 ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
776 nf_reset(skb); 776 nf_reset(skb);
777 pkt_len = skb->len; 777 pkt_len = skb->len;
778 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 778 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL,
779 skb->dst->dev, dst_output); 779 skb->dst->dev, dst_output);
780 780
781 if (net_xmit_eval(err) == 0) { 781 if (net_xmit_eval(err) == 0) {
@@ -898,14 +898,14 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
898} 898}
899 899
900/** 900/**
901 * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace 901 * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace
902 * @dev: virtual device associated with tunnel 902 * @dev: virtual device associated with tunnel
903 * @ifr: parameters passed from userspace 903 * @ifr: parameters passed from userspace
904 * @cmd: command to be performed 904 * @cmd: command to be performed
905 * 905 *
906 * Description: 906 * Description:
907 * ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels 907 * ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels
908 * from userspace. 908 * from userspace.
909 * 909 *
910 * The possible commands are the following: 910 * The possible commands are the following:
911 * %SIOCGETTUNNEL: get tunnel parameters for device 911 * %SIOCGETTUNNEL: get tunnel parameters for device
@@ -913,7 +913,7 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
913 * %SIOCCHGTUNNEL: change tunnel parameters to those given 913 * %SIOCCHGTUNNEL: change tunnel parameters to those given
914 * %SIOCDELTUNNEL: delete tunnel 914 * %SIOCDELTUNNEL: delete tunnel
915 * 915 *
916 * The fallback device "ip6tnl0", created during module 916 * The fallback device "ip6tnl0", created during module
917 * initialization, can be used for creating other tunnel devices. 917 * initialization, can be used for creating other tunnel devices.
918 * 918 *
919 * Return: 919 * Return:
@@ -999,7 +999,8 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
999 break; 999 break;
1000 dev = t->dev; 1000 dev = t->dev;
1001 } 1001 }
1002 err = unregister_netdevice(dev); 1002 err = 0;
1003 unregister_netdevice(dev);
1003 break; 1004 break;
1004 default: 1005 default:
1005 err = -EINVAL; 1006 err = -EINVAL;
@@ -1008,7 +1009,7 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1008} 1009}
1009 1010
1010/** 1011/**
1011 * ip6ip6_tnl_get_stats - return the stats for tunnel device 1012 * ip6ip6_tnl_get_stats - return the stats for tunnel device
1012 * @dev: virtual device associated with tunnel 1013 * @dev: virtual device associated with tunnel
1013 * 1014 *
1014 * Return: stats for device 1015 * Return: stats for device
@@ -1101,7 +1102,7 @@ ip6ip6_tnl_dev_init(struct net_device *dev)
1101 * Return: 0 1102 * Return: 0
1102 **/ 1103 **/
1103 1104
1104static int 1105static int
1105ip6ip6_fb_tnl_dev_init(struct net_device *dev) 1106ip6ip6_fb_tnl_dev_init(struct net_device *dev)
1106{ 1107{
1107 struct ip6_tnl *t = netdev_priv(dev); 1108 struct ip6_tnl *t = netdev_priv(dev);