diff options
author | Job Snijders <job@cvs.openbsd.org> | 2025-01-02 12:29:31 +0000 |
---|---|---|
committer | Job Snijders <job@cvs.openbsd.org> | 2025-01-02 12:29:31 +0000 |
commit | 89b4554eac072748093f6bcf8117d6914e5a1e65 (patch) | |
tree | a10655ee549d93d6904be34b6af6613bee9af740 /usr.sbin/rpki-client | |
parent | 448ba1fe1ed08062c5a97f8e13bc3889b9d01298 (diff) |
Remove BIRD v1 output, add BIRD v3 output (which includes static ASPA entries)
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r-- | usr.sbin/rpki-client/extern.h | 8 | ||||
-rw-r--r-- | usr.sbin/rpki-client/output-bird.c | 77 | ||||
-rw-r--r-- | usr.sbin/rpki-client/output.c | 5 | ||||
-rw-r--r-- | usr.sbin/rpki-client/rpki-client.8 | 10 |
4 files changed, 62 insertions, 38 deletions
diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h index e4277ba1795..95e0c1847ed 100644 --- a/usr.sbin/rpki-client/extern.h +++ b/usr.sbin/rpki-client/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.234 2024/12/02 14:55:02 job Exp $ */ +/* $OpenBSD: extern.h,v 1.235 2025/01/02 12:29:30 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -969,12 +969,10 @@ int outputfiles(struct vrp_tree *v, struct brk_tree *b, int outputheader(FILE *, struct stats *); int output_bgpd(FILE *, struct vrp_tree *, struct brk_tree *, struct vap_tree *, struct vsp_tree *, struct stats *); -int output_bird1v4(FILE *, struct vrp_tree *, struct brk_tree *, - struct vap_tree *, struct vsp_tree *, struct stats *); -int output_bird1v6(FILE *, struct vrp_tree *, struct brk_tree *, - struct vap_tree *, struct vsp_tree *, struct stats *); int output_bird2(FILE *, struct vrp_tree *, struct brk_tree *, struct vap_tree *, struct vsp_tree *, struct stats *); +int output_bird3(FILE *, struct vrp_tree *, struct brk_tree *, + struct vap_tree *, struct vsp_tree *, struct stats *); int output_csv(FILE *, struct vrp_tree *, struct brk_tree *, struct vap_tree *, struct vsp_tree *, struct stats *); int output_json(FILE *, struct vrp_tree *, struct brk_tree *, diff --git a/usr.sbin/rpki-client/output-bird.c b/usr.sbin/rpki-client/output-bird.c index fca66050797..f824271d324 100644 --- a/usr.sbin/rpki-client/output-bird.c +++ b/usr.sbin/rpki-client/output-bird.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-bird.c,v 1.19 2024/02/22 12:49:42 job Exp $ */ +/* $OpenBSD: output-bird.c,v 1.20 2025/01/02 12:29:30 job Exp $ */ /* * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2020 Robert Scheck <robert@fedoraproject.org> @@ -21,16 +21,21 @@ #include "extern.h" int -output_bird1v4(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, +output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) { extern const char *bird_tablename; struct vrp *v; + time_t now = get_current_time(); if (outputheader(out, st) < 0) return -1; - if (fprintf(out, "\nroa table %s {\n", bird_tablename) < 0) + if (fprintf(out, "\ndefine force_roa_table_update = %lld;\n\n" + "roa4 table %s4;\nroa6 table %s6;\n\n" + "protocol static {\n\troa4 { table %s4; };\n\n", + (long long)now, bird_tablename, bird_tablename, + bird_tablename) < 0) return -1; RB_FOREACH(v, vrp_tree, vrps) { @@ -38,28 +43,14 @@ output_bird1v4(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, if (v->afi == AFI_IPV4) { ip_addr_print(&v->addr, v->afi, buf, sizeof(buf)); - if (fprintf(out, "\troa %s max %u as %u;\n", buf, + if (fprintf(out, "\troute %s max %u as %u;\n", buf, v->maxlength, v->asid) < 0) return -1; } } - if (fprintf(out, "}\n") < 0) - return -1; - return 0; -} - -int -output_bird1v6(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, - struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) -{ - extern const char *bird_tablename; - struct vrp *v; - - if (outputheader(out, st) < 0) - return -1; - - if (fprintf(out, "\nroa table %s {\n", bird_tablename) < 0) + if (fprintf(out, "}\n\nprotocol static {\n\troa6 { table %s6; };\n\n", + bird_tablename) < 0) return -1; RB_FOREACH(v, vrp_tree, vrps) { @@ -67,7 +58,7 @@ output_bird1v6(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, if (v->afi == AFI_IPV6) { ip_addr_print(&v->addr, v->afi, buf, sizeof(buf)); - if (fprintf(out, "\troa %s max %u as %u;\n", buf, + if (fprintf(out, "\troute %s max %u as %u;\n", buf, v->maxlength, v->asid) < 0) return -1; } @@ -79,20 +70,29 @@ output_bird1v6(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, } int -output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, +output_bird3(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, struct vap_tree *vaps, struct vsp_tree *vsps, struct stats *st) { extern const char *bird_tablename; struct vrp *v; + struct vap *vap; time_t now = get_current_time(); + size_t i; if (outputheader(out, st) < 0) return -1; if (fprintf(out, "\ndefine force_roa_table_update = %lld;\n\n" - "roa4 table %s4;\nroa6 table %s6;\n\n" - "protocol static {\n\troa4 { table %s4; };\n\n", - (long long)now, bird_tablename, bird_tablename, + "roa4 table %s4;\nroa6 table %s6;\n", (long long)now, + bird_tablename, bird_tablename) < 0) + return -1; + + if (!excludeaspa) { + if (fprintf(out, "aspa table ASPAS;\n") < 0) + return -1; + } + + if (fprintf(out, "\nprotocol static {\n\troa4 { table %s4; };\n\n", bird_tablename) < 0) return -1; @@ -122,7 +122,34 @@ output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, } } + if (fprintf(out, "}") < 0) + return -1; + + if (excludeaspa) + return 0; + + if (fprintf(out, "\n\nprotocol static {\n\taspa { table ASPAS; " + "};\n\n") < 0) + return -1; + + RB_FOREACH(vap, vap_tree, vaps) { + if (vap->overflowed) + continue; + if (fprintf(out, "\troute aspa %d providers ", vap->custasid) <0) + return -1; + for (i = 0; i < vap->num_providers; i++) { + if (fprintf(out, "%u", vap->providers[i]) < 0) + return -1; + if (i + 1 < vap->num_providers) + if (fprintf(out, ", ") < 0) + return -1; + } + if (fprintf(out, ";\n") < 0) + return -1; + } + if (fprintf(out, "}\n") < 0) return -1; + return 0; } diff --git a/usr.sbin/rpki-client/output.c b/usr.sbin/rpki-client/output.c index 93b97dc7674..31913a318ee 100644 --- a/usr.sbin/rpki-client/output.c +++ b/usr.sbin/rpki-client/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.36 2024/12/15 19:42:33 tb Exp $ */ +/* $OpenBSD: output.c,v 1.37 2025/01/02 12:29:30 job Exp $ */ /* * Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org> * @@ -67,9 +67,8 @@ static const struct outputs { struct vap_tree *, struct vsp_tree *, struct stats *); } outputs[] = { { FORMAT_OPENBGPD, "openbgpd", output_bgpd }, - { FORMAT_BIRD, "bird1v4", output_bird1v4 }, - { FORMAT_BIRD, "bird1v6", output_bird1v6 }, { FORMAT_BIRD, "bird", output_bird2 }, + { FORMAT_BIRD, "bird3", output_bird3 }, { FORMAT_CSV, "csv", output_csv }, { FORMAT_JSON, "json", output_json }, { FORMAT_OMETRIC, "metrics", output_ometric }, diff --git a/usr.sbin/rpki-client/rpki-client.8 b/usr.sbin/rpki-client/rpki-client.8 index 0c403ac1b99..bdd882cb876 100644 --- a/usr.sbin/rpki-client/rpki-client.8 +++ b/usr.sbin/rpki-client/rpki-client.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rpki-client.8,v 1.115 2024/12/04 16:17:31 job Exp $ +.\" $OpenBSD: rpki-client.8,v 1.116 2025/01/02 12:29:30 job Exp $ .\" .\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -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: December 4 2024 $ +.Dd $Mdocdate: January 2 2025 $ .Dt RPKI-CLIENT 8 .Os .Sh NAME @@ -72,11 +72,11 @@ Exclude the ASPA-set from the output files that support it (JSON and OpenBGPD). .It Fl B Create output in the files -.Pa bird1v4 , -.Pa bird1v6 , -and .Pa bird (for bird2) +and +.Pa bird3 +(for bird3) in the output directory which is suitable for the BIRD internet routing daemon. .It Fl b Ar sourceaddr Tell the HTTP and rsync clients to use |