From 2c4aab275fc4967ce456e62199ccbcb86372ef56 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 28 Jul 2022 10:40:26 +0000 Subject: Adjust bgpctl show fib output. Remove F_DOWN from flags since kroutes can no longer be marked down. Also clean up the flag printing code and printf() and increase the size of destionation and gateway so that more IPv6 addrs fit. OK tb@ --- usr.sbin/bgpctl/bgpctl.c | 18 +++++------------- usr.sbin/bgpctl/output.c | 10 +++++----- usr.sbin/bgpctl/output_json.c | 3 +-- 3 files changed, 11 insertions(+), 20 deletions(-) (limited to 'usr.sbin/bgpctl') diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index d8ec76ad48d..deca860f36c 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.280 2022/07/07 12:17:57 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.281 2022/07/28 10:40:25 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -625,19 +625,14 @@ fmt_fib_flags(uint16_t flags) { static char buf[8]; - if (flags & F_DOWN) - strlcpy(buf, " ", sizeof(buf)); - else - strlcpy(buf, "*", sizeof(buf)); - if (flags & F_BGPD) - strlcat(buf, "B", sizeof(buf)); + strlcpy(buf, "B", sizeof(buf)); else if (flags & F_CONNECTED) - strlcat(buf, "C", sizeof(buf)); + strlcpy(buf, "C", sizeof(buf)); else if (flags & F_STATIC) - strlcat(buf, "S", sizeof(buf)); + strlcpy(buf, "S", sizeof(buf)); else - strlcat(buf, " ", sizeof(buf)); + strlcpy(buf, " ", sizeof(buf)); if (flags & F_NEXTHOP) strlcat(buf, "N", sizeof(buf)); @@ -653,9 +648,6 @@ fmt_fib_flags(uint16_t flags) else strlcat(buf, " ", sizeof(buf)); - if (strlcat(buf, " ", sizeof(buf)) >= sizeof(buf)) - errx(1, "%s buffer too small", __func__); - return buf; } diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index db6796b89a8..c8a9ca0e276 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.24 2022/07/08 16:12:11 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.25 2022/07/28 10:40:25 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -45,12 +45,12 @@ show_head(struct parse_result *res) "MsgRcvd", "MsgSent", "OutQ", "Up/Down", "State/PrfRcvd"); break; case SHOW_FIB: - printf("flags: * = valid, B = BGP, C = Connected, " - "S = Static\n"); + printf("flags: B = BGP, C = Connected, S = Static\n"); printf(" " "N = BGP Nexthop reachable via this route\n"); printf(" r = reject route, b = blackhole route\n\n"); - printf("flags prio destination gateway\n"); + printf("%-5s %-4s %-32s %-32s\n", "flags", "prio", + "destination", "gateway"); break; case SHOW_FIB_TABLES: printf("%-5s %-20s %-8s\n", "Table", "Description", "State"); @@ -467,7 +467,7 @@ show_fib(struct kroute_full *kf) if (asprintf(&p, "%s/%u", log_addr(&kf->prefix), kf->prefixlen) == -1) err(1, NULL); - printf("%s%4i %-20s ", fmt_fib_flags(kf->flags), kf->priority, p); + printf("%-5s %4i %-32s ", fmt_fib_flags(kf->flags), kf->priority, p); free(p); if (kf->flags & F_CONNECTED) diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 8bc01381db7..1c6902fa8ca 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.19 2022/07/08 16:12:11 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.20 2022/07/28 10:40:25 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -362,7 +362,6 @@ json_fib(struct kroute_full *kf) json_do_printf("prefix", "%s/%u", log_addr(&kf->prefix), kf->prefixlen); json_do_uint("priority", kf->priority); - json_do_bool("up", !(kf->flags & F_DOWN)); if (kf->flags & F_BGPD) origin = "bgp"; else if (kf->flags & F_CONNECTED) -- cgit v1.2.3