Skip to content

Commit

Permalink
bgpd: rename reflect in subgroup_announce_check
Browse files Browse the repository at this point in the history
In subgroup_announce_check(), the variable reflect is misleading, as it
suggests a relation to route reflection. However, it actually refers to
the scenario where an iBGP peer announces a route to another iBGP peer.

Rename reflect to ibgp_to_ibgp.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Oct 14, 2024
1 parent d1433ee commit 4ae65cc
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
struct attr *piattr;
route_map_result_t ret;
int transparent;
int reflect;
int ibgp_to_ibgp;
afi_t afi;
safi_t safi;
int samepeer_safe = 0; /* for synthetic mplsvpns routes */
Expand Down Expand Up @@ -2357,14 +2357,14 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
}
}

/* Route-Reflect check. */
/* iBGP to iBGP check. */
if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
reflect = 1;
ibgp_to_ibgp = 1;
else
reflect = 0;
ibgp_to_ibgp = 0;

/* IBGP reflection check. */
if (reflect && !samepeer_safe) {
if (ibgp_to_ibgp && !samepeer_safe) {
/* A route from a Client peer. */
if (CHECK_FLAG(from->af_flags[afi][safi],
PEER_FLAG_REFLECTOR_CLIENT)) {
Expand Down Expand Up @@ -2410,8 +2410,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,

/* If originator-id is not set and the route is to be reflected,
set the originator id */
if (reflect
&& (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
if (ibgp_to_ibgp && (!(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))) {
IPV4_ADDR_COPY(&(attr->originator_id), &(from->remote_id));
SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
}
Expand Down Expand Up @@ -2444,7 +2443,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* announced to an EBGP peer (and they have the same attributes barring
* their nexthop).
*/
if (reflect)
if (ibgp_to_ibgp)
SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED);

#define NEXTHOP_IS_V6 \
Expand Down Expand Up @@ -2472,7 +2471,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
*/
if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local))
global_and_ll = true;
} else if (!reflect && !transparent &&
} else if (!ibgp_to_ibgp && !transparent &&
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_local) && peer->shared_network &&
(from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))
global_and_ll = true;
Expand Down Expand Up @@ -2694,9 +2693,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
PEER_FLAG_NEXTHOP_SELF)
|| CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
if (!reflect
|| CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
if (!ibgp_to_ibgp ||
CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) {
subgroup_announce_reset_nhop(
(peer_cap_enhe(peer, afi, safi)
? AF_INET6
Expand Down

0 comments on commit 4ae65cc

Please sign in to comment.