update to bgpq3-0.1.33

This commit is contained in:
sthen 2017-11-15 21:50:47 +00:00
parent d579e1bf4e
commit d2dfc303ee
5 changed files with 5 additions and 225 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.4 2016/10/14 13:14:45 phessler Exp $
# $OpenBSD: Makefile,v 1.5 2017/11/15 21:50:47 sthen Exp $
PORTROACH = skipv:initial
COMMENT = bgp filtering automation for Cisco and Juniper routers
COMMENT = bgp filtering automation for Cisco and Juniper routers
VERSION = 0.1.32
VERSION = 0.1.33
GH_PROJECT = bgpq3
GH_ACCOUNT = snar
GH_TAGNAME = v${VERSION}

View File

@ -1,2 +1,2 @@
SHA256 (bgpq3-0.1.32.tar.gz) = oRwoPbGkgNCFvhWjN8sK1j3+73jk2gmo9enzI7arMxs=
SIZE (bgpq3-0.1.32.tar.gz) = 82283
SHA256 (bgpq3-0.1.33.tar.gz) = 86WNVHNoxDluW8K2GJ/paFZ/Gv3kckUiCxupSGsm+zk=
SIZE (bgpq3-0.1.33.tar.gz) = 82696

View File

@ -1,50 +0,0 @@
$OpenBSD: patch-bgpq3_c,v 1.1 2016/10/14 13:15:21 phessler Exp $
--- bgpq3.c.orig Wed Sep 23 18:29:08 2015
+++ bgpq3.c Tue Oct 4 13:16:40 2016
@@ -27,7 +27,7 @@ int
usage(int ecode)
{
printf("\nUsage: bgpq3 [-h host[:port]] [-S sources] [-P|E|G <num>|f <num>]"
- " [-2346AbDJjXd] [-R len] <OBJECTS>...\n");
+ " [-2346AbBDJjXd] [-R len] <OBJECTS>...\n");
printf(" -2 : allow routes belonging to as23456 (transition-as) "
"(default: false)\n");
printf(" -3 : assume that your device is asn32-safe\n");
@@ -36,6 +36,7 @@ usage(int ecode)
printf(" -A : try to aggregate Cisco prefix-lists or Juniper "
"route-filters\n as much as possible\n");
printf(" -b : generate BIRD output (Cisco IOS by default)\n");
+ printf(" -B : generate OpenBGPD output (Cisco IOS by default)\n");
printf(" -d : generate some debugging output\n");
printf(" -D : use asdot notation in as-path (Cisco only)\n");
printf(" -E : generate extended access-list(Cisco) or "
@@ -81,7 +82,7 @@ exclusive()
void
vendor_exclusive()
{
- fprintf(stderr, "-b (BIRD), -F (formatted), -J (JunOS), -j (JSON) "
+ fprintf(stderr, "-b (BIRD), -B (OpenBGPD), -F (formatted), -J (JunOS), -j (JSON) "
"and -X (IOS XR) options are mutually exclusive\n");
exit(1);
};
@@ -134,7 +135,7 @@ main(int argc, char* argv[])
if (getenv("IRRD_SOURCES"))
expander.sources=getenv("IRRD_SOURCES");
- while((c=getopt(argc,argv,"2346AbdDEF:S:jJf:l:L:m:M:W:Ppr:R:G:Th:Xs"))
+ while((c=getopt(argc,argv,"2346AbBdDEF:S:jJf:l:L:m:M:W:Ppr:R:G:Th:Xs"))
!=EOF) {
switch(c) {
case '2':
@@ -167,6 +168,11 @@ main(int argc, char* argv[])
case 'b':
if(expander.vendor) vendor_exclusive();
expander.vendor=V_BIRD;
+ break;
+ case 'B':
+ if(expander.vendor) vendor_exclusive();
+ expander.vendor=V_OPENBGPD;
+ expander.asn32=1;
break;
case 'd': debug_expander++;
break;

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-bgpq3_h,v 1.1 2016/10/14 13:15:21 phessler Exp $
--- bgpq3.h.orig Fri Jan 8 18:52:16 2016
+++ bgpq3.h Fri Jan 8 18:52:39 2016
@@ -16,6 +16,7 @@ typedef enum {
V_CISCO_XR,
V_JSON,
V_BIRD,
+ V_OPENBGPD,
V_FORMAT
} bgpq_vendor_t;

View File

@ -1,159 +0,0 @@
$OpenBSD: patch-bgpq3_printer_c,v 1.1 2016/10/14 13:15:21 phessler Exp $
--- bgpq3_printer.c.orig Sun Aug 28 18:18:20 2016
+++ bgpq3_printer.c Tue Oct 4 13:34:25 2016
@@ -18,6 +18,7 @@ extern int debug_expander;
int bgpq3_print_json_aspath(FILE* f, struct bgpq_expander* b);
int bgpq3_print_bird_aspath(FILE* f, struct bgpq_expander* b);
+int bgpq3_print_openbgpd_aspath(FILE* f, struct bgpq_expander* b);
int
bgpq3_print_cisco_aspath(FILE* f, struct bgpq_expander* b)
@@ -304,6 +305,25 @@ bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expan
};
int
+bgpq3_print_openbgpd_oaspath(FILE* f, struct bgpq_expander* b)
+{
+ int i, j, k;
+
+ for(k=0;k<65536;k++) {
+ if(!b->asn32s[k]) continue;
+
+ for(i=0;i<8192;i++) {
+ for(j=0;j<8;j++) {
+ if(b->asn32s[k][i]&(0x80>>j)) {
+ fprintf(f, "%s%u%s%u\n", "allow to AS ", b->asnumber, " AS ", k*65536+i*8+j);
+ };
+ };
+ };
+ };
+ return 0;
+};
+
+int
bgpq3_print_aspath(FILE* f, struct bgpq_expander* b)
{
if(b->vendor==V_JUNIPER) {
@@ -316,6 +336,8 @@ bgpq3_print_aspath(FILE* f, struct bgpq_expander* b)
return bgpq3_print_json_aspath(f,b);
} else if(b->vendor==V_BIRD) {
return bgpq3_print_bird_aspath(f,b);
+ } else if(b->vendor==V_OPENBGPD) {
+ return bgpq3_print_openbgpd_aspath(f,b);
} else {
sx_report(SX_FATAL,"Unknown vendor %i\n", b->vendor);
};
@@ -331,6 +353,8 @@ bgpq3_print_oaspath(FILE* f, struct bgpq_expander* b)
return bgpq3_print_cisco_oaspath(f,b);
} else if(b->vendor==V_CISCO_XR) {
return bgpq3_print_cisco_xr_oaspath(f,b);
+ } else if(b->vendor==V_OPENBGPD) {
+ return bgpq3_print_openbgpd_oaspath(f,b);
} else {
sx_report(SX_FATAL,"Unknown vendor %i\n", b->vendor);
};
@@ -472,6 +496,53 @@ bgpq3_print_bird_aspath(FILE* f, struct bgpq_expander*
};
void
+bgpq3_print_openbgpd_prefix(struct sx_radix_node* n, void* ff)
+{
+ char prefix[128];
+ FILE* f=(FILE*)ff;
+ if(n->isGlue)
+ goto checkSon;
+ if(!f)
+ f=stdout;
+ sx_prefix_snprintf(&n->prefix, prefix, sizeof(prefix));
+ if (!n->isAggregate) {
+ fprintf(f, "\n\t%s \\", prefix);
+ } else if (n->aggregateLow == n->aggregateHi) {
+ fprintf(f, "\n\t%s prefixlen = %u \\",
+ prefix, n->aggregateHi);
+ } else if (n->aggregateLow > n->prefix.masklen) {
+ fprintf(f, "\n\t%s prefixlen %u - %u \\",
+ prefix, n->aggregateLow, n->aggregateHi);
+ } else {
+ fprintf(f, "\n\t%s prefixlen %u - %u \\",
+ prefix, n->prefix.masklen, n->aggregateHi);
+ };
+ needscomma=1;
+checkSon:
+ if(n->son)
+ bgpq3_print_openbgpd_prefix(n->son, ff);
+};
+
+int
+bgpq3_print_openbgpd_aspath(FILE* f, struct bgpq_expander* b)
+{
+ int i, j, k;
+
+ for(k=0;k<65536;k++) {
+ if(!b->asn32s[k]) continue;
+
+ for(i=0;i<8192;i++) {
+ for(j=0;j<8;j++) {
+ if(b->asn32s[k][i]&(0x80>>j)) {
+ fprintf(f, "%s%u%s%u\n", "allow from AS ", b->asnumber, " AS ", k*65536+i*8+j);
+ };
+ };
+ };
+ };
+ return 0;
+};
+
+void
bgpq3_print_jrfilter(struct sx_radix_node* n, void* ff)
{
char prefix[128];
@@ -658,7 +729,33 @@ bgpq3_print_juniper_routefilter(FILE* f, struct bgpq_e
return 0;
};
+
int
+bgpq3_print_openbgpd_prefixlist(FILE* f, struct bgpq_expander* b)
+{
+ if (!sx_radix_tree_empty(b->tree)) {
+ if(b->name){
+ if(strcmp(b->name, "NN") != 0) {
+ fprintf(f, "%s=\"", b->name);
+ }
+ }
+ fprintf(f,"prefix { \\");
+ sx_radix_tree_foreach(b->tree,bgpq3_print_openbgpd_prefix,f);
+ fprintf(f, "\n\t}");
+ if(b->name){
+ if(strcmp(b->name, "NN") != 0) {
+ fprintf(f, "\"");
+ }
+ }
+ fprintf(f, "\n");
+ } else {
+ fprintf(f, "# generated prefix-list %s (AS %u) is empty\n", bname, b->asnumber);
+ fprintf(f, "deny from AS %u\n", b->asnumber);
+ };
+ return 0;
+};
+
+int
bgpq3_print_cisco_prefixlist(FILE* f, struct bgpq_expander* b)
{
bname=b->name ? b->name : "NN";
@@ -767,6 +864,7 @@ bgpq3_print_prefixlist(FILE* f, struct bgpq_expander*
case V_CISCO_XR: return bgpq3_print_ciscoxr_prefixlist(f,b);
case V_JSON: return bgpq3_print_json_prefixlist(f,b);
case V_BIRD: return bgpq3_print_bird_prefixlist(f,b);
+ case V_OPENBGPD: return bgpq3_print_openbgpd_prefixlist(f,b);
case V_FORMAT: return bgpq3_print_format_prefixlist(f,b);
};
return 0;
@@ -781,6 +879,7 @@ bgpq3_print_eacl(FILE* f, struct bgpq_expander* b)
case V_CISCO_XR: sx_report(SX_FATAL, "unreachable point\n");
case V_JSON: sx_report(SX_FATAL, "unreachable point\n");
case V_BIRD: sx_report(SX_FATAL, "unreachable point\n");
+ case V_OPENBGPD: return bgpq3_print_openbgpd_prefixlist(f,b);
case V_FORMAT: sx_report(SX_FATAL, "unreachable point\n");
};
return 0;