bgpd: revert no retain backend

Partially revert a486300b26 ("bgpd: implement retain route-target all
behaviour") in order to fix a memory consumption issue in the next
commit.

Fixes: a486300b26 ("bgpd: implement retain route-target all behaviour")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Louis Scalbert 2023-06-06 14:02:42 +02:00
parent 22c329ed32
commit 59bbe85d4b
3 changed files with 11 additions and 30 deletions

View File

@ -2116,7 +2116,7 @@ static struct bgp *bgp_lookup_by_rd(struct bgp_path_info *bpi,
return NULL;
}
static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
static void vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
struct bgp *from_bgp, /* from */
struct bgp_path_info *path_vpn,
struct prefix_rd *prd)
@ -2146,7 +2146,7 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
"%s: from vpn (%s) to vrf (%s), skipping: %s",
__func__, from_bgp->name_pretty,
to_bgp->name_pretty, debugmsg);
return false;
return;
}
/*
@ -2173,7 +2173,7 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
zlog_debug(
"from vpn (%s) to vrf (%s), skipping after no intersection of route targets",
from_bgp->name_pretty, to_bgp->name_pretty);
return false;
return;
}
rd_buf[0] = '\0';
@ -2190,7 +2190,7 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
zlog_debug(
"%s: skipping import, match RD (%s) of src VRF (%s) and the prefix (%pFX)",
__func__, rd_buf, to_bgp->name_pretty, p);
return false;
return;
}
if (debug)
@ -2301,7 +2301,7 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
to_bgp->vpn_policy[afi]
.rmap[BGP_VPN_POLICY_DIR_FROMVPN]
->name);
return false;
return;
}
/*
* if route-map changed nexthop, don't nexthop-self on output
@ -2363,17 +2363,14 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
num_labels, src_vrf, &nexthop_orig, nexthop_self_flag,
debug))
bgp_dest_unlock_node(bn);
return true;
}
bool vpn_leak_to_vrf_update(struct bgp *from_bgp,
void vpn_leak_to_vrf_update(struct bgp *from_bgp,
struct bgp_path_info *path_vpn,
struct prefix_rd *prd)
{
struct listnode *mnode, *mnnode;
struct bgp *bgp;
bool leak_success = false;
int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
@ -2385,11 +2382,10 @@ bool vpn_leak_to_vrf_update(struct bgp *from_bgp,
if (!path_vpn->extra
|| path_vpn->extra->bgp_orig != bgp) { /* no loop */
leak_success |= vpn_leak_to_vrf_update_onevrf(
bgp, from_bgp, path_vpn, prd);
vpn_leak_to_vrf_update_onevrf(bgp, from_bgp, path_vpn,
prd);
}
}
return leak_success;
}
void vpn_leak_to_vrf_withdraw(struct bgp_path_info *path_vpn)

View File

@ -59,7 +59,7 @@ extern void vpn_leak_to_vrf_withdraw_all(struct bgp *to_bgp, afi_t afi);
extern void vpn_leak_to_vrf_update_all(struct bgp *to_bgp, struct bgp *from_bgp,
afi_t afi);
extern bool vpn_leak_to_vrf_update(struct bgp *from_bgp,
extern void vpn_leak_to_vrf_update(struct bgp *from_bgp,
struct bgp_path_info *path_vpn,
struct prefix_rd *prd);

View File

@ -4026,7 +4026,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
afi_t nh_afi;
bool force_evpn_import = false;
safi_t orig_safi = safi;
bool leak_success = true;
int allowas_in = 0;
if (frrtrace_enabled(frr_bgp, process_update)) {
@ -4713,7 +4712,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
}
if ((SAFI_MPLS_VPN == safi)
&& (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) {
leak_success = vpn_leak_to_vrf_update(bgp, pi, prd);
vpn_leak_to_vrf_update(bgp, pi, prd);
}
#ifdef ENABLE_BGP_VNC
@ -4728,13 +4727,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
type, sub_type, NULL);
}
#endif
if ((safi == SAFI_MPLS_VPN) &&
!CHECK_FLAG(bgp->af_flags[afi][safi],
BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL) &&
!leak_success) {
bgp_unlink_nexthop(pi);
bgp_path_info_delete(dest, pi);
}
return;
} // End of implicit withdraw
@ -4876,7 +4868,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
}
if ((SAFI_MPLS_VPN == safi)
&& (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) {
leak_success = vpn_leak_to_vrf_update(bgp, new, prd);
vpn_leak_to_vrf_update(bgp, new, prd);
}
#ifdef ENABLE_BGP_VNC
if (SAFI_MPLS_VPN == safi) {
@ -4890,13 +4882,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
sub_type, NULL);
}
#endif
if ((safi == SAFI_MPLS_VPN) &&
!CHECK_FLAG(bgp->af_flags[afi][safi],
BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL) &&
!leak_success) {
bgp_unlink_nexthop(new);
bgp_path_info_delete(dest, new);
}
return;