diff -u --recursive proto/bgp/bgp.c.orig proto/bgp/bgp.c --- proto/bgp/bgp.c.orig 2023-04-23 17:22:52.000000000 +0300 +++ proto/bgp/bgp.c 2023-06-14 21:09:39.658788000 +0300 @@ -2387,6 +2387,50 @@ return "?"; } +void +bgp_sh_summary(struct symbol *sym) +{ + struct proto *P = NULL; + struct bgp_proto *bp; + byte tbuf[TM_DATETIME_BUFFER_SIZE]; + char rs[20]; + char ps[256]; + struct channel *c; + + /* Check if there is any BGP protocol */ + if (proto_iterate_named(sym, &proto_bgp, P)) + { + cli_msg(1026, "%-30s %-10s %-19s %s\n %-61s %s", "Peer", "AS", "Last state change", "State/Last error", "Channel", "Prefixes rcvd/best" ); + PROTO_WALK_CMD(sym, &proto_bgp, p) + { + /* Get protocol data */ + if (p->proto->get_status) + p->proto->get_status(p, ps); + + tm_format_time(tbuf, &config->tf_proto, p->last_state_change); + + /* Print information about peer state */ + bp = (struct bgp_proto *) p; + cli_msg(1026, "%-30I %-10u %-19s %s", + bp->cf->remote_ip, + bp->remote_as, + tbuf, + ps); + + /* Get information about channels */ + WALK_LIST(c, p->channels) + { + if (c->channel_state == CS_UP) + { + bsnprintf(rs, sizeof(rs), "%u/%u", c->stats.imp_routes, c->stats.pref_routes); + cli_msg(1026, " %-61s %s", c->name, rs); + } + } + } + } + cli_msg(0, ""); +} + static void bgp_show_capabilities(struct bgp_proto *p UNUSED, struct bgp_caps *caps) { diff -u --recursive proto/bgp/bgp.h.orig proto/bgp/bgp.h --- proto/bgp/bgp.h.orig 2023-04-23 17:22:52.000000000 +0300 +++ proto/bgp/bgp.h 2023-06-14 21:09:39.658677000 +0300 @@ -549,6 +549,7 @@ void bgp_store_error(struct bgp_proto *p, struct bgp_conn *c, u8 class, u32 code); void bgp_stop(struct bgp_proto *p, int subcode, byte *data, uint len); const char *bgp_format_role_name(u8 role); +void bgp_sh_summary(struct symbol *sym); void bgp_fix_attr_flags(ea_list *attrs); diff -u --recursive proto/bgp/config.Y.orig proto/bgp/config.Y --- proto/bgp/config.Y.orig 2023-04-23 17:22:52.000000000 +0300 +++ proto/bgp/config.Y 2023-06-14 21:09:39.658604000 +0300 @@ -365,7 +365,10 @@ dynamic_attr: BGP_OTC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_ONLY_TO_CUSTOMER)); } ; - +CF_CLI_HELP(SHOW BGP, ... , [[Show information about BGP protocol]]) +CF_CLI_HELP(SHOW BGP SUMMARY, [], [[Show BGP summary]]) +CF_CLI(SHOW BGP SUMMARY, optproto, [], [[Show BGP summary]]) +{ bgp_sh_summary($4); }; CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE)