diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-04-05 08:14:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-05 08:14:27 -0400 |
| commit | fe09938b2b38e091bef84ca8798f55d5544105f6 (patch) | |
| tree | 0947cdd868db7f2b2b3099901b73ce7ac66ee592 | |
| parent | 84361736342360c34ea138c7b051fc49b8a6be5f (diff) | |
| parent | 41f0fb76bd885878deff452884bacab039ee8afc (diff) | |
Merge pull request #4090 from ton31337/stable/6.0
bgpd: [6.0] Remove private AS numbers if local-as is defined
| -rw-r--r-- | bgpd/bgp_attr.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 640c3bdb7a..a8eab9cfec 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -3001,6 +3001,22 @@ void bgp_packet_mpattr_end(struct stream *s, size_t sizep) stream_putw_at(s, sizep, (stream_get_endp(s) - sizep) - 2); } +static int bgp_append_local_as(struct peer *peer, afi_t afi, safi_t safi) +{ + if (!BGP_AS_IS_PRIVATE(peer->local_as) + || (BGP_AS_IS_PRIVATE(peer->local_as) + && !CHECK_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_REMOVE_PRIVATE_AS) + && !CHECK_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_REMOVE_PRIVATE_AS_ALL) + && !CHECK_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE) + && !CHECK_FLAG(peer->af_flags[afi][safi], + PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))) + return 1; + return 0; +} + /* Make attribute packet. */ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, struct stream *s, struct attr *attr, @@ -3066,12 +3082,12 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, /* If replace-as is specified, we only use the change_local_as when advertising routes. */ - if (!CHECK_FLAG( - peer->flags, - PEER_FLAG_LOCAL_AS_REPLACE_AS)) { - aspath = aspath_add_seq(aspath, - peer->local_as); - } + if (!CHECK_FLAG(peer->flags, + PEER_FLAG_LOCAL_AS_REPLACE_AS)) + if (bgp_append_local_as(peer, afi, + safi)) + aspath = aspath_add_seq( + aspath, peer->local_as); aspath = aspath_add_seq(aspath, peer->change_local_as); } else { |
