Index: cache.c =================================================================== RCS file: /cvs/src/usr.bin/systat/cache.c,v retrieving revision 1.7 diff -u -p -r1.7 cache.c --- cache.c 26 Aug 2016 09:10:11 -0000 1.7 +++ cache.c 15 Nov 2018 01:30:41 -0000 @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -41,12 +42,13 @@ /* prototypes */ void update_state(struct sc_ent *, struct pfsync_state *, double); struct sc_ent *cache_state(struct pfsync_state *); -static __inline int sc_cmp(struct sc_ent *s1, struct sc_ent *s2); +static __inline int sc_cmp(const struct sc_ent *s1, const struct sc_ent *s2); /* initialize the tree and queue */ -RB_HEAD(sc_tree, sc_ent) sctree; +RBT_HEAD(sc_tree, sc_ent) sctree; TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free; -RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp) +RBT_PROTOTYPE(sc_tree, sc_ent, tlink, sc_cmp); +RBT_GENERATE(sc_tree, sc_ent, tlink, sc_cmp); struct sc_queue *scq_act = NULL; struct sc_queue *scq_exp = NULL; @@ -74,7 +76,7 @@ cache_init(int max) return (1); } - RB_INIT(&sctree); + RBT_INIT(sc_tree, &sctree); TAILQ_INIT(&scq1); TAILQ_INIT(&scq2); TAILQ_INIT(&scq_free); @@ -126,7 +128,7 @@ add_state(struct pfsync_state *st) ent->rate = 0; ent->t = 0; - RB_INSERT(sc_tree, &sctree, ent); + RBT_INSERT(sc_tree, &sctree, ent); TAILQ_INSERT_HEAD(scq_act, ent, qlink); } @@ -142,7 +144,7 @@ cache_state(struct pfsync_state *st) ent.id = st->id; ent.creatorid = st->creatorid; - old = RB_FIND(sc_tree, &sctree, &ent); + old = RBT_FIND(sc_tree, &sctree, &ent); if (old == NULL) { add_state(st); @@ -177,7 +179,7 @@ cache_endupdate(void) while (! TAILQ_EMPTY(scq_exp)) { ent = TAILQ_FIRST(scq_exp); TAILQ_REMOVE(scq_exp, ent, qlink); - RB_REMOVE(sc_tree, &sctree, ent); + RBT_REMOVE(sc_tree, &sctree, ent); TAILQ_INSERT_HEAD(&scq_free, ent, qlink); cache_size++; } @@ -188,7 +190,7 @@ cache_endupdate(void) } static __inline int -sc_cmp(struct sc_ent *a, struct sc_ent *b) +sc_cmp(const struct sc_ent *a, const struct sc_ent *b) { if (a->id > b->id) return (1); Index: engine.h =================================================================== RCS file: /cvs/src/usr.bin/systat/engine.h,v retrieving revision 1.9 diff -u -p -r1.9 engine.h --- engine.h 8 Feb 2018 07:00:33 -0000 1.9 +++ engine.h 15 Nov 2018 01:30:41 -0000 @@ -53,7 +53,7 @@ typedef struct { - char *title; + const char *title; int norm_width; int max_width; int increment; Index: if.c =================================================================== RCS file: /cvs/src/usr.bin/systat/if.c,v retrieving revision 1.23 diff -u -p -r1.23 if.c --- if.c 16 Jan 2015 00:03:37 -0000 1.23 +++ if.c 15 Nov 2018 01:30:42 -0000 @@ -56,6 +56,12 @@ static void showifstat(struct ifstat *); static void showtotal(void); static void rt_getaddrinfo(struct sockaddr *, int, struct sockaddr **); +static const char ierrs[] = "IERRS"; +static const char oerrs[] = "OERRS"; +static const char iqdrops[] = "IQDROPS"; +static const char oqdrops[] = "OQDROPS"; + +static int show_errs = 1; /* Define fields */ field_def fields_if[] = { @@ -63,10 +69,10 @@ field_def fields_if[] = { {"STATE", 4, 6, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"IPKTS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"IBYTES", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, - {"IERRS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, + {ierrs, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"OPKTS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"OBYTES", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, - {"OERRS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, + {oerrs, 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"COLLS", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"DESC", 14, 64, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, }; @@ -264,9 +270,11 @@ fetchifstat(void) UPDATE(ifc_ip, ifm_data.ifi_ipackets); UPDATE(ifc_ib, ifm_data.ifi_ibytes); UPDATE(ifc_ie, ifm_data.ifi_ierrors); + UPDATE(ifc_iq, ifm_data.ifi_iqdrops); UPDATE(ifc_op, ifm_data.ifi_opackets); UPDATE(ifc_ob, ifm_data.ifi_obytes); UPDATE(ifc_oe, ifm_data.ifi_oerrors); + UPDATE(ifc_oq, ifm_data.ifi_oqdrops); UPDATE(ifc_co, ifm_data.ifi_collisions); ifs->ifs_cur.ifc_flags = ifm.ifm_flags; ifs->ifs_cur.ifc_state = ifm.ifm_data.ifi_link_state; @@ -315,11 +323,13 @@ showifstat(struct ifstat *ifs) print_fld_sdiv(FLD_IF_IBYTES, ifs->ifs_cur.ifc_ib * conv, div); print_fld_size(FLD_IF_IPKTS, ifs->ifs_cur.ifc_ip); - print_fld_size(FLD_IF_IERRS, ifs->ifs_cur.ifc_ie); + print_fld_size(FLD_IF_IERRS, show_errs ? + ifs->ifs_cur.ifc_ie : ifs->ifs_cur.ifc_iq); print_fld_sdiv(FLD_IF_OBYTES, ifs->ifs_cur.ifc_ob * conv, div); print_fld_size(FLD_IF_OPKTS, ifs->ifs_cur.ifc_op); - print_fld_size(FLD_IF_OERRS, ifs->ifs_cur.ifc_oe); + print_fld_size(FLD_IF_OERRS, show_errs ? + ifs->ifs_cur.ifc_oe : ifs->ifs_cur.ifc_oq); print_fld_size(FLD_IF_COLLS, ifs->ifs_cur.ifc_co); @@ -336,11 +346,11 @@ showtotal(void) print_fld_sdiv(FLD_IF_IBYTES, sum.ifc_ib * conv, div); print_fld_size(FLD_IF_IPKTS, sum.ifc_ip); - print_fld_size(FLD_IF_IERRS, sum.ifc_ie); + print_fld_size(FLD_IF_IERRS, show_errs ? sum.ifc_ie : sum.ifc_iq); print_fld_sdiv(FLD_IF_OBYTES, sum.ifc_ob * conv, div); print_fld_size(FLD_IF_OPKTS, sum.ifc_op); - print_fld_size(FLD_IF_OERRS, sum.ifc_oe); + print_fld_size(FLD_IF_OERRS, show_errs ? sum.ifc_oe : sum.ifc_oq); print_fld_size(FLD_IF_COLLS, sum.ifc_co); @@ -354,6 +364,19 @@ if_keyboard_callback(int ch) struct ifstat *ifs; switch (ch) { + case 'd': + show_errs = 1; + FLD_IF_IERRS->title = iqdrops; + FLD_IF_OERRS->title = oqdrops; + gotsig_alarm = 1; + break; + case 'e': + show_errs = 0; + FLD_IF_IERRS->title = ierrs; + FLD_IF_OERRS->title = oerrs; + gotsig_alarm = 1; + break; + case 'r': for (ifs = ifstats; ifs < ifstats + nifs; ifs++) ifs->ifs_old = ifs->ifs_now; Index: systat.1 =================================================================== RCS file: /cvs/src/usr.bin/systat/systat.1,v retrieving revision 1.110 diff -u -p -r1.110 systat.1 --- systat.1 25 Jul 2018 17:24:14 -0000 1.110 +++ systat.1 15 Nov 2018 01:30:42 -0000 @@ -290,6 +290,10 @@ between display refreshes. changes the counters to show the average per second over the display refresh interval; this is the default. +.Ic d +displays input and output queue drops instead of errors. +.Ic e +displays input and output errors instead of queue drops. .It Ic iostat Display statistics about disk throughput. Statistics Index: systat.h =================================================================== RCS file: /cvs/src/usr.bin/systat/systat.h,v retrieving revision 1.22 diff -u -p -r1.22 systat.h --- systat.h 30 May 2018 13:43:51 -0000 1.22 +++ systat.h 15 Nov 2018 01:30:42 -0000 @@ -104,9 +104,11 @@ struct ifcount { u_int64_t ifc_ib; /* input bytes */ u_int64_t ifc_ip; /* input packets */ u_int64_t ifc_ie; /* input errors */ + u_int64_t ifc_iq; /* input qdrops */ u_int64_t ifc_ob; /* output bytes */ u_int64_t ifc_op; /* output packets */ u_int64_t ifc_oe; /* output errors */ + u_int64_t ifc_oq; /* output qdrops */ u_int64_t ifc_co; /* collisions */ int ifc_flags; /* up / down */ int ifc_state; /* link state */