]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_zebra.c
Merge pull request #13060 from opensourcerouting/feature/allow_peering_with_127.0.0.1
[mirror_frr.git] / bgpd / bgp_zebra.c
index da598993d145480e4520bf5e4da041af82e01dcc..96b1f3e00f4c1776e9f9028b240869b7643a2838 100644 (file)
@@ -13,7 +13,7 @@
 #include "sockunion.h"
 #include "zclient.h"
 #include "routemap.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "queue.h"
 #include "memory.h"
 #include "lib/json.h"
@@ -834,6 +834,13 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
                                                      peer->bgp->vrf_id);
        }
 
+       /* Handle peerings via loopbacks. For instance, peer between
+        * 127.0.0.1 and 127.0.0.2. In short, allow peering with self
+        * via 127.0.0.0/8.
+        */
+       if (!ifp && cmd_allow_reserved_ranges_get())
+               ifp = if_get_vrf_loopback(peer->bgp->vrf_id);
+
        if (!ifp) {
                /*
                 * BGP views do not currently get proper data
@@ -1046,19 +1053,19 @@ static bool bgp_table_map_apply(struct route_map *map, const struct prefix *p,
        return false;
 }
 
-static struct thread *bgp_tm_thread_connect;
+static struct event *bgp_tm_thread_connect;
 static bool bgp_tm_status_connected;
 static bool bgp_tm_chunk_obtained;
 #define BGP_FLOWSPEC_TABLE_CHUNK 100000
 static uint32_t bgp_tm_min, bgp_tm_max, bgp_tm_chunk_size;
 struct bgp *bgp_tm_bgp;
 
-static void bgp_zebra_tm_connect(struct thread *t)
+static void bgp_zebra_tm_connect(struct event *t)
 {
        struct zclient *zclient;
        int delay = 10, ret = 0;
 
-       zclient = THREAD_ARG(t);
+       zclient = EVENT_ARG(t);
        if (bgp_tm_status_connected && zclient->sock > 0)
                delay = 60;
        else {
@@ -1082,8 +1089,8 @@ static void bgp_zebra_tm_connect(struct thread *t)
                        }
                }
        }
-       thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
-                        &bgp_tm_thread_connect);
+       event_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+                       &bgp_tm_thread_connect);
 }
 
 bool bgp_zebra_tm_chunk_obtained(void)
@@ -1113,8 +1120,8 @@ void bgp_zebra_init_tm_connect(struct bgp *bgp)
        bgp_tm_min = bgp_tm_max = 0;
        bgp_tm_chunk_size = BGP_FLOWSPEC_TABLE_CHUNK;
        bgp_tm_bgp = bgp;
-       thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
-                        &bgp_tm_thread_connect);
+       event_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
+                       &bgp_tm_thread_connect);
 }
 
 int bgp_zebra_get_table_range(uint32_t chunk_size,
@@ -1309,6 +1316,14 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
        uint32_t bos = 0;
        uint32_t exp = 0;
 
+       /*
+        * BGP is installing this route and bgp has been configured
+        * to suppress announcements until the route has been installed
+        * let's set the fact that we expect this route to be installed
+        */
+       if (BGP_SUPPRESS_FIB_ENABLED(bgp))
+               SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
+
        /* Don't try to install if we're not connected to Zebra or Zebra doesn't
         * know of this instance.
         */
@@ -1760,6 +1775,12 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
        struct zapi_route api;
        struct peer *peer;
 
+       /*
+        * If we are withdrawing the route, we don't need to have this
+        * flag set.  So unset it.
+        */
+       UNSET_FLAG(info->net->flags, BGP_NODE_FIB_INSTALL_PENDING);
+
        /* Don't try to install if we're not connected to Zebra or Zebra doesn't
         * know of this instance.
         */
@@ -3443,7 +3464,7 @@ void bgp_if_init(void)
        hook_register_prio(if_del, 0, bgp_if_delete_hook);
 }
 
-void bgp_zebra_init(struct thread_master *master, unsigned short instance)
+void bgp_zebra_init(struct event_loop *master, unsigned short instance)
 {
        zclient_num_connects = 0;