mirror of
https://github.com/bgp/bgpq4
synced 2025-02-28 08:53:11 +00:00
OpenBGPD: -E now generates prefix-sets instead of prefix-lists.
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -1,10 +1,12 @@
|
|||||||
untagged yet (2018-08-10)
|
untagged yet (2018-09-05)
|
||||||
- initial support for Juniper route-filter-lists (JunOS 16.2+).
|
- initial support for Juniper route-filter-lists (JunOS 16.2+).
|
||||||
- too large (>124bytes) sources list was not handled correctly.
|
- too large (>124bytes) sources list was not handled correctly.
|
||||||
Reported by Pier Carlo Chiodi.
|
Reported by Pier Carlo Chiodi.
|
||||||
- initial support for Huawei format (prefix-lists and as-path filters)
|
- initial support for Huawei format (prefix-lists and as-path filters)
|
||||||
New flag -U. Requested by Alexander Wagberg.
|
New flag -U. Requested by Alexander Wagberg.
|
||||||
- fix ipv6 prefix-ranges. Reported by Jay Ford.
|
- fix ipv6 prefix-ranges. Reported by Jay Ford.
|
||||||
|
- OpenBGPd change: -E now generates prefix-set instead of prefix-list.
|
||||||
|
Based on submission by Denis Fondras
|
||||||
|
|
||||||
0.1.35-rc2 (2017-06-14)
|
0.1.35-rc2 (2017-06-14)
|
||||||
- OpenBSD need <sys/select.h>. Reported by Denis Fondras.
|
- OpenBSD need <sys/select.h>. Reported by Denis Fondras.
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ Use asdot notation for Cisco as-path access-lists.
|
|||||||
#### -E
|
#### -E
|
||||||
|
|
||||||
Generate extended access-list (Cisco) or policy-statement term using
|
Generate extended access-list (Cisco) or policy-statement term using
|
||||||
route-filters (Juniper) or [ip|ipv6]-prefix-list (Nokia)
|
route-filters (Juniper), [ip|ipv6]-prefix-list (Nokia) or prefix-filter
|
||||||
|
(OpenBGPD)
|
||||||
|
|
||||||
#### -f `AS number`
|
#### -f `AS number`
|
||||||
|
|
||||||
|
|||||||
3
bgpq3.8
3
bgpq3.8
@@ -78,7 +78,8 @@ enable some debugging output.
|
|||||||
use asdot notation for Cisco as-path access-lists.
|
use asdot notation for Cisco as-path access-lists.
|
||||||
.It Fl E
|
.It Fl E
|
||||||
generate extended access-list (Cisco), policy-statement term using
|
generate extended access-list (Cisco), policy-statement term using
|
||||||
route-filters (Juniper) or [ip|ipv6]-prefix-list (Nokia).
|
route-filters (Juniper), [ip|ipv6]-prefix-list (Nokia) or prefix-sets
|
||||||
|
(OpenBGPd).
|
||||||
.It Fl f Ar number
|
.It Fl f Ar number
|
||||||
generate input as-path access-list.
|
generate input as-path access-list.
|
||||||
.It Fl F Ar fmt
|
.It Fl F Ar fmt
|
||||||
|
|||||||
5
bgpq3.c
5
bgpq3.c
@@ -40,8 +40,9 @@ usage(int ecode)
|
|||||||
printf(" -D : use asdot notation in as-path (Cisco only)\n");
|
printf(" -D : use asdot notation in as-path (Cisco only)\n");
|
||||||
printf(" -d : generate some debugging output\n");
|
printf(" -d : generate some debugging output\n");
|
||||||
printf(" -E : generate extended access-list(Cisco), "
|
printf(" -E : generate extended access-list(Cisco), "
|
||||||
"route-filter(Juniper) or\n"
|
"route-filter(Juniper)\n"
|
||||||
" [ip|ipv6]-prefix-list (Nokia)\n");
|
" [ip|ipv6]-prefix-list (Nokia) or prefix-set (OpenBGPD)"
|
||||||
|
"\n");
|
||||||
printf(" -F fmt : generate output in user-defined format\n");
|
printf(" -F fmt : generate output in user-defined format\n");
|
||||||
printf(" -f number : generate input as-path access-list\n");
|
printf(" -f number : generate input as-path access-list\n");
|
||||||
printf(" -G number : generate output as-path access-list\n");
|
printf(" -G number : generate output as-path access-list\n");
|
||||||
|
|||||||
@@ -558,6 +558,7 @@ bgpq3_print_jprefix(struct sx_radix_node* n, void* ff)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int needscomma=0;
|
static int needscomma=0;
|
||||||
|
static int prefixset=0;
|
||||||
|
|
||||||
void
|
void
|
||||||
bgpq3_print_json_prefix(struct sx_radix_node* n, void* ff)
|
bgpq3_print_json_prefix(struct sx_radix_node* n, void* ff)
|
||||||
@@ -684,6 +685,7 @@ void
|
|||||||
bgpq3_print_openbgpd_prefix(struct sx_radix_node* n, void* ff)
|
bgpq3_print_openbgpd_prefix(struct sx_radix_node* n, void* ff)
|
||||||
{
|
{
|
||||||
char prefix[128];
|
char prefix[128];
|
||||||
|
int pc = needscomma & prefixset;
|
||||||
FILE* f=(FILE*)ff;
|
FILE* f=(FILE*)ff;
|
||||||
if(n->isGlue)
|
if(n->isGlue)
|
||||||
goto checkSon;
|
goto checkSon;
|
||||||
@@ -691,16 +693,16 @@ bgpq3_print_openbgpd_prefix(struct sx_radix_node* n, void* ff)
|
|||||||
f=stdout;
|
f=stdout;
|
||||||
sx_prefix_snprintf(&n->prefix, prefix, sizeof(prefix));
|
sx_prefix_snprintf(&n->prefix, prefix, sizeof(prefix));
|
||||||
if (!n->isAggregate) {
|
if (!n->isAggregate) {
|
||||||
fprintf(f, "\n\t%s \\", prefix);
|
fprintf(f, "%s\n\t%s", pc ? "," : " \\", prefix);
|
||||||
} else if (n->aggregateLow == n->aggregateHi) {
|
} else if (n->aggregateLow == n->aggregateHi) {
|
||||||
fprintf(f, "\n\t%s prefixlen = %u \\",
|
fprintf(f, "%s\n\t%s prefixlen = %u",
|
||||||
prefix, n->aggregateHi);
|
pc ? "," : " \\", prefix, n->aggregateHi);
|
||||||
} else if (n->aggregateLow > n->prefix.masklen) {
|
} else if (n->aggregateLow > n->prefix.masklen) {
|
||||||
fprintf(f, "\n\t%s prefixlen %u - %u \\",
|
fprintf(f, "%s\n\t%s prefixlen %u - %u",
|
||||||
prefix, n->aggregateLow, n->aggregateHi);
|
pc ? "," : " \\", prefix, n->aggregateLow, n->aggregateHi);
|
||||||
} else {
|
} else {
|
||||||
fprintf(f, "\n\t%s prefixlen %u - %u \\",
|
fprintf(f, "%s\n\t%s prefixlen %u - %u",
|
||||||
prefix, n->prefix.masklen, n->aggregateHi);
|
pc ? "," : " \\", prefix, n->prefix.masklen, n->aggregateHi);
|
||||||
};
|
};
|
||||||
needscomma=1;
|
needscomma=1;
|
||||||
checkSon:
|
checkSon:
|
||||||
@@ -994,7 +996,6 @@ bgpq3_print_juniper_routefilter(FILE* f, struct bgpq_expander* b)
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
bgpq3_print_openbgpd_prefixlist(FILE* f, struct bgpq_expander* b)
|
bgpq3_print_openbgpd_prefixlist(FILE* f, struct bgpq_expander* b)
|
||||||
{
|
{
|
||||||
@@ -1012,9 +1013,9 @@ bgpq3_print_openbgpd_prefixlist(FILE* f, struct bgpq_expander* b)
|
|||||||
fprintf(f, "%s=\"", b->name);
|
fprintf(f, "%s=\"", b->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(f,"prefix { \\");
|
fprintf(f,"prefix {");
|
||||||
sx_radix_tree_foreach(b->tree,bgpq3_print_openbgpd_prefix,f);
|
sx_radix_tree_foreach(b->tree,bgpq3_print_openbgpd_prefix,f);
|
||||||
fprintf(f, "\n\t}");
|
fprintf(f, " \\\n\t}");
|
||||||
if(b->name){
|
if(b->name){
|
||||||
if(strcmp(b->name, "NN") != 0) {
|
if(strcmp(b->name, "NN") != 0) {
|
||||||
fprintf(f, "\"");
|
fprintf(f, "\"");
|
||||||
@@ -1027,6 +1028,29 @@ bgpq3_print_openbgpd_prefixlist(FILE* f, struct bgpq_expander* b)
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
bgpq3_print_openbgpd_prefixset(FILE* f, struct bgpq_expander* b)
|
||||||
|
{
|
||||||
|
bname=b->name ? b->name : "NN";
|
||||||
|
if (sx_radix_tree_empty(b->tree)) {
|
||||||
|
fprintf(f, "# generated prefix-set %s (AS %u) is empty\n", bname,
|
||||||
|
b->asnumber);
|
||||||
|
if (!b->asnumber)
|
||||||
|
fprintf(f, "# use -a <asn> to generate \"deny from ASN <asn>\" "
|
||||||
|
"instead of this list\n");
|
||||||
|
};
|
||||||
|
if (!sx_radix_tree_empty(b->tree) || !b->asnumber) {
|
||||||
|
fprintf(f,"prefix-set %s { ", b->name);
|
||||||
|
prefixset=1;
|
||||||
|
sx_radix_tree_foreach(b->tree,bgpq3_print_openbgpd_prefix,f);
|
||||||
|
fprintf(f, "\n\t}\n");
|
||||||
|
} else {
|
||||||
|
fprintf(f, "deny from AS %u\n", b->asnumber);
|
||||||
|
};
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
bgpq3_print_cisco_prefixlist(FILE* f, struct bgpq_expander* b)
|
bgpq3_print_cisco_prefixlist(FILE* f, struct bgpq_expander* b)
|
||||||
{
|
{
|
||||||
@@ -1199,7 +1223,7 @@ bgpq3_print_eacl(FILE* f, struct bgpq_expander* b)
|
|||||||
case V_CISCO_XR: sx_report(SX_FATAL, "unreachable point\n");
|
case V_CISCO_XR: sx_report(SX_FATAL, "unreachable point\n");
|
||||||
case V_JSON: 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_BIRD: sx_report(SX_FATAL, "unreachable point\n");
|
||||||
case V_OPENBGPD: return bgpq3_print_openbgpd_prefixlist(f,b);
|
case V_OPENBGPD: return bgpq3_print_openbgpd_prefixset(f,b);
|
||||||
case V_FORMAT: sx_report(SX_FATAL, "unreachable point\n");
|
case V_FORMAT: sx_report(SX_FATAL, "unreachable point\n");
|
||||||
case V_NOKIA: return bgpq3_print_nokia_ipprefixlist(f,b);
|
case V_NOKIA: return bgpq3_print_nokia_ipprefixlist(f,b);
|
||||||
case V_HUAWEI: return sx_report(SX_FATAL, "unreachable point\n");
|
case V_HUAWEI: return sx_report(SX_FATAL, "unreachable point\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user