On Fri, Mar 06, 2020 at 05:53:59PM +0100, Sebastian Benoit wrote: > Hi, > > generate 3 different outputs for BIRD: > - bird v1 with IPv4 routes > - bird v1 with IPv6 routes > - bird v2 > when using command line option -B. > BIRD v2 output from Robert Scheck, robert AT fedoraproject DOT org > > > Note that I haven't tried this with bird 1 or 2 yet ;) > comments, oks? > > > (benno_rpki_bird.diff) > > diff --git usr.sbin/rpki-client/extern.h usr.sbin/rpki-client/extern.h > index 127db60fa37..6592ea83b5e 100644 > --- usr.sbin/rpki-client/extern.h > +++ usr.sbin/rpki-client/extern.h > @@ -374,7 +374,9 @@ FILE *output_createtmp(char *); > void output_cleantmp(void); > void output_finish(FILE *); > int output_bgpd(FILE *, struct vrp_tree *); > -int output_bird(FILE *, struct vrp_tree *); > +int output_bird1v4(FILE *, struct vrp_tree *); > +int output_bird1v6(FILE *, struct vrp_tree *); > +int output_bird2(FILE *, struct vrp_tree *); > int output_csv(FILE *, struct vrp_tree *); > int output_json(FILE *, struct vrp_tree *); > > diff --git usr.sbin/rpki-client/output-bird.c > usr.sbin/rpki-client/output-bird.c > index a15faa69164..0299018f8af 100644 > --- usr.sbin/rpki-client/output-bird.c > +++ usr.sbin/rpki-client/output-bird.c > @@ -1,6 +1,7 @@ > /* $OpenBSD: output-bird.c,v 1.6 2019/12/04 23:03:05 benno Exp $ */ > /* > * Copyright (c) 2019 Claudio Jeker <clau...@openbsd.org> > + * Copyright (c) 2020 Robert Scheck <rob...@fedoraproject.org> > * > * Permission to use, copy, modify, and distribute this software for any > * purpose with or without fee is hereby granted, provided that the above > @@ -21,7 +22,7 @@ > #include "extern.h" > > int > -output_bird(FILE *out, struct vrp_tree *vrps) > +output_bird1v4(FILE *out, struct vrp_tree *vrps) > { > extern const char *bird_tablename; > char buf[64]; > @@ -31,10 +32,78 @@ output_bird(FILE *out, struct vrp_tree *vrps) > return -1; > > RB_FOREACH(v, vrp_tree, vrps) { > - ip_addr_print(&v->addr, v->afi, buf, sizeof(buf)); > - if (fprintf(out, "\troa %s max %u as %u;\n", buf, v->maxlength, > - v->asid) < 0) > + 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, > + 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) > +{ > + extern const char *bird_tablename; > + char buf[64]; > + struct vrp *v; > + > + if (fprintf(out, "roa table %s {\n", bird_tablename) < 0) > + return -1; > + > + RB_FOREACH(v, vrp_tree, vrps) { > + 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, > + v->maxlength, v->asid) < 0) > + return -1; > + } > + } > + > + if (fprintf(out, "}\n") < 0) > + return -1; > + return 0; > +} > + > +int > +output_bird2(FILE *out, struct vrp_tree *vrps) > +{ > + extern const char *bird_tablename; > + char buf[64]; > + struct vrp *v; > + time_t now = time(NULL); > + > + if (fprintf(out, "define 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) { > + if (v->afi == AFI_IPV4) { > + ip_addr_print(&v->addr, v->afi, buf, sizeof(buf)); > + if (fprintf(out, "\troute %s max %u as %u;\n", buf, > + v->maxlength, v->asid) < 0) > + return -1; > + } > + } > + > + if (fprintf(out, "}\n\nprotocol static {\n\troa6 { table %s6; };\n\n", > + bird_tablename) < 0) > + return -1; > + > + RB_FOREACH(v, vrp_tree, vrps) { > + if (v->afi == AFI_IPV6) { > + ip_addr_print(&v->addr, v->afi, buf, sizeof(buf)); > + if (fprintf(out, "\troute %s max %u as %u;\n", buf, > + v->maxlength, v->asid) < 0) > + return -1; > + } > } > > if (fprintf(out, "}\n") < 0) > diff --git usr.sbin/rpki-client/output.c usr.sbin/rpki-client/output.c > index adafc5c0b53..b26b964eeaa 100644 > --- usr.sbin/rpki-client/output.c > +++ usr.sbin/rpki-client/output.c > @@ -39,10 +39,12 @@ struct outputs { > char *name; > int (*fn)(FILE *, struct vrp_tree *); > } outputs[] = { > - { FORMAT_OPENBGPD, "openbgpd", output_bgpd }, > - { FORMAT_BIRD, "bird", output_bird }, > - { FORMAT_CSV, "csv", output_csv }, > - { FORMAT_JSON, "json", output_json }, > + { FORMAT_OPENBGPD, "openbgpd", output_bgpd }, > + { FORMAT_BIRD, "bird1v4", output_bird1v4 }, > + { FORMAT_BIRD, "bird1v6", output_bird1v6 }, > + { FORMAT_BIRD, "bird", output_bird2 }, > + { FORMAT_CSV, "csv", output_csv }, > + { FORMAT_JSON, "json", output_json },
Spaces, my god so many spaces. > { 0, NULL } > }; > Apart from that OK claudio@, we can tweak and fix it more in tree :) -- :wq Claudio