aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipip.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-09-27 19:56:46 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-29 16:23:50 -0400
commitfada5636fe41fd1423fe4e6af7b9f609378acde6 (patch)
treeb9cf69a96229907f903d322b2a60f349c1d15903 /net/ipv4/ipip.c
parent6d81f41c58c69ddde497e9e640ba5805aa26e78c (diff)
ipip: fix percpu stats accounting
commit 3c97af99a5aa1 (ipip: percpu stats accounting) forgot the fallback tunnel case (tunl0), and can crash pretty fast. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipip.c')
-rw-r--r--net/ipv4/ipip.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 12b6fde6f65a..9e78f11da786 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -789,7 +789,7 @@ static int ipip_tunnel_init(struct net_device *dev)
789 return 0; 789 return 0;
790} 790}
791 791
792static void __net_init ipip_fb_tunnel_init(struct net_device *dev) 792static int __net_init ipip_fb_tunnel_init(struct net_device *dev)
793{ 793{
794 struct ip_tunnel *tunnel = netdev_priv(dev); 794 struct ip_tunnel *tunnel = netdev_priv(dev);
795 struct iphdr *iph = &tunnel->parms.iph; 795 struct iphdr *iph = &tunnel->parms.iph;
@@ -802,8 +802,13 @@ static void __net_init ipip_fb_tunnel_init(struct net_device *dev)
802 iph->protocol = IPPROTO_IPIP; 802 iph->protocol = IPPROTO_IPIP;
803 iph->ihl = 5; 803 iph->ihl = 5;
804 804
805 dev->tstats = alloc_percpu(struct pcpu_tstats);
806 if (!dev->tstats)
807 return -ENOMEM;
808
805 dev_hold(dev); 809 dev_hold(dev);
806 rcu_assign_pointer(ipn->tunnels_wc[0], tunnel); 810 rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
811 return 0;
807} 812}
808 813
809static struct xfrm_tunnel ipip_handler __read_mostly = { 814static struct xfrm_tunnel ipip_handler __read_mostly = {
@@ -852,7 +857,9 @@ static int __net_init ipip_init_net(struct net *net)
852 } 857 }
853 dev_net_set(ipn->fb_tunnel_dev, net); 858 dev_net_set(ipn->fb_tunnel_dev, net);
854 859
855 ipip_fb_tunnel_init(ipn->fb_tunnel_dev); 860 err = ipip_fb_tunnel_init(ipn->fb_tunnel_dev);
861 if (err)
862 goto err_reg_dev;
856 863
857 if ((err = register_netdev(ipn->fb_tunnel_dev))) 864 if ((err = register_netdev(ipn->fb_tunnel_dev)))
858 goto err_reg_dev; 865 goto err_reg_dev;
@@ -860,7 +867,7 @@ static int __net_init ipip_init_net(struct net *net)
860 return 0; 867 return 0;
861 868
862err_reg_dev: 869err_reg_dev:
863 free_netdev(ipn->fb_tunnel_dev); 870 ipip_dev_free(ipn->fb_tunnel_dev);
864err_alloc_dev: 871err_alloc_dev:
865 /* nothing */ 872 /* nothing */
866 return err; 873 return err;