From patchwork Tue Sep 28 09:56:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 65951 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C377B70F2 for ; Tue, 28 Sep 2010 19:56:56 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753921Ab0I1J4v (ORCPT ); Tue, 28 Sep 2010 05:56:51 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:62383 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753214Ab0I1J4u (ORCPT ); Tue, 28 Sep 2010 05:56:50 -0400 Received: by fxm3 with SMTP id 3so2459103fxm.19 for ; Tue, 28 Sep 2010 02:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=+iY2fw7Z9zt2GW2DBgDomdLfPsW/gpUK70BfrsXiP5A=; b=A0PIFO3vzGnkl/FuIey8lizhbbQASkrOrGmS2DPObfdwtJTA9HbKcJIjYFEVMzIbq7 0RDahEIG+5Ermh6kKMKL9xxcmFmLW6Ev+Eq9Yqx5aiDst7n35R+1I8YPcfrUJHIsV6mX 0DbI58O/j1soVaRMqf9k9YIn02Q0jpCT4CtsM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=tooz/FrmUBKa9o66FKRxDo5nlMLuo5Lo6jascXrkafnG2ClhFYg4thdnTN2a5Wr1xP Z5V5nLjyJqpb5wi+CnrCGY8eitRrNgTQXWdx+R+HMDkJVuSfwZx0DMDVZLZXAqE14ISp X3FRJlJpqIQong787dQzWc0SiEzC/l/Sjhtxc= Received: by 10.223.106.8 with SMTP id v8mr9056215fao.42.1285667809109; Tue, 28 Sep 2010 02:56:49 -0700 (PDT) Received: from [10.150.51.220] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id 14sm2972208fav.26.2010.09.28.02.56.47 (version=SSLv3 cipher=RC4-MD5); Tue, 28 Sep 2010 02:56:48 -0700 (PDT) Subject: [PATCH net-next-2.6] ipip: fix percpu stats accounting From: Eric Dumazet To: David Miller Cc: netdev Date: Tue, 28 Sep 2010 11:56:46 +0200 Message-ID: <1285667806.3154.8.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org commit 3c97af99a5aa1 (ipip: percpu stats accounting) forgot the fallback tunnel case (tunl0), and can crash pretty fast. Signed-off-by: Eric Dumazet --- net/ipv4/ipip.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 12b6fde..9e78f11 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -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; @@ -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 = { @@ -852,7 +857,9 @@ 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; @@ -860,7 +867,7 @@ static int __net_init ipip_init_net(struct net *net) return 0; err_reg_dev: - free_netdev(ipn->fb_tunnel_dev); + ipip_dev_free(ipn->fb_tunnel_dev); err_alloc_dev: /* nothing */ return err;