diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-09-27 22:17:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-29 16:25:21 -0400 |
commit | dd4080ee575db1a2d0f40538aed5aa7662a06c54 (patch) | |
tree | 7e8627bf0bb37ada382b5d34d15073c4fcfb2366 /net/ipv6 | |
parent | fada5636fe41fd1423fe4e6af7b9f609378acde6 (diff) |
sit: fix percpu stats accounting
commit 15fc1f7056ebd (sit: percpu stats accounting) forgot the fallback
tunnel case (sit0), 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/ipv6')
-rw-r--r-- | net/ipv6/sit.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 011ecf55d34e..2cb646079237 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -1160,7 +1160,7 @@ static int ipip6_tunnel_init(struct net_device *dev) | |||
1160 | return 0; | 1160 | return 0; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | static void __net_init ipip6_fb_tunnel_init(struct net_device *dev) | 1163 | static int __net_init ipip6_fb_tunnel_init(struct net_device *dev) |
1164 | { | 1164 | { |
1165 | struct ip_tunnel *tunnel = netdev_priv(dev); | 1165 | struct ip_tunnel *tunnel = netdev_priv(dev); |
1166 | struct iphdr *iph = &tunnel->parms.iph; | 1166 | struct iphdr *iph = &tunnel->parms.iph; |
@@ -1175,8 +1175,12 @@ static void __net_init ipip6_fb_tunnel_init(struct net_device *dev) | |||
1175 | iph->ihl = 5; | 1175 | iph->ihl = 5; |
1176 | iph->ttl = 64; | 1176 | iph->ttl = 64; |
1177 | 1177 | ||
1178 | dev->tstats = alloc_percpu(struct pcpu_tstats); | ||
1179 | if (!dev->tstats) | ||
1180 | return -ENOMEM; | ||
1178 | dev_hold(dev); | 1181 | dev_hold(dev); |
1179 | sitn->tunnels_wc[0] = tunnel; | 1182 | sitn->tunnels_wc[0] = tunnel; |
1183 | return 0; | ||
1180 | } | 1184 | } |
1181 | 1185 | ||
1182 | static struct xfrm_tunnel sit_handler __read_mostly = { | 1186 | static struct xfrm_tunnel sit_handler __read_mostly = { |
@@ -1220,7 +1224,10 @@ static int __net_init sit_init_net(struct net *net) | |||
1220 | } | 1224 | } |
1221 | dev_net_set(sitn->fb_tunnel_dev, net); | 1225 | dev_net_set(sitn->fb_tunnel_dev, net); |
1222 | 1226 | ||
1223 | ipip6_fb_tunnel_init(sitn->fb_tunnel_dev); | 1227 | err = ipip6_fb_tunnel_init(sitn->fb_tunnel_dev); |
1228 | if (err) | ||
1229 | goto err_dev_free; | ||
1230 | |||
1224 | ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn); | 1231 | ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn); |
1225 | 1232 | ||
1226 | if ((err = register_netdev(sitn->fb_tunnel_dev))) | 1233 | if ((err = register_netdev(sitn->fb_tunnel_dev))) |
@@ -1230,7 +1237,8 @@ static int __net_init sit_init_net(struct net *net) | |||
1230 | 1237 | ||
1231 | err_reg_dev: | 1238 | err_reg_dev: |
1232 | dev_put(sitn->fb_tunnel_dev); | 1239 | dev_put(sitn->fb_tunnel_dev); |
1233 | free_netdev(sitn->fb_tunnel_dev); | 1240 | err_dev_free: |
1241 | ipip6_dev_free(sitn->fb_tunnel_dev); | ||
1234 | err_alloc_dev: | 1242 | err_alloc_dev: |
1235 | return err; | 1243 | return err; |
1236 | } | 1244 | } |