From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net-next,v2] IPv6 ifstats separation Date: Thu, 4 Oct 2018 13:42:06 -0700 Message-ID: References: <20181004190828.26536-1-ssuryaextr@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Stephen Suryaputra , netdev@vger.kernel.org Return-path: Received: from mail-pf1-f194.google.com ([209.85.210.194]:41359 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727519AbeJEDhH (ORCPT ); Thu, 4 Oct 2018 23:37:07 -0400 Received: by mail-pf1-f194.google.com with SMTP id m77-v6so3947772pfi.8 for ; Thu, 04 Oct 2018 13:42:09 -0700 (PDT) In-Reply-To: <20181004190828.26536-1-ssuryaextr@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/04/2018 12:08 PM, Stephen Suryaputra wrote: > Separate IPv6 ifstats into the ones that are hit on fast path and > the ones that aren't. The ones that are not can be removed as needed > using sysctls. > > The separation minimizes percpu data. It reduces from 288 bytes per cpu to 56 > bytes. When the other stats are disabled, then it adds 4144 bytes saving per > netdev. > > The stats that are hit on fast path are percpu and the existing macro that > increments them is added with a constant check that should be optimized by the > preprocessor. > > This is done based on some feedbacks in the past to make IPv6 stats optional. > It doesn't fully accomplish that but it enables all but 6 counters be optional. > Those optional counters however are still enabled by default to preserve the > current behavior. > How have you decided some counters can be 'slow' and other 'fast' ? I can tell you I see many ultra-fast candidates in your 'slow' list :/ Also think about DDOS. After your patch, all these 'wrong packets' will incur an expensive operation on a shared and highly contented cache line, effectively making the attack easier to conduct. +static const struct snmp_mib snmp6_ipstats_device_list[] = { + SNMP_MIB_ITEM("Ip6InHdrErrors", IPSTATS_MIB_INHDRERRORS), + SNMP_MIB_ITEM("Ip6InTooBigErrors", IPSTATS_MIB_INTOOBIGERRORS), + SNMP_MIB_ITEM("Ip6InNoRoutes", IPSTATS_MIB_INNOROUTES), + SNMP_MIB_ITEM("Ip6InAddrErrors", IPSTATS_MIB_INADDRERRORS), + SNMP_MIB_ITEM("Ip6InUnknownProtos", IPSTATS_MIB_INUNKNOWNPROTOS), + SNMP_MIB_ITEM("Ip6InTruncatedPkts", IPSTATS_MIB_INTRUNCATEDPKTS), + SNMP_MIB_ITEM("Ip6InDiscards", IPSTATS_MIB_INDISCARDS), + SNMP_MIB_ITEM("Ip6OutDiscards", IPSTATS_MIB_OUTDISCARDS), + SNMP_MIB_ITEM("Ip6OutNoRoutes", IPSTATS_MIB_OUTNOROUTES), + SNMP_MIB_ITEM("Ip6ReasmTimeout", IPSTATS_MIB_REASMTIMEOUT), + SNMP_MIB_ITEM("Ip6ReasmReqds", IPSTATS_MIB_REASMREQDS), + SNMP_MIB_ITEM("Ip6ReasmOKs", IPSTATS_MIB_REASMOKS), + SNMP_MIB_ITEM("Ip6ReasmFails", IPSTATS_MIB_REASMFAILS), + SNMP_MIB_ITEM("Ip6FragOKs", IPSTATS_MIB_FRAGOKS), + SNMP_MIB_ITEM("Ip6FragFails", IPSTATS_MIB_FRAGFAILS), + SNMP_MIB_ITEM("Ip6FragCreates", IPSTATS_MIB_FRAGCREATES), + SNMP_MIB_ITEM("Ip6InMcastPkts", IPSTATS_MIB_INMCASTPKTS), + SNMP_MIB_ITEM("Ip6OutMcastPkts", IPSTATS_MIB_OUTMCASTPKTS), + SNMP_MIB_ITEM("Ip6InMcastOctets", IPSTATS_MIB_INMCASTOCTETS), + SNMP_MIB_ITEM("Ip6OutMcastOctets", IPSTATS_MIB_OUTMCASTOCTETS), + SNMP_MIB_ITEM("Ip6InBcastOctets", IPSTATS_MIB_INBCASTOCTETS), + SNMP_MIB_ITEM("Ip6OutBcastOctets", IPSTATS_MIB_OUTBCASTOCTETS), + /* IPSTATS_MIB_CSUMERRORS is not relevant in IPv6 (no checksum) */ + SNMP_MIB_ITEM("Ip6InNoECTPkts", IPSTATS_MIB_NOECTPKTS), + SNMP_MIB_ITEM("Ip6InECT1Pkts", IPSTATS_MIB_ECT1PKTS), + SNMP_MIB_ITEM("Ip6InECT0Pkts", IPSTATS_MIB_ECT0PKTS), + SNMP_MIB_ITEM("Ip6InCEPkts", IPSTATS_MIB_CEPKTS), + SNMP_MIB_SENTINEL +}; +