]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_nht.c
Merge pull request #9374 from mjstapp/fix_nhg_add_leak
[mirror_frr.git] / bgpd / bgp_nht.c
index eb00a4641c8393d6d43a2e3a288cfe94d2743dda..c77e240855a8f4ce0f43e949d2f09963d999a847 100644 (file)
@@ -160,7 +160,8 @@ void bgp_unlink_nexthop_by_peer(struct peer *peer)
  */
 int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
                            afi_t afi, safi_t safi, struct bgp_path_info *pi,
-                           struct peer *peer, int connected)
+                           struct peer *peer, int connected,
+                           const struct prefix *orig_prefix)
 {
        struct bgp_nexthop_cache_head *tree = NULL;
        struct bgp_nexthop_cache *bnc;
@@ -192,6 +193,16 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
                if (make_prefix(afi, pi, &p) < 0)
                        return 1;
 
+               if (!is_bgp_static_route && orig_prefix
+                   && prefix_same(&p, orig_prefix)) {
+                       if (BGP_DEBUG(nht, NHT)) {
+                               zlog_debug(
+                                       "%s(%pFX): prefix loops through itself",
+                                       __func__, &p);
+                       }
+                       return 0;
+               }
+
                srte_color = pi->attr->srte_color;
        } else if (peer) {
                /*