ifnet: Add oqdrops statistics
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 27 Jun 2016 14:21:57 +0000 (22:21 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 27 Jun 2016 14:23:12 +0000 (22:23 +0800)
sys/net/if.c
sys/net/if.h
sys/net/if_mib.c
sys/net/if_var.h
sys/net/ifq_var.h
sys/net/ppp/if_ppp.c
sys/net/rtsock.c
sys/net/sl/if_sl.c
sys/net/sppp/if_spppsubr.c
sys/netproto/802_11/wlan/ieee80211_dragonfly.c
usr.bin/netstat/if.c

index 12cb693..b8456b9 100644 (file)
@@ -1697,6 +1697,7 @@ if_slowtimo_dispatch(netmsg_t nmsg)
                        IFNET_STAT_GET(ifp, omcasts, ifp->if_omcasts);
                        IFNET_STAT_GET(ifp, iqdrops, ifp->if_iqdrops);
                        IFNET_STAT_GET(ifp, noproto, ifp->if_noproto);
+                       IFNET_STAT_GET(ifp, oqdrops, ifp->if_oqdrops);
                }
 
                if (ifp->if_timer == 0 || --ifp->if_timer) {
@@ -3075,6 +3076,7 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa)
        ALTQ_SQ_LOCK(ifsq);
        error = ifsq_enqueue_locked(ifsq, m, pa);
        if (error) {
+               IFNET_STAT_INC(ifp, oqdrops, 1);
                if (!ifsq_data_ready(ifsq)) {
                        ALTQ_SQ_UNLOCK(ifsq);
                        crit_exit_quick(td);
index 5c79fd9..32855da 100644 (file)
@@ -94,7 +94,7 @@ struct if_data {
        u_long  ifi_iqdrops;            /* dropped on input, this interface */
        u_long  ifi_noproto;            /* destined for unsupported protocol */
        u_long  ifi_hwassist;           /* HW offload capabilities */
-       u_long  ifi_unused;             /* XXX was ifi_xmittiming */
+       u_long  ifi_oqdrops;            /* dropped on input, this interface */
        struct  timeval ifi_lastchange; /* time of last administrative change */
 };
 
index 736bf61..6a72ba2 100644 (file)
@@ -120,6 +120,7 @@ sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */
                COPY_DATA(omcasts);
                COPY_DATA(iqdrops);
                COPY_DATA(noproto);
+               COPY_DATA(oqdrops);
 #undef COPY_DATA
 
                ifmd.ifmd_snd_maxlen = ifp->if_snd.altq_maxlen;
@@ -164,6 +165,7 @@ sysctl_ifdata(SYSCTL_HANDLER_ARGS) /* XXX bad syntax! */
                COPY_DATA(omcasts);
                COPY_DATA(iqdrops);
                COPY_DATA(noproto);
+               COPY_DATA(oqdrops);
 #undef COPY_DATA
 
 #ifdef notyet
index f1fd5a4..6b84124 100644 (file)
@@ -436,6 +436,7 @@ typedef void if_init_f_t (void *);
 #define        if_omcasts      if_data.ifi_omcasts
 #define        if_iqdrops      if_data.ifi_iqdrops
 #define        if_noproto      if_data.ifi_noproto
+#define        if_oqdrops      if_data.ifi_oqdrops
 #define        if_lastchange   if_data.ifi_lastchange
 #define if_recvquota   if_data.ifi_recvquota
 #define        if_xmitquota    if_data.ifi_xmitquota
@@ -459,6 +460,7 @@ struct ifdata_pcpu {
        u_long  ifd_omcasts;            /* packets sent via multicast */
        u_long  ifd_iqdrops;            /* dropped on input, this interface */
        u_long  ifd_noproto;            /* destined for unsupported protocol */
+       u_long  ifd_oqdrops;            /* dropped on output, this interface */
 } __cachealign;
 
 #endif /* _KERNEL || _KERNEL_STRUCTURES */
index dca0f59..58def44 100644 (file)
@@ -399,6 +399,8 @@ ifq_handoff(struct ifnet *_ifp, struct mbuf *_m, struct altq_pktattr *_pa)
                        IFNET_STAT_INC(_ifp, omcasts, 1);
                if (!ifsq_is_oactive(_ifsq))
                        (*_ifp->if_start)(_ifp, _ifsq);
+       } else {
+               IFNET_STAT_INC(_ifp, oqdrops, 1);
        }
        return(_error);
 }
