From: Donatas Abraitis Date: Sun, 8 Dec 2024 19:46:59 +0000 (+0200) Subject: bgpd: Import allowed routes with self AS if desired X-Git-Tag: docker/10.2.1~8^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=485f62ebe3c6bbb18cef337ebd28c6fd810c23d3;p=matthieu%2Ffrr.git bgpd: Import allowed routes with self AS if desired Previously we couldn't install VPN routes with self AS in the path because we never checked if we have allowas-in enabled, or not. Signed-off-by: Donatas Abraitis (cherry picked from commit 222ba5f39048953f384ab3aa207af753dfa92e67) --- diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index df45cf237e..5eca5e3e9b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -2158,6 +2158,8 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */ struct interface *ifp = NULL; char rd_buf[RD_ADDRSTRLEN]; struct aspath *new_aspath; + int32_t aspath_loop_count = 0; + struct peer *peer = path_vpn->peer; int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); @@ -2218,7 +2220,9 @@ static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */ bn = bgp_afi_node_get(to_bgp->rib[afi][safi], afi, safi, p, NULL); /* Check if leaked route has our asn. If so, don't import it. */ - if (aspath_loop_check(path_vpn->attr->aspath, to_bgp->as)) { + if (CHECK_FLAG(peer->af_flags[afi][SAFI_MPLS_VPN], PEER_FLAG_ALLOWAS_IN)) + aspath_loop_count = peer->allowas_in[afi][SAFI_MPLS_VPN]; + if (aspath_loop_check(path_vpn->attr->aspath, to_bgp->as) > aspath_loop_count) { for (bpi = bgp_dest_get_bgp_path_info(bn); bpi; bpi = bpi->next) { if (bpi->extra && bpi->extra->vrfleak &&