aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_tunnel.c
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2014-02-13 14:46:28 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-14 15:49:55 -0500
commit1c213bd24ad04f4430031d20d740d7783162b099 (patch)
treeeb42b8d216e89008065634185fd6a5fcce5ec4e9 /net/ipv4/ip_tunnel.c
parented1acc8cd8c22efa919da8d300bab646e01c2dce (diff)
net: introduce netdev_alloc_pcpu_stats() for drivers
There are many drivers calling alloc_percpu() to allocate pcpu stats and then initializing ->syncp. So just introduce a helper function for them. Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_tunnel.c')
-rw-r--r--net/ipv4/ip_tunnel.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 50228be5c17b..3400d737adc6 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -1041,19 +1041,13 @@ int ip_tunnel_init(struct net_device *dev)
1041{ 1041{
1042 struct ip_tunnel *tunnel = netdev_priv(dev); 1042 struct ip_tunnel *tunnel = netdev_priv(dev);
1043 struct iphdr *iph = &tunnel->parms.iph; 1043 struct iphdr *iph = &tunnel->parms.iph;
1044 int i, err; 1044 int err;
1045 1045
1046 dev->destructor = ip_tunnel_dev_free; 1046 dev->destructor = ip_tunnel_dev_free;
1047 dev->tstats = alloc_percpu(struct pcpu_sw_netstats); 1047 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1048 if (!dev->tstats) 1048 if (!dev->tstats)
1049 return -ENOMEM; 1049 return -ENOMEM;
1050 1050
1051 for_each_possible_cpu(i) {
1052 struct pcpu_sw_netstats *ipt_stats;
1053 ipt_stats = per_cpu_ptr(dev->tstats, i);
1054 u64_stats_init(&ipt_stats->syncp);
1055 }
1056
1057 tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst); 1051 tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst);
1058 if (!tunnel->dst_cache) { 1052 if (!tunnel->dst_cache) {
1059 free_percpu(dev->tstats); 1053 free_percpu(dev->tstats);