From patchwork Sun Nov 1 12:35:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 315899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01C03C2D0A3 for ; Sun, 1 Nov 2020 12:38:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B39FD2223F for ; Sun, 1 Nov 2020 12:38:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q6frTauU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726588AbgKAMi3 (ORCPT ); Sun, 1 Nov 2020 07:38:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgKAMi0 (ORCPT ); Sun, 1 Nov 2020 07:38:26 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F521C0617A6 for ; Sun, 1 Nov 2020 04:38:26 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id d3so6864079wma.4 for ; Sun, 01 Nov 2020 04:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nJoOvIzuc/7uU26Wna8rdxyNpzSb0ihaLCFiqgwSV/s=; b=q6frTauU4fPIP3xTDfmui4WU+x34OXYBMajOkeJHyBrf4czr1AsVSCy9aw4q35+Lid 8h1WBADrmY+MlLHQMt7gVGDgpHBNgtZ4VvWA160Vqv7Sisbhd6h4Tg3O4wqzkTp6t+8Z DDo4tla1jgUQu+JnnpZ+PoYnZl19E8LWNw/C4rNxlo7T6jJyiujuCC7qtfUThWAYXyeF mRwVBo7BvcuFhziiH/4mPDm2a5hby/s1P6EfYdQ7CdA7f9bhi4ZOa0jHHK1atC0biBZh eL8tPRG/bSS9fGuc/sJv09Bi7J0j/yAaQhoPg5aDlXT4avKWWj9AGLKnV0d+/ipiAACP V1ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nJoOvIzuc/7uU26Wna8rdxyNpzSb0ihaLCFiqgwSV/s=; b=VU8XIKoO9GbXAalhzvKeG6X6IogdTvi6EYRufYV2mhanfs0ufaRqu6EaFyVbO1jDVT OjHjIAcJQUPDIOOdLYp83apAELozkCI3pOpDALn59Iyo0WOEmDmJFD3CLdzrGzTXbjN1 zaHtkF35l5miCOLVqBXI9UQmw2VhWG1XbD1bMMKxoAZ91ZuNT0msrgd6xbCFbTEwnSFj +9Sq+sPh+dMzlS02I5bI6OHXhn1vvlDbhSQArGzPimnAg/P33FCDNA2obuanmzQujeQS 9Hw7pt0pwjWSS5uAeYi5JENBbizElU1xLHhz/uFMxgLf6iMtG60AkSs4XEmHJ8noMxMe VEgg== X-Gm-Message-State: AOAM531u6gAvWQm0zIVAawvss7rCXl1FxgcB15fnTo6pbcyngBB1Oila FRbz+eYYor+qqVNa8alvrB9uvhmvezk= X-Google-Smtp-Source: ABdhPJzxjrrmVgCvJeChaFBYrVy1qU0gjA5b5UzvKKbEUopRAOEeMMIu5/EKhTOKV0g+xxtRcgpZNQ== X-Received: by 2002:a1c:f214:: with SMTP id s20mr12235919wmc.71.1604234304594; Sun, 01 Nov 2020 04:38:24 -0800 (PST) Received: from ?IPv6:2003:ea:8f23:2800:dc4f:e3f6:2803:90d0? (p200300ea8f232800dc4fe3f6280390d0.dip0.t-ipconnect.de. [2003:ea:8f23:2800:dc4f:e3f6:2803:90d0]) by smtp.googlemail.com with ESMTPSA id t6sm19904415wre.30.2020.11.01.04.38.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Nov 2020 04:38:24 -0800 (PST) Subject: [PATCH net-next 2/5] net: make ip_tunnel_get_stats64 an alias for dev_get_tstats64 From: Heiner Kallweit To: Jakub Kicinski , David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Russell King Cc: "netdev@vger.kernel.org" References: <25c7e008-c3fb-9fcd-f518-5d36e181c0cb@gmail.com> Message-ID: <944fa7d0-9b0e-5ae2-d4f8-9c609f1a7c20@gmail.com> Date: Sun, 1 Nov 2020 13:35:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <25c7e008-c3fb-9fcd-f518-5d36e181c0cb@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ip_tunnel_get_stats64() now is a duplicate of dev_get_tstats64(). Make it an alias so that we don't have to change all users of ip_tunnel_get_stats64(). Signed-off-by: Heiner Kallweit Reviewed-by: Florian Fainelli --- include/net/ip_tunnels.h | 4 ++-- net/ipv4/ip_tunnel_core.c | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 02ccd3254..500943ba8 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -274,8 +274,8 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict); int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu); -void ip_tunnel_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *tot); +#define ip_tunnel_get_stats64 dev_get_tstats64 + struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, int link, __be16 flags, __be32 remote, __be32 local, diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 25f1caf5a..923a9fa2e 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c @@ -429,15 +429,6 @@ int skb_tunnel_check_pmtu(struct sk_buff *skb, struct dst_entry *encap_dst, } EXPORT_SYMBOL(skb_tunnel_check_pmtu); -/* Often modified stats are per cpu, other are shared (netdev->stats) */ -void ip_tunnel_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *tot) -{ - netdev_stats_to_stats64(tot, &dev->stats); - dev_fetch_sw_netstats(tot, dev->tstats); -} -EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64); - static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { [LWTUNNEL_IP_UNSPEC] = { .strict_start_type = LWTUNNEL_IP_OPTS }, [LWTUNNEL_IP_ID] = { .type = NLA_U64 }, From patchwork Sun Nov 1 12:36:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 315898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 204DFC4741F for ; Sun, 1 Nov 2020 12:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD4FA20882 for ; Sun, 1 Nov 2020 12:38:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GlntBfZz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbgKAMie (ORCPT ); Sun, 1 Nov 2020 07:38:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbgKAMi1 (ORCPT ); Sun, 1 Nov 2020 07:38:27 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6734EC0617A6 for ; Sun, 1 Nov 2020 04:38:27 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id n15so11436974wrq.2 for ; Sun, 01 Nov 2020 04:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WWh8Icx3a6xt4/VTrwlKOf5ZL4xCuid/F8XraeHweps=; b=GlntBfZz2PjVNoWNDUf/Al+pwMRcHdkuhRH+7G4hrA6wCd7JkYsOZZZ4wB6tM3M1Ju bAm54vb63uWDCqtcBUay37fmpQjHsCPO4REZXncyOJQg1nnUoll+3ysKuJ+RJuFrN9/6 MBZ65PpJA44xWh1gbdPI9kUmTme3GuBi2+lxQindi+ty+DS4kunLvQJ9KXqv4Kdgua6Y eTX0Amjiu6PlZz8kubwp415rXaVEZR7d66FfrtFmnPAa4iWLe3llF19m1tNHjn0tVTGq m2HIS+ZAfBX2yUZHkUh+LGDuJoXKzHGma7N+QMyKJmeoggmlHC8DGLbizfTPboJPNs3l 0Jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WWh8Icx3a6xt4/VTrwlKOf5ZL4xCuid/F8XraeHweps=; b=l1UIC8HlXpld1cstO99HJtJjku3TDJ1Kd5Z8MDIXOsHGwKRzTiGegUc67fuYoN8ztM H0G7NYUpiXNBa19qYOXFObmXuqOiMGQ8QJagyeeRuFBXVnHCfMmNJg9XSkqJX5gt7Hvz FzOnDQyiNzAhsy+r5D8hMlhmlxnkBNcJOOPbUZWg8CneT8Bhxjvc09LW+sYyAWZjuTaC 2t6ORcI+u9pYgUVMLAkupuUXGHjartMNkhDjT/vC3rlYIKVoWvqVjS0E6qJbmVrEN7RF L3u84qV7qJB0UpDOZBoAb1gYyrWvjxJWFZj5iO92geJnzQ7e/R9/ey6VNJJy8jThyPGD VKuA== X-Gm-Message-State: AOAM533u6N7snNx17lArb1DJLyT9hPnrR+s0833oTH/wRIblqCkqqGgm k8DMGa7/6GSHm0zFz0LTbtT6AuZOo1g= X-Google-Smtp-Source: ABdhPJzbOkK55W2iMZAouV24tnq2hYwyo7fbIx7vYjwogZKprjTSYn90DfqijnHy3j9GH0yZDHid6g== X-Received: by 2002:adf:edcf:: with SMTP id v15mr13630083wro.291.1604234305916; Sun, 01 Nov 2020 04:38:25 -0800 (PST) Received: from ?IPv6:2003:ea:8f23:2800:dc4f:e3f6:2803:90d0? (p200300ea8f232800dc4fe3f6280390d0.dip0.t-ipconnect.de. [2003:ea:8f23:2800:dc4f:e3f6:2803:90d0]) by smtp.googlemail.com with ESMTPSA id i2sm3358943wmc.28.2020.11.01.04.38.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Nov 2020 04:38:25 -0800 (PST) Subject: [PATCH net-next 3/5] ip6_tunnel: use ip_tunnel_get_stats64 as ndo_get_stats64 callback From: Heiner Kallweit To: Jakub Kicinski , David Miller , Alexey Kuznetsov , Hideaki YOSHIFUJI , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Russell King Cc: "netdev@vger.kernel.org" References: <25c7e008-c3fb-9fcd-f518-5d36e181c0cb@gmail.com> Message-ID: Date: Sun, 1 Nov 2020 13:36:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <25c7e008-c3fb-9fcd-f518-5d36e181c0cb@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Switch ip6_tunnel to the standard statistics pattern: - use dev->stats for the less frequently accessed counters - use dev->tstats for the frequently accessed counters An additional benefit is that we now have 64bit statistics also on 32bit systems. Signed-off-by: Heiner Kallweit --- net/ipv6/ip6_tunnel.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index a0217e5bf..4ba18d9f9 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -94,36 +94,6 @@ static inline int ip6_tnl_mpls_supported(void) return IS_ENABLED(CONFIG_MPLS); } -static struct net_device_stats *ip6_get_stats(struct net_device *dev) -{ - struct pcpu_sw_netstats tmp, sum = { 0 }; - int i; - - for_each_possible_cpu(i) { - unsigned int start; - const struct pcpu_sw_netstats *tstats = - per_cpu_ptr(dev->tstats, i); - - do { - start = u64_stats_fetch_begin_irq(&tstats->syncp); - tmp.rx_packets = tstats->rx_packets; - tmp.rx_bytes = tstats->rx_bytes; - tmp.tx_packets = tstats->tx_packets; - tmp.tx_bytes = tstats->tx_bytes; - } while (u64_stats_fetch_retry_irq(&tstats->syncp, start)); - - sum.rx_packets += tmp.rx_packets; - sum.rx_bytes += tmp.rx_bytes; - sum.tx_packets += tmp.tx_packets; - sum.tx_bytes += tmp.tx_bytes; - } - dev->stats.rx_packets = sum.rx_packets; - dev->stats.rx_bytes = sum.rx_bytes; - dev->stats.tx_packets = sum.tx_packets; - dev->stats.tx_bytes = sum.tx_bytes; - return &dev->stats; -} - #define for_each_ip6_tunnel_rcu(start) \ for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) @@ -1835,7 +1805,7 @@ static const struct net_device_ops ip6_tnl_netdev_ops = { .ndo_start_xmit = ip6_tnl_start_xmit, .ndo_do_ioctl = ip6_tnl_ioctl, .ndo_change_mtu = ip6_tnl_change_mtu, - .ndo_get_stats = ip6_get_stats, + .ndo_get_stats64 = ip_tunnel_get_stats64, .ndo_get_iflink = ip6_tnl_get_iflink, };