index f8d930b..114dcda 100644 (file)
@@ -855,7 +855,7 @@ pppoutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq,
        }
        if (error) {
            crit_exit();
-           IFNET_STAT_INC(&sc->sc_if, oerrors, 1);
+           IFNET_STAT_INC(&sc->sc_if, oqdrops, 1);
            sc->sc_stats.ppp_oerrors++;
            return (error);
        }
@@ -931,7 +931,7 @@ ppp_requeue(struct ppp_softc *sc)
                error = ifsq_enqueue(ifsq, m, NULL);
            }
            if (error) {
-                   IFNET_STAT_INC(&sc->sc_if, oerrors, 1);
+                   IFNET_STAT_INC(&sc->sc_if, oqdrops, 1);
                    sc->sc_stats.ppp_oerrors++;
            }
            break;
index c63187c..5038181 100644 (file)
@@ -1272,6 +1272,7 @@ ifnet_compute_stats(struct ifnet *ifp)
        IFNET_STAT_GET(ifp, omcasts, ifp->if_omcasts);
        IFNET_STAT_GET(ifp, iqdrops, ifp->if_iqdrops);
        IFNET_STAT_GET(ifp, noproto, ifp->if_noproto);
+       IFNET_STAT_GET(ifp, oqdrops, ifp->if_oqdrops);
 }
 
 static int
index 79f0b76..e824106 100644 (file)
@@ -504,7 +504,7 @@ sloutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq,
                error = ifsq_enqueue(ifsq, m, &pktattr);
        }
        if (error) {
-               IFNET_STAT_INC(&sc->sc_if, oerrors, 1);
+               IFNET_STAT_INC(&sc->sc_if, oqdrops, 1);
                crit_exit();
                return (error);
        }
index 02a9748..0f7a80c 100644 (file)
@@ -882,7 +882,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq,
                rv = ifsq_enqueue(ifsq, m, &pktattr);
        }
        if (rv) {
-               IFNET_STAT_INC(ifp, oerrors, 1);
+               IFNET_STAT_INC(ifp, oqdrops, 1);
                crit_exit();
                return(rv);
        }
index 98c0a17..71bc5f1 100644 (file)
@@ -289,6 +289,8 @@ ieee80211_vap_xmitpkt(struct ieee80211vap *vap, struct mbuf *m)
        IEEE80211_TX_UNLOCK_ASSERT(vap->iv_ic);
 
        error = ifsq_enqueue(ifsq, m, NULL);
+       if (error)
+               IFNET_STAT_INC(ifp, oqdrops, 1);
        wst = wlan_serialize_push();
        ifp->if_start(ifp, ifsq);
        wlan_serialize_pop(wst);
index e21c0fb..2364040 100644 (file)
@@ -124,8 +124,8 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr)
        u_long oerrors;
        u_long ierrors;
        u_long collisions;
+       u_long oqdrops;
        short timer;
-       int drops;
        struct sockaddr *sa = NULL;
        char name[IFNAMSIZ];
        short network_layer;
@@ -228,6 +228,7 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr)
                oerrors = ifdata.ifd_oerrors;
                ierrors = ifdata.ifd_ierrors;
                collisions = ifdata.ifd_collisions;
