]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #13086 from donaldsharp/suppress_fib_pending
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 27 Mar 2023 18:55:58 +0000 (21:55 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Mar 2023 18:55:58 +0000 (21:55 +0300)
bgpd: Ensure suppress-fib-pending works with network statements

bgpd/bgp_route.c
bgpd/bgp_zebra.c
tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py

index 07bec23b296235d83368aebc1b9f85517605aa30..efdc907971feaee2b118bd1386a108d31f951bca 100644 (file)
@@ -3225,11 +3225,6 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
                        if (bgp_fibupd_safi(safi)
                            && !bgp_option_check(BGP_OPT_NO_FIB)) {
 
-                               if (BGP_SUPPRESS_FIB_ENABLED(bgp)
-                                   && new_select->sub_type == BGP_ROUTE_NORMAL)
-                                       SET_FLAG(dest->flags,
-                                                BGP_NODE_FIB_INSTALL_PENDING);
-
                                if (new_select->type == ZEBRA_ROUTE_BGP
                                    && (new_select->sub_type == BGP_ROUTE_NORMAL
                                        || new_select->sub_type
@@ -3335,10 +3330,6 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
                        || new_select->sub_type == BGP_ROUTE_AGGREGATE
                        || new_select->sub_type == BGP_ROUTE_IMPORTED)) {
 
-                       if (BGP_SUPPRESS_FIB_ENABLED(bgp))
-                               SET_FLAG(dest->flags,
-                                        BGP_NODE_FIB_INSTALL_PENDING);
-
                        /* if this is an evpn imported type-5 prefix,
                         * we need to withdraw the route first to clear
                         * the nh neigh and the RMAC entry.
@@ -4268,18 +4259,6 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                bgp_attr_flush(&new_attr);
                goto filtered;
        }
-       /* The flag BGP_NODE_FIB_INSTALL_PENDING is for the following
-        * condition :
-        * Suppress fib is enabled
-        * BGP_OPT_NO_FIB is not enabled
-        * Route type is BGP_ROUTE_NORMAL (peer learnt routes)
-        * Route is being installed first time (BGP_NODE_FIB_INSTALLED not set)
-        */
-       if (bgp_fibupd_safi(safi) && BGP_SUPPRESS_FIB_ENABLED(bgp)
-           && (sub_type == BGP_ROUTE_NORMAL)
-           && (!bgp_option_check(BGP_OPT_NO_FIB))
-           && (!CHECK_FLAG(dest->flags, BGP_NODE_FIB_INSTALLED)))
-               SET_FLAG(dest->flags, BGP_NODE_FIB_INSTALL_PENDING);
 
        /* If neighbor soo is configured, tag all incoming routes with
         * this SoO tag and then filter out advertisements in
index 3b17c99d6ddd49f466f510bdb8450b57a24af9c5..3d659d48d44d177a292147a285157bda5e1e5d74 100644 (file)
@@ -1309,6 +1309,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 +1768,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.
         */
index ed8e41903f179d9e5f02ce763f6ad0fd2c28b2f9..ef9200b1978115cbc62565b8d44845ee24c69304 100644 (file)
@@ -217,6 +217,20 @@ def test_bgp_allow_as_in():
     assertmsg = '"r2" 192.168.1.1/32 route should be gone'
     assert result is None, assertmsg
 
+def test_local_vs_non_local():
+    tgen = get_topogen()
+
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r2 = tgen.gears["r2"]
+
+    output = json.loads(r2.vtysh_cmd("show bgp ipv4 uni 60.0.0.0/24 json"))
+    paths = output["paths"]
+    for i in range(len(paths)):
+        if "fibPending" in paths[i]:
+            assert(False),  "Route 60.0.0.0/24 should not have fibPending"
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]