]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: authorise to select bgp self peer prefix on rr case 12330/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 7 Nov 2022 10:56:37 +0000 (11:56 +0100)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Thu, 17 Nov 2022 02:58:49 +0000 (02:58 +0000)
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)

bgpd/bgp_route.c

index 9ec70ab3de5ed8dc0d111ee221903779a3ccd35d..7104ee3d1df9c3fd388497da1b65a8444891a606 100644 (file)
@@ -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)) {