From: claudio Date: Thu, 27 May 2021 08:29:06 +0000 (+0000) Subject: Add the bits needed in bgpctl to show the new ADD-PATH and enhanced X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b6faf4c975a75f9f1c544ad098500c72aaf7696f;p=openbsd Add the bits needed in bgpctl to show the new ADD-PATH and enhanced route refresh capabilities in the neighbor output. --- diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index d99661595f9..13bc565bd86 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.267 2021/05/03 14:01:56 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.268 2021/05/27 08:29:06 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -1351,6 +1351,13 @@ print_capability(u_int8_t capa_code, u_char *p, u_int8_t len) } else printf("bad length"); break; + case CAPA_ADD_PATH: + printf("add-path capability"); + /* XXX there is more needed here */ + break; + case CAPA_ENHANCED_RR: + printf("enhanced route refresh capability"); + break; default: printf("unknown capability %u length %u", capa_code, len); break; diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index ddcec8048fc..f817c715ce8 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.16 2021/04/26 18:23:20 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.17 2021/05/27 08:29:07 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -146,6 +146,34 @@ show_neighbor_capa_mp(struct capabilities *capa) printf("\n"); } +static void +show_neighbor_capa_add_path(struct capabilities *capa) +{ + const char *mode; + int comma; + u_int8_t i; + + printf(" Add-path: "); + for (i = 0, comma = 0; i < AID_MAX; i++) { + switch (capa->add_path[i]) { + case 0: + default: + continue; + case CAPA_AP_RECV: + mode = "recv"; + break; + case CAPA_AP_SEND: + mode = "send"; + break; + case CAPA_AP_BIDIR: + mode = "bidir"; + } + printf("%s%s %s", comma ? ", " : "", aid2str(i), mode); + comma = 1; + } + printf("\n"); +} + static void show_neighbor_capa_restart(struct capabilities *capa) { @@ -202,6 +230,13 @@ show_neighbor_msgstats(struct peer *p) p->stats.prefix_sent_withdraw, p->stats.prefix_rcvd_withdraw); printf(" %-15s %10llu %10llu\n", "End-of-Rib", p->stats.prefix_sent_eor, p->stats.prefix_rcvd_eor); + printf(" Route Refresh statistics:\n"); + printf(" %-15s %10llu %10llu\n", "Request", + p->stats.refresh_sent_req, p->stats.refresh_rcvd_req); + printf(" %-15s %10llu %10llu\n", "Begin-of-RR", + p->stats.refresh_sent_borr, p->stats.refresh_rcvd_borr); + printf(" %-15s %10llu %10llu\n", "End-of-RR", + p->stats.refresh_sent_eorr, p->stats.refresh_rcvd_eorr); } static void @@ -210,7 +245,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res) const char *errstr; struct in_addr ina; char *s; - int hascapamp = 0; + int hascapamp, hascapaap; u_int8_t i; if ((p->conf.remote_addr.aid == AID_INET && @@ -279,35 +314,57 @@ show_neighbor_full(struct peer *p, struct parse_result *res) fmt_monotime(p->stats.last_read), p->holdtime, p->holdtime/3); printf(" Last write %s\n", fmt_monotime(p->stats.last_write)); - for (i = 0; i < AID_MAX; i++) + + hascapamp = 0; + hascapaap = 0; + for (i = AID_MIN; i < AID_MAX; i++) { if (p->capa.peer.mp[i]) hascapamp = 1; - if (hascapamp || p->capa.peer.refresh || - p->capa.peer.grestart.restart || p->capa.peer.as4byte) { + if (p->capa.peer.add_path[i]) + hascapaap = 1; + } + if (hascapamp || hascapaap || p->capa.peer.grestart.restart || + p->capa.peer.refresh || p->capa.peer.enhanced_rr || + p->capa.peer.as4byte) { printf(" Neighbor capabilities:\n"); if (hascapamp) show_neighbor_capa_mp(&p->capa.peer); + if (p->capa.peer.as4byte) + printf(" 4-byte AS numbers\n"); if (p->capa.peer.refresh) printf(" Route Refresh\n"); + if (p->capa.peer.enhanced_rr) + printf(" Enhanced Route Refresh\n"); if (p->capa.peer.grestart.restart) show_neighbor_capa_restart(&p->capa.peer); - if (p->capa.peer.as4byte) - printf(" 4-byte AS numbers\n"); + if (hascapaap) + show_neighbor_capa_add_path(&p->capa.peer); } - for (i = 0; i < AID_MAX; i++) + + hascapamp = 0; + hascapaap = 0; + for (i = AID_MIN; i < AID_MAX; i++) { if (p->capa.neg.mp[i]) hascapamp = 1; - if (hascapamp || p->capa.neg.refresh || - p->capa.neg.grestart.restart || p->capa.neg.as4byte) { + if (p->capa.neg.add_path[i]) + hascapaap = 1; + } + if (hascapamp || hascapaap || p->capa.neg.grestart.restart || + p->capa.neg.refresh || p->capa.neg.enhanced_rr || + p->capa.neg.as4byte) { printf(" Negotiated capabilities:\n"); if (hascapamp) show_neighbor_capa_mp(&p->capa.neg); + if (p->capa.neg.as4byte) + printf(" 4-byte AS numbers\n"); if (p->capa.neg.refresh) printf(" Route Refresh\n"); + if (p->capa.neg.enhanced_rr) + printf(" Enhanced Route Refresh\n"); if (p->capa.neg.grestart.restart) show_neighbor_capa_restart(&p->capa.neg); - if (p->capa.neg.as4byte) - printf(" 4-byte AS numbers\n"); + if (hascapaap) + show_neighbor_capa_add_path(&p->capa.neg); } printf("\n"); diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 1afa4425754..03e7025f7c6 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.10 2021/05/03 14:01:56 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.11 2021/05/27 08:29:07 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -40,19 +40,23 @@ json_head(struct parse_result *res) static void json_neighbor_capabilities(struct capabilities *capa) { - int hascapamp; + int hascapamp = 0, hascapaap = 0; uint8_t i; - for (i = 0; i < AID_MAX; i++) + for (i = 0; i < AID_MAX; i++) { if (capa->mp[i]) hascapamp = 1; - if (!hascapamp && !capa->refresh && !capa->grestart.restart && - !capa->as4byte) + if (capa->add_path[i]) + hascapaap = 1; + } + if (!hascapamp && !hascapaap && !capa->grestart.restart && + !capa->refresh && !capa->enhanced_rr && !capa->as4byte) return; json_do_object("capabilities"); json_do_bool("as4byte", capa->as4byte); json_do_bool("refresh", capa->refresh); + json_do_bool("enhanced_refresh", capa->enhanced_rr); if (hascapamp) { json_do_array("multiprotocol"); @@ -95,6 +99,31 @@ json_neighbor_capabilities(struct capabilities *capa) json_do_end(); } + if (hascapaap) { + json_do_array("add-path"); + for (i = 0; i < AID_MAX; i++) + if (capa->add_path[i]) { + json_do_object("add-path-elm"); + json_do_printf("family", "%s", aid2str(i)); + switch (capa->add_path[i]) { + case CAPA_AP_RECV: + json_do_printf("mode", "recv"); + break; + case CAPA_AP_SEND: + json_do_printf("mode", "send"); + break; + case CAPA_AP_BIDIR: + json_do_printf("mode", "bidir"); + break; + default: + json_do_printf("mode", "unknown %d", + capa->add_path[i]); + break; + } + json_do_end(); + } + json_do_end(); + } json_do_end(); } @@ -157,6 +186,22 @@ json_neighbor_stats(struct peer *p) json_do_end(); + json_do_object("route-refresh"); + + json_do_object("sent"); + json_do_uint("request", p->stats.refresh_sent_req); + json_do_uint("borr", p->stats.refresh_sent_borr); + json_do_uint("eorr", p->stats.refresh_sent_eorr); + json_do_end(); + + json_do_object("received"); + json_do_uint("request", p->stats.refresh_rcvd_req); + json_do_uint("borr", p->stats.refresh_rcvd_borr); + json_do_uint("eorr", p->stats.refresh_rcvd_eorr); + json_do_end(); + + json_do_end(); + json_do_end(); }