From cb563a9e29415a44b4c0733dda505cec6d8cf3d3 Mon Sep 17 00:00:00 2001 From: claudio Date: Mon, 13 Mar 2023 17:31:28 +0000 Subject: [PATCH] Extend bgplgd to handle leaked and invalid options to show rib. OK tb@ --- usr.sbin/bgplgd/bgplgd.8 | 8 ++++++-- usr.sbin/bgplgd/bgplgd.h | 9 ++++++--- usr.sbin/bgplgd/qs.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/usr.sbin/bgplgd/bgplgd.8 b/usr.sbin/bgplgd/bgplgd.8 index 377abecc0b3..a6a1a184bf8 100644 --- a/usr.sbin/bgplgd/bgplgd.8 +++ b/usr.sbin/bgplgd/bgplgd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgplgd.8,v 1.6 2023/02/03 15:51:09 jmc Exp $ +.\" $OpenBSD: bgplgd.8,v 1.7 2023/03/13 17:31:28 claudio Exp $ .\" .\" Copyright (c) 2021 Claudio Jeker .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 3 2023 $ +.Dd $Mdocdate: March 13 2023 $ .Dt BGPLGD 8 .Os .Sh NAME @@ -145,6 +145,10 @@ Show only prefixes that match the specified ASPA Validation State. Show only selected routes. .It Cm error Ns = Ns 1 Show only prefixes which are marked invalid and were treated as withdrawn. +.It Cm invalid Ns = Ns 1 +Show only prefixes which are not eligible. +.It Cm leaked Ns = Ns 1 +Show only prefixes where a route leak was detected. .It Cm prefix Ns = Ns Ar addr Show only entries that match prefix either as the best matching route or show the entry for this CIDR prefix. diff --git a/usr.sbin/bgplgd/bgplgd.h b/usr.sbin/bgplgd/bgplgd.h index 4b3726151b4..1a660378683 100644 --- a/usr.sbin/bgplgd/bgplgd.h +++ b/usr.sbin/bgplgd/bgplgd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgplgd.h,v 1.2 2023/02/03 10:10:36 job Exp $ */ +/* $OpenBSD: bgplgd.h,v 1.3 2023/03/13 17:31:28 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker * @@ -30,7 +30,9 @@ #define QS_SHORTER 13 #define QS_ERROR 14 #define QS_AVS 15 -#define QS_MAX 16 +#define QS_INVALID 16 +#define QS_LEAKED 17 +#define QS_MAX 18 /* too add: empty-as, in, out, peer-as, source-as, transit-as */ @@ -41,7 +43,8 @@ (1 << QS_EXTCOMMUNITY) | (1 << QS_LARGECOMMUNITY) | \ (1 << QS_AF) | (1 << QS_RIB) | (1 << QS_OVS) | \ (1 << QS_BEST) | (1 << QS_ALL) | (1 << QS_SHORTER) | \ - (1 << QS_ERROR) | (1 << QS_AVS)) + (1 << QS_ERROR) | (1 << QS_AVS) | (1 << QS_INVALID) | \ + (1 << QS_LEAKED)) struct cmd; struct lg_ctx { diff --git a/usr.sbin/bgplgd/qs.c b/usr.sbin/bgplgd/qs.c index 98d2664eef9..cb5dfde7c79 100644 --- a/usr.sbin/bgplgd/qs.c +++ b/usr.sbin/bgplgd/qs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qs.c,v 1.3 2023/02/03 10:10:36 job Exp $ */ +/* $OpenBSD: qs.c,v 1.4 2023/03/13 17:31:28 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker * @@ -55,6 +55,8 @@ const struct qs { { QS_SHORTER, "or-shorter", ONE }, { QS_ERROR, "error", ONE }, { QS_AVS, "avs", AVS }, + { QS_INVALID, "invalid", ONE }, + { QS_LEAKED, "leaked", ONE }, { 0, NULL } }; @@ -380,13 +382,19 @@ qs_argv(char **argv, size_t argc, size_t len, struct lg_ctx *ctx, int barenbr) if (argc < len) argv[argc++] = ctx->qs_args[QS_AVS].string; } - /* BEST and ERROR are exclusive */ + /* BEST, ERROR, INVALID and LEAKED are exclusive */ if (ctx->qs_args[QS_BEST].one) { if (argc < len) argv[argc++] = "best"; } else if (ctx->qs_args[QS_ERROR].one) { if (argc < len) argv[argc++] = "error"; + } else if (ctx->qs_args[QS_INVALID].one) { + if (argc < len) + argv[argc++] = "invalid"; + } else if (ctx->qs_args[QS_LEAKED].one) { + if (argc < len) + argv[argc++] = "leaked"; } /* prefix must be last for show rib */ -- 2.20.1