From: claudio Date: Thu, 7 Jul 2022 12:17:57 +0000 (+0000) Subject: Print dmetric for prefixes, this may still change in the future. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2953a2c1df174f5a5fd61917a24d9eecf9b9f8c8;p=openbsd Print dmetric for prefixes, this may still change in the future. OK tb@ --- diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index f4857d17a98..d8ec76ad48d 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.279 2022/06/27 13:27:38 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.280 2022/07/07 12:17:57 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -675,7 +675,7 @@ fmt_origin(uint8_t origin, int sum) } const char * -fmt_flags(uint8_t flags, int sum) +fmt_flags(uint32_t flags, int sum) { static char buf[80]; char flagstr[5]; @@ -696,6 +696,10 @@ fmt_flags(uint8_t flags, int sum) *p++ = '*'; if (flags & F_PREF_BEST) *p++ = '>'; + if (flags & F_PREF_ECMP) + *p++ = 'm'; + if (flags & F_PREF_AS_WIDE) + *p++ = 'w'; *p = '\0'; snprintf(buf, sizeof(buf), "%-5s", flagstr); } else { @@ -714,6 +718,10 @@ fmt_flags(uint8_t flags, int sum) strlcat(buf, ", valid", sizeof(buf)); if (flags & F_PREF_BEST) strlcat(buf, ", best", sizeof(buf)); + if (flags & F_PREF_ECMP) + strlcat(buf, ", ecmp", sizeof(buf)); + if (flags & F_PREF_AS_WIDE) + strlcat(buf, ", as-wide", sizeof(buf)); if (flags & F_PREF_ANNOUNCE) strlcat(buf, ", announced", sizeof(buf)); if (strlen(buf) >= sizeof(buf) - 1) diff --git a/usr.sbin/bgpctl/bgpctl.h b/usr.sbin/bgpctl/bgpctl.h index 5486cc720c9..f147bedb2aa 100644 --- a/usr.sbin/bgpctl/bgpctl.h +++ b/usr.sbin/bgpctl/bgpctl.h @@ -47,7 +47,7 @@ const char *fmt_timeframe(time_t); const char *fmt_monotime(time_t); const char *fmt_fib_flags(uint16_t); const char *fmt_origin(uint8_t, int); -const char *fmt_flags(uint8_t, int); +const char *fmt_flags(uint32_t, int); const char *fmt_ovs(uint8_t, int); const char *fmt_auth_method(enum auth_method); const char *fmt_mem(long long); diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 78ff0eb0c1c..7037dfd768b 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.17 2022/06/27 13:27:38 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.18 2022/07/07 12:17:57 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -870,6 +870,10 @@ json_rib(struct ctl_show_rib *r, u_char *asdata, size_t aslen, json_do_bool("valid", r->flags & F_PREF_ELIGIBLE); if (r->flags & F_PREF_BEST) json_do_bool("best", 1); + if (r->flags & F_PREF_ECMP) + json_do_bool("ecmp", 1); + if (r->flags & F_PREF_AS_WIDE) + json_do_bool("as-wide", 1); if (r->flags & F_PREF_INTERNAL) json_do_printf("source", "%s", "internal"); else @@ -885,6 +889,7 @@ json_rib(struct ctl_show_rib *r, u_char *asdata, size_t aslen, json_do_uint("metric", r->med); json_do_uint("localpref", r->local_pref); json_do_uint("weight", r->weight); + json_do_int("dmetric", r->dmetric); json_do_printf("last_update", "%s", fmt_timeframe(r->age)); json_do_int("last_update_sec", r->age);