Date: Thu, 3 Apr 2014 14:58:52 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r264076 - in stable/10: sys/net usr.bin/netstat Message-ID: <201404031458.s33Ewq90031775@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Thu Apr 3 14:58:52 2014 New Revision: 264076 URL: http://svnweb.freebsd.org/changeset/base/264076 Log: o Provide a compatibility shim for netstat(1) to obtain output queue drops via NET_RT_IFLISTL sysctl. The sysctl handler appends oqdrops at the end of struct if_msghdrl, and netstat(1) sees that as an additional field of struct if_data. This allows us to fetch the data keeping ABI and API compatibility. This is direct commit to stable/10. o Merge r263331 from head, to restore printing of queue drops. Sponsored by: Nginx, Inc. Sponsored by: Netflix Modified: stable/10/sys/net/if.h stable/10/sys/net/rtsock.c stable/10/usr.bin/netstat/if.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/if.h ============================================================================== --- stable/10/sys/net/if.h Thu Apr 3 14:47:36 2014 (r264075) +++ stable/10/sys/net/if.h Thu Apr 3 14:58:52 2014 (r264076) @@ -106,6 +106,9 @@ struct if_data { uint64_t 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 */ +#ifdef _IFI_OQDROPS + u_long ifi_oqdrops; /* dropped on output */ +#endif }; /*- @@ -283,6 +286,9 @@ struct if_msghdrl { u_short ifm_len; /* length of if_msghdrl incl. if_data */ u_short ifm_data_off; /* offset of if_data from beginning */ struct if_data ifm_data;/* statistics and other data about if */ +#ifdef _IN_NET_RTSOCK_C + u_long ifi_oqdrops; +#endif }; /* Modified: stable/10/sys/net/rtsock.c ============================================================================== --- stable/10/sys/net/rtsock.c Thu Apr 3 14:47:36 2014 (r264075) +++ stable/10/sys/net/rtsock.c Thu Apr 3 14:58:52 2014 (r264076) @@ -52,6 +52,7 @@ #include <sys/sysctl.h> #include <sys/systm.h> +#define _IN_NET_RTSOCK_C #include <net/if.h> #include <net/if_dl.h> #include <net/if_llatbl.h> @@ -105,6 +106,7 @@ struct if_data32 { uint32_t ifi_hwassist; int32_t ifi_epoch; struct timeval32 ifi_lastchange; + uint32_t ifi_oqdrops; }; struct if_msghdr32 { @@ -1662,6 +1664,7 @@ sysctl_iflist_ifml(struct ifnet *ifp, st if (carp_get_vhid_p != NULL) ifm32->ifm_data.ifi_vhid = (*carp_get_vhid_p)(ifp->if_addr); + ifm32->ifm_data.ifi_oqdrops = ifp->if_snd.ifq_drops; return (SYSCTL_OUT(w->w_req, (caddr_t)ifm32, len)); } @@ -1679,6 +1682,9 @@ sysctl_iflist_ifml(struct ifnet *ifp, st if (carp_get_vhid_p != NULL) ifm->ifm_data.ifi_vhid = (*carp_get_vhid_p)(ifp->if_addr); + ifm->ifm_data.ifi_datalen += sizeof(u_long); + ifm->ifi_oqdrops = ifp->if_snd.ifq_drops; + return (SYSCTL_OUT(w->w_req, (caddr_t)ifm, len)); } Modified: stable/10/usr.bin/netstat/if.c ============================================================================== --- stable/10/usr.bin/netstat/if.c Thu Apr 3 14:47:36 2014 (r264075) +++ stable/10/usr.bin/netstat/if.c Thu Apr 3 14:58:52 2014 (r264076) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/time.h> +#define _IFI_OQDROPS #include <net/if.h> #include <net/if_var.h> #include <net/if_dl.h> @@ -251,7 +252,7 @@ intpr(int interval, void (*pfunc)(char * printf(" %10.10s","Obytes"); printf(" %5s", "Coll"); if (dflag) - printf(" %s", "Drop"); + printf(" %s", "Drop"); putchar('\n'); } @@ -382,7 +383,8 @@ intpr(int interval, void (*pfunc)(char * if (bflag) show_stat("lu", 10, IFA_STAT(obytes), link|network); show_stat("NRSlu", 5, IFA_STAT(collisions), link); - /* XXXGL: output queue drops */ + if (dflag) + show_stat("LSlu", 5, IFA_STAT(oqdrops), link); putchar('\n'); if (!aflag) @@ -460,6 +462,7 @@ struct iftot { u_long ift_id; /* input drops */ u_long ift_op; /* output packets */ u_long ift_oe; /* output errors */ + u_long ift_od; /* output drops */ u_long ift_co; /* collisions */ u_long ift_ib; /* input bytes */ u_long ift_ob; /* output bytes */ @@ -495,6 +498,7 @@ fill_iftot(struct iftot *st) st->ift_ib += IFA_STAT(ibytes); st->ift_op += IFA_STAT(opackets); st->ift_oe += IFA_STAT(oerrors); + st->ift_od += IFA_STAT(oqdrops); st->ift_ob += IFA_STAT(obytes); st->ift_co += IFA_STAT(collisions); } @@ -573,7 +577,8 @@ loop: show_stat("lu", 5, new->ift_oe - old->ift_oe, 1); show_stat("lu", 10, new->ift_ob - old->ift_ob, 1); show_stat("NRSlu", 5, new->ift_co - old->ift_co, 1); - /* XXXGL: output queue drops */ + if (dflag) + show_stat("LSlu", 5, new->ift_od - old->ift_od, 1); putchar('\n'); fflush(stdout);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404031458.s33Ewq90031775>