Hi, I noticed bgpctl didn't seem to have a way to show the MPLS label attached to MPLS L3VPN routes. The label was already there in the prefix info it just wasn't printed, so this diff adds printing the label info if the prefix has one in the show rib detail command.
Example output below. I was originally going to add it between Nexthop and Neighbor but when I did that I thought it could easily be mistaken to be the MPLS label of the next hop instead of the VPN label. So instead I put it on a new line. BGP routing table entry for rd 4372800702:702 172.19.195.2/31 4372800702 4372800702 4372800702 65521 Nexthop 172.17.0.7 (via 172.17.6.30) Neighbor 172.17.0.3 (172.17.0.3) Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, internal, valid Label 524280 Last update: 01:45:32 ago Ext. Communities: rt 4372800702:702 Originator Id: 172.17.0.7 Cluster Id List: 0.0.0.255 diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index 22c7dcce2..a9b1e09cd 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -19,6 +19,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/types.h> + #include <endian.h> #include <err.h> #include <math.h> @@ -936,6 +938,8 @@ show_rib_detail(struct ctl_show_rib *r, u_char *asdata, size_t aslen, { struct in_addr id; char *aspath, *s; + u_int32_t label; + int i; printf("\nBGP routing table entry for %s/%u%c", log_addr(&r->prefix), r->prefixlen, @@ -961,9 +965,22 @@ show_rib_detail(struct ctl_show_rib *r, u_char *asdata, size_t aslen, fmt_origin(r->origin, 0), r->med, r->local_pref, r->weight, fmt_ovs(r->validation_state, 0)); printf("%s", fmt_flags(r->flags, 0)); + printf("%c", EOL0(flag0)); - printf("%c Last update: %s ago%c", EOL0(flag0), - fmt_timeframe(r->age), EOL0(flag0)); + if (r->prefix.labellen) { + printf(" Label"); + for (i = 0; i < r->prefix.labellen / 3; ++i) { + printf(" "); + label = (r->prefix.labelstack[i * 3] << 12) | + (r->prefix.labelstack[i * 3 + 1] << 4) | + (r->prefix.labelstack[i * 3 + 2] >> 4); + printf("%u", label); + } + printf("%c", EOL0(flag0)); + } + + printf(" Last update: %s ago%c", fmt_timeframe(r->age), + EOL0(flag0)); } static void