From: claudio Date: Thu, 9 Mar 2023 13:13:14 +0000 (+0000) Subject: Add role output to bgpctl, also adjust the capability output. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1d3c7c09f94f4de5b3050ee8cf4d404737867380;p=openbsd Add role output to bgpctl, also adjust the capability output. Note, this changes the JSON output of neighbors a bit. Part of the large RFC9234 rework in bgpd. OK tb@ --- diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index 4babc6297b1..6faef7fbd2b 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.36 2023/01/31 14:32:43 job Exp $ */ +/* $OpenBSD: output.c,v 1.37 2023/03/09 13:13:14 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -281,6 +281,8 @@ show_neighbor_full(struct peer *p, struct parse_result *res) printf("\n"); if (p->conf.descr[0]) printf(" Description: %s\n", p->conf.descr); + if (p->conf.ebgp && p->conf.role != ROLE_NONE) + printf(" Role: %s\n", log_policy(p->conf.role)); if (p->conf.max_prefix) { printf(" Max-prefix: %u", p->conf.max_prefix); if (p->conf.max_prefix_restart) @@ -330,7 +332,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res) } if (hascapamp || hascapaap || p->capa.peer.grestart.restart || p->capa.peer.refresh || p->capa.peer.enhanced_rr || - p->capa.peer.as4byte || p->capa.peer.role_ena) { + p->capa.peer.as4byte || p->capa.peer.policy) { printf(" Neighbor capabilities:\n"); if (hascapamp) show_neighbor_capa_mp(&p->capa.peer); @@ -344,10 +346,10 @@ show_neighbor_full(struct peer *p, struct parse_result *res) show_neighbor_capa_restart(&p->capa.peer); if (hascapaap) show_neighbor_capa_add_path(&p->capa.peer); - if (p->capa.peer.role_ena) + if (p->capa.peer.policy) printf(" Open Policy role %s (local %s)\n", - log_policy(p->capa.peer.role), - log_policy(p->capa.ann.role)); + log_policy(p->remote_role), + log_policy(p->conf.role)); } hascapamp = 0; @@ -360,7 +362,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res) } if (hascapamp || hascapaap || p->capa.neg.grestart.restart || p->capa.neg.refresh || p->capa.neg.enhanced_rr || - p->capa.neg.as4byte || p->capa.neg.role_ena) { + p->capa.neg.as4byte || p->capa.neg.policy) { printf(" Negotiated capabilities:\n"); if (hascapamp) show_neighbor_capa_mp(&p->capa.neg); @@ -374,10 +376,10 @@ show_neighbor_full(struct peer *p, struct parse_result *res) show_neighbor_capa_restart(&p->capa.neg); if (hascapaap) show_neighbor_capa_add_path(&p->capa.neg); - if (p->capa.neg.role_ena) + if (p->capa.neg.policy) printf(" Open Policy role %s (local %s)\n", - log_policy(p->capa.neg.role), - log_policy(p->capa.ann.role)); + log_policy(p->remote_role), + log_policy(p->conf.role)); } printf("\n"); diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 72d2cb99942..86ac1626e93 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.29 2023/01/24 11:29:34 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.30 2023/03/09 13:13:14 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -125,10 +125,9 @@ json_neighbor_capabilities(struct capabilities *capa) json_do_end(); } - if (capa->role_ena) { - json_do_printf("open_policy_role", "%s%s", - log_policy(capa->role), - capa->role_ena == 2 ? " enforce" : ""); + if (capa->policy) { + json_do_printf("open_policy", "%s", + capa->policy == 2 ? "enforce" : "present"); } json_do_end(); @@ -248,6 +247,9 @@ json_neighbor_full(struct peer *p) json_do_bool("ttl_security", p->conf.ttlsec); json_do_uint("holdtime", p->conf.holdtime); json_do_uint("min_holdtime", p->conf.min_holdtime); + if (p->conf.ebgp && p->conf.role != ROLE_NONE) + json_do_printf("role", "%s", + log_policy(p->conf.role)); /* capabilities */ json_do_bool("announce_capabilities", p->conf.announce_capa); @@ -296,6 +298,12 @@ json_neighbor_full(struct peer *p) /* capabilities */ json_neighbor_capabilities(&p->capa.neg); + if (p->conf.ebgp && p->conf.role != ROLE_NONE) { + json_do_printf("remote_role", "%s", + log_policy(p->remote_role)); + json_do_printf("local_role", "%s", + log_policy(p->conf.role)); + } json_do_end(); } }