diff options
Diffstat (limited to 'net/ipv4/ipip.c')
| -rw-r--r-- | net/ipv4/ipip.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index eda04fed3379..ec036731a70b 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
| @@ -95,6 +95,7 @@ | |||
| 95 | #include <linux/module.h> | 95 | #include <linux/module.h> |
| 96 | #include <linux/types.h> | 96 | #include <linux/types.h> |
| 97 | #include <linux/kernel.h> | 97 | #include <linux/kernel.h> |
| 98 | #include <linux/slab.h> | ||
| 98 | #include <asm/uaccess.h> | 99 | #include <asm/uaccess.h> |
| 99 | #include <linux/skbuff.h> | 100 | #include <linux/skbuff.h> |
| 100 | #include <linux/netdevice.h> | 101 | #include <linux/netdevice.h> |
| @@ -130,7 +131,6 @@ struct ipip_net { | |||
| 130 | struct net_device *fb_tunnel_dev; | 131 | struct net_device *fb_tunnel_dev; |
| 131 | }; | 132 | }; |
| 132 | 133 | ||
| 133 | static void ipip_fb_tunnel_init(struct net_device *dev); | ||
| 134 | static void ipip_tunnel_init(struct net_device *dev); | 134 | static void ipip_tunnel_init(struct net_device *dev); |
| 135 | static void ipip_tunnel_setup(struct net_device *dev); | 135 | static void ipip_tunnel_setup(struct net_device *dev); |
| 136 | 136 | ||
| @@ -374,11 +374,8 @@ static int ipip_rcv(struct sk_buff *skb) | |||
| 374 | skb->protocol = htons(ETH_P_IP); | 374 | skb->protocol = htons(ETH_P_IP); |
| 375 | skb->pkt_type = PACKET_HOST; | 375 | skb->pkt_type = PACKET_HOST; |
| 376 | 376 | ||
| 377 | tunnel->dev->stats.rx_packets++; | 377 | skb_tunnel_rx(skb, tunnel->dev); |
| 378 | tunnel->dev->stats.rx_bytes += skb->len; | 378 | |
| 379 | skb->dev = tunnel->dev; | ||
| 380 | skb_dst_drop(skb); | ||
| 381 | nf_reset(skb); | ||
| 382 | ipip_ecn_decapsulate(iph, skb); | 379 | ipip_ecn_decapsulate(iph, skb); |
| 383 | netif_rx(skb); | 380 | netif_rx(skb); |
| 384 | rcu_read_unlock(); | 381 | rcu_read_unlock(); |
| @@ -438,7 +435,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 438 | goto tx_error_icmp; | 435 | goto tx_error_icmp; |
| 439 | } | 436 | } |
| 440 | } | 437 | } |
| 441 | tdev = rt->u.dst.dev; | 438 | tdev = rt->dst.dev; |
| 442 | 439 | ||
| 443 | if (tdev == dev) { | 440 | if (tdev == dev) { |
| 444 | ip_rt_put(rt); | 441 | ip_rt_put(rt); |
| @@ -449,7 +446,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 449 | df |= old_iph->frag_off & htons(IP_DF); | 446 | df |= old_iph->frag_off & htons(IP_DF); |
| 450 | 447 | ||
| 451 | if (df) { | 448 | if (df) { |
| 452 | mtu = dst_mtu(&rt->u.dst) - sizeof(struct iphdr); | 449 | mtu = dst_mtu(&rt->dst) - sizeof(struct iphdr); |
| 453 | 450 | ||
| 454 | if (mtu < 68) { | 451 | if (mtu < 68) { |
| 455 | stats->collisions++; | 452 | stats->collisions++; |
| @@ -506,7 +503,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 506 | IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | | 503 | IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | |
| 507 | IPSKB_REROUTED); | 504 | IPSKB_REROUTED); |
| 508 | skb_dst_drop(skb); | 505 | skb_dst_drop(skb); |
| 509 | skb_dst_set(skb, &rt->u.dst); | 506 | skb_dst_set(skb, &rt->dst); |
| 510 | 507 | ||
| 511 | /* | 508 | /* |
| 512 | * Push down and install the IPIP header. | 509 | * Push down and install the IPIP header. |
| @@ -555,7 +552,7 @@ static void ipip_tunnel_bind_dev(struct net_device *dev) | |||
| 555 | .proto = IPPROTO_IPIP }; | 552 | .proto = IPPROTO_IPIP }; |
| 556 | struct rtable *rt; | 553 | struct rtable *rt; |
| 557 | if (!ip_route_output_key(dev_net(dev), &rt, &fl)) { | 554 | if (!ip_route_output_key(dev_net(dev), &rt, &fl)) { |
| 558 | tdev = rt->u.dst.dev; | 555 | tdev = rt->dst.dev; |
| 559 | ip_rt_put(rt); | 556 | ip_rt_put(rt); |
| 560 | } | 557 | } |
| 561 | dev->flags |= IFF_POINTOPOINT; | 558 | dev->flags |= IFF_POINTOPOINT; |
| @@ -730,7 +727,7 @@ static void ipip_tunnel_init(struct net_device *dev) | |||
| 730 | ipip_tunnel_bind_dev(dev); | 727 | ipip_tunnel_bind_dev(dev); |
| 731 | } | 728 | } |
| 732 | 729 | ||
| 733 | static void ipip_fb_tunnel_init(struct net_device *dev) | 730 | static void __net_init ipip_fb_tunnel_init(struct net_device *dev) |
| 734 | { | 731 | { |
| 735 | struct ip_tunnel *tunnel = netdev_priv(dev); | 732 | struct ip_tunnel *tunnel = netdev_priv(dev); |
| 736 | struct iphdr *iph = &tunnel->parms.iph; | 733 | struct iphdr *iph = &tunnel->parms.iph; |
| @@ -773,7 +770,7 @@ static void ipip_destroy_tunnels(struct ipip_net *ipn, struct list_head *head) | |||
| 773 | } | 770 | } |
| 774 | } | 771 | } |
| 775 | 772 | ||
| 776 | static int ipip_init_net(struct net *net) | 773 | static int __net_init ipip_init_net(struct net *net) |
| 777 | { | 774 | { |
| 778 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 775 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
| 779 | int err; | 776 | int err; |
| @@ -806,7 +803,7 @@ err_alloc_dev: | |||
| 806 | return err; | 803 | return err; |
| 807 | } | 804 | } |
| 808 | 805 | ||
| 809 | static void ipip_exit_net(struct net *net) | 806 | static void __net_exit ipip_exit_net(struct net *net) |
| 810 | { | 807 | { |
| 811 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 808 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
| 812 | LIST_HEAD(list); | 809 | LIST_HEAD(list); |
| @@ -831,15 +828,14 @@ static int __init ipip_init(void) | |||
| 831 | 828 | ||
| 832 | printk(banner); | 829 | printk(banner); |
| 833 | 830 | ||
| 834 | if (xfrm4_tunnel_register(&ipip_handler, AF_INET)) { | 831 | err = register_pernet_device(&ipip_net_ops); |
| 832 | if (err < 0) | ||
| 833 | return err; | ||
| 834 | err = xfrm4_tunnel_register(&ipip_handler, AF_INET); | ||
| 835 | if (err < 0) { | ||
| 836 | unregister_pernet_device(&ipip_net_ops); | ||
| 835 | printk(KERN_INFO "ipip init: can't register tunnel\n"); | 837 | printk(KERN_INFO "ipip init: can't register tunnel\n"); |
| 836 | return -EAGAIN; | ||
| 837 | } | 838 | } |
| 838 | |||
| 839 | err = register_pernet_device(&ipip_net_ops); | ||
| 840 | if (err) | ||
| 841 | xfrm4_tunnel_deregister(&ipip_handler, AF_INET); | ||
| 842 | |||
| 843 | return err; | 839 | return err; |
| 844 | } | 840 | } |
| 845 | 841 | ||
