From 449e80ab743fa51ee60f8f7c535fa952f965fc5b Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 7 Nov 2022 14:44:49 +0100 Subject: [PATCH] bgpd: to select bgp self peer prefix on rr case with bgp-lu This commit addresses an issue that happens when using bgp labeled unicast peering with a rr client, with a received prefix which is the local ip address of the bgp session. 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, no nexthop entry is referenced for that prefix, and the route will not be selected. As it has been done for ipv4-unicast, apply the following fix for labeled address families: when the received peer is a route reflector, the prefix has to be selected, even if the route can not be installed locally. Fixes: f874552557cf ("bgpd: authorise to select bgp self peer prefix on rr case") Signed-off-by: Philippe Guibert Signed-off-by: Dmytro Shytyi --- bgpd/bgp_route.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 94c21e1861..e1cc62ef00 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4638,7 +4638,22 @@ void 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)) + /* 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, + * no nexthop entry is referenced for that prefix, and the route + * will not be selected. + * + * As it has been done for ipv4-unicast, apply the following fix + * for labeled address families: when the received peer is + * a route reflector, the prefix has to be selected, even if the + * route can not be installed locally. + */ + if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT) || + (safi == SAFI_UNICAST && !peer->afc[afi][safi] && + peer->afc[afi][SAFI_LABELED_UNICAST] && + CHECK_FLAG(peer->af_flags[afi][SAFI_LABELED_UNICAST], + PEER_FLAG_REFLECTOR_CLIENT))) bgp_nht_param_prefix = NULL; else bgp_nht_param_prefix = p;