bgpd: retain peer asn even with remove-private-AS
In situations where remove-private-AS is configured for eBGP peers
residing in a private ASN, the peer's ASN was not being retained
in the AS-Path which can allow loops to occur. This was addressed
in a prior commit but it only addressed cases where the "replace-AS"
keyword was configured.
This commit ensures we retain the peer's ASN when using
"remove-private-AS" for eBGP peers in a private ASN regardless of other
keywords.
Setup:
=========
router bgp
4200000002
neighbor enp1s0 interface v6only remote-as external
neighbor enp6s0 interface v6only remote-as external
!
address-family ipv4 unicast
neighbor enp6s0 remove-private-AS
exit-address-family
ub18# show ip bgp sum | include 420000
BGP router identifier 100.64.0.111, local AS number
4200000002 vrf-id 0 <<<<< local asn
4200000002
ub20(enp1s0) 4
4200000001 22 22 0 0 0 00:00:57 1 1
ub20(enp6s0) 4
4200000001 21 22 0 0 0 00:00:57 0 1 <<<< peer asn
4200000001
ub18# show ip bgp | include 0.2
Default local pref 100, local AS
4200000002
*> 100.64.0.2/32 enp1s0 0 0
4200000001 4200000004 4200000005 4200000001 i
Before ("remote-private-AS" only):
=========
ub18# show ip bgp neighbors enp6s0 advertised-routes | include 100.64.0.2
*> 100.64.0.2/32 :: 0 i <<<<< empty as-path, no way to prevent loop
After ("remote-private-AS" only):
=========
ub18# show ip bgp neighbors enp6s0 advertised-routes | include 100.64.0.2
*> 100.64.0.2/32 :: 0
4200000001 4200000001 i <<<< retain peer's asn, breaks loop
Ticket:
2857047
Signed-off-by: Trey Aspelund <taspelund@nvidia.com>