summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2022-11-07 11:56:37 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2022-11-17 02:58:49 +0000
commit56dd706e9b3a5eb790fa695e8f6f71e73b843aab (patch)
tree26894b26ee099eac0275d52f8c4c374754c52315
parent23f40f230d1fe293eb519aafb0825444ea44f0e0 (diff)
bgpd: authorise to select bgp self peer prefix on rr case
This commit addresses an issue that happens when using bgp peering with a rr client, with a received prefix which is the local ip address of the bgp session. When using bgp ipv4 unicast 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, no nexthop entry is referenced for that prefix, and the route will not be selected. When the received peer is a route reflector, the prefix has to be selected, even if the route can not be installed locally. Fixes: ("fb8ae704615c") bgpd: prevent routes loop through itself Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> (cherry picked from commit f874552557cf2577ae91b297f422e307084f22d3)
-rw-r--r--bgpd/bgp_route.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9ec70ab3de..7104ee3d1d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3874,6 +3874,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
int vnc_implicit_withdraw = 0;
#endif
int same_attr = 0;
+ const struct prefix *bgp_nht_param_prefix;
/* Special case for BGP-LU - map LU safi to ordinary unicast safi */
if (orig_safi == SAFI_LABELED_UNICAST)
@@ -3937,6 +3938,11 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (aspath_get_last_as(attr->aspath) == bgp->as)
do_loop_check = 0;
+ if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
+ bgp_nht_param_prefix = NULL;
+ else
+ bgp_nht_param_prefix = p;
+
/* AS path loop check. */
if (do_loop_check) {
if (aspath_loop_check(attr->aspath, bgp->as)
@@ -4445,8 +4451,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, nh_afi,
safi, pi, NULL, connected,
- p)
- || CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
+ bgp_nht_param_prefix) ||
+ CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
bgp_path_info_set_flag(dest, pi,
BGP_PATH_VALID);
else {
@@ -4604,8 +4610,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
nh_afi = BGP_ATTR_NH_AFI(afi, new->attr);
if (bgp_find_or_add_nexthop(bgp, bgp, nh_afi, safi, new, NULL,
- connected, p)
- || CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
+ connected, bgp_nht_param_prefix) ||
+ CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
bgp_path_info_set_flag(dest, new, BGP_PATH_VALID);
else {
if (BGP_DEBUG(nht, NHT)) {