I noticed that some of the loops over all AID (address identifiers) start
at 0 but they should use AID_MIN. This is not a general rule and I
actually skipped one of the for loops because I think there 0 is actually
better. In the cases I fixed it is known that only known AID and not
AID_UNSPEC are allowed.
This fixes a visual glitch when using add-path.
--
:wq Claudio
Index: output.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/output.c,v
retrieving revision 1.23
diff -u -p -r1.23 output.c
--- output.c 27 Jun 2022 13:27:38 -0000 1.23
+++ output.c 8 Jul 2022 13:38:27 -0000
@@ -138,7 +138,7 @@ show_neighbor_capa_mp(struct capabilitie
uint8_t i;
printf(" Multiprotocol extensions: ");
- for (i = 0, comma = 0; i < AID_MAX; i++)
+ for (i = AID_MIN, comma = 0; i < AID_MAX; i++)
if (capa->mp[i]) {
printf("%s%s", comma ? ", " : "", aid2str(i));
comma = 1;
@@ -154,7 +154,7 @@ show_neighbor_capa_add_path(struct capab
uint8_t i;
printf(" Add-path: ");
- for (i = 0, comma = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN, comma = 0; i < AID_MAX; i++) {
switch (capa->add_path[i]) {
case 0:
default:
@@ -183,7 +183,7 @@ show_neighbor_capa_restart(struct capabi
printf(" Graceful Restart");
if (capa->grestart.timeout)
printf(": Timeout: %d, ", capa->grestart.timeout);
- for (i = 0, comma = 0; i < AID_MAX; i++)
+ for (i = AID_MIN, comma = 0; i < AID_MAX; i++)
if (capa->grestart.flags[i] & CAPA_GR_PRESENT) {
if (!comma &&
capa->grestart.flags[i] & CAPA_GR_RESTART)
Index: output_json.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
retrieving revision 1.18
diff -u -p -r1.18 output_json.c
--- output_json.c 7 Jul 2022 12:17:57 -0000 1.18
+++ output_json.c 8 Jul 2022 13:38:27 -0000
@@ -43,7 +43,7 @@ json_neighbor_capabilities(struct capabi
int hascapamp = 0, hascapaap = 0;
uint8_t i;
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (capa->mp[i])
hascapamp = 1;
if (capa->add_path[i])
@@ -60,7 +60,7 @@ json_neighbor_capabilities(struct capabi
if (hascapamp) {
json_do_array("multiprotocol");
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if (capa->mp[i])
json_do_printf("mp", "%s", aid2str(i));
json_do_end();
@@ -68,7 +68,7 @@ json_neighbor_capabilities(struct capabi
if (capa->grestart.restart) {
int restarted = 0, present = 0;
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if (capa->grestart.flags[i] & CAPA_GR_PRESENT) {
present = 1;
if (capa->grestart.flags[i] & CAPA_GR_RESTART)
@@ -101,7 +101,7 @@ json_neighbor_capabilities(struct capabi
}
if (hascapaap) {
json_do_array("add-path");
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if (capa->add_path[i]) {
json_do_object("add-path-elm");
json_do_printf("family", "%s", aid2str(i));