Le Sun, Dec 12, 2021 at 01:43:06PM +0000, Stuart Henderson a écrit :
> On 2021/12/12 14:13, Denis Fondras wrote:
> > Number of received prefixes appear in `bgpctl sh` but not in `bgpctl -j sh`.
> > 
> > Here is a diff to add this piece of information.
> > 
> > OK ?
> 
> Makes sense, but if prefix_cnt is added, max_prefix probably should be too
> 

If order of appearance is not important, there is no need to check for state ==
ESTABLISHED twice.

Index: output_json.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
retrieving revision 1.12
diff -u -p -r1.12 output_json.c
--- output_json.c       27 Jul 2021 07:42:37 -0000      1.12
+++ output_json.c       12 Dec 2021 14:16:58 -0000
@@ -311,10 +311,13 @@ json_neighbor(struct peer *p, struct par
                struct in_addr ina;
                ina.s_addr = p->remote_bgpid;
                json_do_printf("bgpid", "%s", inet_ntoa(ina));
+               json_do_uint("received_prefixes", p->stats.prefix_cnt);
        }
        json_do_printf("state", "%s", statenames[p->state]);
        json_do_printf("last_updown", "%s", fmt_monotime(p->stats.last_updown));
        json_do_int("last_updown_sec", get_monotime(p->stats.last_updown));
+       if (p->conf.max_prefix != 0)
+               json_do_uint("max_prefix", p->conf.max_prefix);
 
        switch (res->action) {
        case SHOW:

Reply via email to