diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-12-03 10:38:07 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-12-03 10:38:07 +0000 |
commit | e5b0af1484b6b92037d9e84084d68fa68520ca77 (patch) | |
tree | 1e060fa9c42887a1ec6a50051f843f8bcf2ba7aa | |
parent | d26cf8511bcba4a74eb0188a544993b5a9e62550 (diff) |
Add /rib/in and /rib/out as endpoints to query the Adj-RIB-In and Adj-RIB-Out
respectively.
Also fix the rib query parameter to properly work. bgpctl calls this table.
OK sthen@
-rw-r--r-- | usr.sbin/bgplgd/bgplgd.8 | 20 | ||||
-rw-r--r-- | usr.sbin/bgplgd/bgplgd.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgplgd/bgplgd.h | 16 | ||||
-rw-r--r-- | usr.sbin/bgplgd/qs.c | 4 |
4 files changed, 32 insertions, 14 deletions
diff --git a/usr.sbin/bgplgd/bgplgd.8 b/usr.sbin/bgplgd/bgplgd.8 index ce9a9d39347..70a67339aa7 100644 --- a/usr.sbin/bgplgd/bgplgd.8 +++ b/usr.sbin/bgplgd/bgplgd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgplgd.8,v 1.11 2024/09/19 08:55:22 claudio Exp $ +.\" $OpenBSD: bgplgd.8,v 1.12 2024/12/03 10:38:06 claudio Exp $ .\" .\" Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org> .\" @@ -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: September 19 2024 $ +.Dd $Mdocdate: December 3 2024 $ .Dt BGPLGD 8 .Os .Sh NAME @@ -88,7 +88,8 @@ Show the version and exit. .Nm provides the following API endpoints. Unless further specified the endpoints do not take any parameters: -.Bl -tag -width Ds +.Pp +.Bl -tag -width "/interfaces" -compact .It Pa /interfaces Show the interface states. .It Pa /memory @@ -110,7 +111,17 @@ Show only entries from the specified peer group. .It Pa /nexthops Show the list of BGP nexthops and the result of their validity check. .It Pa /rib +.It Pa /rib/in +.It Pa /rib/out Show routes from the bgpd(8) Routing Information Base. +For +.Pa /rib/in +the +.Ar Adj-RIB-In +will be queried and for +.Pa /rib/out +the +.Ar Adj-RIB-out . The following parameters can be used to filter the output: .Pp .Bl -tag -width "neighbor=peer" -compact @@ -134,6 +145,9 @@ Show only entries that match the specified address family. .It Cm rib Ns = Ns Ar name Show only entries from the RIB with name .Ar name . +Can only be used with the +.Pa /rib +endpoint. .It Xo .Ic ovs Ns = Ns .Pq Ic valid | not-found | invalid diff --git a/usr.sbin/bgplgd/bgplgd.c b/usr.sbin/bgplgd/bgplgd.c index e66da1672cd..a807c2b52ba 100644 --- a/usr.sbin/bgplgd/bgplgd.c +++ b/usr.sbin/bgplgd/bgplgd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgplgd.c,v 1.3 2022/10/17 15:42:19 claudio Exp $ */ +/* $OpenBSD: bgplgd.c,v 1.4 2024/12/03 10:38:06 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * @@ -25,7 +25,7 @@ #include "bgplgd.h" -#define NCMDARGS 4 +#define NCMDARGS 5 #define OMETRIC_TYPE \ "application/openmetrics-text; version=1.0.0; charset=utf-8" @@ -41,6 +41,8 @@ const struct cmd { { "/neighbors", { "show", "neighbor", NULL }, QS_MASK_NEIGHBOR, 1 }, { "/nexthops", { "show", "nexthop", NULL }, 0 }, { "/rib", { "show", "rib", "detail", NULL }, QS_MASK_RIB }, + { "/rib/in", { "show", "rib", "in", "detail", NULL }, QS_MASK_ADJRIB }, + { "/rib/out", { "show", "rib", "out", "detail", NULL }, QS_MASK_ADJRIB }, { "/rtr", { "show", "rtr", NULL }, 0 }, { "/sets", { "show", "sets", NULL }, 0 }, { "/summary", { "show", NULL }, 0 }, diff --git a/usr.sbin/bgplgd/bgplgd.h b/usr.sbin/bgplgd/bgplgd.h index 4cf62b73af4..c74d9cedadb 100644 --- a/usr.sbin/bgplgd/bgplgd.h +++ b/usr.sbin/bgplgd/bgplgd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgplgd.h,v 1.4 2024/08/15 09:13:13 claudio Exp $ */ +/* $OpenBSD: bgplgd.h,v 1.5 2024/12/03 10:38:06 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * @@ -35,17 +35,19 @@ #define QS_FILTERED 18 #define QS_MAX 19 -/* too add: empty-as, in, out, peer-as, source-as, transit-as */ +/* too add: empty-as, peer-as, source-as, transit-as */ #define QS_MASK_NEIGHBOR ((1 << QS_NEIGHBOR) | (1 << QS_GROUP)) -#define QS_MASK_RIB \ +#define QS_MASK_ADJRIB \ ((1 << QS_NEIGHBOR) | (1 << QS_GROUP) | (1 << QS_AS) | \ (1 << QS_PREFIX) | (1 << QS_COMMUNITY) | \ (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_INVALID) | \ - (1 << QS_LEAKED) | (1 << QS_FILTERED)) + (1 << QS_AF) | (1 << QS_OVS) | (1 << QS_BEST) | \ + (1 << QS_ALL) | (1 << QS_SHORTER) | (1 << QS_ERROR) | \ + (1 << QS_AVS) | (1 << QS_INVALID) | (1 << QS_LEAKED) | \ + (1 << QS_FILTERED)) + +#define QS_MASK_RIB (QS_MASK_ADJRIB | (1 << QS_RIB)) struct cmd; struct lg_ctx { diff --git a/usr.sbin/bgplgd/qs.c b/usr.sbin/bgplgd/qs.c index ee865810fbb..7dde7010800 100644 --- a/usr.sbin/bgplgd/qs.c +++ b/usr.sbin/bgplgd/qs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qs.c,v 1.6 2024/08/15 09:13:13 claudio Exp $ */ +/* $OpenBSD: qs.c,v 1.7 2024/12/03 10:38:06 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * @@ -367,7 +367,7 @@ qs_argv(char **argv, size_t argc, size_t len, struct lg_ctx *ctx, int barenbr) } if (ctx->qs_set & (1 << QS_RIB)) { if (argc < len) - argv[argc++] = "rib"; + argv[argc++] = "table"; if (argc < len) argv[argc++] = ctx->qs_args[QS_RIB].string; } |