]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_nht.c
Merge pull request #5703 from ton31337/feature/limit_outgoing_prefixes
[mirror_frr.git] / bgpd / bgp_nht.c
index 915963fad81b9aa7c2f1def67fb2ec9d6e70594d..a50fc7d69726c61ecd9d31c5ba27c448238bc31a 100644 (file)
@@ -43,6 +43,7 @@
 #include "bgpd/bgp_fsm.h"
 #include "bgpd/bgp_zebra.h"
 #include "bgpd/bgp_flowspec_util.h"
+#include "bgpd/bgp_evpn.h"
 
 extern struct zclient *zclient;
 
@@ -65,27 +66,6 @@ static int bgp_isvalid_labeled_nexthop(struct bgp_nexthop_cache *bnc)
                || (bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_LABELED_VALID)));
 }
 
-int bgp_find_nexthop(struct bgp_path_info *path, int connected)
-{
-       struct bgp_nexthop_cache *bnc = path->nexthop;
-
-       if (!bnc)
-               return 0;
-
-       /*
-        * We are cheating here.  Views have no associated underlying
-        * ability to detect nexthops.  So when we have a view
-        * just tell everyone the nexthop is valid
-        */
-       if (path->peer && path->peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
-               return 1;
-
-       if (connected && !(CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)))
-               return 0;
-
-       return (bgp_isvalid_nexthop(bnc));
-}
-
 static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc)
 {
        if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info) {
@@ -441,7 +421,8 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
                        if (peer && !peer->ifp
                            && CHECK_FLAG(peer->flags,
                                          PEER_FLAG_CAPABILITY_ENHE)
-                           && nhr.prefix.family == AF_INET6) {
+                           && nhr.prefix.family == AF_INET6
+                           && nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
                                struct interface *ifp;
 
                                ifp = if_lookup_by_index(nexthop->ifindex,
@@ -794,6 +775,16 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
                    || CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED))
                        SET_FLAG(path->flags, BGP_PATH_IGP_CHANGED);
 
+               if (safi == SAFI_EVPN &&
+                   bgp_evpn_is_prefix_nht_supported(&rn->p)) {
+                       if (CHECK_FLAG(path->flags, BGP_PATH_VALID))
+                               bgp_evpn_import_route(bgp_path, afi, safi,
+                                                     &rn->p, path);
+                       else
+                               bgp_evpn_unimport_route(bgp_path, afi, safi,
+                                                       &rn->p, path);
+               }
+
                bgp_process(bgp_path, rn, afi, safi);
        }