Skip to content

Commit

Permalink
implement -f 0 (transparent route-server) for Nokia
Browse files Browse the repository at this point in the history
  • Loading branch information
snar committed Jun 11, 2021
1 parent 66dda80 commit 5953397
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- correct spacing for IOS-XR. Reported by Mathias Wolkert.
- hyperaggregation (supernets-only) mode.
- correct Huawei as-path-filter generation. Thanks to JKejsjwq.
- implement -f 0 (transparent route-server scenario) for Nokia too.

0.1.35 (2018-11-30):
- initial support for Juniper route-filter-lists (JunOS 16.2+).
Expand Down
4 changes: 0 additions & 4 deletions bgpq3.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,6 @@ main(int argc, char* argv[])
(expander.vendor==V_OPENBGPD)) {
sx_report(SX_FATAL, "Sorry, -f 0 makes no sense with OpenBGPD\n");
};
if(expander.generation==T_ASPATH && expander.asnumber==0 &&
(expander.vendor==V_NOKIA || expander.vendor==V_NOKIA_MD)) {
sx_report(SX_FATAL, "Sorry, -f 0 is not yet implemented for Nokia\n");
};

if(!argv[0])
usage(1);
Expand Down
18 changes: 12 additions & 6 deletions bgpq3_printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ bgpq3_print_nokia_aspath(FILE* f, struct bgpq_expander* b)
b->name ? b->name : "NN");
fprintf(f,"as-path-group \"%s\"\n", b->name ? b->name : "NN");

if(b->asn32s[b->asnumber/65536] &&
if(b->asnumber>0 && b->asn32s[b->asnumber/65536] &&
b->asn32s[b->asnumber/65535][(b->asnumber%65536)/8]&
(0x80>>(b->asnumber%8))) {
fprintf(f," entry %u expression \"%u+\"\n", lineNo, b->asnumber);
Expand All @@ -365,10 +365,13 @@ bgpq3_print_nokia_aspath(FILE* f, struct bgpq_expander* b)
for(i=0;i<8192;i++) {
for(j=0;j<8;j++) {
if(b->asn32s[k][i]&(0x80>>j)) {
if(k*65536+i*8+j==b->asnumber) continue;
if(!nc) {
if(b->asnumber>0 && k*65536+i*8+j==b->asnumber) continue;
if(!nc && b->asnumber!=0) {
fprintf(f," entry %u expression \"%u.*[%u",
lineNo,b->asnumber,k*65536+i*8+j);
} else if(!nc) {
fprintf(f," entry %u expression \".*[%u",
lineNo,k*65536+i*8+j);
} else {
fprintf(f," %u",k*65536+i*8+j);
};
Expand Down Expand Up @@ -396,7 +399,7 @@ bgpq3_print_nokia_md_aspath(FILE* f, struct bgpq_expander* b)
b->name ? b->name : "NN");
fprintf(f,"as-path-group \"%s\" {\n", b->name ? b->name : "NN");

if(b->asn32s[b->asnumber/65536] &&
if(b->asnumber!=0 && b->asn32s[b->asnumber/65536] &&
b->asn32s[b->asnumber/65535][(b->asnumber%65536)/8]&
(0x80>>(b->asnumber%8))) {
fprintf(f," entry %u {\n expression \"%u+\"\n }\n", lineNo,
Expand All @@ -408,10 +411,13 @@ bgpq3_print_nokia_md_aspath(FILE* f, struct bgpq_expander* b)
for(i=0;i<8192;i++) {
for(j=0;j<8;j++) {
if(b->asn32s[k][i]&(0x80>>j)) {
if(k*65536+i*8+j==b->asnumber) continue;
if(!nc) {
if(b->asnumber!=0 && k*65536+i*8+j==b->asnumber) continue;
if(!nc && b->asnumber!=0) {
fprintf(f," entry %u {\n expression \"%u.*[%u",
lineNo,b->asnumber,k*65536+i*8+j);
} else if(!nc) {
fprintf(f," entry %u {\n expression \".*[%u",
lineNo,k*65536+i*8+j);
} else {
fprintf(f," %u",k*65536+i*8+j);
};
Expand Down

0 comments on commit 5953397

Please sign in to comment.