diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-20 03:03:14 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-20 03:03:14 +0200 |
commit | c7122e14246e4a2699b9e0b30cf05e111ac2e5d7 (patch) | |
tree | cc506f7d12b3e9b3b6683002de4cc3b6613c6c9b /bgpd/bgp_aspath.c | |
parent | per-interface ospf enable and area set command. (diff) | |
download | frr-c7122e14246e4a2699b9e0b30cf05e111ac2e5d7.tar.xz frr-c7122e14246e4a2699b9e0b30cf05e111ac2e5d7.zip |
Implement BGP as-override feature
Diffstat (limited to 'bgpd/bgp_aspath.c')
-rw-r--r-- | bgpd/bgp_aspath.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index b8bd71b99..450f5f527 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -1146,6 +1146,58 @@ aspath_private_as_check (struct aspath *aspath) return 1; } +/* Return True if the entire ASPATH consist of the specified ASN */ +int +aspath_single_asn_check (struct aspath *aspath, as_t asn) +{ + struct assegment *seg; + + if ( !(aspath && aspath->segments) ) + return 0; + + seg = aspath->segments; + + while (seg) + { + int i; + + for (i = 0; i < seg->length; i++) + { + if (seg->as[i] != asn) + return 0; + } + seg = seg->next; + } + return 1; +} + +/* Replace all instances of the target ASN with our own ASN */ +struct aspath * +aspath_replace_specific_asn (struct aspath *aspath, as_t target_asn, + as_t our_asn) +{ + struct aspath *new; + struct assegment *seg; + + new = aspath_dup(aspath); + seg = new->segments; + + while (seg) + { + int i; + + for (i = 0; i < seg->length; i++) + { + if (seg->as[i] == target_asn) + seg->as[i] = our_asn; + } + seg = seg->next; + } + + aspath_str_update(new); + return new; +} + /* Replace all private ASNs with our own ASN */ struct aspath * aspath_replace_private_asns (struct aspath *aspath, as_t asn) |