summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-11-09 14:20:12 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-11-09 14:20:12 +0000
commitdb8481d0501226032067d65e59e40d907d464dae (patch)
tree8e30fe18a13825b1b4e4c0381c1ec772b54af12d /usr.sbin
parent33478f270b061b173cdfcf0b1b9224bc6356f1a7 (diff)
Show the MPLS label of a L3VPN route in show fib output.
OK tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpctl/bgpctl.h4
-rw-r--r--usr.sbin/bgpctl/output.c4
-rw-r--r--usr.sbin/bgpctl/output_json.c8
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 <claudio@openbsd.org>
@@ -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 <henning@openbsd.org>
@@ -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 <claudio@openbsd.org>
@@ -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();
}