From: claudio Date: Wed, 14 Aug 2024 19:10:51 +0000 (+0000) Subject: Add 'bgpctl show rib filtered' support. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=09b2f24c941b2b504dadf2dbf0cec4772a09785d;p=openbsd Add 'bgpctl show rib filtered' support. OK tb@ --- diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8 index 4f344f4d003..a1bd3636742 100644 --- a/usr.sbin/bgpctl/bgpctl.8 +++ b/usr.sbin/bgpctl/bgpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpctl.8,v 1.111 2023/05/09 13:26:27 claudio Exp $ +.\" $OpenBSD: bgpctl.8,v 1.112 2024/08/14 19:10:51 claudio Exp $ .\" .\" Copyright (c) 2003 Henning Brauer .\" @@ -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: May 9 2023 $ +.Dd $Mdocdate: August 14 2024 $ .Dt BGPCTL 8 .Os .Sh NAME @@ -416,6 +416,11 @@ Show only routes which are not eligible. Show only prefixes which are marked invalid and were treated as withdrawn. .It Ar family Limit the output to the given address family. +.It Cm filtered +Show only routes which were filtered out. +Requires +.Ic rde rib Loc-RIB include filtered +to be set in the config. .It Cm in Show routes from the unfiltered Adj-RIB-In. The diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 1dd4c7a6767..d8becf6f808 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.306 2024/05/22 08:42:34 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.307 2024/08/14 19:10:51 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -745,6 +745,8 @@ fmt_flags(uint32_t flags, int sum) char *p = flagstr; if (sum) { + if (flags & F_PREF_FILTERED) + *p++ = 'F'; if (flags & F_PREF_INVALID) *p++ = 'E'; if (flags & F_PREF_OTC_LEAK) @@ -771,6 +773,8 @@ fmt_flags(uint32_t flags, int sum) else strlcpy(buf, "external", sizeof(buf)); + if (flags & F_PREF_FILTERED) + strlcat(buf, ", filtered", sizeof(buf)); if (flags & F_PREF_INVALID) strlcat(buf, ", invalid", sizeof(buf)); if (flags & F_PREF_OTC_LEAK) diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index e75ec7a2266..8f72fecc892 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.52 2024/08/12 09:05:28 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.53 2024/08/14 19:10:51 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -66,7 +66,7 @@ show_head(struct parse_result *res) break; printf("flags: " "* = Valid, > = Selected, I = via IBGP, A = Announced,\n" - " S = Stale, E = Error\n"); + " S = Stale, E = Error, F = Filtered\n"); printf("origin validation state: " "N = not-found, V = valid, ! = invalid\n"); printf("aspa validation state: " diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index daf865a1b4b..8a2e26ccf78 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.45 2024/08/12 09:05:28 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.46 2024/08/14 19:10:51 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -834,6 +834,8 @@ json_rib(struct ctl_show_rib *r, struct ibuf *asbuf, struct parse_result *res) /* flags */ json_do_bool("valid", r->flags & F_PREF_ELIGIBLE); + if (r->flags & F_PREF_FILTERED) + json_do_bool("filtered", 1); if (r->flags & F_PREF_BEST) json_do_bool("best", 1); if (r->flags & F_PREF_ECMP) diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 56be82df705..7654051b8b1 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.134 2023/11/20 14:18:21 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.135 2024/08/14 19:10:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -183,6 +183,7 @@ static const struct token t_show_rib[] = { { ASTYPE, "empty-as", AS_EMPTY, t_show_rib}, { FLAG, "error", F_CTL_INVALID, t_show_rib}, { EXTCOMMUNITY, "ext-community", NONE, t_show_rib}, + { FLAG, "filtered", F_CTL_FILTERED, t_show_rib}, { FLAG, "in", F_CTL_ADJ_IN, t_show_rib}, { LRGCOMMUNITY, "large-community", NONE, t_show_rib}, { FLAG, "leaked", F_CTL_LEAKED, t_show_rib},