Skip to content

Commit

Permalink
ipip: fix percpu stats accounting
Browse files Browse the repository at this point in the history
commit 3c97af9 (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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 29, 2010
1 parent 6d81f41 commit fada563
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/ipv4/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ static int ipip_tunnel_init(struct net_device *dev)
return 0;
}

static void __net_init ipip_fb_tunnel_init(struct net_device *dev)
static int __net_init ipip_fb_tunnel_init(struct net_device *dev)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
struct iphdr *iph = &tunnel->parms.iph;
Expand All @@ -802,8 +802,13 @@ static void __net_init ipip_fb_tunnel_init(struct net_device *dev)
iph->protocol = IPPROTO_IPIP;
iph->ihl = 5;

dev->tstats = alloc_percpu(struct pcpu_tstats);
if (!dev->tstats)
return -ENOMEM;

dev_hold(dev);
rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
return 0;
}

static struct xfrm_tunnel ipip_handler __read_mostly = {
Expand Down Expand Up @@ -852,15 +857,17 @@ static int __net_init ipip_init_net(struct net *net)
}
dev_net_set(ipn->fb_tunnel_dev, net);

ipip_fb_tunnel_init(ipn->fb_tunnel_dev);
err = ipip_fb_tunnel_init(ipn->fb_tunnel_dev);
if (err)
goto err_reg_dev;

if ((err = register_netdev(ipn->fb_tunnel_dev)))
goto err_reg_dev;

return 0;

err_reg_dev:
free_netdev(ipn->fb_tunnel_dev);
ipip_dev_free(ipn->fb_tunnel_dev);
err_alloc_dev:
/* nothing */
return err;
Expand Down

0 comments on commit fada563

Please sign in to comment.