From owner-freebsd-net@FreeBSD.ORG Mon Nov 16 23:56:26 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 289DE106566B; Mon, 16 Nov 2009 23:56:26 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-bw0-f213.google.com (mail-bw0-f213.google.com [209.85.218.213]) by mx1.freebsd.org (Postfix) with ESMTP id 51AAB8FC12; Mon, 16 Nov 2009 23:56:24 +0000 (UTC) Received: by bwz5 with SMTP id 5so6637390bwz.3 for ; Mon, 16 Nov 2009 15:56:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=aQ79ro09pt0js5y3WkfVmJor4SrcS0pxixrTrlH8viQ=; b=lXOyChIg64ZZ4Aj3kXJTQsXEw9wWSOSGEkYJq6dNJQUQ8dFQa7IwxdywQWtTrYhw0h nmoI95xLDcnGE3mdqtY/5Wj4UESuwABfIWOFuC5GaN/OUdA3EhWQ5022WB27atDD31y4 X5rj1XFZg799yw3mpSqVZRcU0LsaKvyVbogTQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=ULGbR9AHk0oN2Q3NrdQIkfCenLfmzEadcyCmtKVoUgpUsGQ+/y2sWW48R5IiD1mvGm aXczqSgMikJd93/aESn9UE7kc72iByyzgnb5lu92PfvNaJCiJ+i8+Ag5wTCjAC3Pb8eC LxcY9KSbJcw6K9kHrAdMaUEH/OsNT+iXpnXEc= MIME-Version: 1.0 Sender: asmrookie@gmail.com Received: by 10.223.4.137 with SMTP id 9mr1280109far.95.1258415783563; Mon, 16 Nov 2009 15:56:23 -0800 (PST) In-Reply-To: <20091116233828.GG1262@michelle.cdnetworks.com> References: <3bbf2fe10911160715m34fc0ba4hc13af02541405491@mail.gmail.com> <20091116182423.GD1262@michelle.cdnetworks.com> <3bbf2fe10911161404s4c5870a4pe0afbb890e0fdde2@mail.gmail.com> <20091116233828.GG1262@michelle.cdnetworks.com> Date: Tue, 17 Nov 2009 00:56:23 +0100 X-Google-Sender-Auth: f238647dfdccdbd4 Message-ID: <3bbf2fe10911161556h6fb602a6qe5043fea590e7800@mail.gmail.com> From: Attilio Rao To: pyunyh@gmail.com Content-Type: text/plain; charset=UTF-8 Cc: freebsd-net@freebsd.org, Bruce Evans , John Baldwin Subject: Re: [PATCH] Add idrop report to netstat X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2009 23:56:26 -0000 2009/11/17 Pyun YongHyeon : > On Mon, Nov 16, 2009 at 11:04:20PM +0100, Attilio Rao wrote: >> 2009/11/16 Pyun YongHyeon : >> > On Mon, Nov 16, 2009 at 04:15:09PM +0100, Attilio Rao wrote: >> >> [Please CC me as I'm not subscribed to -net@] >> >> >> >> This patch allows to show the informations about packets droped on >> >> input for interfaces on netstat: >> >> http://www.freebsd.org/~attilio/Sandvine/STABLE_8/idrops/idrops.diff >> >> >> >> This patch as been contributed back from Sandvine Incorporated. >> >> Comments, reviews and testing are welcome. >> >> >> > >> > Doesn't -d of netstat(1) show the same information? >> >> Am I wrong or "-d" prints the drops on the output path? >> The patch provides information on the input drops. >> > > struct if_data { > /* generic interface information */ > u_char ifi_type; /* ethernet, tokenring, etc */ > u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ > [...] > u_long ifi_iqdrops; /* dropped on input, this interface */ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > u_long ifi_noproto; /* destined for unsupported protocol */ > u_long ifi_hwassist; /* HW offload capabilities, see IFCAP */ > time_t ifi_epoch; /* uptime at attach or stat reset */ > struct timeval ifi_lastchange; /* time of last administrative change */ > }; Err, but dflag does print out if_snd.ifq_drops. Infact: @if.c:sidewaysintpr() [...] if (!first) { show_stat("lu", 10, ifnet.if_ipackets - ip->ift_ip, 1); show_stat("lu", 5, ifnet.if_ierrors - ip->ift_ie, 1); show_stat("lu", 10, ifnet.if_ibytes - ip->ift_ib, 1); show_stat("lu", 10, ifnet.if_opackets - ip->ift_op, 1); show_stat("lu", 5, ifnet.if_oerrors - ip->ift_oe, 1); show_stat("lu", 10, ifnet.if_obytes - ip->ift_ob, 1); show_stat("NRSlu", 5, ifnet.if_collisions - ip->ift_co, 1); if (dflag) show_stat("LSu", 5, ifnet.if_snd.ifq_drops - ip->ift_dr, 1); } [...] if (!first) { show_stat("lu", 10, sum->ift_ip - total->ift_ip, 1); show_stat("lu", 5, sum->ift_ie - total->ift_ie, 1); show_stat("lu", 10, sum->ift_ib - total->ift_ib, 1); show_stat("lu", 10, sum->ift_op - total->ift_op, 1); show_stat("lu", 5, sum->ift_oe - total->ift_oe, 1); show_stat("lu", 10, sum->ift_ob - total->ift_ob, 1); show_stat("NRSlu", 5, sum->ift_co - total->ift_co, 1); if (dflag) show_stat("LSu", 5, sum->ift_dr - total->ift_dr, 1); } Which is defined in sys/net/if_var.h as: struct ifnet { void *if_softc; /* pointer to driver state */ void *if_l2com; /* pointer to protocol bits */ struct vnet *if_vnet; /* pointer to network stack instance */ [...] int if_drv_flags; /* driver-managed status flags */ struct ifaltq if_snd; /* output queue (includes altq) */ const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ [...] }; Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein