[PATCH] Add idrop report to netstat
pluknet
pluknet at gmail.com
Tue Nov 17 00:29:05 UTC 2009
2009/11/17 Attilio Rao <attilio at freebsd.org>:
> 2009/11/17 Pyun YongHyeon <pyunyh at gmail.com>:
>> On Mon, Nov 16, 2009 at 11:04:20PM +0100, Attilio Rao wrote:
>>> 2009/11/16 Pyun YongHyeon <pyunyh at gmail.com>:
>>> > 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 */
> [...]
> };
ifq_drops != *_iqdrops
Historically *_iqdrops was designed strictly to record falure to
allocate a buffer on Rx chain (or so).
while ifq_drops was for logically higher level: output and (some kind
of) input ifnet queue shortage stats.
[and that's recorded in the earlier BSD's. Though, input queue was
replaced later with netisr magics
in if_ethersubr.c, though it still possible to track the roots in
struct netist_work{ nw_len..nw_qlimit..nw_drops }).
--
wbr,
pluknet
More information about the freebsd-net
mailing list