Hello! Please find attached 'show bgp summary' patch for bird 2.13. Code has been simplified and placed in more correct place. Route stats are shown for each channel. Example output: bird> show bgp summary Peer AS Last state change State/Last error Channel Prefixes rcvd/best 193.25.180.4 43380 20:39:40.244 Established ipv4 0/0 flow4 0/0 193.25.180.255 31210 20:39:16.686 Established ipv4 1/1 193.25.181.0 31210 20:39:08.221 Active Socket: Connection closed 193.25.180.17 25372 20:39:42.584 Established ipv4 1/1 flow4 1/1 193.25.180.194 48641 20:39:08.221 Passive 2001:7f8:63::1:28 12963 20:39:08.221 Passive 2001:7f8:63::1:2a 12963 20:39:08.221 Passive On Thu, Dec 22, 2022 at 10:15:47 +0100, Milan Strakoš via Bird-users wrote:
Hello,
I provide a patch for bird version 2, which is based on the patch for version 1 and displays imported, exported, preferred and filtered prefixes (also for "show protocols"). I use this output also for parsing. The output formatting can be adjusted individually. I'm not a programmer, so maybe it could be done better.
Nice holidays, Milan
Dne 25. 02. 21 v 9:09 Cybertinus napsal(a):
Hello Roman,
1. Bird 1.3.x is very old. Bird 1.6.8 and 2.0.7 are the current versions. If you still run on Bird 1.3 I highly recommend that you upgrade to at least 1.6.x
2. There is such a command already: `show protocols`. It doesn't show you how many prefixes you received from it, but is you ask for more detail it will: `show protocols all`. If you have a lot of peers, this will show you way to much information, so you can also request this info for 1 specific peer: `show protocols all <name_of_the_peer_in_the_bird_config>`. I don't know if these commands work on 1.3 though, but I think they would. I never used 1.3, I started using Bird when 1.6.4 was the latest and greatest and Bird 2 didn't exist yet.
Or is there some more you want to see from the `sh bgp sum` command that isn't shown by `show protocols`, even with more details?
Kind regards, Cybertinus
On 2021-02-25 07:37, Roman Bulakh wrote:
Hi,
we use BIRD in our environment, and it would be very nice to have some command like `show bgp summary` in juniper. This command show information about peer IP, peer AS, last update, prefixes received/best/exported and last state.
Example: bird> show bgp summary Peer AS Last state change Prfx rcvd/best/export State X.X.X.X asXXXX 2021-01-27 6786/6785/109000 Established Y.Y.Y.Y asYYYY 2020-12-16 0/0/0 Passive BGP Error: Hold timer expired
The are patch created for BIRD 1.3.4 and 1.3.6, but it would be good to have this in upstream software, without rebuilding and patching.
as I understand it, no functionality should be affected by these changes, this is only a visual update for cli.
Old patches describes at pages: https://marc.info/?l=bird-users&m=132155489919052&w=2 http://trubka.network.cz/pipermail/bird-users/attachments/20120228/a1499be7/... https://bird-users.network.narkive.com/Px6EH3yl/bird-1-3-6-show-bgp-summary-...
--- bird-2.0.11/nest/proto.c 2022-12-12 00:23:42.000000000 +0100 +++ bird-2.0.11-upraveny/nest/proto.c 2022-12-20 10:23:58.848461673 +0100 @@ -2049,22 +2049,31 @@ proto_cmd_show(struct proto *p, uintptr_t verbose, int cnt) { byte buf[256], tbuf[TM_DATETIME_BUFFER_SIZE]; + char rs[20];
/* First protocol - show header */ if (!cnt) - cli_msg(-2002, "%-10s %-10s %-10s %-6s %-12s %s", - "Name", "Proto", "Table", "State", "Since", "Info"); + cli_msg(-2002, "%-30s %-10s %-10s %-6s %-20s %-21s %s", + "Name", "Proto", "Table", "State", "Since", "Prfx imp/pref/exp/fil", "Info");
buf[0] = 0; if (p->proto->get_status) p->proto->get_status(p, buf); tm_format_time(tbuf, &config->tf_proto, p->last_state_change); - cli_msg(-1002, "%-10s %-10s %-10s %-6s %-12s %s", + struct channel *c; + bsnprintf(rs, sizeof(rs), "%u/%u/%u/%u", 0, 0, 0, 0); + WALK_LIST(c, p->channels) { + struct proto_stats *s = &c->stats; + if (c->channel_state == CS_UP) + bsnprintf(rs, sizeof(rs), "%u/%u/%u/%u", s->imp_routes, s->pref_routes, s->exp_routes, s->filt_routes); + } + cli_msg(-1002, "%-30s %-10s %-10s %-6s %-20s %-21s %s", p->name, p->proto->name, p->main_channel ? p->main_channel->table->name : "---", proto_state_name(p), tbuf, + rs, buf);
if (verbose) --- bird-2.0.11/proto/bfd/bfd.c 2022-09-08 09:20:39.000000000 +0200 +++ bird-2.0.11-upraveny/proto/bfd/bfd.c 2022-12-12 09:11:30.939234856 +0100 @@ -1157,7 +1157,7 @@ }
cli_msg(-1020, "%s:", p->p.name); - cli_msg(-1020, "%-25s %-10s %-10s %-12s %8s %8s", + cli_msg(-1020, "%-25s %-10s %-10s %-19s %8s %8s", "IP address", "Interface", "State", "Since", "Interval", "Timeout");
--- bird-2.0.11/proto/bgp/bgp.c 2022-12-12 00:23:42.000000000 +0100 +++ bird-2.0.11-upraveny/proto/bgp/bgp.c 2022-12-20 10:24:42.038459672 +0100 @@ -136,10 +136,80 @@ static void bgp_setup_sk(struct bgp_conn *conn, sock *s); static void bgp_send_open(struct bgp_conn *conn); static void bgp_update_bfd(struct bgp_proto *p, const struct bfd_options *bfd); +static void bgp_sh_proto_summary(struct proto *p);
static int bgp_incoming_connection(sock *sk, uint dummy UNUSED); static void bgp_listen_sock_err(sock *sk UNUSED, int err);
+void +bgp_sh_summary(struct symbol *sym) +{ + struct proto_config *q; + struct proto *p; + if (sym) + { + cli_msg(-2002, "%-30s %-22s %10s %-19s %-18s %s", "Proto", "Peer", "AS", "Last state change", "Prfx imp/pref/exp/fil", "State/Last error" ); + bgp_sh_proto_summary(proto_get_named(sym, &proto_bgp)); + } + else + { + p = NULL; + WALK_LIST(q, config->protos) + { + if (q->protocol == &proto_bgp && q->proto) + { + if (p == NULL) + { + cli_msg(-2002, "%-30s %-22s %10s %-19s %-18s %s", "Proto", "Peer", "AS", "Last state change", "Prfx imp/pref/exp/fil", "State/Last error" ); + } + p = q->proto; + bgp_sh_proto_summary(p); + } + } + + if (p == NULL) + cli_msg(-1006, "No protocols match"); + } + cli_msg(0, ""); +} + +static void +bgp_sh_proto_summary(struct proto *p) +{ + struct bgp_proto *bp; + byte buf[256], tbuf[TM_DATETIME_BUFFER_SIZE]; + char rs[20]; + char ps[256]; + + /* Get protocol data */ + buf[0] = 0; + if (p->proto->get_status) + p->proto->get_status(p, buf); + tm_format_time(tbuf, &config->tf_proto, p->last_state_change); + struct channel *c; + bsnprintf(rs, sizeof(rs), "%u/%u/%u/%u", 0, 0, 0, 0); + WALK_LIST(c, p->channels) { + struct proto_stats *s = &c->stats; + if (c->channel_state == CS_UP) + bsnprintf(rs, sizeof(rs), "%u/%u/%u/%u", s->imp_routes, s->pref_routes, s->exp_routes, s->filt_routes); + } + + p->proto->get_status(p, ps); + + /* Get BGP protocol from protocol */ + bp = (struct bgp_proto *) p; + + /* Display summary */ +// cli_msg(-1006, "%-30s %I\n%12u %-19s %-20s %s", + cli_msg(-1006, "%-30s %-22I %10u %-19s %-20s %s", + p->name, + bp->cf->remote_ip, + bp->remote_as, + tbuf, + rs, + ps); +} + /** * bgp_open - open a BGP instance * @p: BGP instance --- bird-2.0.11/proto/bgp/bgp.h 2022-12-12 00:23:42.000000000 +0100 +++ bird-2.0.11-upraveny/proto/bgp/bgp.h 2022-12-15 14:41:14.377759705 +0100 @@ -54,6 +54,7 @@ #define BGP_AF_FLOW4 BGP_AF( BGP_AFI_IPV4, BGP_SAFI_FLOW ) #define BGP_AF_FLOW6 BGP_AF( BGP_AFI_IPV6, BGP_SAFI_FLOW )
+void bgp_sh_summary(struct symbol *sym);
struct bgp_write_state; struct bgp_parse_state; --- bird-2.0.11/proto/bgp/config.Y 2022-12-12 00:23:42.000000000 +0100 +++ bird-2.0.11-upraveny/proto/bgp/config.Y 2022-12-15 14:22:06.967812861 +0100 @@ -365,6 +365,11 @@
CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE)
+CF_CLI_HELP(SHOW BGP, , [[Show BGP protocol information]]) + +CF_CLI(SHOW BGP SUMMARY, optproto, [<name>], [[Show BGP peers summary]]) + { bgp_sh_summary($4); }; + CF_CODE
CF_END
-- Alexander Shikov Technical Staff, Digital Telecom IX Tel.: +380 44 201 14 07 Mob.: +380 50 410 30 57 http://dtel-ix.net/