mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 00:41:20 +00:00
bgpd: In bgp_update try to optimize is_loop_check variable
The variable is_loop_check is being set and then later we test against it multiple times. Move the setting of whether or not to check for as loops to where it is tested against and stop testing it multiple times. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
d9fd4901f0
commit
fb78a9b66b
@ -4639,7 +4639,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
||||
const char *reason;
|
||||
char pfx_buf[BGP_PRD_PATH_STRLEN];
|
||||
int connected = 0;
|
||||
int do_loop_check = 1;
|
||||
afi_t nh_afi;
|
||||
bool force_evpn_import = false;
|
||||
safi_t orig_safi = safi;
|
||||
@ -4720,14 +4719,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
||||
}
|
||||
}
|
||||
|
||||
/* If the peer is configured for "allowas-in origin" and the last ASN in
|
||||
* the
|
||||
* as-path is our ASN then we do not need to call aspath_loop_check
|
||||
*/
|
||||
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN_ORIGIN))
|
||||
if (aspath_get_last_as(attr->aspath) == bgp->as)
|
||||
do_loop_check = 0;
|
||||
|
||||
/* When using bgp ipv4 labeled session, the local prefix is
|
||||
* received by a peer, and finds out that the proposed prefix
|
||||
* and its next-hop are the same. To avoid a route loop locally,
|
||||
@ -4748,24 +4739,30 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
|
||||
else
|
||||
bgp_nht_param_prefix = p;
|
||||
|
||||
/* AS path loop check. */
|
||||
if (do_loop_check) {
|
||||
/*
|
||||
* If the peer is configured for "allowas-in origin" and the last ASN in
|
||||
* the as-path is our ASN then we do not need to call aspath_loop_check
|
||||
*/
|
||||
if (!CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN_ORIGIN) ||
|
||||
(aspath_get_last_as(attr->aspath) != bgp->as)) {
|
||||
/* AS path loop check. */
|
||||
if (aspath_loop_check(attr->aspath, bgp->as) >
|
||||
peer->allowas_in[afi][safi]) {
|
||||
peer->stat_pfx_aspath_loop++;
|
||||
reason = "as-path contains our own AS;";
|
||||
goto filtered;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we're a CONFED we need to loop check the CONFED ID too */
|
||||
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) && do_loop_check)
|
||||
if (aspath_loop_check_confed(attr->aspath, bgp->confed_id) >
|
||||
peer->allowas_in[afi][safi]) {
|
||||
peer->stat_pfx_aspath_loop++;
|
||||
reason = "as-path contains our own confed AS;";
|
||||
goto filtered;
|
||||
/* If we're a CONFED we need to loop check the CONFED ID too */
|
||||
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) {
|
||||
if (aspath_loop_check_confed(attr->aspath, bgp->confed_id) >
|
||||
peer->allowas_in[afi][safi]) {
|
||||
peer->stat_pfx_aspath_loop++;
|
||||
reason = "as-path contains our own confed AS;";
|
||||
goto filtered;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Route reflector originator ID check. If ACCEPT_OWN mechanism is
|
||||
* enabled, then take care of that too.
|
||||
|
Loading…
Reference in New Issue
Block a user