+               oqdrops = ifdata.ifd_oqdrops;
 
                for (cpu = 1; cpu < ncpus; ++cpu) {
                        if (kread(ifdataaddr + (cpu * sizeof(ifdata)),
@@ -240,10 +241,10 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr)
                        oerrors += ifdata.ifd_oerrors;
                        ierrors += ifdata.ifd_ierrors;
                        collisions += ifdata.ifd_collisions;
+                       oqdrops += ifdata.ifd_oqdrops;
                }
 
                timer = ifnet.if_timer;
-               drops = 0;
 
                if (ifaddraddr == 0) {
                        printf("%-7.7s %-5lu ", name, ifnet.if_mtu);
@@ -410,7 +411,7 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *), u_long ncpusaddr)
                }
                if (dflag) {
                        printf(" ");
-                       show_stat("d", 3, drops, link_layer);
+                       show_stat("lu", 5, oqdrops, link_layer);
                }
                putchar('\n');
                if (aflag && ifaddrfound) {
@@ -481,7 +482,7 @@ struct      iftot {
        u_long  ift_op;                 /* output packets */
        u_long  ift_oe;                 /* output errors */
        u_long  ift_co;                 /* collisions */
-       u_int   ift_dr;                 /* drops */
+       u_long  ift_dr;                 /* drops */
        u_long  ift_ib;                 /* input bytes */
        u_long  ift_ob;                 /* output bytes */
 };
@@ -587,6 +588,7 @@ loop:
                ifnet.if_oerrors = ifdata.ifd_oerrors;
                ifnet.if_obytes = ifdata.ifd_obytes;
                ifnet.if_collisions = ifdata.ifd_collisions;
+               ifnet.if_oqdrops = ifdata.ifd_oqdrops;
 
                for (cpu = 1; cpu < ncpus; ++cpu) {
                        if (kread(ifdata_addr + (cpu * sizeof(ifdata)),
@@ -601,6 +603,7 @@ loop:
                        ifnet.if_oerrors += ifdata.ifd_oerrors;
                        ifnet.if_obytes += ifdata.ifd_obytes;
                        ifnet.if_collisions += ifdata.ifd_collisions;
+                       ifnet.if_oqdrops += ifdata.ifd_oqdrops;
                }
 
                if (!first) {
@@ -613,7 +616,7 @@ loop:
                                ifnet.if_obytes - ip->ift_ob,
                                ifnet.if_collisions - ip->ift_co);
                        if (dflag)
-                               printf(" %5u", 0 - ip->ift_dr);
+                               printf(" %5lu", ifnet.if_oqdrops - ip->ift_dr);
                }
                ip->ift_ip = ifnet.if_ipackets;
                ip->ift_ie = ifnet.if_ierrors;
@@ -622,7 +625,7 @@ loop:
                ip->ift_oe = ifnet.if_oerrors;
                ip->ift_ob = ifnet.if_obytes;
                ip->ift_co = ifnet.if_collisions;
-               ip->ift_dr = 0;
+               ip->ift_dr = ifnet.if_oqdrops;
        } else {
                sum->ift_ip = 0;
                sum->ift_ie = 0;
@@ -653,6 +656,7 @@ loop:
                        ifnet.if_oerrors = ifdata.ifd_oerrors;
                        ifnet.if_obytes = ifdata.ifd_obytes;
                        ifnet.if_collisions = ifdata.ifd_collisions;
+                       ifnet.if_oqdrops = ifdata.ifd_oqdrops;
 
                        for (cpu = 1; cpu < ncpus; ++cpu) {
                                if (kread(ifdata_addr + (cpu * sizeof(ifdata)),
@@ -667,6 +671,7 @@ loop:
                                ifnet.if_oerrors += ifdata.ifd_oerrors;
                                ifnet.if_obytes += ifdata.ifd_obytes;
                                ifnet.if_collisions += ifdata.ifd_collisions;
+                               ifnet.if_oqdrops += ifdata.ifd_oqdrops;
                        }
 
                        /*
@@ -686,7 +691,7 @@ loop:
                                sum->ift_oe += ifnet.if_oerrors;
                                sum->ift_ob += ifnet.if_obytes;
                                sum->ift_co += ifnet.if_collisions;
-                               sum->ift_dr += 0;
+                               sum->ift_dr += ifnet.if_oqdrops;
                        }
                        off = (u_long)TAILQ_NEXT(&ifnet, if_link);
                }