From 1edf347076a39f0e69e79a342ce03292e7070b41 Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 9 Nov 2022 14:20:11 +0000 Subject: [PATCH] Show the MPLS label of a L3VPN route in show fib output. OK tb@ --- usr.sbin/bgpctl/bgpctl.h | 4 +++- usr.sbin/bgpctl/output.c | 4 +++- usr.sbin/bgpctl/output_json.c | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.h b/usr.sbin/bgpctl/bgpctl.h index 7014095ba75..e911bd5cf66 100644 --- a/usr.sbin/bgpctl/bgpctl.h +++ b/usr.sbin/bgpctl/bgpctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.h,v 1.17 2022/10/17 12:01:19 claudio Exp $ */ +/* $OpenBSD: bgpctl.h,v 1.18 2022/11/09 14:20:11 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -58,3 +58,5 @@ const char *fmt_community(uint16_t, uint16_t); const char *fmt_large_community(uint32_t, uint32_t, uint32_t); const char *fmt_ext_community(uint8_t *); const char *fmt_set_type(struct ctl_show_set *); + +#define MPLS_LABEL_OFFSET 12 diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index 4c746b10def..1597d48be81 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.31 2022/11/07 11:33:24 mbuhl Exp $ */ +/* $OpenBSD: output.c,v 1.32 2022/11/09 14:20:11 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -477,6 +477,8 @@ show_fib(struct kroute_full *kf) printf("link#%u", kf->ifindex); else printf("%s", log_addr(&kf->nexthop)); + if (kf->flags & F_MPLS) + printf(" mpls %d", ntohl(kf->mplslabel) >> MPLS_LABEL_OFFSET); printf("\n"); } diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 6def8a3ac23..22752f11cea 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.25 2022/11/07 11:33:24 mbuhl Exp $ */ +/* $OpenBSD: output_json.c,v 1.26 2022/11/09 14:20:11 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -385,6 +385,12 @@ json_fib(struct kroute_full *kf) else json_do_printf("nexthop", "%s", log_addr(&kf->nexthop)); + if (kf->flags & F_MPLS) { + json_do_array("mplslabel"); + json_do_uint("mplslabel", + ntohl(kf->mplslabel) >> MPLS_LABEL_OFFSET); + json_do_end(); + } json_do_end(); } -- 2.20.1