bgpctl show rib mem no longer shows any hash statistics so remove that
code from bgpctl as a first step. Also since show rib mem is a single
message adjust the code to be done after the message is received.

OK?
-- 
:wq Claudio

Index: bgpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.282
diff -u -p -r1.282 bgpctl.c
--- bgpctl.c    17 Aug 2022 15:16:12 -0000      1.282
+++ bgpctl.c    31 Aug 2022 14:35:20 -0000
@@ -410,7 +410,6 @@ show(struct imsg *imsg, struct parse_res
        struct ktable           *kt;
        struct ctl_show_rib      rib;
        struct rde_memstats      stats;
-       struct rde_hashstats     hash;
        u_char                  *asdata;
        u_int                    rescode, ilen;
        size_t                   aslen;
@@ -478,13 +477,7 @@ show(struct imsg *imsg, struct parse_res
                        errx(1, "wrong imsg len");
                memcpy(&stats, imsg->data, sizeof(stats));
                output->rib_mem(&stats);
-               break;
-       case IMSG_CTL_SHOW_RIB_HASH:
-               if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(hash))
-                       errx(1, "wrong imsg len");
-               memcpy(&hash, imsg->data, sizeof(hash));
-               output->rib_hash(&hash);
-               break;
+               return (1);
        case IMSG_CTL_SHOW_SET:
                if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(set))
                        errx(1, "wrong imsg len");
Index: bgpctl.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.h,v
retrieving revision 1.14
diff -u -p -r1.14 bgpctl.h
--- bgpctl.h    7 Jul 2022 12:17:57 -0000       1.14
+++ bgpctl.h    31 Aug 2022 14:34:18 -0000
@@ -28,7 +28,6 @@ struct output {
        void    (*communities)(u_char *, size_t, struct parse_result *);
        void    (*rib)(struct ctl_show_rib *, u_char *, size_t,
                    struct parse_result *);
-       void    (*rib_hash)(struct rde_hashstats *);
        void    (*rib_mem)(struct rde_memstats *);
        void    (*set)(struct ctl_show_set *);
        void    (*rtr)(struct ctl_show_rtr *);
Index: output.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/output.c,v
retrieving revision 1.28
diff -u -p -r1.28 output.c
--- output.c    29 Aug 2022 18:19:21 -0000      1.28
+++ output.c    31 Aug 2022 14:34:43 -0000
@@ -1030,20 +1030,6 @@ show_rib_mem(struct rde_memstats *stats)
            stats->attr_data));
        printf("Sets using %s of memory\n", fmt_mem(stats->aset_size +
            stats->pset_size));
-       printf("\nRDE hash statistics\n");
-}
-
-static void
-show_rib_hash(struct rde_hashstats *hash)
-{
-       double avg, dev;
-
-       printf("\t%s: size %lld, %lld entries\n", hash->name, hash->num,
-           hash->sum);
-       avg = (double)hash->sum / (double)hash->num;
-       dev = sqrt(fmax(0, hash->sumq / hash->num - avg * avg));
-       printf("\t    min %lld max %lld avg/std-dev = %.3f/%.3f\n",
-           hash->min, hash->max, avg, dev);
 }
 
 static void
@@ -1131,7 +1117,6 @@ const struct output show_output = {
        .attr = show_attr,
        .rib = show_rib,
        .rib_mem = show_rib_mem,
-       .rib_hash = show_rib_hash,
        .set = show_rib_set,
        .rtr = show_rtr,
        .result = show_result,
Index: output_json.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
retrieving revision 1.22
diff -u -p -r1.22 output_json.c
--- output_json.c       29 Aug 2022 18:19:21 -0000      1.22
+++ output_json.c       31 Aug 2022 14:35:01 -0000
@@ -966,28 +966,6 @@ json_rib_mem(struct rde_memstats *stats)
 }
 
 static void
-json_rib_hash(struct rde_hashstats *hash)
-{
-       double avg, dev;
-
-       json_do_array("hashtables");
-
-       avg = (double)hash->sum / (double)hash->num;
-       dev = sqrt(fmax(0, hash->sumq / hash->num - avg * avg));
-
-       json_do_object("hashtable");
-
-       json_do_printf("name", "%s", hash->name);
-       json_do_uint("size", hash->num);
-       json_do_uint("entries", hash->sum);
-       json_do_uint("min", hash->min);
-       json_do_uint("max", hash->max);
-       json_do_double("avg", avg);
-       json_do_double("std_dev", dev);
-       json_do_end();
-}
-
-static void
 json_rib_set(struct ctl_show_set *set)
 {
        json_do_array("sets");
@@ -1076,7 +1054,6 @@ const struct output json_output = {
        .attr = json_attr,
        .rib = json_rib,
        .rib_mem = json_rib_mem,
-       .rib_hash = json_rib_hash,
        .set = json_rib_set,
        .rtr = json_rtr,
        .result = json_result,

Reply via email to