From patchwork Sat Dec 6 01:10:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 418333 X-Patchwork-Delegate: shemminger@vyatta.com 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 CF49A140129 for ; Sat, 6 Dec 2014 12:10:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751738AbaLFBKv (ORCPT ); Fri, 5 Dec 2014 20:10:51 -0500 Received: from mail-ie0-f179.google.com ([209.85.223.179]:33981 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbaLFBKu (ORCPT ); Fri, 5 Dec 2014 20:10:50 -0500 Received: by mail-ie0-f179.google.com with SMTP id rp18so1790934iec.10 for ; Fri, 05 Dec 2014 17:10:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=2WfLI4ezjQuQCmK8PW7wMr7CYuAzg6j6Aub31SVEnMo=; b=Sm9vIkTjqlnNw22/ZGi/OMDNTMkCDaRpj7CsOtmpjijYD7y25/IuNxCMMpKxATQ6vI sy/r8RxmilPfNJ+s5GCzivSz4scn7YdLfwIyhVB+HqCMvbkLOKxV6fjC47oTT2wKj8F4 nQ7oaAwozecpgSCu1Fb0EyZRs7Yb8vweCiv7t1ECcfIOhxL3glgh0wr8jzCxIphGf4em EzCfV1yJgaQt1Ji+p2JO9EWv8/Hde1h4EAJcczOnbCYTYB6XQBDK8cyIus2aDi5nWb5N ohjM1t3n/2ESaGLsNkgFvRGo5BN5g4qweBAJQPACHHU62XZPi09Oyk9S26rYYhvtF8Tw 67mA== X-Received: by 10.42.203.199 with SMTP id fj7mr18311658icb.60.1417828249437; Fri, 05 Dec 2014 17:10:49 -0800 (PST) Received: from ?IPv6:2620:0:1000:3e02:4839:27a9:1af0:3844? ([2620:0:1000:3e02:4839:27a9:1af0:3844]) by mx.google.com with ESMTPSA id la3sm58792igb.0.2014.12.05.17.10.48 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 05 Dec 2014 17:10:48 -0800 (PST) Message-ID: <1417828247.15618.19.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: iproute2/nstat: Bug in displaying icmp stats From: Eric Dumazet To: Vijay Subramanian Cc: netdev Date: Fri, 05 Dec 2014 17:10:47 -0800 In-Reply-To: References: X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2014-12-05 at 15:35 -0800, Vijay Subramanian wrote: > Hi, > > I noticed nstat is displaying icmp stats incorrectly. > > $ cat /proc/net/snmp | grep Icmp | head -2 | awk '{print $1 " " $2 " " > $3 " " $4}' > Icmp: InMsgs InErrors InCsumErrors > Icmp: 215 0 0 > > $ nstat -az | grep IcmpIn | head -3 > IcmpInMsgs 0 0.0 > IcmpInErrors 215 0.0 > IcmpInCsumErrors 0 0.0 > > For example, as seen in /proc/net/snmp, IcmpInMsgs should be 215 but > that value is assigned to IcmpInErrors. > > The issue seems to be the way the values are populated. > > $vim +209 misc/nstat.c > -----x---- > > /* Trick to skip "dummy" trailing ICMP MIB in 2.4 */ > > if (strcmp(idbuf, "IcmpOutAddrMaskReps") == 0) > > idbuf[5] = 0; > > else > > n = n->next; > > -----x------ > > It seems "IcmpOutAddrMaskReps" is processed twice and values assigned > are off by one. > > Any idea what the code is doing for 2.4 kernel and how to fix this? > > vijay According to git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git This was fixed in 2002 : commit b838c6d5c189d03d3db56c2774de451cf041a39f Author: Erik Schoenfelder Date: Sun Sep 29 03:56:52 2002 -0700 net/ipv4/proc.c: Dont print dummy member of icmp_mib. --- 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/proc.c b/net/ipv4/proc.c index 649620a..3f2dbcb 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -128,7 +128,7 @@ int snmp_get_info(char *buffer, char **start, off_t offset, int length) len += sprintf (buffer + len, "\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps\n" "Icmp:"); - for (i=0; i